diff --git a/.github/workflows/bot_fix_style_comment.yaml b/.github/workflows/bot_fix_style_comment.yaml index d63c2d39771e3..4414eb4b576b5 100644 --- a/.github/workflows/bot_fix_style_comment.yaml +++ b/.github/workflows/bot_fix_style_comment.yaml @@ -9,7 +9,6 @@ jobs: name: Fix style issues from lint if: (github.event.issue.pull_request) && (startsWith(github.event.comment.body, 'bot fix style') || contains(toJSON(github.event.comment.body), '\nbot fix style')) runs-on: ubuntu-latest - continue-on-error: true # do not annoy the user when linting fails, as expected steps: - id: user_permission uses: actions-cool/check-user-permission@v2 @@ -58,7 +57,6 @@ jobs: - name: lint if: steps.user_permission.outputs.require-result == 'true' - continue-on-error: true # allows the following `reviewdog` step to add GitHub suggestions run: | lake exe lint-style --fix @@ -70,14 +68,15 @@ jobs: - name: lint references.bib if: steps.user_permission.outputs.require-result == 'true' - continue-on-error: true # allows the following `reviewdog` step to add GitHub suggestions run: | - ./scripts/lint-bib.sh + # ignoring the return code allows the following `reviewdog` step to add GitHub suggestions + ./scripts/lint-bib.sh || true - name: update {Mathlib, Tactic, Counterexamples, Archive}.lean if: steps.user_permission.outputs.require-result == 'true' - continue-on-error: true # allows the following `reviewdog` step to add GitHub suggestions - run: lake exe mk_all + run: | + # ignoring the return code allows the following `reviewdog` step to add GitHub suggestions + lake exe mk_all || true - name: Commit and push changes if: steps.user_permission.outputs.require-result == 'true' diff --git a/.github/workflows/bot_fix_style_review.yaml b/.github/workflows/bot_fix_style_review.yaml index 3d99da3c124a6..99fa4ae9a7dab 100644 --- a/.github/workflows/bot_fix_style_review.yaml +++ b/.github/workflows/bot_fix_style_review.yaml @@ -10,7 +10,6 @@ jobs: name: Fix style issues from lint if: (startsWith(github.event.review.body, 'bot fix style') || contains(toJSON(github.event.review.body), '\nbot fix style')) runs-on: ubuntu-latest - continue-on-error: true # do not annoy the user when linting fails, as expected steps: - id: user_permission uses: actions-cool/check-user-permission@v2 @@ -64,7 +63,6 @@ jobs: - name: lint if: steps.user_permission.outputs.require-result == 'true' - continue-on-error: true # allows the following `reviewdog` step to add GitHub suggestions run: | lake exe lint-style --fix @@ -76,14 +74,15 @@ jobs: - name: lint references.bib if: steps.user_permission.outputs.require-result == 'true' - continue-on-error: true # allows the following `reviewdog` step to add GitHub suggestions run: | - ./scripts/lint-bib.sh + # ignoring the return code allows the following `reviewdog` step to add GitHub suggestions + ./scripts/lint-bib.sh || true - name: update {Mathlib, Tactic, Counterexamples, Archive}.lean if: steps.user_permission.outputs.require-result == 'true' - continue-on-error: true # allows the following `reviewdog` step to add GitHub suggestions - run: lake exe mk_all + run: | + # ignoring the return code allows the following `reviewdog` step to add GitHub suggestions + lake exe mk_all || true - name: Commit and push changes if: steps.user_permission.outputs.require-result == 'true' diff --git a/.github/workflows/bot_fix_style_review_comment.yaml b/.github/workflows/bot_fix_style_review_comment.yaml index 49d0ca91cb8c2..097b24ba35954 100644 --- a/.github/workflows/bot_fix_style_review_comment.yaml +++ b/.github/workflows/bot_fix_style_review_comment.yaml @@ -9,7 +9,6 @@ jobs: name: Fix style issues from lint if: (startsWith(github.event.comment.body, 'bot fix style') || contains(toJSON(github.event.comment.body), '\nbot fix style')) runs-on: ubuntu-latest - continue-on-error: true # do not annoy the user when linting fails, as expected steps: - id: user_permission uses: actions-cool/check-user-permission@v2 @@ -62,7 +61,6 @@ jobs: - name: lint if: steps.user_permission.outputs.require-result == 'true' - continue-on-error: true # allows the following `reviewdog` step to add GitHub suggestions run: | lake exe lint-style --fix @@ -74,14 +72,15 @@ jobs: - name: lint references.bib if: steps.user_permission.outputs.require-result == 'true' - continue-on-error: true # allows the following `reviewdog` step to add GitHub suggestions run: | - ./scripts/lint-bib.sh + # ignoring the return code allows the following `reviewdog` step to add GitHub suggestions + ./scripts/lint-bib.sh || true - name: update {Mathlib, Tactic, Counterexamples, Archive}.lean if: steps.user_permission.outputs.require-result == 'true' - continue-on-error: true # allows the following `reviewdog` step to add GitHub suggestions - run: lake exe mk_all + run: | + # ignoring the return code allows the following `reviewdog` step to add GitHub suggestions + lake exe mk_all || true - name: Commit and push changes if: steps.user_permission.outputs.require-result == 'true' diff --git a/.github/workflows/dependent-issues.yml b/.github/workflows/dependent-issues.yml index 682c5311f52b0..a73285496116b 100644 --- a/.github/workflows/dependent-issues.yml +++ b/.github/workflows/dependent-issues.yml @@ -18,7 +18,7 @@ jobs: check: runs-on: ubuntu-latest steps: - - uses: z0al/dependent-issues@v1 + - uses: z0al/dependent-issues@75d554cd9494b6e1766bc9d08a81c26444ad5c5a env: # (Required) The token to use to make API calls to GitHub. GITHUB_TOKEN: ${{ secrets.DEPENDENT_ISSUES_TOKEN }} diff --git a/.github/workflows/lean4checker.yml b/.github/workflows/lean4checker.yml index 3152d364350df..c595c278b283b 100644 --- a/.github/workflows/lean4checker.yml +++ b/.github/workflows/lean4checker.yml @@ -69,7 +69,7 @@ jobs: run: | git clone https://github.com/leanprover/lean4checker cd lean4checker - git checkout v4.11.0-rc1 + git checkout v4.11.0 # Now that the git hash is embedded in each olean, # we need to compile lean4checker on the same toolchain cp ../lean-toolchain . diff --git a/.github/workflows/lint_and_suggest_pr.yml b/.github/workflows/lint_and_suggest_pr.yml index 6c8f932fc70a1..409e78ebc223e 100644 --- a/.github/workflows/lint_and_suggest_pr.yml +++ b/.github/workflows/lint_and_suggest_pr.yml @@ -30,14 +30,13 @@ jobs: # if you update this step (or its dependencies), please also update them in bot_fix_style_comment.yaml - name: lint - continue-on-error: true # allows the following `reviewdog` step to add GitHub suggestions run: | lake exe lint-style --fix - name: suggester / lint-style uses: reviewdog/action-suggester@v1 with: - tool_name: lint-style + tool_name: lint-style (comment with "bot fix style" to have the bot commit all style suggestions) - name: Install bibtool run: | @@ -46,14 +45,14 @@ jobs: # if you update this step (or its dependencies), please also update them in bot_fix_style_comment.yaml - name: lint references.bib - continue-on-error: true # allows the following `reviewdog` step to add GitHub suggestions run: | - ./scripts/lint-bib.sh + # ignoring the return code allows the following `reviewdog` step to add GitHub suggestions + ./scripts/lint-bib.sh || true - name: suggester / lint-bib uses: reviewdog/action-suggester@v1 with: - tool_name: lint-bib + tool_name: lint-bib (comment with "bot fix style" to have the bot commit all style suggestions) check_imported: if: github.repository == 'leanprover-community/mathlib4' && github.event.pull_request.draft == false @@ -75,10 +74,11 @@ jobs: # if you update this step (or its dependencies), please also update them in bot_fix_style_comment.yaml - name: update {Mathlib, Tactic, Counterexamples, Archive}.lean - continue-on-error: true # allows the following `reviewdog` step to add GitHub suggestions - run: lake exe mk_all + run: + # ignoring the return code allows the following `reviewdog` step to add GitHub suggestions + lake exe mk_all || true - name: suggester / import list uses: reviewdog/action-suggester@v1 with: - tool_name: imports + tool_name: imports (comment with "bot fix style" to have the bot commit all style suggestions) diff --git a/.github/workflows/maintainer_merge_comment.yml b/.github/workflows/maintainer_merge_comment.yml index 61d41d9ac1375..531d8e9c3b43e 100644 --- a/.github/workflows/maintainer_merge_comment.yml +++ b/.github/workflows/maintainer_merge_comment.yml @@ -20,6 +20,17 @@ jobs: # This feature is only applicable in an issue (or PR) context exit: true # optional. If the action should exit if the user is not part of the team. Defaults to true. + - uses: actions/checkout@v4 + with: + ref: master + - name: Determine Zulip topic + id: determine_topic + run: | + ./scripts/get_tlabel.sh "${PR}" >> "$GITHUB_OUTPUT" + env: + PR: /repos/{owner}/{repo}/issues/{pull_number} + GH_TOKEN: ${{secrets.GITHUB_TOKEN}} + - name: Send message on Zulip uses: zulip/github-actions-zulip/send-message@v1 with: @@ -28,7 +39,7 @@ jobs: organization-url: 'https://leanprover.zulipchat.com' to: 'mathlib reviewers' type: 'stream' - topic: 'maintainer merge' + topic: ${{ steps.determine_topic.outputs.topic }} content: | ${{ format('{0} requested a maintainer merge from comment on PR [#{1}]({2}):', github.event.comment.user.login, github.event.issue.number, github.event.issue.html_url ) }} diff --git a/.github/workflows/maintainer_merge_review.yml b/.github/workflows/maintainer_merge_review.yml index aaefc4ecbdcb2..196d7aa6e1cb7 100644 --- a/.github/workflows/maintainer_merge_review.yml +++ b/.github/workflows/maintainer_merge_review.yml @@ -19,6 +19,17 @@ jobs: token: ${{ secrets.MATHLIB_REVIEWERS_TEAM_KEY }} # required. Personal Access Token with the `read:org` permission exit: true # optional. If the action should exit if the user is not part of the team. Defaults to true. + - uses: actions/checkout@v4 + with: + ref: master + - name: Determine Zulip topic + id: determine_topic + run: | + ./scripts/get_tlabel.sh "${PR}" >> "$GITHUB_OUTPUT" + env: + PR: /repos/{owner}/{repo}/issues/{pull_number} + GH_TOKEN: ${{secrets.GITHUB_TOKEN}} + - name: Send message on Zulip uses: zulip/github-actions-zulip/send-message@v1 with: @@ -27,7 +38,7 @@ jobs: organization-url: 'https://leanprover.zulipchat.com' to: 'mathlib reviewers' type: 'stream' - topic: 'maintainer merge' + topic: ${{ steps.determine_topic.outputs.topic }} content: | ${{ format('{0} requested a maintainer merge from review on PR [#{1}]({2}):', github.event.review.user.login, github.event.pull_request.number, github.event.pull_request.html_url ) }} diff --git a/.github/workflows/maintainer_merge_review_comment.yml b/.github/workflows/maintainer_merge_review_comment.yml index 48ccc466ac1ea..5e104e87dc26d 100644 --- a/.github/workflows/maintainer_merge_review_comment.yml +++ b/.github/workflows/maintainer_merge_review_comment.yml @@ -18,6 +18,17 @@ jobs: token: ${{ secrets.MATHLIB_REVIEWERS_TEAM_KEY }} # required. Personal Access Token with the `read:org` permission exit: true # optional. If the action should exit if the user is not part of the team. Defaults to true. + - uses: actions/checkout@v4 + with: + ref: master + - name: Determine Zulip topic + id: determine_topic + run: | + ./scripts/get_tlabel.sh "${PR}" >> "$GITHUB_OUTPUT" + env: + PR: /repos/{owner}/{repo}/issues/{pull_number} + GH_TOKEN: ${{secrets.GITHUB_TOKEN}} + - name: Send message on Zulip uses: zulip/github-actions-zulip/send-message@v1 with: @@ -26,7 +37,7 @@ jobs: organization-url: 'https://leanprover.zulipchat.com' to: 'mathlib reviewers' type: 'stream' - topic: 'maintainer merge' + topic: ${{ steps.determine_topic.outputs.topic }} content: | ${{ format('{0} requested a maintainer merge from review comment on PR [#{1}]({2}):', github.event.comment.user.login, github.event.pull_request.number, github.event.pull_request.html_url ) }} diff --git a/.github/workflows/nolints.yml b/.github/workflows/nolints.yml index ed9b666b0d7eb..5f90ccdcce587 100644 --- a/.github/workflows/nolints.yml +++ b/.github/workflows/nolints.yml @@ -25,6 +25,9 @@ jobs: echo "$HOME/.elan/bin" >> "${GITHUB_PATH}" - uses: actions/checkout@v4 + with: + ## fetch the whole repository, as we want to push to it later + fetch-depth: 0 - name: print lean and lake versions run: | @@ -61,7 +64,7 @@ jobs: - name: configure git setup run: | - git remote add origin-bot "https://leanprover-community-bot:${{ secrets.UPDATE_NOLINTS_TOKEN }}@github.com/leanprover-community/mathlib.git" + git remote add origin-bot "https://leanprover-community-bot:${{ secrets.UPDATE_NOLINTS_TOKEN }}@github.com/leanprover-community/mathlib4.git" git config user.email "leanprover.community@gmail.com" git config user.name "leanprover-community-bot" diff --git a/.github/workflows/update_dependencies.yml b/.github/workflows/update_dependencies.yml index 885bef03a2be2..fa5edb339177f 100644 --- a/.github/workflows/update_dependencies.yml +++ b/.github/workflows/update_dependencies.yml @@ -19,25 +19,39 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - token: "${{ secrets.NIGHTLY_TESTING }}" + token: "${{ secrets.UPDATE_DEPENDENCIES_TOKEN }}" + + - name: Get PR and labels + id: PR # all the steps below are skipped if 'ready-to-merge' is in the list of labels found here + uses: 8BitJonny/gh-get-current-pr@3.0.0 + # TODO: this may not work properly if the same commit is pushed to multiple branches: + # https://github.com/8BitJonny/gh-get-current-pr/issues/8 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + # Only return if PR is still open + filterOutClosed: true - name: Configure Git User + if: ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') }} run: | git config user.name "leanprover-community-mathlib4-bot" git config user.email "leanprover-community-mathlib4-bot@users.noreply.github.com" - name: Update dependencies + if: ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') }} run: lake update - name: Generate PR title + if: ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') }} run: | echo "timestamp=$(date -u +"%Y-%m-%d-%H-%M")" >> "$GITHUB_ENV" echo "pr_title=chore: update Mathlib dependencies $(date -u +"%Y-%m-%d")" >> "$GITHUB_ENV" - name: Create Pull Request + if: ${{ !contains(steps.PR.outputs.pr_labels, 'ready-to-merge') }} uses: peter-evans/create-pull-request@v6 with: - token: "${{ secrets.NIGHTLY_TESTING }}" + token: "${{ secrets.UPDATE_DEPENDENCIES_TOKEN }}" commit-message: "chore: update Mathlib dependencies ${{ env.timestamp }}" # this branch is referenced in update_dependencies_zulip.yml branch: "update-dependencies-bot-use-only" diff --git a/.github/workflows/update_dependencies_zulip.yml b/.github/workflows/update_dependencies_zulip.yml index 466b06668f31f..1f8a3b507374b 100644 --- a/.github/workflows/update_dependencies_zulip.yml +++ b/.github/workflows/update_dependencies_zulip.yml @@ -1,7 +1,5 @@ name: Monitor Dependency Update Failures -# This action currently uses the NIGHTLY_TESTING secret, but could be moved to a separate secret. - on: workflow_run: workflows: ["continuous integration"] @@ -20,7 +18,7 @@ jobs: uses: actions/github-script@v7 id: construct_message with: - github-token: ${{ secrets.NIGHTLY_TESTING }} + github-token: ${{ secrets.UPDATE_DEPENDENCIES_TOKEN }} result-encoding: string script: | const owner = context.repo.owner, repo = context.repo.repo; diff --git a/Counterexamples/CliffordAlgebraNotInjective.lean b/Counterexamples/CliffordAlgebraNotInjective.lean index b84245b0d53cc..38955c69d5249 100644 --- a/Counterexamples/CliffordAlgebraNotInjective.lean +++ b/Counterexamples/CliffordAlgebraNotInjective.lean @@ -132,7 +132,7 @@ theorem sq_zero_of_αβγ_mul {x : K} : α * β * γ * x = 0 → x * x = 0 := by rw [Ideal.Quotient.eq_zero_iff_mem, Ideal.Quotient.eq_zero_iff_mem] exact mul_self_mem_kIdeal_of_X0_X1_X2_mul_mem -/-- Though `αβγ` is not itself zero-/ +/-- Though `αβγ` is not itself zero -/ theorem αβγ_ne_zero : α * β * γ ≠ 0 := fun h => X0_X1_X2_not_mem_kIdeal <| Ideal.Quotient.eq_zero_iff_mem.1 h diff --git a/LongestPole/SpeedCenterJson.lean b/LongestPole/SpeedCenterJson.lean index 89bfb54a07ffa..63cf423acecec 100644 --- a/LongestPole/SpeedCenterJson.lean +++ b/LongestPole/SpeedCenterJson.lean @@ -47,7 +47,7 @@ structure RunResponse where run : Run deriving ToJson, FromJson -/-- The error response-/ +/-- The error response -/ structure ErrorMessage where repo_id : String message : String diff --git a/Mathlib.lean b/Mathlib.lean index b14e2fda0255a..3b790ce929268 100644 --- a/Mathlib.lean +++ b/Mathlib.lean @@ -583,6 +583,7 @@ import Mathlib.Algebra.Order.Group.Unbundled.Int import Mathlib.Algebra.Order.Group.Units import Mathlib.Algebra.Order.GroupWithZero.Action.Synonym import Mathlib.Algebra.Order.GroupWithZero.Canonical +import Mathlib.Algebra.Order.GroupWithZero.Submonoid import Mathlib.Algebra.Order.GroupWithZero.Synonym import Mathlib.Algebra.Order.GroupWithZero.Unbundled import Mathlib.Algebra.Order.GroupWithZero.WithZero @@ -817,6 +818,7 @@ import Mathlib.AlgebraicGeometry.Morphisms.Affine import Mathlib.AlgebraicGeometry.Morphisms.Basic import Mathlib.AlgebraicGeometry.Morphisms.ClosedImmersion import Mathlib.AlgebraicGeometry.Morphisms.Constructors +import Mathlib.AlgebraicGeometry.Morphisms.FinitePresentation import Mathlib.AlgebraicGeometry.Morphisms.FiniteType import Mathlib.AlgebraicGeometry.Morphisms.IsIso import Mathlib.AlgebraicGeometry.Morphisms.OpenImmersion @@ -1118,6 +1120,7 @@ import Mathlib.Analysis.InnerProductSpace.ConformalLinearMap import Mathlib.Analysis.InnerProductSpace.Dual import Mathlib.Analysis.InnerProductSpace.EuclideanDist import Mathlib.Analysis.InnerProductSpace.GramSchmidtOrtho +import Mathlib.Analysis.InnerProductSpace.JointEigenspace import Mathlib.Analysis.InnerProductSpace.LaxMilgram import Mathlib.Analysis.InnerProductSpace.LinearPMap import Mathlib.Analysis.InnerProductSpace.MeanErgodic @@ -1366,6 +1369,7 @@ import Mathlib.CategoryTheory.Adjunction.Opposites import Mathlib.CategoryTheory.Adjunction.Over import Mathlib.CategoryTheory.Adjunction.Reflective import Mathlib.CategoryTheory.Adjunction.Restrict +import Mathlib.CategoryTheory.Adjunction.Triple import Mathlib.CategoryTheory.Adjunction.Unique import Mathlib.CategoryTheory.Adjunction.Whiskering import Mathlib.CategoryTheory.Balanced @@ -3379,6 +3383,7 @@ import Mathlib.NumberTheory.LSeries.Convergence import Mathlib.NumberTheory.LSeries.Convolution import Mathlib.NumberTheory.LSeries.Deriv import Mathlib.NumberTheory.LSeries.Dirichlet +import Mathlib.NumberTheory.LSeries.DirichletContinuation import Mathlib.NumberTheory.LSeries.HurwitzZeta import Mathlib.NumberTheory.LSeries.HurwitzZetaEven import Mathlib.NumberTheory.LSeries.HurwitzZetaOdd @@ -3386,6 +3391,7 @@ import Mathlib.NumberTheory.LSeries.HurwitzZetaValues import Mathlib.NumberTheory.LSeries.Linearity import Mathlib.NumberTheory.LSeries.MellinEqDirichlet import Mathlib.NumberTheory.LSeries.RiemannZeta +import Mathlib.NumberTheory.LSeries.ZMod import Mathlib.NumberTheory.LegendreSymbol.AddCharacter import Mathlib.NumberTheory.LegendreSymbol.Basic import Mathlib.NumberTheory.LegendreSymbol.GaussEisensteinLemmas @@ -4401,6 +4407,7 @@ import Mathlib.Topology.Category.FinTopCat import Mathlib.Topology.Category.LightProfinite.AsLimit import Mathlib.Topology.Category.LightProfinite.Basic import Mathlib.Topology.Category.LightProfinite.EffectiveEpi +import Mathlib.Topology.Category.LightProfinite.Extend import Mathlib.Topology.Category.LightProfinite.Limits import Mathlib.Topology.Category.LightProfinite.Sequence import Mathlib.Topology.Category.Locale @@ -4408,6 +4415,7 @@ import Mathlib.Topology.Category.Profinite.AsLimit import Mathlib.Topology.Category.Profinite.Basic import Mathlib.Topology.Category.Profinite.CofilteredLimit import Mathlib.Topology.Category.Profinite.EffectiveEpi +import Mathlib.Topology.Category.Profinite.Extend import Mathlib.Topology.Category.Profinite.Limits import Mathlib.Topology.Category.Profinite.Nobeling import Mathlib.Topology.Category.Profinite.Product diff --git a/Mathlib/Algebra/Algebra/Hom.lean b/Mathlib/Algebra/Algebra/Hom.lean index 0f526f05a2fe1..d15f9fc46298b 100644 --- a/Mathlib/Algebra/Algebra/Hom.lean +++ b/Mathlib/Algebra/Algebra/Hom.lean @@ -39,7 +39,7 @@ infixr:25 " →ₐ " => AlgHom _ notation:25 A " →ₐ[" R "] " B => AlgHom R A B /-- `AlgHomClass F R A B` asserts `F` is a type of bundled algebra homomorphisms -from `A` to `B`. -/ +from `A` to `B`. -/ class AlgHomClass (F : Type*) (R A B : outParam Type*) [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B] [FunLike F A B] extends RingHomClass F A B : Prop where diff --git a/Mathlib/Algebra/Algebra/NonUnitalHom.lean b/Mathlib/Algebra/Algebra/NonUnitalHom.lean index b991f1ec71416..34a5518dc4de3 100644 --- a/Mathlib/Algebra/Algebra/NonUnitalHom.lean +++ b/Mathlib/Algebra/Algebra/NonUnitalHom.lean @@ -64,7 +64,7 @@ notation:25 A " →ₙₐ[" R "] " B => NonUnitalAlgHom (MonoidHom.id R) A B attribute [nolint docBlame] NonUnitalAlgHom.toMulHom /-- `NonUnitalAlgSemiHomClass F φ A B` asserts `F` is a type of bundled algebra homomorphisms -from `A` to `B` which are equivariant with respect to `φ`. -/ +from `A` to `B` which are equivariant with respect to `φ`. -/ class NonUnitalAlgSemiHomClass (F : Type*) {R S : outParam Type*} [Monoid R] [Monoid S] (φ : outParam (R →* S)) (A B : outParam Type*) [NonUnitalNonAssocSemiring A] [NonUnitalNonAssocSemiring B] @@ -483,7 +483,7 @@ variable (R : Type*) {S A B : Type*} [Monoid R] [Monoid S] [IsScalarTower R S A] [IsScalarTower R S B] /-- If a monoid `R` acts on another monoid `S`, then a non-unital algebra homomorphism -over `S` can be viewed as a non-unital algebra homomorphism over `R`. -/ +over `S` can be viewed as a non-unital algebra homomorphism over `R`. -/ def restrictScalars (f : A →ₙₐ[S] B) : A →ₙₐ[R] B := { (f : A →ₙ+* B) with map_smul' := fun r x ↦ by have := map_smul f (r • 1) x; simpa } diff --git a/Mathlib/Algebra/Algebra/Operations.lean b/Mathlib/Algebra/Algebra/Operations.lean index d0bb76295683d..53d2a0737daf3 100644 --- a/Mathlib/Algebra/Algebra/Operations.lean +++ b/Mathlib/Algebra/Algebra/Operations.lean @@ -359,12 +359,12 @@ theorem mul_smul_mul_eq_smul_mul_smul (x y : R) : (x * y) • (M * N) = (x • M · rintro ⟨_, hx, rfl⟩ rw [DistribMulAction.toLinearMap_apply] refine Submodule.mul_induction_on hx (fun m hm n hn ↦ ?_) (fun _ _ hn hm ↦ ?_) - · rw [← smul_mul_smul x y m n] + · rw [mul_smul_mul_comm] exact mul_mem_mul (smul_mem_pointwise_smul m x M hm) (smul_mem_pointwise_smul n y N hn) · rw [smul_add] exact Submodule.add_mem _ hn hm · rintro _ ⟨m, hm, rfl⟩ _ ⟨n, hn, rfl⟩ - erw [smul_mul_smul x y m n] + erw [smul_mul_smul_comm] exact smul_mem_pointwise_smul _ _ _ (mul_mem_mul hm hn) /-- Sub-R-modules of an R-algebra form an idempotent semiring. -/ diff --git a/Mathlib/Algebra/Algebra/Spectrum.lean b/Mathlib/Algebra/Algebra/Spectrum.lean index 2919c52895656..2b7e28f8e2c29 100644 --- a/Mathlib/Algebra/Algebra/Spectrum.lean +++ b/Mathlib/Algebra/Algebra/Spectrum.lean @@ -53,7 +53,7 @@ local notation "↑ₐ" => algebraMap R A -- definition and basic properties /-- Given a commutative ring `R` and an `R`-algebra `A`, the *resolvent set* of `a : A` is the `Set R` consisting of those `r : R` for which `r•1 - a` is a unit of the -algebra `A`. -/ +algebra `A`. -/ def resolventSet (a : A) : Set R := {r : R | IsUnit (↑ₐ r - a)} @@ -61,7 +61,7 @@ def resolventSet (a : A) : Set R := is the `Set R` consisting of those `r : R` for which `r•1 - a` is not a unit of the algebra `A`. -The spectrum is simply the complement of the resolvent set. -/ +The spectrum is simply the complement of the resolvent set. -/ def spectrum (a : A) : Set R := (resolventSet R a)ᶜ @@ -113,6 +113,10 @@ theorem zero_not_mem_iff {a : A} : (0 : R) ∉ σ a ↔ IsUnit a := by alias ⟨isUnit_of_zero_not_mem, zero_not_mem⟩ := spectrum.zero_not_mem_iff +@[simp] +lemma _root_.Units.zero_not_mem_spectrum (a : Aˣ) : 0 ∉ spectrum R (a : A) := + spectrum.zero_not_mem R a.isUnit + lemma subset_singleton_zero_compl {a : A} (ha : IsUnit a) : spectrum R a ⊆ {0}ᶜ := Set.subset_compl_singleton_iff.mpr <| spectrum.zero_not_mem R ha diff --git a/Mathlib/Algebra/BigOperators/Fin.lean b/Mathlib/Algebra/BigOperators/Fin.lean index 42ddb80a5d4b1..f336a553c7f57 100644 --- a/Mathlib/Algebra/BigOperators/Fin.lean +++ b/Mathlib/Algebra/BigOperators/Fin.lean @@ -86,11 +86,16 @@ theorem prod_univ_get' [CommMonoid β] (l : List α) (f : α → β) : ∏ i : Fin l.length, f l[i.1] = (l.map f).prod := by simp [Finset.prod_eq_multiset_prod] -@[to_additive] +@[to_additive (attr := simp)] theorem prod_cons [CommMonoid β] {n : ℕ} (x : β) (f : Fin n → β) : (∏ i : Fin n.succ, (cons x f : Fin n.succ → β) i) = x * ∏ i : Fin n, f i := by simp_rw [prod_univ_succ, cons_zero, cons_succ] +@[to_additive (attr := simp)] +theorem prod_snoc [CommMonoid β] {n : ℕ} (x : β) (f : Fin n → β) : + (∏ i : Fin n.succ, (snoc f x : Fin n.succ → β) i) = (∏ i : Fin n, f i) * x := by + simp [prod_univ_castSucc] + @[to_additive sum_univ_one] theorem prod_univ_one [CommMonoid β] (f : Fin 1 → β) : ∏ i, f i = f 0 := by simp diff --git a/Mathlib/Algebra/BigOperators/Finprod.lean b/Mathlib/Algebra/BigOperators/Finprod.lean index 9a2dc40b1b77f..751e627de3492 100644 --- a/Mathlib/Algebra/BigOperators/Finprod.lean +++ b/Mathlib/Algebra/BigOperators/Finprod.lean @@ -750,7 +750,7 @@ theorem finprod_mem_insert_one (h : f a = 1) : ∏ᶠ i ∈ insert a s, f i = finprod_mem_insert_of_eq_one_if_not_mem fun _ => h /-- If the multiplicative support of `f` is finite, then for every `x` in the domain of `f`, `f x` -divides `finprod f`. -/ +divides `finprod f`. -/ theorem finprod_mem_dvd {f : α → N} (a : α) (hf : (mulSupport f).Finite) : f a ∣ finprod f := by by_cases ha : a ∈ mulSupport f · rw [finprod_eq_prod_of_mulSupport_toFinset_subset f hf (Set.Subset.refl _)] diff --git a/Mathlib/Algebra/BigOperators/Group/Finset.lean b/Mathlib/Algebra/BigOperators/Group/Finset.lean index e528ac15b6c6b..84b2a9a1ee80b 100644 --- a/Mathlib/Algebra/BigOperators/Group/Finset.lean +++ b/Mathlib/Algebra/BigOperators/Group/Finset.lean @@ -540,7 +540,7 @@ theorem prod_biUnion [DecidableEq α] {s : Finset γ} {t : γ → Finset α} rw [← disjiUnion_eq_biUnion _ _ hs, prod_disjiUnion] /-- Product over a sigma type equals the product of fiberwise products. For rewriting -in the reverse direction, use `Finset.prod_sigma'`. -/ +in the reverse direction, use `Finset.prod_sigma'`. -/ @[to_additive "Sum over a sigma type equals the sum of fiberwise sums. For rewriting in the reverse direction, use `Finset.sum_sigma'`"] theorem prod_sigma {σ : α → Type*} (s : Finset α) (t : ∀ a, Finset (σ a)) (f : Sigma σ → β) : @@ -1494,7 +1494,7 @@ theorem prod_pow (s : Finset α) (n : ℕ) (f : α → β) : ∏ x ∈ s, f x ^ Multiset.prod_map_pow @[to_additive sum_nsmul_assoc] -lemma prod_pow_eq_pow_sum (s : Finset ι) (f : ι → ℕ) (a : β) : +lemma prod_pow_eq_pow_sum (s : Finset ι) (f : ι → ℕ) (a : β) : ∏ i ∈ s, a ^ f i = a ^ ∑ i ∈ s, f i := cons_induction (by simp) (fun _ _ _ _ ↦ by simp [prod_cons, sum_cons, pow_add, *]) s @@ -2260,3 +2260,5 @@ theorem Finset.sum_sym2_filter_not_isDiag {ι α} [LinearOrder ι] [AddCommMonoi simp [and_assoc] · rintro ⟨⟨i₁, j₁⟩, hij₁⟩ simp + +set_option linter.style.longFile 2400 diff --git a/Mathlib/Algebra/BigOperators/Ring.lean b/Mathlib/Algebra/BigOperators/Ring.lean index 2253d0bb0465c..0cf28cc97f8a8 100644 --- a/Mathlib/Algebra/BigOperators/Ring.lean +++ b/Mathlib/Algebra/BigOperators/Ring.lean @@ -239,7 +239,7 @@ lemma prod_sub_ordered [LinearOrder ι] (s : Finset ι) (f g : ι → α) : simp /-- `∏ i, (1 - f i) = 1 - ∑ i, f i * (∏ j < i, 1 - f j)`. This formula is useful in construction of -a partition of unity from a collection of “bump” functions. -/ +a partition of unity from a collection of “bump” functions. -/ theorem prod_one_sub_ordered [LinearOrder ι] (s : Finset ι) (f : ι → α) : ∏ i ∈ s, (1 - f i) = 1 - ∑ i ∈ s, f i * ∏ j ∈ s.filter (· < i), (1 - f j) := by rw [prod_sub_ordered] diff --git a/Mathlib/Algebra/Category/Grp/FilteredColimits.lean b/Mathlib/Algebra/Category/Grp/FilteredColimits.lean index cd3489812cf51..b79cc51e0f2ed 100644 --- a/Mathlib/Algebra/Category/Grp/FilteredColimits.lean +++ b/Mathlib/Algebra/Category/Grp/FilteredColimits.lean @@ -58,7 +58,7 @@ abbrev G.mk : (Σ j, F.obj j) → G.{v, u} F := theorem G.mk_eq (x y : Σ j, F.obj j) (h : ∃ (k : J) (f : x.1 ⟶ k) (g : y.1 ⟶ k), F.map f x.2 = F.map g y.2) : G.mk.{v, u} F x = G.mk F y := - Quot.EqvGen_sound (Types.FilteredColimit.eqvGen_quot_rel_of_rel (F ⋙ forget Grp) x y h) + Quot.eqvGen_sound (Types.FilteredColimit.eqvGen_quot_rel_of_rel (F ⋙ forget Grp) x y h) /-- The "unlifted" version of taking inverses in the colimit. -/ @[to_additive "The \"unlifted\" version of negation in the colimit."] diff --git a/Mathlib/Algebra/Category/Grp/Limits.lean b/Mathlib/Algebra/Category/Grp/Limits.lean index f605284f69e1f..1f73a158c1bf6 100644 --- a/Mathlib/Algebra/Category/Grp/Limits.lean +++ b/Mathlib/Algebra/Category/Grp/Limits.lean @@ -126,7 +126,7 @@ instance hasLimit : HasLimit F := end /-- A functor `F : J ⥤ Grp.{u}` has a limit iff `(F ⋙ forget Grp).sections` is -`u`-small. -/ +`u`-small. -/ @[to_additive "A functor `F : J ⥤ AddGrp.{u}` has a limit iff `(F ⋙ forget AddGrp).sections` is `u`-small."] lemma hasLimit_iff_small_sections : @@ -281,7 +281,7 @@ instance hasLimit : HasLimit F := end /-- A functor `F : J ⥤ CommGrp.{u}` has a limit iff `(F ⋙ forget CommGrp).sections` is -`u`-small. -/ +`u`-small. -/ @[to_additive "A functor `F : J ⥤ AddCommGrp.{u}` has a limit iff `(F ⋙ forget AddCommGrp).sections` is `u`-small."] lemma hasLimit_iff_small_sections : diff --git a/Mathlib/Algebra/Category/ModuleCat/FilteredColimits.lean b/Mathlib/Algebra/Category/ModuleCat/FilteredColimits.lean index 2d0de3a1c067e..16abcd3247283 100644 --- a/Mathlib/Algebra/Category/ModuleCat/FilteredColimits.lean +++ b/Mathlib/Algebra/Category/ModuleCat/FilteredColimits.lean @@ -51,7 +51,7 @@ abbrev M.mk : (Σ j, F.obj j) → M F := theorem M.mk_eq (x y : Σ j, F.obj j) (h : ∃ (k : J) (f : x.1 ⟶ k) (g : y.1 ⟶ k), F.map f x.2 = F.map g y.2) : M.mk F x = M.mk F y := - Quot.EqvGen_sound (Types.FilteredColimit.eqvGen_quot_rel_of_rel (F ⋙ forget (ModuleCat R)) x y h) + Quot.eqvGen_sound (Types.FilteredColimit.eqvGen_quot_rel_of_rel (F ⋙ forget (ModuleCat R)) x y h) /-- The "unlifted" version of scalar multiplication in the colimit. -/ def colimitSMulAux (r : R) (x : Σ j, F.obj j) : M F := diff --git a/Mathlib/Algebra/Category/ModuleCat/Free.lean b/Mathlib/Algebra/Category/ModuleCat/Free.lean index 7c67bb3e86b4f..ce028e860756f 100644 --- a/Mathlib/Algebra/Category/ModuleCat/Free.lean +++ b/Mathlib/Algebra/Category/ModuleCat/Free.lean @@ -14,12 +14,12 @@ This file proves results about linear independence and span in exact sequences o ## Main theorems * `linearIndependent_shortExact`: Given a short exact sequence `0 ⟶ X₁ ⟶ X₂ ⟶ X₃ ⟶ 0` of - `R`-modules and linearly independent families `v : ι → X₁` and `w : ι' → X₃`, we get a linearly + `R`-modules and linearly independent families `v : ι → X₁` and `w : ι' → X₃`, we get a linearly independent family `ι ⊕ ι' → X₂` * `span_rightExact`: Given an exact sequence `X₁ ⟶ X₂ ⟶ X₃ ⟶ 0` of `R`-modules and spanning - families `v : ι → X₁` and `w : ι' → X₃`, we get a spanning family `ι ⊕ ι' → X₂` + families `v : ι → X₁` and `w : ι' → X₃`, we get a spanning family `ι ⊕ ι' → X₂` * Using `linearIndependent_shortExact` and `span_rightExact`, we prove `free_shortExact`: In a - short exact sequence `0 ⟶ X₁ ⟶ X₂ ⟶ X₃ ⟶ 0` where `X₁` and `X₃` are free, `X₂` is free as well. + short exact sequence `0 ⟶ X₁ ⟶ X₂ ⟶ X₃ ⟶ 0` where `X₁` and `X₃` are free, `X₂` is free as well. ## Tags linear algebra, module, free @@ -61,8 +61,8 @@ include hv hm in v| u| w| ι → ι ⊕ ι' ← ι' ``` -where the top row is an exact sequence of modules and the maps on the bottom are `Sum.inl` and -`Sum.inr`. If `u` is injective and `v` and `w` are linearly independent, then `u` is linearly +where the top row is an exact sequence of modules and the maps on the bottom are `Sum.inl` and +`Sum.inr`. If `u` is injective and `v` and `w` are linearly independent, then `u` is linearly independent. -/ theorem linearIndependent_leftExact : LinearIndependent R u := by rw [linearIndependent_sum] @@ -76,7 +76,7 @@ end include hS' hv in /-- Given a short exact sequence `0 ⟶ X₁ ⟶ X₂ ⟶ X₃ ⟶ 0` of `R`-modules and linearly independent - families `v : ι → N` and `w : ι' → P`, we get a linearly independent family `ι ⊕ ι' → M` -/ + families `v : ι → N` and `w : ι' → P`, we get a linearly independent family `ι ⊕ ι' → M` -/ theorem linearIndependent_shortExact {w : ι' → S.X₃} (hw : LinearIndependent R w) : LinearIndependent R (Sum.elim (S.f ∘ v) (S.g.toFun.invFun ∘ w)) := by apply linearIndependent_leftExact hS'.exact hv _ hS'.mono_f rfl @@ -98,8 +98,8 @@ include hS in v| u| w| ι → ι ⊕ ι' ← ι' ``` -where the top row is an exact sequence of modules and the maps on the bottom are `Sum.inl` and -`Sum.inr`. If `v` spans `X₁` and `w` spans `X₃`, then `u` spans `X₂`. -/ +where the top row is an exact sequence of modules and the maps on the bottom are `Sum.inl` and +`Sum.inr`. If `v` spans `X₁` and `w` spans `X₃`, then `u` spans `X₂`. -/ theorem span_exact {β : Type*} {u : ι ⊕ β → S.X₂} (huv : u ∘ Sum.inl = S.f ∘ v) (hv : ⊤ ≤ span R (range v)) (hw : ⊤ ≤ span R (range (S.g ∘ u ∘ Sum.inr))) : @@ -135,7 +135,7 @@ theorem span_exact {β : Type*} {u : ι ⊕ β → S.X₂} (huv : u ∘ Sum.inl include hS in /-- Given an exact sequence `X₁ ⟶ X₂ ⟶ X₃ ⟶ 0` of `R`-modules and spanning - families `v : ι → X₁` and `w : ι' → X₃`, we get a spanning family `ι ⊕ ι' → X₂` -/ + families `v : ι → X₁` and `w : ι' → X₃`, we get a spanning family `ι ⊕ ι' → X₂` -/ theorem span_rightExact {w : ι' → S.X₃} (hv : ⊤ ≤ span R (range v)) (hw : ⊤ ≤ span R (range w)) (hE : Epi S.g) : ⊤ ≤ span R (range (Sum.elim (S.f ∘ v) (S.g.toFun.invFun ∘ w))) := by @@ -149,8 +149,8 @@ theorem span_rightExact {w : ι' → S.X₃} (hv : ⊤ ≤ span R (range v)) end Span -/-- In a short exact sequence `0 ⟶ X₁ ⟶ X₂ ⟶ X₃ ⟶ 0`, given bases for `X₁` and `X₃` -indexed by `ι` and `ι'` respectively, we get a basis for `X₂` indexed by `ι ⊕ ι'`. -/ +/-- In a short exact sequence `0 ⟶ X₁ ⟶ X₂ ⟶ X₃ ⟶ 0`, given bases for `X₁` and `X₃` +indexed by `ι` and `ι'` respectively, we get a basis for `X₂` indexed by `ι ⊕ ι'`. -/ noncomputable def Basis.ofShortExact (bN : Basis ι R S.X₁) (bP : Basis ι' R S.X₃) : Basis (ι ⊕ ι') R S.X₂ := @@ -159,7 +159,7 @@ def Basis.ofShortExact include hS' -/-- In a short exact sequence `0 ⟶ X₁ ⟶ X₂ ⟶ X₃ ⟶ 0`, if `X₁` and `X₃` are free, +/-- In a short exact sequence `0 ⟶ X₁ ⟶ X₂ ⟶ X₃ ⟶ 0`, if `X₁` and `X₃` are free, then `X₂` is free. -/ theorem free_shortExact [Module.Free R S.X₁] [Module.Free R S.X₃] : Module.Free R S.X₂ := diff --git a/Mathlib/Algebra/Category/ModuleCat/Presheaf/Abelian.lean b/Mathlib/Algebra/Category/ModuleCat/Presheaf/Abelian.lean index 80d80075b9e8a..42747bed79af5 100644 --- a/Mathlib/Algebra/Category/ModuleCat/Presheaf/Abelian.lean +++ b/Mathlib/Algebra/Category/ModuleCat/Presheaf/Abelian.lean @@ -22,7 +22,7 @@ namespace PresheafOfModules variable {C : Type u₁} [Category.{v₁} C] (R : Cᵒᵖ ⥤ RingCat.{u}) noncomputable instance : NormalEpiCategory (PresheafOfModules.{v} R) where - normalEpiOfEpi p _ := NormalEpi.mk _ (kernel.ι p) (kernel.condition _) + normalEpiOfEpi p _ := NormalEpi.mk _ (kernel.ι p) (kernel.condition _) (evaluationJointlyReflectsColimits _ _ (fun _ => Abelian.isColimitMapCoconeOfCokernelCoforkOfπ _ _)) diff --git a/Mathlib/Algebra/Category/MonCat/FilteredColimits.lean b/Mathlib/Algebra/Category/MonCat/FilteredColimits.lean index f565afec21772..9624ff56fed29 100644 --- a/Mathlib/Algebra/Category/MonCat/FilteredColimits.lean +++ b/Mathlib/Algebra/Category/MonCat/FilteredColimits.lean @@ -56,7 +56,7 @@ noncomputable abbrev M.mk : (Σ j, F.obj j) → M.{v, u} F := theorem M.mk_eq (x y : Σ j, F.obj j) (h : ∃ (k : J) (f : x.1 ⟶ k) (g : y.1 ⟶ k), F.map f x.2 = F.map g y.2) : M.mk.{v, u} F x = M.mk F y := - Quot.EqvGen_sound (Types.FilteredColimit.eqvGen_quot_rel_of_rel (F ⋙ forget MonCat) x y h) + Quot.eqvGen_sound (Types.FilteredColimit.eqvGen_quot_rel_of_rel (F ⋙ forget MonCat) x y h) variable [IsFiltered J] diff --git a/Mathlib/Algebra/ContinuedFractions/Basic.lean b/Mathlib/Algebra/ContinuedFractions/Basic.lean index cdf31ebeb15da..6a34dbcebe789 100644 --- a/Mathlib/Algebra/ContinuedFractions/Basic.lean +++ b/Mathlib/Algebra/ContinuedFractions/Basic.lean @@ -41,7 +41,7 @@ numerics, number theory, approximations, fractions -- Fix a carrier `α`. variable (α : Type*) -/-!### Definitions-/ +/-!### Definitions -/ -- Porting note: Originally `protected structure GenContFract.Pair` /-- We collect a partial numerator `aᵢ` and partial denominator `bᵢ` in a pair `⟨aᵢ, bᵢ⟩`. -/ diff --git a/Mathlib/Algebra/EuclideanDomain/Defs.lean b/Mathlib/Algebra/EuclideanDomain/Defs.lean index 81b62ab8bf111..8a0022c6dee04 100644 --- a/Mathlib/Algebra/EuclideanDomain/Defs.lean +++ b/Mathlib/Algebra/EuclideanDomain/Defs.lean @@ -67,7 +67,7 @@ universe u satisfying `b * (a / b) + a % b = a`. The definition of a Euclidean domain usually includes a valuation function `R → ℕ`. This definition is slightly generalised to include a well founded relation - `r` with the property that `r (a % b) b`, instead of a valuation. -/ + `r` with the property that `r (a % b) b`, instead of a valuation. -/ class EuclideanDomain (R : Type u) extends CommRing R, Nontrivial R where /-- A division function (denoted `/`) on `R`. This satisfies the property `b * (a / b) + a % b = a`, where `%` denotes `remainder`. -/ diff --git a/Mathlib/Algebra/Field/Subfield.lean b/Mathlib/Algebra/Field/Subfield.lean index b304f131e2f96..8d57654e441ac 100644 --- a/Mathlib/Algebra/Field/Subfield.lean +++ b/Mathlib/Algebra/Field/Subfield.lean @@ -320,7 +320,7 @@ instance toDivisionRing (s : Subfield K) : DivisionRing s := instance toField {K} [Field K] (s : Subfield K) : Field s := Subtype.coe_injective.field ((↑) : s → K) rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) - (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (by intros; rfl) (fun _ => rfl) + (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (by intros; rfl) (fun _ => rfl) (fun _ => rfl) (by intros; rfl) fun _ => rfl @[simp, norm_cast] diff --git a/Mathlib/Algebra/FreeAlgebra.lean b/Mathlib/Algebra/FreeAlgebra.lean index b10a44ea077c2..f5a0544bbff92 100644 --- a/Mathlib/Algebra/FreeAlgebra.lean +++ b/Mathlib/Algebra/FreeAlgebra.lean @@ -151,7 +151,7 @@ namespace FreeAlgebra attribute [local instance] Pre.hasCoeGenerator Pre.hasCoeSemiring Pre.hasMul Pre.hasAdd Pre.hasZero Pre.hasOne Pre.hasSMul -/-! Define the basic operations-/ +/-! Define the basic operations -/ instance instSMul {A} [CommSemiring A] [Algebra R A] : SMul R (FreeAlgebra A X) where smul r := Quot.map (HMul.hMul (algebraMap R A r : Pre A X)) fun _ _ ↦ Rel.mul_compat_right diff --git a/Mathlib/Algebra/GCDMonoid/Basic.lean b/Mathlib/Algebra/GCDMonoid/Basic.lean index 71a5cdc6fa600..e7ff47b1fe976 100644 --- a/Mathlib/Algebra/GCDMonoid/Basic.lean +++ b/Mathlib/Algebra/GCDMonoid/Basic.lean @@ -478,7 +478,7 @@ theorem dvd_mul_gcd_iff_dvd_mul [GCDMonoid α] {m n k : α} : k ∣ m * gcd k n Note: In general, this representation is highly non-unique. -See `Nat.prodDvdAndDvdOfDvdProd` for a constructive version on `ℕ`. -/ +See `Nat.prodDvdAndDvdOfDvdProd` for a constructive version on `ℕ`. -/ instance [h : Nonempty (GCDMonoid α)] : DecompositionMonoid α where primal k m n H := by cases h diff --git a/Mathlib/Algebra/Group/Action/Defs.lean b/Mathlib/Algebra/Group/Action/Defs.lean index 220aa2d2f5e5c..91a530d0f239f 100644 --- a/Mathlib/Algebra/Group/Action/Defs.lean +++ b/Mathlib/Algebra/Group/Action/Defs.lean @@ -354,6 +354,24 @@ lemma smul_smul_smul_comm [SMul α β] [SMul α γ] [SMul β δ] [SMul α δ] [S [IsScalarTower α β δ] [IsScalarTower α γ δ] [SMulCommClass β γ δ] (a : α) (b : β) (c : γ) (d : δ) : (a • b) • c • d = (a • c) • b • d := by rw [smul_assoc, smul_assoc, smul_comm b] +/-- Note that the `IsScalarTower α β β` and `SMulCommClass α β β` typeclass arguments are usually +satisfied by `Algebra α β`. -/ +@[to_additive] +lemma smul_mul_smul_comm [Mul α] [Mul β] [SMul α β] [IsScalarTower α β β] + [IsScalarTower α α β] [SMulCommClass α β β] (a : α) (b : β) (c : α) (d : β) : + (a • b) * (c • d) = (a * c) • (b * d) := by + have : SMulCommClass β α β := .symm ..; exact smul_smul_smul_comm a b c d + +@[to_additive (attr := deprecated (since := "2024-08-29"))] +alias smul_mul_smul := smul_mul_smul_comm + +/-- Note that the `IsScalarTower α β β` and `SMulCommClass α β β` typeclass arguments are usually +satisfied by `Algebra α β`. -/ +@[to_additive] +lemma mul_smul_mul_comm [Mul α] [Mul β] [SMul α β] [IsScalarTower α β β] + [IsScalarTower α α β] [SMulCommClass α β β] (a b : α) (c d : β) : + (a * b) • (c * d) = (a • c) * (b • d) := smul_smul_smul_comm a b c d + variable [SMul M α] @[to_additive] @@ -444,19 +462,12 @@ instance IsScalarTower.left : IsScalarTower M M α where variable {M} -/-- Note that the `IsScalarTower M α α` and `SMulCommClass M α α` typeclass arguments are -usually satisfied by `Algebra M α`. -/ -@[to_additive] -- Porting note: nolint to_additive_doc -lemma smul_mul_smul [Mul α] (r s : M) (x y : α) [IsScalarTower M α α] [SMulCommClass M α α] : - r • x * s • y = (r * s) • (x * y) := by - rw [smul_mul_assoc, mul_smul_comm, ← smul_assoc, smul_eq_mul] - section Monoid variable [Monoid N] [MulAction M N] [IsScalarTower M N N] [SMulCommClass M N N] lemma smul_pow (r : M) (x : N) : ∀ n, (r • x) ^ n = r ^ n • x ^ n | 0 => by simp - | n + 1 => by rw [pow_succ', smul_pow _ _ n, smul_mul_smul, ← pow_succ', ← pow_succ'] + | n + 1 => by rw [pow_succ', smul_pow _ _ n, smul_mul_smul_comm, ← pow_succ', ← pow_succ'] end Monoid @@ -489,7 +500,7 @@ end Mul variable [Group H] [MulAction G H] [SMulCommClass G H H] [IsScalarTower G H H] lemma smul_inv (g : G) (a : H) : (g • a)⁻¹ = g⁻¹ • a⁻¹ := - inv_eq_of_mul_eq_one_right <| by rw [smul_mul_smul, mul_inv_cancel, mul_inv_cancel, one_smul] + inv_eq_of_mul_eq_one_right <| by rw [smul_mul_smul_comm, mul_inv_cancel, mul_inv_cancel, one_smul] lemma smul_zpow (g : G) (a : H) (n : ℤ) : (g • a) ^ n = g ^ n • a ^ n := by cases n <;> simp [smul_pow, smul_inv] diff --git a/Mathlib/Algebra/Group/Action/Prod.lean b/Mathlib/Algebra/Group/Action/Prod.lean index 0ce4d03aff4d1..e753d630bb914 100644 --- a/Mathlib/Algebra/Group/Action/Prod.lean +++ b/Mathlib/Algebra/Group/Action/Prod.lean @@ -132,7 +132,7 @@ section BundledSMul def smulMulHom [Monoid α] [Mul β] [MulAction α β] [IsScalarTower α β β] [SMulCommClass α β β] : α × β →ₙ* β where toFun a := a.1 • a.2 - map_mul' _ _ := (smul_mul_smul _ _ _ _).symm + map_mul' _ _ := (smul_mul_smul_comm _ _ _ _).symm /-- Scalar multiplication as a monoid homomorphism. -/ @[simps] diff --git a/Mathlib/Algebra/Group/Action/Units.lean b/Mathlib/Algebra/Group/Action/Units.lean index d7ad6e43cfdf4..b1b817a1fb920 100644 --- a/Mathlib/Algebra/Group/Action/Units.lean +++ b/Mathlib/Algebra/Group/Action/Units.lean @@ -69,8 +69,8 @@ instance mulAction' [Group G] [Monoid M] [MulAction G M] [SMulCommClass G M M] [IsScalarTower G M M] : MulAction G Mˣ where smul g m := ⟨g • (m : M), (g⁻¹ • ((m⁻¹ : Mˣ) : M)), - by rw [smul_mul_smul, Units.mul_inv, mul_inv_cancel, one_smul], - by rw [smul_mul_smul, Units.inv_mul, inv_mul_cancel, one_smul]⟩ + by rw [smul_mul_smul_comm, Units.mul_inv, mul_inv_cancel, one_smul], + by rw [smul_mul_smul_comm, Units.inv_mul, inv_mul_cancel, one_smul]⟩ one_smul m := Units.ext <| one_smul _ _ mul_smul g₁ g₂ m := Units.ext <| mul_smul _ _ _ diff --git a/Mathlib/Algebra/Group/Basic.lean b/Mathlib/Algebra/Group/Basic.lean index be38ab0a3a6b8..8c68d20cf55f8 100644 --- a/Mathlib/Algebra/Group/Basic.lean +++ b/Mathlib/Algebra/Group/Basic.lean @@ -90,7 +90,7 @@ section Semigroup variable [Semigroup α] @[to_additive] -instance Semigroup.to_isAssociative : Std.Associative (α := α) (· * ·) := ⟨mul_assoc⟩ +instance Semigroup.to_isAssociative : Std.Associative (α := α) (· * ·) := ⟨mul_assoc⟩ /-- Composing two multiplications on the left by `y` then `x` is equal to a multiplication on the left by `x * y`. diff --git a/Mathlib/Algebra/Group/Hom/Basic.lean b/Mathlib/Algebra/Group/Hom/Basic.lean index e1a97f26ed9b8..bac422e61797b 100644 --- a/Mathlib/Algebra/Group/Hom/Basic.lean +++ b/Mathlib/Algebra/Group/Hom/Basic.lean @@ -101,7 +101,7 @@ section Group variable [Group G] [CommGroup H] /-- A homomorphism from a group to a monoid is injective iff its kernel is trivial. -For the iff statement on the triviality of the kernel, see `injective_iff_map_eq_one'`. -/ +For the iff statement on the triviality of the kernel, see `injective_iff_map_eq_one'`. -/ @[to_additive "A homomorphism from an additive group to an additive monoid is injective iff its kernel is trivial. For the iff statement on the triviality of the kernel, diff --git a/Mathlib/Algebra/Group/Indicator.lean b/Mathlib/Algebra/Group/Indicator.lean index 68214b8258570..ccb3633809bca 100644 --- a/Mathlib/Algebra/Group/Indicator.lean +++ b/Mathlib/Algebra/Group/Indicator.lean @@ -41,7 +41,7 @@ section One variable [One M] [One N] {s t : Set α} {f g : α → M} {a : α} -/-- `Set.mulIndicator s f a` is `f a` if `a ∈ s`, `1` otherwise. -/ +/-- `Set.mulIndicator s f a` is `f a` if `a ∈ s`, `1` otherwise. -/ @[to_additive "`Set.indicator s f a` is `f a` if `a ∈ s`, `0` otherwise."] noncomputable def mulIndicator (s : Set α) (f : α → M) (x : α) : M := haveI := Classical.decPred (· ∈ s) diff --git a/Mathlib/Algebra/Group/Subgroup/Basic.lean b/Mathlib/Algebra/Group/Subgroup/Basic.lean index 01289fa8997c3..4e2fee2a296c8 100644 --- a/Mathlib/Algebra/Group/Subgroup/Basic.lean +++ b/Mathlib/Algebra/Group/Subgroup/Basic.lean @@ -892,7 +892,7 @@ theorem closure_induction {p : G → Prop} {x} (h : x ∈ closure k) (mem : ∀ (mul : ∀ x y, p x → p y → p (x * y)) (inv : ∀ x, p x → p x⁻¹) : p x := (@closure_le _ _ ⟨⟨⟨setOf p, fun {x y} ↦ mul x y⟩, one⟩, fun {x} ↦ inv x⟩ k).2 mem h -/-- A dependent version of `Subgroup.closure_induction`. -/ +/-- A dependent version of `Subgroup.closure_induction`. -/ @[to_additive (attr := elab_as_elim) "A dependent version of `AddSubgroup.closure_induction`. "] theorem closure_induction' {p : ∀ x, x ∈ closure k → Prop} (mem : ∀ (x) (h : x ∈ k), p x (subset_closure h)) (one : p 1 (one_mem _)) @@ -1076,7 +1076,7 @@ theorem toAddSubgroup_comap {G₂ : Type*} [Group G₂] (f : G →* G₂) (s : S @[simp] theorem _root_.AddSubgroup.toSubgroup_comap {A A₂ : Type*} [AddGroup A] [AddGroup A₂] - (f : A →+ A₂) (s : AddSubgroup A₂) : + (f : A →+ A₂) (s : AddSubgroup A₂) : s.toSubgroup.comap (AddMonoidHom.toMultiplicative f) = AddSubgroup.toSubgroup (s.comap f) := rfl @[to_additive (attr := simp)] @@ -1709,7 +1709,7 @@ def _root_.NormalizerCondition := variable {G} /-- Alternative phrasing of the normalizer condition: Only the full group is self-normalizing. -This may be easier to work with, as it avoids inequalities and negations. -/ +This may be easier to work with, as it avoids inequalities and negations. -/ theorem _root_.normalizerCondition_iff_only_full_group_self_normalizing : NormalizerCondition G ↔ ∀ H : Subgroup G, H.normalizer = H → H = ⊤ := by apply forall_congr'; intro H @@ -2912,3 +2912,5 @@ def noncenter (G : Type*) [Monoid G] : Set (ConjClasses G) := g ∈ noncenter G ↔ g.carrier.Nontrivial := Iff.rfl end ConjClasses + +set_option linter.style.longFile 3000 diff --git a/Mathlib/Algebra/Group/Subgroup/Finite.lean b/Mathlib/Algebra/Group/Subgroup/Finite.lean index 77f194a84dacd..b4dc8b267698d 100644 --- a/Mathlib/Algebra/Group/Subgroup/Finite.lean +++ b/Mathlib/Algebra/Group/Subgroup/Finite.lean @@ -200,7 +200,7 @@ theorem pi_mem_of_mulSingle_mem [Finite η] [DecidableEq η] {H : Subgroup (∀ cases nonempty_fintype η exact pi_mem_of_mulSingle_mem_aux Finset.univ x (by simp) fun i _ => h i -/-- For finite index types, the `Subgroup.pi` is generated by the embeddings of the groups. -/ +/-- For finite index types, the `Subgroup.pi` is generated by the embeddings of the groups. -/ @[to_additive "For finite index types, the `Subgroup.pi` is generated by the embeddings of the additive groups."] theorem pi_le_iff [DecidableEq η] [Finite η] {H : ∀ i, Subgroup (f i)} {J : Subgroup (∀ i, f i)} : diff --git a/Mathlib/Algebra/Group/Submonoid/Basic.lean b/Mathlib/Algebra/Group/Submonoid/Basic.lean index 35c066cced16e..ddb7f8577ed46 100644 --- a/Mathlib/Algebra/Group/Submonoid/Basic.lean +++ b/Mathlib/Algebra/Group/Submonoid/Basic.lean @@ -376,7 +376,7 @@ theorem closure_induction {p : M → Prop} {x} (h : x ∈ closure s) (mem : ∀ (mul : ∀ x y, p x → p y → p (x * y)) : p x := (@closure_le _ _ _ ⟨⟨p, mul _ _⟩, one⟩).2 mem h -/-- A dependent version of `Submonoid.closure_induction`. -/ +/-- A dependent version of `Submonoid.closure_induction`. -/ @[to_additive (attr := elab_as_elim) "A dependent version of `AddSubmonoid.closure_induction`. "] theorem closure_induction' (s : Set M) {p : ∀ x, x ∈ closure s → Prop} (mem : ∀ (x) (h : x ∈ s), p x (subset_closure h)) (one : p 1 (one_mem _)) @@ -387,7 +387,7 @@ theorem closure_induction' (s : Set M) {p : ∀ x, x ∈ closure s → Prop} closure_induction hx (fun x hx => ⟨_, mem x hx⟩) ⟨_, one⟩ fun x y ⟨hx', hx⟩ ⟨hy', hy⟩ => ⟨_, mul _ _ _ _ hx hy⟩ -/-- An induction principle for closure membership for predicates with two arguments. -/ +/-- An induction principle for closure membership for predicates with two arguments. -/ @[to_additive (attr := elab_as_elim) "An induction principle for additive closure membership for predicates with two arguments."] theorem closure_induction₂ {p : M → M → Prop} {x} {y : M} (hx : x ∈ closure s) (hy : y ∈ closure s) diff --git a/Mathlib/Algebra/Group/Submonoid/Membership.lean b/Mathlib/Algebra/Group/Submonoid/Membership.lean index 603662f188ac8..e1ec1fb022a46 100644 --- a/Mathlib/Algebra/Group/Submonoid/Membership.lean +++ b/Mathlib/Algebra/Group/Submonoid/Membership.lean @@ -293,7 +293,7 @@ variable {S : Submonoid M} [Fintype S] open Fintype /- curly brackets `{}` are used here instead of instance brackets `[]` because - the instance in a goal is often not the same as the one inferred by type class inference. -/ + the instance in a goal is often not the same as the one inferred by type class inference. -/ @[to_additive] theorem card_bot {_ : Fintype (⊥ : Submonoid M)} : card (⊥ : Submonoid M) = 1 := card_eq_one_iff.2 diff --git a/Mathlib/Algebra/Group/Submonoid/Units.lean b/Mathlib/Algebra/Group/Submonoid/Units.lean index 2754d556e4588..038b61740f30e 100644 --- a/Mathlib/Algebra/Group/Submonoid/Units.lean +++ b/Mathlib/Algebra/Group/Submonoid/Units.lean @@ -40,13 +40,13 @@ variable {M : Type*} [Monoid M] open Units open Pointwise in -/-- The units of `S`, packaged as a subgroup of `Mˣ`. -/ +/-- The units of `S`, packaged as a subgroup of `Mˣ`. -/ @[to_additive " The additive units of `S`, packaged as an additive subgroup of `AddUnits M`. "] def Submonoid.units (S : Submonoid M) : Subgroup Mˣ where toSubmonoid := S.comap (coeHom M) ⊓ (S.comap (coeHom M))⁻¹ inv_mem' ha := ⟨ha.2, ha.1⟩ -/-- A subgroup of units represented as a submonoid of `M`. -/ +/-- A subgroup of units represented as a submonoid of `M`. -/ @[to_additive " A additive subgroup of additive units represented as a additive submonoid of `M`. "] def Subgroup.ofUnits (S : Subgroup Mˣ) : Submonoid M := S.toSubmonoid.map (coeHom M) diff --git a/Mathlib/Algebra/Group/Subsemigroup/Basic.lean b/Mathlib/Algebra/Group/Subsemigroup/Basic.lean index eb038acc2f5ba..f65687e5782d3 100644 --- a/Mathlib/Algebra/Group/Subsemigroup/Basic.lean +++ b/Mathlib/Algebra/Group/Subsemigroup/Basic.lean @@ -298,7 +298,7 @@ theorem closure_induction {p : M → Prop} {x} (h : x ∈ closure s) (mem : ∀ (mul : ∀ x y, p x → p y → p (x * y)) : p x := (@closure_le _ _ _ ⟨p, mul _ _⟩).2 mem h -/-- A dependent version of `Subsemigroup.closure_induction`. -/ +/-- A dependent version of `Subsemigroup.closure_induction`. -/ @[to_additive (attr := elab_as_elim) "A dependent version of `AddSubsemigroup.closure_induction`. "] theorem closure_induction' (s : Set M) {p : ∀ x, x ∈ closure s → Prop} (mem : ∀ (x) (h : x ∈ s), p x (subset_closure h)) @@ -309,7 +309,7 @@ theorem closure_induction' (s : Set M) {p : ∀ x, x ∈ closure s → Prop} closure_induction hx (fun x hx => ⟨_, mem x hx⟩) fun x y ⟨hx', hx⟩ ⟨hy', hy⟩ => ⟨_, mul _ _ _ _ hx hy⟩ -/-- An induction principle for closure membership for predicates with two arguments. -/ +/-- An induction principle for closure membership for predicates with two arguments. -/ @[to_additive (attr := elab_as_elim) "An induction principle for additive closure membership for predicates with two arguments."] theorem closure_induction₂ {p : M → M → Prop} {x} {y : M} (hx : x ∈ closure s) (hy : y ∈ closure s) diff --git a/Mathlib/Algebra/Homology/BifunctorAssociator.lean b/Mathlib/Algebra/Homology/BifunctorAssociator.lean index e13e10c8a242e..70f0ff7943445 100644 --- a/Mathlib/Algebra/Homology/BifunctorAssociator.lean +++ b/Mathlib/Algebra/Homology/BifunctorAssociator.lean @@ -65,7 +65,7 @@ variable (F₁₂ G) in /-- Given bifunctors `F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂`, `G : C₁₂ ⥤ C₃ ⥤ C₄`, homological complexes `K₁ : HomologicalComplex C₁ c₁`, `K₂ : HomologicalComplex C₂ c₂` and `K₃ : HomologicalComplex C₃ c₃`, and complexes shapes `c₁₂`, `c₄`, this asserts -that for all `i₁₂ : ι₁₂` and `i₃ : ι₃`, the functor `G(-, K₃.X i₃)` commutes wich +that for all `i₁₂ : ι₁₂` and `i₃ : ι₃`, the functor `G(-, K₃.X i₃)` commutes with the coproducts of the `F₁₂(X₁ i₁, X₂ i₂)` such that `π c₁ c₂ c₁₂ ⟨i₁, i₂⟩ = i₁₂`. -/ abbrev HasGoodTrifunctor₁₂Obj := GradedObject.HasGoodTrifunctor₁₂Obj F₁₂ G @@ -76,7 +76,7 @@ variable (F G₂₃) in `K₁ : HomologicalComplex C₁ c₁`, `K₂ : HomologicalComplex C₂ c₂` and `K₃ : HomologicalComplex C₃ c₃`, and complexes shapes `c₁₂`, `c₂₃`, `c₄` with `ComplexShape.Associative c₁ c₂ c₃ c₁₂ c₂₃ c₄`, this asserts that for -all `i₁ : ι₁` and `i₂₃ : ι₂₃`, the functor `F(K₁.X i₁, _)` commutes wich +all `i₁ : ι₁` and `i₂₃ : ι₂₃`, the functor `F(K₁.X i₁, _)` commutes with the coproducts of the `G₂₃(K₂.X i₂, K₃.X i₃)` such that `π c₂ c₃ c₂₃ ⟨i₂, i₃⟩ = i₂₃`. -/ abbrev HasGoodTrifunctor₂₃Obj := diff --git a/Mathlib/Algebra/Homology/Embedding/TruncGE.lean b/Mathlib/Algebra/Homology/Embedding/TruncGE.lean index 3cfeee56bada8..c0c9a8b3cbd18 100644 --- a/Mathlib/Algebra/Homology/Embedding/TruncGE.lean +++ b/Mathlib/Algebra/Homology/Embedding/TruncGE.lean @@ -110,8 +110,8 @@ noncomputable def truncGE'XIsoOpcycles {i : ι} {i' : ι'} (hi' : e.f i = i') (h (K.truncGE' e).X i ≅ K.opcycles i' := (truncGE'.XIsoOpcycles K e hi) ≪≫ eqToIso (by subst hi'; rfl) -lemma truncGE'_d_eq {i j : ι} (hij : c.Rel i j) {i' j' : ι'} - (hi' : e.f i = i') (hj' : e.f j = j') (hi : ¬ e.BoundaryGE i) : +lemma truncGE'_d_eq {i j : ι} (hij : c.Rel i j) {i' j' : ι'} + (hi' : e.f i = i') (hj' : e.f j = j') (hi : ¬ e.BoundaryGE i) : (K.truncGE' e).d i j = (K.truncGE'XIso e hi' hi).hom ≫ K.d i' j' ≫ (K.truncGE'XIso e hj' (e.not_boundaryGE_next hij)).inv := by dsimp [truncGE', truncGE'.d] diff --git a/Mathlib/Algebra/Homology/HomologySequence.lean b/Mathlib/Algebra/Homology/HomologySequence.lean index 3c219686c7084..6a325db2f53a9 100644 --- a/Mathlib/Algebra/Homology/HomologySequence.lean +++ b/Mathlib/Algebra/Homology/HomologySequence.lean @@ -283,7 +283,7 @@ namespace ShortComplex namespace ShortExact /-- The connecting homoomorphism `S.X₃.homology i ⟶ S.X₁.homology j` for a short exact -short complex `S`. -/ +short complex `S`. -/ noncomputable def δ : S.X₃.homology i ⟶ S.X₁.homology j := (snakeInput hS i j hij).δ @[reassoc (attr := simp)] diff --git a/Mathlib/Algebra/Homology/HomotopyCategory/MappingCone.lean b/Mathlib/Algebra/Homology/HomotopyCategory/MappingCone.lean index 957e7c2a38b45..42704741a95dc 100644 --- a/Mathlib/Algebra/Homology/HomotopyCategory/MappingCone.lean +++ b/Mathlib/Algebra/Homology/HomotopyCategory/MappingCone.lean @@ -51,7 +51,7 @@ open HomComplex /-- The left inclusion in the mapping cone, as a cochain of degree `-1`. -/ noncomputable def inl : Cochain F (mappingCone φ) (-1) := - Cochain.mk (fun p q hpq => homotopyCofiber.inlX φ p q (by dsimp; omega)) + Cochain.mk (fun p q hpq => homotopyCofiber.inlX φ p q (by dsimp; omega)) /-- The right inclusion in the mapping cone. -/ noncomputable def inr : G ⟶ mappingCone φ := homotopyCofiber.inr φ diff --git a/Mathlib/Algebra/Homology/ShortComplex/LeftHomology.lean b/Mathlib/Algebra/Homology/ShortComplex/LeftHomology.lean index 1d91f59bef1b9..1022a52c7ab90 100644 --- a/Mathlib/Algebra/Homology/ShortComplex/LeftHomology.lean +++ b/Mathlib/Algebra/Homology/ShortComplex/LeftHomology.lean @@ -388,10 +388,10 @@ section variable (S) variable [S.HasLeftHomology] -/-- The left homology of a short complex, given by the `H` field of a chosen left homology data. -/ +/-- The left homology of a short complex, given by the `H` field of a chosen left homology data. -/ noncomputable def leftHomology : C := S.leftHomologyData.H -/-- The cycles of a short complex, given by the `K` field of a chosen left homology data. -/ +/-- The cycles of a short complex, given by the `K` field of a chosen left homology data. -/ noncomputable def cycles : C := S.leftHomologyData.K /-- The "homology class" map `S.cycles ⟶ S.leftHomology`. -/ diff --git a/Mathlib/Algebra/Homology/ShortComplex/Preadditive.lean b/Mathlib/Algebra/Homology/ShortComplex/Preadditive.lean index d1364bc4bca38..8d23c46c9a207 100644 --- a/Mathlib/Algebra/Homology/ShortComplex/Preadditive.lean +++ b/Mathlib/Algebra/Homology/ShortComplex/Preadditive.lean @@ -508,7 +508,7 @@ def op (h : Homotopy φ₁ φ₂) : Homotopy (opMap φ₁) (opMap φ₂) where /-- The homotopy between morphisms in `ShortComplex C` that is induced by a homotopy between morphisms in `ShortComplex Cᵒᵖ`. -/ @[simps] -def unop {S₁ S₂ : ShortComplex Cᵒᵖ} {φ₁ φ₂ : S₁ ⟶ S₂} (h : Homotopy φ₁ φ₂) : +def unop {S₁ S₂ : ShortComplex Cᵒᵖ} {φ₁ φ₂ : S₁ ⟶ S₂} (h : Homotopy φ₁ φ₂) : Homotopy (unopMap φ₁) (unopMap φ₂) where h₀ := h.h₃.unop h₁ := h.h₂.unop diff --git a/Mathlib/Algebra/Homology/ShortComplex/RightHomology.lean b/Mathlib/Algebra/Homology/ShortComplex/RightHomology.lean index 5a62395fcb632..865ffa00b94fb 100644 --- a/Mathlib/Algebra/Homology/ShortComplex/RightHomology.lean +++ b/Mathlib/Algebra/Homology/ShortComplex/RightHomology.lean @@ -1004,7 +1004,7 @@ variable (φ : S₁ ⟶ S₂) (h : RightHomologyData S₁) [Epi φ.τ₁] [IsIso /-- If `φ : S₁ ⟶ S₂` is a morphism of short complexes such that `φ.τ₁` is epi, `φ.τ₂` is an iso and `φ.τ₃` is mono, then a right homology data for `S₁` induces a right homology data for `S₂` with the same `Q` and `H` fields. This is obtained by dualising `LeftHomologyData.ofEpiOfIsIsoOfMono'`. -The inverse construction is `ofEpiOfIsIsoOfMono'`. -/ +The inverse construction is `ofEpiOfIsIsoOfMono'`. -/ noncomputable def ofEpiOfIsIsoOfMono : RightHomologyData S₂ := by haveI : Epi (opMap φ).τ₁ := by dsimp; infer_instance haveI : IsIso (opMap φ).τ₂ := by dsimp; infer_instance @@ -1032,7 +1032,7 @@ variable (φ : S₁ ⟶ S₂) (h : RightHomologyData S₂) [Epi φ.τ₁] [IsIso /-- If `φ : S₁ ⟶ S₂` is a morphism of short complexes such that `φ.τ₁` is epi, `φ.τ₂` is an iso and `φ.τ₃` is mono, then a right homology data for `S₂` induces a right homology data for `S₁` with the same `Q` and `H` fields. This is obtained by dualising `LeftHomologyData.ofEpiOfIsIsoOfMono`. -The inverse construction is `ofEpiOfIsIsoOfMono`. -/ +The inverse construction is `ofEpiOfIsIsoOfMono`. -/ noncomputable def ofEpiOfIsIsoOfMono' : RightHomologyData S₁ := by haveI : Epi (opMap φ).τ₁ := by dsimp; infer_instance haveI : IsIso (opMap φ).τ₂ := by dsimp; infer_instance diff --git a/Mathlib/Algebra/Jordan/Basic.lean b/Mathlib/Algebra/Jordan/Basic.lean index 4098f22e03cf1..b6e455cab6209 100644 --- a/Mathlib/Algebra/Jordan/Basic.lean +++ b/Mathlib/Algebra/Jordan/Basic.lean @@ -101,7 +101,7 @@ instance (priority := 100) IsCommJordan.toIsJordan [CommMagma A] [IsCommJordan A rw [mul_comm b a, IsCommJordan.lmul_comm_rmul_rmul, mul_comm] -- see Note [lower instance priority] -/-- Semigroup multiplication satisfies the (non-commutative) Jordan axioms-/ +/-- Semigroup multiplication satisfies the (non-commutative) Jordan axioms -/ instance (priority := 100) Semigroup.isJordan [Semigroup A] : IsJordan A where lmul_comm_rmul a b := by rw [mul_assoc] lmul_lmul_comm_lmul a b := by rw [mul_assoc, mul_assoc] diff --git a/Mathlib/Algebra/Lie/Subalgebra.lean b/Mathlib/Algebra/Lie/Subalgebra.lean index 5301d1d9b0348..069da030a3fa3 100644 --- a/Mathlib/Algebra/Lie/Subalgebra.lean +++ b/Mathlib/Algebra/Lie/Subalgebra.lean @@ -555,7 +555,7 @@ theorem coe_ofLe : (ofLe h : Submodule R K') = LinearMap.range (Submodule.inclus rfl /-- Given nested Lie subalgebras `K ⊆ K'`, there is a natural equivalence from `K` to its image in -`K'`. -/ +`K'`. -/ noncomputable def equivOfLe : K ≃ₗ⁅R⁆ ofLe h := (inclusion h).equivRangeOfInjective (inclusion_injective h) diff --git a/Mathlib/Algebra/Module/Injective.lean b/Mathlib/Algebra/Module/Injective.lean index 536a41a974e42..9462f04c45e08 100644 --- a/Mathlib/Algebra/Module/Injective.lean +++ b/Mathlib/Algebra/Module/Injective.lean @@ -249,7 +249,7 @@ variable (f) def ExtensionOfMaxAdjoin.ideal (y : N) : Ideal R := (extensionOfMax i f).domain.comap ((LinearMap.id : R →ₗ[R] R).smulRight y) -/-- A linear map `I ⟶ Q` by `x ↦ f' (x • y)` where `f'` is the maximal extension-/ +/-- A linear map `I ⟶ Q` by `x ↦ f' (x • y)` where `f'` is the maximal extension -/ def ExtensionOfMaxAdjoin.idealTo (y : N) : ExtensionOfMaxAdjoin.ideal i f y →ₗ[R] Q where toFun (z : { x // x ∈ ideal i f y }) := (extensionOfMax i f).toLinearPMap ⟨(↑z : R) • y, z.prop⟩ map_add' (z1 z2 : { x // x ∈ ideal i f y }) := by diff --git a/Mathlib/Algebra/Module/Submodule/Basic.lean b/Mathlib/Algebra/Module/Submodule/Basic.lean index 6c89784c098f8..0b6a8bcb0c7e1 100644 --- a/Mathlib/Algebra/Module/Submodule/Basic.lean +++ b/Mathlib/Algebra/Module/Submodule/Basic.lean @@ -152,7 +152,7 @@ variable [Semiring R] [AddCommMonoid M] [Module R M] {A : Type*} [SetLike A M] [AddSubmonoidClass A M] [SMulMemClass A R M] (S' : A) -- Prefer subclasses of `Module` over `SMulMemClass`. -/-- A submodule of a `Module` is a `Module`. -/ +/-- A submodule of a `Module` is a `Module`. -/ instance (priority := 75) toModule : Module R S' := Subtype.coe_injective.module R (AddSubmonoidClass.subtype S') (SetLike.val_smul S') diff --git a/Mathlib/Algebra/Module/Submodule/Bilinear.lean b/Mathlib/Algebra/Module/Submodule/Bilinear.lean index 8f1e0b93e8437..bacd3bc47d6b5 100644 --- a/Mathlib/Algebra/Module/Submodule/Bilinear.lean +++ b/Mathlib/Algebra/Module/Submodule/Bilinear.lean @@ -37,7 +37,7 @@ variable [Module R M] [Module R N] [Module R P] /-- Map a pair of submodules under a bilinear map. -This is the submodule version of `Set.image2`. -/ +This is the submodule version of `Set.image2`. -/ def map₂ (f : M →ₗ[R] N →ₗ[R] P) (p : Submodule R M) (q : Submodule R N) : Submodule R P := ⨆ s : p, q.map (f s) diff --git a/Mathlib/Algebra/MonoidAlgebra/Basic.lean b/Mathlib/Algebra/MonoidAlgebra/Basic.lean index 4022f37abb36e..23c0fabadf6c7 100644 --- a/Mathlib/Algebra/MonoidAlgebra/Basic.lean +++ b/Mathlib/Algebra/MonoidAlgebra/Basic.lean @@ -656,7 +656,7 @@ def liftMagma [Module k A] [IsScalarTower k A A] [SMulCommClass k A A] : intros rw [← add_smul] -- Porting note: `reducible` cannot be `local` so proof gets long. - simp_rw [Finsupp.mul_sum, Finsupp.sum_mul, smul_mul_smul, ← f.map_mul, mul_def, + simp_rw [Finsupp.mul_sum, Finsupp.sum_mul, smul_mul_smul_comm, ← f.map_mul, mul_def, sum_comm a₂ a₁] rw [sum_sum_index h₁ h₂]; congr; ext rw [sum_sum_index h₁ h₂]; congr; ext @@ -1966,3 +1966,5 @@ def AddMonoidAlgebra.toMultiplicativeAlgEquiv [Semiring k] [Algebra R k] [AddMon def MonoidAlgebra.toAdditiveAlgEquiv [Semiring k] [Algebra R k] [Monoid G] : MonoidAlgebra k G ≃ₐ[R] AddMonoidAlgebra k (Additive G) := { MonoidAlgebra.toAdditive k G with commutes' := fun r => by simp [MonoidAlgebra.toAdditive] } + +set_option linter.style.longFile 2100 diff --git a/Mathlib/Algebra/MonoidAlgebra/ToDirectSum.lean b/Mathlib/Algebra/MonoidAlgebra/ToDirectSum.lean index 81bb2a27474e6..111fe27da2293 100644 --- a/Mathlib/Algebra/MonoidAlgebra/ToDirectSum.lean +++ b/Mathlib/Algebra/MonoidAlgebra/ToDirectSum.lean @@ -191,7 +191,7 @@ def addMonoidAlgebraEquivDirectSum [DecidableEq ι] [Semiring M] [∀ m : M, Dec toFun := AddMonoidAlgebra.toDirectSum invFun := DirectSum.toAddMonoidAlgebra } -/-- The additive version of `AddMonoidAlgebra.addMonoidAlgebraEquivDirectSum`. -/ +/-- The additive version of `AddMonoidAlgebra.addMonoidAlgebraEquivDirectSum`. -/ @[simps (config := .asFn)] def addMonoidAlgebraAddEquivDirectSum [DecidableEq ι] [Semiring M] [∀ m : M, Decidable (m ≠ 0)] : AddMonoidAlgebra M ι ≃+ ⨁ _ : ι, M := @@ -200,7 +200,7 @@ def addMonoidAlgebraAddEquivDirectSum [DecidableEq ι] [Semiring M] [∀ m : M, invFun := DirectSum.toAddMonoidAlgebra map_add' := AddMonoidAlgebra.toDirectSum_add } -/-- The ring version of `AddMonoidAlgebra.addMonoidAlgebraEquivDirectSum`. -/ +/-- The ring version of `AddMonoidAlgebra.addMonoidAlgebraEquivDirectSum`. -/ @[simps (config := .asFn)] def addMonoidAlgebraRingEquivDirectSum [DecidableEq ι] [AddMonoid ι] [Semiring M] [∀ m : M, Decidable (m ≠ 0)] : AddMonoidAlgebra M ι ≃+* ⨁ _ : ι, M := diff --git a/Mathlib/Algebra/MvPolynomial/Basic.lean b/Mathlib/Algebra/MvPolynomial/Basic.lean index 90a2b3d0d0db8..7603d4411fdfd 100644 --- a/Mathlib/Algebra/MvPolynomial/Basic.lean +++ b/Mathlib/Algebra/MvPolynomial/Basic.lean @@ -461,7 +461,7 @@ theorem linearMap_ext {M : Type*} [AddCommMonoid M] [Module R M] {f g : MvPolyno section Support -/-- The finite set of all `m : σ →₀ ℕ` such that `X^m` has a non-zero coefficient. -/ +/-- The finite set of all `m : σ →₀ ℕ` such that `X^m` has a non-zero coefficient. -/ def support (p : MvPolynomial σ R) : Finset (σ →₀ ℕ) := Finsupp.support p @@ -1539,3 +1539,5 @@ end EvalMem end CommSemiring end MvPolynomial + +set_option linter.style.longFile 1700 diff --git a/Mathlib/Algebra/MvPolynomial/Variables.lean b/Mathlib/Algebra/MvPolynomial/Variables.lean index f431fe8b5f796..2c49de4e57ad4 100644 --- a/Mathlib/Algebra/MvPolynomial/Variables.lean +++ b/Mathlib/Algebra/MvPolynomial/Variables.lean @@ -272,7 +272,7 @@ theorem eval₂Hom_congr' {f₁ f₂ : R →+* S} {g₁ g₂ : σ → S} {p₁ p /-- If `f₁` and `f₂` are ring homs out of the polynomial ring and `p₁` and `p₂` are polynomials, then `f₁ p₁ = f₂ p₂` if `p₁ = p₂` and `f₁` and `f₂` are equal on `R` and on the variables - of `p₁`. -/ + of `p₁`. -/ theorem hom_congr_vars {f₁ f₂ : MvPolynomial σ R →+* S} {p₁ p₂ : MvPolynomial σ R} (hC : f₁.comp C = f₂.comp C) (hv : ∀ i, i ∈ p₁.vars → i ∈ p₂.vars → f₁ (X i) = f₂ (X i)) (hp : p₁ = p₂) : f₁ p₁ = f₂ p₂ := diff --git a/Mathlib/Algebra/NeZero.lean b/Mathlib/Algebra/NeZero.lean index 5851e7c4e2cef..aaa15d8a6209e 100644 --- a/Mathlib/Algebra/NeZero.lean +++ b/Mathlib/Algebra/NeZero.lean @@ -19,7 +19,7 @@ We create a typeclass `NeZero n` which carries around the fact that `(n : R) ≠ variable {R : Type*} [Zero R] -/-- A type-class version of `n ≠ 0`. -/ +/-- A type-class version of `n ≠ 0`. -/ class NeZero (n : R) : Prop where /-- The proposition that `n` is not zero. -/ out : n ≠ 0 diff --git a/Mathlib/Algebra/Order/Antidiag/Pi.lean b/Mathlib/Algebra/Order/Antidiag/Pi.lean index 2573fd6a28d1f..92206333ffa94 100644 --- a/Mathlib/Algebra/Order/Antidiag/Pi.lean +++ b/Mathlib/Algebra/Order/Antidiag/Pi.lean @@ -164,7 +164,7 @@ lemma pairwiseDisjoint_piAntidiag_map_addRightEmbedding (hi : i ∉ s) (n : μ) rintro hfg _ f rfl - rfl g rfl - hgf exact hfg <| by simpa [sum_add_distrib, hi] using congr_arg (∑ j ∈ s, · j) hgf.symm -lemma piAntidiag_cons (hi : i ∉ s) (n : μ) : +lemma piAntidiag_cons (hi : i ∉ s) (n : μ) : piAntidiag (cons i s hi) n = (antidiagonal n).disjiUnion (fun p : μ × μ ↦ (piAntidiag s p.snd).map (addRightEmbedding fun t ↦ if t = i then p.fst else 0)) (pairwiseDisjoint_piAntidiag_map_addRightEmbedding hi _) := by diff --git a/Mathlib/Algebra/Order/Floor.lean b/Mathlib/Algebra/Order/Floor.lean index 590bbabf6d112..11cca30187ba8 100644 --- a/Mathlib/Algebra/Order/Floor.lean +++ b/Mathlib/Algebra/Order/Floor.lean @@ -1501,7 +1501,7 @@ theorem Int.natCast_ceil_eq_ceil (ha : 0 ≤ a) : (⌈a⌉₊ : ℤ) = ⌈a⌉ : theorem natCast_floor_eq_intCast_floor (ha : 0 ≤ a) : (⌊a⌋₊ : α) = ⌊a⌋ := by rw [← Int.natCast_floor_eq_floor ha, Int.cast_natCast] -theorem natCast_ceil_eq_intCast_ceil (ha : 0 ≤ a) : (⌈a⌉₊ : α) = ⌈a⌉ := by +theorem natCast_ceil_eq_intCast_ceil (ha : 0 ≤ a) : (⌈a⌉₊ : α) = ⌈a⌉ := by rw [← Int.natCast_ceil_eq_ceil ha, Int.cast_natCast] @[deprecated (since := "2024-08-20")] alias Int.ofNat_floor_eq_floor := natCast_floor_eq_floor @@ -1581,3 +1581,5 @@ def evalIntCeil : PositivityExt where eval {u α} _zα _pα e := do | _, _, _ => throwError "failed to match on Int.ceil application" end Mathlib.Meta.Positivity + +set_option linter.style.longFile 1700 diff --git a/Mathlib/Algebra/Order/Group/Defs.lean b/Mathlib/Algebra/Order/Group/Defs.lean index c486a4984cd8a..a47229cb3489f 100644 --- a/Mathlib/Algebra/Order/Group/Defs.lean +++ b/Mathlib/Algebra/Order/Group/Defs.lean @@ -170,7 +170,7 @@ end LinearOrderedCommGroup section NormNumLemmas /- The following lemmas are stated so that the `norm_num` tactic can use them with the -expected signatures. -/ +expected signatures. -/ variable [OrderedCommGroup α] {a b : α} @[to_additive (attr := gcongr) neg_le_neg] diff --git a/Mathlib/Algebra/Order/GroupWithZero/Submonoid.lean b/Mathlib/Algebra/Order/GroupWithZero/Submonoid.lean new file mode 100644 index 0000000000000..c3b553bb0ca38 --- /dev/null +++ b/Mathlib/Algebra/Order/GroupWithZero/Submonoid.lean @@ -0,0 +1,27 @@ +/- +Copyright (c) 2021 Chris Birkbeck. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Chris Birkbeck +-/ +import Mathlib.Algebra.Group.Submonoid.Basic +import Mathlib.Algebra.Order.GroupWithZero.Unbundled + +/-! +# The submonoid of positive elements +-/ + +namespace Submonoid +variable (α) [MulZeroOneClass α] [PartialOrder α] [PosMulStrictMono α] [ZeroLEOneClass α] + [NeZero (1 : α)] {a : α} + +/-- The submonoid of positive elements. -/ +@[simps] def pos : Submonoid α where + carrier := Set.Ioi 0 + one_mem' := zero_lt_one + mul_mem' := mul_pos + +variable {α} + +@[simp] lemma mem_pos : a ∈ pos α ↔ 0 < a := Iff.rfl + +end Submonoid diff --git a/Mathlib/Algebra/Order/Hom/Monoid.lean b/Mathlib/Algebra/Order/Hom/Monoid.lean index d212b514c3cc4..89356b58c0ecf 100644 --- a/Mathlib/Algebra/Order/Hom/Monoid.lean +++ b/Mathlib/Algebra/Order/Hom/Monoid.lean @@ -18,12 +18,17 @@ This file defines morphisms between (additive) ordered monoids. * `OrderAddMonoidHom`: Ordered additive monoid homomorphisms. * `OrderMonoidHom`: Ordered monoid homomorphisms. * `OrderMonoidWithZeroHom`: Ordered monoid with zero homomorphisms. +* `OrderAddMonoidIso`: Ordered additive monoid isomorphisms. +* `OrderMonoidIso`: Ordered monoid isomorphisms. ## Notation -* `→+o`: Bundled ordered additive monoid homs. Also use for additive groups homs. -* `→*o`: Bundled ordered monoid homs. Also use for groups homs. -* `→*₀o`: Bundled ordered monoid with zero homs. Also use for groups with zero homs. +* `→+o`: Bundled ordered additive monoid homs. Also use for additive group homs. +* `→*o`: Bundled ordered monoid homs. Also use for group homs. +* `→*₀o`: Bundled ordered monoid with zero homs. Also use for group with zero homs. +* `≃+o`: Bundled ordered additive monoid isos. Also use for additive group isos. +* `≃*o`: Bundled ordered monoid isos. Also use for group isos. +* `≃*₀o`: Bundled ordered monoid with zero isos. Also use for group with zero isos. ## Implementation notes @@ -66,9 +71,8 @@ structure. `OrderAddMonoidHom` is also used for ordered group homomorphisms. When possible, instead of parametrizing results over `(f : α →+o β)`, -you should parametrize over `(F : Type*) [OrderAddMonoidHomClass F α β] (f : F)`. - -When you extend this structure, make sure to extend `OrderAddMonoidHomClass`. -/ +you should parametrize over +`(F : Type*) [FunLike F M N] [MonoidHomClass F M N] [OrderHomClass F M N] (f : F)`. -/ structure OrderAddMonoidHom (α β : Type*) [Preorder α] [Preorder β] [AddZeroClass α] [AddZeroClass β] extends α →+ β where /-- An `OrderAddMonoidHom` is a monotone function. -/ @@ -77,6 +81,22 @@ structure OrderAddMonoidHom (α β : Type*) [Preorder α] [Preorder β] [AddZero /-- Infix notation for `OrderAddMonoidHom`. -/ infixr:25 " →+o " => OrderAddMonoidHom +/-- `α ≃+o β` is the type of monotone isomorphisms `α ≃ β` that preserve the `OrderedAddCommMonoid` +structure. + +`OrderAddMonoidIso` is also used for ordered group isomorphisms. + +When possible, instead of parametrizing results over `(f : α ≃+o β)`, +you should parametrize over +`(F : Type*) [FunLike F M N] [AddEquivClass F M N] [OrderIsoClass F M N] (f : F)`. -/ +structure OrderAddMonoidIso (α β : Type*) [Preorder α] [Preorder β] [AddZeroClass α] + [AddZeroClass β] extends α ≃+ β where + /-- An `OrderAddMonoidIso` respects `≤`. -/ + map_le_map_iff' {a b : α} : toFun a ≤ toFun b ↔ a ≤ b + +/-- Infix notation for `OrderAddMonoidIso`. -/ +infixr:25 " ≃+o " => OrderAddMonoidIso + -- Instances and lemmas are defined below through `@[to_additive]`. end AddMonoid @@ -87,9 +107,8 @@ section Monoid `OrderMonoidHom` is also used for ordered group homomorphisms. When possible, instead of parametrizing results over `(f : α →*o β)`, -you should parametrize over `(F : Type*) [OrderMonoidHomClass F α β] (f : F)`. - -When you extend this structure, make sure to extend `OrderMonoidHomClass`. -/ +you should parametrize over +`(F : Type*) [FunLike F M N] [MonoidHomClass F M N] [OrderHomClass F M N] (f : F)`. -/ @[to_additive] structure OrderMonoidHom (α β : Type*) [Preorder α] [Preorder β] [MulOneClass α] [MulOneClass β] extends α →* β where @@ -104,8 +123,9 @@ variable [Preorder α] [Preorder β] [MulOneClass α] [MulOneClass β] [FunLike /-- Turn an element of a type `F` satisfying `OrderHomClass F α β` and `MonoidHomClass F α β` into an actual `OrderMonoidHom`. This is declared as the default coercion from `F` to `α →*o β`. -/ @[to_additive (attr := coe) - "Turn an element of a type `F` satisfying `OrderAddMonoidHomClass F α β` into an actual - `OrderAddMonoidHom`. This is declared as the default coercion from `F` to `α →+o β`."] + "Turn an element of a type `F` satisfying `OrderHomClass F α β` and `AddMonoidHomClass F α β` + into an actual `OrderAddMonoidHom`. + This is declared as the default coercion from `F` to `α →+o β`."] def OrderMonoidHomClass.toOrderMonoidHom [OrderHomClass F α β] [MonoidHomClass F α β] (f : F) : α →*o β := { (f : α →* β) with monotone' := OrderHomClass.monotone f } @@ -117,6 +137,49 @@ def OrderMonoidHomClass.toOrderMonoidHom [OrderHomClass F α β] [MonoidHomClass instance [OrderHomClass F α β] [MonoidHomClass F α β] : CoeTC F (α →*o β) := ⟨OrderMonoidHomClass.toOrderMonoidHom⟩ +/-- `α ≃*o β` is the type of isomorphisms `α ≃ β` that preserve the `OrderedCommMonoid` structure. + +`OrderMonoidIso` is also used for ordered group isomorphisms. + +When possible, instead of parametrizing results over `(f : α ≃*o β)`, +you should parametrize over +`(F : Type*) [FunLike F M N] [MulEquivClass F M N] [OrderIsoClass F M N] (f : F)`. -/ +@[to_additive] +structure OrderMonoidIso (α β : Type*) [Preorder α] [Preorder β] [MulOneClass α] + [MulOneClass β] extends α ≃* β where + /-- An `OrderMonoidIso` respects `≤`. -/ + map_le_map_iff' {a b : α} : toFun a ≤ toFun b ↔ a ≤ b + +/-- Infix notation for `OrderMonoidIso`. -/ +infixr:25 " ≃*o " => OrderMonoidIso + +variable [Preorder α] [Preorder β] [MulOneClass α] [MulOneClass β] [FunLike F α β] + +/-- Turn an element of a type `F` satisfying `OrderIsoClass F α β` and `MulEquivClass F α β` +into an actual `OrderMonoidIso`. This is declared as the default coercion from `F` to `α ≃*o β`. -/ +@[to_additive (attr := coe) + "Turn an element of a type `F` satisfying `OrderIsoClass F α β` and `AddEquivClass F α β` + into an actual `OrderAddMonoidIso`. + This is declared as the default coercion from `F` to `α ≃+o β`."] +def OrderMonoidIsoClass.toOrderMonoidIso [EquivLike F α β] [OrderIsoClass F α β] + [MulEquivClass F α β] (f : F) : + α ≃*o β := + { (f : α ≃* β) with map_le_map_iff' := OrderIsoClass.map_le_map_iff f } + +/-- Any type satisfying `OrderMonoidHomClass` can be cast into `OrderMonoidHom` via + `OrderMonoidHomClass.toOrderMonoidHom`. -/ +@[to_additive "Any type satisfying `OrderAddMonoidHomClass` can be cast into `OrderAddMonoidHom` via + `OrderAddMonoidHomClass.toOrderAddMonoidHom`"] +instance [OrderHomClass F α β] [MonoidHomClass F α β] : CoeTC F (α →*o β) := + ⟨OrderMonoidHomClass.toOrderMonoidHom⟩ + +/-- Any type satisfying `OrderMonoidIsoClass` can be cast into `OrderMonoidIso` via + `OrderMonoidIsoClass.toOrderMonoidIso`. -/ +@[to_additive "Any type satisfying `OrderAddMonoidIsoClass` can be cast into `OrderAddMonoidIso` via + `OrderAddMonoidIsoClass.toOrderAddMonoidIso`"] +instance [EquivLike F α β] [OrderIsoClass F α β] [MulEquivClass F α β] : CoeTC F (α ≃*o β) := + ⟨OrderMonoidIsoClass.toOrderMonoidIso⟩ + end Monoid section MonoidWithZero @@ -129,9 +192,8 @@ the `MonoidWithZero` structure. `OrderMonoidWithZeroHom` is also used for group homomorphisms. When possible, instead of parametrizing results over `(f : α →+ β)`, -you should parametrize over `(F : Type*) [OrderMonoidWithZeroHomClass F α β] (f : F)`. - -When you extend this structure, make sure to extend `OrderMonoidWithZeroHomClass`. -/ +you should parameterize over +`(F : Type*) [FunLike F M N] [MonoidWithZeroHomClass F M N] [OrderHomClass F M N] (f : F)`. -/ structure OrderMonoidWithZeroHom (α β : Type*) [Preorder α] [Preorder β] [MulZeroOneClass α] [MulZeroOneClass β] extends α →*₀ β where /-- An `OrderMonoidWithZeroHom` is a monotone function. -/ @@ -446,6 +508,172 @@ end OrderedCommGroup end OrderMonoidHom +namespace OrderMonoidIso + +section Preorder + +variable [Preorder α] [Preorder β] [Preorder γ] [Preorder δ] [MulOneClass α] [MulOneClass β] + [MulOneClass γ] [MulOneClass δ] {f g : α ≃*o β} + +@[to_additive] +instance : EquivLike (α ≃*o β) α β where + coe f := f.toFun + inv f := f.invFun + left_inv f := f.left_inv + right_inv f := f.right_inv + coe_injective' f g h₁ h₂ := by + obtain ⟨⟨⟨_, _⟩⟩, _⟩ := f + obtain ⟨⟨⟨_, _⟩⟩, _⟩ := g + congr + +@[to_additive] +instance : OrderIsoClass (α ≃*o β) α β where + map_le_map_iff f := f.map_le_map_iff' + +@[to_additive] +instance : MulEquivClass (α ≃*o β) α β where + map_mul f := map_mul f.toMulEquiv + +-- Other lemmas should be accessed through the `FunLike` API +@[to_additive (attr := ext)] +theorem ext (h : ∀ a, f a = g a) : f = g := + DFunLike.ext f g h + +@[to_additive] +theorem toFun_eq_coe (f : α ≃*o β) : f.toFun = (f : α → β) := + rfl + +@[to_additive (attr := simp)] +theorem coe_mk (f : α ≃* β) (h) : (OrderMonoidIso.mk f h : α → β) = f := + rfl + +@[to_additive (attr := simp)] +theorem mk_coe (f : α ≃*o β) (h) : OrderMonoidIso.mk (f : α ≃* β) h = f := rfl + +/-- Reinterpret an ordered monoid isomorphism as an order isomorphism. -/ +@[to_additive "Reinterpret an ordered additive monoid isomomorphism as an order isomomorphism."] +def toOrderIso (f : α ≃*o β) : α ≃o β := + { f with + map_rel_iff' := map_le_map_iff f } + +@[to_additive (attr := simp)] +theorem coe_mulEquiv (f : α ≃*o β) : ((f : α ≃* β) : α → β) = f := + rfl + +@[to_additive (attr := simp)] +theorem coe_orderIso (f : α ≃*o β) : ((f : α →o β) : α → β) = f := + rfl + +@[to_additive] +theorem toMulEquiv_injective : Injective (toMulEquiv : _ → α ≃* β) := fun f g h => + ext <| by convert DFunLike.ext_iff.1 h using 0 + +@[to_additive] +theorem toOrderIso_injective : Injective (toOrderIso : _ → α ≃o β) := fun f g h => + ext <| by convert DFunLike.ext_iff.1 h using 0 + +variable (α) + +/-- The identity map as an ordered monoid isomorphism. -/ +@[to_additive "The identity map as an ordered additive monoid isomorphism."] +protected def refl : α ≃*o α := + { MulEquiv.refl α with map_le_map_iff' := by simp } + +@[to_additive (attr := simp)] +theorem coe_refl : ⇑(OrderMonoidIso.refl α) = id := + rfl + +@[to_additive] +instance : Inhabited (α ≃*o α) := + ⟨OrderMonoidIso.refl α⟩ + +variable {α} + +/-- Transitivity of multiplication-preserving order isomorphisms -/ +@[to_additive (attr := trans) "Transitivity of addition-preserving order isomorphisms"] +def trans (f : α ≃*o β) (g : β ≃*o γ) : α ≃*o γ := + { (f : α ≃* β).trans g with map_le_map_iff' := by simp } + +@[to_additive (attr := simp)] +theorem coe_trans (f : α ≃*o β) (g : β ≃*o γ) : (f.trans g : α → γ) = g ∘ f := + rfl + +@[to_additive (attr := simp)] +theorem trans_apply (f : α ≃*o β) (g : β ≃*o γ) (a : α) : (f.trans g) a = g (f a) := + rfl + +@[to_additive] +theorem coe_trans_mulEquiv (f : α ≃*o β) (g : β ≃*o γ) : + (f.trans g : α ≃* γ) = (f : α ≃* β).trans g := + rfl + +@[to_additive] +theorem coe_trans_orderIso (f : α ≃*o β) (g : β ≃*o γ) : + (f.trans g : α ≃o γ) = (f : α ≃o β).trans g := + rfl + +@[to_additive (attr := simp)] +theorem trans_assoc (f : α ≃*o β) (g : β ≃*o γ) (h : γ ≃*o δ) : + (f.trans g).trans h = f.trans (g.trans h) := + rfl + +@[to_additive (attr := simp)] +theorem trans_refl (f : α ≃*o β) : f.trans (OrderMonoidIso.refl β) = f := + rfl + +@[to_additive (attr := simp)] +theorem refl_trans (f : α ≃*o β) : (OrderMonoidIso.refl α).trans f = f := + rfl + +@[to_additive (attr := simp)] +theorem cancel_right {g₁ g₂ : α ≃*o β} {f : β ≃*o γ} (hf : Function.Injective f) : + g₁.trans f = g₂.trans f ↔ g₁ = g₂ := + ⟨fun h => ext fun a => hf <| by rw [← trans_apply, h, trans_apply], by rintro rfl; rfl⟩ + +@[to_additive (attr := simp)] +theorem cancel_left {g : α ≃*o β} {f₁ f₂ : β ≃*o γ} (hg : Function.Surjective g) : + g.trans f₁ = g.trans f₂ ↔ f₁ = f₂ := + ⟨fun h => ext <| hg.forall.2 <| DFunLike.ext_iff.1 h, fun _ => by congr⟩ + +@[to_additive (attr := simp)] +theorem toMulEquiv_eq_coe (f : α ≃*o β) : f.toMulEquiv = f := + rfl + +@[to_additive (attr := simp)] +theorem toOrderIso_eq_coe (f : α ≃*o β) : f.toOrderIso = f := + rfl + +variable (f) + +@[to_additive] +protected lemma strictMono : StrictMono f := + strictMono_of_le_iff_le fun _ _ ↦ (map_le_map_iff _).symm + +@[to_additive] +protected lemma strictMono_symm : StrictMono f.symm := + strictMono_of_le_iff_le <| fun a b ↦ by + rw [← map_le_map_iff f] + convert Iff.rfl <;> + exact f.toEquiv.apply_symm_apply _ + +end Preorder + +section OrderedCommGroup + +variable {hα : OrderedCommGroup α} {hβ : OrderedCommGroup β} + +/-- Makes an ordered group isomorphism from a proof that the map preserves multiplication. -/ +@[to_additive + "Makes an ordered additive group isomorphism from a proof that the map preserves + addition."] +def mk' (f : α ≃ β) (hf : ∀ {a b}, f a ≤ f b ↔ a ≤ b) (map_mul : ∀ a b : α, f (a * b) = f a * f b) : + α ≃*o β := + { MulEquiv.mk' f map_mul with map_le_map_iff' := hf } + +end OrderedCommGroup + +end OrderMonoidIso + namespace OrderMonoidWithZeroHom section Preorder diff --git a/Mathlib/Algebra/Order/Kleene.lean b/Mathlib/Algebra/Order/Kleene.lean index 4a57e54379465..064a1499bf6bf 100644 --- a/Mathlib/Algebra/Order/Kleene.lean +++ b/Mathlib/Algebra/Order/Kleene.lean @@ -4,11 +4,10 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Siddhartha Prasad, Yaël Dillies -/ import Mathlib.Algebra.Order.Monoid.Canonical.Defs -import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Ring.InjSurj -import Mathlib.Tactic.Monotonicity.Attr +import Mathlib.Algebra.Ring.Pi import Mathlib.Algebra.Ring.Prod -import Mathlib.Algebra.Order.Monoid.Canonical.Defs +import Mathlib.Tactic.Monotonicity.Attr /-! # Kleene Algebras diff --git a/Mathlib/Algebra/Order/Module/Defs.lean b/Mathlib/Algebra/Order/Module/Defs.lean index 2d1fc4bb7948c..fbf1c3d4a4b3b 100644 --- a/Mathlib/Algebra/Order/Module/Defs.lean +++ b/Mathlib/Algebra/Order/Module/Defs.lean @@ -1163,7 +1163,7 @@ end NoZeroSMulDivisors open Lean.Meta Qq -/-- Positivity extension for HSMul, i.e. (_ • _). -/ +/-- Positivity extension for HSMul, i.e. (_ • _). -/ @[positivity HSMul.hSMul _ _] def evalHSMul : PositivityExt where eval {_u α} zα pα (e : Q($α)) := do let .app (.app (.app (.app (.app (.app diff --git a/Mathlib/Algebra/Order/Monoid/Canonical/Defs.lean b/Mathlib/Algebra/Order/Monoid/Canonical/Defs.lean index 87f6d53965914..6e2104c91ef78 100644 --- a/Mathlib/Algebra/Order/Monoid/Canonical/Defs.lean +++ b/Mathlib/Algebra/Order/Monoid/Canonical/Defs.lean @@ -128,6 +128,10 @@ theorem one_lt_iff_ne_one : 1 < a ↔ a ≠ 1 := @[to_additive] theorem eq_one_or_one_lt (a : α) : a = 1 ∨ 1 < a := (one_le a).eq_or_lt.imp_left Eq.symm +@[to_additive] +lemma one_not_mem_iff {s : Set α} : 1 ∉ s ↔ ∀ x ∈ s, 1 < x := + bot_eq_one (α := α) ▸ bot_not_mem_iff + @[to_additive (attr := simp) add_pos_iff] theorem one_lt_mul_iff : 1 < a * b ↔ 1 < a ∨ 1 < b := by simp only [one_lt_iff_ne_one, Ne, mul_eq_one, not_and_or] diff --git a/Mathlib/Algebra/Order/Monoid/Submonoid.lean b/Mathlib/Algebra/Order/Monoid/Submonoid.lean index 6aa9c7927f6b2..d88dd033520c1 100644 --- a/Mathlib/Algebra/Order/Monoid/Submonoid.lean +++ b/Mathlib/Algebra/Order/Monoid/Submonoid.lean @@ -3,16 +3,15 @@ Copyright (c) 2021 Damiano Testa. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Damiano Testa -/ - import Mathlib.Algebra.Group.Submonoid.Operations -import Mathlib.Algebra.Order.GroupWithZero.Unbundled import Mathlib.Algebra.Order.Monoid.Basic -import Mathlib.Algebra.Order.ZeroLEOne /-! # Ordered instances on submonoids -/ +assert_not_exists MonoidWithZero + namespace SubmonoidClass variable {M S : Type*} [SetLike S M] @@ -103,21 +102,4 @@ variable {M} @[to_additive (attr := simp) mem_nonneg] lemma mem_oneLE : a ∈ oneLE M ↔ 1 ≤ a := Iff.rfl end Preorder - -section MulZeroClass -variable (α) [MulZeroOneClass α] [PartialOrder α] [PosMulStrictMono α] [ZeroLEOneClass α] - [NeZero (1 : α)] {a : α} - -/-- The submonoid of positive elements. -/ -@[simps] def pos : Submonoid α where - carrier := Set.Ioi 0 - one_mem' := zero_lt_one - mul_mem' := mul_pos - -variable {α} - -@[simp] lemma mem_pos : a ∈ pos α ↔ 0 < a := Iff.rfl - -end MulZeroClass - end Submonoid diff --git a/Mathlib/Algebra/Order/Monoid/Unbundled/MinMax.lean b/Mathlib/Algebra/Order/Monoid/Unbundled/MinMax.lean index d15dacf956b13..b509125489cc7 100644 --- a/Mathlib/Algebra/Order/Monoid/Unbundled/MinMax.lean +++ b/Mathlib/Algebra/Order/Monoid/Unbundled/MinMax.lean @@ -21,7 +21,7 @@ section CommSemigroup variable [LinearOrder α] [CommSemigroup β] @[to_additive] -lemma fn_min_mul_fn_max (f : α → β) (a b : α) : f (min a b) * f (max a b) = f a * f b := by +lemma fn_min_mul_fn_max (f : α → β) (a b : α) : f (min a b) * f (max a b) = f a * f b := by obtain h | h := le_total a b <;> simp [h, mul_comm] @[to_additive] diff --git a/Mathlib/Algebra/Order/Pi.lean b/Mathlib/Algebra/Order/Pi.lean index b89f80e5f895b..be50955c5d5ae 100644 --- a/Mathlib/Algebra/Order/Pi.lean +++ b/Mathlib/Algebra/Order/Pi.lean @@ -6,7 +6,6 @@ Authors: Simon Hudon, Patrick Massot import Mathlib.Algebra.Order.Monoid.Canonical.Defs import Mathlib.Algebra.Order.Ring.Defs import Mathlib.Algebra.Ring.Pi -import Mathlib.Algebra.Order.Monoid.Canonical.Defs /-! # Pi instances for ordered groups and monoids diff --git a/Mathlib/Algebra/Order/Ring/Unbundled/Basic.lean b/Mathlib/Algebra/Order/Ring/Unbundled/Basic.lean index 41655cc0c930f..68c19b0c396c3 100644 --- a/Mathlib/Algebra/Order/Ring/Unbundled/Basic.lean +++ b/Mathlib/Algebra/Order/Ring/Unbundled/Basic.lean @@ -199,7 +199,7 @@ theorem mul_le_mul_of_nonpos_of_nonpos' [ExistsAddOfLE α] [PosMulMono α] [MulP (hca : c ≤ a) (hdb : d ≤ b) (ha : a ≤ 0) (hd : d ≤ 0) : a * b ≤ c * d := (mul_le_mul_of_nonpos_left hdb ha).trans <| mul_le_mul_of_nonpos_right hca hd -/-- Variant of `mul_le_of_le_one_left` for `b` non-positive instead of non-negative. -/ +/-- Variant of `mul_le_of_le_one_left` for `b` non-positive instead of non-negative. -/ theorem le_mul_of_le_one_left [ExistsAddOfLE α] [MulPosMono α] [CovariantClass α α (swap (· + ·)) (· ≤ ·)] [ContravariantClass α α (swap (· + ·)) (· ≤ ·)] (hb : b ≤ 0) (h : a ≤ 1) : b ≤ a * b := by diff --git a/Mathlib/Algebra/Polynomial/Basic.lean b/Mathlib/Algebra/Polynomial/Basic.lean index cce2711cbb23d..dc5582e2148d6 100644 --- a/Mathlib/Algebra/Polynomial/Basic.lean +++ b/Mathlib/Algebra/Polynomial/Basic.lean @@ -930,7 +930,7 @@ section Update /-- Replace the coefficient of a `p : R[X]` at a given degree `n : ℕ` by a given value `a : R`. If `a = 0`, this is equal to `p.erase n` -If `p.natDegree < n` and `a ≠ 0`, this increases the degree to `n`. -/ +If `p.natDegree < n` and `a ≠ 0`, this increases the degree to `n`. -/ def update (p : R[X]) (n : ℕ) (a : R) : R[X] := Polynomial.ofFinsupp (p.toFinsupp.update n a) diff --git a/Mathlib/Algebra/Polynomial/Degree/Lemmas.lean b/Mathlib/Algebra/Polynomial/Degree/Lemmas.lean index 809a37a648c0d..d3cc2b29e0004 100644 --- a/Mathlib/Algebra/Polynomial/Degree/Lemmas.lean +++ b/Mathlib/Algebra/Polynomial/Degree/Lemmas.lean @@ -58,6 +58,13 @@ theorem natDegree_comp_le : natDegree (p.comp q) ≤ natDegree p * natDegree q : mul_le_mul_of_nonneg_right (le_natDegree_of_ne_zero (mem_support_iff.1 hn)) (Nat.zero_le _) +theorem natDegree_comp_eq_of_mul_ne_zero (h : p.leadingCoeff * q.leadingCoeff ^ p.natDegree ≠ 0) : + natDegree (p.comp q) = natDegree p * natDegree q := by + by_cases hq : natDegree q = 0 + · exact le_antisymm natDegree_comp_le (by simp [hq]) + apply natDegree_eq_of_le_of_coeff_ne_zero natDegree_comp_le + rwa [coeff_comp_degree_mul_degree hq] + theorem degree_pos_of_root {p : R[X]} (hp : p ≠ 0) (h : IsRoot p a) : 0 < degree p := lt_of_not_ge fun hlt => by have := eq_C_of_degree_le_zero hlt @@ -345,9 +352,8 @@ theorem natDegree_comp : natDegree (p.comp q) = natDegree p * natDegree q := by natDegree_C, mul_zero] · by_cases p0 : p = 0 · simp only [p0, zero_comp, natDegree_zero, zero_mul] - refine le_antisymm natDegree_comp_le (le_natDegree_of_ne_zero ?_) - simp only [coeff_comp_degree_mul_degree q0, p0, mul_eq_zero, leadingCoeff_eq_zero, or_self_iff, - ne_zero_of_natDegree_gt (Nat.pos_of_ne_zero q0), pow_ne_zero, Ne, not_false_iff] + · simp only [Ne, mul_eq_zero, leadingCoeff_eq_zero, p0, natDegree_comp_eq_of_mul_ne_zero, + ne_zero_of_natDegree_gt (Nat.pos_of_ne_zero q0), not_false_eq_true, pow_ne_zero, or_self] @[simp] theorem natDegree_iterate_comp (k : ℕ) : diff --git a/Mathlib/Algebra/Polynomial/Module/Basic.lean b/Mathlib/Algebra/Polynomial/Module/Basic.lean index 4beded12152cd..b1da6574813fc 100644 --- a/Mathlib/Algebra/Polynomial/Module/Basic.lean +++ b/Mathlib/Algebra/Polynomial/Module/Basic.lean @@ -66,7 +66,7 @@ theorem add_apply (g₁ g₂ : PolynomialModule R M) (a : ℕ) : (g₁ + g₂) a Finsupp.add_apply g₁ g₂ a /-- The monomial `m * x ^ i`. This is defeq to `Finsupp.singleAddHom`, and is redefined here -so that it has the desired type signature. -/ +so that it has the desired type signature. -/ noncomputable def single (i : ℕ) : M →+ PolynomialModule R M := Finsupp.singleAddHom i @@ -305,7 +305,7 @@ lemma aeval_equivPolynomial {S : Type*} [CommRing S] [Algebra S R] rw [equivPolynomial_single, aeval_monomial, mul_comm, map_single, Algebra.linearMap_apply, eval_single, smul_eq_mul] -/-- `comp p q` is the composition of `p : R[X]` and `q : M[X]` as `q(p(x))`. -/ +/-- `comp p q` is the composition of `p : R[X]` and `q : M[X]` as `q(p(x))`. -/ @[simps!] noncomputable def comp (p : R[X]) : PolynomialModule R M →ₗ[R] PolynomialModule R M := LinearMap.comp ((eval p).restrictScalars R) (map R[X] (lsingle R 0)) diff --git a/Mathlib/Algebra/Polynomial/Reverse.lean b/Mathlib/Algebra/Polynomial/Reverse.lean index 788dcb3ce0de2..2dba679853097 100644 --- a/Mathlib/Algebra/Polynomial/Reverse.lean +++ b/Mathlib/Algebra/Polynomial/Reverse.lean @@ -86,7 +86,7 @@ In other words, the terms with exponent `[0, ..., N]` now have exponent `[N, ... In practice, `reflect` is only used when `N` is at least as large as the degree of `f`. -Eventually, it will be used with `N` exactly equal to the degree of `f`. -/ +Eventually, it will be used with `N` exactly equal to the degree of `f`. -/ noncomputable def reflect (N : ℕ) : R[X] → R[X] | ⟨f⟩ => ⟨Finsupp.embDomain (revAt N) f⟩ diff --git a/Mathlib/Algebra/Polynomial/RingDivision.lean b/Mathlib/Algebra/Polynomial/RingDivision.lean index c3fd1bd83e3f6..e4e14ccf3d644 100644 --- a/Mathlib/Algebra/Polynomial/RingDivision.lean +++ b/Mathlib/Algebra/Polynomial/RingDivision.lean @@ -27,6 +27,26 @@ universe u v w z variable {R : Type u} {S : Type v} {T : Type w} {a b : R} {n : ℕ} +section Semiring + +variable [Semiring R] {p q : R[X]} + +theorem Monic.comp (hp : p.Monic) (hq : q.Monic) (h : q.natDegree ≠ 0) : (p.comp q).Monic := by + nontriviality R + have : (p.comp q).natDegree = p.natDegree * q.natDegree := by + apply natDegree_comp_eq_of_mul_ne_zero + simp [hp.leadingCoeff, hq.leadingCoeff] + rw [Monic.def, Polynomial.leadingCoeff, this, coeff_comp_degree_mul_degree h, hp.leadingCoeff, + hq.leadingCoeff, one_pow, mul_one] + +theorem Monic.comp_X_add_C (hp : p.Monic) (r : R) : (p.comp (X + C r)).Monic := by + nontriviality R + refine hp.comp (monic_X_add_C _) fun ha => ?_ + rw [natDegree_X_add_C] at ha + exact one_ne_zero ha + +end Semiring + section CommRing variable [CommRing R] {p q : R[X]} @@ -210,8 +230,6 @@ theorem not_isUnit_of_natDegree_pos (p : R[X]) (hpl : 0 < p.natDegree) : ¬ IsUnit p := not_isUnit_of_degree_pos _ (natDegree_pos_iff_degree_pos.mp hpl) -variable [CharZero R] - end NoZeroDivisors section NoZeroDivisors @@ -527,6 +545,9 @@ theorem rootMultiplicity_mul' {p q : R[X]} {x : R} simp_rw [eval_divByMonic_eq_trailingCoeff_comp] at hpq simp_rw [rootMultiplicity_eq_natTrailingDegree, mul_comp, natTrailingDegree_mul' hpq] +theorem Monic.comp_X_sub_C {p : R[X]} (hp : p.Monic) (r : R) : (p.comp (X - C r)).Monic := by + simpa using hp.comp_X_add_C (-r) + variable [IsDomain R] {p q : R[X]} @[simp] @@ -654,17 +675,6 @@ theorem natDegree_multiset_prod_X_sub_C_eq_card (s : Multiset R) : mul_one] · exact Multiset.forall_mem_map_iff.2 fun a _ => monic_X_sub_C a -theorem Monic.comp (hp : p.Monic) (hq : q.Monic) (h : q.natDegree ≠ 0) : (p.comp q).Monic := by - rw [Monic.def, leadingCoeff_comp h, Monic.def.1 hp, Monic.def.1 hq, one_pow, one_mul] - -theorem Monic.comp_X_add_C (hp : p.Monic) (r : R) : (p.comp (X + C r)).Monic := by - refine hp.comp (monic_X_add_C _) fun ha => ?_ - rw [natDegree_X_add_C] at ha - exact one_ne_zero ha - -theorem Monic.comp_X_sub_C (hp : p.Monic) (r : R) : (p.comp (X - C r)).Monic := by - simpa using hp.comp_X_add_C (-r) - theorem units_coeff_zero_smul (c : R[X]ˣ) (p : R[X]) : (c : R[X]).coeff 0 • p = c * p := by rw [← Polynomial.C_mul', ← Polynomial.eq_C_of_degree_eq_zero (degree_coe_units c)] diff --git a/Mathlib/Algebra/Quandle.lean b/Mathlib/Algebra/Quandle.lean index c28296aa12d17..a3921e4072e72 100644 --- a/Mathlib/Algebra/Quandle.lean +++ b/Mathlib/Algebra/Quandle.lean @@ -93,7 +93,7 @@ The binary operation is regarded as a left action of the type on itself. class Shelf (α : Type u) where /-- The action of the `Shelf` over `α`-/ act : α → α → α - /-- A verification that `act` is self-distributive-/ + /-- A verification that `act` is self-distributive -/ self_distrib : ∀ {x y z : α}, act x (act y z) = act (act x y) (act x z) /-- @@ -111,7 +111,7 @@ This is also the notion of rack and quandle homomorphisms. structure ShelfHom (S₁ : Type*) (S₂ : Type*) [Shelf S₁] [Shelf S₂] where /-- The function under the Shelf Homomorphism -/ toFun : S₁ → S₂ - /-- The homomorphism property of a Shelf Homomorphism-/ + /-- The homomorphism property of a Shelf Homomorphism -/ map_act' : ∀ {x y : S₁}, toFun (Shelf.act x y) = Shelf.act (toFun x) (toFun y) /-- A *rack* is an automorphic set (a set with an action on itself by @@ -129,13 +129,13 @@ class Rack (α : Type u) extends Shelf α where /-- Proof of right inverse -/ right_inv : ∀ x, Function.RightInverse (invAct x) (act x) -/-- Action of a Shelf-/ +/-- Action of a Shelf -/ scoped[Quandles] infixr:65 " ◃ " => Shelf.act -/-- Inverse Action of a Rack-/ +/-- Inverse Action of a Rack -/ scoped[Quandles] infixr:65 " ◃⁻¹ " => Rack.invAct -/-- Shelf Homomorphism-/ +/-- Shelf Homomorphism -/ scoped[Quandles] infixr:25 " →◃ " => ShelfHom open Quandles diff --git a/Mathlib/Algebra/Quaternion.lean b/Mathlib/Algebra/Quaternion.lean index 56d78e1cdaf61..a063ebfdef089 100644 --- a/Mathlib/Algebra/Quaternion.lean +++ b/Mathlib/Algebra/Quaternion.lean @@ -296,7 +296,7 @@ variable [Ring R] * `i * j = k`, `j * i = -k`; * `k * k = -c₁ * c₂`; * `i * k = c₁ * j`, `k * i = -c₁ * j`; -* `j * k = -c₂ * i`, `k * j = c₂ * i`. -/ +* `j * k = -c₂ * i`, `k * j = c₂ * i`. -/ instance : Mul ℍ[R,c₁,c₂] := ⟨fun a b => ⟨a.1 * b.1 + c₁ * a.2 * b.2 + c₂ * a.3 * b.3 - c₁ * c₂ * a.4 * b.4, diff --git a/Mathlib/Algebra/Ring/Subring/Basic.lean b/Mathlib/Algebra/Ring/Subring/Basic.lean index 365272a227add..e7263037e785a 100644 --- a/Mathlib/Algebra/Ring/Subring/Basic.lean +++ b/Mathlib/Algebra/Ring/Subring/Basic.lean @@ -819,7 +819,7 @@ theorem mem_closure_iff {s : Set R} {x} : mul_mem hx hy) (zero_mem _) (fun x y hx hy => add_mem hx hy) fun x hx => neg_mem hx⟩ -/-- If all elements of `s : Set A` commute pairwise, then `closure s` is a commutative ring. -/ +/-- If all elements of `s : Set A` commute pairwise, then `closure s` is a commutative ring. -/ def closureCommRingOfComm {s : Set R} (hcomm : ∀ a ∈ s, ∀ b ∈ s, a * b = b * a) : CommRing (closure s) := { (closure s).toRing with diff --git a/Mathlib/Algebra/Ring/Subring/Units.lean b/Mathlib/Algebra/Ring/Subring/Units.lean index 76b3f05824db9..157cdab1d1c19 100644 --- a/Mathlib/Algebra/Ring/Subring/Units.lean +++ b/Mathlib/Algebra/Ring/Subring/Units.lean @@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Birkbeck -/ import Mathlib.Algebra.Group.Subgroup.Basic -import Mathlib.Algebra.Order.Monoid.Submonoid +import Mathlib.Algebra.Order.GroupWithZero.Submonoid import Mathlib.Algebra.Order.Ring.Defs /-! diff --git a/Mathlib/Algebra/SMulWithZero.lean b/Mathlib/Algebra/SMulWithZero.lean index 3ef4bb96b5b9f..1eba1392560bd 100644 --- a/Mathlib/Algebra/SMulWithZero.lean +++ b/Mathlib/Algebra/SMulWithZero.lean @@ -196,7 +196,7 @@ theorem smul_inv₀ [SMulCommClass α β β] [IsScalarTower α β β] (c : α) ( obtain rfl | hx := eq_or_ne x 0 · simp only [inv_zero, smul_zero] · refine inv_eq_of_mul_eq_one_left ?_ - rw [smul_mul_smul, inv_mul_cancel₀ hc, inv_mul_cancel₀ hx, one_smul] + rw [smul_mul_smul_comm, inv_mul_cancel₀ hc, inv_mul_cancel₀ hx, one_smul] end GroupWithZero diff --git a/Mathlib/Algebra/Star/Basic.lean b/Mathlib/Algebra/Star/Basic.lean index c592e1abb4297..35276edb14891 100644 --- a/Mathlib/Algebra/Star/Basic.lean +++ b/Mathlib/Algebra/Star/Basic.lean @@ -111,7 +111,7 @@ theorem star_eq_iff_star_eq [InvolutiveStar R] {r s : R} : star r = s ↔ star s /-- Typeclass for a trivial star operation. This is mostly meant for `ℝ`. -/ class TrivialStar (R : Type u) [Star R] : Prop where - /-- Condition that star is trivial-/ + /-- Condition that star is trivial -/ star_trivial : ∀ r : R, star r = r export TrivialStar (star_trivial) @@ -221,7 +221,7 @@ theorem star_id_of_comm {R : Type*} [CommSemiring R] {x : R} : star x = x := end /-- A `*`-additive monoid `R` is an additive monoid with an involutive `star` operation which -preserves addition. -/ +preserves addition. -/ class StarAddMonoid (R : Type u) [AddMonoid R] extends InvolutiveStar R where /-- `star` commutes with addition -/ star_add : ∀ r s : R, star (r + s) = star r + star s @@ -261,16 +261,16 @@ theorem star_sub [AddGroup R] [StarAddMonoid R] (r s : R) : star (r - s) = star (starAddEquiv : R ≃+ R).map_sub _ _ @[simp] -theorem star_nsmul [AddMonoid R] [StarAddMonoid R] (x : R) (n : ℕ) : star (n • x) = n • star x := +theorem star_nsmul [AddMonoid R] [StarAddMonoid R] (n : ℕ) (x : R) : star (n • x) = n • star x := (starAddEquiv : R ≃+ R).toAddMonoidHom.map_nsmul _ _ @[simp] -theorem star_zsmul [AddGroup R] [StarAddMonoid R] (x : R) (n : ℤ) : star (n • x) = n • star x := +theorem star_zsmul [AddGroup R] [StarAddMonoid R] (n : ℤ) (x : R) : star (n • x) = n • star x := (starAddEquiv : R ≃+ R).toAddMonoidHom.map_zsmul _ _ /-- A `*`-ring `R` is a non-unital, non-associative (semi)ring with an involutive `star` operation which is additive which makes `R` with its multiplicative structure into a `*`-multiplication -(i.e. `star (r * s) = star s * star r`). -/ +(i.e. `star (r * s) = star s * star r`). -/ class StarRing (R : Type u) [NonUnitalNonAssocSemiring R] extends StarMul R where /-- `star` commutes with addition -/ star_add : ∀ r s : R, star (r + s) = star r + star s @@ -415,13 +415,16 @@ attribute [simp] star_smul instance StarMul.toStarModule [CommMonoid R] [StarMul R] : StarModule R R := ⟨star_mul'⟩ -instance StarAddMonoid.toStarModuleNat {α} [AddCommMonoid α] [StarAddMonoid α] : StarModule ℕ α := - ⟨fun n a ↦ by rw [star_nsmul, star_trivial n]⟩ +instance StarAddMonoid.toStarModuleNat {α} [AddCommMonoid α] [StarAddMonoid α] : + StarModule ℕ α where star_smul := star_nsmul + +instance StarAddMonoid.toStarModuleInt {α} [AddCommGroup α] [StarAddMonoid α] : StarModule ℤ α where + star_smul := star_zsmul namespace RingHomInvPair /-- Instance needed to define star-linear maps over a commutative star ring -(ex: conjugate-linear maps when R = ℂ). -/ +(ex: conjugate-linear maps when R = ℂ). -/ instance [CommSemiring R] [StarRing R] : RingHomInvPair (starRingEnd R) (starRingEnd R) := ⟨RingHom.ext star_star, RingHom.ext star_star⟩ diff --git a/Mathlib/Algebra/Star/Order.lean b/Mathlib/Algebra/Star/Order.lean index 3d1200121de45..a172c47b06e1e 100644 --- a/Mathlib/Algebra/Star/Order.lean +++ b/Mathlib/Algebra/Star/Order.lean @@ -294,7 +294,7 @@ lemma StarModule.smul_lt_smul_of_pos {a b : A} {c : R} (hab : a < b) (hc : 0 < c obtain ⟨y, hy⟩ := hx apply AddSubmonoid.subset_closure refine ⟨z • y, ?_⟩ - simp only [star_smul, smul_mul_smul, hz, hy] + simp only [star_smul, smul_mul_smul_comm, hz, hy] case zeroc => simpa only [zero_smul] using zero_mem _ case addc => exact fun c' d ↦ by simpa only [add_smul] using add_mem case zero => simpa only [smul_zero] using zero_mem _ diff --git a/Mathlib/Algebra/Star/StarAlgHom.lean b/Mathlib/Algebra/Star/StarAlgHom.lean index 09ee718f7b1c2..53f42e18c47a9 100644 --- a/Mathlib/Algebra/Star/StarAlgHom.lean +++ b/Mathlib/Algebra/Star/StarAlgHom.lean @@ -263,7 +263,7 @@ variable (R : Type*) {S A B : Type*} [Monoid R] [Monoid S] [Star A] [Star B] [IsScalarTower R S A] [IsScalarTower R S B] /-- If a monoid `R` acts on another monoid `S`, then a non-unital star algebra homomorphism -over `S` can be viewed as a non-unital star algebra homomorphism over `R`. -/ +over `S` can be viewed as a non-unital star algebra homomorphism over `R`. -/ def restrictScalars (f : A →⋆ₙₐ[S] B) : A →⋆ₙₐ[R] B := { (f : A →ₙₐ[S] B).restrictScalars R with map_star' := map_star f } diff --git a/Mathlib/Algebra/TrivSqZeroExt.lean b/Mathlib/Algebra/TrivSqZeroExt.lean index 57a769c399bef..d8111d36eba22 100644 --- a/Mathlib/Algebra/TrivSqZeroExt.lean +++ b/Mathlib/Algebra/TrivSqZeroExt.lean @@ -873,7 +873,7 @@ def lift (f : R →ₐ[S] A) (g : M →ₗ[S] A) (TrivSqZeroExt.ind fun r₁ m₁ => TrivSqZeroExt.ind fun r₂ m₂ => by dsimp - simp only [add_zero, zero_add, add_mul, mul_add, smul_mul_smul, hg, smul_zero, + simp only [add_zero, zero_add, add_mul, mul_add, smul_mul_smul_comm, hg, smul_zero, op_smul_eq_smul] rw [← map_mul, LinearMap.map_add, add_comm (g _), add_assoc, hfg, hgf]) diff --git a/Mathlib/AlgebraicGeometry/Cover/Open.lean b/Mathlib/AlgebraicGeometry/Cover/Open.lean index 20acd2442916a..959dc19b68c73 100644 --- a/Mathlib/AlgebraicGeometry/Cover/Open.lean +++ b/Mathlib/AlgebraicGeometry/Cover/Open.lean @@ -92,7 +92,7 @@ theorem OpenCover.iSup_opensRange {X : Scheme.{u}} (𝒰 : X.OpenCover) : Opens.ext <| by rw [Opens.coe_iSup]; exact 𝒰.iUnion_range /-- Given an open cover `{ Uᵢ }` of `X`, and for each `Uᵢ` an open cover, we may combine these -open covers to form an open cover of `X`. -/ +open covers to form an open cover of `X`. -/ @[simps! J obj map] def OpenCover.bind (f : ∀ x : 𝒰.J, OpenCover (𝒰.obj x)) : OpenCover X where J := Σ i : 𝒰.J, (f i).J diff --git a/Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian.lean b/Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian.lean index 6042ae7f510d6..b3f2eea5ac125 100644 --- a/Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian.lean +++ b/Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian.lean @@ -359,8 +359,8 @@ variable (W') in /-- The proposition that a point representative $(x, y, z)$ in `W'` is nonsingular. In other words, either $W_X(x, y, z) \ne 0$, $W_Y(x, y, z) \ne 0$, or $W_Z(x, y, z) \ne 0$. -Note that this definition is only mathematically accurate for fields. -TODO: generalise this definition to be mathematically accurate for a larger class of rings. -/ +Note that this definition is only mathematically accurate for fields. -/ +-- TODO: generalise this definition to be mathematically accurate for a larger class of rings. def Nonsingular (P : Fin 3 → R) : Prop := W'.Equation P ∧ (eval P W'.polynomialX ≠ 0 ∨ eval P W'.polynomialY ≠ 0 ∨ eval P W'.polynomialZ ≠ 0) @@ -1619,3 +1619,5 @@ end WeierstrassCurve.Jacobian abbrev WeierstrassCurve.Affine.Point.toJacobian {R : Type u} [CommRing R] [Nontrivial R] {W : Affine R} (P : W.Point) : W.toJacobian.Point := Jacobian.Point.fromAffine P + +set_option linter.style.longFile 1700 diff --git a/Mathlib/AlgebraicGeometry/EllipticCurve/Projective.lean b/Mathlib/AlgebraicGeometry/EllipticCurve/Projective.lean index f1314e4735540..e010653a6a29e 100644 --- a/Mathlib/AlgebraicGeometry/EllipticCurve/Projective.lean +++ b/Mathlib/AlgebraicGeometry/EllipticCurve/Projective.lean @@ -3,9 +3,10 @@ Copyright (c) 2023 David Kurniadi Angdinata. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: David Kurniadi Angdinata -/ -import Mathlib.AlgebraicGeometry.EllipticCurve.Affine import Mathlib.Algebra.MvPolynomial.CommRing import Mathlib.Algebra.MvPolynomial.PDeriv +import Mathlib.AlgebraicGeometry.EllipticCurve.Affine +import Mathlib.Data.Fin.Tuple.Reflection /-! # Projective coordinates for Weierstrass curves @@ -18,7 +19,7 @@ condition. Let `W` be a Weierstrass curve over a field `F`. A point on the projective plane is an equivalence class of triples $[x:y:z]$ with coordinates in `F` such that $(x, y, z) \sim (x', y', z')$ precisely -if there is some unit $u$ of `F` such that $(x, y, z) = (ux', uy', uz')$, with an extra condition +if there is some unit `u` of `F` such that $(x, y, z) = (ux', uy', uz')$, with an extra condition that $(x, y, z) \ne (0, 0, 0)$. As described in `Mathlib.AlgebraicGeometry.EllipticCurve.Affine`, a rational point is a point on the projective plane satisfying a homogeneous Weierstrass equation, and being nonsingular means the partial derivatives $W_X(X, Y, Z)$, $W_Y(X, Y, Z)$, and $W_Z(X, Y, Z)$ @@ -42,11 +43,11 @@ given by a tuple consisting of $[x:y:z]$ and the nonsingular condition on any re A point representative is implemented as a term `P` of type `Fin 3 → R`, which allows for the vector notation `![x, y, z]`. However, `P` is not definitionally equivalent to the expanded vector -`![P x, P y, P z]`, so the auxiliary lemma `fin3_def` can be used to convert between the two forms. -The equivalence of two point representatives `P` and `Q` is implemented as an equivalence of orbits -of the action of `Rˣ`, or equivalently that there is some unit `u` of `R` such that `P = u • Q`. -However, `u • Q` is again not definitionally equal to `![u * Q x, u * Q y, u * Q z]`, so the -auxiliary lemmas `smul_fin3` and `smul_fin3_ext` can be used to convert between the two forms. +`![P x, P y, P z]`, so the lemmas `fin3_def` and `fin3_def_ext` can be used to convert between the +two forms. The equivalence of two point representatives `P` and `Q` is implemented as an equivalence +of orbits of the action of `Rˣ`, or equivalently that there is some unit `u` of `R` such that +`P = u • Q`. However, `u • Q` is not definitionally equal to `![u * Q x, u * Q y, u * Q z]`, so the +lemmas `smul_fin3` and `smul_fin3_ext` can be used to convert between the two forms. ## References @@ -57,23 +58,27 @@ auxiliary lemmas `smul_fin3` and `smul_fin3_ext` can be used to convert between elliptic curve, rational point, projective coordinates -/ -local notation "x" => 0 +local notation3 "x" => (0 : Fin 3) -local notation "y" => 1 +local notation3 "y" => (1 : Fin 3) -local notation "z" => 2 +local notation3 "z" => (2 : Fin 3) local macro "matrix_simp" : tactic => `(tactic| simp only [Matrix.head_cons, Matrix.tail_cons, Matrix.smul_empty, Matrix.smul_cons, Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.cons_val_two]) -universe u +universe u v /-! ## Weierstrass curves -/ /-- An abbreviation for a Weierstrass curve in projective coordinates. -/ -abbrev WeierstrassCurve.Projective := - WeierstrassCurve +abbrev WeierstrassCurve.Projective (R : Type u) : Type u := + WeierstrassCurve R + +/-- The coercion to a Weierstrass curve in projective coordinates. -/ +abbrev WeierstrassCurve.toProjective {R : Type u} (W : WeierstrassCurve R) : Projective R := + W namespace WeierstrassCurve.Projective @@ -85,231 +90,360 @@ local macro "eval_simp" : tactic => local macro "pderiv_simp" : tactic => `(tactic| simp only [map_ofNat, map_neg, map_add, map_sub, map_mul, pderiv_mul, pderiv_pow, pderiv_C, pderiv_X_self, pderiv_X_of_ne one_ne_zero, pderiv_X_of_ne one_ne_zero.symm, - pderiv_X_of_ne (by decide : (2 : Fin 3) ≠ 0), pderiv_X_of_ne (by decide : (0 : Fin 3) ≠ 2), - pderiv_X_of_ne (by decide : (2 : Fin 3) ≠ 1), pderiv_X_of_ne (by decide : (1 : Fin 3) ≠ 2)]) + pderiv_X_of_ne (by decide : z ≠ x), pderiv_X_of_ne (by decide : x ≠ z), + pderiv_X_of_ne (by decide : z ≠ y), pderiv_X_of_ne (by decide : y ≠ z)]) + +variable {R : Type u} {W' : Projective R} {F : Type v} [Field F] {W : Projective F} -variable {R : Type u} [CommRing R] (W : Projective R) +section Projective -lemma fin3_def {R : Type u} (P : Fin 3 → R) : P = ![P x, P y, P z] := by +/-! ### Projective coordinates -/ + +lemma fin3_def (P : Fin 3 → R) : ![P x, P y, P z] = P := by ext n; fin_cases n <;> rfl -lemma smul_fin3 {R : Type u} [CommRing R] (P : Fin 3 → R) (u : Rˣ) : - u • P = ![u * P x, u * P y, u * P z] := by - rw [fin3_def P] - matrix_simp - simp only [Units.smul_def, smul_eq_mul] +lemma fin3_def_ext (X Y Z : R) : ![X, Y, Z] x = X ∧ ![X, Y, Z] y = Y ∧ ![X, Y, Z] z = Z := + ⟨rfl, rfl, rfl⟩ + +lemma comp_fin3 {S} (f : R → S) (X Y Z : R) : f ∘ ![X, Y, Z] = ![f X, f Y, f Z] := + (FinVec.map_eq _ _).symm + +variable [CommRing R] + +lemma smul_fin3 (P : Fin 3 → R) (u : R) : u • P = ![u * P x, u * P y, u * P z] := + List.ofFn_inj.mp rfl -lemma smul_fin3_ext {R : Type u} [CommRing R] (P : Fin 3 → R) (u : Rˣ) : - (u • P) x = u * P x ∧ (u • P) y = u * P y ∧ (u • P) z = u * P z := by - refine ⟨?_, ?_, ?_⟩ <;> simp only [Units.smul_def, Pi.smul_apply, smul_eq_mul] +lemma smul_fin3_ext (P : Fin 3 → R) (u : R) : + (u • P) x = u * P x ∧ (u • P) y = u * P y ∧ (u • P) z = u * P z := + ⟨rfl, rfl, rfl⟩ /-- The equivalence setoid for a point representative. -/ scoped instance instSetoidPoint : Setoid <| Fin 3 → R := MulAction.orbitRel Rˣ <| Fin 3 → R +variable (R) in /-- The equivalence class of a point representative. -/ -abbrev PointClass (R : Type u) [CommRing R] : Type u := +abbrev PointClass : Type u := MulAction.orbitRel.Quotient Rˣ <| Fin 3 → R +lemma smul_equiv (P : Fin 3 → R) {u : R} (hu : IsUnit u) : u • P ≈ P := + ⟨hu.unit, rfl⟩ + +@[simp] +lemma smul_eq (P : Fin 3 → R) {u : R} (hu : IsUnit u) : (⟦u • P⟧ : PointClass R) = ⟦P⟧ := + Quotient.eq.mpr <| smul_equiv P hu + +variable (W') in /-- The coercion to a Weierstrass curve in affine coordinates. -/ abbrev toAffine : Affine R := - W + W' + +lemma equiv_iff_eq_of_Z_eq' {P Q : Fin 3 → R} (hz : P z = Q z) (mem : Q z ∈ nonZeroDivisors R) : + P ≈ Q ↔ P = Q := by + refine ⟨?_, by rintro rfl; exact Setoid.refl _⟩ + rintro ⟨u, rfl⟩ + rw [← one_mul (Q z)] at hz + simp_rw [Units.smul_def, (mul_cancel_right_mem_nonZeroDivisors mem).mp hz, one_smul] + +lemma equiv_iff_eq_of_Z_eq [NoZeroDivisors R] {P Q : Fin 3 → R} (hz : P z = Q z) (hQz : Q z ≠ 0) : + P ≈ Q ↔ P = Q := + equiv_iff_eq_of_Z_eq' hz (mem_nonZeroDivisors_of_ne_zero hQz) + +lemma Z_eq_zero_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : P z = 0 ↔ Q z = 0 := by + rcases h with ⟨_, rfl⟩ + simp only [Units.smul_def, smul_fin3_ext, Units.mul_right_eq_zero] + +lemma X_eq_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : P x * Q z = Q x * P z := by + rcases h with ⟨u, rfl⟩ + simp only [Units.smul_def, smul_fin3_ext] + ring1 + +lemma Y_eq_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : P y * Q z = Q y * P z := by + rcases h with ⟨u, rfl⟩ + simp only [Units.smul_def, smul_fin3_ext] + ring1 + +lemma not_equiv_of_Z_eq_zero_left {P Q : Fin 3 → R} (hPz : P z = 0) (hQz : Q z ≠ 0) : ¬P ≈ Q := + fun h => hQz <| (Z_eq_zero_of_equiv h).mp hPz + +lemma not_equiv_of_Z_eq_zero_right {P Q : Fin 3 → R} (hPz : P z ≠ 0) (hQz : Q z = 0) : ¬P ≈ Q := + fun h => hPz <| (Z_eq_zero_of_equiv h).mpr hQz + +lemma not_equiv_of_X_ne {P Q : Fin 3 → R} (hx : P x * Q z ≠ Q x * P z) : ¬P ≈ Q := + hx.comp X_eq_of_equiv + +lemma not_equiv_of_Y_ne {P Q : Fin 3 → R} (hy : P y * Q z ≠ Q y * P z) : ¬P ≈ Q := + hy.comp Y_eq_of_equiv + +lemma equiv_of_X_eq_of_Y_eq {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) + (hx : P x * Q z = Q x * P z) (hy : P y * Q z = Q y * P z) : P ≈ Q := by + use Units.mk0 _ hPz / Units.mk0 _ hQz + simp only [Units.smul_def, smul_fin3, Units.val_div_eq_div_val, Units.val_mk0, mul_comm, mul_div, + ← hx, ← hy, mul_div_cancel_right₀ _ hQz, fin3_def] + +lemma equiv_some_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) : P ≈ ![P x / P z, P y / P z, 1] := + equiv_of_X_eq_of_Y_eq hPz one_ne_zero + (by linear_combination (norm := (matrix_simp; ring1)) -P x * div_self hPz) + (by linear_combination (norm := (matrix_simp; ring1)) -P y * div_self hPz) + +lemma X_eq_iff {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) : + P x * Q z = Q x * P z ↔ P x / P z = Q x / Q z := + (div_eq_div_iff hPz hQz).symm + +lemma Y_eq_iff {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) : + P y * Q z = Q y * P z ↔ P y / P z = Q y / Q z := + (div_eq_div_iff hPz hQz).symm + +end Projective + +variable [CommRing R] section Equation -/-! ### Equations and nonsingularity -/ +/-! ### Weierstrass equations -/ +variable (W') in /-- The polynomial $W(X, Y, Z) := Y^2Z + a_1XYZ + a_3YZ^2 - (X^3 + a_2X^2Z + a_4XZ^2 + a_6Z^3)$ -associated to a Weierstrass curve `W` over `R`. This is represented as a term of type +associated to a Weierstrass curve `W'` over `R`. This is represented as a term of type `MvPolynomial (Fin 3) R`, where `X 0`, `X 1`, and `X 2` represent $X$, $Y$, and $Z$ respectively. -/ noncomputable def polynomial : MvPolynomial (Fin 3) R := - X 1 ^ 2 * X 2 + C W.a₁ * X 0 * X 1 * X 2 + C W.a₃ * X 1 * X 2 ^ 2 - - (X 0 ^ 3 + C W.a₂ * X 0 ^ 2 * X 2 + C W.a₄ * X 0 * X 2 ^ 2 + C W.a₆ * X 2 ^ 3) + X 1 ^ 2 * X 2 + C W'.a₁ * X 0 * X 1 * X 2 + C W'.a₃ * X 1 * X 2 ^ 2 + - (X 0 ^ 3 + C W'.a₂ * X 0 ^ 2 * X 2 + C W'.a₄ * X 0 * X 2 ^ 2 + C W'.a₆ * X 2 ^ 3) -lemma eval_polynomial (P : Fin 3 → R) : eval P W.polynomial = - P y ^ 2 * P z + W.a₁ * P x * P y * P z + W.a₃ * P y * P z ^ 2 - - (P x ^ 3 + W.a₂ * P x ^ 2 * P z + W.a₄ * P x * P z ^ 2 + W.a₆ * P z ^ 3) := by +lemma eval_polynomial (P : Fin 3 → R) : eval P W'.polynomial = + P y ^ 2 * P z + W'.a₁ * P x * P y * P z + W'.a₃ * P y * P z ^ 2 + - (P x ^ 3 + W'.a₂ * P x ^ 2 * P z + W'.a₄ * P x * P z ^ 2 + W'.a₆ * P z ^ 3) := by rw [polynomial] eval_simp -/-- The proposition that a point representative $(x, y, z)$ lies in `W`. +lemma eval_polynomial_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) : eval P W.polynomial / P z ^ 3 = + W.toAffine.polynomial.evalEval (P x / P z) (P y / P z) := by + linear_combination (norm := (rw [eval_polynomial, Affine.evalEval_polynomial]; ring1)) + P y ^ 2 / P z ^ 2 * div_self hPz + W.a₁ * P x * P y / P z ^ 2 * div_self hPz + + W.a₃ * P y / P z * div_self (pow_ne_zero 2 hPz) - W.a₂ * P x ^ 2 / P z ^ 2 * div_self hPz + - W.a₄ * P x / P z * div_self (pow_ne_zero 2 hPz) - W.a₆ * div_self (pow_ne_zero 3 hPz) + +variable (W') in +/-- The proposition that a point representative $(x, y, z)$ lies in `W'`. In other words, $W(x, y, z) = 0$. -/ def Equation (P : Fin 3 → R) : Prop := - eval P W.polynomial = 0 + eval P W'.polynomial = 0 -lemma equation_iff (P : Fin 3 → R) : W.Equation P ↔ - P y ^ 2 * P z + W.a₁ * P x * P y * P z + W.a₃ * P y * P z ^ 2 - = P x ^ 3 + W.a₂ * P x ^ 2 * P z + W.a₄ * P x * P z ^ 2 + W.a₆ * P z ^ 3 := by +lemma equation_iff (P : Fin 3 → R) : W'.Equation P ↔ + P y ^ 2 * P z + W'.a₁ * P x * P y * P z + W'.a₃ * P y * P z ^ 2 + - (P x ^ 3 + W'.a₂ * P x ^ 2 * P z + W'.a₄ * P x * P z ^ 2 + W'.a₆ * P z ^ 3) = 0 := by rw [Equation, eval_polynomial, sub_eq_zero] -lemma equation_zero (Y : R) : W.Equation ![0, Y, 0] := - (W.equation_iff ![0, Y, 0]).mpr <| by matrix_simp; ring1 +lemma equation_smul (P : Fin 3 → R) {u : R} (hu : IsUnit u) : W'.Equation (u • P) ↔ W'.Equation P := + have (u : R) {P : Fin 3 → R} (hP : W'.Equation P) : W'.Equation <| u • P := by + rw [equation_iff] at hP ⊢ + linear_combination (norm := (simp only [smul_fin3_ext]; ring1)) u ^ 3 * hP + ⟨fun h => by convert this hu.unit.inv h; erw [smul_smul, hu.val_inv_mul, one_smul], this u⟩ + +lemma equation_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : W'.Equation P ↔ W'.Equation Q := by + rcases h with ⟨u, rfl⟩ + exact equation_smul Q u.isUnit + +lemma equation_of_Z_eq_zero {P : Fin 3 → R} (hPz : P z = 0) : W'.Equation P ↔ P x ^ 3 = 0 := by + simp only [equation_iff, hPz, add_zero, zero_sub, mul_zero, zero_pow <| OfNat.ofNat_ne_zero _, + neg_eq_zero] + +lemma equation_zero : W'.Equation ![0, 1, 0] := by + simp only [equation_of_Z_eq_zero, fin3_def_ext, zero_pow three_ne_zero] + +lemma equation_some (X Y : R) : W'.Equation ![X, Y, 1] ↔ W'.toAffine.Equation X Y := by + simp only [equation_iff, Affine.equation_iff', fin3_def_ext, one_pow, mul_one] -lemma equation_some (X Y : R) : W.Equation ![X, Y, 1] ↔ W.toAffine.Equation X Y := by - rw [equation_iff, W.toAffine.equation_iff] - congr! 1 <;> matrix_simp <;> ring1 +lemma equation_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) : + W.Equation P ↔ W.toAffine.Equation (P x / P z) (P y / P z) := + (equation_of_equiv <| equiv_some_of_Z_ne_zero hPz).trans <| equation_some .. -lemma equation_smul_iff (P : Fin 3 → R) (u : Rˣ) : W.Equation (u • P) ↔ W.Equation P := - have (u : Rˣ) {P : Fin 3 → R} (h : W.Equation P) : W.Equation <| u • P := by - rw [equation_iff] at h ⊢ - linear_combination (norm := (simp only [smul_fin3_ext]; ring1)) (u : R) ^ 3 * h - ⟨fun h => by convert this u⁻¹ h; rw [inv_smul_smul], this u⟩ +lemma X_eq_zero_of_Z_eq_zero [NoZeroDivisors R] {P : Fin 3 → R} (hP : W'.Equation P) + (hPz : P z = 0) : P x = 0 := + pow_eq_zero <| (equation_of_Z_eq_zero hPz).mp hP + +end Equation +section Nonsingular + +/-! ### Nonsingular Weierstrass equations -/ + +variable (W') in /-- The partial derivative $W_X(X, Y, Z)$ of $W(X, Y, Z)$ with respect to $X$. -/ noncomputable def polynomialX : MvPolynomial (Fin 3) R := - pderiv x W.polynomial + pderiv x W'.polynomial -lemma polynomialX_eq : W.polynomialX = - C W.a₁ * X 1 * X 2 - (C 3 * X 0 ^ 2 + C (2 * W.a₂) * X 0 * X 2 + C W.a₄ * X 2 ^ 2) := by +lemma polynomialX_eq : W'.polynomialX = + C W'.a₁ * X 1 * X 2 - (C 3 * X 0 ^ 2 + C (2 * W'.a₂) * X 0 * X 2 + C W'.a₄ * X 2 ^ 2) := by rw [polynomialX, polynomial] pderiv_simp ring1 -lemma eval_polynomialX (P : Fin 3 → R) : eval P W.polynomialX = - W.a₁ * P y * P z - (3 * P x ^ 2 + 2 * W.a₂ * P x * P z + W.a₄ * P z ^ 2) := by +lemma eval_polynomialX (P : Fin 3 → R) : eval P W'.polynomialX = + W'.a₁ * P y * P z - (3 * P x ^ 2 + 2 * W'.a₂ * P x * P z + W'.a₄ * P z ^ 2) := by rw [polynomialX_eq] eval_simp +lemma eval_polynomialX_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) : + eval P W.polynomialX / P z ^ 2 = W.toAffine.polynomialX.evalEval (P x / P z) (P y / P z) := by + linear_combination (norm := (rw [eval_polynomialX, Affine.evalEval_polynomialX]; ring1)) + W.a₁ * P y / P z * div_self hPz - 2 * W.a₂ * P x / P z * div_self hPz + - W.a₄ * div_self (pow_ne_zero 2 hPz) + +variable (W') in /-- The partial derivative $W_Y(X, Y, Z)$ of $W(X, Y, Z)$ with respect to $Y$. -/ noncomputable def polynomialY : MvPolynomial (Fin 3) R := - pderiv y W.polynomial + pderiv y W'.polynomial -lemma polynomialY_eq : W.polynomialY = - C 2 * X 1 * X 2 + C W.a₁ * X 0 * X 2 + C W.a₃ * X 2 ^ 2 := by +lemma polynomialY_eq : W'.polynomialY = + C 2 * X 1 * X 2 + C W'.a₁ * X 0 * X 2 + C W'.a₃ * X 2 ^ 2 := by rw [polynomialY, polynomial] pderiv_simp ring1 lemma eval_polynomialY (P : Fin 3 → R) : - eval P W.polynomialY = 2 * P y * P z + W.a₁ * P x * P z + W.a₃ * P z ^ 2 := by + eval P W'.polynomialY = 2 * P y * P z + W'.a₁ * P x * P z + W'.a₃ * P z ^ 2 := by rw [polynomialY_eq] eval_simp +lemma eval_polynomialY_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) : + eval P W.polynomialY / P z ^ 2 = W.toAffine.polynomialY.evalEval (P x / P z) (P y / P z) := by + linear_combination (norm := (rw [eval_polynomialY, Affine.evalEval_polynomialY]; ring1)) + 2 * P y / P z * div_self hPz + W.a₁ * P x / P z * div_self hPz + + W.a₃ * div_self (pow_ne_zero 2 hPz) + +variable (W') in /-- The partial derivative $W_Z(X, Y, Z)$ of $W(X, Y, Z)$ with respect to $Z$. -/ noncomputable def polynomialZ : MvPolynomial (Fin 3) R := - pderiv z W.polynomial + pderiv z W'.polynomial -lemma polynomialZ_eq : W.polynomialZ = - X 1 ^ 2 + C W.a₁ * X 0 * X 1 + C (2 * W.a₃) * X 1 * X 2 - - (C W.a₂ * X 0 ^ 2 + C (2 * W.a₄) * X 0 * X 2 + C (3 * W.a₆) * X 2 ^ 2) := by +lemma polynomialZ_eq : W'.polynomialZ = + X 1 ^ 2 + C W'.a₁ * X 0 * X 1 + C (2 * W'.a₃) * X 1 * X 2 + - (C W'.a₂ * X 0 ^ 2 + C (2 * W'.a₄) * X 0 * X 2 + C (3 * W'.a₆) * X 2 ^ 2) := by rw [polynomialZ, polynomial] pderiv_simp ring1 -lemma eval_polynomialZ (P : Fin 3 → R) : eval P W.polynomialZ = - P y ^ 2 + W.a₁ * P x * P y + 2 * W.a₃ * P y * P z - - (W.a₂ * P x ^ 2 + 2 * W.a₄ * P x * P z + 3 * W.a₆ * P z ^ 2) := by +lemma eval_polynomialZ (P : Fin 3 → R) : eval P W'.polynomialZ = + P y ^ 2 + W'.a₁ * P x * P y + 2 * W'.a₃ * P y * P z + - (W'.a₂ * P x ^ 2 + 2 * W'.a₄ * P x * P z + 3 * W'.a₆ * P z ^ 2) := by rw [polynomialZ_eq] eval_simp /-- Euler's homogeneous function theorem. -/ -theorem polynomial_relation (P : Fin 3 → R) : 3 * eval P W.polynomial = - P x * eval P W.polynomialX + P y * eval P W.polynomialY + P z * eval P W.polynomialZ := by +theorem polynomial_relation (P : Fin 3 → R) : 3 * eval P W'.polynomial = + P x * eval P W'.polynomialX + P y * eval P W'.polynomialY + P z * eval P W'.polynomialZ := by rw [eval_polynomial, eval_polynomialX, eval_polynomialY, eval_polynomialZ] ring1 -/-- The proposition that a point representative $(x, y, z)$ in `W` is nonsingular. -In other words, either $W_X(x, y, z) \ne 0$, $W_Y(x, y, z) \ne 0$, or $W_Z(x, y, z) \ne 0$. -/ -def Nonsingular (P : Fin 3 → R) : Prop := - W.Equation P ∧ (eval P W.polynomialX ≠ 0 ∨ eval P W.polynomialY ≠ 0 ∨ eval P W.polynomialZ ≠ 0) - -lemma nonsingular_iff (P : Fin 3 → R) : W.Nonsingular P ↔ W.Equation P ∧ - (W.a₁ * P y * P z ≠ 3 * P x ^ 2 + 2 * W.a₂ * P x * P z + W.a₄ * P z ^ 2 ∨ - P y * P z ≠ -P y * P z - W.a₁ * P x * P z - W.a₃ * P z ^ 2 ∨ - P y ^ 2 + W.a₁ * P x * P y + 2 * W.a₃ * P y * P z - ≠ W.a₂ * P x ^ 2 + 2 * W.a₄ * P x * P z + 3 * W.a₆ * P z ^ 2) := by - rw [Nonsingular, eval_polynomialX, eval_polynomialY, eval_polynomialZ, sub_ne_zero, sub_ne_zero, - ← sub_ne_zero (a := P y * P z)] - congr! 4 - ring1 - -lemma nonsingular_zero [Nontrivial R] : W.Nonsingular ![0, 1, 0] := - (W.nonsingular_iff ![0, 1, 0]).mpr ⟨W.equation_zero 1, by simp⟩ +variable (W') in +/-- The proposition that a point representative $(x, y, z)$ in `W'` is nonsingular. +In other words, either $W_X(x, y, z) \ne 0$, $W_Y(x, y, z) \ne 0$, or $W_Z(x, y, z) \ne 0$. -lemma nonsingular_zero' [NoZeroDivisors R] {Y : R} (hy : Y ≠ 0) : W.Nonsingular ![0, Y, 0] := - (W.nonsingular_iff ![0, Y, 0]).mpr ⟨W.equation_zero Y, by simpa⟩ - -lemma nonsingular_some (X Y : R) : W.Nonsingular ![X, Y, 1] ↔ W.toAffine.Nonsingular X Y := by - rw [nonsingular_iff] - matrix_simp - simp only [W.toAffine.nonsingular_iff, equation_some, and_congr_right_iff, - W.toAffine.equation_iff, ← not_and_or, not_iff_not, one_pow, mul_one, Iff.comm, iff_self_and] - intro h hX hY - linear_combination (norm := ring1) 3 * h - X * hX - Y * hY - -lemma nonsingular_smul_iff (P : Fin 3 → R) (u : Rˣ) : W.Nonsingular (u • P) ↔ W.Nonsingular P := - have (u : Rˣ) {P : Fin 3 → R} (h : W.Nonsingular <| u • P) : W.Nonsingular P := by - rcases (W.nonsingular_iff _).mp h with ⟨h, h'⟩ - refine (W.nonsingular_iff P).mpr ⟨(W.equation_smul_iff P u).mp h, ?_⟩ - contrapose! h' +Note that this definition is only mathematically accurate for fields. -/ +-- TODO: generalise this definition to be mathematically accurate for a larger class of rings. +def Nonsingular (P : Fin 3 → R) : Prop := + W'.Equation P ∧ + (eval P W'.polynomialX ≠ 0 ∨ eval P W'.polynomialY ≠ 0 ∨ eval P W'.polynomialZ ≠ 0) + +lemma nonsingular_iff (P : Fin 3 → R) : W'.Nonsingular P ↔ W'.Equation P ∧ + (W'.a₁ * P y * P z - (3 * P x ^ 2 + 2 * W'.a₂ * P x * P z + W'.a₄ * P z ^ 2) ≠ 0 ∨ + 2 * P y * P z + W'.a₁ * P x * P z + W'.a₃ * P z ^ 2 ≠ 0 ∨ + P y ^ 2 + W'.a₁ * P x * P y + 2 * W'.a₃ * P y * P z + - (W'.a₂ * P x ^ 2 + 2 * W'.a₄ * P x * P z + 3 * W'.a₆ * P z ^ 2) ≠ 0) := by + rw [Nonsingular, eval_polynomialX, eval_polynomialY, eval_polynomialZ] + +lemma nonsingular_smul (P : Fin 3 → R) {u : R} (hu : IsUnit u) : + W'.Nonsingular (u • P) ↔ W'.Nonsingular P := + have {u : R} (hu : IsUnit u) {P : Fin 3 → R} (hP : W'.Nonsingular <| u • P) : + W'.Nonsingular P := by + rcases (nonsingular_iff _).mp hP with ⟨hP, hP'⟩ + refine (nonsingular_iff P).mpr ⟨(equation_smul P hu).mp hP, ?_⟩ + contrapose! hP' simp only [smul_fin3_ext] - exact ⟨by linear_combination (norm := ring1) (u : R) ^ 2 * h'.left, - by linear_combination (norm := ring1) (u : R) ^ 2 * h'.right.left, - by linear_combination (norm := ring1) (u : R) ^ 2 * h'.right.right⟩ - ⟨this u, fun h => this u⁻¹ <| by rwa [inv_smul_smul]⟩ + exact ⟨by linear_combination (norm := ring1) u ^ 2 * hP'.left, + by linear_combination (norm := ring1) u ^ 2 * hP'.right.left, + by linear_combination (norm := ring1) u ^ 2 * hP'.right.right⟩ + ⟨this hu, fun h => this hu.unit⁻¹.isUnit <| by rwa [smul_smul, hu.val_inv_mul, one_smul]⟩ -lemma nonsingular_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : W.Nonsingular P ↔ W.Nonsingular Q := by +lemma nonsingular_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : W'.Nonsingular P ↔ W'.Nonsingular Q := by rcases h with ⟨u, rfl⟩ - exact W.nonsingular_smul_iff Q u - -/-- The proposition that a point class on `W` is nonsingular. If `P` is a point representative, -then `W.NonsingularLift ⟦P⟧` is definitionally equivalent to `W.Nonsingular P`. -/ -def NonsingularLift (P : PointClass R) : Prop := - P.lift W.Nonsingular fun _ _ => propext ∘ W.nonsingular_of_equiv - -@[simp] -lemma nonsingularLift_iff (P : Fin 3 → R) : W.NonsingularLift ⟦P⟧ ↔ W.Nonsingular P := - Iff.rfl + exact nonsingular_smul Q u.isUnit + +lemma nonsingular_of_Z_eq_zero {P : Fin 3 → R} (hPz : P z = 0) : + W'.Nonsingular P ↔ + W'.Equation P ∧ (3 * P x ^ 2 ≠ 0 ∨ P y ^ 2 + W'.a₁ * P x * P y - W'.a₂ * P x ^ 2 ≠ 0) := by + simp only [nonsingular_iff, hPz, add_zero, sub_zero, zero_sub, mul_zero, + zero_pow <| OfNat.ofNat_ne_zero _, neg_ne_zero, ne_self_iff_false, false_or] + +lemma nonsingular_zero [Nontrivial R] : W'.Nonsingular ![0, 1, 0] := by + simp only [nonsingular_of_Z_eq_zero, equation_zero, true_and, fin3_def_ext, ← not_and_or] + exact fun h => one_ne_zero <| by linear_combination (norm := ring1) h.right + +lemma nonsingular_some (X Y : R) : W'.Nonsingular ![X, Y, 1] ↔ W'.toAffine.Nonsingular X Y := by + simp_rw [nonsingular_iff, equation_some, fin3_def_ext, Affine.nonsingular_iff', + Affine.equation_iff', and_congr_right_iff, ← not_and_or, not_iff_not, one_pow, mul_one, + and_congr_right_iff, Iff.comm, iff_self_and] + intro h hX hY + linear_combination (norm := ring1) 3 * h - X * hX - Y * hY -lemma nonsingularLift_zero [Nontrivial R] : W.NonsingularLift ⟦![0, 1, 0]⟧ := - W.nonsingular_zero +lemma nonsingular_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) : + W.Nonsingular P ↔ W.toAffine.Nonsingular (P x / P z) (P y / P z) := + (nonsingular_of_equiv <| equiv_some_of_Z_ne_zero hPz).trans <| nonsingular_some .. -lemma nonsingularLift_zero' [NoZeroDivisors R] {Y : R} (hy : Y ≠ 0) : - W.NonsingularLift ⟦![0, Y, 0]⟧ := - W.nonsingular_zero' hy +lemma nonsingular_iff_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) : + W.Nonsingular P ↔ W.Equation P ∧ (eval P W.polynomialX ≠ 0 ∨ eval P W.polynomialY ≠ 0) := by + rw [nonsingular_of_Z_ne_zero hPz, Affine.Nonsingular, ← equation_of_Z_ne_zero hPz, + ← eval_polynomialX_of_Z_ne_zero hPz, div_ne_zero_iff, and_iff_left <| pow_ne_zero 2 hPz, + ← eval_polynomialY_of_Z_ne_zero hPz, div_ne_zero_iff, and_iff_left <| pow_ne_zero 2 hPz] -lemma nonsingularLift_some (X Y : R) : - W.NonsingularLift ⟦![X, Y, 1]⟧ ↔ W.toAffine.Nonsingular X Y := - W.nonsingular_some X Y +lemma Y_ne_zero_of_Z_eq_zero [NoZeroDivisors R] {P : Fin 3 → R} (hP : W'.Nonsingular P) + (hPz : P z = 0) : P y ≠ 0 := by + intro hPy + simp only [nonsingular_of_Z_eq_zero hPz, X_eq_zero_of_Z_eq_zero hP.left hPz, hPy, add_zero, + sub_zero, mul_zero, zero_pow two_ne_zero, or_self, ne_self_iff_false, and_false] at hP -variable {F : Type u} [Field F] {W : Projective F} +lemma isUnit_Y_of_Z_eq_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z = 0) : IsUnit (P y) := + (Y_ne_zero_of_Z_eq_zero hP hPz).isUnit lemma equiv_of_Z_eq_zero {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hQ : W.Nonsingular Q) (hPz : P z = 0) (hQz : Q z = 0) : P ≈ Q := by - rw [fin3_def P, hPz] at hP ⊢ - rw [fin3_def Q, hQz] at hQ ⊢ - simp? [nonsingular_iff, equation_iff] at hP hQ says - simp only [Nat.succ_eq_add_one, Nat.reduceAdd, Fin.isValue, nonsingular_iff, - equation_iff, Matrix.cons_val_one, Matrix.head_cons, Matrix.cons_val_two, Matrix.tail_cons, - mul_zero, Matrix.cons_val_zero, add_zero, ne_eq, OfNat.ofNat_ne_zero, not_false_eq_true, - zero_pow, zero_eq_mul, pow_eq_zero_iff, not_or, sub_self, not_true_eq_false, false_or] - at hP hQ - simp? [pow_eq_zero hP.left.symm, pow_eq_zero hQ.left.symm] at * says - simp only [Fin.isValue, pow_eq_zero hP.left.symm, ne_eq, OfNat.ofNat_ne_zero, - not_false_eq_true, zero_pow, not_true_eq_false, and_false, mul_zero, zero_mul, add_zero, - pow_eq_zero_iff, false_or, true_and, pow_eq_zero hQ.left.symm, Nat.succ_eq_add_one, - Nat.reduceAdd] at * - exact ⟨Units.mk0 (P y / Q y) <| div_ne_zero hP hQ, by simp [div_mul_cancel₀ _ hQ]⟩ - -lemma equiv_zero_of_Z_eq_zero {P : Fin 3 → F} (h : W.Nonsingular P) (hPz : P z = 0) : - P ≈ ![0, 1, 0] := - equiv_of_Z_eq_zero h W.nonsingular_zero hPz rfl + use (isUnit_Y_of_Z_eq_zero hP hPz).unit / (isUnit_Y_of_Z_eq_zero hQ hQz).unit + simp only [Units.smul_def, smul_fin3, X_eq_zero_of_Z_eq_zero hQ.left hQz, hQz, mul_zero, + Units.val_div_eq_div_val, IsUnit.unit_spec, (isUnit_Y_of_Z_eq_zero hQ hQz).div_mul_cancel] + conv_rhs => rw [← fin3_def P, X_eq_zero_of_Z_eq_zero hP.left hPz, hPz] -lemma equiv_some_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) : P ≈ ![P x / P z, P y / P z, 1] := - ⟨Units.mk0 _ hPz, by simp [← fin3_def P, mul_div_cancel₀ _ hPz]⟩ +lemma equiv_zero_of_Z_eq_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z = 0) : + P ≈ ![0, 1, 0] := + equiv_of_Z_eq_zero hP nonsingular_zero hPz rfl -lemma nonsingular_iff_affine_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) : - W.Nonsingular P ↔ W.toAffine.Nonsingular (P x / P z) (P y / P z) := - (W.nonsingular_of_equiv <| equiv_some_of_Z_ne_zero hPz).trans <| W.nonsingular_some .. +variable (W') in +/-- The proposition that a point class on `W'` is nonsingular. If `P` is a point representative, +then `W.NonsingularLift ⟦P⟧` is definitionally equivalent to `W.Nonsingular P`. -/ +def NonsingularLift (P : PointClass R) : Prop := + P.lift W'.Nonsingular fun _ _ => propext ∘ nonsingular_of_equiv -lemma nonsingular_of_affine_of_Z_ne_zero {P : Fin 3 → F} - (h : W.toAffine.Nonsingular (P x / P z) (P y / P z)) (hPz : P z ≠ 0) : W.Nonsingular P := - (nonsingular_iff_affine_of_Z_ne_zero hPz).mpr h +lemma nonsingularLift_iff (P : Fin 3 → R) : W'.NonsingularLift ⟦P⟧ ↔ W'.Nonsingular P := + Iff.rfl -lemma nonsingular_affine_of_Z_ne_zero {P : Fin 3 → F} (h : W.Nonsingular P) (hPz : P z ≠ 0) : - W.toAffine.Nonsingular (P x / P z) (P y / P z) := - (nonsingular_iff_affine_of_Z_ne_zero hPz).mp h +lemma nonsingularLift_zero [Nontrivial R] : W'.NonsingularLift ⟦![0, 1, 0]⟧ := + nonsingular_zero -end Equation +lemma nonsingularLift_some (X Y : R) : + W'.NonsingularLift ⟦![X, Y, 1]⟧ ↔ W'.toAffine.Nonsingular X Y := + nonsingular_some X Y + +end Nonsingular + +@[deprecated (since := "2024-08-27")] alias equation_smul_iff := equation_smul +@[deprecated (since := "2024-08-27")] alias nonsingularLift_zero' := nonsingularLift_zero +@[deprecated (since := "2024-08-27")] +alias nonsingular_affine_of_Z_ne_zero := nonsingular_of_Z_ne_zero +@[deprecated (since := "2024-08-27")] +alias nonsingular_iff_affine_of_Z_ne_zero := nonsingular_of_Z_ne_zero +@[deprecated (since := "2024-08-27")] +alias nonsingular_of_affine_of_Z_ne_zero := nonsingular_of_Z_ne_zero +@[deprecated (since := "2024-08-27")] alias nonsingular_smul_iff := nonsingular_smul +@[deprecated (since := "2024-08-27")] alias nonsingular_zero' := nonsingular_zero end WeierstrassCurve.Projective diff --git a/Mathlib/AlgebraicGeometry/Morphisms/Basic.lean b/Mathlib/AlgebraicGeometry/Morphisms/Basic.lean index e92624a6197d0..7d7bc17702e37 100644 --- a/Mathlib/AlgebraicGeometry/Morphisms/Basic.lean +++ b/Mathlib/AlgebraicGeometry/Morphisms/Basic.lean @@ -108,7 +108,7 @@ Also see `IsLocalAtTarget.mk'` for a convenient constructor. class IsLocalAtTarget (P : MorphismProperty Scheme) : Prop where /-- `P` respects isomorphisms. -/ respectsIso : P.RespectsIso := by infer_instance - /-- `P` holds for `f ∣_ U` for an open cover `U` of `Y` if and only if `P` holds for `f`. -/ + /-- `P` holds for `f ∣_ U` for an open cover `U` of `Y` if and only if `P` holds for `f`. -/ iff_of_openCover' : ∀ {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y), P f ↔ ∀ i, P (𝒰.pullbackHom f i) @@ -186,7 +186,7 @@ Also see `IsLocalAtSource.mk'` for a convenient constructor. class IsLocalAtSource (P : MorphismProperty Scheme) : Prop where /-- `P` respects isomorphisms. -/ respectsIso : P.RespectsIso := by infer_instance - /-- `P` holds for `f ∣_ U` for an open cover `U` of `Y` if and only if `P` holds for `f`. -/ + /-- `P` holds for `f ∣_ U` for an open cover `U` of `Y` if and only if `P` holds for `f`. -/ iff_of_openCover' : ∀ {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} X), P f ↔ ∀ i, P (𝒰.map i ≫ f) diff --git a/Mathlib/AlgebraicGeometry/Morphisms/FinitePresentation.lean b/Mathlib/AlgebraicGeometry/Morphisms/FinitePresentation.lean new file mode 100644 index 0000000000000..384a722407c6d --- /dev/null +++ b/Mathlib/AlgebraicGeometry/Morphisms/FinitePresentation.lean @@ -0,0 +1,62 @@ +/- +Copyright (c) 2024 Christian Merten. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Christian Merten +-/ +import Mathlib.AlgebraicGeometry.Morphisms.RingHomProperties +import Mathlib.RingTheory.RingHom.FinitePresentation + +/-! + +# Morphisms of finite presentation + +A morphism of schemes `f : X ⟶ Y` is locally of finite presentation if for each affine `U ⊆ Y` and +`V ⊆ f ⁻¹' U`, The induced map `Γ(Y, U) ⟶ Γ(X, V)` is of finite presentation. + +A morphism of schemes is of finite presentation if it is both locally of finite presentation and +quasi-compact. We do not provide a separate declaration for this, instead simply assume both +conditions. + +We show that these properties are local, and are stable under compositions. + +-/ + + +noncomputable section + +open CategoryTheory + +universe v u + +namespace AlgebraicGeometry + +variable {X Y : Scheme.{u}} (f : X ⟶ Y) + +/-- A morphism of schemes `f : X ⟶ Y` is locally of finite presentation if for each affine `U ⊆ Y` +and `V ⊆ f ⁻¹' U`, The induced map `Γ(Y, U) ⟶ Γ(X, V)` is of finite presentation. -/ +@[mk_iff] +class LocallyOfFinitePresentation : Prop where + finitePresentation_of_affine_subset : + ∀ (U : Y.affineOpens) (V : X.affineOpens) (e : V.1 ≤ f ⁻¹ᵁ U.1), + (f.appLE U V e).FinitePresentation + +instance : HasRingHomProperty @LocallyOfFinitePresentation RingHom.FinitePresentation where + isLocal_ringHomProperty := RingHom.finitePresentation_isLocal + eq_affineLocally' := by + ext X Y f + rw [locallyOfFinitePresentation_iff, affineLocally_iff_affineOpens_le] + +instance (priority := 900) locallyOfFinitePresentation_of_isOpenImmersion [IsOpenImmersion f] : + LocallyOfFinitePresentation f := + HasRingHomProperty.of_isOpenImmersion + +instance locallyOfFinitePresentation_comp {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z) + [hf : LocallyOfFinitePresentation f] [hg : LocallyOfFinitePresentation g] : + LocallyOfFinitePresentation (f ≫ g) := + MorphismProperty.comp_mem _ f g hf hg + +lemma locallyOfFinitePresentation_stableUnderBaseChange : + MorphismProperty.StableUnderBaseChange @LocallyOfFinitePresentation := + HasRingHomProperty.stableUnderBaseChange RingHom.finitePresentation_stableUnderBaseChange + +end AlgebraicGeometry diff --git a/Mathlib/AlgebraicGeometry/Restrict.lean b/Mathlib/AlgebraicGeometry/Restrict.lean index aa6bf66cace12..07a9eb9cfa1e3 100644 --- a/Mathlib/AlgebraicGeometry/Restrict.lean +++ b/Mathlib/AlgebraicGeometry/Restrict.lean @@ -480,7 +480,7 @@ def morphismRestrictRestrict {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) (V : Scheme.restrictRestrict_hom_restrict, morphismRestrict_ι_assoc, morphismRestrict_ι] -/-- Restricting a morphism twice onto a basic open set is isomorphic to one restriction. -/ +/-- Restricting a morphism twice onto a basic open set is isomorphic to one restriction. -/ def morphismRestrictRestrictBasicOpen {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) (r : Γ(Y, U)) : Arrow.mk (f ∣_ U ∣_ U.toScheme.basicOpen (Y.presheaf.map (eqToHom U.openEmbedding_obj_top).op r)) ≅ diff --git a/Mathlib/AlgebraicGeometry/Spec.lean b/Mathlib/AlgebraicGeometry/Spec.lean index ccb5927d0074e..b60cff5c8de99 100644 --- a/Mathlib/AlgebraicGeometry/Spec.lean +++ b/Mathlib/AlgebraicGeometry/Spec.lean @@ -269,7 +269,7 @@ section SpecΓ open AlgebraicGeometry.LocallyRingedSpace -/-- The counit morphism `R ⟶ Γ(Spec R)` given by `AlgebraicGeometry.StructureSheaf.toOpen`. -/ +/-- The counit morphism `R ⟶ Γ(Spec R)` given by `AlgebraicGeometry.StructureSheaf.toOpen`. -/ @[simps!] def toSpecΓ (R : CommRingCat.{u}) : R ⟶ Γ.obj (op (Spec.toLocallyRingedSpace.obj (op R))) := StructureSheaf.toOpen R ⊤ diff --git a/Mathlib/AlgebraicTopology/DoldKan/Equivalence.lean b/Mathlib/AlgebraicTopology/DoldKan/Equivalence.lean index 59cf4f6cf84aa..72a3b619b766a 100644 --- a/Mathlib/AlgebraicTopology/DoldKan/Equivalence.lean +++ b/Mathlib/AlgebraicTopology/DoldKan/Equivalence.lean @@ -62,7 +62,7 @@ we define the functor in the other direction extension of a functor `Γ₀ : ChainComplex C ℕ ⥤ SimplicialObject C` which is defined similarly as in [*Simplicial Homotopy Theory* by Goerss-Jardine][goerss-jardine-2009]. In `Degeneracies.lean`, we show that `PInfty` vanishes on the image of degeneracy -operators, which is one of the key properties that makes it possible to contruct +operators, which is one of the key properties that makes it possible to construct the isomorphism `N₂Γ₂ : Γ₂ ⋙ N₂ ≅ 𝟭 (Karoubi (ChainComplex C ℕ))`. The rest of the proof follows the strategy in the [original paper by Dold][dold1958]. We show diff --git a/Mathlib/AlgebraicTopology/SimplexCategory.lean b/Mathlib/AlgebraicTopology/SimplexCategory.lean index 3003a0457ca57..1f52cf7037c0b 100644 --- a/Mathlib/AlgebraicTopology/SimplexCategory.lean +++ b/Mathlib/AlgebraicTopology/SimplexCategory.lean @@ -520,7 +520,7 @@ theorem epi_iff_surjective {n m : SimplexCategory} {f : n ⟶ m} : simp only [skeletalFunctor_obj, skeletalFunctor_map, NonemptyFinLinOrd.epi_iff_surjective, NonemptyFinLinOrd.coe_of] -/-- A monomorphism in `SimplexCategory` must increase lengths-/ +/-- A monomorphism in `SimplexCategory` must increase lengths -/ theorem len_le_of_mono {x y : SimplexCategory} {f : x ⟶ y} : Mono f → x.len ≤ y.len := by intro hyp_f_mono have f_inj : Function.Injective f.toOrderHom.toFun := mono_iff_injective.1 hyp_f_mono @@ -529,7 +529,7 @@ theorem len_le_of_mono {x y : SimplexCategory} {f : x ⟶ y} : Mono f → x.len theorem le_of_mono {n m : ℕ} {f : ([n] : SimplexCategory) ⟶ [m]} : CategoryTheory.Mono f → n ≤ m := len_le_of_mono -/-- An epimorphism in `SimplexCategory` must decrease lengths-/ +/-- An epimorphism in `SimplexCategory` must decrease lengths -/ theorem len_le_of_epi {x y : SimplexCategory} {f : x ⟶ y} : Epi f → y.len ≤ x.len := by intro hyp_f_epi have f_surj : Function.Surjective f.toOrderHom.toFun := epi_iff_surjective.1 hyp_f_epi diff --git a/Mathlib/AlgebraicTopology/SplitSimplicialObject.lean b/Mathlib/AlgebraicTopology/SplitSimplicialObject.lean index c3a4875c7d176..447b1a9770800 100644 --- a/Mathlib/AlgebraicTopology/SplitSimplicialObject.lean +++ b/Mathlib/AlgebraicTopology/SplitSimplicialObject.lean @@ -208,14 +208,14 @@ structure Splitting (X : SimplicialObject C) where /-- The "inclusion" `N n ⟶ X _[n]` for all `n : ℕ`. -/ ι : ∀ n, N n ⟶ X _[n] /-- For each `Δ`, `X.obj Δ` identifies to the coproduct of the objects `N A.1.unop.len` - for all `A : IndexSet Δ`. -/ + for all `A : IndexSet Δ`. -/ isColimit' : ∀ Δ : SimplexCategoryᵒᵖ, IsColimit (Splitting.cofan' N X ι Δ) namespace Splitting variable {X Y : SimplicialObject C} (s : Splitting X) -/-- The cofan for `summand s.N Δ` induced by a splitting of a simplicial object. -/ +/-- The cofan for `summand s.N Δ` induced by a splitting of a simplicial object. -/ def cofan (Δ : SimplexCategoryᵒᵖ) : Cofan (summand s.N Δ) := Cofan.mk (X.obj Δ) (fun A => s.ι A.1.unop.len ≫ X.map A.e.op) diff --git a/Mathlib/Analysis/Analytic/CPolynomial.lean b/Mathlib/Analysis/Analytic/CPolynomial.lean index e217c3fc8e1c6..355c4baaf830d 100644 --- a/Mathlib/Analysis/Analytic/CPolynomial.lean +++ b/Mathlib/Analysis/Analytic/CPolynomial.lean @@ -381,7 +381,7 @@ main point is that the new series `p.changeOrigin x` is still finite, with the s variable (p : FormalMultilinearSeries 𝕜 E F) {x y : E} {r R : ℝ≥0} /-- If `p` is a formal multilinear series such that `p m = 0` for `n ≤ m`, then -`p.changeOriginSeriesTerm k l = 0` for `n ≤ k + l`. -/ +`p.changeOriginSeriesTerm k l = 0` for `n ≤ k + l`. -/ lemma changeOriginSeriesTerm_bound (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ} (hn : ∀ (m : ℕ), n ≤ m → p m = 0) (k l : ℕ) {s : Finset (Fin (k + l))} (hs : s.card = l) (hkl : n ≤ k + l) : @@ -393,7 +393,7 @@ lemma changeOriginSeriesTerm_bound (p : FormalMultilinearSeries 𝕜 E F) {n : /-- If `p` is a finite formal multilinear series, then so is `p.changeOriginSeries k` for every `k` in `ℕ`. More precisely, if `p m = 0` for `n ≤ m`, then `p.changeOriginSeries k m = 0` for -`n ≤ k + m`. -/ +`n ≤ k + m`. -/ lemma changeOriginSeries_finite_of_finite (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ} (hn : ∀ (m : ℕ), n ≤ m → p m = 0) (k : ℕ) : ∀ {m : ℕ}, n ≤ k + m → p.changeOriginSeries k m = 0 := by @@ -413,7 +413,7 @@ lemma changeOriginSeries_sum_eq_partialSum_of_finite (p : FormalMultilinearSerie ContinuousMultilinearMap.zero_apply] /-- If `p` is a formal multilinear series such that `p m = 0` for `n ≤ m`, then -`p.changeOrigin x k = 0` for `n ≤ k`. -/ +`p.changeOrigin x k = 0` for `n ≤ k`. -/ lemma changeOrigin_finite_of_finite (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ} (hn : ∀ (m : ℕ), n ≤ m → p m = 0) {k : ℕ} (hk : n ≤ k) : p.changeOrigin x k = 0 := by diff --git a/Mathlib/Analysis/Analytic/Composition.lean b/Mathlib/Analysis/Analytic/Composition.lean index 52ae7340407a9..7696e7f5b0714 100644 --- a/Mathlib/Analysis/Analytic/Composition.lean +++ b/Mathlib/Analysis/Analytic/Composition.lean @@ -419,7 +419,7 @@ theorem id_comp (p : FormalMultilinearSeries 𝕜 E F) (h : p 0 = 0) : (id 𝕜 rfl · simp -/-! ### Summability properties of the composition of formal power series-/ +/-! ### Summability properties of the composition of formal power series -/ section diff --git a/Mathlib/Analysis/Analytic/Within.lean b/Mathlib/Analysis/Analytic/Within.lean index a35cbce9538cf..d8c30c30b6b97 100644 --- a/Mathlib/Analysis/Analytic/Within.lean +++ b/Mathlib/Analysis/Analytic/Within.lean @@ -9,7 +9,7 @@ import Mathlib.Analysis.Calculus.FDeriv.Analytic /-! # Properties of analyticity restricted to a set -From `Mathlib.Analysis.Analytic.Basic`, we have the definitons +From `Mathlib.Analysis.Analytic.Basic`, we have the definitions 1. `AnalyticWithinAt 𝕜 f s x` means a power series at `x` converges to `f` on `𝓝[s] x`, and `f` is continuous within `s` at `x`. diff --git a/Mathlib/Analysis/Asymptotics/Asymptotics.lean b/Mathlib/Analysis/Asymptotics/Asymptotics.lean index fe71abddb5aca..645ede1a98355 100644 --- a/Mathlib/Analysis/Asymptotics/Asymptotics.lean +++ b/Mathlib/Analysis/Asymptotics/Asymptotics.lean @@ -2036,3 +2036,5 @@ protected theorem isBigO_rev_principal (hf : ContinuousOn f s) end IsBigORev end ContinuousOn + +set_option linter.style.longFile 2200 diff --git a/Mathlib/Analysis/BoundedVariation.lean b/Mathlib/Analysis/BoundedVariation.lean index 0d69ebc8834bd..dd6942a44733b 100644 --- a/Mathlib/Analysis/BoundedVariation.lean +++ b/Mathlib/Analysis/BoundedVariation.lean @@ -192,7 +192,7 @@ protected theorem lowerSemicontinuous (s : Set α) : simpa only [UniformOnFun.tendsto_iff_tendstoUniformlyOn, mem_image, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂, tendstoUniformlyOn_singleton_iff_tendsto] using @tendsto_id _ (𝓝 f) -/-- The map `(eVariationOn · s)` is lower semicontinuous for uniform convergence on `s`. -/ +/-- The map `(eVariationOn · s)` is lower semicontinuous for uniform convergence on `s`. -/ theorem lowerSemicontinuous_uniformOn (s : Set α) : LowerSemicontinuous fun f : α →ᵤ[{s}] E => eVariationOn f s := fun f ↦ by apply @lowerSemicontinuous_aux _ _ _ _ (UniformOnFun α E {s}) id (𝓝 f) f s _ diff --git a/Mathlib/Analysis/BoxIntegral/Basic.lean b/Mathlib/Analysis/BoxIntegral/Basic.lean index b2c6da7cff285..e9d54c402baef 100644 --- a/Mathlib/Analysis/BoxIntegral/Basic.lean +++ b/Mathlib/Analysis/BoxIntegral/Basic.lean @@ -184,7 +184,7 @@ theorem hasIntegral_iff : HasIntegral I l f vol y ↔ simp [@forall_swap ℝ≥0 (TaggedPrepartition I)] /-- Quite often it is more natural to prove an estimate of the form `a * ε`, not `ε` in the RHS of -`BoxIntegral.hasIntegral_iff`, so we provide this auxiliary lemma. -/ +`BoxIntegral.hasIntegral_iff`, so we provide this auxiliary lemma. -/ theorem HasIntegral.of_mul (a : ℝ) (h : ∀ ε : ℝ, 0 < ε → ∃ r : ℝ≥0 → ℝⁿ → Ioi (0 : ℝ), (∀ c, l.RCond (r c)) ∧ ∀ c π, l.MemBaseSet I c (r c) π → IsPartition π → dist (integralSum f vol π) y ≤ a * ε) : @@ -391,7 +391,7 @@ additional distortion estimates if `BoxIntegral.IntegrationParams.bDistortion l corresponding integral sum is `ε`-close to the integral. If `BoxIntegral.IntegrationParams.bRiemann = true`, then `r c x` does not depend on `x`. If -`ε ≤ 0`, then we use `r c x = 1`. -/ +`ε ≤ 0`, then we use `r c x = 1`. -/ def convergenceR (h : Integrable I l f vol) (ε : ℝ) : ℝ≥0 → ℝⁿ → Ioi (0 : ℝ) := if hε : 0 < ε then (hasIntegral_iff.1 h.hasIntegral ε hε).choose else fun _ _ => ⟨1, Set.mem_Ioi.2 zero_lt_one⟩ @@ -447,7 +447,7 @@ theorem dist_integralSum_le_of_memBaseSet (h : Integrable I l f vol) (hpos₁ : /-- If `f` is integrable on `I` along `l`, then for two sufficiently fine tagged prepartitions (in the sense of the filter `BoxIntegral.IntegrationParams.toFilter l I`) such that they cover -the same part of `I`, the integral sums of `f` over `π₁` and `π₂` are very close to each other. -/ +the same part of `I`, the integral sums of `f` over `π₁` and `π₂` are very close to each other. -/ theorem tendsto_integralSum_toFilter_prod_self_inf_iUnion_eq_uniformity (h : Integrable I l f vol) : Tendsto (fun π : TaggedPrepartition I × TaggedPrepartition I => (integralSum f vol π.1, integralSum f vol π.2)) diff --git a/Mathlib/Analysis/BoxIntegral/Box/Basic.lean b/Mathlib/Analysis/BoxIntegral/Box/Basic.lean index 9017646668d13..c7b8a46f6ef69 100644 --- a/Mathlib/Analysis/BoxIntegral/Box/Basic.lean +++ b/Mathlib/Analysis/BoxIntegral/Box/Basic.lean @@ -275,7 +275,7 @@ theorem withBotCoe_inj {I J : WithBot (Box ι)} : (I : Set (ι → ℝ)) = J ↔ /-- Make a `WithBot (Box ι)` from a pair of corners `l u : ι → ℝ`. If `l i < u i` for all `i`, then the result is `⟨l, u, _⟩ : Box ι`, otherwise it is `⊥`. In any case, the result interpreted -as a set in `ι → ℝ` is the set `{x : ι → ℝ | ∀ i, x i ∈ Ioc (l i) (u i)}`. -/ +as a set in `ι → ℝ` is the set `{x : ι → ℝ | ∀ i, x i ∈ Ioc (l i) (u i)}`. -/ def mk' (l u : ι → ℝ) : WithBot (Box ι) := if h : ∀ i, l i < u i then ↑(⟨l, u, h⟩ : Box ι) else ⊥ diff --git a/Mathlib/Analysis/BoxIntegral/DivergenceTheorem.lean b/Mathlib/Analysis/BoxIntegral/DivergenceTheorem.lean index 79429fdb79725..9c979a7202bd1 100644 --- a/Mathlib/Analysis/BoxIntegral/DivergenceTheorem.lean +++ b/Mathlib/Analysis/BoxIntegral/DivergenceTheorem.lean @@ -77,7 +77,7 @@ theorem norm_volume_sub_integral_face_upper_sub_lower_smul_le {f : (Fin (n + 1) `f y - a - f' (y - x)` over each of these faces is less than or equal to `ε * c * vol I`. We integrate a function of the norm `≤ ε * diam I.Icc` over a box of volume `∏ j ≠ i, (I.upper j - I.lower j)`. Since `diam I.Icc ≤ c * (I.upper i - I.lower i)`, we get the - required estimate. -/ + required estimate. -/ have Hl : I.lower i ∈ Icc (I.lower i) (I.upper i) := Set.left_mem_Icc.2 (I.lower_le_upper i) have Hu : I.upper i ∈ Icc (I.lower i) (I.upper i) := Set.right_mem_Icc.2 (I.lower_le_upper i) have Hi : ∀ x ∈ Icc (I.lower i) (I.upper i), diff --git a/Mathlib/Analysis/BoxIntegral/Integrability.lean b/Mathlib/Analysis/BoxIntegral/Integrability.lean index 12a2a1c87c00d..9cd4c5108bd04 100644 --- a/Mathlib/Analysis/BoxIntegral/Integrability.lean +++ b/Mathlib/Analysis/BoxIntegral/Integrability.lean @@ -152,7 +152,7 @@ theorem HasIntegral.of_aeEq_zero {l : IntegrationParams} {I : Box ι} {f : (ι exact (mul_le_mul_left' this.le _).trans ENNReal.mul_div_le /-- If `f` has integral `y` on a box `I` with respect to a locally finite measure `μ` and `g` is -a.e. equal to `f` on `I`, then `g` has the same integral on `I`. -/ +a.e. equal to `f` on `I`, then `g` has the same integral on `I`. -/ theorem HasIntegral.congr_ae {l : IntegrationParams} {I : Box ι} {y : E} {f g : (ι → ℝ) → E} {μ : Measure (ι → ℝ)} [IsLocallyFiniteMeasure μ] (hf : HasIntegral.{u, v, v} I l f μ.toBoxAdditive.toSMul y) (hfg : f =ᵐ[μ.restrict I] g) @@ -191,7 +191,7 @@ end SimpleFunc open TopologicalSpace /-- If `f : ℝⁿ → E` is Bochner integrable w.r.t. a locally finite measure `μ` on a rectangular box -`I`, then it is McShane integrable on `I` with the same integral. -/ +`I`, then it is McShane integrable on `I` with the same integral. -/ theorem IntegrableOn.hasBoxIntegral [CompleteSpace E] {f : (ι → ℝ) → E} {μ : Measure (ι → ℝ)} [IsLocallyFiniteMeasure μ] {I : Box ι} (hf : IntegrableOn f I μ) (l : IntegrationParams) (hl : l.bRiemann = false) : diff --git a/Mathlib/Analysis/BoxIntegral/Partition/Split.lean b/Mathlib/Analysis/BoxIntegral/Partition/Split.lean index 5d3d61fca5246..fa8553041f1e2 100644 --- a/Mathlib/Analysis/BoxIntegral/Partition/Split.lean +++ b/Mathlib/Analysis/BoxIntegral/Partition/Split.lean @@ -244,7 +244,7 @@ theorem inf_splitMany {I : Box ι} (π : Prepartition I) (s : Finset (ι × ℝ) /-- Let `s : Finset (ι × ℝ)` be a set of hyperplanes `{x : ι → ℝ | x i = r}` in `ι → ℝ` encoded as pairs `(i, r)`. Suppose that this set contains all faces of a box `J`. The hyperplanes of `s` split a box `I` into subboxes. Let `Js` be one of them. If `J` and `Js` have nonempty intersection, then -`Js` is a subbox of `J`. -/ +`Js` is a subbox of `J`. -/ theorem not_disjoint_imp_le_of_subset_of_mem_splitMany {I J Js : Box ι} {s : Finset (ι × ℝ)} (H : ∀ i, {(i, J.lower i), (i, J.upper i)} ⊆ s) (HJs : Js ∈ splitMany I s) (Hn : ¬Disjoint (J : WithBot (Box ι)) Js) : Js ≤ J := by diff --git a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Instances.lean b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Instances.lean index eaa3333737924..4430a3345b71d 100644 --- a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Instances.lean +++ b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Instances.lean @@ -267,6 +267,11 @@ instance IsSelfAdjoint.instContinuousFunctionalCalculus : Complex.isometry_ofReal.uniformEmbedding (.zero _) (fun _ ↦ isSelfAdjoint_iff_isStarNormal_and_spectrumRestricts) +lemma IsSelfAdjoint.spectrum_nonempty {A : Type*} [Ring A] [StarRing A] + [TopologicalSpace A] [Algebra ℝ A] [ContinuousFunctionalCalculus ℝ (IsSelfAdjoint : A → Prop)] + [Nontrivial A] {a : A} (ha : IsSelfAdjoint a) : (σ ℝ a).Nonempty := + CFC.spectrum_nonempty ℝ a ha + end SelfAdjointUnital /-! @@ -311,6 +316,12 @@ instance Nonneg.instNonUnitalContinuousFunctionalCalculus : uniformEmbedding_subtype_val le_rfl (fun _ ↦ nonneg_iff_isSelfAdjoint_and_quasispectrumRestricts) +open NNReal in +lemma NNReal.spectrum_nonempty {A : Type*} [Ring A] [StarRing A] [PartialOrder A] + [TopologicalSpace A] [Algebra ℝ≥0 A] [ContinuousFunctionalCalculus ℝ≥0 (fun x : A ↦ 0 ≤ x)] + [Nontrivial A] {a : A} (ha : 0 ≤ a) : (spectrum ℝ≥0 a).Nonempty := + CFC.spectrum_nonempty ℝ≥0 a ha + end Nonneg diff --git a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Integral.lean b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Integral.lean index bbbc262674d48..f56a3cf3d1927 100644 --- a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Integral.lean +++ b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Integral.lean @@ -95,8 +95,8 @@ variable {X : Type*} {𝕜 : Type*} {A : Type*} {p : A → Prop} [RCLike 𝕜] [NonUnitalContinuousFunctionalCalculus 𝕜 p] lemma cfcₙL_integral (a : A) (f : X → C(quasispectrum 𝕜 a, 𝕜)₀) (hf₁ : Integrable f μ) - (ha : p a := by cfc_tac) : - ∫ x, cfcₙL (a := a) ha (f x) ∂μ = cfcₙL (a := a) ha (∫ x, f x ∂μ) := by + (ha : p a := by cfc_tac) : + ∫ x, cfcₙL (a := a) ha (f x) ∂μ = cfcₙL (a := a) ha (∫ x, f x ∂μ) := by rw [ContinuousLinearMap.integral_comp_comm _ hf₁] lemma cfcₙHom_integral (a : A) (f : X → C(quasispectrum 𝕜 a, 𝕜)₀) (hf₁ : Integrable f μ) diff --git a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Order.lean b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Order.lean index 2bebd79a58986..5b0321bda4366 100644 --- a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Order.lean +++ b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Order.lean @@ -64,6 +64,39 @@ lemma inr_nonneg_iff {a : A} : 0 ≤ (a : Unitization ℂ A) ↔ 0 ≤ a := by end Unitization +/-- `cfc_le_iff` only applies to a scalar ring where `R` is an actual `Ring`, and not a `Semiring`. +However, this theorem still holds for `ℝ≥0` as long as the algebra `A` itself is an `ℝ`-algebra. -/ +lemma cfc_nnreal_le_iff {A : Type*} [TopologicalSpace A] [Ring A] [StarRing A] [PartialOrder A] + [StarOrderedRing A] [Algebra ℝ A] [TopologicalRing A] [NonnegSpectrumClass ℝ A] + [ContinuousFunctionalCalculus ℝ (IsSelfAdjoint : A → Prop)] + [UniqueContinuousFunctionalCalculus ℝ A] + (f : ℝ≥0 → ℝ≥0) (g : ℝ≥0 → ℝ≥0) (a : A) + (ha_spec : SpectrumRestricts a ContinuousMap.realToNNReal) + (hf : ContinuousOn f (spectrum ℝ≥0 a) := by cfc_cont_tac) + (hg : ContinuousOn g (spectrum ℝ≥0 a) := by cfc_cont_tac) + (ha : 0 ≤ a := by cfc_tac) : + cfc f a ≤ cfc g a ↔ ∀ x ∈ spectrum ℝ≥0 a, f x ≤ g x := by + have hf' := hf.ofReal_map_toNNReal <| ha_spec.image ▸ Set.mapsTo_image .. + have hg' := hg.ofReal_map_toNNReal <| ha_spec.image ▸ Set.mapsTo_image .. + rw [cfc_nnreal_eq_real, cfc_nnreal_eq_real, cfc_le_iff ..] + simp [NNReal.coe_le_coe, ← ha_spec.image] + +/-- In a unital `ℝ`-algebra `A` with a continuous functional calculus, an element `a : A` is larger +than some `algebraMap ℝ A r` if and only if every element of the `ℝ`-spectrum is nonnegative. -/ +lemma CFC.exists_pos_algebraMap_le_iff {A : Type*} [TopologicalSpace A] [Ring A] [StarRing A] + [PartialOrder A] [StarOrderedRing A] [Algebra ℝ A] [NonnegSpectrumClass ℝ A] + [ContinuousFunctionalCalculus ℝ (IsSelfAdjoint : A → Prop)] + {a : A} [CompactSpace (spectrum ℝ a)] + (h_non : (spectrum ℝ a).Nonempty) (ha : IsSelfAdjoint a := by cfc_tac) : + (∃ r > 0, algebraMap ℝ A r ≤ a) ↔ (∀ x ∈ spectrum ℝ a, 0 < x) := by + have h_cpct : IsCompact (spectrum ℝ a) := isCompact_iff_compactSpace.mpr inferInstance + simp_rw [algebraMap_le_iff_le_spectrum (a := a)] + refine ⟨?_, fun h ↦ ?_⟩ + · rintro ⟨r, hr, hr_le⟩ + exact (hr.trans_le <| hr_le · ·) + · obtain ⟨r, hr, hr_min⟩ := h_cpct.exists_isMinOn h_non continuousOn_id + exact ⟨r, h _ hr, hr_min⟩ + section CStar_unital variable {A : Type*} [NormedRing A] [StarRing A] [CStarRing A] [CompleteSpace A] @@ -103,7 +136,9 @@ lemma IsSelfAdjoint.toReal_spectralRadius_eq_norm {a : A} (ha : IsSelfAdjoint a) (spectralRadius ℝ a).toReal = ‖a‖ := by simp [ha.spectrumRestricts.spectralRadius_eq, ha.spectralRadius_eq_nnnorm] -lemma CStarRing.norm_or_neg_norm_mem_spectrum [Nontrivial A] {a : A} +namespace CStarRing + +lemma norm_or_neg_norm_mem_spectrum [Nontrivial A] {a : A} (ha : IsSelfAdjoint a := by cfc_tac) : ‖a‖ ∈ spectrum ℝ a ∨ -‖a‖ ∈ spectrum ℝ a := by have ha' : SpectrumRestricts a Complex.reCLM := ha.spectrumRestricts rw [← ha.toReal_spectralRadius_eq_norm] @@ -111,16 +146,48 @@ lemma CStarRing.norm_or_neg_norm_mem_spectrum [Nontrivial A] {a : A} variable [PartialOrder A] [StarOrderedRing A] -lemma CStarRing.nnnorm_mem_spectrum_of_nonneg [Nontrivial A] {a : A} (ha : 0 ≤ a := by cfc_tac) : +lemma nnnorm_mem_spectrum_of_nonneg [Nontrivial A] {a : A} (ha : 0 ≤ a := by cfc_tac) : ‖a‖₊ ∈ spectrum ℝ≥0 a := by have : IsSelfAdjoint a := .of_nonneg ha convert NNReal.spectralRadius_mem_spectrum (a := a) ?_ (.nnreal_of_nonneg ha) · simp [this.spectrumRestricts.spectralRadius_eq, this.spectralRadius_eq_nnnorm] · exact this.spectrumRestricts.image ▸ (spectrum.nonempty a).image _ -lemma CStarRing.norm_mem_spectrum_of_nonneg [Nontrivial A] {a : A} (ha : 0 ≤ a := by cfc_tac) : +lemma norm_mem_spectrum_of_nonneg [Nontrivial A] {a : A} (ha : 0 ≤ a := by cfc_tac) : ‖a‖ ∈ spectrum ℝ a := by - simpa using spectrum.algebraMap_mem ℝ <| CStarRing.nnnorm_mem_spectrum_of_nonneg ha + simpa using spectrum.algebraMap_mem ℝ <| nnnorm_mem_spectrum_of_nonneg ha + +lemma norm_le_iff_le_algebraMap (a : A) {r : ℝ} (hr : 0 ≤ r) (ha : 0 ≤ a := by cfc_tac) : + ‖a‖ ≤ r ↔ a ≤ algebraMap ℝ A r := by + rw [le_algebraMap_iff_spectrum_le] + obtain (h | _) := subsingleton_or_nontrivial A + · simp [Subsingleton.elim a 0, hr] + · exact ⟨fun h x hx ↦ Real.le_norm_self x |>.trans (spectrum.norm_le_norm_of_mem hx) |>.trans h, + fun h ↦ h ‖a‖ <| norm_mem_spectrum_of_nonneg⟩ + +lemma nnnorm_le_iff_of_nonneg (a : A) (r : ℝ≥0) (ha : 0 ≤ a := by cfc_tac) : + ‖a‖₊ ≤ r ↔ a ≤ algebraMap ℝ≥0 A r := by + rw [← NNReal.coe_le_coe] + exact norm_le_iff_le_algebraMap a r.2 + +lemma norm_le_one_iff_of_nonneg (a : A) (ha : 0 ≤ a := by cfc_tac) : + ‖a‖ ≤ 1 ↔ a ≤ 1 := by + simpa using norm_le_iff_le_algebraMap a zero_le_one + +lemma nnnorm_le_one_iff_of_nonneg (a : A) (ha : 0 ≤ a := by cfc_tac) : + ‖a‖₊ ≤ 1 ↔ a ≤ 1 := by + rw [← NNReal.coe_le_coe] + exact norm_le_one_iff_of_nonneg a + +lemma norm_le_natCast_iff_of_nonneg (a : A) (n : ℕ) (ha : 0 ≤ a := by cfc_tac) : + ‖a‖ ≤ n ↔ a ≤ n := by + simpa using norm_le_iff_le_algebraMap a n.cast_nonneg + +lemma nnnorm_le_natCast_iff_of_nonneg (a : A) (n : ℕ) (ha : 0 ≤ a := by cfc_tac) : + ‖a‖₊ ≤ n ↔ a ≤ n := by + simpa using nnnorm_le_iff_of_nonneg a n + +end CStarRing end CStar_unital @@ -130,13 +197,15 @@ variable {A : Type*} [NonUnitalNormedRing A] [CompleteSpace A] [PartialOrder A] [StarOrderedRing A] [CStarRing A] [NormedSpace ℂ A] [StarModule ℂ A] [SMulCommClass ℂ A A] [IsScalarTower ℂ A A] +namespace CStarRing + open ComplexOrder in -instance CStarRing.instNonnegSpectrumClassComplexNonUnital : NonnegSpectrumClass ℂ A where +instance instNonnegSpectrumClassComplexNonUnital : NonnegSpectrumClass ℂ A where quasispectrum_nonneg_of_nonneg a ha x hx := by rw [Unitization.quasispectrum_eq_spectrum_inr' ℂ ℂ a] at hx exact spectrum_nonneg_of_nonneg (Unitization.inr_nonneg_iff.mpr ha) hx -lemma CStarRing.norm_le_norm_of_nonneg_of_le {a b : A} (ha : 0 ≤ a := by cfc_tac) (hab : a ≤ b) : +lemma norm_le_norm_of_nonneg_of_le {a b : A} (ha : 0 ≤ a := by cfc_tac) (hab : a ≤ b) : ‖a‖ ≤ ‖b‖ := by suffices ∀ a b : Unitization ℂ A, 0 ≤ a → a ≤ b → ‖a‖ ≤ ‖b‖ by have hb := ha.trans hab @@ -156,7 +225,7 @@ lemma CStarRing.norm_le_norm_of_nonneg_of_le {a b : A} (ha : 0 ≤ a := by cfc_t rw [cfc_le_iff id (fun _ => ‖b‖) a] at h₂ exact h₂ ‖a‖ <| norm_mem_spectrum_of_nonneg ha -lemma CStarRing.conjugate_le_norm_smul {a b : A} (hb : IsSelfAdjoint b := by cfc_tac) : +lemma conjugate_le_norm_smul {a b : A} (hb : IsSelfAdjoint b := by cfc_tac) : star a * b * a ≤ ‖b‖ • (star a * a) := by suffices ∀ a b : Unitization ℂ A, IsSelfAdjoint b → star a * b * a ≤ ‖b‖ • (star a * a) by rw [← Unitization.inr_le_iff _ _ (by aesop) ((IsSelfAdjoint.all _).smul (.star_mul_self a))] @@ -167,11 +236,13 @@ lemma CStarRing.conjugate_le_norm_smul {a b : A} (hb : IsSelfAdjoint b := by cfc conjugate_le_conjugate hb.le_algebraMap_norm_self _ _ = ‖b‖ • (star a * a) := by simp [Algebra.algebraMap_eq_smul_one] -lemma CStarRing.conjugate_le_norm_smul' {a b : A} (hb : IsSelfAdjoint b := by cfc_tac) : +lemma conjugate_le_norm_smul' {a b : A} (hb : IsSelfAdjoint b := by cfc_tac) : a * b * star a ≤ ‖b‖ • (a * star a) := by have h₁ : a * b * star a = star (star a) * b * star a := by simp have h₂ : a * star a = star (star a) * star a := by simp simp only [h₁, h₂] exact conjugate_le_norm_smul +end CStarRing + end CStar_nonunital diff --git a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Unital.lean b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Unital.lean index 804929b679d15..557467f9b4ceb 100644 --- a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Unital.lean +++ b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Unital.lean @@ -107,7 +107,7 @@ b = cfc id b = cfc (NNReal.sqrt ∘ (· ^ 2)) b = + `cfc : (R → R) → A → A`: an unbundled version of `cfcHom` which takes the junk value `0` when `cfcHom` is not defined. + `cfcUnits`: builds a unit from `cfc f a` when `f` is nonzero and continuous on the - specturm of `a`. + spectrum of `a`. ## Main theorems @@ -580,7 +580,7 @@ lemma cfc_comp_smul {S : Type*} [SMul S R] [ContinuousConstSMul S R] [SMulZeroCl rw [cfc_comp' .., cfc_smul_id ..] lemma cfc_comp_const_mul (r : R) (f : R → R) (a : A) - (hf : ContinuousOn f ((r * ·) '' (spectrum R a)) := by cfc_cont_tac) (ha : p a := by cfc_tac) : + (hf : ContinuousOn f ((r * ·) '' (spectrum R a)) := by cfc_cont_tac) (ha : p a := by cfc_tac) : cfc (f <| r * ·) a = cfc f (r • a) := by rw [cfc_comp' .., cfc_const_mul_id ..] @@ -662,6 +662,16 @@ instance IsStarNormal.cfc_map (f : R → R) (a : A) : IsStarNormal (cfc f a) whe exact mul_comm _ _ · simp [cfc_apply_of_not_continuousOn a h] +variable (R) in +/-- In an `R`-algebra with a continuous functional calculus, every element satisfying the predicate +has nonempty `R`-spectrum. -/ +lemma CFC.spectrum_nonempty [Nontrivial A] (a : A) (ha : p a := by cfc_tac) : + (spectrum R a).Nonempty := by + by_contra! h + apply one_ne_zero (α := A) + rw [← cfc_one R a, ← cfc_zero R a] + exact cfc_congr fun x hx ↦ by simp_all + end CFC end Basic @@ -898,6 +908,14 @@ lemma one_le_cfc (f : R → R) (a : A) (h : ∀ x ∈ spectrum R a, 1 ≤ f x) 1 ≤ cfc f a := by simpa using algebraMap_le_cfc f 1 a h +lemma CFC.le_one {a : A} (h : ∀ x ∈ spectrum R a, x ≤ 1) (ha : p a := by cfc_tac) : + a ≤ 1 := by + simpa using le_algebraMap_of_spectrum_le h + +lemma CFC.one_le {a : A} (h : ∀ x ∈ spectrum R a, 1 ≤ x) (ha : p a := by cfc_tac) : + 1 ≤ a := by + simpa using algebraMap_le_of_le_spectrum h + end Semiring section NNReal @@ -921,7 +939,7 @@ variable {R A : Type*} {p : A → Prop} [OrderedCommRing R] [StarRing R] variable [MetricSpace R] [TopologicalRing R] [ContinuousStar R] variable [∀ (α) [TopologicalSpace α], StarOrderedRing C(α, R)] variable [TopologicalSpace A] [Ring A] [StarRing A] [PartialOrder A] [StarOrderedRing A] -variable [Algebra R A] [ContinuousFunctionalCalculus R p] +variable [Algebra R A] [instCFC : ContinuousFunctionalCalculus R p] variable [NonnegSpectrumClass R A] lemma cfcHom_le_iff {a : A} (ha : p a) {f g : C(spectrum R a, R)} : @@ -939,6 +957,44 @@ lemma cfc_nonpos_iff (f : R → R) (a : A) (hf : ContinuousOn f (spectrum R a) : simp_rw [← neg_nonneg, ← cfc_neg] exact cfc_nonneg_iff (fun x ↦ -f x) a +lemma cfc_le_algebraMap_iff (f : R → R) (r : R) (a : A) + (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : + cfc f a ≤ algebraMap R A r ↔ ∀ x ∈ spectrum R a, f x ≤ r := by + rw [← cfc_const r a, cfc_le_iff ..] + +lemma algebraMap_le_cfc_iff (f : R → R) (r : R) (a : A) + (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : + algebraMap R A r ≤ cfc f a ↔ ∀ x ∈ spectrum R a, r ≤ f x := by + rw [← cfc_const r a, cfc_le_iff ..] + +lemma le_algebraMap_iff_spectrum_le {r : R} {a : A} (ha : p a := by cfc_tac) : + a ≤ algebraMap R A r ↔ ∀ x ∈ spectrum R a, x ≤ r := by + nth_rw 1 [← cfc_id R a] + exact cfc_le_algebraMap_iff id r a + +lemma algebraMap_le_iff_le_spectrum {r : R} {a : A} (ha : p a := by cfc_tac) : + algebraMap R A r ≤ a ↔ ∀ x ∈ spectrum R a, r ≤ x:= by + nth_rw 1 [← cfc_id R a] + exact algebraMap_le_cfc_iff id r a + +lemma cfc_le_one_iff (f : R → R) (a : A) + (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : + cfc f a ≤ 1 ↔ ∀ x ∈ spectrum R a, f x ≤ 1 := by + simpa using cfc_le_algebraMap_iff f 1 a + +lemma one_le_cfc_iff (f : R → R) (a : A) + (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : + 1 ≤ cfc f a ↔ ∀ x ∈ spectrum R a, 1 ≤ f x := by + simpa using algebraMap_le_cfc_iff f 1 a + +lemma CFC.le_one_iff (a : A) (ha : p a := by cfc_tac) : + a ≤ 1 ↔ ∀ x ∈ spectrum R a, x ≤ 1 := by + simpa using le_algebraMap_iff_spectrum_le (r := (1 : R)) (a := a) + +lemma CFC.one_le_iff (a : A) (ha : p a := by cfc_tac) : + 1 ≤ a ↔ ∀ x ∈ spectrum R a, 1 ≤ x := by + simpa using algebraMap_le_iff_le_spectrum (r := (1 : R)) (a := a) + end Ring end Order diff --git a/Mathlib/Analysis/CStarAlgebra/Matrix.lean b/Mathlib/Analysis/CStarAlgebra/Matrix.lean index 2a7915775d319..49e853c8a1438 100644 --- a/Mathlib/Analysis/CStarAlgebra/Matrix.lean +++ b/Mathlib/Analysis/CStarAlgebra/Matrix.lean @@ -125,14 +125,14 @@ lemma piLp_equiv_toEuclideanCLM (A : Matrix n n 𝕜) (x : EuclideanSpace 𝕜 n rfl /-- An auxiliary definition used only to construct the true `NormedAddCommGroup` (and `Metric`) -structure provided by `Matrix.instMetricSpaceL2Op` and `Matrix.instNormedAddCommGroupL2Op`. -/ +structure provided by `Matrix.instMetricSpaceL2Op` and `Matrix.instNormedAddCommGroupL2Op`. -/ def l2OpNormedAddCommGroupAux : NormedAddCommGroup (Matrix m n 𝕜) := @NormedAddCommGroup.induced ((Matrix m n 𝕜) ≃ₗ[𝕜] (EuclideanSpace 𝕜 n →L[𝕜] EuclideanSpace 𝕜 m)) _ _ _ _ ContinuousLinearMap.toNormedAddCommGroup.toNormedAddGroup _ _ <| (toEuclideanLin.trans toContinuousLinearMap).injective /-- An auxiliary definition used only to construct the true `NormedRing` (and `Metric`) structure -provided by `Matrix.instMetricSpaceL2Op` and `Matrix.instNormedRingL2Op`. -/ +provided by `Matrix.instMetricSpaceL2Op` and `Matrix.instNormedRingL2Op`. -/ def l2OpNormedRingAux : NormedRing (Matrix n n 𝕜) := @NormedRing.induced ((Matrix n n 𝕜) ≃⋆ₐ[𝕜] (EuclideanSpace 𝕜 n →L[𝕜] EuclideanSpace 𝕜 n)) _ _ _ _ ContinuousLinearMap.toNormedRing _ _ toEuclideanCLM.injective diff --git a/Mathlib/Analysis/CStarAlgebra/Module/Defs.lean b/Mathlib/Analysis/CStarAlgebra/Module/Defs.lean index daf2909a3ed1a..1c4045a1ebb24 100644 --- a/Mathlib/Analysis/CStarAlgebra/Module/Defs.lean +++ b/Mathlib/Analysis/CStarAlgebra/Module/Defs.lean @@ -168,7 +168,7 @@ lemma norm_sq_eq {x : E} : ‖x‖ ^ 2 = ‖⟪x, x⟫‖ := by simp [norm_eq_sq section include A -protected lemma norm_nonneg {x : E} : 0 ≤ ‖x‖ := by simp [norm_eq_sqrt_norm_inner_self]; positivity +protected lemma norm_nonneg {x : E} : 0 ≤ ‖x‖ := by simp [norm_eq_sqrt_norm_inner_self] protected lemma norm_pos {x : E} (hx : x ≠ 0) : 0 < ‖x‖ := by simp only [norm_eq_sqrt_norm_inner_self, Real.sqrt_pos, norm_pos_iff] diff --git a/Mathlib/Analysis/CStarAlgebra/Unitization.lean b/Mathlib/Analysis/CStarAlgebra/Unitization.lean index 0ccc38b7262f0..d664e50c7c219 100644 --- a/Mathlib/Analysis/CStarAlgebra/Unitization.lean +++ b/Mathlib/Analysis/CStarAlgebra/Unitization.lean @@ -129,7 +129,7 @@ instance Unitization.instCStarRing : CStarRing (Unitization 𝕜 E) where norm_mul_self_le x := by -- rewrite both sides as a `⊔` simp only [Unitization.norm_def, Prod.norm_def, ← sup_eq_max] - -- Show that `(Unitization.splitMul 𝕜 E x).snd` satisifes the C⋆-property, in two stages: + -- Show that `(Unitization.splitMul 𝕜 E x).snd` satisfies the C⋆-property, in two stages: have h₁ : ∀ x : Unitization 𝕜 E, ‖(Unitization.splitMul 𝕜 E x).snd‖ ≤ ‖(Unitization.splitMul 𝕜 E (star x)).snd‖ := by simp only [add_zero, Unitization.splitMul_apply, Unitization.snd_star, Unitization.fst_star] diff --git a/Mathlib/Analysis/Calculus/Conformal/NormedSpace.lean b/Mathlib/Analysis/Calculus/Conformal/NormedSpace.lean index b64a5bf2e5cc8..5e7a4a62baea7 100644 --- a/Mathlib/Analysis/Calculus/Conformal/NormedSpace.lean +++ b/Mathlib/Analysis/Calculus/Conformal/NormedSpace.lean @@ -63,7 +63,7 @@ theorem conformalAt_const_smul {c : ℝ} (h : c ≠ 0) (x : X) : ConformalAt (fu theorem Subsingleton.conformalAt [Subsingleton X] (f : X → Y) (x : X) : ConformalAt f x := ⟨0, hasFDerivAt_of_subsingleton _ _, isConformalMap_of_subsingleton _⟩ -/-- A function is a conformal map if and only if its differential is a conformal linear map-/ +/-- A function is a conformal map if and only if its differential is a conformal linear map -/ theorem conformalAt_iff_isConformalMap_fderiv {f : X → Y} {x : X} : ConformalAt f x ↔ IsConformalMap (fderiv ℝ f x) := by constructor diff --git a/Mathlib/Analysis/Calculus/ContDiff/Basic.lean b/Mathlib/Analysis/Calculus/ContDiff/Basic.lean index 3dc61bad5603b..b0af5efec3bfb 100644 --- a/Mathlib/Analysis/Calculus/ContDiff/Basic.lean +++ b/Mathlib/Analysis/Calculus/ContDiff/Basic.lean @@ -882,7 +882,7 @@ then there is a function `f' : E → F →L[𝕜] G` that is `C^n` at `x₀` wit sufficiently close to `x₀` within `s ∪ {x₀}` the function `y ↦ f x y` has derivative `f' x` at `g x` within `t ⊆ F`. For convenience, we return an explicit set of `x`'s where this holds that is a subset of `s ∪ {x₀}`. We need one additional condition, namely that `t` is a neighborhood of -`g(x₀)` within `g '' s`. -/ +`g(x₀)` within `g '' s`. -/ theorem ContDiffWithinAt.hasFDerivWithinAt_nhds {f : E → F → G} {g : E → F} {t : Set F} {n : ℕ} {x₀ : E} (hf : ContDiffWithinAt 𝕜 (n + 1) (uncurry f) (insert x₀ s ×ˢ t) (x₀, g x₀)) (hg : ContDiffWithinAt 𝕜 n g s x₀) (hgt : t ∈ 𝓝[g '' s] g x₀) : @@ -1948,3 +1948,5 @@ theorem ContDiff.restrict_scalars (h : ContDiff 𝕜' n f) : ContDiff 𝕜 n f : contDiff_iff_contDiffAt.2 fun _ => h.contDiffAt.restrict_scalars _ end RestrictScalars + +set_option linter.style.longFile 2100 diff --git a/Mathlib/Analysis/Calculus/ContDiff/Defs.lean b/Mathlib/Analysis/Calculus/ContDiff/Defs.lean index 1bde1bf2752a2..07eb8aa5454b7 100644 --- a/Mathlib/Analysis/Calculus/ContDiff/Defs.lean +++ b/Mathlib/Analysis/Calculus/ContDiff/Defs.lean @@ -1598,3 +1598,5 @@ theorem ContDiff.continuous_fderiv_apply (h : ContDiff 𝕜 n f) (hn : 1 ≤ n) have B : Continuous fun p : E × E => (fderiv 𝕜 f p.1, p.2) := ((h.continuous_fderiv hn).comp continuous_fst).prod_mk continuous_snd A.comp B + +set_option linter.style.longFile 1700 diff --git a/Mathlib/Analysis/Calculus/InverseFunctionTheorem/FDeriv.lean b/Mathlib/Analysis/Calculus/InverseFunctionTheorem/FDeriv.lean index 82d6364c31eb6..43a83ae9b58a1 100644 --- a/Mathlib/Analysis/Calculus/InverseFunctionTheorem/FDeriv.lean +++ b/Mathlib/Analysis/Calculus/InverseFunctionTheorem/FDeriv.lean @@ -186,7 +186,7 @@ theorem to_localInverse (hf : HasStrictFDerivAt f (f' : E →L[𝕜] F) a) : and `g (f x) = x` in a neighborhood of `a`, then `g` has derivative `f'.symm` at `f a`. For a version assuming `f (g y) = y` and continuity of `g` at `f a` but not `[CompleteSpace E]` -see `of_local_left_inverse`. -/ +see `of_local_left_inverse`. -/ theorem to_local_left_inverse (hf : HasStrictFDerivAt f (f' : E →L[𝕜] F) a) {g : F → E} (hg : ∀ᶠ x in 𝓝 a, g (f x) = x) : HasStrictFDerivAt g (f'.symm : F →L[𝕜] E) (f a) := hf.to_localInverse.congr_of_eventuallyEq <| (hf.localInverse_unique hg).mono fun _ => Eq.symm diff --git a/Mathlib/Analysis/Calculus/LocalExtr/Rolle.lean b/Mathlib/Analysis/Calculus/LocalExtr/Rolle.lean index dbaffb564b895..bd4dace2f8094 100644 --- a/Mathlib/Analysis/Calculus/LocalExtr/Rolle.lean +++ b/Mathlib/Analysis/Calculus/LocalExtr/Rolle.lean @@ -58,7 +58,7 @@ theorem exists_deriv_eq_zero (hab : a < b) (hfc : ContinuousOn f (Icc a b)) (hfI /-- **Rolle's Theorem**, a version for a function on an open interval: if `f` has derivative `f'` on `(a, b)` and has the same limit `l` at `𝓝[>] a` and `𝓝[<] b`, then `f' c = 0` -for some `c ∈ (a, b)`. -/ +for some `c ∈ (a, b)`. -/ theorem exists_hasDerivAt_eq_zero' (hab : a < b) (hfa : Tendsto f (𝓝[>] a) (𝓝 l)) (hfb : Tendsto f (𝓝[<] b) (𝓝 l)) (hff' : ∀ x ∈ Ioo a b, HasDerivAt f (f' x) x) : ∃ c ∈ Ioo a b, f' c = 0 := diff --git a/Mathlib/Analysis/Calculus/ParametricIntervalIntegral.lean b/Mathlib/Analysis/Calculus/ParametricIntervalIntegral.lean index a6d43de3221c4..fa25dfa3f5ee9 100644 --- a/Mathlib/Analysis/Calculus/ParametricIntervalIntegral.lean +++ b/Mathlib/Analysis/Calculus/ParametricIntervalIntegral.lean @@ -10,7 +10,7 @@ import Mathlib.MeasureTheory.Integral.IntervalIntegral # Derivatives of interval integrals depending on parameters In this file we restate theorems about derivatives of integrals depending on parameters for interval -integrals. -/ +integrals. -/ open TopologicalSpace MeasureTheory Filter Metric diff --git a/Mathlib/Analysis/Complex/AbsMax.lean b/Mathlib/Analysis/Complex/AbsMax.lean index e7257a7aab9fb..377cec68b96e4 100644 --- a/Mathlib/Analysis/Complex/AbsMax.lean +++ b/Mathlib/Analysis/Complex/AbsMax.lean @@ -172,7 +172,7 @@ Finally, we generalize the theorem from a disk in `ℂ` to a closed ball in any /-- **Maximum modulus principle** on a closed ball: if `f : E → F` is continuous on a closed ball, is complex differentiable on the corresponding open ball, and the norm `‖f w‖` takes its maximum -value on the open ball at its center, then the norm `‖f w‖` is constant on the closed ball. -/ +value on the open ball at its center, then the norm `‖f w‖` is constant on the closed ball. -/ theorem norm_eqOn_closedBall_of_isMaxOn {f : E → F} {z : E} {r : ℝ} (hd : DiffContOnCl ℂ f (ball z r)) (hz : IsMaxOn (norm ∘ f) (ball z r) z) : EqOn (norm ∘ f) (const E ‖f z‖) (closedBall z r) := by @@ -306,7 +306,7 @@ normed complex space to a strictly convex normed complex space has the following - it is complex differentiable on the corresponding open ball; - the norm `‖f w‖` takes its maximum value on the open ball at its center. -Then `f` is a constant on the closed ball. -/ +Then `f` is a constant on the closed ball. -/ theorem eqOn_closedBall_of_isMaxOn_norm {f : E → F} {z : E} {r : ℝ} (hd : DiffContOnCl ℂ f (ball z r)) (hz : IsMaxOn (norm ∘ f) (ball z r) z) : EqOn f (const E (f z)) (closedBall z r) := fun _x hx => diff --git a/Mathlib/Analysis/Complex/Angle.lean b/Mathlib/Analysis/Complex/Angle.lean index 81cc8f077e489..e7031e3748729 100644 --- a/Mathlib/Analysis/Complex/Angle.lean +++ b/Mathlib/Analysis/Complex/Angle.lean @@ -96,7 +96,7 @@ lemma norm_sub_mem_Icc_angle (hx : ‖x‖ = 1) (hy : ‖y‖ = 1) : calc _ = 2 * (1 - (1 - 2 / π ^ 2 * θ ^ 2)) := by ring _ ≤ 2 * (1 - θ.cos) := by - gcongr; exact Real.cos_quadratic_upper_bound <| abs_le.2 <| Ioc_subset_Icc_self hθ + gcongr; exact Real.cos_le_one_sub_mul_cos_sq <| abs_le.2 <| Ioc_subset_Icc_self hθ _ = _ := by linear_combination -θ.cos_sq_add_sin_sq · rw [Real.sqrt_le_left (by positivity), ← _root_.abs_pow, abs_sq] calc diff --git a/Mathlib/Analysis/Complex/TaylorSeries.lean b/Mathlib/Analysis/Complex/TaylorSeries.lean index 90a8b74ad8c80..91e330885478d 100644 --- a/Mathlib/Analysis/Complex/TaylorSeries.lean +++ b/Mathlib/Analysis/Complex/TaylorSeries.lean @@ -11,7 +11,7 @@ import Mathlib.Analysis.Complex.CauchyIntegral We show that the Taylor series around some point `c : ℂ` of a function `f` that is complex differentiable on the open ball of radius `r` around `c` converges to `f` on that open ball; see `Complex.hasSum_taylorSeries_on_ball` and `Complex.taylorSeries_eq_on_ball` for versions -(in terms of `HasSum` and `tsum`, repsectively) for functions to a complete normed +(in terms of `HasSum` and `tsum`, respectively) for functions to a complete normed space over `ℂ`, and `Complex.taylorSeries_eq_on_ball'` for a variant when `f : ℂ → ℂ`. There are corresponding statements for `EMEtric.ball`s; see diff --git a/Mathlib/Analysis/Convex/Cone/InnerDual.lean b/Mathlib/Analysis/Convex/Cone/InnerDual.lean index 555882971d866..63d49213b6aba 100644 --- a/Mathlib/Analysis/Convex/Cone/InnerDual.lean +++ b/Mathlib/Analysis/Convex/Cone/InnerDual.lean @@ -181,7 +181,7 @@ theorem ConvexCone.hyperplane_separation_of_nonempty_of_isClosed_of_nmem (K : Co _ = ⟪b - z, b - z + z⟫_ℝ := (inner_add_right _ _ _).symm _ = ⟪b - z, b⟫_ℝ := by rw [sub_add_cancel] -/-- The inner dual of inner dual of a non-empty, closed convex cone is itself. -/ +/-- The inner dual of inner dual of a non-empty, closed convex cone is itself. -/ theorem ConvexCone.innerDualCone_of_innerDualCone_eq_self (K : ConvexCone ℝ H) (ne : (K : Set H).Nonempty) (hc : IsClosed (K : Set H)) : ((K : Set H).innerDualCone : Set H).innerDualCone = K := by diff --git a/Mathlib/Analysis/Convex/Gauge.lean b/Mathlib/Analysis/Convex/Gauge.lean index 4083b51c775b0..b73b52f91006a 100644 --- a/Mathlib/Analysis/Convex/Gauge.lean +++ b/Mathlib/Analysis/Convex/Gauge.lean @@ -67,7 +67,7 @@ private theorem gauge_set_bddBelow : BddBelow { r : ℝ | 0 < r ∧ x ∈ r • ⟨0, fun _ hr => hr.1.le⟩ /-- If the given subset is `Absorbent` then the set we take an infimum over in `gauge` is nonempty, -which is useful for proving many properties about the gauge. -/ +which is useful for proving many properties about the gauge. -/ theorem Absorbent.gauge_set_nonempty (absorbs : Absorbent ℝ s) : { r : ℝ | 0 < r ∧ x ∈ r • s }.Nonempty := let ⟨r, hr₁, hr₂⟩ := (absorbs x).exists_pos @@ -359,12 +359,12 @@ theorem gauge_lt_one_eq_self_of_isOpen (hs₁ : Convex ℝ s) (hs₀ : (0 : E) convert interior_subset_gauge_lt_one s exact hs₂.interior_eq.symm --- Porting note: droped unneeded assumptions +-- Porting note: dropped unneeded assumptions theorem gauge_lt_one_of_mem_of_isOpen (hs₂ : IsOpen s) {x : E} (hx : x ∈ s) : gauge s x < 1 := interior_subset_gauge_lt_one s <| by rwa [hs₂.interior_eq] --- Porting note: droped unneeded assumptions +-- Porting note: dropped unneeded assumptions theorem gauge_lt_of_mem_smul (x : E) (ε : ℝ) (hε : 0 < ε) (hs₂ : IsOpen s) (hx : x ∈ ε • s) : gauge s x < ε := by have : ε⁻¹ • x ∈ s := by rwa [← mem_smul_set_iff_inv_smul_mem₀ hε.ne'] diff --git a/Mathlib/Analysis/Convex/Measure.lean b/Mathlib/Analysis/Convex/Measure.lean index 6dec1b9d305d3..d8b9b78be2d4b 100644 --- a/Mathlib/Analysis/Convex/Measure.lean +++ b/Mathlib/Analysis/Convex/Measure.lean @@ -59,7 +59,7 @@ theorem addHaar_frontier (hs : Convex ℝ s) : μ (frontier s) = 0 := by `μ (closure s) ≤ μ (interior s)`. -/ replace hb : μ (interior s) ≠ ∞ := (hb.subset interior_subset).measure_lt_top.ne suffices μ (closure s) ≤ μ (interior s) by - rwa [frontier, measure_diff interior_subset_closure isOpen_interior.measurableSet hb, + rwa [frontier, measure_diff interior_subset_closure isOpen_interior.nullMeasurableSet hb, tsub_eq_zero_iff_le] /- Due to `Convex.closure_subset_image_homothety_interior_of_one_lt`, for any `r > 1` we have `closure s ⊆ homothety x r '' interior s`, hence `μ (closure s) ≤ r ^ d * μ (interior s)`, diff --git a/Mathlib/Analysis/Distribution/SchwartzSpace.lean b/Mathlib/Analysis/Distribution/SchwartzSpace.lean index cb092fd0a5552..73c009395f7d1 100644 --- a/Mathlib/Analysis/Distribution/SchwartzSpace.lean +++ b/Mathlib/Analysis/Distribution/SchwartzSpace.lean @@ -380,7 +380,7 @@ end Module section Seminorms -/-! ### Seminorms on Schwartz space-/ +/-! ### Seminorms on Schwartz space -/ variable [NormedField 𝕜] [NormedSpace 𝕜 F] [SMulCommClass ℝ 𝕜 F] @@ -480,7 +480,7 @@ end Seminorms section Topology -/-! ### The topology on the Schwartz space-/ +/-! ### The topology on the Schwartz space -/ variable [NormedField 𝕜] [NormedSpace 𝕜 F] [SMulCommClass ℝ 𝕜 F] diff --git a/Mathlib/Analysis/Fourier/RiemannLebesgueLemma.lean b/Mathlib/Analysis/Fourier/RiemannLebesgueLemma.lean index 9d6a346e16240..e3095be779ad6 100644 --- a/Mathlib/Analysis/Fourier/RiemannLebesgueLemma.lean +++ b/Mathlib/Analysis/Fourier/RiemannLebesgueLemma.lean @@ -9,7 +9,6 @@ import Mathlib.Analysis.InnerProductSpace.EuclideanDist import Mathlib.MeasureTheory.Function.ContinuousMapDense import Mathlib.MeasureTheory.Group.Integral import Mathlib.MeasureTheory.Integral.SetIntegral -import Mathlib.MeasureTheory.Measure.Haar.NormedSpace import Mathlib.Topology.EMetricSpace.Paracompact import Mathlib.MeasureTheory.Measure.Haar.Unique @@ -262,41 +261,11 @@ theorem tendsto_integral_exp_smul_cocompact (μ : Measure V) [μ.IsAddHaarMeasur borelize V' -- various equivs derived from A let Aₘ : MeasurableEquiv V V' := A.toHomeomorph.toMeasurableEquiv - -- isomorphism between duals derived from A -- need to do continuity as a separate step in order - -- to apply `LinearMap.continuous_of_finiteDimensional`. - let Adualₗ : (V →L[ℝ] ℝ) ≃ₗ[ℝ] V' →L[ℝ] ℝ := - { toFun := fun t => t.comp A.symm.toContinuousLinearMap - invFun := fun t => t.comp A.toContinuousLinearMap - map_add' := by - intro t s - ext1 v - simp only [ContinuousLinearMap.coe_comp', Function.comp_apply, - ContinuousLinearMap.add_apply] - map_smul' := by - intro x f - ext1 v - simp only [RingHom.id_apply, ContinuousLinearMap.coe_comp', Function.comp_apply, - ContinuousLinearMap.smul_apply] - left_inv := by - intro w - ext1 v - simp only [ContinuousLinearMap.coe_comp', - ContinuousLinearEquiv.coe_coe, Function.comp_apply, - ContinuousLinearEquiv.symm_apply_apply] - right_inv := by - intro w - ext1 v - simp only [ContinuousLinearMap.coe_comp', - ContinuousLinearEquiv.coe_coe, Function.comp_apply, - ContinuousLinearEquiv.apply_symm_apply] } - let Adual : (V →L[ℝ] ℝ) ≃L[ℝ] V' →L[ℝ] ℝ := - { Adualₗ with - continuous_toFun := Adualₗ.toLinearMap.continuous_of_finiteDimensional - continuous_invFun := Adualₗ.symm.toLinearMap.continuous_of_finiteDimensional } - have : (μ.map Aₘ).IsAddHaarMeasure := Measure.MapContinuousLinearEquiv.isAddHaarMeasure _ A - convert - (tendsto_integral_exp_smul_cocompact_of_inner_product (f ∘ A.symm) (μ.map Aₘ)).comp - Adual.toHomeomorph.toCocompactMap.cocompact_tendsto' with w + -- isomorphism between duals derived from A + let Adual : (V →L[ℝ] ℝ) ≃L[ℝ] V' →L[ℝ] ℝ := A.arrowCongrSL (.refl _ _) + have : (μ.map Aₘ).IsAddHaarMeasure := A.isAddHaarMeasure_map _ + convert (tendsto_integral_exp_smul_cocompact_of_inner_product (f ∘ A.symm) (μ.map Aₘ)).comp + Adual.toHomeomorph.toCocompactMap.cocompact_tendsto' with w rw [Function.comp_apply, integral_map_equiv] congr 1 with v : 1 congr diff --git a/Mathlib/Analysis/InnerProductSpace/Adjoint.lean b/Mathlib/Analysis/InnerProductSpace/Adjoint.lean index c4a1bcd72f1b5..d70316a5027b3 100644 --- a/Mathlib/Analysis/InnerProductSpace/Adjoint.lean +++ b/Mathlib/Analysis/InnerProductSpace/Adjoint.lean @@ -564,7 +564,7 @@ lemma Matrix.toLin_conjTranspose (A : Matrix m n 𝕜) : orthonormal_iff_ite.mp v₁.orthonormal, orthonormal_iff_ite.mp v₂.orthonormal] /-- The matrix associated to the adjoint of a linear map corresponding to two orthonormal bases -is the conjugate tranpose of the matrix associated to the linear map. -/ +is the conjugate transpose of the matrix associated to the linear map. -/ lemma LinearMap.toMatrix_adjoint (f : E →ₗ[𝕜] F) : toMatrix v₂.toBasis v₁.toBasis (adjoint f) = (toMatrix v₁.toBasis v₂.toBasis f)ᴴ := toLin v₂.toBasis v₁.toBasis |>.injective <| by simp [toLin_conjTranspose] diff --git a/Mathlib/Analysis/InnerProductSpace/Basic.lean b/Mathlib/Analysis/InnerProductSpace/Basic.lean index 5756f35edab9d..f2d58902381c5 100644 --- a/Mathlib/Analysis/InnerProductSpace/Basic.lean +++ b/Mathlib/Analysis/InnerProductSpace/Basic.lean @@ -1816,7 +1816,7 @@ theorem inner_sum_smul_sum_smul_of_sum_eq_zero {ι₁ : Type*} {s₁ : Finset ι variable (𝕜) /-- `innerSL` is an isometry. Note that the associated `LinearIsometry` is defined in -`InnerProductSpace.Dual` as `toDualMap`. -/ +`InnerProductSpace.Dual` as `toDualMap`. -/ @[simp] theorem innerSL_apply_norm (x : E) : ‖innerSL 𝕜 x‖ = ‖x‖ := by refine @@ -2416,3 +2416,5 @@ instance innerProductSpace : InnerProductSpace 𝕜 (Completion E) where end UniformSpace.Completion end UniformSpace.Completion + +set_option linter.style.longFile 2500 diff --git a/Mathlib/Analysis/InnerProductSpace/GramSchmidtOrtho.lean b/Mathlib/Analysis/InnerProductSpace/GramSchmidtOrtho.lean index dc8c71696a394..a3c9277c121f4 100644 --- a/Mathlib/Analysis/InnerProductSpace/GramSchmidtOrtho.lean +++ b/Mathlib/Analysis/InnerProductSpace/GramSchmidtOrtho.lean @@ -137,7 +137,7 @@ theorem gramSchmidt_mem_span (f : ι → E) : (Submodule.sum_mem _ fun k hk => ?_) let hkj : k < j := (Finset.mem_Iio.1 hk).trans_le hij exact smul_mem _ _ - (span_mono (image_subset f <| Iic_subset_Iic.2 hkj.le) <| gramSchmidt_mem_span _ le_rfl) + (span_mono (image_subset f <| Set.Iic_subset_Iic.2 hkj.le) <| gramSchmidt_mem_span _ le_rfl) termination_by j => j theorem span_gramSchmidt_Iic (f : ι → E) (c : ι) : diff --git a/Mathlib/Analysis/InnerProductSpace/JointEigenspace.lean b/Mathlib/Analysis/InnerProductSpace/JointEigenspace.lean new file mode 100644 index 0000000000000..868496a0b3462 --- /dev/null +++ b/Mathlib/Analysis/InnerProductSpace/JointEigenspace.lean @@ -0,0 +1,113 @@ +/- +Copyright (c) 2024 Jon Bannon. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Jon Bannon, Jack Cheverton, Samyak Dhar Tuladhar +-/ + +import Mathlib.Analysis.InnerProductSpace.Spectrum +import Mathlib.Analysis.InnerProductSpace.Projection +import Mathlib.Order.CompleteLattice +import Mathlib.LinearAlgebra.Eigenspace.Basic + +/-! # Joint eigenspaces of a commuting pair of symmetric operators + +This file collects various decomposition results for joint eigenspaces of a commuting pair +of symmetric operators on a finite-dimensional inner product space. + +# Main Result + +* `LinearMap.IsSymmetric.directSum_isInternal_of_commute` establishes that + if `{A B : E →ₗ[𝕜] E}`, then `IsSymmetric A`, `IsSymmetric B` and `A ∘ₗ B = B ∘ₗ A` imply that + `E` decomposes as an internal direct sum of the pairwise orthogonal spaces + `eigenspace B μ ⊓ eigenspace A ν` + +## TODO + +Develop a `Diagonalization` structure for linear maps and / or matrices which consists of a basis, +and a proof obligation that the basis vectors are eigenvectors. + +## Tags + +self-adjoint operator, simultaneous eigenspaces, joint eigenspaces + +-/ + +variable {𝕜 E : Type*} [RCLike 𝕜] +variable [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] + +open Module.End + +namespace LinearMap + +namespace IsSymmetric + +section Pair + +variable {α : 𝕜} {A B : E →ₗ[𝕜] E} + +/--If a pair of operators commute, then the eigenspaces of one are invariant under the other.-/ +theorem eigenspace_invariant_of_commute + (hAB : A ∘ₗ B = B ∘ₗ A) (α : 𝕜) : ∀ v ∈ (eigenspace A α), (B v ∈ eigenspace A α) := by + intro v hv + rw [eigenspace, mem_ker, sub_apply, Module.algebraMap_end_apply, ← comp_apply A B v, hAB, + comp_apply B A v, ← map_smul, ← map_sub, hv, map_zero] at * + +/--The simultaneous eigenspaces of a pair of commuting symmetric operators form an +`OrthogonalFamily`.-/ +theorem orthogonalFamily_eigenspace_inf_eigenspace (hA : A.IsSymmetric) (hB : B.IsSymmetric) : + OrthogonalFamily 𝕜 (fun (i : 𝕜 × 𝕜) => (eigenspace A i.2 ⊓ eigenspace B i.1 : Submodule 𝕜 E)) + (fun i => (eigenspace A i.2 ⊓ eigenspace B i.1).subtypeₗᵢ) := + OrthogonalFamily.of_pairwise fun i j hij v ⟨hv1 , hv2⟩ ↦ by + obtain (h₁ | h₂) : i.1 ≠ j.1 ∨ i.2 ≠ j.2 := by rwa [Ne.eq_def, Prod.ext_iff, not_and_or] at hij + all_goals intro w ⟨hw1, hw2⟩ + · exact hB.orthogonalFamily_eigenspaces.pairwise h₁ hv2 w hw2 + · exact hA.orthogonalFamily_eigenspaces.pairwise h₂ hv1 w hw1 + +open Submodule in + +/-- The intersection of eigenspaces of commuting selfadjoint operators is equal to the eigenspace of +one operator restricted to the eigenspace of the other, which is an invariant subspace because the +operators commute. -/ +theorem eigenspace_inf_eigenspace + (hAB : A ∘ₗ B = B ∘ₗ A) (γ : 𝕜) : + eigenspace A α ⊓ eigenspace B γ = map (Submodule.subtype (eigenspace A α)) + (eigenspace (B.restrict (eigenspace_invariant_of_commute hAB α)) γ) := + (eigenspace A α).inf_genEigenspace _ _ (k := 1) + +variable [FiniteDimensional 𝕜 E] + +/-- If A and B are commuting symmetric operators on a finite dimensional inner product space +then the eigenspaces of the restriction of B to any eigenspace of A exhaust that eigenspace.-/ +theorem iSup_eigenspace_inf_eigenspace (hB : B.IsSymmetric) + (hAB : A ∘ₗ B = B ∘ₗ A): + (⨆ γ, eigenspace A α ⊓ eigenspace B γ) = eigenspace A α := by + conv_rhs => rw [← (eigenspace A α).map_subtype_top] + simp only [eigenspace_inf_eigenspace hAB, ← Submodule.map_iSup] + congr 1 + rw [← Submodule.orthogonal_eq_bot_iff] + exact orthogonalComplement_iSup_eigenspaces_eq_bot <| + hB.restrict_invariant <| eigenspace_invariant_of_commute hAB α + +/-- If A and B are commuting symmetric operators acting on a finite dimensional inner product space, +then the simultaneous eigenspaces of A and B exhaust the space. -/ +theorem iSup_iSup_eigenspace_inf_eigenspace_eq_top (hA : A.IsSymmetric) (hB : B.IsSymmetric) + (hAB : A ∘ₗ B = B ∘ₗ A) : + (⨆ α, ⨆ γ, eigenspace A α ⊓ eigenspace B γ) = ⊤ := by + simpa [iSup_eigenspace_inf_eigenspace hB hAB] using + Submodule.orthogonal_eq_bot_iff.mp <| hA.orthogonalComplement_iSup_eigenspaces_eq_bot + +/-- Given a commuting pair of symmetric linear operators on a finite dimensional inner product +space, the space decomposes as an internal direct sum of simultaneous eigenspaces of these +operators. -/ +theorem directSum_isInteral_of_commute (hA : A.IsSymmetric) (hB : B.IsSymmetric) + (hAB : A ∘ₗ B = B ∘ₗ A) : + DirectSum.IsInternal (fun (i : 𝕜 × 𝕜) ↦ (eigenspace A i.2 ⊓ eigenspace B i.1)):= by + apply (orthogonalFamily_eigenspace_inf_eigenspace hA hB).isInternal_iff.mpr + rw [Submodule.orthogonal_eq_bot_iff, iSup_prod, iSup_comm] + exact iSup_iSup_eigenspace_inf_eigenspace_eq_top hA hB hAB + +end Pair + +end IsSymmetric + +end LinearMap diff --git a/Mathlib/Analysis/InnerProductSpace/Projection.lean b/Mathlib/Analysis/InnerProductSpace/Projection.lean index b76dc64049bfa..3adbca1522567 100644 --- a/Mathlib/Analysis/InnerProductSpace/Projection.lean +++ b/Mathlib/Analysis/InnerProductSpace/Projection.lean @@ -347,7 +347,7 @@ theorem norm_eq_iInf_iff_inner_eq_zero {u : E} {v : E} (hv : v ∈ K) : exact zero_re' exact (norm_eq_iInf_iff_real_inner_eq_zero K' hv).2 this -/-- A subspace `K : Submodule 𝕜 E` has an orthogonal projection if evey vector `v : E` admits an +/-- A subspace `K : Submodule 𝕜 E` has an orthogonal projection if every vector `v : E` admits an orthogonal projection to `K`. -/ class HasOrthogonalProjection (K : Submodule 𝕜 E) : Prop where exists_orthogonal (v : E) : ∃ w ∈ K, v - w ∈ Kᗮ @@ -471,13 +471,13 @@ theorem orthogonalProjectionFn_eq (v : E) : orthogonalProjectionFn K v = (orthogonalProjection K v : E) := rfl -/-- The characterization of the orthogonal projection. -/ +/-- The characterization of the orthogonal projection. -/ @[simp] theorem orthogonalProjection_inner_eq_zero (v : E) : ∀ w ∈ K, ⟪v - orthogonalProjection K v, w⟫ = 0 := orthogonalProjectionFn_inner_eq_zero v -/-- The difference of `v` from its orthogonal projection onto `K` is in `Kᗮ`. -/ +/-- The difference of `v` from its orthogonal projection onto `K` is in `Kᗮ`. -/ @[simp] theorem sub_orthogonalProjection_mem_orthogonal (v : E) : v - orthogonalProjection K v ∈ Kᗮ := by intro w hw @@ -780,7 +780,7 @@ is the topological closure of `K`. Note that the completeness assumption is necessary. Let `E` be the space `ℕ →₀ ℝ` with inner space structure inherited from `PiLp 2 (fun _ : ℕ ↦ ℝ)`. Let `K` be the subspace of sequences with the sum -of all elements equal to zero. Then `Kᗮ = ⊥`, `Kᗮᗮ = ⊤`. -/ +of all elements equal to zero. Then `Kᗮ = ⊥`, `Kᗮᗮ = ⊤`. -/ theorem Submodule.orthogonal_orthogonal_eq_closure [CompleteSpace E] : Kᗮᗮ = K.topologicalClosure := by refine le_antisymm ?_ ?_ diff --git a/Mathlib/Analysis/MeanInequalities.lean b/Mathlib/Analysis/MeanInequalities.lean index b35c1fbdcb152..6f0c79f037af0 100644 --- a/Mathlib/Analysis/MeanInequalities.lean +++ b/Mathlib/Analysis/MeanInequalities.lean @@ -330,7 +330,7 @@ end Real namespace NNReal /-- **Young's inequality**, `ℝ≥0` version. We use `{p q : ℝ≥0}` in order to avoid constructing -witnesses of `0 ≤ p` and `0 ≤ q` for the denominators. -/ +witnesses of `0 ≤ p` and `0 ≤ q` for the denominators. -/ theorem young_inequality (a b : ℝ≥0) {p q : ℝ≥0} (hpq : p.IsConjExponent q) : a * b ≤ a ^ (p : ℝ) / p + b ^ (q : ℝ) / q := Real.young_inequality_of_nonneg a.coe_nonneg b.coe_nonneg hpq.coe @@ -476,7 +476,7 @@ theorem inner_le_Lp_mul_Lq_tsum' {f g : ι → ℝ≥0} {p q : ℝ} (hpq : p.IsC /-- **Hölder inequality**: the scalar product of two functions is bounded by the product of their `L^p` and `L^q` norms when `p` and `q` are conjugate exponents. A version for `NNReal`-valued functions. For an alternative version, convenient if the infinite sums are not already expressed as -`p`-th powers, see `inner_le_Lp_mul_Lq_tsum`. -/ +`p`-th powers, see `inner_le_Lp_mul_Lq_tsum`. -/ theorem inner_le_Lp_mul_Lq_hasSum {f g : ι → ℝ≥0} {A B : ℝ≥0} {p q : ℝ} (hpq : p.IsConjExponent q) (hf : HasSum (fun i => f i ^ p) (A ^ p)) (hg : HasSum (fun i => g i ^ q) (B ^ q)) : ∃ C, C ≤ A * B ∧ HasSum (fun i => f i * g i) C := by @@ -584,7 +584,7 @@ theorem Lp_add_le_tsum' {f g : ι → ℝ≥0} {p : ℝ} (hp : 1 ≤ p) (hf : Su /-- **Minkowski inequality**: the `L_p` seminorm of the infinite sum of two vectors is less than or equal to the infinite sum of the `L_p`-seminorms of the summands, if these infinite sums both exist. A version for `NNReal`-valued functions. For an alternative version, convenient if the -infinite sums are not already expressed as `p`-th powers, see `Lp_add_le_tsum_of_nonneg`. -/ +infinite sums are not already expressed as `p`-th powers, see `Lp_add_le_tsum_of_nonneg`. -/ theorem Lp_add_le_hasSum {f g : ι → ℝ≥0} {A B : ℝ≥0} {p : ℝ} (hp : 1 ≤ p) (hf : HasSum (fun i => f i ^ p) (A ^ p)) (hg : HasSum (fun i => g i ^ p) (B ^ p)) : ∃ C, C ≤ A + B ∧ HasSum (fun i => (f i + g i) ^ p) (C ^ p) := by @@ -688,7 +688,7 @@ theorem inner_le_Lp_mul_Lq_tsum_of_nonneg' (hpq : p.IsConjExponent q) (hf : ∀ /-- **Hölder inequality**: the scalar product of two functions is bounded by the product of their `L^p` and `L^q` norms when `p` and `q` are conjugate exponents. A version for `NNReal`-valued functions. For an alternative version, convenient if the infinite sums are not already expressed as -`p`-th powers, see `inner_le_Lp_mul_Lq_tsum_of_nonneg`. -/ +`p`-th powers, see `inner_le_Lp_mul_Lq_tsum_of_nonneg`. -/ theorem inner_le_Lp_mul_Lq_hasSum_of_nonneg (hpq : p.IsConjExponent q) {A B : ℝ} (hA : 0 ≤ A) (hB : 0 ≤ B) (hf : ∀ i, 0 ≤ f i) (hg : ∀ i, 0 ≤ g i) (hf_sum : HasSum (fun i => f i ^ p) (A ^ p)) (hg_sum : HasSum (fun i => g i ^ q) (B ^ q)) : diff --git a/Mathlib/Analysis/Normed/Algebra/Exponential.lean b/Mathlib/Analysis/Normed/Algebra/Exponential.lean index 5f50363a1084b..21dce5d6376e3 100644 --- a/Mathlib/Analysis/Normed/Algebra/Exponential.lean +++ b/Mathlib/Analysis/Normed/Algebra/Exponential.lean @@ -269,7 +269,7 @@ theorem exp_add_of_commute_of_mem_ball [CharZero 𝕂] {x y : 𝔸} (hxy : Commu ext rw [hxy.add_pow' _, Finset.smul_sum] refine tsum_congr fun n => Finset.sum_congr rfl fun kl hkl => ?_ - rw [← Nat.cast_smul_eq_nsmul 𝕂, smul_smul, smul_mul_smul, ← Finset.mem_antidiagonal.mp hkl, + rw [← Nat.cast_smul_eq_nsmul 𝕂, smul_smul, smul_mul_smul_comm, ← Finset.mem_antidiagonal.mp hkl, Nat.cast_add_choose, Finset.mem_antidiagonal.mp hkl] congr 1 have : (n ! : 𝕂) ≠ 0 := Nat.cast_ne_zero.mpr n.factorial_ne_zero diff --git a/Mathlib/Analysis/Normed/Algebra/Spectrum.lean b/Mathlib/Analysis/Normed/Algebra/Spectrum.lean index d74a1d6c50562..e6e984888bc72 100644 --- a/Mathlib/Analysis/Normed/Algebra/Spectrum.lean +++ b/Mathlib/Analysis/Normed/Algebra/Spectrum.lean @@ -740,6 +740,26 @@ lemma real_iff [Algebra ℂ A] {a : A} : simp · exact .of_subset_range_algebraMap Complex.ofReal_re fun x hx ↦ ⟨x.re, (h x hx).symm⟩ +lemma nnreal_le_iff [Algebra ℝ A] {a : A} + (ha : SpectrumRestricts a ContinuousMap.realToNNReal) {r : ℝ≥0} : + (∀ x ∈ spectrum ℝ≥0 a, r ≤ x) ↔ ∀ x ∈ spectrum ℝ a, r ≤ x := by + simp [← ha.algebraMap_image] + +lemma nnreal_lt_iff [Algebra ℝ A] {a : A} + (ha : SpectrumRestricts a ContinuousMap.realToNNReal) {r : ℝ≥0} : + (∀ x ∈ spectrum ℝ≥0 a, r < x) ↔ ∀ x ∈ spectrum ℝ a, r < x := by + simp [← ha.algebraMap_image] + +lemma le_nnreal_iff [Algebra ℝ A] {a : A} + (ha : SpectrumRestricts a ContinuousMap.realToNNReal) {r : ℝ≥0} : + (∀ x ∈ spectrum ℝ≥0 a, x ≤ r) ↔ ∀ x ∈ spectrum ℝ a, x ≤ r := by + simp [← ha.algebraMap_image] + +lemma lt_nnreal_iff [Algebra ℝ A] {a : A} + (ha : SpectrumRestricts a ContinuousMap.realToNNReal) {r : ℝ≥0} : + (∀ x ∈ spectrum ℝ≥0 a, x < r) ↔ ∀ x ∈ spectrum ℝ a, x < r := by + simp [← ha.algebraMap_image] + lemma nnreal_iff_spectralRadius_le [Algebra ℝ A] {a : A} {t : ℝ≥0} (ht : spectralRadius ℝ a ≤ t) : SpectrumRestricts a ContinuousMap.realToNNReal ↔ spectralRadius ℝ (algebraMap ℝ A t - a) ≤ t := by @@ -817,6 +837,16 @@ lemma real_iff [Module ℂ A] [IsScalarTower ℂ A A] [SMulCommClass ℂ A A] {a rw [quasispectrumRestricts_iff_spectrumRestricts_inr, Unitization.quasispectrum_eq_spectrum_inr' _ ℂ, SpectrumRestricts.real_iff] +lemma le_nnreal_iff [Module ℝ A] [IsScalarTower ℝ A A] [SMulCommClass ℝ A A] {a : A} + (ha : QuasispectrumRestricts a ContinuousMap.realToNNReal) {r : ℝ≥0} : + (∀ x ∈ quasispectrum ℝ≥0 a, x ≤ r) ↔ ∀ x ∈ quasispectrum ℝ a, x ≤ r := by + simp [← ha.algebraMap_image] + +lemma lt_nnreal_iff [Module ℝ A] [IsScalarTower ℝ A A] [SMulCommClass ℝ A A] {a : A} + (ha : QuasispectrumRestricts a ContinuousMap.realToNNReal) {r : ℝ≥0} : + (∀ x ∈ quasispectrum ℝ≥0 a, x < r) ↔ ∀ x ∈ quasispectrum ℝ a, x < r := by + simp [← ha.algebraMap_image] + end QuasispectrumRestricts variable {A : Type*} [Ring A] [PartialOrder A] diff --git a/Mathlib/Analysis/Normed/Algebra/Unitization.lean b/Mathlib/Analysis/Normed/Algebra/Unitization.lean index 789e764e8c4e0..90fcffffc0c67 100644 --- a/Mathlib/Analysis/Normed/Algebra/Unitization.lean +++ b/Mathlib/Analysis/Normed/Algebra/Unitization.lean @@ -213,7 +213,7 @@ theorem uniformEmbedding_addEquiv {𝕜} [NontriviallyNormedField 𝕜] : comap_uniformity := rfl inj := (addEquiv 𝕜 A).injective -/-- `Unitization 𝕜 A` is complete whenever `𝕜` and `A` are also. -/ +/-- `Unitization 𝕜 A` is complete whenever `𝕜` and `A` are also. -/ instance instCompleteSpace [CompleteSpace 𝕜] [CompleteSpace A] : CompleteSpace (Unitization 𝕜 A) := (completeSpace_congr uniformEmbedding_addEquiv).mpr CompleteSpace.prod diff --git a/Mathlib/Analysis/Normed/Field/Basic.lean b/Mathlib/Analysis/Normed/Field/Basic.lean index c9a3e6d3393c9..67f29e5b6d206 100644 --- a/Mathlib/Analysis/Normed/Field/Basic.lean +++ b/Mathlib/Analysis/Normed/Field/Basic.lean @@ -245,7 +245,7 @@ theorem mulRight_bound (x : α) : ∀ y : α, ‖AddMonoidHom.mulRight x y‖ exact norm_mul_le y x /-- A non-unital subalgebra of a non-unital seminormed ring is also a non-unital seminormed ring, -with the restriction of the norm. -/ +with the restriction of the norm. -/ instance NonUnitalSubalgebra.nonUnitalSeminormedRing {𝕜 : Type*} [CommRing 𝕜] {E : Type*} [NonUnitalSeminormedRing E] [Module 𝕜 E] (s : NonUnitalSubalgebra 𝕜 E) : NonUnitalSeminormedRing s := @@ -253,7 +253,7 @@ instance NonUnitalSubalgebra.nonUnitalSeminormedRing {𝕜 : Type*} [CommRing norm_mul := fun a b => norm_mul_le a.1 b.1 } /-- A non-unital subalgebra of a non-unital seminormed ring is also a non-unital seminormed ring, -with the restriction of the norm. -/ +with the restriction of the norm. -/ -- necessary to require `SMulMemClass S 𝕜 E` so that `𝕜` can be determined as an `outParam` @[nolint unusedArguments] instance (priority := 75) NonUnitalSubalgebraClass.nonUnitalSeminormedRing {S 𝕜 E : Type*} @@ -264,14 +264,14 @@ instance (priority := 75) NonUnitalSubalgebraClass.nonUnitalSeminormedRing {S norm_mul := fun a b => norm_mul_le a.1 b.1 } /-- A non-unital subalgebra of a non-unital normed ring is also a non-unital normed ring, with the -restriction of the norm. -/ +restriction of the norm. -/ instance NonUnitalSubalgebra.nonUnitalNormedRing {𝕜 : Type*} [CommRing 𝕜] {E : Type*} [NonUnitalNormedRing E] [Module 𝕜 E] (s : NonUnitalSubalgebra 𝕜 E) : NonUnitalNormedRing s := { s.nonUnitalSeminormedRing with eq_of_dist_eq_zero := eq_of_dist_eq_zero } /-- A non-unital subalgebra of a non-unital normed ring is also a non-unital normed ring, -with the restriction of the norm. -/ +with the restriction of the norm. -/ instance (priority := 75) NonUnitalSubalgebraClass.nonUnitalNormedRing {S 𝕜 E : Type*} [CommRing 𝕜] [NonUnitalNormedRing E] [Module 𝕜 E] [SetLike S E] [NonUnitalSubringClass S E] [SMulMemClass S 𝕜 E] (s : S) : @@ -326,7 +326,7 @@ end NonUnitalSeminormedRing section SeminormedRing -variable [SeminormedRing α] +variable [SeminormedRing α] {a b c : α} /-- A subalgebra of a seminormed ring is also a seminormed ring, with the restriction of the norm. -/ @@ -447,6 +447,29 @@ instance MulOpposite.instSeminormedRing : SeminormedRing αᵐᵒᵖ where __ := instRing __ := instNonUnitalSeminormedRing +/-- This inequality is particularly useful when `c = 1` and `‖a‖ = ‖b‖ = 1` as it then shows that +chord length is a metric on the unit complex numbers. -/ +lemma norm_sub_mul_le (ha : ‖a‖ ≤ 1) : ‖c - a * b‖ ≤ ‖c - a‖ + ‖1 - b‖ := + calc + _ ≤ ‖c - a‖ + ‖a * (1 - b)‖ := by + simpa [mul_one_sub] using norm_sub_le_norm_sub_add_norm_sub c a (a * b) + _ ≤ ‖c - a‖ + ‖a‖ * ‖1 - b‖ := by gcongr; exact norm_mul_le .. + _ ≤ ‖c - a‖ + 1 * ‖1 - b‖ := by gcongr + _ = ‖c - a‖ + ‖1 - b‖ := by simp + +/-- This inequality is particularly useful when `c = 1` and `‖a‖ = ‖b‖ = 1` as it then shows that +chord length is a metric on the unit complex numbers. -/ +lemma norm_sub_mul_le' (hb : ‖b‖ ≤ 1) : ‖c - a * b‖ ≤ ‖1 - a‖ + ‖c - b‖ := by + rw [add_comm]; exact norm_sub_mul_le (α := αᵐᵒᵖ) hb + +/-- This inequality is particularly useful when `c = 1` and `‖a‖ = ‖b‖ = 1` as it then shows that +chord length is a metric on the unit complex numbers. -/ +lemma nnnorm_sub_mul_le (ha : ‖a‖₊ ≤ 1) : ‖c - a * b‖₊ ≤ ‖c - a‖₊ + ‖1 - b‖₊ := norm_sub_mul_le ha + +/-- This inequality is particularly useful when `c = 1` and `‖a‖ = ‖b‖ = 1` as it then shows that +chord length is a metric on the unit complex numbers. -/ +lemma nnnorm_sub_mul_le' (hb : ‖b‖₊ ≤ 1) : ‖c - a * b‖₊ ≤ ‖1 - a‖₊ + ‖c - b‖₊ := norm_sub_mul_le' hb + end SeminormedRing section NonUnitalNormedRing @@ -533,14 +556,14 @@ section NonUnitalNormedCommRing variable [NonUnitalNormedCommRing α] /-- A non-unital subalgebra of a non-unital seminormed commutative ring is also a non-unital -seminormed commutative ring, with the restriction of the norm. -/ +seminormed commutative ring, with the restriction of the norm. -/ instance NonUnitalSubalgebra.nonUnitalSeminormedCommRing {𝕜 : Type*} [CommRing 𝕜] {E : Type*} [NonUnitalSeminormedCommRing E] [Module 𝕜 E] (s : NonUnitalSubalgebra 𝕜 E) : NonUnitalSeminormedCommRing s := { s.nonUnitalSeminormedRing, s.toNonUnitalCommRing with } /-- A non-unital subalgebra of a non-unital normed commutative ring is also a non-unital normed -commutative ring, with the restriction of the norm. -/ +commutative ring, with the restriction of the norm. -/ instance NonUnitalSubalgebra.nonUnitalNormedCommRing {𝕜 : Type*} [CommRing 𝕜] {E : Type*} [NonUnitalNormedCommRing E] [Module 𝕜 E] (s : NonUnitalSubalgebra 𝕜 E) : NonUnitalNormedCommRing s := @@ -594,13 +617,13 @@ end SeminormedCommRing section NormedCommRing /-- A subalgebra of a seminormed commutative ring is also a seminormed commutative ring, with the -restriction of the norm. -/ +restriction of the norm. -/ instance Subalgebra.seminormedCommRing {𝕜 : Type*} [CommRing 𝕜] {E : Type*} [SeminormedCommRing E] [Algebra 𝕜 E] (s : Subalgebra 𝕜 E) : SeminormedCommRing s := { s.seminormedRing, s.toCommRing with } /-- A subalgebra of a normed commutative ring is also a normed commutative ring, with the -restriction of the norm. -/ +restriction of the norm. -/ instance Subalgebra.normedCommRing {𝕜 : Type*} [CommRing 𝕜] {E : Type*} [NormedCommRing E] [Algebra 𝕜 E] (s : Subalgebra 𝕜 E) : NormedCommRing s := { s.seminormedCommRing, s.normedRing with } diff --git a/Mathlib/Analysis/Normed/Field/InfiniteSum.lean b/Mathlib/Analysis/Normed/Field/InfiniteSum.lean index 4defadc79c84a..53112926ff88d 100644 --- a/Mathlib/Analysis/Normed/Field/InfiniteSum.lean +++ b/Mathlib/Analysis/Normed/Field/InfiniteSum.lean @@ -21,9 +21,9 @@ We first establish results about arbitrary index types, `ι` and `ι'`, and then variable {R : Type*} {ι : Type*} {ι' : Type*} [NormedRing R] -open scoped Classical +open scoped Topology -open Finset +open Finset Filter /-! ### Arbitrary index types -/ @@ -43,13 +43,35 @@ theorem summable_mul_of_summable_norm [CompleteSpace R] {f : ι → R} {g : ι' Summable fun x : ι × ι' => f x.1 * g x.2 := (hf.mul_norm hg).of_norm -/-- Product of two infinites sums indexed by arbitrary types. - See also `tsum_mul_tsum` if `f` and `g` are *not* absolutely summable. -/ +theorem summable_mul_of_summable_norm' {f : ι → R} {g : ι' → R} + (hf : Summable fun x => ‖f x‖) (h'f : Summable f) + (hg : Summable fun x => ‖g x‖) (h'g : Summable g) : + Summable fun x : ι × ι' => f x.1 * g x.2 := by + classical + suffices HasSum (fun x : ι × ι' => f x.1 * g x.2) ((∑' i, f i) * (∑' j, g j)) from this.summable + let s : Finset ι × Finset ι' → Finset (ι × ι') := fun p ↦ p.1 ×ˢ p.2 + apply hasSum_of_subseq_of_summable (hf.mul_norm hg) tendsto_finset_prod_atTop + rw [← prod_atTop_atTop_eq] + have := Tendsto.prod_map h'f.hasSum h'g.hasSum + rw [← nhds_prod_eq] at this + convert ((continuous_mul (M := R)).continuousAt + (x := (∑' (i : ι), f i, ∑' (j : ι'), g j))).tendsto.comp this with p + simp [s, sum_product, ← mul_sum, ← sum_mul] + +/-- Product of two infinite sums indexed by arbitrary types. + See also `tsum_mul_tsum` if `f` and `g` are *not* absolutely summable, and + `tsum_mul_tsum_of_summable_norm'` when the space is not complete. -/ theorem tsum_mul_tsum_of_summable_norm [CompleteSpace R] {f : ι → R} {g : ι' → R} (hf : Summable fun x => ‖f x‖) (hg : Summable fun x => ‖g x‖) : ((∑' x, f x) * ∑' y, g y) = ∑' z : ι × ι', f z.1 * g z.2 := tsum_mul_tsum hf.of_norm hg.of_norm (summable_mul_of_summable_norm hf hg) +theorem tsum_mul_tsum_of_summable_norm' {f : ι → R} {g : ι' → R} + (hf : Summable fun x => ‖f x‖) (h'f : Summable f) + (hg : Summable fun x => ‖g x‖) (h'g : Summable g) : + ((∑' x, f x) * ∑' y, g y) = ∑' z : ι × ι', f z.1 * g z.2 := + tsum_mul_tsum h'f h'g (summable_mul_of_summable_norm' hf h'f hg h'g) + /-! ### `ℕ`-indexed families (Cauchy product) We prove two versions of the Cauchy product formula. The first one is @@ -76,28 +98,69 @@ theorem summable_norm_sum_mul_antidiagonal_of_summable_norm {f g : ℕ → R} norm_sum_le _ _ _ ≤ ∑ kl ∈ antidiagonal n, ‖f kl.1‖ * ‖g kl.2‖ := by gcongr; apply norm_mul_le +theorem summable_sum_mul_antidiagonal_of_summable_norm' {f g : ℕ → R} + (hf : Summable fun x => ‖f x‖) (h'f : Summable f) + (hg : Summable fun x => ‖g x‖) (h'g : Summable g) : + Summable fun n => ∑ kl ∈ antidiagonal n, f kl.1 * g kl.2 := + summable_sum_mul_antidiagonal_of_summable_mul (summable_mul_of_summable_norm' hf h'f hg h'g) + /-- The Cauchy product formula for the product of two infinite sums indexed by `ℕ`, expressed by summing on `Finset.antidiagonal`. See also `tsum_mul_tsum_eq_tsum_sum_antidiagonal` if `f` and `g` are - *not* absolutely summable. -/ + *not* absolutely summable, and `tsum_mul_tsum_eq_tsum_sum_antidiagonal_of_summable_norm'` + when the space is not complete. -/ theorem tsum_mul_tsum_eq_tsum_sum_antidiagonal_of_summable_norm [CompleteSpace R] {f g : ℕ → R} (hf : Summable fun x => ‖f x‖) (hg : Summable fun x => ‖g x‖) : ((∑' n, f n) * ∑' n, g n) = ∑' n, ∑ kl ∈ antidiagonal n, f kl.1 * g kl.2 := tsum_mul_tsum_eq_tsum_sum_antidiagonal hf.of_norm hg.of_norm (summable_mul_of_summable_norm hf hg) +theorem tsum_mul_tsum_eq_tsum_sum_antidiagonal_of_summable_norm' {f g : ℕ → R} + (hf : Summable fun x => ‖f x‖) (h'f : Summable f) + (hg : Summable fun x => ‖g x‖) (h'g : Summable g) : + ((∑' n, f n) * ∑' n, g n) = ∑' n, ∑ kl ∈ antidiagonal n, f kl.1 * g kl.2 := + tsum_mul_tsum_eq_tsum_sum_antidiagonal h'f h'g (summable_mul_of_summable_norm' hf h'f hg h'g) + theorem summable_norm_sum_mul_range_of_summable_norm {f g : ℕ → R} (hf : Summable fun x => ‖f x‖) (hg : Summable fun x => ‖g x‖) : Summable fun n => ‖∑ k ∈ range (n + 1), f k * g (n - k)‖ := by simp_rw [← sum_antidiagonal_eq_sum_range_succ fun k l => f k * g l] exact summable_norm_sum_mul_antidiagonal_of_summable_norm hf hg +theorem summable_sum_mul_range_of_summable_norm' {f g : ℕ → R} + (hf : Summable fun x => ‖f x‖) (h'f : Summable f) + (hg : Summable fun x => ‖g x‖) (h'g : Summable g) : + Summable fun n => ∑ k ∈ range (n + 1), f k * g (n - k) := by + simp_rw [← sum_antidiagonal_eq_sum_range_succ fun k l => f k * g l] + exact summable_sum_mul_antidiagonal_of_summable_norm' hf h'f hg h'g + /-- The Cauchy product formula for the product of two infinite sums indexed by `ℕ`, expressed by summing on `Finset.range`. See also `tsum_mul_tsum_eq_tsum_sum_range` if `f` and `g` are - *not* absolutely summable. -/ + *not* absolutely summable, and `tsum_mul_tsum_eq_tsum_sum_range_of_summable_norm'` when the + space is not complete. -/ theorem tsum_mul_tsum_eq_tsum_sum_range_of_summable_norm [CompleteSpace R] {f g : ℕ → R} (hf : Summable fun x => ‖f x‖) (hg : Summable fun x => ‖g x‖) : ((∑' n, f n) * ∑' n, g n) = ∑' n, ∑ k ∈ range (n + 1), f k * g (n - k) := by simp_rw [← sum_antidiagonal_eq_sum_range_succ fun k l => f k * g l] exact tsum_mul_tsum_eq_tsum_sum_antidiagonal_of_summable_norm hf hg +theorem hasSum_sum_range_mul_of_summable_norm [CompleteSpace R] {f g : ℕ → R} + (hf : Summable fun x => ‖f x‖) (hg : Summable fun x => ‖g x‖) : + HasSum (fun n ↦ ∑ k ∈ range (n + 1), f k * g (n - k)) ((∑' n, f n) * ∑' n, g n) := by + convert (summable_norm_sum_mul_range_of_summable_norm hf hg).of_norm.hasSum + exact tsum_mul_tsum_eq_tsum_sum_range_of_summable_norm hf hg + +theorem tsum_mul_tsum_eq_tsum_sum_range_of_summable_norm' {f g : ℕ → R} + (hf : Summable fun x => ‖f x‖) (h'f : Summable f) + (hg : Summable fun x => ‖g x‖) (h'g : Summable g) : + ((∑' n, f n) * ∑' n, g n) = ∑' n, ∑ k ∈ range (n + 1), f k * g (n - k) := by + simp_rw [← sum_antidiagonal_eq_sum_range_succ fun k l => f k * g l] + exact tsum_mul_tsum_eq_tsum_sum_antidiagonal_of_summable_norm' hf h'f hg h'g + +theorem hasSum_sum_range_mul_of_summable_norm' {f g : ℕ → R} + (hf : Summable fun x => ‖f x‖) (h'f : Summable f) + (hg : Summable fun x => ‖g x‖) (h'g : Summable g) : + HasSum (fun n ↦ ∑ k ∈ range (n + 1), f k * g (n - k)) ((∑' n, f n) * ∑' n, g n) := by + convert (summable_sum_mul_range_of_summable_norm' hf h'f hg h'g).hasSum + exact tsum_mul_tsum_eq_tsum_sum_range_of_summable_norm' hf h'f hg h'g + end Nat diff --git a/Mathlib/Analysis/Normed/Group/Completeness.lean b/Mathlib/Analysis/Normed/Group/Completeness.lean index 6390ce5cd3cc9..8fee862ad3d6d 100644 --- a/Mathlib/Analysis/Normed/Group/Completeness.lean +++ b/Mathlib/Analysis/Normed/Group/Completeness.lean @@ -51,7 +51,7 @@ section Normed variable {E : Type*} [NormedAddCommGroup E] /-- A normed additive group is complete if any absolutely convergent series converges in the -space. -/ +space. -/ lemma NormedAddCommGroup.completeSpace_of_summable_imp_tendsto (h : ∀ u : ℕ → E, Summable (‖u ·‖) → ∃ a, Tendsto (fun n => ∑ i ∈ range n, u i) atTop (𝓝 a)) : @@ -73,14 +73,14 @@ lemma NormedAddCommGroup.completeSpace_of_summable_imp_tendsto simpa only [sub_add_cancel] using h₁ /-- In a complete normed additive group, every absolutely convergent series converges in the -space. -/ +space. -/ lemma NormedAddCommGroup.summable_imp_tendsto_of_complete [CompleteSpace E] (u : ℕ → E) (hu : Summable (‖u ·‖)) : ∃ a, Tendsto (fun n => ∑ i ∈ range n, u i) atTop (𝓝 a) := by refine cauchySeq_tendsto_of_complete <| cauchySeq_of_summable_dist ?_ simp [dist_eq_norm, sum_range_succ, hu] /-- In a normed additive group, every absolutely convergent series converges in the -space iff the space is complete. -/ +space iff the space is complete. -/ lemma NormedAddCommGroup.summable_imp_tendsto_iff_completeSpace : (∀ u : ℕ → E, Summable (‖u ·‖) → ∃ a, Tendsto (fun n => ∑ i ∈ range n, u i) atTop (𝓝 a)) ↔ CompleteSpace E := diff --git a/Mathlib/Analysis/Normed/Group/Hom.lean b/Mathlib/Analysis/Normed/Group/Hom.lean index 0b30d2fdc3c07..b433f7a144ef5 100644 --- a/Mathlib/Analysis/Normed/Group/Hom.lean +++ b/Mathlib/Analysis/Normed/Group/Hom.lean @@ -532,7 +532,7 @@ instance toNormedAddCommGroup {V₁ V₂ : Type*} [NormedAddCommGroup V₁] [Nor add_le' := opNorm_add_le eq_zero_of_map_eq_zero' := fun _f => opNorm_zero_iff.1 } -/-- Coercion of a `NormedAddGroupHom` is an `AddMonoidHom`. Similar to `AddMonoidHom.coeFn`. -/ +/-- Coercion of a `NormedAddGroupHom` is an `AddMonoidHom`. Similar to `AddMonoidHom.coeFn`. -/ @[simps] def coeAddHom : NormedAddGroupHom V₁ V₂ →+ V₁ → V₂ where toFun := DFunLike.coe diff --git a/Mathlib/Analysis/Normed/Group/Quotient.lean b/Mathlib/Analysis/Normed/Group/Quotient.lean index 7406b8e2cf248..085dab581687e 100644 --- a/Mathlib/Analysis/Normed/Group/Quotient.lean +++ b/Mathlib/Analysis/Normed/Group/Quotient.lean @@ -213,7 +213,7 @@ theorem quotient_nhd_basis (S : AddSubgroup M) : refine fun ε ↦ Set.ext <| forall_mk.2 fun x ↦ ?_ rw [ball_zero_eq, mem_setOf_eq, norm_lt_iff, mem_image] exact exists_congr fun _ ↦ and_comm - rw [← mk_zero, nhds_eq, ← funext this] + rw [← QuotientAddGroup.mk_zero, nhds_eq, ← funext this] exact .map _ Metric.nhds_basis_ball /-- The seminormed group structure on the quotient by an additive subgroup. -/ diff --git a/Mathlib/Analysis/Normed/Lp/LpEquiv.lean b/Mathlib/Analysis/Normed/Lp/LpEquiv.lean index d43a285b86665..8be09ea3634f1 100644 --- a/Mathlib/Analysis/Normed/Lp/LpEquiv.lean +++ b/Mathlib/Analysis/Normed/Lp/LpEquiv.lean @@ -72,7 +72,7 @@ theorem coe_equiv_lpPiLp_symm (f : PiLp p E) : (Equiv.lpPiLp.symm f : ∀ i, E i def AddEquiv.lpPiLp : lp E p ≃+ PiLp p E := { Equiv.lpPiLp with map_add' := fun _f _g ↦ rfl } -theorem coe_addEquiv_lpPiLp (f : lp E p) : AddEquiv.lpPiLp f = ⇑f := +theorem coe_addEquiv_lpPiLp (f : lp E p) : AddEquiv.lpPiLp f = ⇑f := rfl theorem coe_addEquiv_lpPiLp_symm (f : PiLp p E) : diff --git a/Mathlib/Analysis/Normed/Lp/PiLp.lean b/Mathlib/Analysis/Normed/Lp/PiLp.lean index 45556b51f15c5..a8d44803d2842 100644 --- a/Mathlib/Analysis/Normed/Lp/PiLp.lean +++ b/Mathlib/Analysis/Normed/Lp/PiLp.lean @@ -640,7 +640,7 @@ variable (p 𝕜) variable (E : Type*) [SeminormedAddCommGroup E] [Module 𝕜 E] /-- An equivalence of finite domains induces a linearly isometric equivalence of finitely supported -functions-/ +functions -/ def _root_.LinearIsometryEquiv.piLpCongrLeft (e : ι ≃ ι') : (PiLp p fun _ : ι => E) ≃ₗᵢ[𝕜] PiLp p fun _ : ι' => E where toLinearEquiv := LinearEquiv.piCongrLeft' 𝕜 (fun _ : ι => E) e diff --git a/Mathlib/Analysis/Normed/Lp/WithLp.lean b/Mathlib/Analysis/Normed/Lp/WithLp.lean index b636322d0d7e8..d921359dcb5a5 100644 --- a/Mathlib/Analysis/Normed/Lp/WithLp.lean +++ b/Mathlib/Analysis/Normed/Lp/WithLp.lean @@ -46,7 +46,7 @@ instance, on `Prod` and finite `Pi` types). -/ @[nolint unusedArguments] def WithLp (_p : ℝ≥0∞) (V : Type uV) : Type uV := V -variable (p : ℝ≥0∞) (K : Type uK) (K' : Type uK') (V : Type uV) +variable (p : ℝ≥0∞) (K : Type uK) (K' : Type uK') (V : Type uV) namespace WithLp diff --git a/Mathlib/Analysis/Normed/Operator/Banach.lean b/Mathlib/Analysis/Normed/Operator/Banach.lean index 5d6eca063bbe1..8561d451ba771 100644 --- a/Mathlib/Analysis/Normed/Operator/Banach.lean +++ b/Mathlib/Analysis/Normed/Operator/Banach.lean @@ -531,7 +531,7 @@ section BijectivityCriteria namespace ContinuousLinearMap -variable {σ : 𝕜 →+* 𝕜'} {σ' : 𝕜' →+* 𝕜} [RingHomInvPair σ σ'] {f : E →SL[σ] F} +variable {σ : 𝕜 →+* 𝕜'} {σ' : 𝕜' →+* 𝕜} [RingHomInvPair σ σ'] {f : E →SL[σ] F} variable {F : Type u_4} [NormedAddCommGroup F] [NormedSpace 𝕜' F] variable [CompleteSpace E] diff --git a/Mathlib/Analysis/Normed/Operator/WeakOperatorTopology.lean b/Mathlib/Analysis/Normed/Operator/WeakOperatorTopology.lean index b7a5ea7136815..45dfa1892cbcc 100644 --- a/Mathlib/Analysis/Normed/Operator/WeakOperatorTopology.lean +++ b/Mathlib/Analysis/Normed/Operator/WeakOperatorTopology.lean @@ -85,7 +85,7 @@ variable (𝕜) (E) (F) unseal ContinuousLinearMapWOT in /-- The linear equivalence that sends a continuous linear map to the type copy endowed with the -weak operator topology. -/ +weak operator topology. -/ def _root_.ContinuousLinearMap.toWOT : (E →L[𝕜] F) ≃ₗ[𝕜] (E →WOT[𝕜] F) := LinearEquiv.refl 𝕜 _ variable {𝕜} {E} {F} @@ -211,7 +211,7 @@ end Topology section Seminorms /-- The family of seminorms that induce the weak operator topology, namely `‖y (A x)‖` for -all `x` and `y`. -/ +all `x` and `y`. -/ def seminorm (x : E) (y : F⋆) : Seminorm 𝕜 (E →WOT[𝕜] F) where toFun A := ‖y (A x)‖ map_zero' := by simp @@ -221,7 +221,7 @@ def seminorm (x : E) (y : F⋆) : Seminorm 𝕜 (E →WOT[𝕜] F) where variable (𝕜) (E) (F) in /-- The family of seminorms that induce the weak operator topology, namely `‖y (A x)‖` for -all `x` and `y`. -/ +all `x` and `y`. -/ def seminormFamily : SeminormFamily 𝕜 (E →WOT[𝕜] F) (E × F⋆) := fun ⟨x, y⟩ => seminorm x y diff --git a/Mathlib/Analysis/Normed/Ring/Seminorm.lean b/Mathlib/Analysis/Normed/Ring/Seminorm.lean index 9d88d4bb64e68..8bf3cb7ea8909 100644 --- a/Mathlib/Analysis/Normed/Ring/Seminorm.lean +++ b/Mathlib/Analysis/Normed/Ring/Seminorm.lean @@ -298,7 +298,7 @@ instance : Inhabited (MulRingNorm R) := variable {R : Type*} [Ring R] /-- Two multiplicative ring norms `f, g` on `R` are equivalent if there exists a positive constant - `c` such that for all `x ∈ R`, `(f x)^c = g x`. -/ + `c` such that for all `x ∈ R`, `(f x)^c = g x`. -/ def equiv (f : MulRingNorm R) (g : MulRingNorm R) := ∃ c : ℝ, 0 < c ∧ (fun x => (f x) ^ c) = g diff --git a/Mathlib/Analysis/Normed/Ring/SeminormFromBounded.lean b/Mathlib/Analysis/Normed/Ring/SeminormFromBounded.lean index 2855ee36ba27b..a98f45db8cc03 100644 --- a/Mathlib/Analysis/Normed/Ring/SeminormFromBounded.lean +++ b/Mathlib/Analysis/Normed/Ring/SeminormFromBounded.lean @@ -153,11 +153,11 @@ theorem seminormFromBounded_eq_zero_iff (f_nonneg : 0 ≤ f) refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩ · have hf := seminormFromBounded_ge f_nonneg f_mul x rw [h, mul_zero] at hf - exact hf.antisymm (f_nonneg _) + exact hf.antisymm (f_nonneg _) · have hf : seminormFromBounded' f x ≤ c * f x := seminormFromBounded_le f_nonneg f_mul x rw [h, mul_zero] at hf - exact hf.antisymm (seminormFromBounded_nonneg f_nonneg f_mul x) + exact hf.antisymm (seminormFromBounded_nonneg f_nonneg f_mul x) /-- If `f` is invariant under negation of `x`, then so is `seminormFromBounded'`.-/ theorem seminormFromBounded_neg (f_neg : ∀ x : R, f (-x) = f x) (x : R) : diff --git a/Mathlib/Analysis/Normed/Ring/Units.lean b/Mathlib/Analysis/Normed/Ring/Units.lean index c46b35e61a4d4..5a8661f9daa50 100644 --- a/Mathlib/Analysis/Normed/Ring/Units.lean +++ b/Mathlib/Analysis/Normed/Ring/Units.lean @@ -36,7 +36,7 @@ variable {R : Type*} [NormedRing R] [CompleteSpace R] namespace Units /-- In a complete normed ring, a perturbation of `1` by an element `t` of distance less than `1` -from `1` is a unit. Here we construct its `Units` structure. -/ +from `1` is a unit. Here we construct its `Units` structure. -/ @[simps val] def oneSub (t : R) (h : ‖t‖ < 1) : Rˣ where val := 1 - t diff --git a/Mathlib/Analysis/NormedSpace/OperatorNorm/Bilinear.lean b/Mathlib/Analysis/NormedSpace/OperatorNorm/Bilinear.lean index 07c05d0a62e73..1d70cb3750159 100644 --- a/Mathlib/Analysis/NormedSpace/OperatorNorm/Bilinear.lean +++ b/Mathlib/Analysis/NormedSpace/OperatorNorm/Bilinear.lean @@ -382,7 +382,7 @@ variable {𝕜₁' : Type*} {𝕜₂' : Type*} [NontriviallyNormedField 𝕜₁' [RingHomIsometric σ₂₃] [RingHomIsometric σ₁₃'] [RingHomIsometric σ₂₃'] /-- Compose a bilinear map `E →SL[σ₁₃] F →SL[σ₂₃] G` with two linear maps -`E' →SL[σ₁'] E` and `F' →SL[σ₂'] F`. -/ +`E' →SL[σ₁'] E` and `F' →SL[σ₂'] F`. -/ def bilinearComp (f : E →SL[σ₁₃] F →SL[σ₂₃] G) (gE : E' →SL[σ₁'] E) (gF : F' →SL[σ₂'] F) : E' →SL[σ₁₃'] F' →SL[σ₂₃'] G := ((f.comp gE).flip.comp gF).flip diff --git a/Mathlib/Analysis/NormedSpace/OperatorNorm/Completeness.lean b/Mathlib/Analysis/NormedSpace/OperatorNorm/Completeness.lean index 03c7738155ba1..b4e87ed65eb32 100644 --- a/Mathlib/Analysis/NormedSpace/OperatorNorm/Completeness.lean +++ b/Mathlib/Analysis/NormedSpace/OperatorNorm/Completeness.lean @@ -184,7 +184,7 @@ section variable (h_e : UniformInducing e) /-- Extension of a continuous linear map `f : E →SL[σ₁₂] F`, with `E` a normed space and `F` a -complete normed space, along a uniform and dense embedding `e : E →L[𝕜] Fₗ`. -/ +complete normed space, along a uniform and dense embedding `e : E →L[𝕜] Fₗ`. -/ def extend : Fₗ →SL[σ₁₂] F := -- extension of `f` is continuous have cont := (uniformContinuous_uniformly_extend h_e h_dense f.uniformContinuous).continuous diff --git a/Mathlib/Analysis/RCLike/Basic.lean b/Mathlib/Analysis/RCLike/Basic.lean index 0cd73e900fc17..3b099de5281aa 100644 --- a/Mathlib/Analysis/RCLike/Basic.lean +++ b/Mathlib/Analysis/RCLike/Basic.lean @@ -230,7 +230,7 @@ theorem norm_ofReal (r : ℝ) : ‖(r : K)‖ = |r| := /-! ### Characteristic zero -/ -- see Note [lower instance priority] -/-- ℝ and ℂ are both of characteristic zero. -/ +/-- ℝ and ℂ are both of characteristic zero. -/ instance (priority := 100) charZero_rclike : CharZero K := (RingHom.charZero_iff (algebraMap ℝ K).injective).1 inferInstance @@ -832,7 +832,7 @@ theorem toOrderedSMul : OrderedSMul ℝ K := scoped[ComplexOrder] attribute [instance] RCLike.toOrderedSMul -/-- A star algebra over `K` has a scalar multiplication that respects the order. -/ +/-- A star algebra over `K` has a scalar multiplication that respects the order. -/ lemma _root_.StarModule.instOrderedSMul {A : Type*} [NonUnitalRing A] [StarRing A] [PartialOrder A] [StarOrderedRing A] [Module K A] [StarModule K A] [IsScalarTower K A A] [SMulCommClass K A A] : OrderedSMul K A where diff --git a/Mathlib/Analysis/SpecialFunctions/BinaryEntropy.lean b/Mathlib/Analysis/SpecialFunctions/BinaryEntropy.lean index c76c7577fe79d..765ed994e7883 100644 --- a/Mathlib/Analysis/SpecialFunctions/BinaryEntropy.lean +++ b/Mathlib/Analysis/SpecialFunctions/BinaryEntropy.lean @@ -276,7 +276,7 @@ private lemma tendsto_log_one_sub_sub_log_nhdsWithin_one_atBot : · have : Tendsto log (𝓝[>] 0) atBot := Real.tendsto_log_nhdsWithin_zero_right apply Tendsto.comp (f := (1 - ·)) (g := log) this have contF : Continuous ((1 : ℝ) - ·) := continuous_sub_left 1 - have : MapsTo ((1 : ℝ) - ·) (Iio 1) (Ioi 0) := by + have : MapsTo ((1 : ℝ) - ·) (Iio 1) (Ioi 0) := by intro p hx simp_all only [mem_Iio, mem_Ioi, sub_pos] convert ContinuousWithinAt.tendsto_nhdsWithin (x :=(1 : ℝ)) contF.continuousWithinAt this diff --git a/Mathlib/Analysis/SpecialFunctions/Complex/Log.lean b/Mathlib/Analysis/SpecialFunctions/Complex/Log.lean index 48b5d9c9e10b9..ad7f981e284ec 100644 --- a/Mathlib/Analysis/SpecialFunctions/Complex/Log.lean +++ b/Mathlib/Analysis/SpecialFunctions/Complex/Log.lean @@ -250,7 +250,7 @@ variable {α ι: Type*} open Real -lemma Real.HasSum_rexp_HasProd (f : ι → α → ℝ) (hfn : ∀ x n, 0 < f n x) +lemma Real.HasSum_rexp_HasProd (f : ι → α → ℝ) (hfn : ∀ x n, 0 < f n x) (hf : ∀ x : α, HasSum (fun n => log (f n x)) (∑' i, log (f i x))) (a : α) : HasProd (fun b ↦ f b a) (∏' n : ι, (f n a)) := by have : HasProd (fun b ↦ f b a) ((rexp ∘ fun a ↦ ∑' (n : ι), log (f n a)) a) := by diff --git a/Mathlib/Analysis/SpecialFunctions/Gamma/Beta.lean b/Mathlib/Analysis/SpecialFunctions/Gamma/Beta.lean index 674fd91181743..5b9cac12afe16 100644 --- a/Mathlib/Analysis/SpecialFunctions/Gamma/Beta.lean +++ b/Mathlib/Analysis/SpecialFunctions/Gamma/Beta.lean @@ -123,7 +123,7 @@ theorem betaIntegral_scaled (s t : ℂ) {a : ℝ} (ha : 0 < a) : push_cast rw [mul_sub, mul_one, mul_div_cancel₀ _ ha'] -/-- Relation between Beta integral and Gamma function. -/ +/-- Relation between Beta integral and Gamma function. -/ theorem Gamma_mul_Gamma_eq_betaIntegral {s t : ℂ} (hs : 0 < re s) (ht : 0 < re t) : Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by -- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate @@ -270,7 +270,7 @@ theorem GammaSeq_eq_approx_Gamma_integral {s : ℂ} (hs : 0 < re s) {n : ℕ} (h mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le] rw [A, B, cpow_natCast]; ring -/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the +/-- The main technical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/ theorem approx_Gamma_integral_tendsto_Gamma_integral {s : ℂ} (hs : 0 < re s) : Tendsto (fun n : ℕ => ∫ x : ℝ in (0)..n, ((1 - x / n) ^ n : ℝ) * (x : ℂ) ^ (s - 1)) atTop diff --git a/Mathlib/Analysis/SpecialFunctions/Gaussian/FourierTransform.lean b/Mathlib/Analysis/SpecialFunctions/Gaussian/FourierTransform.lean index a60fa19f4171c..ea572b4ce3c4e 100644 --- a/Mathlib/Analysis/SpecialFunctions/Gaussian/FourierTransform.lean +++ b/Mathlib/Analysis/SpecialFunctions/Gaussian/FourierTransform.lean @@ -41,7 +41,7 @@ namespace GaussianFourier variable {b : ℂ} /-- The integral of the Gaussian function over the vertical edges of a rectangle -with vertices at `(±T, 0)` and `(±T, c)`. -/ +with vertices at `(±T, 0)` and `(±T, c)`. -/ def verticalIntegral (b : ℂ) (c T : ℝ) : ℂ := ∫ y : ℝ in (0 : ℝ)..c, I * (cexp (-b * (T + y * I) ^ 2) - cexp (-b * (T - y * I) ^ 2)) diff --git a/Mathlib/Analysis/SpecialFunctions/Pow/Real.lean b/Mathlib/Analysis/SpecialFunctions/Pow/Real.lean index c037a96c86a69..6a7ea43f88beb 100644 --- a/Mathlib/Analysis/SpecialFunctions/Pow/Real.lean +++ b/Mathlib/Analysis/SpecialFunctions/Pow/Real.lean @@ -775,7 +775,7 @@ lemma zpow_le_of_le_log {n : ℤ} (hy : 0 < y) (h : log x ≤ n * log y) : x ≤ lemma rpow_lt_iff_lt_log (hx : 0 < x) (hy : 0 < y) : x ^ z < y ↔ z * log x < log y := by rw [← log_lt_log_iff (rpow_pos_of_pos hx _) hy, log_rpow hx] -lemma pow_lt_iff_lt_log (hx : 0 < x) (hy : 0 < y) : x ^ n < y ↔ n * log x < log y := by +lemma pow_lt_iff_lt_log (hx : 0 < x) (hy : 0 < y) : x ^ n < y ↔ n * log x < log y := by rw [← rpow_lt_iff_lt_log hx hy, rpow_natCast] lemma zpow_lt_iff_lt_log {n : ℤ} (hx : 0 < x) (hy : 0 < y) : x ^ n < y ↔ n * log x < log y := by diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Bounds.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Bounds.lean index c270fdc3cf837..e0595d589e11d 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Bounds.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Bounds.lean @@ -1,8 +1,9 @@ /- Copyright (c) 2022 David Loeffler. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. -Authors: David Loeffler, Yaël Dillies +Authors: David Loeffler, Yaël Dillies, Bhavik Mehta -/ +import Mathlib.Analysis.Convex.SpecificFunctions.Deriv import Mathlib.Analysis.SpecialFunctions.Trigonometric.ArctanDeriv /-! @@ -54,81 +55,94 @@ lemma sin_le (hx : 0 ≤ x) : sin x ≤ x := by lemma lt_sin (hx : x < 0) : x < sin x := by simpa using sin_lt <| neg_pos.2 hx lemma le_sin (hx : x ≤ 0) : x ≤ sin x := by simpa using sin_le <| neg_nonneg.2 hx -lemma one_sub_sq_div_two_le_cos : 1 - x ^ 2 / 2 ≤ cos x := by +theorem lt_sin_mul {x : ℝ} (hx : 0 < x) (hx' : x < 1) : x < sin (π / 2 * x) := by + simpa [mul_comm x] using + strictConcaveOn_sin_Icc.2 ⟨le_rfl, pi_pos.le⟩ ⟨pi_div_two_pos.le, half_le_self pi_pos.le⟩ + pi_div_two_pos.ne (sub_pos.2 hx') hx + +theorem le_sin_mul {x : ℝ} (hx : 0 ≤ x) (hx' : x ≤ 1) : x ≤ sin (π / 2 * x) := by + simpa [mul_comm x] using + strictConcaveOn_sin_Icc.concaveOn.2 ⟨le_rfl, pi_pos.le⟩ + ⟨pi_div_two_pos.le, half_le_self pi_pos.le⟩ (sub_nonneg.2 hx') hx + +theorem mul_lt_sin {x : ℝ} (hx : 0 < x) (hx' : x < π / 2) : 2 / π * x < sin x := by + rw [← inv_div] + simpa [-inv_div, mul_inv_cancel_left₀ pi_div_two_pos.ne'] using @lt_sin_mul ((π / 2)⁻¹ * x) + (mul_pos (inv_pos.2 pi_div_two_pos) hx) (by rwa [← div_eq_inv_mul, div_lt_one pi_div_two_pos]) + +/-- One half of **Jordan's inequality**. + +In the range `[0, π / 2]`, we have a linear lower bound on `sin`. The other half is given by +`Real.sin_le`. +-/ +theorem mul_le_sin {x : ℝ} (hx : 0 ≤ x) (hx' : x ≤ π / 2) : 2 / π * x ≤ sin x := by + rw [← inv_div] + simpa [-inv_div, mul_inv_cancel_left₀ pi_div_two_pos.ne'] using @le_sin_mul ((π / 2)⁻¹ * x) + (mul_nonneg (inv_nonneg.2 pi_div_two_pos.le) hx) + (by rwa [← div_eq_inv_mul, div_le_one pi_div_two_pos]) + +/-- Half of **Jordan's inequality** for negative values. -/ +lemma sin_le_mul (hx : -(π / 2) ≤ x) (hx₀ : x ≤ 0) : sin x ≤ 2 / π * x := by + simpa using mul_le_sin (neg_nonneg.2 hx₀) (neg_le.2 hx) + +/-- Half of **Jordan's inequality** for absolute values. -/ +lemma mul_abs_le_abs_sin (hx : |x| ≤ π / 2) : 2 / π * |x| ≤ |sin x| := by wlog hx₀ : 0 ≤ x - · simpa using this <| neg_nonneg.2 <| le_of_not_le hx₀ - suffices MonotoneOn (fun x ↦ cos x + x ^ 2 / 2) (Ici 0) by - simpa using this left_mem_Ici hx₀ hx₀ - refine monotoneOn_of_hasDerivWithinAt_nonneg - (convex_Ici _) (by fun_prop) - (fun x _ ↦ ((hasDerivAt_cos ..).add <| (hasDerivAt_pow ..).div_const _).hasDerivWithinAt) - fun x hx ↦ ?_ - simpa [mul_div_cancel_left₀] using sin_le <| interior_subset hx - -/-- **Jordan's inequality**. -/ -lemma two_div_pi_mul_le_sin (hx₀ : 0 ≤ x) (hx : x ≤ π / 2) : 2 / π * x ≤ sin x := by - rw [← sub_nonneg] - suffices ConcaveOn ℝ (Icc 0 (π / 2)) (fun x ↦ sin x - 2 / π * x) by - refine (le_min ?_ ?_).trans <| this.min_le_of_mem_Icc (by simp [Real.pi_nonneg, div_nonneg]) - (by simp [Real.pi_nonneg, div_nonneg]) ⟨hx₀, hx⟩ <;> field_simp - exact concaveOn_of_hasDerivWithinAt2_nonpos (convex_Icc ..) - (Continuous.continuousOn <| by fun_prop) - (fun x _ ↦ ((hasDerivAt_sin ..).sub <| (hasDerivAt_id ..).const_mul (2 / π)).hasDerivWithinAt) - (fun x _ ↦ (hasDerivAt_cos ..).hasDerivWithinAt.sub_const _) - fun x hx ↦ neg_nonpos.2 <| sin_nonneg_of_mem_Icc <| Icc_subset_Icc_right (by linarith) <| - interior_subset hx - -/-- **Jordan's inequality** for negative values. -/ -lemma sin_le_two_div_pi_mul (hx : -(π / 2) ≤ x) (hx₀ : x ≤ 0) : sin x ≤ 2 / π * x := by - simpa using two_div_pi_mul_le_sin (neg_nonneg.2 hx₀) (neg_le.2 hx) - -/-- **Jordan's inequality** for `cos`. -/ -lemma one_sub_two_div_pi_mul_le_cos (hx₀ : 0 ≤ x) (hx : x ≤ π / 2) : 1 - 2 / π * x ≤ cos x := by + case inr => simpa using this (by rwa [abs_neg]) <| neg_nonneg.2 <| le_of_not_le hx₀ + rw [abs_of_nonneg hx₀] at hx ⊢ + exact (mul_le_sin hx₀ hx).trans (le_abs_self _) + +lemma sin_sq_lt_sq (hx : x ≠ 0) : sin x ^ 2 < x ^ 2 := by + wlog hx₀ : 0 < x + case inr => + simpa using this (neg_ne_zero.2 hx) <| neg_pos_of_neg <| hx.lt_of_le <| le_of_not_lt hx₀ + rcases le_or_lt x 1 with hxπ | hxπ + case inl => + exact pow_lt_pow_left (sin_lt hx₀) + (sin_nonneg_of_nonneg_of_le_pi hx₀.le (by linarith [two_le_pi])) (by simp) + case inr => + exact (sin_sq_le_one _).trans_lt (by rwa [one_lt_sq_iff hx₀.le]) + +lemma sin_sq_le_sq : sin x ^ 2 ≤ x ^ 2 := by + rcases eq_or_ne x 0 with rfl | hx + case inl => simp + case inr => exact (sin_sq_lt_sq hx).le + +lemma abs_sin_lt_abs (hx : x ≠ 0) : |sin x| < |x| := sq_lt_sq.1 (sin_sq_lt_sq hx) +lemma abs_sin_le_abs : |sin x| ≤ |x| := sq_le_sq.1 sin_sq_le_sq + +lemma one_sub_sq_div_two_lt_cos (hx : x ≠ 0) : 1 - x ^ 2 / 2 < cos x := by + have := (sin_sq_lt_sq (by positivity)).trans_eq' (sin_sq_eq_half_sub (x / 2)).symm + ring_nf at this + linarith + +lemma one_sub_sq_div_two_le_cos : 1 - x ^ 2 / 2 ≤ cos x := by + rcases eq_or_ne x 0 with rfl | hx + case inl => simp + case inr => exact (one_sub_sq_div_two_lt_cos hx).le + +/-- Half of **Jordan's inequality** for `cos`. -/ +lemma one_sub_mul_le_cos (hx₀ : 0 ≤ x) (hx : x ≤ π / 2) : 1 - 2 / π * x ≤ cos x := by simpa [sin_pi_div_two_sub, mul_sub, div_mul_div_comm, mul_comm π, pi_pos.ne'] - using two_div_pi_mul_le_sin (x := π / 2 - x) (by simpa) (by simpa) + using mul_le_sin (x := π / 2 - x) (by simpa) (by simpa) + +/-- Half of **Jordan's inequality** for `cos` and negative values. -/ +lemma one_add_mul_le_cos (hx₀ : -(π / 2) ≤ x) (hx : x ≤ 0) : 1 + 2 / π * x ≤ cos x := by + simpa using one_sub_mul_le_cos (x := -x) (by linarith) (by linarith) -lemma cos_quadratic_upper_bound (hx : |x| ≤ π) : cos x ≤ 1 - 2 / π ^ 2 * x ^ 2 := by +lemma cos_le_one_sub_mul_cos_sq (hx : |x| ≤ π) : cos x ≤ 1 - 2 / π ^ 2 * x ^ 2 := by wlog hx₀ : 0 ≤ x - · simpa using this (by rwa [abs_neg]) <| neg_nonneg.2 <| le_of_not_le hx₀ + case inr => simpa using this (by rwa [abs_neg]) <| neg_nonneg.2 <| le_of_not_le hx₀ rw [abs_of_nonneg hx₀] at hx - -- TODO: `compute_deriv` tactic? - have hderiv (x) : HasDerivAt (fun x ↦ 1 - 2 / π ^ 2 * x ^ 2 - cos x) _ x := - (((hasDerivAt_pow ..).const_mul _).const_sub _).sub <| hasDerivAt_cos _ - simp only [Nat.cast_ofNat, Nat.succ_sub_succ_eq_sub, tsub_zero, pow_one, ← neg_sub', neg_sub, - ← mul_assoc] at hderiv - have hmono : MonotoneOn (fun x ↦ 1 - 2 / π ^ 2 * x ^ 2 - cos x) (Icc 0 (π / 2)) := by - -- Compiles without this option, but somewhat slower. - set_option tactic.skipAssignedInstances false in - refine monotoneOn_of_hasDerivWithinAt_nonneg - (convex_Icc ..) - (Continuous.continuousOn <| by fun_prop) - (fun x _ ↦ (hderiv _).hasDerivWithinAt) - fun x hx ↦ sub_nonneg.2 ?_ - have ⟨hx₀, hx⟩ := interior_subset hx - calc 2 / π ^ 2 * 2 * x - = 2 / π * (2 / π * x) := by ring - _ ≤ 1 * sin x := by - gcongr; exacts [div_le_one_of_le two_le_pi (by positivity), two_div_pi_mul_le_sin hx₀ hx] - _ = sin x := one_mul _ - have hconc : ConcaveOn ℝ (Icc (π / 2) π) (fun x ↦ 1 - 2 / π ^ 2 * x ^ 2 - cos x) := by - -- Compiles without this option, but somewhat slower. - set_option tactic.skipAssignedInstances false in - refine concaveOn_of_hasDerivWithinAt2_nonpos (convex_Icc ..) - (Continuous.continuousOn <| by fun_prop) (fun x _ ↦ (hderiv _).hasDerivWithinAt) - (fun x _ ↦ ((hasDerivAt_sin ..).sub <| (hasDerivAt_id ..).const_mul _).hasDerivWithinAt) - fun x hx ↦ ?_ - have ⟨hx, hx'⟩ := interior_subset hx - calc - _ ≤ (0 : ℝ) - 0 := by - gcongr - · exact cos_nonpos_of_pi_div_two_le_of_le hx <| hx'.trans <| by linarith - · positivity - _ = 0 := sub_zero _ - rw [← sub_nonneg] - obtain hx' | hx' := le_total x (π / 2) - · simpa using hmono (left_mem_Icc.2 <| by positivity) ⟨hx₀, hx'⟩ hx₀ - · refine (le_min ?_ ?_).trans <| hconc.min_le_of_mem_Icc (by simp [Real.pi_nonneg]) - (by simp [Real.pi_nonneg]) ⟨hx', hx⟩ <;> field_simp <;> norm_num + have : x / π ≤ sin (x / 2) := by simpa using mul_le_sin (x := x / 2) (by positivity) (by linarith) + have := (pow_le_pow_left (by positivity) this 2).trans_eq (sin_sq_eq_half_sub _) + ring_nf at this ⊢ + linarith + +@[deprecated (since := "2024-08-29")] alias two_div_pi_mul_le_sin := mul_le_sin +@[deprecated (since := "2024-08-29")] alias sin_le_two_div_pi_mul := sin_le_mul +@[deprecated (since := "2024-08-29")] alias one_sub_two_div_pi_mul_le_cos := one_sub_mul_le_cos +@[deprecated (since := "2024-08-29")] alias cos_quadratic_upper_bound := cos_le_one_sub_mul_cos_sq /-- For 0 < x ≤ 1 we have x - x ^ 3 / 4 < sin x. diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Complex.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Complex.lean index 32502108c05af..ece140bac4b05 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Complex.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Complex.lean @@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson -/ import Mathlib.Algebra.QuadraticDiscriminant -import Mathlib.Analysis.Convex.SpecificFunctions.Deriv import Mathlib.Analysis.SpecialFunctions.Pow.Complex /-! @@ -59,7 +58,7 @@ theorem sin_ne_zero_iff {θ : ℂ} : sin θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ k * π iff this number is equal to `k * π / 2` for an integer `k`. Note that this lemma takes into account that we use zero as the junk value for division by zero. -See also `Complex.tan_eq_zero_iff'`. -/ +See also `Complex.tan_eq_zero_iff'`. -/ theorem tan_eq_zero_iff {θ : ℂ} : tan θ = 0 ↔ ∃ k : ℤ, k * π / 2 = θ := by rw [tan, div_eq_zero_iff, ← mul_eq_zero, ← mul_right_inj' two_ne_zero, mul_zero, ← mul_assoc, ← sin_two_mul, sin_eq_zero_iff] @@ -236,27 +235,4 @@ theorem tan_eq_zero_iff' {θ : ℝ} (hθ : cos θ ≠ 0) : tan θ = 0 ↔ ∃ k theorem tan_ne_zero_iff {θ : ℝ} : tan θ ≠ 0 ↔ ∀ k : ℤ, k * π / 2 ≠ θ := mod_cast @Complex.tan_ne_zero_iff θ -theorem lt_sin_mul {x : ℝ} (hx : 0 < x) (hx' : x < 1) : x < sin (π / 2 * x) := by - simpa [mul_comm x] using - strictConcaveOn_sin_Icc.2 ⟨le_rfl, pi_pos.le⟩ ⟨pi_div_two_pos.le, half_le_self pi_pos.le⟩ - pi_div_two_pos.ne (sub_pos.2 hx') hx - -theorem le_sin_mul {x : ℝ} (hx : 0 ≤ x) (hx' : x ≤ 1) : x ≤ sin (π / 2 * x) := by - simpa [mul_comm x] using - strictConcaveOn_sin_Icc.concaveOn.2 ⟨le_rfl, pi_pos.le⟩ - ⟨pi_div_two_pos.le, half_le_self pi_pos.le⟩ (sub_nonneg.2 hx') hx - -theorem mul_lt_sin {x : ℝ} (hx : 0 < x) (hx' : x < π / 2) : 2 / π * x < sin x := by - rw [← inv_div] - simpa [-inv_div, mul_inv_cancel_left₀ pi_div_two_pos.ne'] using @lt_sin_mul ((π / 2)⁻¹ * x) - (mul_pos (inv_pos.2 pi_div_two_pos) hx) (by rwa [← div_eq_inv_mul, div_lt_one pi_div_two_pos]) - -/-- In the range `[0, π / 2]`, we have a linear lower bound on `sin`. This inequality forms one half -of Jordan's inequality, the other half is `Real.sin_lt` -/ -theorem mul_le_sin {x : ℝ} (hx : 0 ≤ x) (hx' : x ≤ π / 2) : 2 / π * x ≤ sin x := by - rw [← inv_div] - simpa [-inv_div, mul_inv_cancel_left₀ pi_div_two_pos.ne'] using @le_sin_mul ((π / 2)⁻¹ * x) - (mul_nonneg (inv_nonneg.2 pi_div_two_pos.le) hx) - (by rwa [← div_eq_inv_mul, div_le_one pi_div_two_pos]) - end Real diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/ComplexDeriv.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/ComplexDeriv.lean index 6d74a3ace85b2..e414b1421381a 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/ComplexDeriv.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/ComplexDeriv.lean @@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson -/ import Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex +import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv /-! # Complex trigonometric functions diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/EulerSineProd.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/EulerSineProd.lean index 7b8d099c1e98a..fc6711228b07f 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/EulerSineProd.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/EulerSineProd.lean @@ -141,7 +141,7 @@ theorem integral_sin_mul_sin_mul_cos_pow_eq (hn : 2 ≤ n) (hz : z ≠ 0) : · apply Continuous.intervalIntegrable exact Complex.continuous_sin.comp (continuous_const.mul Complex.continuous_ofReal) -/-- Note this also holds for `z = 0`, but we do not need this case for `sin_pi_mul_eq`. -/ +/-- Note this also holds for `z = 0`, but we do not need this case for `sin_pi_mul_eq`. -/ theorem integral_cos_mul_cos_pow (hn : 2 ≤ n) (hz : z ≠ 0) : (((1 : ℂ) - (4 : ℂ) * z ^ 2 / (n : ℂ) ^ 2) * ∫ x in (0 : ℝ)..π / 2, Complex.cos (2 * z * x) * (cos x : ℂ) ^ n) = diff --git a/Mathlib/Analysis/SpecificLimits/Basic.lean b/Mathlib/Analysis/SpecificLimits/Basic.lean index 647d3cef3d49b..5b3478e93056c 100644 --- a/Mathlib/Analysis/SpecificLimits/Basic.lean +++ b/Mathlib/Analysis/SpecificLimits/Basic.lean @@ -258,7 +258,7 @@ protected theorem ENNReal.tendsto_pow_atTop_nhds_top_iff {r : ℝ≥0∞} : simp only [ENNReal.tendsto_pow_atTop_nhds_zero_iff, inv_zero] at obs simpa [← ENNReal.inv_pow] using obs <| ENNReal.inv_lt_one.mpr r_gt_one -/-! ### Geometric series-/ +/-! ### Geometric series -/ section Geometric diff --git a/Mathlib/Analysis/SpecificLimits/Normed.lean b/Mathlib/Analysis/SpecificLimits/Normed.lean index 1e0cb4ba7e313..c46af42ab84e6 100644 --- a/Mathlib/Analysis/SpecificLimits/Normed.lean +++ b/Mathlib/Analysis/SpecificLimits/Normed.lean @@ -5,11 +5,15 @@ Authors: Anatole Dedecker, Sébastien Gouëzel, Yury Kudryashov, Dylan MacKenzie -/ import Mathlib.Algebra.BigOperators.Module import Mathlib.Algebra.Order.Field.Basic -import Mathlib.Order.Filter.ModEq import Mathlib.Analysis.Asymptotics.Asymptotics +import Mathlib.Analysis.Normed.Field.InfiniteSum +import Mathlib.Analysis.Normed.Module.Basic import Mathlib.Analysis.SpecificLimits.Basic import Mathlib.Data.List.TFAE -import Mathlib.Analysis.Normed.Module.Basic +import Mathlib.Data.Nat.Choose.Bounds +import Mathlib.Order.Filter.ModEq +import Mathlib.RingTheory.Polynomial.Pochhammer +import Mathlib.Tactic.NoncommRing /-! # A collection of specific limit computations @@ -258,7 +262,7 @@ theorem tendsto_pow_atTop_nhds_zero_of_abs_lt_one {r : ℝ} (h : |r| < 1) : @[deprecated (since := "2024-01-31")] alias tendsto_pow_atTop_nhds_0_of_abs_lt_1 := tendsto_pow_atTop_nhds_zero_of_abs_lt_one -/-! ### Geometric series-/ +/-! ### Geometric series -/ section Geometric @@ -327,54 +331,144 @@ end Geometric section MulGeometric +theorem summable_norm_mul_geometric_of_norm_lt_one {R : Type*} [NormedRing R] {k : ℕ} {r : R} + (hr : ‖r‖ < 1) {u : ℕ → ℕ} (hu : (fun n ↦ (u n : ℝ)) =O[atTop] (fun n ↦ (↑(n ^ k) : ℝ))) : + Summable fun n : ℕ ↦ ‖(u n * r ^ n : R)‖ := by + rcases exists_between hr with ⟨r', hrr', h⟩ + rw [← norm_norm] at hrr' + apply summable_of_isBigO_nat (summable_geometric_of_lt_one ((norm_nonneg _).trans hrr'.le) h) + calc + fun n ↦ ‖↑(u n) * r ^ n‖ + _ =O[atTop] fun n ↦ u n * ‖r‖ ^ n := by + apply (IsBigOWith.of_bound (c := ‖(1 : R)‖) ?_).isBigO + filter_upwards [eventually_norm_pow_le r] with n hn + simp only [norm_norm, norm_mul, Real.norm_eq_abs, abs_cast, norm_pow, abs_norm] + apply (norm_mul_le _ _).trans + have : ‖(u n : R)‖ * ‖r ^ n‖ ≤ (u n * ‖(1 : R)‖) * ‖r‖ ^ n := by + gcongr; exact norm_cast_le (u n) + exact this.trans_eq (by ring) + _ =O[atTop] fun n ↦ ↑(n ^ k) * ‖r‖ ^ n := hu.mul (isBigO_refl _ _) + _ =O[atTop] fun n ↦ r' ^ n := by + simp only [cast_pow] + exact (isLittleO_pow_const_mul_const_pow_const_pow_of_norm_lt k hrr').isBigO + theorem summable_norm_pow_mul_geometric_of_norm_lt_one {R : Type*} [NormedRing R] (k : ℕ) {r : R} (hr : ‖r‖ < 1) : Summable fun n : ℕ ↦ ‖((n : R) ^ k * r ^ n : R)‖ := by - rcases exists_between hr with ⟨r', hrr', h⟩ - exact summable_of_isBigO_nat (summable_geometric_of_lt_one ((norm_nonneg _).trans hrr'.le) h) - (isLittleO_pow_const_mul_const_pow_const_pow_of_norm_lt _ hrr').isBigO.norm_left + simp only [← cast_pow] + exact summable_norm_mul_geometric_of_norm_lt_one (k := k) (u := fun n ↦ n ^ k) hr + (isBigO_refl _ _) + +theorem summable_norm_geometric_of_norm_lt_one {R : Type*} [NormedRing R] {r : R} + (hr : ‖r‖ < 1) : Summable fun n : ℕ ↦ ‖(r ^ n : R)‖ := by + simpa using summable_norm_pow_mul_geometric_of_norm_lt_one 0 hr @[deprecated (since := "2024-01-31")] alias summable_norm_pow_mul_geometric_of_norm_lt_1 := summable_norm_pow_mul_geometric_of_norm_lt_one -theorem summable_pow_mul_geometric_of_norm_lt_one {R : Type*} [NormedRing R] [CompleteSpace R] - (k : ℕ) {r : R} (hr : ‖r‖ < 1) : Summable (fun n ↦ (n : R) ^ k * r ^ n : ℕ → R) := - .of_norm <| summable_norm_pow_mul_geometric_of_norm_lt_one _ hr +variable {𝕜 : Type*} [NormedDivisionRing 𝕜] + +/-- The sum of `(n+k).choose k * r^n` is `1/(1-r)^{k+1}`. +See also `PowerSeries.invOneSubPow_val_eq_mk_choose_add` for the corresponding statement in formal +power series, without summability arguments. -/ +lemma hasSum_choose_mul_geometric_of_norm_lt_one + (k : ℕ) {r : 𝕜} (hr : ‖r‖ < 1) : + HasSum (fun n ↦ (n + k).choose k * r ^ n) (1 / (1 - r) ^ (k + 1)) := by + induction k with + | zero => simpa using hasSum_geometric_of_norm_lt_one hr + | succ k ih => + have I1 : Summable (fun (n : ℕ) ↦ ‖(n + k).choose k * r ^ n‖) := by + apply summable_norm_mul_geometric_of_norm_lt_one (k := k) hr + apply isBigO_iff.2 ⟨2 ^ k, ?_⟩ + filter_upwards [Ioi_mem_atTop k] with n (hn : k < n) + simp only [Real.norm_eq_abs, abs_cast, cast_pow, norm_pow] + norm_cast + calc (n + k).choose k + _ ≤ (2 * n).choose k := choose_le_choose k (by omega) + _ ≤ (2 * n) ^ k := Nat.choose_le_pow _ _ + _ = 2 ^ k * n ^ k := Nat.mul_pow 2 n k + convert hasSum_sum_range_mul_of_summable_norm' I1 ih.summable + (summable_norm_geometric_of_norm_lt_one hr) (summable_geometric_of_norm_lt_one hr) using 1 + · ext n + have : ∑ i ∈ Finset.range (n + 1), ↑((i + k).choose k) * r ^ i * r ^ (n - i) = + ∑ i ∈ Finset.range (n + 1), ↑((i + k).choose k) * r ^ n := by + apply Finset.sum_congr rfl (fun i hi ↦ ?_) + simp only [Finset.mem_range] at hi + rw [mul_assoc, ← pow_add, show i + (n - i) = n by omega] + simp_rw [this, ← sum_mul, ← Nat.cast_sum, sum_range_add_choose n k, add_assoc] + · rw [ih.tsum_eq, (hasSum_geometric_of_norm_lt_one hr).tsum_eq, pow_succ] + simp only [one_div, ← mul_inv_rev, ← pow_succ, ← _root_.pow_succ'] + +lemma summable_choose_mul_geometric_of_norm_lt_one (k : ℕ) {r : 𝕜} (hr : ‖r‖ < 1) : + Summable (fun n ↦ (n + k).choose k * r ^ n) := + (hasSum_choose_mul_geometric_of_norm_lt_one k hr).summable + +lemma tsum_choose_mul_geometric_of_norm_lt_one (k : ℕ) {r : 𝕜} (hr : ‖r‖ < 1) : + ∑' n, (n + k).choose k * r ^ n = 1 / (1 - r) ^ (k + 1) := + (hasSum_choose_mul_geometric_of_norm_lt_one k hr).tsum_eq + +lemma summable_descFactorial_mul_geometric_of_norm_lt_one (k : ℕ) {r : 𝕜} (hr : ‖r‖ < 1) : + Summable (fun n ↦ (n + k).descFactorial k * r ^ n) := by + convert (summable_choose_mul_geometric_of_norm_lt_one k hr).mul_left (k.factorial : 𝕜) + using 2 with n + simp [← mul_assoc, descFactorial_eq_factorial_mul_choose (n + k) k] + +open Polynomial in +theorem summable_pow_mul_geometric_of_norm_lt_one (k : ℕ) {r : 𝕜} (hr : ‖r‖ < 1) : + Summable (fun n ↦ (n : 𝕜) ^ k * r ^ n : ℕ → 𝕜) := by + refine Nat.strong_induction_on k fun k hk => ?_ + obtain ⟨a, ha⟩ : ∃ (a : ℕ → ℕ), ∀ n, (n + k).descFactorial k + = n ^ k + ∑ i ∈ range k, a i * n ^ i := by + let P : Polynomial ℕ := (ascPochhammer ℕ k).comp (Polynomial.X + C 1) + refine ⟨fun i ↦ P.coeff i, fun n ↦ ?_⟩ + have mP : Monic P := Monic.comp_X_add_C (monic_ascPochhammer ℕ k) _ + have dP : P.natDegree = k := by + simp only [P, natDegree_comp, ascPochhammer_natDegree, mul_one, natDegree_X_add_C] + have A : (n + k).descFactorial k = P.eval n := by + have : n + 1 + k - 1 = n + k := by omega + simp [P, ascPochhammer_nat_eq_descFactorial, this] + conv_lhs => rw [A, mP.as_sum, dP] + simp [eval_finset_sum] + have : Summable (fun n ↦ (n + k).descFactorial k * r ^ n + - ∑ i ∈ range k, a i * n ^ (i : ℕ) * r ^ n) := by + apply (summable_descFactorial_mul_geometric_of_norm_lt_one k hr).sub + apply summable_sum (fun i hi ↦ ?_) + simp_rw [mul_assoc] + simp only [Finset.mem_range] at hi + exact (hk _ hi).mul_left _ + convert this using 1 + ext n + simp [ha n, add_mul, sum_mul] @[deprecated (since := "2024-01-31")] alias summable_pow_mul_geometric_of_norm_lt_1 := summable_pow_mul_geometric_of_norm_lt_one /-- If `‖r‖ < 1`, then `∑' n : ℕ, n * r ^ n = r / (1 - r) ^ 2`, `HasSum` version. -/ -theorem hasSum_coe_mul_geometric_of_norm_lt_one {𝕜 : Type*} [NormedDivisionRing 𝕜] [CompleteSpace 𝕜] +theorem hasSum_coe_mul_geometric_of_norm_lt_one {r : 𝕜} (hr : ‖r‖ < 1) : HasSum (fun n ↦ n * r ^ n : ℕ → 𝕜) (r / (1 - r) ^ 2) := by - have A : Summable (fun n ↦ (n : 𝕜) * r ^ n : ℕ → 𝕜) := by - simpa only [pow_one] using summable_pow_mul_geometric_of_norm_lt_one 1 hr - have B : HasSum (r ^ · : ℕ → 𝕜) (1 - r)⁻¹ := hasSum_geometric_of_norm_lt_one hr - refine A.hasSum_iff.2 ?_ - have hr' : r ≠ 1 := by - rintro rfl - simp [lt_irrefl] at hr - set s : 𝕜 := ∑' n : ℕ, n * r ^ n - have : Commute (1 - r) s := - .tsum_right _ fun _ => - .sub_left (.one_left _) (.mul_right (Nat.commute_cast _ _) (.pow_right (.refl _) _)) - calc - s = s * (1 - r) / (1 - r) := (mul_div_cancel_right₀ _ (sub_ne_zero.2 hr'.symm)).symm - _ = (1 - r) * s / (1 - r) := by rw [this.eq] - _ = (s - r * s) / (1 - r) := by rw [_root_.sub_mul, one_mul] - _ = (((0 : ℕ) * r ^ 0 + ∑' n : ℕ, (n + 1 : ℕ) * r ^ (n + 1)) - r * s) / (1 - r) := by - rw [← tsum_eq_zero_add A] - _ = ((r * ∑' n : ℕ, ↑(n + 1) * r ^ n) - r * s) / (1 - r) := by - simp only [cast_zero, pow_zero, mul_one, _root_.pow_succ', (Nat.cast_commute _ r).left_comm, - _root_.tsum_mul_left, zero_add] + have A : HasSum (fun (n : ℕ) ↦ (n + 1) * r ^ n) (1 / (1 - r) ^ 2) := by + convert hasSum_choose_mul_geometric_of_norm_lt_one 1 hr with n + simp + have B : HasSum (fun (n : ℕ) ↦ r ^ n) ((1 - r) ⁻¹) := hasSum_geometric_of_norm_lt_one hr + convert A.sub B using 1 + · ext n + simp [add_mul] + · symm + calc 1 / (1 - r) ^ 2 - (1 - r) ⁻¹ + _ = 1 / (1 - r) ^ 2 - ((1 - r) * (1 - r) ⁻¹) * (1 - r) ⁻¹ := by + rw [mul_inv_cancel₀, one_mul] + intro h + simp only [sub_eq_zero] at h + simp [← h] at hr _ = r / (1 - r) ^ 2 := by - simp [add_mul, tsum_add A B.summable, mul_add, B.tsum_eq, ← div_eq_mul_inv, sq, - div_mul_eq_div_div_swap] + simp only [one_div, mul_assoc, ← mul_inv_rev] + rw [inv_eq_one_div, inv_eq_one_div, ← pow_two, _root_.sub_mul, one_mul, mul_div, mul_one] + abel @[deprecated (since := "2024-01-31")] alias hasSum_coe_mul_geometric_of_norm_lt_1 := hasSum_coe_mul_geometric_of_norm_lt_one /-- If `‖r‖ < 1`, then `∑' n : ℕ, n * r ^ n = r / (1 - r) ^ 2`. -/ -theorem tsum_coe_mul_geometric_of_norm_lt_one {𝕜 : Type*} [NormedDivisionRing 𝕜] [CompleteSpace 𝕜] +theorem tsum_coe_mul_geometric_of_norm_lt_one {r : 𝕜} (hr : ‖r‖ < 1) : (∑' n : ℕ, n * r ^ n : 𝕜) = r / (1 - r) ^ 2 := (hasSum_coe_mul_geometric_of_norm_lt_one hr).tsum_eq diff --git a/Mathlib/Analysis/SumOverResidueClass.lean b/Mathlib/Analysis/SumOverResidueClass.lean index 92432ccab72a0..cf56394e76ad9 100644 --- a/Mathlib/Analysis/SumOverResidueClass.lean +++ b/Mathlib/Analysis/SumOverResidueClass.lean @@ -92,3 +92,14 @@ lemma summable_indicator_mod_iff {m : ℕ} [NeZero m] {f : ℕ → ℝ} (hf : An convert summable_sum (s := Finset.univ) fun a _ ↦ summable_indicator_mod_iff_summable_indicator_mod hf a H simp only [Finset.sum_apply] + +open ZMod + +/-- If `f` is a summable function on `ℕ`, and `0 < N`, then we may compute `∑' n : ℕ, f n` by +summing each residue class mod `N` separately. -/ +lemma Nat.sumByResidueClasses {R : Type*} [AddCommGroup R] [UniformSpace R] [UniformAddGroup R] + [CompleteSpace R] [T0Space R] {f : ℕ → R} (hf : Summable f) (N : ℕ) [NeZero N] : + ∑' n, f n = ∑ j : ZMod N, ∑' m, f (j.val + N * m) := by + rw [← (residueClassesEquiv N).symm.tsum_eq f, tsum_prod, tsum_fintype, residueClassesEquiv, + Equiv.coe_fn_symm_mk] + exact hf.comp_injective (residueClassesEquiv N).symm.injective diff --git a/Mathlib/CategoryTheory/Abelian/Exact.lean b/Mathlib/CategoryTheory/Abelian/Exact.lean index cfc118215dd0f..85352b81dbb61 100644 --- a/Mathlib/CategoryTheory/Abelian/Exact.lean +++ b/Mathlib/CategoryTheory/Abelian/Exact.lean @@ -240,14 +240,14 @@ theorem preservesMonomorphisms_of_map_exact : L.PreservesMonomorphisms where preserves f hf := by apply ((Abelian.tfae_mono (L.map f) (L.obj 0)).out 2 0).mp refine ShortComplex.exact_of_iso ?_ (hL _ (((tfae_mono f 0).out 0 2).mp hf)) - exact ShortComplex.isoMk (Iso.refl _) (Iso.refl _) (Iso.refl _) + exact ShortComplex.isoMk (Iso.refl _) (Iso.refl _) (Iso.refl _) /-- A functor which preserves exactness preserves epimorphisms. -/ theorem preservesEpimorphisms_of_map_exact : L.PreservesEpimorphisms where preserves f hf := by apply ((Abelian.tfae_epi (L.map f) (L.obj 0)).out 2 0).mp refine ShortComplex.exact_of_iso ?_ (hL _ (((tfae_epi f 0).out 0 2).mp hf)) - exact ShortComplex.isoMk (Iso.refl _) (Iso.refl _) (Iso.refl _) + exact ShortComplex.isoMk (Iso.refl _) (Iso.refl _) (Iso.refl _) /-- A functor which preserves the exactness of short complexes preserves homology. -/ def preservesHomologyOfMapExact : L.PreservesHomology where diff --git a/Mathlib/CategoryTheory/Abelian/Transfer.lean b/Mathlib/CategoryTheory/Abelian/Transfer.lean index 1948ebfb7f9a6..9e05999b3184a 100644 --- a/Mathlib/CategoryTheory/Abelian/Transfer.lean +++ b/Mathlib/CategoryTheory/Abelian/Transfer.lean @@ -128,7 +128,7 @@ def coimageIsoImage (i : F ⋙ G ≅ 𝟭 C) (adj : G ⊣ F) {X Y : C} (f : X _ ≅ Abelian.image f := Iso.refl _ -- The account of this proof in the Stacks project omits this calculation. -theorem coimageIsoImage_hom (i : F ⋙ G ≅ 𝟭 C) (adj : G ⊣ F) {X Y : C} (f : X ⟶ Y) : +theorem coimageIsoImage_hom (i : F ⋙ G ≅ 𝟭 C) (adj : G ⊣ F) {X Y : C} (f : X ⟶ Y) : (coimageIsoImage F G i adj f).hom = Abelian.coimageImageComparison f := by dsimp [coimageIsoImage, cokernelIso, cokernelEpiComp, cokernelCompIsIso_inv, coimageIsoImageAux, kernelCompMono] diff --git a/Mathlib/CategoryTheory/Adjunction/AdjointFunctorTheorems.lean b/Mathlib/CategoryTheory/Adjunction/AdjointFunctorTheorems.lean index fdc950a181b49..3d5e083b0ab9b 100644 --- a/Mathlib/CategoryTheory/Adjunction/AdjointFunctorTheorems.lean +++ b/Mathlib/CategoryTheory/Adjunction/AdjointFunctorTheorems.lean @@ -62,7 +62,7 @@ section GeneralAdjointFunctorTheorem variable {D : Type u} [Category.{v} D] variable (G : D ⥤ C) -/-- If `G : D ⥤ C` is a right adjoint it satisfies the solution set condition. -/ +/-- If `G : D ⥤ C` is a right adjoint it satisfies the solution set condition. -/ theorem solutionSetCondition_of_isRightAdjoint [G.IsRightAdjoint] : SolutionSetCondition G := by intro A refine diff --git a/Mathlib/CategoryTheory/Adjunction/Opposites.lean b/Mathlib/CategoryTheory/Adjunction/Opposites.lean index ea57e651e6b63..b757cf23557da 100644 --- a/Mathlib/CategoryTheory/Adjunction/Opposites.lean +++ b/Mathlib/CategoryTheory/Adjunction/Opposites.lean @@ -71,12 +71,12 @@ def opAdjointOpOfAdjoint (F : C ⥤ D) (G : D ⥤ C) (h : G ⊣ F) : F.op ⊣ G. (opEquiv _ Y).trans ((h.homEquiv _ _).symm.trans (opEquiv X (Opposite.op _)).symm) homEquiv_naturality_left_symm := by -- Porting note: This proof was handled by `obviously` in mathlib3. The only obstruction to - -- automation fully kicking in here is that the `@[simps]` lemmas of `opEquiv` aren't firing. + -- automation fully kicking in here is that the `@[simps]` lemmas of `opEquiv` aren't firing. intros simp [opEquiv] homEquiv_naturality_right := by -- Porting note: This proof was handled by `obviously` in mathlib3. The only obstruction to - -- automation fully kicking in here is that the `@[simps]` lemmas of `opEquiv` aren't firing. + -- automation fully kicking in here is that the `@[simps]` lemmas of `opEquiv` aren't firing. intros simp [opEquiv] } diff --git a/Mathlib/CategoryTheory/Adjunction/Triple.lean b/Mathlib/CategoryTheory/Adjunction/Triple.lean new file mode 100644 index 0000000000000..d8b28fd060834 --- /dev/null +++ b/Mathlib/CategoryTheory/Adjunction/Triple.lean @@ -0,0 +1,55 @@ +/- +Copyright (c) 2024 Dagur Asgeirsson. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Dagur Asgeirsson +-/ +import Mathlib.CategoryTheory.Adjunction.Unique +import Mathlib.CategoryTheory.Monad.Adjunction +/-! + +# Adjoint triples + +This file concerns adjoint triples `F ⊣ G ⊣ H` of functors `F H : C ⥤ D`, `G : D ⥤ C`. + +Currently, the only result is that `F` is fully faithful if and only if `H` is fully faithful. +-/ + +namespace CategoryTheory.Adjunction + +variable {C D : Type*} [Category C] [Category D] +variable {F H : C ⥤ D} {G : D ⥤ C} +variable (adj₁ : F ⊣ G) (adj₂ : G ⊣ H) + +lemma isIso_unit_iff_isIso_counit : IsIso adj₁.unit ↔ IsIso adj₂.counit := by + let adj : F ⋙ G ⊣ H ⋙ G := adj₁.comp adj₂ + constructor + · intro h + let idAdj : 𝟭 C ⊣ H ⋙ G := adj.ofNatIsoLeft (asIso adj₁.unit).symm + exact adj₂.isIso_counit_of_iso (idAdj.rightAdjointUniq id) + · intro h + let adjId : F ⋙ G ⊣ 𝟭 C := adj.ofNatIsoRight (asIso adj₂.counit) + exact adj₁.isIso_unit_of_iso (adjId.leftAdjointUniq id) + +/-- +Given an adjoint triple `F ⊣ G ⊣ H`, the left adjoint `F` is fully faithful if and only if the +right adjoint `H` is fully faithful. +-/ +noncomputable def fullyFaithfulEquiv : F.FullyFaithful ≃ H.FullyFaithful where + toFun h := + haveI := h.full + haveI := h.faithful + haveI : IsIso adj₂.counit := by + rw [← adj₁.isIso_unit_iff_isIso_counit adj₂] + infer_instance + adj₂.fullyFaithfulROfIsIsoCounit + invFun h := + haveI := h.full + haveI := h.faithful + haveI : IsIso adj₁.unit := by + rw [adj₁.isIso_unit_iff_isIso_counit adj₂] + infer_instance + adj₁.fullyFaithfulLOfIsIsoUnit + left_inv _ := Subsingleton.elim _ _ + right_inv _ := Subsingleton.elim _ _ + +end CategoryTheory.Adjunction diff --git a/Mathlib/CategoryTheory/Adjunction/Unique.lean b/Mathlib/CategoryTheory/Adjunction/Unique.lean index 118731c61129b..e911b3e4dcb59 100644 --- a/Mathlib/CategoryTheory/Adjunction/Unique.lean +++ b/Mathlib/CategoryTheory/Adjunction/Unique.lean @@ -11,8 +11,8 @@ import Mathlib.CategoryTheory.Adjunction.Basic This file shows that adjoints are unique up to natural isomorphism. ## Main results -* `Adjunction.natTransEquiv` and `Adjunction.natIsoEquiv` If `F ⊣ G` and `F' ⊣ G'` are adjunctions, - then there are equivalences `(G ⟶ G') ≃ (F' ⟶ F)` and `(G ≅ G') ≃ (F' ≅ F)`. +* `Adjunction.natTransEquiv` and `Adjunction.natIsoEquiv` If `F ⊣ G` and `F' ⊣ G'` are adjunctions, + then there are equivalences `(G ⟶ G') ≃ (F' ⟶ F)` and `(G ≅ G') ≃ (F' ≅ F)`. Everything else is deduced from this: * `Adjunction.leftAdjointUniq` : If `F` and `F'` are both left adjoint to `G`, then they are @@ -23,7 +23,7 @@ Everything else is deduced from this: ## TODO -There some overlap with the file `Adjunction.Mates`. In particular, `natTransEquiv` is just a +There some overlap with the file `Adjunction.Mates`. In particular, `natTransEquiv` is just a special case of `mateEquiv`. However, before removing `natTransEquiv`, in favour of `mateEquiv`, the latter needs some more API lemmas such as `natTransEquiv_apply_app`, `natTransEquiv_id`, etc. in order to make automation work better in the rest of this file. @@ -36,7 +36,7 @@ variable {C D : Type*} [Category C] [Category D] namespace CategoryTheory.Adjunction /-- -If `F ⊣ G` and `F' ⊣ G'` are adjunctions, then giving a natural transformation `G ⟶ G'` is the +If `F ⊣ G` and `F' ⊣ G'` are adjunctions, then giving a natural transformation `G ⟶ G'` is the same as giving a natural transformation `F' ⟶ F`. -/ @[simps] @@ -99,7 +99,7 @@ lemma natTransEquiv_comp_symm {F F' F'' : C ⥤ D} {G G' G'' : D ⥤ C} simp /-- -If `F ⊣ G` and `F' ⊣ G'` are adjunctions, then giving a natural isomorphism `G ≅ G'` is the +If `F ⊣ G` and `F' ⊣ G'` are adjunctions, then giving a natural isomorphism `G ≅ G'` is the same as giving a natural transformation `F' ≅ F`. -/ @[simps] diff --git a/Mathlib/CategoryTheory/Closed/Cartesian.lean b/Mathlib/CategoryTheory/Closed/Cartesian.lean index 7dc0f610b435c..cc3a110baa215 100644 --- a/Mathlib/CategoryTheory/Closed/Cartesian.lean +++ b/Mathlib/CategoryTheory/Closed/Cartesian.lean @@ -308,7 +308,7 @@ def powZero {I : C} (t : IsInitial I) [CartesianClosed C] : I ⟹ B ≅ ⊤_ C w rw [← curry_natural_left, curry_eq_iff, ← cancel_epi (mulZero t).inv] apply t.hom_ext --- TODO: Generalise the below to its commutated variants. +-- TODO: Generalise the below to its commuted variants. -- TODO: Define a distributive category, so that zero_mul and friends can be derived from this. /-- In a CCC with binary coproducts, the distribution morphism is an isomorphism. -/ def prodCoprodDistrib [HasBinaryCoproducts C] [CartesianClosed C] (X Y Z : C) : diff --git a/Mathlib/CategoryTheory/Closed/Types.lean b/Mathlib/CategoryTheory/Closed/Types.lean index 76a1e1194bd3e..e1b0ffa01b4f2 100644 --- a/Mathlib/CategoryTheory/Closed/Types.lean +++ b/Mathlib/CategoryTheory/Closed/Types.lean @@ -51,7 +51,7 @@ instance {C : Type v₁} [SmallCategory C] : CartesianClosed (C ⥤ Type v₁) : have := Presheaf.isLeftAdjoint_of_preservesColimits (prod.functor.obj F) exact Exponentiable.mk _ _ (Adjunction.ofIsLeftAdjoint (prod.functor.obj F))) --- TODO: once we have `MonoidalClosed` instances for functor categories into general monoidal +-- TODO: once we have `MonoidalClosed` instances for functor categories into general monoidal -- closed categories, replace this with that, as it will be a more explicit construction. /-- This is not a good instance because of the universe levels. Below is the instance where the target category is `Type (max u₁ v₁)`. -/ @@ -63,12 +63,12 @@ def cartesianClosedFunctorToTypes {C : Type u₁} [Category.{v₁} C] : (ULift.equivalence.trans ULiftHom.equiv).functor) cartesianClosedOfEquiv e --- TODO: once we have `MonoidalClosed` instances for functor categories into general monoidal +-- TODO: once we have `MonoidalClosed` instances for functor categories into general monoidal -- closed categories, replace this with that, as it will be a more explicit construction. instance {C : Type u₁} [Category.{v₁} C] : CartesianClosed (C ⥤ Type (max u₁ v₁)) := cartesianClosedFunctorToTypes --- TODO: once we have `MonoidalClosed` instances for functor categories into general monoidal +-- TODO: once we have `MonoidalClosed` instances for functor categories into general monoidal -- closed categories, replace this with that, as it will be a more explicit construction. instance {C : Type u₁} [Category.{v₁} C] [EssentiallySmall.{v₁} C] : CartesianClosed (C ⥤ Type v₁) := diff --git a/Mathlib/CategoryTheory/Comma/Arrow.lean b/Mathlib/CategoryTheory/Comma/Arrow.lean index 1f396ae0ab27c..972c94b207848 100644 --- a/Mathlib/CategoryTheory/Comma/Arrow.lean +++ b/Mathlib/CategoryTheory/Comma/Arrow.lean @@ -34,7 +34,7 @@ variable (T) def Arrow := Comma.{v, v, v} (𝟭 T) (𝟭 T) -/- Porting note: could not derive `Category` above so this instance works in its place-/ +/- Porting note: could not derive `Category` above so this instance works in its place -/ instance : Category (Arrow T) := commaCategory -- Satisfying the inhabited linter diff --git a/Mathlib/CategoryTheory/Comma/Basic.lean b/Mathlib/CategoryTheory/Comma/Basic.lean index 770ff3e2e5e03..892745edf3a95 100644 --- a/Mathlib/CategoryTheory/Comma/Basic.lean +++ b/Mathlib/CategoryTheory/Comma/Basic.lean @@ -60,7 +60,7 @@ variable {B' : Type u₅} [Category.{v₅} B'] variable {T' : Type u₆} [Category.{v₆} T'] /-- The objects of the comma category are triples of an object `left : A`, an object - `right : B` and a morphism `hom : L.obj left ⟶ R.obj right`. -/ + `right : B` and a morphism `hom : L.obj left ⟶ R.obj right`. -/ structure Comma (L : A ⥤ T) (R : B ⥤ T) : Type max u₁ u₂ v₃ where left : A right : B diff --git a/Mathlib/CategoryTheory/Comma/Over.lean b/Mathlib/CategoryTheory/Comma/Over.lean index a1d85c11217fa..cc20542eb281d 100644 --- a/Mathlib/CategoryTheory/Comma/Over.lean +++ b/Mathlib/CategoryTheory/Comma/Over.lean @@ -638,7 +638,7 @@ lemma toOver_comp_forget (F : S ⥤ T) (X : T) (f : (Y : S) → F.obj Y ⟶ X) /-- Given `X : T`, to upgrade a functor `F : S ⥤ T` to a functor `S ⥤ Under X`, it suffices to provide maps `X ⟶ F.obj Y` for all `Y` making the obvious triangles involving all `F.map g` - commute. -/ + commute. -/ @[simps! obj_right map_right] def toUnder (F : S ⥤ T) (X : T) (f : (Y : S) → X ⟶ F.obj Y) (h : ∀ {Y Z : S} (g : Y ⟶ Z), f Y ≫ F.map g = f Z) : S ⥤ Under X := diff --git a/Mathlib/CategoryTheory/Comma/StructuredArrow.lean b/Mathlib/CategoryTheory/Comma/StructuredArrow.lean index 7c9348d8e83bf..9dff431f80860 100644 --- a/Mathlib/CategoryTheory/Comma/StructuredArrow.lean +++ b/Mathlib/CategoryTheory/Comma/StructuredArrow.lean @@ -111,7 +111,7 @@ def homMk {f f' : StructuredArrow S T} (g : f.right ⟶ f'.right) simpa using w.symm /- Porting note: it appears the simp lemma is not getting generated but the linter -picks up on it (seems like a bug). Either way simp solves it. -/ +picks up on it (seems like a bug). Either way simp solves it. -/ attribute [-simp, nolint simpNF] homMk_left theorem homMk_surjective {f f' : StructuredArrow S T} (φ : f ⟶ f') : @@ -120,7 +120,7 @@ theorem homMk_surjective {f f' : StructuredArrow S T} (φ : f ⟶ f') : ⟨φ.right, StructuredArrow.w φ, rfl⟩ /-- Given a structured arrow `X ⟶ T(Y)`, and an arrow `Y ⟶ Y'`, we can construct a morphism of - structured arrows given by `(X ⟶ T(Y)) ⟶ (X ⟶ T(Y) ⟶ T(Y'))`. -/ + structured arrows given by `(X ⟶ T(Y)) ⟶ (X ⟶ T(Y) ⟶ T(Y'))`. -/ @[simps] def homMk' (f : StructuredArrow S T) (g : f.right ⟶ Y') : f ⟶ mk (f.hom ≫ T.map g) where left := 𝟙 _ diff --git a/Mathlib/CategoryTheory/ConnectedComponents.lean b/Mathlib/CategoryTheory/ConnectedComponents.lean index b6522e987ae80..8a2d534554def 100644 --- a/Mathlib/CategoryTheory/ConnectedComponents.lean +++ b/Mathlib/CategoryTheory/ConnectedComponents.lean @@ -56,7 +56,7 @@ def ConnectedComponents.functorToDiscrete (X : Type*) map g := Discrete.eqToHom (congrArg f (Quotient.sound (Zigzag.of_hom g))) /-- Every functor to a discrete category gives a function from connected components -/ -def ConnectedComponents.liftFunctor (J) [Category J] {X : Type*} (F :J ⥤ Discrete X) : +def ConnectedComponents.liftFunctor (J) [Category J] {X : Type*} (F :J ⥤ Discrete X) : (ConnectedComponents J → X) := Quotient.lift (fun c => (F.obj c).as) (fun _ _ h => eq_of_zigzag X (zigzag_obj_of_zigzag F h)) @@ -116,7 +116,7 @@ instance (j : ConnectedComponents J) : IsConnected (Component j) := by -- Everything in our chosen zigzag from `j₁` to `j₂` has a zigzag to `j₂`. have hf : ∀ a : J, a ∈ l → Zigzag a j₂ := by intro i hi - apply List.Chain.induction (fun t => Zigzag t j₂) _ hl₁ hl₂ _ _ _ (List.mem_of_mem_tail hi) + apply hl₁.backwards_induction (fun t => Zigzag t j₂) _ hl₂ _ _ _ (List.mem_of_mem_tail hi) · intro j k apply Relation.ReflTransGen.head · apply Relation.ReflTransGen.refl diff --git a/Mathlib/CategoryTheory/EffectiveEpi/Basic.lean b/Mathlib/CategoryTheory/EffectiveEpi/Basic.lean index b835df66d8be2..4259ae6bf495b 100644 --- a/Mathlib/CategoryTheory/EffectiveEpi/Basic.lean +++ b/Mathlib/CategoryTheory/EffectiveEpi/Basic.lean @@ -24,7 +24,7 @@ then these definitions are equivalent, see the file `CategoryTheory/EffectiveEpi/RegularEpi.lean` See [nlab: *Effective Epimorphism*](https://ncatlab.org/nlab/show/effective+epimorphism) and [Stacks 00WP](https://stacks.math.columbia.edu/tag/00WP) for the standard definitions. Note that -our notion of `EffectiveEpi` is often called "strict epi" in the literature. +our notion of `EffectiveEpi` is often called "strict epi" in the literature. ## References - [Elephant]: *Sketches of an Elephant*, P. T. Johnstone: C2.1, Example 2.1.12. @@ -45,7 +45,7 @@ This structure encodes the data required for a morphism to be an effective epimo structure EffectiveEpiStruct {X Y : C} (f : Y ⟶ X) where /-- For every `W` with a morphism `e : Y ⟶ W` that coequalizes every pair of morphisms - `g₁ g₂ : Z ⟶ Y` which `f` coequalizes, `desc e h` is a morphism `X ⟶ W`...  + `g₁ g₂ : Z ⟶ Y` which `f` coequalizes, `desc e h` is a morphism `X ⟶ W`... -/ desc : ∀ {W : C} (e : Y ⟶ W), (∀ {Z : C} (g₁ g₂ : Z ⟶ Y), g₁ ≫ f = g₂ ≫ f → g₁ ≫ e = g₂ ≫ e) → (X ⟶ W) @@ -65,7 +65,7 @@ If `f` has a kernel pair, then this is equivalent to showing that the correspond a colimit. -/ class EffectiveEpi {X Y : C} (f : Y ⟶ X) : Prop where - /-- `f` is an effective epimorphism if there exists an `EffectiveEpiStruct` for `f`. -/ + /-- `f` is an effective epimorphism if there exists an `EffectiveEpiStruct` for `f`. -/ effectiveEpi : Nonempty (EffectiveEpiStruct f) /-- Some chosen `EffectiveEpiStruct` associated to an effective epi. -/ @@ -107,7 +107,7 @@ structure EffectiveEpiFamilyStruct {B : C} {α : Type*} /-- For every `W` with a family of morphisms `e a : Y a ⟶ W` that coequalizes every pair of morphisms `g₁ : Z ⟶ Y a₁`, `g₂ : Z ⟶ Y a₂` which the family `π` coequalizes, `desc e h` is a morphism - `X ⟶ W`...  + `X ⟶ W`... -/ desc : ∀ {W} (e : (a : α) → (X a ⟶ W)), (∀ {Z : C} (a₁ a₂ : α) (g₁ : Z ⟶ X a₁) (g₂ : Z ⟶ X a₂), @@ -129,7 +129,7 @@ provided that the `π a` exhibit `B` as a colimit of the diagram of all "relatio `R → X a₁`, `R ⟶ X a₂` for all `a₁ a₂ : α`. -/ class EffectiveEpiFamily {B : C} {α : Type*} (X : α → C) (π : (a : α) → (X a ⟶ B)) : Prop where - /-- `π` is an effective epimorphic family if there exists an `EffectiveEpiFamilyStruct` for `π` -/ + /-- `π` is an effective epimorphic family if there exists an `EffectiveEpiFamilyStruct` for `π` -/ effectiveEpiFamily : Nonempty (EffectiveEpiFamilyStruct X π) /-- Some chosen `EffectiveEpiFamilyStruct` associated to an effective epi family. -/ @@ -186,7 +186,7 @@ instance {B X : C} (f : X ⟶ B) [EffectiveEpi f] : EffectiveEpiFamily (fun () ⟨⟨effectiveEpiFamilyStructSingletonOfEffectiveEpi f⟩⟩ /-- -A single element `EffectiveEpiFamily` consists of an `EffectiveEpi` +A single element `EffectiveEpiFamily` consists of an `EffectiveEpi` -/ noncomputable def effectiveEpiStructOfEffectiveEpiFamilySingleton {B X : C} (f : X ⟶ B) diff --git a/Mathlib/CategoryTheory/EffectiveEpi/Comp.lean b/Mathlib/CategoryTheory/EffectiveEpi/Comp.lean index 94fd3321440d7..a8b4353556eb6 100644 --- a/Mathlib/CategoryTheory/EffectiveEpi/Comp.lean +++ b/Mathlib/CategoryTheory/EffectiveEpi/Comp.lean @@ -8,7 +8,7 @@ import Mathlib.CategoryTheory.EffectiveEpi.Basic # Composition of effective epimorphisms -This file provides `EffectiveEpi` instances for certain compositions. +This file provides `EffectiveEpi` instances for certain compositions. -/ diff --git a/Mathlib/CategoryTheory/EffectiveEpi/Coproduct.lean b/Mathlib/CategoryTheory/EffectiveEpi/Coproduct.lean index 85b4dfd1e7fc3..80a53351c358d 100644 --- a/Mathlib/CategoryTheory/EffectiveEpi/Coproduct.lean +++ b/Mathlib/CategoryTheory/EffectiveEpi/Coproduct.lean @@ -56,7 +56,7 @@ example {B : C} {α : Type*} (X : α → C) (π : (a : α) → (X a ⟶ B)) [Eff /-- This is an auxiliary lemma used twice in the definition of `EffectiveEpiFamilyOfEffectiveEpiDesc`. -It is the `h` hypothesis of `EffectiveEpi.desc` and `EffectiveEpi.fac`.  +It is the `h` hypothesis of `EffectiveEpi.desc` and `EffectiveEpi.fac`. -/ theorem effectiveEpiFamilyStructOfEffectiveEpiDesc_aux {B : C} {α : Type*} {X : α → C} {π : (a : α) → X a ⟶ B} [HasCoproduct X] diff --git a/Mathlib/CategoryTheory/EffectiveEpi/Enough.lean b/Mathlib/CategoryTheory/EffectiveEpi/Enough.lean index 1c4b96149fb57..dc7f679ddd6fb 100644 --- a/Mathlib/CategoryTheory/EffectiveEpi/Enough.lean +++ b/Mathlib/CategoryTheory/EffectiveEpi/Enough.lean @@ -8,7 +8,7 @@ import Mathlib.CategoryTheory.EffectiveEpi.Basic # Effectively enough objects in the image of a functor -We define the class `F.EffectivelyEnough` on a functor `F : C ⥤ D` which says that for every object +We define the class `F.EffectivelyEnough` on a functor `F : C ⥤ D` which says that for every object in `D`, there exists an effective epi to it from an object in the image of `F`. -/ @@ -21,11 +21,11 @@ variable {C D : Type*} [Category C] [Category D] (F : C ⥤ D) namespace Functor /-- -An effective presentation of an object `X` with respect to a functor `F` is the data of an effective +An effective presentation of an object `X` with respect to a functor `F` is the data of an effective epimorphism of the form `F.obj p ⟶ X`. -/ structure EffectivePresentation (X : D) where - /-- The object of `C` giving the source of the effective epi -/ + /-- The object of `C` giving the source of the effective epi -/ p : C /-- The morphism `F.obj p ⟶ X` -/ f : F.obj p ⟶ X @@ -33,11 +33,11 @@ structure EffectivePresentation (X : D) where effectiveEpi : EffectiveEpi f /-- -`D` has *effectively enough objects with respect to the functor `F` if every object has an +`D` has *effectively enough objects with respect to the functor `F` if every object has an effective presentation. -/ class EffectivelyEnough : Prop where - /-- For every `X : D`, there exists an object `p` of `C` with an effective epi `F.obj p ⟶ X`. -/ + /-- For every `X : D`, there exists an object `p` of `C` with an effective epi `F.obj p ⟶ X`. -/ presentation : ∀ (X : D), Nonempty (F.EffectivePresentation X) variable [F.EffectivelyEnough] diff --git a/Mathlib/CategoryTheory/EffectiveEpi/Extensive.lean b/Mathlib/CategoryTheory/EffectiveEpi/Extensive.lean index 433f695391d2d..00ace33a89767 100644 --- a/Mathlib/CategoryTheory/EffectiveEpi/Extensive.lean +++ b/Mathlib/CategoryTheory/EffectiveEpi/Extensive.lean @@ -11,7 +11,7 @@ import Mathlib.CategoryTheory.Limits.Preserves.Finite # Preserving and reflecting effective epis on extensive categories -We prove that a functor between `FinitaryPreExtensive` categories preserves (resp. reflects) finite +We prove that a functor between `FinitaryPreExtensive` categories preserves (resp. reflects) finite effective epi families if it preserves (resp. reflects) effective epis. -/ diff --git a/Mathlib/CategoryTheory/EffectiveEpi/RegularEpi.lean b/Mathlib/CategoryTheory/EffectiveEpi/RegularEpi.lean index 8f471641e5b1f..9272c878d3ca1 100644 --- a/Mathlib/CategoryTheory/EffectiveEpi/RegularEpi.lean +++ b/Mathlib/CategoryTheory/EffectiveEpi/RegularEpi.lean @@ -19,7 +19,7 @@ open Limits RegularEpi variable {C : Type*} [Category C] -/-- The data of an `EffectiveEpi` structure on a `RegularEpi`. -/ +/-- The data of an `EffectiveEpi` structure on a `RegularEpi`. -/ def effectiveEpiStructOfRegularEpi {B X : C} (f : X ⟶ B) [RegularEpi f] : EffectiveEpiStruct f where desc _ h := Cofork.IsColimit.desc isColimit _ (h _ _ w) diff --git a/Mathlib/CategoryTheory/Extensive.lean b/Mathlib/CategoryTheory/Extensive.lean index aea742746748d..887e41f0debb8 100644 --- a/Mathlib/CategoryTheory/Extensive.lean +++ b/Mathlib/CategoryTheory/Extensive.lean @@ -79,7 +79,7 @@ and binary coproducts are universal. -/ class FinitaryPreExtensive (C : Type u) [Category.{v} C] : Prop where [hasFiniteCoproducts : HasFiniteCoproducts C] [hasPullbacksOfInclusions : HasPullbacksOfInclusions C] - /-- In a finitary extensive category, all coproducts are van Kampen-/ + /-- In a finitary extensive category, all coproducts are van Kampen -/ universal' : ∀ {X Y : C} (c : BinaryCofan X Y), IsColimit c → IsUniversalColimit c attribute [instance] FinitaryPreExtensive.hasFiniteCoproducts @@ -90,7 +90,7 @@ and binary coproducts are van Kampen. -/ class FinitaryExtensive (C : Type u) [Category.{v} C] : Prop where [hasFiniteCoproducts : HasFiniteCoproducts C] [hasPullbacksOfInclusions : HasPullbacksOfInclusions C] - /-- In a finitary extensive category, all coproducts are van Kampen-/ + /-- In a finitary extensive category, all coproducts are van Kampen -/ van_kampen' : ∀ {X Y : C} (c : BinaryCofan X Y), IsColimit c → IsVanKampenColimit c attribute [instance] FinitaryExtensive.hasFiniteCoproducts diff --git a/Mathlib/CategoryTheory/Filtered/Small.lean b/Mathlib/CategoryTheory/Filtered/Small.lean index 7948241296129..5206fd8c67956 100644 --- a/Mathlib/CategoryTheory/Filtered/Small.lean +++ b/Mathlib/CategoryTheory/Filtered/Small.lean @@ -56,11 +56,11 @@ namespace FilteredClosureSmall in `C`. This would require some kind of inductive-recursive definition, which Lean does not allow. Our solution is to define a function `ℕ → Σ t : Type (max v w), t → C` by (strong) induction and then take the union over all natural numbers, mimicking what one would do in a - set-theoretic setting. -/ + set-theoretic setting. -/ /-- One step of the inductive procedure consists of adjoining all maxima and coequalizers of all objects and morphisms obtained so far. This is quite redundant, picking up many objects which we - already hit in earlier iterations, but this is easier to work with later. -/ + already hit in earlier iterations, but this is easier to work with later. -/ private inductive InductiveStep (n : ℕ) (X : ∀ (k : ℕ), k < n → Σ t : Type (max v w), t → C) : Type (max v w) | max : {k k' : ℕ} → (hk : k < n) → (hk' : k' < n) → (X _ hk).1 → (X _ hk').1 → InductiveStep n X @@ -78,7 +78,7 @@ private noncomputable def inductiveStepRealization (n : ℕ) as a function of `ℕ`. The function is defined by well-founded recursion, but we really want to use its - definitional equalities in the proofs below, so lets make it semireducible. -/ + definitional equalities in the proofs below, so lets make it semireducible. -/ @[semireducible] private noncomputable def bundledAbstractFilteredClosure : ℕ → Σ t : Type (max v w), t → C | 0 => ⟨ULift.{v} α, f ∘ ULift.down⟩ @@ -211,7 +211,7 @@ private noncomputable def inductiveStepRealization (n : ℕ) `EssentiallySmall.{max v w} (FullSubcategory (CofilteredClosure f))`. The function is defined by well-founded recursion, but we really want to use its - definitional equalities in the proofs below, so lets make it semireducible. -/ + definitional equalities in the proofs below, so lets make it semireducible. -/ @[semireducible] private noncomputable def bundledAbstractCofilteredClosure : ℕ → Σ t : Type (max v w), t → C | 0 => ⟨ULift.{v} α, f ∘ ULift.down⟩ diff --git a/Mathlib/CategoryTheory/FullSubcategory.lean b/Mathlib/CategoryTheory/FullSubcategory.lean index 49bfb77d86356..8aa58d273b2d2 100644 --- a/Mathlib/CategoryTheory/FullSubcategory.lean +++ b/Mathlib/CategoryTheory/FullSubcategory.lean @@ -97,9 +97,9 @@ See . We do not define 'strictly full -/ @[ext] structure FullSubcategory where - /-- The category of which this is a full subcategory-/ + /-- The category of which this is a full subcategory -/ obj : C - /-- The predicate satisfied by all objects in this subcategory-/ + /-- The predicate satisfied by all objects in this subcategory -/ property : Z obj instance FullSubcategory.category : Category.{v} (FullSubcategory Z) := diff --git a/Mathlib/CategoryTheory/Functor/Derived/RightDerived.lean b/Mathlib/CategoryTheory/Functor/Derived/RightDerived.lean index c926a1b32013f..8acc96f8e2d2d 100644 --- a/Mathlib/CategoryTheory/Functor/Derived/RightDerived.lean +++ b/Mathlib/CategoryTheory/Functor/Derived/RightDerived.lean @@ -97,7 +97,7 @@ lemma rightDerived_ext (G : D ⥤ H) (γ₁ γ₂ : RF ⟶ G) RF.hom_ext_of_isLeftKanExtension α γ₁ γ₂ hγ /-- The natural transformation `RF ⟶ RF'` on right derived functors that is -induced by a natural transformation `F ⟶ F'`. -/ +induced by a natural transformation `F ⟶ F'`. -/ noncomputable def rightDerivedNatTrans (τ : F ⟶ F') : RF ⟶ RF' := RF.rightDerivedDesc α W RF' (τ ≫ α') @@ -128,7 +128,7 @@ lemma rightDerivedNatTrans_comp (τ : F ⟶ F') (τ' : F' ⟶ F'') : rightDerived_ext RF α W _ _ _ (by aesop_cat) /-- The natural isomorphism `RF ≅ RF'` on right derived functors that is -induced by a natural isomorphism `F ≅ F'`. -/ +induced by a natural isomorphism `F ≅ F'`. -/ @[simps] noncomputable def rightDerivedNatIso (τ : F ≅ F') : RF ≅ RF' where diff --git a/Mathlib/CategoryTheory/Functor/FullyFaithful.lean b/Mathlib/CategoryTheory/Functor/FullyFaithful.lean index 97f7070645c30..cbc95c08b955f 100644 --- a/Mathlib/CategoryTheory/Functor/FullyFaithful.lean +++ b/Mathlib/CategoryTheory/Functor/FullyFaithful.lean @@ -171,6 +171,15 @@ lemma full : F.Full where lemma faithful : F.Faithful where map_injective := hF.map_injective +instance : Subsingleton F.FullyFaithful where + allEq h₁ h₂ := by + have := h₁.faithful + cases h₁ with | mk f₁ hf₁ _ => cases h₂ with | mk f₂ hf₂ _ => + simp only [Functor.FullyFaithful.mk.injEq] + ext + apply F.map_injective + rw [hf₁, hf₂] + /-- The unique isomorphism `X ≅ Y` which induces an isomorphism `F.obj X ≅ F.obj Y` when `hF : F.FullyFaithful`. -/ @[simps] diff --git a/Mathlib/CategoryTheory/Galois/GaloisObjects.lean b/Mathlib/CategoryTheory/Galois/GaloisObjects.lean index 1ceed246f266d..5196d8d135625 100644 --- a/Mathlib/CategoryTheory/Galois/GaloisObjects.lean +++ b/Mathlib/CategoryTheory/Galois/GaloisObjects.lean @@ -83,7 +83,7 @@ theorem isGalois_iff_pretransitive (X : C) [IsConnected X] : rw [isGalois_iff_aux, Equiv.nonempty_congr <| quotientByAutTerminalEquivUniqueQuotient F X] exact (MulAction.pretransitive_iff_unique_quotient_of_nonempty (Aut X) (F.obj X)).symm -/-- If `X` is Galois, the quotient `X / Aut X` is terminal. -/ +/-- If `X` is Galois, the quotient `X / Aut X` is terminal. -/ noncomputable def isTerminalQuotientOfIsGalois (X : C) [IsGalois X] : IsTerminal <| colimit <| SingleObj.functor <| Aut.toEnd X := Nonempty.some IsGalois.quotientByAutTerminal diff --git a/Mathlib/CategoryTheory/Galois/Prorepresentability.lean b/Mathlib/CategoryTheory/Galois/Prorepresentability.lean index 0edce049c34ca..ad4a6eb3b3032 100644 --- a/Mathlib/CategoryTheory/Galois/Prorepresentability.lean +++ b/Mathlib/CategoryTheory/Galois/Prorepresentability.lean @@ -189,7 +189,7 @@ noncomputable def autGaloisSystem : PointedGaloisObject F ⥤ Grp.{u₂} where ext (σ : Aut A.obj) simp -/-- The limit of `autGaloisSystem`. -/ +/-- The limit of `autGaloisSystem`. -/ noncomputable def AutGalois : Type (max u₁ u₂) := (autGaloisSystem F ⋙ forget _).sections diff --git a/Mathlib/CategoryTheory/GradedObject/Trifunctor.lean b/Mathlib/CategoryTheory/GradedObject/Trifunctor.lean index 268083af2e28c..e37faa3138dfc 100644 --- a/Mathlib/CategoryTheory/GradedObject/Trifunctor.lean +++ b/Mathlib/CategoryTheory/GradedObject/Trifunctor.lean @@ -361,7 +361,7 @@ section variable [HasMap ((((mapTrifunctor (bifunctorComp₁₂ F₁₂ G) I₁ I₂ I₃).obj X₁).obj X₂).obj X₃) r] /-- The action on graded objects of a trifunctor obtained by composition of two -bifunctors can be computed as a composition of the actions of these two bifunctors. -/ +bifunctors can be computed as a composition of the actions of these two bifunctors. -/ noncomputable def mapBifunctorComp₁₂MapObjIso : mapTrifunctorMapObj (bifunctorComp₁₂ F₁₂ G) r X₁ X₂ X₃ ≅ mapBifunctorMapObj G ρ₁₂.q (mapBifunctorMapObj F₁₂ ρ₁₂.p X₁ X₂) X₃ := @@ -539,7 +539,7 @@ section variable [HasMap ((((mapTrifunctor (bifunctorComp₂₃ F G₂₃) I₁ I₂ I₃).obj X₁).obj X₂).obj X₃) r] /-- The action on graded objects of a trifunctor obtained by composition of two -bifunctors can be computed as a composition of the actions of these two bifunctors. -/ +bifunctors can be computed as a composition of the actions of these two bifunctors. -/ noncomputable def mapBifunctorComp₂₃MapObjIso : mapTrifunctorMapObj (bifunctorComp₂₃ F G₂₃) r X₁ X₂ X₃ ≅ mapBifunctorMapObj F ρ₂₃.q X₁ (mapBifunctorMapObj G₂₃ ρ₂₃.p X₂ X₃) := diff --git a/Mathlib/CategoryTheory/Groupoid/FreeGroupoid.lean b/Mathlib/CategoryTheory/Groupoid/FreeGroupoid.lean index 2521a5e952967..586e4e0c924f3 100644 --- a/Mathlib/CategoryTheory/Groupoid/FreeGroupoid.lean +++ b/Mathlib/CategoryTheory/Groupoid/FreeGroupoid.lean @@ -83,7 +83,7 @@ theorem congr_reverse {X Y : Paths <| Quiver.Symmetrify V} (p q : X ⟶ Y) : theorem congr_comp_reverse {X Y : Paths <| Quiver.Symmetrify V} (p : X ⟶ Y) : Quot.mk (@Quotient.CompClosure _ _ redStep _ _) (p ≫ p.reverse) = Quot.mk (@Quotient.CompClosure _ _ redStep _ _) (𝟙 X) := by - apply Quot.EqvGen_sound + apply Quot.eqvGen_sound induction' p with a b q f ih · apply EqvGen.refl · simp only [Quiver.Path.reverse] diff --git a/Mathlib/CategoryTheory/Groupoid/Subgroupoid.lean b/Mathlib/CategoryTheory/Groupoid/Subgroupoid.lean index b2efc306cfa42..808563792a9e3 100644 --- a/Mathlib/CategoryTheory/Groupoid/Subgroupoid.lean +++ b/Mathlib/CategoryTheory/Groupoid/Subgroupoid.lean @@ -139,7 +139,7 @@ theorem coe_inv_coe' {c d : S.objs} (p : c ⟶ d) : (CategoryTheory.inv p).val = CategoryTheory.inv p.val := by simp only [← inv_eq_inv, coe_inv_coe] -/-- The embedding of the coerced subgroupoid to its parent-/ +/-- The embedding of the coerced subgroupoid to its parent -/ def hom : S.objs ⥤ C where obj c := c.val map f := f.val @@ -292,7 +292,7 @@ theorem IsWide.id_mem {S : Subgroupoid C} (Sw : S.IsWide) (c : C) : 𝟙 c ∈ S theorem IsWide.eqToHom_mem {S : Subgroupoid C} (Sw : S.IsWide) {c d : C} (h : c = d) : eqToHom h ∈ S.arrows c d := by cases h; simp only [eqToHom_refl]; apply Sw.id_mem c -/-- A subgroupoid is normal if it is wide and satisfies the expected stability under conjugacy. -/ +/-- A subgroupoid is normal if it is wide and satisfies the expected stability under conjugacy. -/ structure IsNormal extends IsWide S : Prop where conj : ∀ {c d} (p : c ⟶ d) {γ : c ⟶ c}, γ ∈ S.arrows c c → Groupoid.inv p ≫ γ ≫ p ∈ S.arrows d d diff --git a/Mathlib/CategoryTheory/Idempotents/FunctorCategories.lean b/Mathlib/CategoryTheory/Idempotents/FunctorCategories.lean index ebcbb63e295ad..b1b1f5f30c036 100644 --- a/Mathlib/CategoryTheory/Idempotents/FunctorCategories.lean +++ b/Mathlib/CategoryTheory/Idempotents/FunctorCategories.lean @@ -58,7 +58,7 @@ instance functor_category_isIdempotentComplete [IsIdempotentComplete C] : have hC := (isIdempotentComplete_iff_hasEqualizer_of_id_and_idempotent C).mp inferInstance haveI : ∀ j : J, HasEqualizer (𝟙 _) (p.app j) := fun j => hC _ _ (congr_app hp j) /- We construct the direct factor `Y` associated to `p : F ⟶ F` by computing - the equalizer of the identity and `p.app j` on each object `(j : J)`. -/ + the equalizer of the identity and `p.app j` on each object `(j : J)`. -/ let Y : J ⥤ C := { obj := fun j => Limits.equalizer (𝟙 _) (p.app j) map := fun {j j'} φ => diff --git a/Mathlib/CategoryTheory/Limits/Cones.lean b/Mathlib/CategoryTheory/Limits/Cones.lean index 1d468d8221bd1..84e7ebc84d72c 100644 --- a/Mathlib/CategoryTheory/Limits/Cones.lean +++ b/Mathlib/CategoryTheory/Limits/Cones.lean @@ -668,7 +668,7 @@ def mapCone (c : Cone F) : Cone (F ⋙ H) := def mapCocone (c : Cocone F) : Cocone (F ⋙ H) := (Cocones.functoriality F H).obj c -/-- Given a cone morphism `c ⟶ c'`, construct a cone morphism on the mapped cones functorially. -/ +/-- Given a cone morphism `c ⟶ c'`, construct a cone morphism on the mapped cones functorially. -/ def mapConeMorphism {c c' : Cone F} (f : c ⟶ c') : H.mapCone c ⟶ H.mapCone c' := (Cones.functoriality F H).map f diff --git a/Mathlib/CategoryTheory/Limits/Final/ParallelPair.lean b/Mathlib/CategoryTheory/Limits/Final/ParallelPair.lean index b75d801a67a5d..938e98c7e64e6 100644 --- a/Mathlib/CategoryTheory/Limits/Final/ParallelPair.lean +++ b/Mathlib/CategoryTheory/Limits/Final/ParallelPair.lean @@ -6,10 +6,10 @@ Authors: Dagur Asgeirsson, Joël Riou import Mathlib.CategoryTheory.Limits.Final /-! -# Conditions for `parallelPair` to be initial +# Conditions for `parallelPair` to be initial -In this file we give sufficient conditions on a category `C` and parallel morphisms `f g : X ⟶ Y`  -in `C` so that `parallelPair f g` becomes an initial functor. +In this file we give sufficient conditions on a category `C` and parallel morphisms `f g : X ⟶ Y` +in `C` so that `parallelPair f g` becomes an initial functor. The conditions are that there is a morphism out of `X` to every object of `C` and that any two parallel morphisms out of `X` factor through the parallel pair `f`, `g` diff --git a/Mathlib/CategoryTheory/Limits/HasLimits.lean b/Mathlib/CategoryTheory/Limits/HasLimits.lean index a2ac485b93211..866e9a9ee1602 100644 --- a/Mathlib/CategoryTheory/Limits/HasLimits.lean +++ b/Mathlib/CategoryTheory/Limits/HasLimits.lean @@ -489,7 +489,7 @@ def limYoneda : lim ⋙ yoneda ⋙ (whiskeringRight _ _ _).obj uliftFunctor.{u₁} ≅ CategoryTheory.cones J C := NatIso.ofComponents fun F => NatIso.ofComponents fun W => limit.homIso F (unop W) -/-- The constant functor and limit functor are adjoint to each other-/ +/-- The constant functor and limit functor are adjoint to each other -/ def constLimAdj : (const J : C ⥤ J ⥤ C) ⊣ lim where homEquiv c g := { toFun := fun f => limit.lift _ ⟨c, f⟩ diff --git a/Mathlib/CategoryTheory/Limits/Opposites.lean b/Mathlib/CategoryTheory/Limits/Opposites.lean index fab462149abac..55f267f9bdae5 100644 --- a/Mathlib/CategoryTheory/Limits/Opposites.lean +++ b/Mathlib/CategoryTheory/Limits/Opposites.lean @@ -322,11 +322,11 @@ instance : HasProduct (op <| Z ·) := hasLimitOfIso (Discrete.opposite α).inverse ⋙ (Discrete.functor Z).op ≅ Discrete.functor (op <| Z ·)) -/-- A `Cofan` gives a `Fan` in the opposite category. -/ +/-- A `Cofan` gives a `Fan` in the opposite category. -/ @[simp] def Cofan.op (c : Cofan Z) : Fan (op <| Z ·) := Fan.mk _ (fun a ↦ (c.inj a).op) -/-- If a `Cofan` is colimit, then its opposite is limit. -/ +/-- If a `Cofan` is colimit, then its opposite is limit. -/ def Cofan.IsColimit.op {c : Cofan Z} (hc : IsColimit c) : IsLimit c.op := by let e : Discrete.functor (Opposite.op <| Z ·) ≅ (Discrete.opposite α).inverse ⋙ (Discrete.functor Z).op := Discrete.natIso (fun _ ↦ Iso.refl _) @@ -422,7 +422,7 @@ instance : HasCoproduct (op <| Z ·) := hasColimitOfIso @[simp] def Fan.op (f : Fan Z) : Cofan (op <| Z ·) := Cofan.mk _ (fun a ↦ (f.proj a).op) -/-- If a `Fan` is limit, then its opposite is colimit. -/ +/-- If a `Fan` is limit, then its opposite is colimit. -/ def Fan.IsLimit.op {f : Fan Z} (hf : IsLimit f) : IsColimit f.op := by let e : Discrete.functor (Opposite.op <| Z ·) ≅ (Discrete.opposite α).inverse ⋙ (Discrete.functor Z).op := Discrete.natIso (fun _ ↦ Iso.refl _) diff --git a/Mathlib/CategoryTheory/Limits/Preserves/Shapes/Biproducts.lean b/Mathlib/CategoryTheory/Limits/Preserves/Shapes/Biproducts.lean index c5f4f3bd95437..c3d4d473c6c16 100644 --- a/Mathlib/CategoryTheory/Limits/Preserves/Shapes/Biproducts.lean +++ b/Mathlib/CategoryTheory/Limits/Preserves/Shapes/Biproducts.lean @@ -224,7 +224,7 @@ theorem ι_biproductComparison' (j : J) : variable [PreservesZeroMorphisms F] /-- The composition in the opposite direction is equal to the identity if and only if `F` preserves - the biproduct, see `preservesBiproduct_of_monoBiproductComparison`. -/ + the biproduct, see `preservesBiproduct_of_monoBiproductComparison`. -/ @[reassoc (attr := simp)] theorem biproductComparison'_comp_biproductComparison : biproductComparison' F f ≫ biproductComparison F f = 𝟙 (⨁ F.obj ∘ f) := by diff --git a/Mathlib/CategoryTheory/Limits/Preserves/Shapes/Kernels.lean b/Mathlib/CategoryTheory/Limits/Preserves/Shapes/Kernels.lean index e273955285c7a..9a602e80dbec1 100644 --- a/Mathlib/CategoryTheory/Limits/Preserves/Shapes/Kernels.lean +++ b/Mathlib/CategoryTheory/Limits/Preserves/Shapes/Kernels.lean @@ -176,7 +176,7 @@ def isColimitMapCoconeEquiv : /-- A colimit cokernel cofork is mapped to a colimit cokernel cofork by a functor `G` when this functor preserves the corresponding colimit. -/ -def mapIsColimit (hc : IsColimit c) (G : C ⥤ D) +def mapIsColimit (hc : IsColimit c) (G : C ⥤ D) [Functor.PreservesZeroMorphisms G] [PreservesColimit (parallelPair f 0) G] : IsColimit (c.map G) := c.isColimitMapCoconeEquiv G (isColimitOfPreserves G hc) diff --git a/Mathlib/CategoryTheory/Limits/Preserves/Ulift.lean b/Mathlib/CategoryTheory/Limits/Preserves/Ulift.lean index 9bab8cb39bdb4..e11c09ddc138d 100644 --- a/Mathlib/CategoryTheory/Limits/Preserves/Ulift.lean +++ b/Mathlib/CategoryTheory/Limits/Preserves/Ulift.lean @@ -23,8 +23,8 @@ universe v w w' u namespace CategoryTheory.Limits.Types /-- -The equivalence between `K.sections` and `(K ⋙ uliftFunctor.{v, u}).sections`. This is used to show -that `uliftFunctor` preserves limits that are potentially too large to exist in the source +The equivalence between `K.sections` and `(K ⋙ uliftFunctor.{v, u}).sections`. This is used to show +that `uliftFunctor` preserves limits that are potentially too large to exist in the source category. -/ def sectionsEquiv {J : Type*} [Category J] (K : J ⥤ Type u) : diff --git a/Mathlib/CategoryTheory/Limits/Shapes/Biproducts.lean b/Mathlib/CategoryTheory/Limits/Shapes/Biproducts.lean index 8be6740de1be5..dba19cb9b91c5 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/Biproducts.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/Biproducts.lean @@ -1276,7 +1276,7 @@ abbrev toBinaryBicone {X Y : C} (b : Bicone (pairFunction X Y)) : BinaryBicone X toBinaryBiconeFunctor.obj b /-- A bicone over a pair is a limit cone if and only if the corresponding binary bicone is a limit - cone. -/ + cone. -/ def toBinaryBiconeIsLimit {X Y : C} (b : Bicone (pairFunction X Y)) : IsLimit b.toBinaryBicone.toCone ≃ IsLimit b.toCone := IsLimit.equivIsoLimit <| Cones.ext (Iso.refl _) fun j => by rcases j with ⟨⟨⟩⟩ <;> simp @@ -1762,7 +1762,7 @@ def biprod.fstKernelFork : KernelFork (biprod.fst : X ⊞ Y ⟶ X) := theorem biprod.fstKernelFork_ι : Fork.ι (biprod.fstKernelFork X Y) = (biprod.inr : Y ⟶ X ⊞ Y) := rfl -/-- The fork `biprod.fstKernelFork` is indeed a limit. -/ +/-- The fork `biprod.fstKernelFork` is indeed a limit. -/ def biprod.isKernelFstKernelFork : IsLimit (biprod.fstKernelFork X Y) := BinaryBicone.isLimitFstKernelFork (BinaryBiproduct.isLimit _ _) @@ -1775,7 +1775,7 @@ def biprod.sndKernelFork : KernelFork (biprod.snd : X ⊞ Y ⟶ Y) := theorem biprod.sndKernelFork_ι : Fork.ι (biprod.sndKernelFork X Y) = (biprod.inl : X ⟶ X ⊞ Y) := rfl -/-- The fork `biprod.sndKernelFork` is indeed a limit. -/ +/-- The fork `biprod.sndKernelFork` is indeed a limit. -/ def biprod.isKernelSndKernelFork : IsLimit (biprod.sndKernelFork X Y) := BinaryBicone.isLimitSndKernelFork (BinaryBiproduct.isLimit _ _) @@ -1788,7 +1788,7 @@ def biprod.inlCokernelCofork : CokernelCofork (biprod.inl : X ⟶ X ⊞ Y) := theorem biprod.inlCokernelCofork_π : Cofork.π (biprod.inlCokernelCofork X Y) = biprod.snd := rfl -/-- The cofork `biprod.inlCokernelFork` is indeed a colimit. -/ +/-- The cofork `biprod.inlCokernelFork` is indeed a colimit. -/ def biprod.isCokernelInlCokernelFork : IsColimit (biprod.inlCokernelCofork X Y) := BinaryBicone.isColimitInlCokernelCofork (BinaryBiproduct.isColimit _ _) @@ -1801,7 +1801,7 @@ def biprod.inrCokernelCofork : CokernelCofork (biprod.inr : Y ⟶ X ⊞ Y) := theorem biprod.inrCokernelCofork_π : Cofork.π (biprod.inrCokernelCofork X Y) = biprod.fst := rfl -/-- The cofork `biprod.inrCokernelFork` is indeed a colimit. -/ +/-- The cofork `biprod.inrCokernelFork` is indeed a colimit. -/ def biprod.isCokernelInrCokernelFork : IsColimit (biprod.inrCokernelCofork X Y) := BinaryBicone.isColimitInrCokernelCofork (BinaryBiproduct.isColimit _ _) @@ -1997,3 +1997,5 @@ theorem isIso_right_of_isIso_biprod_map {W X Y Z : C} (f : W ⟶ Y) (g : X ⟶ Z isIso_left_of_isIso_biprod_map g f end CategoryTheory + +set_option linter.style.longFile 2100 diff --git a/Mathlib/CategoryTheory/Limits/Shapes/CombinedProducts.lean b/Mathlib/CategoryTheory/Limits/Shapes/CombinedProducts.lean index 1d6c74aed120e..4563605f05c24 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/CombinedProducts.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/CombinedProducts.lean @@ -41,7 +41,7 @@ abbrev combPairHoms : (i : ι₁ ⊕ ι₂) → bc.pt ⟶ Sum.elim f₁ f₂ i variable {c₁ c₂ bc} /-- If `c₁` and `c₂` are limit fans and `bc` is a limit binary fan on their cone -points, then the fan constructed from `combPairHoms` is a limit cone. -/ +points, then the fan constructed from `combPairHoms` is a limit cone. -/ def combPairIsLimit : IsLimit (Fan.mk bc.pt (combPairHoms c₁ c₂ bc)) := mkFanLimit _ (fun s ↦ Fan.IsLimit.desc h <| fun i ↦ by @@ -76,7 +76,7 @@ abbrev combPairHoms : (i : ι₁ ⊕ ι₂) → Sum.elim f₁ f₂ i ⟶ bc.pt variable {c₁ c₂ bc} /-- If `c₁` and `c₂` are colimit cofans and `bc` is a colimit binary cofan on their cocone -points, then the cofan constructed from `combPairHoms` is a colimit cocone. -/ +points, then the cofan constructed from `combPairHoms` is a colimit cocone. -/ def combPairIsColimit : IsColimit (Cofan.mk bc.pt (combPairHoms c₁ c₂ bc)) := mkCofanColimit _ (fun s ↦ Cofan.IsColimit.desc h <| fun i ↦ by diff --git a/Mathlib/CategoryTheory/Limits/Shapes/Countable.lean b/Mathlib/CategoryTheory/Limits/Shapes/Countable.lean index bd6d44de0f55a..f1b2249d6d828 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/Countable.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/Countable.lean @@ -17,7 +17,7 @@ limits, see `sequentialFunctor_initial`. ## Projects -* There is a series of `proof_wanted` at the bottom of this file, implying that all cofiltered +* There is a series of `proof_wanted` at the bottom of this file, implying that all cofiltered limits over countable categories are isomorphic to sequential limits. * Prove the dual result for filtered colimits. @@ -36,7 +36,7 @@ instance and `J : Type` has a limit. -/ class HasCountableLimits : Prop where /-- `C` has all limits over any type `J` whose objects and morphisms lie in the same universe - and which has countably many objects and morphisms-/ + and which has countably many objects and morphisms -/ out (J : Type) [SmallCategory J] [CountableCategory J] : HasLimitsOfShape J C instance (priority := 100) hasFiniteLimits_of_hasCountableLimits [HasCountableLimits C] : @@ -58,7 +58,7 @@ instance and `J : Type` has a colimit. -/ class HasCountableColimits : Prop where /-- `C` has all limits over any type `J` whose objects and morphisms lie in the same universe - and which has countably many objects and morphisms-/ + and which has countably many objects and morphisms -/ out (J : Type) [SmallCategory J] [CountableCategory J] : HasColimitsOfShape J C instance (priority := 100) hasFiniteColimits_of_hasCountableColimits [HasCountableColimits C] : @@ -127,7 +127,7 @@ proof_wanted preorder_of_cofiltered (J : Type*) [Category J] [IsCofiltered J] : ∃ (I : Type*) (_ : Preorder I) (_ : IsCofiltered I) (F : I ⥤ J), F.Initial /-- -The proof of `preorder_of_cofiltered` should give a countable `I` in the case that `J` is a +The proof of `preorder_of_cofiltered` should give a countable `I` in the case that `J` is a countable category. -/ proof_wanted preorder_of_cofiltered_countable diff --git a/Mathlib/CategoryTheory/Limits/Shapes/Equalizers.lean b/Mathlib/CategoryTheory/Limits/Shapes/Equalizers.lean index bb067d0c9eef4..499e8ff5ad36b 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/Equalizers.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/Equalizers.lean @@ -925,7 +925,7 @@ variable {f g} def idCofork (h : f = g) : Cofork f g := Cofork.ofπ (𝟙 Y) <| h ▸ rfl -/-- The identity on `Y` is a coequalizer of `(f, g)`, where `f = g`. -/ +/-- The identity on `Y` is a coequalizer of `(f, g)`, where `f = g`. -/ def isColimitIdCofork (h : f = g) : IsColimit (idCofork h) := Cofork.IsColimit.mk _ (fun s => Cofork.π s) (fun s => Category.id_comp _) fun s m h => by convert h diff --git a/Mathlib/CategoryTheory/Limits/Shapes/FiniteLimits.lean b/Mathlib/CategoryTheory/Limits/Shapes/FiniteLimits.lean index 154159c993a8c..9cb33fc51bcc3 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/FiniteLimits.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/FiniteLimits.lean @@ -36,7 +36,7 @@ This is often called 'finitely complete'. -/ class HasFiniteLimits : Prop where /-- `C` has all limits over any type `J` whose objects and morphisms lie in the same universe - and which has `FinType` objects and morphisms-/ + and which has `FinType` objects and morphisms -/ out (J : Type) [𝒥 : SmallCategory J] [@FinCategory J 𝒥] : @HasLimitsOfShape J 𝒥 C _ instance (priority := 100) hasLimitsOfShape_of_hasFiniteLimits (J : Type w) [SmallCategory J] @@ -85,7 +85,7 @@ This is often called 'finitely cocomplete'. -/ class HasFiniteColimits : Prop where /-- `C` has all colimits over any type `J` whose objects and morphisms lie in the same universe - and which has `Fintype` objects and morphisms-/ + and which has `Fintype` objects and morphisms -/ out (J : Type) [𝒥 : SmallCategory J] [@FinCategory J 𝒥] : @HasColimitsOfShape J 𝒥 C _ instance (priority := 100) hasColimitsOfShape_of_hasFiniteColimits (J : Type w) [SmallCategory J] diff --git a/Mathlib/CategoryTheory/Limits/Shapes/Products.lean b/Mathlib/CategoryTheory/Limits/Shapes/Products.lean index 0821b11254338..a614b5d85405d 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/Products.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/Products.lean @@ -258,7 +258,7 @@ instance {f : β → C} [HasCoproduct f] : IsIso (Sigma.desc (fun a ↦ Sigma.ι ext simp -/-- A version of `Cocones.ext` for `Cofan`s. -/ +/-- A version of `Cocones.ext` for `Cofan`s. -/ @[simps!] def Cofan.ext {f : β → C} {c₁ c₂ : Cofan f} (e : c₁.pt ≅ c₂.pt) (w : ∀ (b : β), c₁.inj b ≫ e.hom = c₂.inj b := by aesop_cat) : c₁ ≅ c₂ := diff --git a/Mathlib/CategoryTheory/Limits/Shapes/Pullback/Mono.lean b/Mathlib/CategoryTheory/Limits/Shapes/Pullback/Mono.lean index 17d8d712cac9a..87a404f00fcb9 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/Pullback/Mono.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/Pullback/Mono.lean @@ -79,7 +79,7 @@ theorem mono_of_isLimitMkIdId (f : X ⟶ Y) (t : IsLimit (mk (𝟙 X) (𝟙 X) r /-- Suppose `f` and `g` are two morphisms with a common codomain and `s` is a limit cone over the diagram formed by `f` and `g`. Suppose `f` and `g` both factor through a monomorphism `h` via `x` and `y`, respectively. Then `s` is also a limit cone over the diagram formed by `x` and - `y`. -/ + `y`. -/ def isLimitOfFactors (f : X ⟶ Z) (g : Y ⟶ Z) (h : W ⟶ Z) [Mono h] (x : X ⟶ W) (y : Y ⟶ W) (hxh : x ≫ h = f) (hyh : y ≫ h = g) (s : PullbackCone f g) (hs : IsLimit s) : IsLimit @@ -250,7 +250,7 @@ theorem epi_of_isColimitMkIdId (f : X ⟶ Y) /-- Suppose `f` and `g` are two morphisms with a common domain and `s` is a colimit cocone over the diagram formed by `f` and `g`. Suppose `f` and `g` both factor through an epimorphism `h` via `x` and `y`, respectively. Then `s` is also a colimit cocone over the diagram formed by `x` and - `y`. -/ + `y`. -/ def isColimitOfFactors (f : X ⟶ Y) (g : X ⟶ Z) (h : X ⟶ W) [Epi h] (x : W ⟶ Y) (y : W ⟶ Z) (hhx : h ≫ x = f) (hhy : h ≫ y = g) (s : PushoutCocone f g) (hs : IsColimit s) : have reassoc₁ : h ≫ x ≫ inl s = f ≫ inl s := by -- Porting note: working around reassoc diff --git a/Mathlib/CategoryTheory/Limits/Shapes/SingleObj.lean b/Mathlib/CategoryTheory/Limits/Shapes/SingleObj.lean index 5168baa185fa4..e501871d0f757 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/SingleObj.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/SingleObj.lean @@ -72,7 +72,7 @@ section Colimits variable {G : Type v} [Group G] (J : SingleObj G ⥤ Type u) /-- The relation used to construct colimits in types for `J : SingleObj G ⥤ Type u` is -equivalent to the `MulAction.orbitRel` equivalence relation on `J.obj (SingleObj.star G)`. -/ +equivalent to the `MulAction.orbitRel` equivalence relation on `J.obj (SingleObj.star G)`. -/ lemma Types.Quot.Rel.iff_orbitRel (x y : J.obj (SingleObj.star G)) : Types.Quot.Rel J ⟨SingleObj.star G, x⟩ ⟨SingleObj.star G, y⟩ ↔ Setoid.Rel (MulAction.orbitRel G (J.obj (SingleObj.star G))) x y := by diff --git a/Mathlib/CategoryTheory/Limits/Shapes/Types.lean b/Mathlib/CategoryTheory/Limits/Shapes/Types.lean index ec3762f3af920..36236bdb44655 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/Types.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/Types.lean @@ -553,7 +553,7 @@ theorem coequalizer_preimage_image_eq_of_preimage_eq (π : Y ⟶ Z) (e : f ≫ (mono_iff_injective (h.coconePointUniqueUpToIso (coequalizerColimit f g).isColimit).inv).mp inferInstance e' - exact (eqv.eqvGen_iff.mp (EqvGen.mono lem (Quot.exact _ e'))).mp hy + exact (eqv.eqvGen_iff.mp (EqvGen.mono lem (Quot.eqvGen_exact _ e'))).mp hy · exact fun hx => ⟨_, hx, rfl⟩ /-- The categorical coequalizer in `Type u` is the quotient by `f g ~ g x`. -/ diff --git a/Mathlib/CategoryTheory/Limits/Shapes/WideEqualizers.lean b/Mathlib/CategoryTheory/Limits/Shapes/WideEqualizers.lean index c39731729d5e1..6193cbb5c6587 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/WideEqualizers.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/WideEqualizers.lean @@ -138,7 +138,7 @@ def diagramIsoParallelFamily (F : WalkingParallelFamily J ⥤ C) : rintro _ _ (_|_) <;> aesop_cat /-- `WalkingParallelPair` as a category is equivalent to a special case of -`WalkingParallelFamily`. -/ +`WalkingParallelFamily`. -/ @[simps!] def walkingParallelFamilyEquivWalkingParallelPair : WalkingParallelFamily.{w} (ULift Bool) ≌ WalkingParallelPair where diff --git a/Mathlib/CategoryTheory/Limits/TypesFiltered.lean b/Mathlib/CategoryTheory/Limits/TypesFiltered.lean index 48b2c53fe834a..0b910fdeb786d 100644 --- a/Mathlib/CategoryTheory/Limits/TypesFiltered.lean +++ b/Mathlib/CategoryTheory/Limits/TypesFiltered.lean @@ -27,7 +27,7 @@ attribute [local instance] small_quot_of_hasColimit /- For filtered colimits of types, we can give an explicit description of the equivalence relation generated by the relation used to form - the colimit. -/ + the colimit. -/ /-- An alternative relation on `Σ j, F.obj j`, which generates the same equivalence relation as we use to define the colimit in `Type` above, diff --git a/Mathlib/CategoryTheory/Localization/CalculusOfFractions.lean b/Mathlib/CategoryTheory/Localization/CalculusOfFractions.lean index b6cc4f0377426..a46ca7ab8e22f 100644 --- a/Mathlib/CategoryTheory/Localization/CalculusOfFractions.lean +++ b/Mathlib/CategoryTheory/Localization/CalculusOfFractions.lean @@ -226,7 +226,7 @@ lemma LeftFraction.rightFraction_fac [W.HasRightCalculusOfFractions] {X Y : C} /-- The equivalence relation on left fractions for a morphism property `W`. -/ def LeftFractionRel {X Y : C} (z₁ z₂ : W.LeftFraction X Y) : Prop := - ∃ (Z : C) (t₁ : z₁.Y' ⟶ Z) (t₂ : z₂.Y' ⟶ Z) (_ : z₁.s ≫ t₁ = z₂.s ≫ t₂) + ∃ (Z : C) (t₁ : z₁.Y' ⟶ Z) (t₂ : z₂.Y' ⟶ Z) (_ : z₁.s ≫ t₁ = z₂.s ≫ t₂) (_ : z₁.f ≫ t₁ = z₂.f ≫ t₂), W (z₁.s ≫ t₁) namespace LeftFractionRel @@ -877,7 +877,7 @@ instance (W : MorphismProperty Cᵒᵖ) [h : W.HasRightCalculusOfFractions] : /-- The equivalence relation on right fractions for a morphism property `W`. -/ def RightFractionRel {X Y : C} (z₁ z₂ : W.RightFraction X Y) : Prop := - ∃ (Z : C) (t₁ : Z ⟶ z₁.X') (t₂ : Z ⟶ z₂.X') (_ : t₁ ≫ z₁.s = t₂ ≫ z₂.s) + ∃ (Z : C) (t₁ : Z ⟶ z₁.X') (t₂ : Z ⟶ z₂.X') (_ : t₁ ≫ z₁.s = t₂ ≫ z₂.s) (_ : t₁ ≫ z₁.f = t₂ ≫ z₂.f), W (t₁ ≫ z₁.s) lemma RightFractionRel.op {X Y : C} {z₁ z₂ : W.RightFraction X Y} diff --git a/Mathlib/CategoryTheory/Localization/CalculusOfFractions/Fractions.lean b/Mathlib/CategoryTheory/Localization/CalculusOfFractions/Fractions.lean index bf5ec2d0d65aa..465d603552c31 100644 --- a/Mathlib/CategoryTheory/Localization/CalculusOfFractions/Fractions.lean +++ b/Mathlib/CategoryTheory/Localization/CalculusOfFractions/Fractions.lean @@ -87,7 +87,7 @@ variable {W} for a morphism property `W`. The fact it is an equivalence relation is not formalized, but it would follow easily from `LeftFraction₂.map_eq_iff`. -/ def LeftFraction₂Rel {X Y : C} (z₁ z₂ : W.LeftFraction₂ X Y) : Prop := - ∃ (Z : C) (t₁ : z₁.Y' ⟶ Z) (t₂ : z₂.Y' ⟶ Z) (_ : z₁.s ≫ t₁ = z₂.s ≫ t₂) + ∃ (Z : C) (t₁ : z₁.Y' ⟶ Z) (t₂ : z₂.Y' ⟶ Z) (_ : z₁.s ≫ t₁ = z₂.s ≫ t₂) (_ : z₁.f ≫ t₁ = z₂.f ≫ t₂) (_ : z₁.f' ≫ t₁ = z₂.f' ≫ t₂), W (z₁.s ≫ t₁) namespace LeftFraction₂ diff --git a/Mathlib/CategoryTheory/Localization/DerivabilityStructure/Constructor.lean b/Mathlib/CategoryTheory/Localization/DerivabilityStructure/Constructor.lean index 916c45adea7b8..2adefbca8f183 100644 --- a/Mathlib/CategoryTheory/Localization/DerivabilityStructure/Constructor.lean +++ b/Mathlib/CategoryTheory/Localization/DerivabilityStructure/Constructor.lean @@ -87,7 +87,7 @@ lemma isConnected : refine ⟨RightResolution.mk ρ.w.left ρ.hw.1, ?_⟩ have := zigzag_obj_of_zigzag (fromRightResolution Φ L x ⋙ w.costructuredArrowDownwardsPrecomp x y g fac) - (isPreconnected_zigzag (RightResolution.mk (𝟙 _) (W₂.id_mem _)) + (isPreconnected_zigzag (RightResolution.mk (𝟙 _) (W₂.id_mem _)) (RightResolution.mk ρ.w.right ρ.hw.2)) refine Zigzag.trans ?_ (Zigzag.trans this ?_) · exact Zigzag.of_hom (eqToHom (by aesop)) diff --git a/Mathlib/CategoryTheory/Localization/HasLocalization.lean b/Mathlib/CategoryTheory/Localization/HasLocalization.lean index 4078cb38e28f0..76deb68f57da1 100644 --- a/Mathlib/CategoryTheory/Localization/HasLocalization.lean +++ b/Mathlib/CategoryTheory/Localization/HasLocalization.lean @@ -46,7 +46,7 @@ variable (W : MorphismProperty C) namespace MorphismProperty /-- The data of a localized category with a given universe -for the morphisms. -/ +for the morphisms. -/ class HasLocalization where /-- the objects of the localized category. -/ {D : Type u} diff --git a/Mathlib/CategoryTheory/Localization/Predicate.lean b/Mathlib/CategoryTheory/Localization/Predicate.lean index 0b955a5df9ff8..dd06454204670 100644 --- a/Mathlib/CategoryTheory/Localization/Predicate.lean +++ b/Mathlib/CategoryTheory/Localization/Predicate.lean @@ -369,7 +369,7 @@ lemma compLeft_iso (W) (F : D ⥤ E) : Localization.Lifting.iso L W (L ⋙ F) F /-- Given a localization functor `L : C ⥤ D` for `W : MorphismProperty C`, if `F₁' : D ⥤ E` lifts a functor `F₁ : C ⥤ D`, then a functor `F₂'` which -is isomorphic to `F₁'` also lifts a functor `F₂` that is isomorphic to `F₁`. -/ +is isomorphic to `F₁'` also lifts a functor `F₂` that is isomorphic to `F₁`. -/ @[simps] def ofIsos {F₁ F₂ : C ⥤ E} {F₁' F₂' : D ⥤ E} (e : F₁ ≅ F₂) (e' : F₁' ≅ F₂') [Lifting L W F₁ F₁'] : Lifting L W F₂ F₂' := diff --git a/Mathlib/CategoryTheory/Monad/Adjunction.lean b/Mathlib/CategoryTheory/Monad/Adjunction.lean index f84f4ac8a2247..fa27fe0d27eff 100644 --- a/Mathlib/CategoryTheory/Monad/Adjunction.lean +++ b/Mathlib/CategoryTheory/Monad/Adjunction.lean @@ -73,7 +73,7 @@ def toComonad (h : L ⊣ R) : Comonad D where rw [← L.map_comp] simp -/-- The monad induced by the Eilenberg-Moore adjunction is the original monad. -/ +/-- The monad induced by the Eilenberg-Moore adjunction is the original monad. -/ @[simps!] def adjToMonadIso (T : Monad C) : T.adj.toMonad ≅ T := MonadIso.mk (NatIso.ofComponents fun X => Iso.refl _) @@ -84,7 +84,7 @@ def adjToComonadIso (G : Comonad C) : G.adj.toComonad ≅ G := ComonadIso.mk (NatIso.ofComponents fun X => Iso.refl _) /-- -Given an adjunction `L ⊣ R`, if `L ⋙ R` is abstractly isomorphic to the identity functor, then the +Given an adjunction `L ⊣ R`, if `L ⋙ R` is abstractly isomorphic to the identity functor, then the unit is an isomorphism. -/ def unitAsIsoOfIso (adj : L ⊣ R) (i : L ⋙ R ≅ 𝟭 C) : 𝟭 C ≅ L ⋙ R where @@ -100,11 +100,11 @@ def unitAsIsoOfIso (adj : L ⊣ R) (i : L ⋙ R ≅ 𝟭 C) : 𝟭 C ≅ L ⋙ R ext X exact (adj.toMonad.transport i).right_unit X -lemma isIso_unit_of_iso (adj : L ⊣ R) (i : L ⋙ R ≅ 𝟭 C) : IsIso adj.unit := +lemma isIso_unit_of_iso (adj : L ⊣ R) (i : L ⋙ R ≅ 𝟭 C) : IsIso adj.unit := (inferInstanceAs (IsIso (unitAsIsoOfIso adj i).hom)) /-- -Given an adjunction `L ⊣ R`, if `L ⋙ R` is isomorphic to the identity functor, then `L` is +Given an adjunction `L ⊣ R`, if `L ⋙ R` is isomorphic to the identity functor, then `L` is fully faithful. -/ noncomputable def fullyFaithfulLOfCompIsoId (adj : L ⊣ R) (i : L ⋙ R ≅ 𝟭 C) : L.FullyFaithful := @@ -112,7 +112,7 @@ noncomputable def fullyFaithfulLOfCompIsoId (adj : L ⊣ R) (i : L ⋙ R ≅ adj.fullyFaithfulLOfIsIsoUnit /-- -Given an adjunction `L ⊣ R`, if `R ⋙ L` is abstractly isomorphic to the identity functor, then the +Given an adjunction `L ⊣ R`, if `R ⋙ L` is abstractly isomorphic to the identity functor, then the counit is an isomorphism. -/ def counitAsIsoOfIso (adj : L ⊣ R) (j : R ⋙ L ≅ 𝟭 D) : R ⋙ L ≅ 𝟭 D where @@ -132,7 +132,7 @@ lemma isIso_counit_of_iso (adj : L ⊣ R) (j : R ⋙ L ≅ 𝟭 D) : IsIso adj.c inferInstanceAs (IsIso (counitAsIsoOfIso adj j).hom) /-- -Given an adjunction `L ⊣ R`, if `R ⋙ L` is isomorphic to the identity functor, then `R` is +Given an adjunction `L ⊣ R`, if `R ⋙ L` is isomorphic to the identity functor, then `R` is fully faithful. -/ noncomputable def fullyFaithfulROfCompIsoId (adj : L ⊣ R) (j : R ⋙ L ≅ 𝟭 D) : R.FullyFaithful := diff --git a/Mathlib/CategoryTheory/Monad/Basic.lean b/Mathlib/CategoryTheory/Monad/Basic.lean index 911f458280a80..d50e030211dde 100644 --- a/Mathlib/CategoryTheory/Monad/Basic.lean +++ b/Mathlib/CategoryTheory/Monad/Basic.lean @@ -250,7 +250,7 @@ variable {C} -/ /- Porting note: removed `@[simps (config := { rhsMd := semireducible })]` -and replaced with `@[simps]` in the two declarations below-/ +and replaced with `@[simps]` in the two declarations below -/ @[simps!] def MonadIso.toNatIso {M N : Monad C} (h : M ≅ N) : (M : C ⥤ C) ≅ N := (monadToFunctor C).mapIso h diff --git a/Mathlib/CategoryTheory/Monad/Comonadicity.lean b/Mathlib/CategoryTheory/Monad/Comonadicity.lean index 6097def112e98..7aeb43cea5361 100644 --- a/Mathlib/CategoryTheory/Monad/Comonadicity.lean +++ b/Mathlib/CategoryTheory/Monad/Comonadicity.lean @@ -175,7 +175,7 @@ def unitFork (B : C) : Fork.ofι (adj.unit.app B) (adj.unit_naturality _) variable {adj} in -/-- The counit fork is a limit provided `F` preserves it. -/ +/-- The counit fork is a limit provided `F` preserves it. -/ def counitLimitOfPreservesEqualizer (A : adj.toComonad.Coalgebra) [HasEqualizer (G.map A.a) (adj.unit.app (G.obj A.A))] [PreservesLimit (parallelPair (G.map A.a) (adj.unit.app (G.obj A.A))) F] : diff --git a/Mathlib/CategoryTheory/Monad/Monadicity.lean b/Mathlib/CategoryTheory/Monad/Monadicity.lean index 5890e073e784f..5dbca1937d5e9 100644 --- a/Mathlib/CategoryTheory/Monad/Monadicity.lean +++ b/Mathlib/CategoryTheory/Monad/Monadicity.lean @@ -187,7 +187,7 @@ def counitCofork (B : D) : Cofork.ofπ (adj.counit.app B) (adj.counit_naturality _) variable {adj} in -/-- The unit cofork is a colimit provided `G` preserves it. -/ +/-- The unit cofork is a colimit provided `G` preserves it. -/ def unitColimitOfPreservesCoequalizer (A : adj.toMonad.Algebra) [HasCoequalizer (F.map A.a) (adj.counit.app (F.obj A.A))] [PreservesColimit (parallelPair (F.map A.a) (adj.counit.app (F.obj A.A))) G] : diff --git a/Mathlib/CategoryTheory/MorphismProperty/Basic.lean b/Mathlib/CategoryTheory/MorphismProperty/Basic.lean index 2590d4b476d56..8ec29dea73803 100644 --- a/Mathlib/CategoryTheory/MorphismProperty/Basic.lean +++ b/Mathlib/CategoryTheory/MorphismProperty/Basic.lean @@ -83,7 +83,7 @@ lemma inverseImage_iff (P : MorphismProperty D) (F : C ⥤ D) {X Y : C} (f : X /-- The image (up to isomorphisms) of a `MorphismProperty C` by a functor `C ⥤ D` -/ def map (P : MorphismProperty C) (F : C ⥤ D) : MorphismProperty D := fun _ _ f => - ∃ (X' Y' : C) (f' : X' ⟶ Y') (_ : P f'), Nonempty (Arrow.mk (F.map f') ≅ Arrow.mk f) + ∃ (X' Y' : C) (f' : X' ⟶ Y') (_ : P f'), Nonempty (Arrow.mk (F.map f') ≅ Arrow.mk f) lemma map_mem_map (P : MorphismProperty C) (F : C ⥤ D) {X Y : C} (f : X ⟶ Y) (hf : P f) : (P.map F) (F.map f) := ⟨X, Y, f, hf, ⟨Iso.refl _⟩⟩ diff --git a/Mathlib/CategoryTheory/MorphismProperty/Representable.lean b/Mathlib/CategoryTheory/MorphismProperty/Representable.lean index 7c561da14382d..8bef529600a1b 100644 --- a/Mathlib/CategoryTheory/MorphismProperty/Representable.lean +++ b/Mathlib/CategoryTheory/MorphismProperty/Representable.lean @@ -12,7 +12,7 @@ import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq In this file we define and develop basic results about relatively representable morphisms. -Clasically, a morphism `f : X ⟶ Y` of presheaves is said to be representable if for any morphism +Classically, a morphism `f : X ⟶ Y` of presheaves is said to be representable if for any morphism `g : yoneda.obj X ⟶ G`, there exists a pullback square of the following form ``` yoneda.obj Y --yoneda.map snd--> yoneda.obj X diff --git a/Mathlib/CategoryTheory/Opposites.lean b/Mathlib/CategoryTheory/Opposites.lean index 8f3c692708837..901fde4a2fdcc 100644 --- a/Mathlib/CategoryTheory/Opposites.lean +++ b/Mathlib/CategoryTheory/Opposites.lean @@ -102,7 +102,7 @@ def unopUnop : Cᵒᵖᵒᵖ ⥤ C where obj X := unop (unop X) map f := f.unop.unop -/-- The functor from a category to its double-opposite. -/ +/-- The functor from a category to its double-opposite. -/ @[simps] def opOp : C ⥤ Cᵒᵖᵒᵖ where obj X := op (op X) diff --git a/Mathlib/CategoryTheory/Preadditive/Projective.lean b/Mathlib/CategoryTheory/Preadditive/Projective.lean index 8059a72c9ca40..6cf35147c2231 100644 --- a/Mathlib/CategoryTheory/Preadditive/Projective.lean +++ b/Mathlib/CategoryTheory/Preadditive/Projective.lean @@ -6,9 +6,8 @@ Authors: Markus Himmel, Scott Morrison import Mathlib.CategoryTheory.Adjunction.FullyFaithful import Mathlib.CategoryTheory.Adjunction.Limits import Mathlib.CategoryTheory.Limits.Constructions.EpiMono -import Mathlib.CategoryTheory.Limits.Shapes.Biproducts import Mathlib.CategoryTheory.Limits.Preserves.Finite -import Mathlib.CategoryTheory.Limits.Constructions.EpiMono +import Mathlib.CategoryTheory.Limits.Shapes.Biproducts /-! # Projective objects and categories with enough projectives diff --git a/Mathlib/CategoryTheory/Products/Unitor.lean b/Mathlib/CategoryTheory/Products/Unitor.lean index f436f1074f993..7cb26c8bc22cf 100644 --- a/Mathlib/CategoryTheory/Products/Unitor.lean +++ b/Mathlib/CategoryTheory/Products/Unitor.lean @@ -42,7 +42,7 @@ def rightInverseUnitor : C ⥤ C × Discrete (PUnit : Type w) where obj X := ⟨X, ⟨PUnit.unit⟩⟩ map f := ⟨f, 𝟙 _⟩ -/-- The equivalence of categories expressing left unity of products of categories. -/ +/-- The equivalence of categories expressing left unity of products of categories. -/ @[simps] def leftUnitorEquivalence : Discrete (PUnit : Type w) × C ≌ C where functor := leftUnitor C @@ -50,7 +50,7 @@ def leftUnitorEquivalence : Discrete (PUnit : Type w) × C ≌ C where unitIso := Iso.refl _ counitIso := Iso.refl _ -/-- The equivalence of categories expressing right unity of products of categories. -/ +/-- The equivalence of categories expressing right unity of products of categories. -/ @[simps] def rightUnitorEquivalence : C × Discrete (PUnit : Type w) ≌ C where functor := rightUnitor C diff --git a/Mathlib/CategoryTheory/Shift/Localization.lean b/Mathlib/CategoryTheory/Shift/Localization.lean index f95e143399495..5e9f9b7a925b5 100644 --- a/Mathlib/CategoryTheory/Shift/Localization.lean +++ b/Mathlib/CategoryTheory/Shift/Localization.lean @@ -90,7 +90,7 @@ noncomputable def Functor.CommShift.localized : attribute [irreducible] HasShift.localized Functor.CommShift.localized -/-- The localized category `W.Localization` is endowed with the induced shift. -/ +/-- The localized category `W.Localization` is endowed with the induced shift. -/ noncomputable instance HasShift.localization : HasShift W.Localization A := HasShift.localized W.Q W A @@ -104,7 +104,7 @@ attribute [irreducible] HasShift.localization MorphismProperty.commShift_Q variable [W.HasLocalization] -/-- The localized category `W.Localization'` is endowed with the induced shift. -/ +/-- The localized category `W.Localization'` is endowed with the induced shift. -/ noncomputable instance HasShift.localization' : HasShift W.Localization' A := HasShift.localized W.Q' W A @@ -165,7 +165,7 @@ end commShiftOfLocalization /-- In the context of localization of categories, if a functor is induced by a functor which commutes with the shift, then -this functor commutes with the shift. -/ +this functor commutes with the shift. -/ noncomputable def commShiftOfLocalization : F'.CommShift A where iso := commShiftOfLocalization.iso L W F F' zero := by diff --git a/Mathlib/CategoryTheory/Shift/ShiftedHom.lean b/Mathlib/CategoryTheory/Shift/ShiftedHom.lean index 9df10e3410095..09bea544345c6 100644 --- a/Mathlib/CategoryTheory/Shift/ShiftedHom.lean +++ b/Mathlib/CategoryTheory/Shift/ShiftedHom.lean @@ -28,7 +28,7 @@ variable {C : Type*} [Category C] {D : Type*} [Category D] {E : Type*} [Category {M : Type*} [AddMonoid M] [HasShift C M] [HasShift D M] [HasShift E M] /-- In a category `C` equipped with a shift by an additive monoid, -this is the type of morphisms `X ⟶ (Y⟦n⟧)` for `m : M`. -/ +this is the type of morphisms `X ⟶ (Y⟦n⟧)` for `m : M`. -/ def ShiftedHom (X Y : C) (m : M) : Type _ := X ⟶ (Y⟦m⟧) instance [Preadditive C] (X Y : C) (n : M) : AddCommGroup (ShiftedHom X Y n) := by diff --git a/Mathlib/CategoryTheory/Sites/Adjunction.lean b/Mathlib/CategoryTheory/Sites/Adjunction.lean index a2aa3e4aa6b95..a3eb2ee7ed1ea 100644 --- a/Mathlib/CategoryTheory/Sites/Adjunction.lean +++ b/Mathlib/CategoryTheory/Sites/Adjunction.lean @@ -80,7 +80,6 @@ def adjunction [HasWeakSheafify J D] [HasSheafCompose J F] (adj : G ⊣ F) : ext dsimp [composeEquiv] erw [Adjunction.homEquiv_unit, Adjunction.homEquiv_unit] - dsimp simp } instance [HasWeakSheafify J D] [F.IsRightAdjoint] : (sheafCompose J F).IsRightAdjoint := diff --git a/Mathlib/CategoryTheory/Sites/Coherent/Comparison.lean b/Mathlib/CategoryTheory/Sites/Coherent/Comparison.lean index 7c93c78272de3..f0f439fb8e122 100644 --- a/Mathlib/CategoryTheory/Sites/Coherent/Comparison.lean +++ b/Mathlib/CategoryTheory/Sites/Coherent/Comparison.lean @@ -78,9 +78,9 @@ theorem extensive_regular_generate_coherent [Preregular C] [FinitaryPreExtensive Set.mem_setOf_eq] exact Or.inr ⟨_, Sigma.desc f, ⟨rfl, inferInstance⟩⟩ · rintro R g ⟨W, ψ, σ, ⟨⟩, rfl⟩ - change _ ∈ sieves ((extensiveCoverage C) ⊔ (regularCoverage C)).toGrothendieck _ + change _ ∈ ((extensiveCoverage C) ⊔ (regularCoverage C)).toGrothendieck _ R rw [Sieve.pullback_comp] - apply pullback_stable' + apply pullback_stable have : generate (Presieve.ofArrows X fun (i : I) ↦ Sigma.ι X i) ≤ (generate (Presieve.ofArrows X f)).pullback (Sigma.desc f) := by rintro Q q ⟨E, e, r, ⟨hq, rfl⟩⟩ diff --git a/Mathlib/CategoryTheory/Sites/Coherent/Equivalence.lean b/Mathlib/CategoryTheory/Sites/Coherent/Equivalence.lean index e66a91cfd4c63..edc55d2e3f01e 100644 --- a/Mathlib/CategoryTheory/Sites/Coherent/Equivalence.lean +++ b/Mathlib/CategoryTheory/Sites/Coherent/Equivalence.lean @@ -9,7 +9,7 @@ import Mathlib.CategoryTheory.Sites.Equivalence # Coherence and equivalence of categories -This file proves that the coherent and regular topologies transfer nicely along equivalences of +This file proves that the coherent and regular topologies transfer nicely along equivalences of categories. -/ @@ -27,7 +27,7 @@ section Coherent variable [Precoherent C] -/-- `Precoherent` is preserved by equivalence of categories. -/ +/-- `Precoherent` is preserved by equivalence of categories. -/ theorem precoherent (e : C ≌ D) : Precoherent D := e.inverse.reflects_precoherent instance [EssentiallySmall C] : @@ -75,7 +75,7 @@ section Regular variable [Preregular C] -/-- `Preregular` is preserved by equivalence of categories. -/ +/-- `Preregular` is preserved by equivalence of categories. -/ theorem preregular (e : C ≌ D) : Preregular D := e.inverse.reflects_preregular instance [EssentiallySmall C] : diff --git a/Mathlib/CategoryTheory/Sites/Coherent/ExtensiveSheaves.lean b/Mathlib/CategoryTheory/Sites/Coherent/ExtensiveSheaves.lean index 4030384a506a2..ae209ddc24c1e 100644 --- a/Mathlib/CategoryTheory/Sites/Coherent/ExtensiveSheaves.lean +++ b/Mathlib/CategoryTheory/Sites/Coherent/ExtensiveSheaves.lean @@ -62,7 +62,7 @@ instance {α : Type} [Finite α] (Z : α → C) : (ofArrows Z (fun i ↦ Sigma. /-- Every Yoneda-presheaf is a sheaf for the extensive topology. -/ theorem extensiveTopology.isSheaf_yoneda_obj (W : C) : Presieve.IsSheaf (extensiveTopology C) (yoneda.obj W) := by - erw [isSheaf_coverage] + rw [extensiveTopology, isSheaf_coverage] intro X R ⟨Y, α, Z, π, hR, hi⟩ have : IsIso (Sigma.desc (Cofan.inj (Cofan.mk X π))) := hi have : R.Extensive := ⟨Y, α, Z, π, hR, ⟨Cofan.isColimitOfIsIsoSigmaDesc (Cofan.mk X π)⟩⟩ @@ -75,19 +75,19 @@ theorem extensiveTopology.subcanonical : Sheaf.Subcanonical (extensiveTopology C variable [FinitaryExtensive C] /-- -A presheaf of sets on a category which is `FinitaryExtensive` is a sheaf iff it preserves finite +A presheaf of sets on a category which is `FinitaryExtensive` is a sheaf iff it preserves finite products. -/ theorem Presieve.isSheaf_iff_preservesFiniteProducts (F : Cᵒᵖ ⥤ Type w) : Presieve.IsSheaf (extensiveTopology C) F ↔ Nonempty (PreservesFiniteProducts F) := by refine ⟨fun hF ↦ ⟨⟨fun α _ ↦ ⟨fun {K} ↦ ?_⟩⟩⟩, fun hF ↦ ?_⟩ - · erw [Presieve.isSheaf_coverage] at hF + · rw [extensiveTopology, isSheaf_coverage] at hF let Z : α → C := fun i ↦ unop (K.obj ⟨i⟩) - have : (Presieve.ofArrows Z (Cofan.mk (∐ Z) (Sigma.ι Z)).inj).hasPullbacks := - (inferInstance : (Presieve.ofArrows Z (Sigma.ι Z)).hasPullbacks) + have : (ofArrows Z (Cofan.mk (∐ Z) (Sigma.ι Z)).inj).hasPullbacks := + inferInstanceAs (ofArrows Z (Sigma.ι Z)).hasPullbacks have : ∀ (i : α), Mono (Cofan.inj (Cofan.mk (∐ Z) (Sigma.ι Z)) i) := - (inferInstance : ∀ (i : α), Mono (Sigma.ι Z i)) + inferInstanceAs <| ∀ (i : α), Mono (Sigma.ι Z i) let i : K ≅ Discrete.functor (fun i ↦ op (Z i)) := Discrete.natIsoFunctor let _ : PreservesLimit (Discrete.functor (fun i ↦ op (Z i))) F := Presieve.preservesProductOfIsSheafFor F ?_ initialIsInitial _ (coproductIsCoproduct Z) @@ -104,14 +104,14 @@ theorem Presieve.isSheaf_iff_preservesFiniteProducts (F : Cᵒᵖ ⥤ Type w) : ext simp · let _ := hF.some - erw [Presieve.isSheaf_coverage] + rw [extensiveTopology, Presieve.isSheaf_coverage] intro X R ⟨Y, α, Z, π, hR, hi⟩ have : IsIso (Sigma.desc (Cofan.inj (Cofan.mk X π))) := hi have : R.Extensive := ⟨Y, α, Z, π, hR, ⟨Cofan.isColimitOfIsIsoSigmaDesc (Cofan.mk X π)⟩⟩ exact isSheafFor_extensive_of_preservesFiniteProducts R F /-- -A presheaf on a category which is `FinitaryExtensive` is a sheaf iff it preserves finite products. +A presheaf on a category which is `FinitaryExtensive` is a sheaf iff it preserves finite products. -/ theorem Presheaf.isSheaf_iff_preservesFiniteProducts (F : Cᵒᵖ ⥤ D) : IsSheaf (extensiveTopology C) F ↔ Nonempty (PreservesFiniteProducts F) := by diff --git a/Mathlib/CategoryTheory/Sites/Coherent/ExtensiveTopology.lean b/Mathlib/CategoryTheory/Sites/Coherent/ExtensiveTopology.lean index 0cf8285a9167f..1f7872d648175 100644 --- a/Mathlib/CategoryTheory/Sites/Coherent/ExtensiveTopology.lean +++ b/Mathlib/CategoryTheory/Sites/Coherent/ExtensiveTopology.lean @@ -53,7 +53,8 @@ lemma extensiveTopology.mem_sieves_iff_contains_colimit_cofan {X : C} (S : Sieve apply (extensiveCoverage C).mem_toGrothendieck_sieves_of_superset (R := Presieve.ofArrows Y π) · exact fun _ _ hh ↦ by cases hh; exact h' _ · refine ⟨α, inferInstance, Y, π, rfl, ?_⟩ - erw [Limits.Cofan.isColimit_iff_isIso_sigmaDesc (c := Cofan.mk X π)] + rw [show IsIso (Sigma.desc π) ↔ _ from + Limits.Cofan.isColimit_iff_isIso_sigmaDesc (c := Cofan.mk X π)] exact h end CategoryTheory diff --git a/Mathlib/CategoryTheory/Sites/Coherent/LocallySurjective.lean b/Mathlib/CategoryTheory/Sites/Coherent/LocallySurjective.lean index ef1204a732163..3a79842c88fc9 100644 --- a/Mathlib/CategoryTheory/Sites/Coherent/LocallySurjective.lean +++ b/Mathlib/CategoryTheory/Sites/Coherent/LocallySurjective.lean @@ -16,14 +16,14 @@ and extensive topologies. ## Main results * `regularTopology.isLocallySurjective_iff` A morphism of presheaves `f : F ⟶ G` is locally - surjective for the regular topology iff for every object `X` of `C`, and every `y : G(X)`, there - is an effective epimorphism `φ : X' ⟶ X` and an `x : F(X)` such that `f_{X'}(x) = G(φ)(y)`. + surjective for the regular topology iff for every object `X` of `C`, and every `y : G(X)`, there + is an effective epimorphism `φ : X' ⟶ X` and an `x : F(X)` such that `f_{X'}(x) = G(φ)(y)`. * `coherentTopology.isLocallySurjective_iff` a morphism of sheaves for the coherent topology on a preregular finitary extensive category is locally surjective if and only if it is locally surjective for the regular topology. -* `extensiveTopology.isLocallySurjective_iff` a morphism of sheaves for the extensive topology on a +* `extensiveTopology.isLocallySurjective_iff` a morphism of sheaves for the extensive topology on a finitary extensive category is locally surjective iff it is objectwise surjective. -/ @@ -78,9 +78,9 @@ lemma extensiveTopology.surjective_of_isLocallySurjective_sheafOfTypes [Finitary Cofan.mk_ι_app] have : f.app ⟨Y a⟩ (y a) = G.map (π a).op x := (h' a).choose_spec change _ = G.map (π a).op x - erw [← this, ← NatTrans.naturality_apply (φ := f)] - apply congrArg - change (i.hom ≫ F.map (π a).op) y = _ + rw [← this] + erw [← NatTrans.naturality_apply (φ := f)] + change f.app _ ((i.hom ≫ F.map (π a).op) y) = _ erw [IsLimit.map_π] rfl diff --git a/Mathlib/CategoryTheory/Sites/Coherent/ReflectsPrecoherent.lean b/Mathlib/CategoryTheory/Sites/Coherent/ReflectsPrecoherent.lean index a42e9b7bca302..54bc130f05abb 100644 --- a/Mathlib/CategoryTheory/Sites/Coherent/ReflectsPrecoherent.lean +++ b/Mathlib/CategoryTheory/Sites/Coherent/ReflectsPrecoherent.lean @@ -11,8 +11,8 @@ import Mathlib.CategoryTheory.Sites.Coherent.CoherentTopology # Reflecting the property of being precoherent We prove that given a fully faithful functor `F : C ⥤ D` which preserves and reflects finite -effective epimorphic families, such that for every object `X` of `D` there exists an object `W` of -`C` with an effective epi `π : F.obj W ⟶ X`, the category `C` is `Precoherent` whenever `D` is. +effective epimorphic families, such that for every object `X` of `D` there exists an object `W` of +`C` with an effective epi `π : F.obj W ⟶ X`, the category `C` is `Precoherent` whenever `D` is. -/ namespace CategoryTheory diff --git a/Mathlib/CategoryTheory/Sites/Coherent/ReflectsPreregular.lean b/Mathlib/CategoryTheory/Sites/Coherent/ReflectsPreregular.lean index 9b3784170505c..58eef6dd8e4c3 100644 --- a/Mathlib/CategoryTheory/Sites/Coherent/ReflectsPreregular.lean +++ b/Mathlib/CategoryTheory/Sites/Coherent/ReflectsPreregular.lean @@ -11,8 +11,8 @@ import Mathlib.CategoryTheory.Sites.Coherent.RegularTopology # Reflecting the property of being preregular We prove that given a fully faithful functor `F : C ⥤ D`, with `Preregular D`, such that for every -object `X` of `D` there exists an object `W` of `C` with an effective epi `π : F.obj W ⟶ X`, the -category `C` is `Preregular`. +object `X` of `D` there exists an object `W` of `C` with an effective epi `π : F.obj W ⟶ X`, the +category `C` is `Preregular`. -/ namespace CategoryTheory diff --git a/Mathlib/CategoryTheory/Sites/Coherent/RegularSheaves.lean b/Mathlib/CategoryTheory/Sites/Coherent/RegularSheaves.lean index 8292e7e2fadb1..e310d8b283782 100644 --- a/Mathlib/CategoryTheory/Sites/Coherent/RegularSheaves.lean +++ b/Mathlib/CategoryTheory/Sites/Coherent/RegularSheaves.lean @@ -17,7 +17,7 @@ This file characterises sheaves for the regular topology. ## Main results -* `equalizerCondition_iff_isSheaf`: In a preregular category with pullbacks, the sheaves for the +* `equalizerCondition_iff_isSheaf`: In a preregular category with pullbacks, the sheaves for the regular topology are precisely the presheaves satisfying an equaliser condition with respect to effective epimorphisms. @@ -46,7 +46,7 @@ lemma equalizerCondition_w (P : Cᵒᵖ ⥤ D) {X B : C} {π : X ⟶ B} (c : Pul simp only [← Functor.map_comp, ← op_comp, c.condition] /-- -A contravariant functor on `C` satisfies `SingleEqualizerCondition` with respect to a morphism `π` +A contravariant functor on `C` satisfies `SingleEqualizerCondition` with respect to a morphism `π` if it takes its kernel pair to an equalizer diagram. -/ def SingleEqualizerCondition (P : Cᵒᵖ ⥤ D) ⦃X B : C⦄ (π : X ⟶ B) : Prop := @@ -54,7 +54,7 @@ def SingleEqualizerCondition (P : Cᵒᵖ ⥤ D) ⦃X B : C⦄ (π : X ⟶ B) : Nonempty (IsLimit (Fork.ofι (P.map π.op) (equalizerCondition_w P c))) /-- -A contravariant functor on `C` satisfies `EqualizerCondition` if it takes kernel pairs of effective +A contravariant functor on `C` satisfies `EqualizerCondition` if it takes kernel pairs of effective epimorphisms to equalizer diagrams. -/ def EqualizerCondition (P : Cᵒᵖ ⥤ D) : Prop := @@ -148,7 +148,7 @@ theorem equalizerCondition_iff_isIso_lift (P : Cᵒᵖ ⥤ Type*) : EqualizerCon rw [mapToEqualizer_eq_comp, ← isIso_iff_bijective] infer_instance -/-- `P` satisfies the equalizer condition iff its precomposition by an equivalence does. -/ +/-- `P` satisfies the equalizer condition iff its precomposition by an equivalence does. -/ theorem equalizerCondition_iff_of_equivalence (P : Cᵒᵖ ⥤ D) (e : C ≌ E) : EqualizerCondition P ↔ EqualizerCondition (e.op.inverse ⋙ P) := ⟨fun h ↦ equalizerCondition_precomp_of_preservesPullback P e.inverse h, fun h ↦ @@ -177,7 +177,7 @@ theorem parallelPair_pullback_initial {X B : C} (π : X ⟶ B) all_goals exact Comma.hom_ext _ _ (by erw [Over.comp_left]; simp [ij]) rfl /-- -Given a limiting pullback cone, the fork in `SingleEqualizerCondition` is limiting iff the diagram +Given a limiting pullback cone, the fork in `SingleEqualizerCondition` is limiting iff the diagram in `Presheaf.isSheaf_iff_isLimit_coverage` is limiting. -/ noncomputable def isLimit_forkOfι_equiv (P : Cᵒᵖ ⥤ D) {X B : C} (π : X ⟶ B) diff --git a/Mathlib/CategoryTheory/Sites/Coherent/SheafComparison.lean b/Mathlib/CategoryTheory/Sites/Coherent/SheafComparison.lean index 8807986a7a2ee..7f2817071b11a 100644 --- a/Mathlib/CategoryTheory/Sites/Coherent/SheafComparison.lean +++ b/Mathlib/CategoryTheory/Sites/Coherent/SheafComparison.lean @@ -14,9 +14,9 @@ import Mathlib.CategoryTheory.Sites.Whiskering # Categories of coherent sheaves Given a fully faithful functor `F : C ⥤ D` into a precoherent category, which preserves and reflects -finite effective epi families, and satisfies the property `F.EffectivelyEnough` (meaning that to +finite effective epi families, and satisfies the property `F.EffectivelyEnough` (meaning that to every object in `C` there is an effective epi from an object in the image of `F`), the categories -of coherent sheaves on `C` and `D` are equivalent (see +of coherent sheaves on `C` and `D` are equivalent (see `CategoryTheory.coherentTopology.equivalence`). The main application of this equivalence is the characterisation of condensed sets as coherent @@ -101,7 +101,7 @@ variable {C : Type u₁} {D : Type u₂} [Category.{v₁} C] [Category.{v₂} D] /-- The equivalence from coherent sheaves on `C` to coherent sheaves on `D`, given a fully faithful -functor `F : C ⥤ D` to a precoherent category, which preserves and reflects effective epimorphic +functor `F : C ⥤ D` to a precoherent category, which preserves and reflects effective epimorphic families, and satisfies `F.EffectivelyEnough`. -/ noncomputable @@ -124,7 +124,7 @@ variable {C : Type u₁} {D : Type u₂} [Category.{v₁} C] [Category.{v₂} D] /-- The equivalence from coherent sheaves on `C` to coherent sheaves on `D`, given a fully faithful -functor `F : C ⥤ D` to an extensive preregular category, which preserves and reflects effective +functor `F : C ⥤ D` to an extensive preregular category, which preserves and reflects effective epimorphisms and satisfies `F.EffectivelyEnough`. -/ noncomputable @@ -197,7 +197,7 @@ variable {C : Type u₁} {D : Type u₂} [Category.{v₁} C] [Category.{v₂} D] /-- The equivalence from regular sheaves on `C` to regular sheaves on `D`, given a fully faithful -functor `F : C ⥤ D` to a preregular category, which preserves and reflects effective +functor `F : C ⥤ D` to a preregular category, which preserves and reflects effective epimorphisms and satisfies `F.EffectivelyEnough`. -/ noncomputable @@ -246,7 +246,7 @@ theorem isSheaf_iff_extensiveSheaf_of_projective [Preregular C] [FinitaryExtensi rw [isSheaf_iff_preservesFiniteProducts_of_projective, isSheaf_iff_preservesFiniteProducts] /-- -The categories of coherent sheaves and extensive sheaves on `C` are equivalent if `C` is +The categories of coherent sheaves and extensive sheaves on `C` are equivalent if `C` is preregular, finitary extensive, and every object is projective. -/ @[simps] diff --git a/Mathlib/CategoryTheory/Sites/CompatiblePlus.lean b/Mathlib/CategoryTheory/Sites/CompatiblePlus.lean index df5b4c90f4608..602fb9363514a 100644 --- a/Mathlib/CategoryTheory/Sites/CompatiblePlus.lean +++ b/Mathlib/CategoryTheory/Sites/CompatiblePlus.lean @@ -96,7 +96,7 @@ def plusCompIso : J.plusObj P ⋙ F ≅ J.plusObj (P ⋙ F) := ext dsimp simp only [Category.assoc] - erw [Multiequalizer.lift_ι, diagramCompIso_hom_ι, diagramCompIso_hom_ι, ← F.map_comp, + rw [Multiequalizer.lift_ι, diagramCompIso_hom_ι, diagramCompIso_hom_ι, ← F.map_comp, Multiequalizer.lift_ι]) @[reassoc (attr := simp)] diff --git a/Mathlib/CategoryTheory/Sites/ConcreteSheafification.lean b/Mathlib/CategoryTheory/Sites/ConcreteSheafification.lean index 3bff65deb65b1..8d46116dc8326 100644 --- a/Mathlib/CategoryTheory/Sites/ConcreteSheafification.lean +++ b/Mathlib/CategoryTheory/Sites/ConcreteSheafification.lean @@ -153,7 +153,8 @@ theorem res_mk_eq_mk_pullback {Y X : C} {P : Cᵒᵖ ⥤ D} {S : J.Cover X} (x : ext i simp only [Functor.op_obj, unop_op, pullback_obj, diagram_obj, Functor.comp_obj, diagramPullback_app, Meq.equiv_apply, Meq.pullback_apply] - erw [← comp_apply, Multiequalizer.lift_ι, Meq.equiv_symm_eq_apply] + rw [← comp_apply, Multiequalizer.lift_ι] + erw [Meq.equiv_symm_eq_apply] cases i; rfl theorem toPlus_mk {X : C} {P : Cᵒᵖ ⥤ D} (S : J.Cover X) (x : P.obj (op X)) : @@ -162,7 +163,8 @@ theorem toPlus_mk {X : C} {P : Cᵒᵖ ⥤ D} (S : J.Cover X) (x : P.obj (op X)) let e : S ⟶ ⊤ := homOfLE (OrderTop.le_top _) rw [← colimit.w _ e.op] delta Cover.toMultiequalizer - erw [comp_apply, comp_apply] + rw [comp_apply] + erw [comp_apply] apply congr_arg dsimp [diagram] apply Concrete.multiequalizer_ext @@ -347,7 +349,7 @@ theorem exists_of_sep (P : Cᵒᵖ ⥤ D) use mk w ext I dsimp [Meq.mk] - erw [ht, res_mk_eq_mk_pullback] + rw [ht, res_mk_eq_mk_pullback] -- Use the separatedness of `P⁺` to prove that this is indeed a gluing of our -- original local sections. apply sep P (T I) diff --git a/Mathlib/CategoryTheory/Sites/ConstantSheaf.lean b/Mathlib/CategoryTheory/Sites/ConstantSheaf.lean index 1fa5ab155f92b..6109b2798594a 100644 --- a/Mathlib/CategoryTheory/Sites/ConstantSheaf.lean +++ b/Mathlib/CategoryTheory/Sites/ConstantSheaf.lean @@ -39,7 +39,7 @@ noncomputable def constantPresheafAdj {T : C} (hT : IsTerminal T) : variable [HasWeakSheafify J D] /-- -The functor which maps an object of `D` to the constant sheaf at that object, i.e. the +The functor which maps an object of `D` to the constant sheaf at that object, i.e. the sheafification of the constant presheaf. -/ noncomputable def constantSheaf : D ⥤ Sheaf J D := Functor.const Cᵒᵖ ⋙ (presheafToSheaf J D) diff --git a/Mathlib/CategoryTheory/Sites/Discrete.lean b/Mathlib/CategoryTheory/Sites/Discrete.lean index 6998b9657e496..2548ba222d4b7 100644 --- a/Mathlib/CategoryTheory/Sites/Discrete.lean +++ b/Mathlib/CategoryTheory/Sites/Discrete.lean @@ -25,7 +25,7 @@ the one element space in `CompHaus`. of the constant sheaf functor. * `isDiscrete_iff_of_equivalence` : The property of a sheaf of being discrete is invariant under equivalence of sheaf categories. -* `isDiscrete_iff_forget` : Given a "forgetful" functor `U : A ⥤ B` a sheaf `F : Sheaf J A` is +* `isDiscrete_iff_forget` : Given a "forgetful" functor `U : A ⥤ B` a sheaf `F : Sheaf J A` is discrete if and only if the sheaf given by postcomposition with `U` is discrete. ## Future work diff --git a/Mathlib/CategoryTheory/Sites/EqualizerSheafCondition.lean b/Mathlib/CategoryTheory/Sites/EqualizerSheafCondition.lean index 1466ccb25979a..44e39a7bba0c9 100644 --- a/Mathlib/CategoryTheory/Sites/EqualizerSheafCondition.lean +++ b/Mathlib/CategoryTheory/Sites/EqualizerSheafCondition.lean @@ -10,7 +10,7 @@ import Mathlib.Tactic.ApplyFun /-! # The equalizer diagram sheaf condition for a presieve -In `Mathlib/CategoryTheory/Sites/IsSheafFor.lean` it is defined what it means for a presheaf to be a +In `Mathlib/CategoryTheory/Sites/IsSheafFor.lean` it is defined what it means for a presheaf to be a sheaf *for* a particular presieve. In this file we provide equivalent conditions in terms of equalizer diagrams. @@ -228,8 +228,8 @@ theorem compatible_iff (x : FirstObj P R) : See . -/ theorem sheaf_condition : R.IsSheafFor P ↔ Nonempty (IsLimit (Fork.ofι _ (w P R))) := by - rw [Types.type_equalizer_iff_unique] - erw [← Equiv.forall_congr_right (firstObjEqFamily P R).toEquiv.symm] + rw [Types.type_equalizer_iff_unique, + ← Equiv.forall_congr_right (firstObjEqFamily P R).toEquiv.symm] simp_rw [← compatible_iff, ← Iso.toEquiv_fun, Equiv.apply_symm_apply] apply forall₂_congr intro x _ @@ -252,7 +252,7 @@ open Presieve variable {B : C} {I : Type} (X : I → C) (π : (i : I) → X i ⟶ B) [(Presieve.ofArrows X π).hasPullbacks] --- TODO: allow `I : Type w`  +-- TODO: allow `I : Type w` /-- The middle object of the fork diagram of . diff --git a/Mathlib/CategoryTheory/Sites/Equivalence.lean b/Mathlib/CategoryTheory/Sites/Equivalence.lean index faf9debefee9f..2408d76270ca3 100644 --- a/Mathlib/CategoryTheory/Sites/Equivalence.lean +++ b/Mathlib/CategoryTheory/Sites/Equivalence.lean @@ -63,7 +63,8 @@ instance (priority := 900) [G.IsEquivalence] : IsCoverDense G J where instance : e.functor.IsDenseSubsite J (e.inverse.inducedTopology J) := by have : J = e.functor.inducedTopology (e.inverse.inducedTopology J) := by ext X S - erw [← GrothendieckTopology.pullback_mem_iff_of_isIso (i := e.unit.app X)] + rw [show S ∈ (e.functor.inducedTopology (e.inverse.inducedTopology J)) X ↔ _ + from (GrothendieckTopology.pullback_mem_iff_of_isIso (i := e.unit.app X)).symm] congr!; ext Y f; simp nth_rw 1 [this] infer_instance diff --git a/Mathlib/CategoryTheory/Sites/IsSheafFor.lean b/Mathlib/CategoryTheory/Sites/IsSheafFor.lean index ccd585a8efb58..136e553138ef3 100644 --- a/Mathlib/CategoryTheory/Sites/IsSheafFor.lean +++ b/Mathlib/CategoryTheory/Sites/IsSheafFor.lean @@ -123,7 +123,7 @@ In special cases, this condition can be simplified, see `pullbackCompatible_iff` This is referred to as a "compatible family" in Definition C2.1.2 of [Elephant], and on nlab: https://ncatlab.org/nlab/show/sheaf#GeneralDefinitionInComponents -For a more explicit version in the case where `R` is of the form `Presieve.ofArrows`, see +For a more explicit version in the case where `R` is of the form `Presieve.ofArrows`, see `CategoryTheory.Presieve.Arrows.Compatible`. -/ def FamilyOfElements.Compatible (x : FamilyOfElements P R) : Prop := @@ -142,7 +142,7 @@ Equation (5). Viewing the type `FamilyOfElements` as the middle object of the fo https://stacks.math.columbia.edu/tag/00VM, this condition expresses that `pr₀* (x) = pr₁* (x)`, using the notation defined there. -For a more explicit version in the case where `R` is of the form `Presieve.ofArrows`, see +For a more explicit version in the case where `R` is of the form `Presieve.ofArrows`, see `CategoryTheory.Presieve.Arrows.PullbackCompatible`. -/ def FamilyOfElements.PullbackCompatible (x : FamilyOfElements P R) [R.hasPullbacks] : Prop := @@ -663,7 +663,7 @@ section Arrows variable {B : C} {I : Type*} {X : I → C} (π : (i : I) → X i ⟶ B) (P) /-- -A more explicit version of `FamilyOfElements.Compatible` for a `Presieve.ofArrows`. +A more explicit version of `FamilyOfElements.Compatible` for a `Presieve.ofArrows`. -/ def Arrows.Compatible (x : (i : I) → P.obj (op (X i))) : Prop := ∀ i j Z (gi : Z ⟶ X i) (gj : Z ⟶ X j), gi ≫ π i = gj ≫ π j → @@ -720,7 +720,7 @@ theorem isSheafFor_arrows_iff : (ofArrows X π).IsSheafFor P ↔ variable [(ofArrows X π).hasPullbacks] /-- -A more explicit version of `FamilyOfElements.PullbackCompatible` for a `Presieve.ofArrows`. +A more explicit version of `FamilyOfElements.PullbackCompatible` for a `Presieve.ofArrows`. -/ def Arrows.PullbackCompatible (x : (i : I) → P.obj (op (X i))) : Prop := ∀ i j, P.map (pullback.fst (π i) (π j)).op (x i) = diff --git a/Mathlib/CategoryTheory/Sites/LeftExact.lean b/Mathlib/CategoryTheory/Sites/LeftExact.lean index c975c71f51e0c..d12346e4674e9 100644 --- a/Mathlib/CategoryTheory/Sites/LeftExact.lean +++ b/Mathlib/CategoryTheory/Sites/LeftExact.lean @@ -255,15 +255,15 @@ instance preservesfiniteLimits_presheafToSheaf [HasFiniteLimits D] : variable (J D) -/-- `plusPlusSheaf` is isomorphic to an arbitrary choice of left adjoint. -/ +/-- `plusPlusSheaf` is isomorphic to an arbitrary choice of left adjoint. -/ def plusPlusSheafIsoPresheafToSheaf : plusPlusSheaf J D ≅ presheafToSheaf J D := (plusPlusAdjunction J D).leftAdjointUniq (sheafificationAdjunction J D) -/-- `plusPlusFunctor` is isomorphic to `sheafification`. -/ +/-- `plusPlusFunctor` is isomorphic to `sheafification`. -/ def plusPlusFunctorIsoSheafification : J.sheafification D ≅ sheafification J D := isoWhiskerRight (plusPlusSheafIsoPresheafToSheaf J D) (sheafToPresheaf J D) -/-- `plusPlus` is isomorphic to `sheafify`. -/ +/-- `plusPlus` is isomorphic to `sheafify`. -/ def plusPlusIsoSheafify (P : Cᵒᵖ ⥤ D) : J.sheafify P ≅ sheafify J P := (sheafToPresheaf J D).mapIso ((plusPlusSheafIsoPresheafToSheaf J D).app P) diff --git a/Mathlib/CategoryTheory/Sites/Limits.lean b/Mathlib/CategoryTheory/Sites/Limits.lean index d85824a7edd78..1c38d0e033185 100644 --- a/Mathlib/CategoryTheory/Sites/Limits.lean +++ b/Mathlib/CategoryTheory/Sites/Limits.lean @@ -107,7 +107,7 @@ def isLimitMultiforkOfIsLimit (F : K ⥤ Sheaf J D) (E : Cone (F ⋙ sheafToPres erw [(isLimitOfPreserves ((evaluation Cᵒᵖ D).obj (op X)) hE).fac (multiforkEvaluationCone F E X W S)] dsimp [multiforkEvaluationCone, Presheaf.isLimitOfIsSheaf] - erw [Presheaf.IsSheaf.amalgamate_map] + rw [Presheaf.IsSheaf.amalgamate_map] rfl) (by intro S m hm diff --git a/Mathlib/CategoryTheory/Sites/LocallyInjective.lean b/Mathlib/CategoryTheory/Sites/LocallyInjective.lean index a537edefc713a..782d1b84f0591 100644 --- a/Mathlib/CategoryTheory/Sites/LocallyInjective.lean +++ b/Mathlib/CategoryTheory/Sites/LocallyInjective.lean @@ -115,7 +115,7 @@ lemma isLocallyInjective_iff_equalizerSieve_mem_imp : · intro Y f hf refine J.superset_covering (Sieve.le_pullback_bind S.1 T _ hf) (equalizerSieve_mem J φ _ _ ?_) - erw [NatTrans.naturality_apply, NatTrans.naturality_apply] + rw [NatTrans.naturality_apply, NatTrans.naturality_apply] exact hf · intro hφ exact ⟨fun {X} x y h => hφ x y (by simp [h])⟩ @@ -179,7 +179,7 @@ open GrothendieckTopology.Plus instance isLocallyInjective_toPlus (P : Cᵒᵖ ⥤ Type max u v) : IsLocallyInjective J (J.toPlus P) where equalizerSieve_mem {X} x y h := by - erw [toPlus_eq_mk, toPlus_eq_mk, eq_mk_iff_exists] at h + rw [toPlus_eq_mk, toPlus_eq_mk, eq_mk_iff_exists] at h obtain ⟨W, h₁, h₂, eq⟩ := h exact J.superset_covering (fun Y f hf => congr_fun (congr_arg Subtype.val eq) ⟨Y, f, hf⟩) W.2 diff --git a/Mathlib/CategoryTheory/Sites/Plus.lean b/Mathlib/CategoryTheory/Sites/Plus.lean index f8755d25759dd..9fe18afba43ba 100644 --- a/Mathlib/CategoryTheory/Sites/Plus.lean +++ b/Mathlib/CategoryTheory/Sites/Plus.lean @@ -67,24 +67,20 @@ theorem diagramNatTrans_id (X : C) (P : Cᵒᵖ ⥤ D) : J.diagramNatTrans (𝟙 P) X = 𝟙 (J.diagram P X) := by ext : 2 refine Multiequalizer.hom_ext _ _ _ (fun i => ?_) - dsimp - simp only [limit.lift_π, Multifork.ofι_pt, Multifork.ofι_π_app, Category.id_comp] - erw [Category.comp_id] + simp @[simp] theorem diagramNatTrans_zero [Preadditive D] (X : C) (P Q : Cᵒᵖ ⥤ D) : J.diagramNatTrans (0 : P ⟶ Q) X = 0 := by ext : 2 refine Multiequalizer.hom_ext _ _ _ (fun i => ?_) - dsimp - rw [zero_comp, Multiequalizer.lift_ι, comp_zero] + simp @[simp] theorem diagramNatTrans_comp {P Q R : Cᵒᵖ ⥤ D} (η : P ⟶ Q) (γ : Q ⟶ R) (X : C) : J.diagramNatTrans (η ≫ γ) X = J.diagramNatTrans η X ≫ J.diagramNatTrans γ X := by ext : 2 refine Multiequalizer.hom_ext _ _ _ (fun i => ?_) - dsimp simp variable (D) @@ -110,7 +106,7 @@ def plusObj : Cᵒᵖ ⥤ D where simp only [diagramPullback_app, colimit.ι_pre, ι_colimMap_assoc, Category.comp_id] let e := S.unop.pullbackId dsimp only [Functor.op, pullback_obj] - erw [← colimit.w _ e.inv.op, ← Category.assoc] + rw [← colimit.w _ e.inv.op, ← Category.assoc] convert Category.id_comp (colimit.ι (diagram J P (unop X)) S) refine Multiequalizer.hom_ext _ _ _ (fun I => ?_) dsimp @@ -127,7 +123,7 @@ def plusObj : Cᵒᵖ ⥤ D where Category.assoc] let e := S.unop.pullbackComp g.unop f.unop dsimp only [Functor.op, pullback_obj] - erw [← colimit.w _ e.inv.op, ← Category.assoc, ← Category.assoc] + rw [← colimit.w _ e.inv.op, ← Category.assoc, ← Category.assoc] congr 1 refine Multiequalizer.hom_ext _ _ _ (fun I => ?_) dsimp diff --git a/Mathlib/CategoryTheory/Sites/Preserves.lean b/Mathlib/CategoryTheory/Sites/Preserves.lean index c3df3fb2d4af6..233115606bae5 100644 --- a/Mathlib/CategoryTheory/Sites/Preserves.lean +++ b/Mathlib/CategoryTheory/Sites/Preserves.lean @@ -18,14 +18,14 @@ preserve "the corresponding products". More precisely, given a presheaf `F : Cᵒᵖ ⥤ Type*`, we have: * If `F` satisfies the sheaf condition with respect to the empty sieve on the initial object of `C`, - then `F` preserves terminal objects. + then `F` preserves terminal objects. See `preservesTerminalOfIsSheafForEmpty`. -* If `F` furthermore satisfies the sheaf condition with respect to the presieve consisting of the - inclusion arrows in a coproduct in `C`, then `F` preserves the corresponding product. +* If `F` furthermore satisfies the sheaf condition with respect to the presieve consisting of the + inclusion arrows in a coproduct in `C`, then `F` preserves the corresponding product. See `preservesProductOfIsSheafFor`. -* If `F` preserves a product, then it satisfies the sheaf condition with respect to the +* If `F` preserves a product, then it satisfies the sheaf condition with respect to the corresponding presieve of arrows. See `isSheafFor_of_preservesProduct`. -/ @@ -44,8 +44,8 @@ section Terminal variable (I) in /-- -If `F` is a presheaf which satisfies the sheaf condition with respect to the empty presieve on any -object, then `F` takes that object to the terminal object. +If `F` is a presheaf which satisfies the sheaf condition with respect to the empty presieve on any +object, then `F` takes that object to the terminal object. -/ noncomputable def isTerminal_of_isSheafFor_empty_presieve : IsTerminal (F.obj (op I)) := by @@ -54,8 +54,8 @@ def isTerminal_of_isSheafFor_empty_presieve : IsTerminal (F.obj (op I)) := by exact ⟨⟨fun _ ↦ t⟩, fun a ↦ by ext; exact h.2 _ (by tauto)⟩ /-- -If `F` is a presheaf which satisfies the sheaf condition with respect to the empty presieve on the -initial object, then `F` preserves terminal objects. +If `F` is a presheaf which satisfies the sheaf condition with respect to the empty presieve on the +initial object, then `F` preserves terminal objects. -/ noncomputable def preservesTerminalOfIsSheafForEmpty (hI : IsInitial I) : PreservesLimit (Functor.empty Cᵒᵖ) F := diff --git a/Mathlib/CategoryTheory/Sites/Sheaf.lean b/Mathlib/CategoryTheory/Sites/Sheaf.lean index 14f206f8513f1..80f0edcd7ebfb 100644 --- a/Mathlib/CategoryTheory/Sites/Sheaf.lean +++ b/Mathlib/CategoryTheory/Sites/Sheaf.lean @@ -148,7 +148,7 @@ theorem isLimit_iff_isSheafFor : rw [Classical.nonempty_pi]; constructor · intro hu E x hx specialize hu hx.cone - erw [(homEquivAmalgamation hx).uniqueCongr.nonempty_congr] at hu + rw [(homEquivAmalgamation hx).uniqueCongr.nonempty_congr] at hu exact (unique_subtype_iff_exists_unique _).1 hu · rintro h ⟨E, π⟩ let eqv := conesEquivSieveCompatibleFamily P S (op E) @@ -575,7 +575,6 @@ theorem isSheaf_iff_multiequalizer [∀ (X : C) (S : J.Cover X), HasMultiequaliz · intro a symm erw [IsIso.inv_comp_eq] - dsimp simp end MultiequalizerConditions diff --git a/Mathlib/CategoryTheory/Sites/SheafHom.lean b/Mathlib/CategoryTheory/Sites/SheafHom.lean index aeec15f07d717..196eeab7477ac 100644 --- a/Mathlib/CategoryTheory/Sites/SheafHom.lean +++ b/Mathlib/CategoryTheory/Sites/SheafHom.lean @@ -82,7 +82,7 @@ def presheafHomSectionsEquiv : (presheafHom F G).sections ≃ (F ⟶ G) where dsimp refine Eq.trans ?_ ((s.1 ⟨X₁⟩).naturality (Over.homMk f : Over.mk f ⟶ Over.mk (𝟙 X₁)).op) - erw [← s.2 f.op, presheafHom_map_app_op_mk_id] + rw [← s.2 f.op, presheafHom_map_app_op_mk_id] rfl } invFun f := ⟨fun X => whiskerLeft _ f, fun _ => rfl⟩ left_inv s := by @@ -174,7 +174,7 @@ lemma presheafHom_isSheafFor : rintro ⟨Z : Over Y₂.left, hZ⟩ dsimp rw [assoc, assoc, app_cond hG x hx Y₂.hom Z.hom hZ, ← G.map_comp, ← op_comp] - erw [app_cond hG x hx Y₁.hom (Z.hom ≫ φ.left) (by simpa using hZ), + rw [app_cond hG x hx Y₁.hom (Z.hom ≫ φ.left) (by simpa using hZ), ← F.map_comp_assoc, op_comp] congr 3 simp }, ?_⟩ diff --git a/Mathlib/CategoryTheory/Sites/SheafOfTypes.lean b/Mathlib/CategoryTheory/Sites/SheafOfTypes.lean index db8d37ff2bf28..c2d7b20d409ae 100644 --- a/Mathlib/CategoryTheory/Sites/SheafOfTypes.lean +++ b/Mathlib/CategoryTheory/Sites/SheafOfTypes.lean @@ -13,7 +13,7 @@ Defines the notion of a sheaf of types (usually called a sheaf of sets by mathem on a category equipped with a Grothendieck topology, as well as a range of equivalent conditions useful in different situations. -In `Mathlib/CategoryTheory/Sites/IsSheafFor.lean` it is defined what it means for a presheaf to be a +In `Mathlib/CategoryTheory/Sites/IsSheafFor.lean` it is defined what it means for a presheaf to be a sheaf *for* a particular sieve. Given a Grothendieck topology `J`, `P` is a sheaf if it is a sheaf for every sieve in the topology. See `IsSheaf`. diff --git a/Mathlib/CategoryTheory/Sites/Sheafification.lean b/Mathlib/CategoryTheory/Sites/Sheafification.lean index f85396c4e3a8d..409605999eeb7 100644 --- a/Mathlib/CategoryTheory/Sites/Sheafification.lean +++ b/Mathlib/CategoryTheory/Sites/Sheafification.lean @@ -14,7 +14,7 @@ import Mathlib.CategoryTheory.Limits.Preserves.Finite Given a site `(C, J)` we define a typeclass `HasSheafify J A` saying that the inclusion functor from `A`-valued sheaves on `C` to presheaves admits a left exact left adjoint (sheafification). -Note: to access the `HasSheafify` instance for suitable concrete categories, import the file +Note: to access the `HasSheafify` instance for suitable concrete categories, import the file `Mathlib.CategoryTheory.Sites.LeftExact`. -/ @@ -37,7 +37,7 @@ abbrev HasWeakSheafify : Prop := (sheafToPresheaf J A).IsRightAdjoint left adjiont (sheafification). Given a finite limit preserving functor `F : (Cᵒᵖ ⥤ A) ⥤ Sheaf J A` and an adjunction -`adj : F ⊣ sheafToPresheaf J A`, use `HasSheafify.mk'` to construct a `HasSheafify` instance. +`adj : F ⊣ sheafToPresheaf J A`, use `HasSheafify.mk'` to construct a `HasSheafify` instance. -/ class HasSheafify : Prop where isRightAdjoint : HasWeakSheafify J A @@ -141,7 +141,8 @@ theorem isIso_toSheafify {P : Cᵒᵖ ⥤ D} (hP : Presheaf.IsSheaf J P) : IsIso rfl · change (sheafToPresheaf _ _).map _ ≫ _ = _ change _ ≫ (sheafificationAdjunction J D).unit.app ((sheafToPresheaf J D).obj ⟨P, hP⟩) = _ - erw [← (sheafificationAdjunction J D).inv_counit_map (X := ⟨P, hP⟩), comp_inv_eq_id] + rw [← (sheafificationAdjunction J D).inv_counit_map (X := ⟨P, hP⟩)] + simp /-- If `P` is a sheaf, then `P` is isomorphic to `sheafify J P`. -/ noncomputable def isoSheafify {P : Cᵒᵖ ⥤ D} (hP : Presheaf.IsSheaf J P) : P ≅ sheafify J P := diff --git a/Mathlib/CategoryTheory/Sites/Sieves.lean b/Mathlib/CategoryTheory/Sites/Sieves.lean index 149378759550f..0c06b432214bf 100644 --- a/Mathlib/CategoryTheory/Sites/Sieves.lean +++ b/Mathlib/CategoryTheory/Sites/Sieves.lean @@ -82,11 +82,11 @@ theorem bind_comp {S : Presieve X} {R : ∀ ⦃Y : C⦄ ⦃f : Y ⟶ X⦄, S f -- Porting note: it seems the definition of `Presieve` must be unfolded in order to define -- this inductive type, it was thus renamed `singleton'` -- Note we can't make this into `HasSingleton` because of the out-param. -/-- The singleton presieve. -/ +/-- The singleton presieve. -/ inductive singleton' : ⦃Y : C⦄ → (Y ⟶ X) → Prop | mk : singleton' f -/-- The singleton presieve. -/ +/-- The singleton presieve. -/ def singleton : Presieve X := singleton' f lemma singleton.mk {f : Y ⟶ X} : singleton f f := singleton'.mk diff --git a/Mathlib/CategoryTheory/Sites/Subsheaf.lean b/Mathlib/CategoryTheory/Sites/Subsheaf.lean index ac8268e9caf70..3731eadbee58d 100644 --- a/Mathlib/CategoryTheory/Sites/Subsheaf.lean +++ b/Mathlib/CategoryTheory/Sites/Subsheaf.lean @@ -252,7 +252,7 @@ theorem Subpresheaf.sheafify_sheafify (h : Presieve.IsSheaf J F) : (G.sheafify J).sheafify J = G.sheafify J := ((Subpresheaf.eq_sheafify_iff _ h).mpr <| G.sheafify_isSheaf h).symm -/-- The lift of a presheaf morphism onto the sheafification subpresheaf. -/ +/-- The lift of a presheaf morphism onto the sheafification subpresheaf. -/ noncomputable def Subpresheaf.sheafifyLift (f : G.toPresheaf ⟶ F') (h : Presieve.IsSheaf J F') : (G.sheafify J).toPresheaf ⟶ F' where app U s := (h (G.sieveOfSection s.1) s.prop).amalgamate @@ -292,7 +292,7 @@ theorem Subpresheaf.to_sheafify_lift_unique (h : Presieve.IsSheaf J F') apply (h _ hs).isSeparatedFor.ext rintro V i hi dsimp at hi - erw [← FunctorToTypes.naturality, ← FunctorToTypes.naturality] + rw [← FunctorToTypes.naturality, ← FunctorToTypes.naturality] exact (congr_fun (congr_app e <| op V) ⟨_, hi⟩ : _) theorem Subpresheaf.sheafify_le (h : G ≤ G') (hF : Presieve.IsSheaf J F) @@ -305,7 +305,7 @@ theorem Subpresheaf.sheafify_le (h : G ≤ G') (hF : Presieve.IsSheaf J F) congr_arg (fun f : G.toPresheaf ⟶ G'.toPresheaf => (NatTrans.app f (op V) ⟨_, hi⟩).1) (G.to_sheafifyLift (Subpresheaf.homOfLe h) hG') convert this.symm - erw [← Subpresheaf.nat_trans_naturality] + rw [← Subpresheaf.nat_trans_naturality] rfl section Image diff --git a/Mathlib/CategoryTheory/Sites/Whiskering.lean b/Mathlib/CategoryTheory/Sites/Whiskering.lean index f80010696a0b9..17685ddf1e50a 100644 --- a/Mathlib/CategoryTheory/Sites/Whiskering.lean +++ b/Mathlib/CategoryTheory/Sites/Whiskering.lean @@ -129,10 +129,10 @@ instance hasSheafCompose_of_preservesMulticospan (F : A ⥤ B) exact ⟨Limits.IsLimit.postcomposeHomEquiv (S.multicospanComp F P) _ h⟩ /-- -Composing a sheaf with a functor preserving limits of the same size as the hom sets in `C` yields a +Composing a sheaf with a functor preserving limits of the same size as the hom sets in `C` yields a functor between sheaf categories. -Note: the size of the limit that `F` is required to preserve in +Note: the size of the limit that `F` is required to preserve in `hasSheafCompose_of_preservesMulticospan` is in general larger than this. -/ instance hasSheafCompose_of_preservesLimitsOfSize [PreservesLimitsOfSize.{v₁, max u₁ v₁} F] : diff --git a/Mathlib/CategoryTheory/SmallObject/Construction.lean b/Mathlib/CategoryTheory/SmallObject/Construction.lean index 808c18354da20..fe1e1fa4599e9 100644 --- a/Mathlib/CategoryTheory/SmallObject/Construction.lean +++ b/Mathlib/CategoryTheory/SmallObject/Construction.lean @@ -143,7 +143,7 @@ lemma ιFunctorObj_πFunctorObj : ιFunctorObj f πX ≫ πFunctorObj f πX = π /-- The canonical morphism `∐ (functorObjSrcFamily f πX) ⟶ ∐ (functorObjSrcFamily f πY)` induced by a morphism in `φ : X ⟶ Y` such that `φ ≫ πX = πY`. -/ -noncomputable def functorMapSrc (hφ : φ ≫ πY = πX) : +noncomputable def functorMapSrc (hφ : φ ≫ πY = πX) : ∐ (functorObjSrcFamily f πX) ⟶ ∐ functorObjSrcFamily f πY := Sigma.map' (fun x => FunctorObjIndex.mk x.i (x.t ≫ φ) x.b (by simp [hφ])) (fun _ => 𝟙 _) @@ -168,7 +168,7 @@ lemma functorMapSrc_functorObjTop : /-- The canonical morphism `∐ functorObjTgtFamily f πX ⟶ ∐ functorObjTgtFamily f πY` induced by a morphism in `φ : X ⟶ Y` such that `φ ≫ πX = πY`. -/ -noncomputable def functorMapTgt (hφ : φ ≫ πY = πX) : +noncomputable def functorMapTgt (hφ : φ ≫ πY = πX) : ∐ functorObjTgtFamily f πX ⟶ ∐ functorObjTgtFamily f πY := Sigma.map' (fun x => FunctorObjIndex.mk x.i (x.t ≫ φ) x.b (by simp [hφ])) (fun _ => 𝟙 _) diff --git a/Mathlib/CategoryTheory/Sums/Basic.lean b/Mathlib/CategoryTheory/Sums/Basic.lean index b998f1052121e..91a569cf79a16 100644 --- a/Mathlib/CategoryTheory/Sums/Basic.lean +++ b/Mathlib/CategoryTheory/Sums/Basic.lean @@ -31,7 +31,7 @@ section variable (C : Type u₁) [Category.{v₁} C] (D : Type u₁) [Category.{v₁} D] -/- Porting note: `aesop_cat` not firing on `assoc` where autotac in Lean 3 did-/ +/- Porting note: `aesop_cat` not firing on `assoc` where autotac in Lean 3 did -/ /-- `sum C D` gives the direct sum of two categories. -/ diff --git a/Mathlib/CategoryTheory/Widesubcategory.lean b/Mathlib/CategoryTheory/Widesubcategory.lean index 9f60d4fe54f36..e225caffbde77 100644 --- a/Mathlib/CategoryTheory/Widesubcategory.lean +++ b/Mathlib/CategoryTheory/Widesubcategory.lean @@ -83,7 +83,7 @@ Structure for wide subcategories. Objects ignore the morphism property. -/ @[ext, nolint unusedArguments] structure WideSubcategory (_P : MorphismProperty C) [IsMultiplicative _P] where - /-- The category of which this is a wide subcategory-/ + /-- The category of which this is a wide subcategory -/ obj : C instance WideSubcategory.category : Category.{v₁} (WideSubcategory P) := diff --git a/Mathlib/Combinatorics/Colex.lean b/Mathlib/Combinatorics/Colex.lean index 1f8a439741e9c..0d59516a64ae1 100644 --- a/Mathlib/Combinatorics/Colex.lean +++ b/Mathlib/Combinatorics/Colex.lean @@ -197,7 +197,7 @@ lemma toColex_lt_singleton : toColex s < toColex {a} ↔ ∀ b ∈ s, b < a := b · refine h.2 <| eq_singleton_iff_unique_mem.2 ⟨hb, fun c hc ↦ (h.1 _ hc).2 hb⟩ · simp at h -/-- `{a} ≤ s` in colex iff `s` contains an element greated than or equal to `a`. -/ +/-- `{a} ≤ s` in colex iff `s` contains an element greater than or equal to `a`. -/ lemma singleton_le_toColex : (toColex {a} : Colex α) ≤ toColex s ↔ ∃ x ∈ s, a ≤ x := by simp [toColex_le_toColex]; by_cases a ∈ s <;> aesop diff --git a/Mathlib/Combinatorics/Enumerative/Composition.lean b/Mathlib/Combinatorics/Enumerative/Composition.lean index cbe6dc1551920..cd3c84ffbe6b8 100644 --- a/Mathlib/Combinatorics/Enumerative/Composition.lean +++ b/Mathlib/Combinatorics/Enumerative/Composition.lean @@ -112,7 +112,7 @@ structure CompositionAsSet (n : ℕ) where boundaries : Finset (Fin n.succ) /-- Proof that `0` is a member of `boundaries`-/ zero_mem : (0 : Fin n.succ) ∈ boundaries - /-- Last element of the composition-/ + /-- Last element of the composition -/ getLast_mem : Fin.last n ∈ boundaries instance {n : ℕ} : Inhabited (CompositionAsSet n) := diff --git a/Mathlib/Combinatorics/Enumerative/Partition.lean b/Mathlib/Combinatorics/Enumerative/Partition.lean index d88c1fba8060d..94bcb8771017a 100644 --- a/Mathlib/Combinatorics/Enumerative/Partition.lean +++ b/Mathlib/Combinatorics/Enumerative/Partition.lean @@ -50,7 +50,7 @@ namespace Nat structure Partition (n : ℕ) where /-- positive integers summing to `n`-/ parts : Multiset ℕ - /-- proof that the `parts` are positive-/ + /-- proof that the `parts` are positive -/ parts_pos : ∀ {i}, i ∈ parts → 0 < i /-- proof that the `parts` sum to `n`-/ parts_sum : parts.sum = n diff --git a/Mathlib/Combinatorics/Quiver/Symmetric.lean b/Mathlib/Combinatorics/Quiver/Symmetric.lean index f4fc13e6cfaa8..cf87c843a83f7 100644 --- a/Mathlib/Combinatorics/Quiver/Symmetric.lean +++ b/Mathlib/Combinatorics/Quiver/Symmetric.lean @@ -45,7 +45,7 @@ class HasReverse where def reverse {V} [Quiver.{v + 1} V] [HasReverse V] {a b : V} : (a ⟶ b) → (b ⟶ a) := HasReverse.reverse' -/-- A quiver `HasInvolutiveReverse` if reversing twice is the identity. -/ +/-- A quiver `HasInvolutiveReverse` if reversing twice is the identity. -/ class HasInvolutiveReverse extends HasReverse V where /-- `reverse` is involutive -/ inv' : ∀ {a b : V} (f : a ⟶ b), reverse (reverse f) = f diff --git a/Mathlib/Combinatorics/SetFamily/Compression/UV.lean b/Mathlib/Combinatorics/SetFamily/Compression/UV.lean index 5ebbd630b7265..8bfa4e268eb8a 100644 --- a/Mathlib/Combinatorics/SetFamily/Compression/UV.lean +++ b/Mathlib/Combinatorics/SetFamily/Compression/UV.lean @@ -327,7 +327,7 @@ theorem shadow_compression_subset_compression_shadow (u v : Finset α) exact ⟨Or.inl hat, hav⟩ · rw [← erase_sdiff_comm, sup_eq_union, erase_union_distrib, erase_eq_of_not_mem hau] intro s hs𝒜' hs𝒜 - -- This is gonna be useful a couple of times so let's name it. + -- This is going to be useful a couple of times so let's name it. have m : ∀ y, y ∉ s → insert y s ∉ 𝒜 := fun y h a => hs𝒜 (mem_shadow_iff_insert_mem.2 ⟨y, h, a⟩) obtain ⟨x, _, _⟩ := mem_shadow_iff_insert_mem.1 hs𝒜' have hus : u ⊆ insert x s := le_of_mem_compression_of_not_mem ‹_ ∈ 𝒜'› (m _ ‹x ∉ s›) diff --git a/Mathlib/Combinatorics/SimpleGraph/Metric.lean b/Mathlib/Combinatorics/SimpleGraph/Metric.lean index 17d5d69884b4e..615b2148d1687 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Metric.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Metric.lean @@ -56,7 +56,7 @@ protected theorem Reachable.exists_walk_length_eq_edist (hr : G.Reachable u v) : ∃ p : G.Walk u v, p.length = G.edist u v := csInf_mem <| Set.range_nonempty_iff_nonempty.mpr hr -protected theorem Connected.exists_walk_length_eq_edist (hconn : G.Connected) (u v : V) : +protected theorem Connected.exists_walk_length_eq_edist (hconn : G.Connected) (u v : V) : ∃ p : G.Walk u v, p.length = G.edist u v := (hconn u v).exists_walk_length_eq_edist diff --git a/Mathlib/Combinatorics/SimpleGraph/Path.lean b/Mathlib/Combinatorics/SimpleGraph/Path.lean index 4f6d0c3d95760..92eb6a099cf29 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Path.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Path.lean @@ -572,7 +572,7 @@ theorem mapEmbedding_injective (f : G ↪g G') (u v : V) : end Path -/-! ### Transferring between graphs -/ +/-! ### Transferring between graphs -/ namespace Walk diff --git a/Mathlib/Combinatorics/SimpleGraph/Regularity/Energy.lean b/Mathlib/Combinatorics/SimpleGraph/Regularity/Energy.lean index c2dc97dd66768..64284f427847f 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Regularity/Energy.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Regularity/Energy.lean @@ -32,7 +32,7 @@ variable {α : Type*} [DecidableEq α] {s : Finset α} (P : Finpartition s) (G : namespace Finpartition /-- The energy of a partition, also known as index. Auxiliary quantity for Szemerédi's regularity -lemma. -/ +lemma. -/ def energy : ℚ := ((∑ uv ∈ P.parts.offDiag, G.edgeDensity uv.1 uv.2 ^ 2) : ℚ) / (P.parts.card : ℚ) ^ 2 diff --git a/Mathlib/Combinatorics/SimpleGraph/Walk.lean b/Mathlib/Combinatorics/SimpleGraph/Walk.lean index 52c4b7eeca310..f19d80f57beec 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Walk.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Walk.lean @@ -1134,7 +1134,7 @@ theorem map_injective_of_injective {f : G →g G'} (hinj : Function.Injective f) abbrev mapLe {G G' : SimpleGraph V} (h : G ≤ G') {u v : V} (p : G.Walk u v) : G'.Walk u v := p.map (Hom.mapSpanningSubgraphs h) -/-! ### Transferring between graphs -/ +/-! ### Transferring between graphs -/ /-- The walk `p` transferred to lie in `H`, given that `H` contains its edges. -/ @[simp] diff --git a/Mathlib/Computability/AkraBazzi/AkraBazzi.lean b/Mathlib/Computability/AkraBazzi/AkraBazzi.lean index 42babddc640ec..5dc2701af173b 100644 --- a/Mathlib/Computability/AkraBazzi/AkraBazzi.lean +++ b/Mathlib/Computability/AkraBazzi/AkraBazzi.lean @@ -508,7 +508,7 @@ lemma isTheta_smoothingFn_sub_self (i : α) : Every Akra-Bazzi recurrence has an associated exponent, denoted by `p : ℝ`, such that `∑ a_i b_i^p = 1`. This section shows the existence and uniqueness of this exponent `p` for any `R : AkraBazziRecurrence`, and defines `R.asympBound` to be the asymptotic bound satisfied by `R`, -namely `n^p (1 + ∑_{u < n} g(u) / u^(p+1))`. -/ +namely `n^p (1 + ∑_{u < n} g(u) / u^(p+1))`. -/ @[continuity] lemma continuous_sumCoeffsExp : Continuous (fun (p : ℝ) => ∑ i, a i * (b i) ^ p) := by diff --git a/Mathlib/Computability/ContextFreeGrammar.lean b/Mathlib/Computability/ContextFreeGrammar.lean index 4ee8b65304fa8..74ef24c357923 100644 --- a/Mathlib/Computability/ContextFreeGrammar.lean +++ b/Mathlib/Computability/ContextFreeGrammar.lean @@ -53,10 +53,10 @@ inductive Rewrites (r : ContextFreeRule T N) : List (Symbol T N) → List (Symbo r.Rewrites (x :: s₁) (x :: s₂) lemma Rewrites.exists_parts {r : ContextFreeRule T N} {u v : List (Symbol T N)} - (hyp : r.Rewrites u v) : + (hr : r.Rewrites u v) : ∃ p q : List (Symbol T N), u = p ++ [Symbol.nonterminal r.input] ++ q ∧ v = p ++ r.output ++ q := by - induction hyp with + induction hr with | head s => use [], s simp @@ -181,7 +181,7 @@ lemma Derives.append_left {v w : List (Symbol T g.NT)} | refl => rfl | tail _ last ih => exact ih.trans_produces <| last.append_left p -/-- Add extra prefix to context-free deriving. -/ +/-- Add extra postfix to context-free deriving. -/ lemma Derives.append_right {v w : List (Symbol T g.NT)} (hvw : g.Derives v w) (p : List (Symbol T g.NT)) : g.Derives (v ++ p) (w ++ p) := by @@ -193,7 +193,10 @@ end ContextFreeGrammar /-- Context-free languages are defined by context-free grammars. -/ def Language.IsContextFree (L : Language T) : Prop := - ∃ g : ContextFreeGrammar.{uT} T, g.language = L + ∃ g : ContextFreeGrammar.{0} T, g.language = L + +proof_wanted Language.isContextFree_iff {L : Language T} : + L.IsContextFree ↔ ∃ g : ContextFreeGrammar.{uN} T, g.language = L section closure_reversal diff --git a/Mathlib/Computability/Primrec.lean b/Mathlib/Computability/Primrec.lean index 38070a6702b20..967626fac3c92 100644 --- a/Mathlib/Computability/Primrec.lean +++ b/Mathlib/Computability/Primrec.lean @@ -651,7 +651,7 @@ theorem dom_fintype [Finite α] (f : α → σ) : Primrec f := option_some_iff.1 <| by haveI := decidableEqOfEncodable α refine ((list_get?₁ (l.map f)).comp (list_indexOf₁ l)).of_eq fun a => ?_ - rw [List.get?_eq_getElem?, List.getElem?_map, List.getElem?_indexOf (m a), Option.map_some'] + rw [List.get?_eq_getElem?, List.getElem?_map, List.getElem?_indexOf (m a), Option.map_some'] -- Porting note: These are new lemmas -- I added it because it actually simplified the proofs diff --git a/Mathlib/Computability/TMToPartrec.lean b/Mathlib/Computability/TMToPartrec.lean index b4e1c66e921db..af078e791577d 100644 --- a/Mathlib/Computability/TMToPartrec.lean +++ b/Mathlib/Computability/TMToPartrec.lean @@ -1906,3 +1906,5 @@ end end PartrecToTM2 end Turing + +set_option linter.style.longFile 2100 diff --git a/Mathlib/Computability/TuringMachine.lean b/Mathlib/Computability/TuringMachine.lean index 99a30824f06d0..1846c5cbefbf9 100644 --- a/Mathlib/Computability/TuringMachine.lean +++ b/Mathlib/Computability/TuringMachine.lean @@ -2569,3 +2569,5 @@ end end TM2to1 end Turing + +set_option linter.style.longFile 2700 diff --git a/Mathlib/Condensed/Basic.lean b/Mathlib/Condensed/Basic.lean index fb904e7ecb227..8d384f0d7eb88 100644 --- a/Mathlib/Condensed/Basic.lean +++ b/Mathlib/Condensed/Basic.lean @@ -76,7 +76,7 @@ namespace CondensedSet -- Note: `simp` can prove this when stated for `Condensed C` for a concrete category `C`. -- However, it doesn't seem to see through the abbreviation `CondensedSet` @[simp] -lemma hom_naturality_apply {X Y : CondensedSet.{u}} (f : X ⟶ Y) {S T : CompHausᵒᵖ} (g : S ⟶ T) +lemma hom_naturality_apply {X Y : CondensedSet.{u}} (f : X ⟶ Y) {S T : CompHausᵒᵖ} (g : S ⟶ T) (x : X.val.obj S) : f.val.app T (X.val.map g x) = Y.val.map g (f.val.app S x) := NatTrans.naturality_apply f.val g x diff --git a/Mathlib/Condensed/Discrete/Basic.lean b/Mathlib/Condensed/Discrete/Basic.lean index 5f2ed84dfda6a..d7964352317fa 100644 --- a/Mathlib/Condensed/Discrete/Basic.lean +++ b/Mathlib/Condensed/Discrete/Basic.lean @@ -12,13 +12,13 @@ import Mathlib.Condensed.Light.Basic # Discrete-underlying adjunction Given a category `C` with sheafification with respect to the coherent topology on compact Hausdorff -spaces, we define a functor `C ⥤ Condensed C` which associates to an object of `C` the +spaces, we define a functor `C ⥤ Condensed C` which associates to an object of `C` the corresponding "discrete" condensed object (see `Condensed.discrete`). -In `Condensed.discreteUnderlyingAdj` we prove that this functor is left adjoint to the forgetful +In `Condensed.discreteUnderlyingAdj` we prove that this functor is left adjoint to the forgetful functor from `Condensed C` to `C`. -We also give the variant `LightCondensed.discreteUnderlyingAdj` for light condensed objects. +We also give the variant `LightCondensed.discreteUnderlyingAdj` for light condensed objects. -/ universe u v w @@ -30,13 +30,13 @@ namespace Condensed variable (C : Type w) [Category.{u+1} C] [HasWeakSheafify (coherentTopology CompHaus.{u}) C] /-- -The discrete condensed object associated to an object of `C` is the constant sheaf at that object. +The discrete condensed object associated to an object of `C` is the constant sheaf at that object. -/ @[simps!] noncomputable def discrete : C ⥤ Condensed.{u} C := constantSheaf _ C /-- -The underlying object of a condensed object in `C` is the condensed object evaluated at a point. +The underlying object of a condensed object in `C` is the condensed object evaluated at a point. This can be viewed as a sort of forgetful functor from `Condensed C` to `C` -/ @[simps!] @@ -45,7 +45,7 @@ noncomputable def underlying : Condensed.{u} C ⥤ C := /-- Discreteness is left adjoint to the forgetful functor. When `C` is `Type*`, this is analogous to -`TopCat.adj₁ : TopCat.discrete ⊣ forget TopCat`.   +`TopCat.adj₁ : TopCat.discrete ⊣ forget TopCat`. -/ noncomputable def discreteUnderlyingAdj : discrete C ⊣ underlying C := constantSheafAdj _ _ CompHaus.isTerminalPUnit @@ -57,14 +57,14 @@ namespace LightCondensed variable (C : Type w) [Category.{u} C] [HasSheafify (coherentTopology LightProfinite.{u}) C] /-- -The discrete light condensed object associated to an object of `C` is the constant sheaf at that +The discrete light condensed object associated to an object of `C` is the constant sheaf at that object. -/ @[simps!] noncomputable def discrete : C ⥤ LightCondensed.{u} C := constantSheaf _ C /-- -The underlying object of a condensed object in `C` is the light condensed object evaluated at a +The underlying object of a condensed object in `C` is the light condensed object evaluated at a point. This can be viewed as a sort of forgetful functor from `LightCondensed C` to `C` -/ @[simps!] @@ -73,7 +73,7 @@ noncomputable def underlying : LightCondensed.{u} C ⥤ C := /-- Discreteness is left adjoint to the forgetful functor. When `C` is `Type*`, this is analogous to -`TopCat.adj₁ : TopCat.discrete ⊣ forget TopCat`.   +`TopCat.adj₁ : TopCat.discrete ⊣ forget TopCat`. -/ noncomputable def discreteUnderlyingAdj : discrete C ⊣ underlying C := constantSheafAdj _ _ CompHausLike.isTerminalPUnit diff --git a/Mathlib/Condensed/Equivalence.lean b/Mathlib/Condensed/Equivalence.lean index 579875bfae18a..abc50a1886387 100644 --- a/Mathlib/Condensed/Equivalence.lean +++ b/Mathlib/Condensed/Equivalence.lean @@ -20,7 +20,7 @@ Since Stonean spaces are the projective objects in `CompHaus`, which has enough and the notions of effective epimorphism, epimorphism and surjective continuous map are equivalent in `CompHaus` and `Stonean`, we can use the general setup in `Mathlib.CategoryTheory.Sites.Coherent.SheafComparison` to deduce the equivalence of categories. -We give the corresponding statements for `Profinite` as well. +We give the corresponding statements for `Profinite` as well. ## Main results @@ -61,7 +61,7 @@ instance : Stonean.toProfinite.ReflectsEffectiveEpis where ((Stonean.effectiveEpi_tfae f).out 0 2).mpr (((Profinite.effectiveEpi_tfae _).out 0 2).mp h) /-- -An effective presentation of an `X : Profinite` with respect to the inclusion functor from `Stonean` +An effective presentation of an `X : Profinite` with respect to the inclusion functor from `Stonean` -/ noncomputable def stoneanToProfiniteEffectivePresentation (X : Profinite) : Stonean.toProfinite.EffectivePresentation X where diff --git a/Mathlib/Condensed/Explicit.lean b/Mathlib/Condensed/Explicit.lean index 15e67c5ac1557..541c0747e15fc 100644 --- a/Mathlib/Condensed/Explicit.lean +++ b/Mathlib/Condensed/Explicit.lean @@ -19,9 +19,9 @@ We give the following three explicit descriptions of condensed objects: * `Condensed.ofSheafStonean`: A finite-product-preserving presheaf on `CompHaus`, satisfying `EqualizerCondition`. -The property `EqualizerCondition` is defined in `Mathlib/CategoryTheory/Sites/RegularSheaves.lean` +The property `EqualizerCondition` is defined in `Mathlib/CategoryTheory/Sites/RegularSheaves.lean` and it says that for any effective epi `X ⟶ B` (in this case that is equivalent to being a -continuous surjection), the presheaf `F` exhibits `F(B)` as the equalizer of the two maps +continuous surjection), the presheaf `F` exhibits `F(B)` as the equalizer of the two maps `F(X) ⇉ F(X ×_B X)` We also give variants for condensed objects in concrete categories whose forgetful functor @@ -150,17 +150,17 @@ end Condensed namespace CondensedSet -/-- A `CondensedSet` version of `Condensed.ofSheafStonean`. -/ +/-- A `CondensedSet` version of `Condensed.ofSheafStonean`. -/ noncomputable abbrev ofSheafStonean (F : Stonean.{u}ᵒᵖ ⥤ Type (u+1)) [PreservesFiniteProducts F] : CondensedSet := Condensed.ofSheafStonean F -/-- A `CondensedSet` version of `Condensed.ofSheafProfinite`. -/ +/-- A `CondensedSet` version of `Condensed.ofSheafProfinite`. -/ noncomputable abbrev ofSheafProfinite (F : Profinite.{u}ᵒᵖ ⥤ Type (u+1)) [PreservesFiniteProducts F] (hF : EqualizerCondition F) : CondensedSet := Condensed.ofSheafProfinite F hF -/-- A `CondensedSet` version of `Condensed.ofSheafCompHaus`. -/ +/-- A `CondensedSet` version of `Condensed.ofSheafCompHaus`. -/ noncomputable abbrev ofSheafCompHaus (F : CompHaus.{u}ᵒᵖ ⥤ Type (u+1)) [PreservesFiniteProducts F] (hF : EqualizerCondition F) : CondensedSet := Condensed.ofSheafCompHaus F hF @@ -171,19 +171,19 @@ namespace CondensedMod variable (R : Type (u+1)) [Ring R] -/-- A `CondensedMod` version of `Condensed.ofSheafStonean`. -/ +/-- A `CondensedMod` version of `Condensed.ofSheafStonean`. -/ noncomputable abbrev ofSheafStonean (F : Stonean.{u}ᵒᵖ ⥤ ModuleCat.{u+1} R) [PreservesFiniteProducts F] : CondensedMod R := haveI : HasLimitsOfSize.{u, u+1} (ModuleCat R) := hasLimitsOfSizeShrink.{u, u+1, u+1, u+1} _ Condensed.ofSheafStonean F -/-- A `CondensedMod` version of `Condensed.ofSheafProfinite`. -/ +/-- A `CondensedMod` version of `Condensed.ofSheafProfinite`. -/ noncomputable abbrev ofSheafProfinite (F : Profinite.{u}ᵒᵖ ⥤ ModuleCat.{u+1} R) [PreservesFiniteProducts F] (hF : EqualizerCondition F) : CondensedMod R := haveI : HasLimitsOfSize.{u, u+1} (ModuleCat R) := hasLimitsOfSizeShrink.{u, u+1, u+1, u+1} _ Condensed.ofSheafProfinite F hF -/-- A `CondensedMod` version of `Condensed.ofSheafCompHaus`. -/ +/-- A `CondensedMod` version of `Condensed.ofSheafCompHaus`. -/ noncomputable abbrev ofSheafCompHaus (F : CompHaus.{u}ᵒᵖ ⥤ ModuleCat.{u+1} R) [PreservesFiniteProducts F] (hF : EqualizerCondition F) : CondensedMod R := Condensed.ofSheafCompHaus F hF diff --git a/Mathlib/Condensed/Functors.lean b/Mathlib/Condensed/Functors.lean index 73869ef6f22b8..c83e320059c0d 100644 --- a/Mathlib/Condensed/Functors.lean +++ b/Mathlib/Condensed/Functors.lean @@ -17,16 +17,16 @@ sets. ## Main definitions -* `compHausToCondensed : CompHaus.{u} ⥤ CondensedSet.{u}` is essentially the yoneda presheaf - functor. We also define `profiniteToCondensed` and `stoneanToCondensed`. +* `compHausToCondensed : CompHaus.{u} ⥤ CondensedSet.{u}` is essentially the yoneda presheaf + functor. We also define `profiniteToCondensed` and `stoneanToCondensed`. TODO (Dagur): -* Define the analogues of `compHausToCondensed` for sheaves on `Profinite` and `Stonean` and provide - the relevant isomorphisms with `profiniteToCondensed` and `stoneanToCondensed`. +* Define the analogues of `compHausToCondensed` for sheaves on `Profinite` and `Stonean` and provide + the relevant isomorphisms with `profiniteToCondensed` and `stoneanToCondensed`. * Define the functor `Type (u+1) ⥤ CondensedSet.{u}` which takes a set `X` to the presheaf given by - mapping a compact Hausdorff space `S` to `LocallyConstant S X`, along with the isomorphism with + mapping a compact Hausdorff space `S` to `LocallyConstant S X`, along with the isomorphism with the functor that goes through `TopCat.{u+1}`. -/ @@ -49,7 +49,7 @@ end Universes section Topology -/-- The functor from `CompHaus` to `Condensed.{u} (Type u)` given by the Yoneda sheaf. -/ +/-- The functor from `CompHaus` to `Condensed.{u} (Type u)` given by the Yoneda sheaf. -/ def compHausToCondensed' : CompHaus.{u} ⥤ Condensed.{u} (Type u) := (coherentTopology.subcanonical CompHaus).yoneda diff --git a/Mathlib/Condensed/Light/Basic.lean b/Mathlib/Condensed/Light/Basic.lean index e4336e0a3ea2d..f5156d707ed0f 100644 --- a/Mathlib/Condensed/Light/Basic.lean +++ b/Mathlib/Condensed/Light/Basic.lean @@ -60,7 +60,7 @@ namespace LightCondSet -- Note: `simp` can prove this when stated for `LightCondensed C` for a concrete category `C`. -- However, it doesn't seem to see through the abbreviation `LightCondSet` @[simp] -lemma hom_naturality_apply {X Y : LightCondSet.{u}} (f : X ⟶ Y) {S T : LightProfiniteᵒᵖ} +lemma hom_naturality_apply {X Y : LightCondSet.{u}} (f : X ⟶ Y) {S T : LightProfiniteᵒᵖ} (g : S ⟶ T) (x : X.val.obj S) : f.val.app T (X.val.map g x) = Y.val.map g (f.val.app S x) := NatTrans.naturality_apply f.val g x diff --git a/Mathlib/Condensed/Light/Explicit.lean b/Mathlib/Condensed/Light/Explicit.lean index 8967577b1c7d4..837d7f33f7fab 100644 --- a/Mathlib/Condensed/Light/Explicit.lean +++ b/Mathlib/Condensed/Light/Explicit.lean @@ -14,9 +14,9 @@ We give explicit description of light condensed sets: * `LightCondensed.ofSheafLightProfinite`: A finite-product-preserving presheaf on `LightProfinite`, satisfying `EqualizerCondition`. -The property `EqualizerCondition` is defined in `Mathlib/CategoryTheory/Sites/RegularExtensive.lean` +The property `EqualizerCondition` is defined in `Mathlib/CategoryTheory/Sites/RegularExtensive.lean` and it says that for any effective epi `X ⟶ B` (in this case that is equivalent to being a -continuous surjection), the presheaf `F` exhibits `F(B)` as the equalizer of the two maps +continuous surjection), the presheaf `F` exhibits `F(B)` as the equalizer of the two maps `F(X) ⇉ F(X ×_B X)` We also give variants for light condensed objects in concrete categories whose forgetful functor @@ -71,7 +71,7 @@ end LightCondensed namespace LightCondSet -/-- A `LightCondSet` version of `LightCondensed.ofSheafLightProfinite`. -/ +/-- A `LightCondSet` version of `LightCondensed.ofSheafLightProfinite`. -/ noncomputable abbrev ofSheafLightProfinite (F : LightProfinite.{u}ᵒᵖ ⥤ Type u) [PreservesFiniteProducts F] (hF : EqualizerCondition F) : LightCondSet := LightCondensed.ofSheafLightProfinite F hF @@ -82,7 +82,7 @@ namespace LightCondMod variable (R : Type u) [Ring R] -/-- A `LightCondAb` version of `LightCondensed.ofSheafLightProfinite`. -/ +/-- A `LightCondAb` version of `LightCondensed.ofSheafLightProfinite`. -/ noncomputable abbrev ofSheafLightProfinite (F : LightProfinite.{u}ᵒᵖ ⥤ ModuleCat.{u} R) [PreservesFiniteProducts F] (hF : EqualizerCondition F) : LightCondMod.{u} R := LightCondensed.ofSheafLightProfinite F hF @@ -91,7 +91,7 @@ end LightCondMod namespace LightCondAb -/-- A `LightCondAb` version of `LightCondensed.ofSheafLightProfinite`. -/ +/-- A `LightCondAb` version of `LightCondensed.ofSheafLightProfinite`. -/ noncomputable abbrev ofSheafLightProfinite (F : LightProfiniteᵒᵖ ⥤ ModuleCat ℤ) [PreservesFiniteProducts F] (hF : EqualizerCondition F) : LightCondAb := LightCondMod.ofSheafLightProfinite ℤ F hF diff --git a/Mathlib/Condensed/Light/Functors.lean b/Mathlib/Condensed/Light/Functors.lean index 191499d9bb0d8..7d58dbe10bb93 100644 --- a/Mathlib/Condensed/Light/Functors.lean +++ b/Mathlib/Condensed/Light/Functors.lean @@ -14,13 +14,13 @@ sets. ## Main definitions -* `lightProfiniteToLightCondSet : LightProfinite.{u} ⥤ LightCondSet.{u}`  +* `lightProfiniteToLightCondSet : LightProfinite.{u} ⥤ LightCondSet.{u}` is the yoneda presheaf functor. TODO (Dagur): * Define the functor `Type u ⥤ LightCondSet.{u}` which takes a set `X` to the presheaf given by - mapping a light profinite space `S` to `LocallyConstant S X`, along with the isomorphism with + mapping a light profinite space `S` to `LocallyConstant S X`, along with the isomorphism with the functor that goes through `TopCat.{u+1}`. -/ @@ -29,7 +29,7 @@ universe u v open CategoryTheory Limits -/-- The functor from `LightProfinite.{u}` to `LightCondSet.{u}` given by the Yoneda sheaf. -/ +/-- The functor from `LightProfinite.{u}` to `LightCondSet.{u}` given by the Yoneda sheaf. -/ def lightProfiniteToLightCondSet : LightProfinite.{u} ⥤ LightCondSet.{u} := (coherentTopology.subcanonical LightProfinite).yoneda diff --git a/Mathlib/Condensed/Light/Module.lean b/Mathlib/Condensed/Light/Module.lean index d75eee03e1156..e4ba98cbb8812 100644 --- a/Mathlib/Condensed/Light/Module.lean +++ b/Mathlib/Condensed/Light/Module.lean @@ -68,7 +68,7 @@ namespace LightCondMod -- Note: `simp` can prove this when stated for `LightCondensed C` for a concrete category `C`. -- However, it doesn't seem to see through the abbreviation `LightCondMod` @[simp] -lemma hom_naturality_apply {X Y : LightCondMod.{u} R} (f : X ⟶ Y) {S T : LightProfiniteᵒᵖ} +lemma hom_naturality_apply {X Y : LightCondMod.{u} R} (f : X ⟶ Y) {S T : LightProfiniteᵒᵖ} (g : S ⟶ T) (x : X.val.obj S) : f.val.app T (X.val.map g x) = Y.val.map g (f.val.app S x) := NatTrans.naturality_apply f.val g x diff --git a/Mathlib/Condensed/Light/TopCatAdjunction.lean b/Mathlib/Condensed/Light/TopCatAdjunction.lean index 2b67bf1e860bb..740982a3a7bad 100644 --- a/Mathlib/Condensed/Light/TopCatAdjunction.lean +++ b/Mathlib/Condensed/Light/TopCatAdjunction.lean @@ -39,14 +39,14 @@ private def coinducingCoprod : X.val.obj ⟨LightProfinite.of PUnit⟩ := fun ⟨⟨S, i⟩, s⟩ ↦ X.val.map (S.const s).op i -/-- Let `X` be a light condensed set. We define a topology on `X(*)` as the quotient topology of +/-- Let `X` be a light condensed set. We define a topology on `X(*)` as the quotient topology of all the maps from light profinite sets `S` to `X(*)`, corresponding to elements of `X(S)`. In other words, the topology coinduced by the map `LightCondSet.coinducingCoprod` above. -/ local instance underlyingTopologicalSpace : TopologicalSpace (X.val.obj ⟨LightProfinite.of PUnit⟩) := TopologicalSpace.coinduced (coinducingCoprod X) inferInstance -/-- The object part of the functor `LightCondSet ⥤ TopCat`  -/ +/-- The object part of the functor `LightCondSet ⥤ TopCat` -/ def toTopCat : TopCat.{u} := TopCat.of (X.val.obj ⟨LightProfinite.of PUnit⟩) lemma continuous_coinducingCoprod {S : LightProfinite.{u}} (x : X.val.obj ⟨S⟩) : @@ -58,7 +58,7 @@ lemma continuous_coinducingCoprod {S : LightProfinite.{u}} (x : X.val.obj ⟨S variable {X} {Y : LightCondSet} (f : X ⟶ Y) -/-- The map part of the functor `LightCondSet ⥤ TopCat`  -/ +/-- The map part of the functor `LightCondSet ⥤ TopCat` -/ @[simps] def toTopCatMap : X.toTopCat ⟶ Y.toTopCat where toFun := f.val.app ⟨LightProfinite.of PUnit⟩ @@ -73,7 +73,7 @@ def toTopCatMap : X.toTopCat ⟶ Y.toTopCat where rw [this] exact continuous_coinducingCoprod _ _ -/-- The functor `LightCondSet ⥤ TopCat`  -/ +/-- The functor `LightCondSet ⥤ TopCat` -/ @[simps] def _root_.lightCondSetToTopCat : LightCondSet.{u} ⥤ TopCat.{u} where obj X := X.toTopCat @@ -87,7 +87,7 @@ def topCatAdjunctionCounit (X : TopCat.{u}) : X.toLightCondSet.toTopCat ⟶ X wh continuity /-- The counit of the adjunction `lightCondSetToTopCat ⊣ topCatToLightCondSet` is always bijective, -but not an isomorphism in general (the inverse isn't continuous unless `X` is sequential). +but not an isomorphism in general (the inverse isn't continuous unless `X` is sequential). -/ def topCatAdjunctionCounitEquiv (X : TopCat.{u}) : X.toLightCondSet.toTopCat ≃ X where toFun := topCatAdjunctionCounit X diff --git a/Mathlib/Condensed/Light/TopComparison.lean b/Mathlib/Condensed/Light/TopComparison.lean index ee4dbcaabc7ae..bebf7bfe42841 100644 --- a/Mathlib/Condensed/Light/TopComparison.lean +++ b/Mathlib/Condensed/Light/TopComparison.lean @@ -26,7 +26,7 @@ noncomputable abbrev TopCat.toLightCondSet (X : TopCat.{u}) : LightCondSet.{u} : toSheafCompHausLike.{u} _ X (fun _ _ _ ↦ (LightProfinite.effectiveEpi_iff_surjective _).mp) /-- -`TopCat.toLightCondSet` yields a functor from `TopCat.{u}` to `LightCondSet.{u}`. +`TopCat.toLightCondSet` yields a functor from `TopCat.{u}` to `LightCondSet.{u}`. -/ noncomputable abbrev topCatToLightCondSet : TopCat.{u} ⥤ LightCondSet.{u} := topCatToSheafCompHausLike.{u} _ (fun _ _ _ ↦ (LightProfinite.effectiveEpi_iff_surjective _).mp) diff --git a/Mathlib/Condensed/Module.lean b/Mathlib/Condensed/Module.lean index c9e76f9b22338..24a5079139cfa 100644 --- a/Mathlib/Condensed/Module.lean +++ b/Mathlib/Condensed/Module.lean @@ -74,7 +74,7 @@ namespace CondensedMod -- Note: `simp` can prove this when stated for `Condensed C` for a concrete category `C`. -- However, it doesn't seem to see through the abbreviation `CondensedMod` @[simp] -lemma hom_naturality_apply {X Y : CondensedMod.{u} R} (f : X ⟶ Y) {S T : CompHausᵒᵖ} (g : S ⟶ T) +lemma hom_naturality_apply {X Y : CondensedMod.{u} R} (f : X ⟶ Y) {S T : CompHausᵒᵖ} (g : S ⟶ T) (x : X.val.obj S) : f.val.app T (X.val.map g x) = Y.val.map g (f.val.app S x) := NatTrans.naturality_apply f.val g x diff --git a/Mathlib/Condensed/TopCatAdjunction.lean b/Mathlib/Condensed/TopCatAdjunction.lean index 13fedf0cb5e3d..d6794943e54a1 100644 --- a/Mathlib/Condensed/TopCatAdjunction.lean +++ b/Mathlib/Condensed/TopCatAdjunction.lean @@ -34,13 +34,13 @@ private def CondensedSet.coinducingCoprod : (Σ (i : (S : CompHaus.{u}) × X.val.obj ⟨S⟩), i.fst) → X.val.obj ⟨CompHaus.of PUnit⟩ := fun ⟨⟨S, i⟩, s⟩ ↦ X.val.map (S.const s).op i -/-- Let `X` be a condensed set. We define a topology on `X(*)` as the quotient topology of +/-- Let `X` be a condensed set. We define a topology on `X(*)` as the quotient topology of all the maps from compact Hausdorff `S` spaces to `X(*)`, corresponding to elements of `X(S)`. In other words, the topology coinduced by the map `CondensedSet.coinducingCoprod` above. -/ local instance : TopologicalSpace (X.val.obj ⟨CompHaus.of PUnit⟩) := TopologicalSpace.coinduced (coinducingCoprod X) inferInstance -/-- The object part of the functor `CondensedSet ⥤ TopCat`  -/ +/-- The object part of the functor `CondensedSet ⥤ TopCat` -/ def CondensedSet.toTopCat : TopCat.{u+1} := TopCat.of (X.val.obj ⟨CompHaus.of PUnit⟩) namespace CondensedSet @@ -54,7 +54,7 @@ lemma continuous_coinducingCoprod {S : CompHaus.{u}} (x : X.val.obj ⟨S⟩) : variable {X} {Y : CondensedSet} (f : X ⟶ Y) -/-- The map part of the functor `CondensedSet ⥤ TopCat`  -/ +/-- The map part of the functor `CondensedSet ⥤ TopCat` -/ @[simps] def toTopCatMap : X.toTopCat ⟶ Y.toTopCat where toFun := f.val.app ⟨CompHaus.of PUnit⟩ @@ -71,7 +71,7 @@ def toTopCatMap : X.toTopCat ⟶ Y.toTopCat where end CondensedSet -/-- The functor `CondensedSet ⥤ TopCat`  -/ +/-- The functor `CondensedSet ⥤ TopCat` -/ @[simps] def condensedSetToTopCat : CondensedSet.{u} ⥤ TopCat.{u+1} where obj X := X.toTopCat @@ -88,7 +88,7 @@ def topCatAdjunctionCounit (X : TopCat.{u+1}) : X.toCondensedSet.toTopCat ⟶ X continuity /-- The counit of the adjunction `condensedSetToTopCat ⊣ topCatToCondensedSet` is always bijective, -but not an isomorphism in general (the inverse isn't continuous unless `X` is compactly generated). +but not an isomorphism in general (the inverse isn't continuous unless `X` is compactly generated). -/ def topCatAdjunctionCounitEquiv (X : TopCat.{u+1}) : X.toCondensedSet.toTopCat ≃ X where toFun := topCatAdjunctionCounit X diff --git a/Mathlib/Condensed/TopComparison.lean b/Mathlib/Condensed/TopComparison.lean index 290e5f0d3433f..c8679d14fddbc 100644 --- a/Mathlib/Condensed/TopComparison.lean +++ b/Mathlib/Condensed/TopComparison.lean @@ -12,7 +12,7 @@ import Mathlib.Topology.Category.TopCat.Yoneda # The functor from topological spaces to condensed sets -This file builds on the API from the file `TopCat.Yoneda`. If the forgetful functor to `TopCat` has +This file builds on the API from the file `TopCat.Yoneda`. If the forgetful functor to `TopCat` has nice properties, like preserving pullbacks and finite coproducts, then this Yoneda presheaf satisfies the sheaf condition for the regular and extensive topologies respectively. @@ -31,7 +31,7 @@ variable {C : Type u} [Category.{v} C] (G : C ⥤ TopCat.{w}) (X : Type w') [TopologicalSpace X] /-- -An auxiliary lemma to that allows us to use `QuotientMap.lift` in the proof of +An auxiliary lemma to that allows us to use `QuotientMap.lift` in the proof of `equalizerCondition_yonedaPresheaf`. -/ theorem factorsThrough_of_pullbackCondition {Z B : C} {π : Z ⟶ B} [HasPullback π π] @@ -56,7 +56,7 @@ theorem factorsThrough_of_pullbackCondition {Z B : C} {π : Z ⟶ B} [HasPullbac /-- If `G` preserves the relevant pullbacks and every effective epi in `C` is a quotient map (which is -the case when `C` is `CompHaus` or `Profinite`), then `yonedaPresheaf` satisfies the equalizer +the case when `C` is `CompHaus` or `Profinite`), then `yonedaPresheaf` satisfies the equalizer condition which is required to be a sheaf for the regular topology. -/ theorem equalizerCondition_yonedaPresheaf @@ -83,7 +83,7 @@ theorem equalizerCondition_yonedaPresheaf exact DFunLike.ext'_iff.mp ((hq Z B π).lift_comp a (factorsThrough_of_pullbackCondition G X ha)) /-- -If `G` preserves finite coproducts (which is the case when `C` is `CompHaus`, `Profinite` or +If `G` preserves finite coproducts (which is the case when `C` is `CompHaus`, `Profinite` or `Stonean`), then `yonedaPresheaf` preserves finite products, which is required to be a sheaf for the extensive topology. -/ @@ -99,7 +99,7 @@ variable (P : TopCat.{u} → Prop) (X : TopCat.{max u w}) (hs : ∀ ⦃X Y : CompHausLike P⦄ (f : X ⟶ Y), EffectiveEpi f → Function.Surjective f) /-- -The sheaf on `CompHausLike P` of continuous maps to a topological space. +The sheaf on `CompHausLike P` of continuous maps to a topological space. -/ @[simps! val_obj val_map] def TopCat.toSheafCompHausLike : @@ -136,7 +136,7 @@ noncomputable abbrev TopCat.toCondensedSet (X : TopCat.{u+1}) : CondensedSet.{u} toSheafCompHausLike.{u+1} _ X (fun _ _ _ ↦ ((CompHaus.effectiveEpi_tfae _).out 0 2).mp) /-- -`TopCat.toCondensedSet` yields a functor from `TopCat.{u+1}` to `CondensedSet.{u}`. +`TopCat.toCondensedSet` yields a functor from `TopCat.{u+1}` to `CondensedSet.{u}`. -/ noncomputable abbrev topCatToCondensedSet : TopCat.{u+1} ⥤ CondensedSet.{u} := topCatToSheafCompHausLike.{u+1} _ (fun _ _ _ ↦ ((CompHaus.effectiveEpi_tfae _).out 0 2).mp) diff --git a/Mathlib/Control/Functor/Multivariate.lean b/Mathlib/Control/Functor/Multivariate.lean index b2d82ecaeea4d..993d066487aa9 100644 --- a/Mathlib/Control/Functor/Multivariate.lean +++ b/Mathlib/Control/Functor/Multivariate.lean @@ -213,7 +213,7 @@ theorem LiftR_RelLast_iff (x y : F (α ::: β)) : -- Porting note: proof was -- rw [MvFunctor.map_map, MvFunctor.map_map, (· ⊚ ·), (· ⊚ ·)] -- congr <;> ext i ⟨x, _⟩ <;> cases i <;> rfl - suffices (fun i t => t.val.fst) = ((fun i x => (MvFunctor.f' rr n α i x).val.fst)) + suffices (fun i t => t.val.fst) = ((fun i x => (MvFunctor.f' rr n α i x).val.fst)) ∧ (fun i t => t.val.snd) = ((fun i x => (MvFunctor.f' rr n α i x).val.snd)) by rw [this.1, this.2] constructor <;> ext i ⟨x, _⟩ <;> cases i <;> rfl diff --git a/Mathlib/Control/Random.lean b/Mathlib/Control/Random.lean index 05198d61db646..598d03e3d3880 100644 --- a/Mathlib/Control/Random.lean +++ b/Mathlib/Control/Random.lean @@ -32,14 +32,14 @@ set_option autoImplicit true /-- A monad transformer to generate random objects using the generic generator type `g` -/ abbrev RandGT (g : Type) := StateT (ULift g) -/-- A monad to generate random objects using the generator type `g`. -/ +/-- A monad to generate random objects using the generator type `g`. -/ abbrev RandG (g : Type) := RandGT g Id /-- A monad transformer to generate random objects using the generator type `StdGen`. `RandT m α` should be thought of a random value in `m α`. -/ abbrev RandT := RandGT StdGen -/-- A monad to generate random objects using the generator type `StdGen`. -/ +/-- A monad to generate random objects using the generator type `StdGen`. -/ abbrev Rand := RandG StdGen instance [MonadLift m n] : MonadLiftT (RandGT g m) (RandGT g n) where diff --git a/Mathlib/Control/Traversable/Basic.lean b/Mathlib/Control/Traversable/Basic.lean index 6c338a28da53e..e9103c5c55aa4 100644 --- a/Mathlib/Control/Traversable/Basic.lean +++ b/Mathlib/Control/Traversable/Basic.lean @@ -221,7 +221,7 @@ satisfy a naturality condition with respect to applicative transformations. -/ class LawfulTraversable (t : Type u → Type u) [Traversable t] extends LawfulFunctor t : Prop where - /-- `traverse` plays well with `pure` of the identity monad-/ + /-- `traverse` plays well with `pure` of the identity monad -/ id_traverse : ∀ {α} (x : t α), traverse (pure : α → Id α) x = x /-- `traverse` plays well with composition of applicative functors. -/ comp_traverse : diff --git a/Mathlib/Control/Traversable/Equiv.lean b/Mathlib/Control/Traversable/Equiv.lean index 6b7276bafe9a7..fbd1a7fcc724e 100644 --- a/Mathlib/Control/Traversable/Equiv.lean +++ b/Mathlib/Control/Traversable/Equiv.lean @@ -43,7 +43,7 @@ protected def map {α β : Type u} (f : α → β) (x : t' α) : t' β := eqv β <| map f ((eqv α).symm x) /-- The function `Equiv.map` transfers the functoriality of `t` to -`t'` using the equivalences `eqv`. -/ +`t'` using the equivalences `eqv`. -/ protected def functor : Functor t' where map := Equiv.map eqv variable [LawfulFunctor t] diff --git a/Mathlib/Data/Analysis/Topology.lean b/Mathlib/Data/Analysis/Topology.lean index f8db5f20dd999..6da9c694593d9 100644 --- a/Mathlib/Data/Analysis/Topology.lean +++ b/Mathlib/Data/Analysis/Topology.lean @@ -208,7 +208,7 @@ end Ctop.Realizer /-- A `LocallyFinite.Realizer F f` is a realization that `f` is locally finite, namely it is a choice of open sets from the basis of `F` such that they intersect only finitely many of the values -of `f`. -/ +of `f`. -/ structure LocallyFinite.Realizer [TopologicalSpace α] (F : Ctop.Realizer α) (f : β → Set α) where bas : ∀ a, { s // a ∈ F.F s } sets : ∀ x : α, Fintype { i | (f i ∩ F.F (bas x)).Nonempty } @@ -237,7 +237,7 @@ instance [TopologicalSpace α] [Finite β] (F : Ctop.Realizer α) (f : β → Se (locallyFinite_iff_exists_realizer _).1 <| locallyFinite_of_finite _ /-- A `Compact.Realizer s` is a realization that `s` is compact, namely it is a -choice of finite open covers for each set family covering `s`. -/ +choice of finite open covers for each set family covering `s`. -/ def Compact.Realizer [TopologicalSpace α] (s : Set α) := ∀ {f : Filter α} (F : f.Realizer) (x : F.σ), f ≠ ⊥ → F.F x ⊆ s → { a // a ∈ s ∧ 𝓝 a ⊓ f ≠ ⊥ } diff --git a/Mathlib/Data/Bool/Basic.lean b/Mathlib/Data/Bool/Basic.lean index da700043cf44d..85c0f67f57e32 100644 --- a/Mathlib/Data/Bool/Basic.lean +++ b/Mathlib/Data/Bool/Basic.lean @@ -181,7 +181,7 @@ attribute [simp] xor_assoc theorem xor_iff_ne : ∀ {x y : Bool}, xor x y = true ↔ x ≠ y := by decide -/-! ### De Morgan's laws for booleans-/ +/-! ### De Morgan's laws for booleans -/ instance linearOrder : LinearOrder Bool where le_refl := by decide @@ -221,8 +221,8 @@ def ofNat (n : Nat) : Bool := @[simp] lemma toNat_beq_zero (b : Bool) : (b.toNat == 0) = !b := by cases b <;> rfl @[simp] lemma toNat_bne_zero (b : Bool) : (b.toNat != 0) = b := by simp [bne] -@[simp] lemma toNat_beq_one (b : Bool) : (b.toNat == 1) = b := by cases b <;> rfl -@[simp] lemma toNat_bne_one (b : Bool) : (b.toNat != 1) = !b := by simp [bne] +@[simp] lemma toNat_beq_one (b : Bool) : (b.toNat == 1) = b := by cases b <;> rfl +@[simp] lemma toNat_bne_one (b : Bool) : (b.toNat != 1) = !b := by simp [bne] theorem ofNat_le_ofNat {n m : Nat} (h : n ≤ m) : ofNat n ≤ ofNat m := by simp only [ofNat, ne_eq, _root_.decide_not] diff --git a/Mathlib/Data/Complex/Module.lean b/Mathlib/Data/Complex/Module.lean index f13e8b88cc1a3..e8fc5c5c392dc 100644 --- a/Mathlib/Data/Complex/Module.lean +++ b/Mathlib/Data/Complex/Module.lean @@ -291,7 +291,7 @@ def liftAux (I' : A) (hf : I' * I' = -1) : ℂ →ₐ[ℝ] A := congr 1 -- equate "real" and "imaginary" parts · let inst : SMulCommClass ℝ A A := by infer_instance -- Porting note: added - rw [smul_mul_smul, hf, smul_neg, ← Algebra.algebraMap_eq_smul_one, ← sub_eq_add_neg, ← + rw [smul_mul_smul_comm, hf, smul_neg, ← Algebra.algebraMap_eq_smul_one, ← sub_eq_add_neg, ← RingHom.map_mul, ← RingHom.map_sub] · rw [Algebra.smul_def, Algebra.smul_def, Algebra.smul_def, ← Algebra.right_comm _ x₂, ← mul_assoc, ← add_mul, ← RingHom.map_mul, ← RingHom.map_mul, ← RingHom.map_add] diff --git a/Mathlib/Data/DFinsupp/Basic.lean b/Mathlib/Data/DFinsupp/Basic.lean index 88ad862dae1d2..11111a2e35ca6 100644 --- a/Mathlib/Data/DFinsupp/Basic.lean +++ b/Mathlib/Data/DFinsupp/Basic.lean @@ -1300,7 +1300,7 @@ instance distribMulAction₂ [Monoid γ] [∀ i j, AddMonoid (δ i j)] variable [DecidableEq ι] -/-- The natural map between `Π₀ (i : Σ i, α i), δ i.1 i.2` and `Π₀ i (j : α i), δ i j`. -/ +/-- The natural map between `Π₀ (i : Σ i, α i), δ i.1 i.2` and `Π₀ i (j : α i), δ i j`. -/ def sigmaCurry [∀ i j, Zero (δ i j)] (f : Π₀ (i : Σ _, _), δ i.1 i.2) : Π₀ (i) (j), δ i j where toFun := fun i ↦ @@ -2093,3 +2093,5 @@ instance DFinsupp.infinite_of_right {ι : Sort _} {π : ι → Sort _} [∀ i, I DFinsupp.infinite_of_exists_right (Classical.arbitrary ι) end FiniteInfinite + +set_option linter.style.longFile 2200 diff --git a/Mathlib/Data/ENNReal/Basic.lean b/Mathlib/Data/ENNReal/Basic.lean index d1633df0c8af5..e44228f3991d3 100644 --- a/Mathlib/Data/ENNReal/Basic.lean +++ b/Mathlib/Data/ENNReal/Basic.lean @@ -214,6 +214,8 @@ theorem ofReal_eq_coe_nnreal {x : ℝ} (h : 0 ≤ x) : ENNReal.ofReal x = ofNNReal ⟨x, h⟩ := (coe_nnreal_eq ⟨x, h⟩).symm +theorem ofNNReal_toNNReal (x : ℝ) : (Real.toNNReal x : ℝ≥0∞) = ENNReal.ofReal x := rfl + @[simp] theorem ofReal_coe_nnreal : ENNReal.ofReal p = p := (coe_nnreal_eq p).symm @[simp, norm_cast] theorem coe_zero : ↑(0 : ℝ≥0) = (0 : ℝ≥0∞) := rfl diff --git a/Mathlib/Data/ENNReal/Operations.lean b/Mathlib/Data/ENNReal/Operations.lean index 75da1428393a1..9f0b1dbbbddc3 100644 --- a/Mathlib/Data/ENNReal/Operations.lean +++ b/Mathlib/Data/ENNReal/Operations.lean @@ -5,6 +5,7 @@ Authors: Johannes Hölzl, Yury Kudryashov -/ import Mathlib.Algebra.BigOperators.WithTop import Mathlib.Algebra.GroupWithZero.Divisibility +import Mathlib.Algebra.Module.Basic import Mathlib.Data.ENNReal.Basic /-! @@ -523,6 +524,15 @@ theorem smul_top {R} [Zero R] [SMulWithZero R ℝ≥0∞] [IsScalarTower R ℝ -- Porting note: need the primed version of `one_ne_zero` now simp_rw [smul_eq_zero, or_iff_left (one_ne_zero' ℝ≥0∞)] +lemma nnreal_smul_lt_top {x : ℝ≥0} {y : ℝ≥0∞} (hy : y < ⊤) : x • y < ⊤ := mul_lt_top (by simp) hy +lemma nnreal_smul_ne_top {x : ℝ≥0} {y : ℝ≥0∞} (hy : y ≠ ⊤) : x • y ≠ ⊤ := mul_ne_top (by simp) hy + +lemma nnreal_smul_ne_top_iff {x : ℝ≥0} {y : ℝ≥0∞} (hx : x ≠ 0) : x • y ≠ ⊤ ↔ y ≠ ⊤ := + ⟨by rintro h rfl; simp [smul_top, hx] at h, nnreal_smul_ne_top⟩ + +lemma nnreal_smul_lt_top_iff {x : ℝ≥0} {y : ℝ≥0∞} (hx : x ≠ 0) : x • y < ⊤ ↔ y < ⊤ := by + rw [lt_top_iff_ne_top, lt_top_iff_ne_top, nnreal_smul_ne_top_iff hx] + end Actions end ENNReal diff --git a/Mathlib/Data/Fin/Basic.lean b/Mathlib/Data/Fin/Basic.lean index 12906e1a342c1..2e9510a903d4c 100644 --- a/Mathlib/Data/Fin/Basic.lean +++ b/Mathlib/Data/Fin/Basic.lean @@ -402,12 +402,12 @@ alias val_nat_cast := val_natCast -- Porting note: is this the right name for things involving `Nat.cast`? /-- Converting an in-range number to `Fin (n + 1)` produces a result -whose value is the original number. -/ +whose value is the original number. -/ theorem val_cast_of_lt {n : ℕ} [NeZero n] {a : ℕ} (h : a < n) : (a : Fin n).val = a := Nat.mod_eq_of_lt h /-- If `n` is non-zero, converting the value of a `Fin n` to `Fin n` results -in the same value. -/ +in the same value. -/ @[simp] theorem cast_val_eq_self {n : ℕ} [NeZero n] (a : Fin n) : (a.val : Fin n) = a := Fin.ext <| val_cast_of_lt a.isLt @@ -533,7 +533,7 @@ lemma castAdd_injective (m n : ℕ) : Injective (@Fin.castAdd m n) := castLE_inj lemma castSucc_injective (n : ℕ) : Injective (@Fin.castSucc n) := castAdd_injective _ _ -/-- `Fin.castLE` as an `Embedding`, `castLEEmb h i` embeds `i` into a larger `Fin` type. -/ +/-- `Fin.castLE` as an `Embedding`, `castLEEmb h i` embeds `i` into a larger `Fin` type. -/ @[simps! apply] def castLEEmb (h : n ≤ m) : Fin n ↪ Fin m where toFun := castLE h @@ -1519,3 +1519,5 @@ instance toExpr (n : ℕ) : Lean.ToExpr (Fin n) where q(OfNat.ofNat $i) end Fin + +set_option linter.style.longFile 1700 diff --git a/Mathlib/Data/Finmap.lean b/Mathlib/Data/Finmap.lean index fb4a761948449..0b560beb25f2d 100644 --- a/Mathlib/Data/Finmap.lean +++ b/Mathlib/Data/Finmap.lean @@ -17,7 +17,7 @@ open List variable {α : Type u} {β : α → Type v} -/-! ### Multisets of sigma types-/ +/-! ### Multisets of sigma types -/ namespace Multiset diff --git a/Mathlib/Data/Finset/Basic.lean b/Mathlib/Data/Finset/Basic.lean index 4f229d81672f8..ee0a6eba77e0c 100644 --- a/Mathlib/Data/Finset/Basic.lean +++ b/Mathlib/Data/Finset/Basic.lean @@ -3070,3 +3070,5 @@ def proveFinsetNonempty {u : Level} {α : Q(Type u)} (s : Q(Finset $α)) : Lean.getExprMVarAssignment? mvar end Mathlib.Meta + +set_option linter.style.longFile 3100 diff --git a/Mathlib/Data/Finset/Lattice.lean b/Mathlib/Data/Finset/Lattice.lean index c36b539aba616..c35033076c3b9 100644 --- a/Mathlib/Data/Finset/Lattice.lean +++ b/Mathlib/Data/Finset/Lattice.lean @@ -1951,3 +1951,5 @@ theorem set_biInter_biUnion (s : Finset γ) (t : γ → Finset α) (f : α → S iInf_biUnion s t f end Finset + +set_option linter.style.longFile 2100 diff --git a/Mathlib/Data/Finset/PiInduction.lean b/Mathlib/Data/Finset/PiInduction.lean index d040789ab2d0d..4eb4a769d4e6a 100644 --- a/Mathlib/Data/Finset/PiInduction.lean +++ b/Mathlib/Data/Finset/PiInduction.lean @@ -65,7 +65,7 @@ maps provided that it is true on `fun _ ↦ ∅` and for any function `g : ∀ i `i : ι`, and `x ∉ g i`, `p g` implies `p (update g i (insert x (g i)))`. See also `Finset.induction_on_pi_max` and `Finset.induction_on_pi_min` for specialized versions -that require `∀ i, LinearOrder (α i)`. -/ +that require `∀ i, LinearOrder (α i)`. -/ theorem induction_on_pi {p : (∀ i, Finset (α i)) → Prop} (f : ∀ i, Finset (α i)) (h0 : p fun _ ↦ ∅) (step : ∀ (g : ∀ i, Finset (α i)) (i : ι), ∀ x ∉ g i, p g → p (update g i (insert x (g i)))) : p f := diff --git a/Mathlib/Data/Finset/Pointwise/Basic.lean b/Mathlib/Data/Finset/Pointwise/Basic.lean index ffbddd2367556..756533ccc323c 100644 --- a/Mathlib/Data/Finset/Pointwise/Basic.lean +++ b/Mathlib/Data/Finset/Pointwise/Basic.lean @@ -1995,3 +1995,5 @@ instance Nat.decidablePred_mem_vadd_set {s : Set ℕ} [DecidablePred (· ∈ s)] DecidablePred (· ∈ a +ᵥ s) := fun n ↦ decidable_of_iff' (a ≤ n ∧ n - a ∈ s) <| by simp only [Set.mem_vadd_set, vadd_eq_add]; aesop + +set_option linter.style.longFile 2100 diff --git a/Mathlib/Data/Finset/Preimage.lean b/Mathlib/Data/Finset/Preimage.lean index d5c3ba82dd978..840e7e2c93e3e 100644 --- a/Mathlib/Data/Finset/Preimage.lean +++ b/Mathlib/Data/Finset/Preimage.lean @@ -21,7 +21,7 @@ namespace Finset section Preimage -/-- Preimage of `s : Finset β` under a map `f` injective on `f ⁻¹' s` as a `Finset`. -/ +/-- Preimage of `s : Finset β` under a map `f` injective on `f ⁻¹' s` as a `Finset`. -/ noncomputable def preimage (s : Finset β) (f : α → β) (hf : Set.InjOn f (f ⁻¹' ↑s)) : Finset α := (s.finite_toSet.preimage hf).toFinset diff --git a/Mathlib/Data/Finsupp/Basic.lean b/Mathlib/Data/Finsupp/Basic.lean index 3b6f3678beba3..229c71ade1553 100644 --- a/Mathlib/Data/Finsupp/Basic.lean +++ b/Mathlib/Data/Finsupp/Basic.lean @@ -1702,3 +1702,5 @@ theorem sigmaFinsuppAddEquivPiFinsupp_apply {α : Type*} {ιs : η → Type*} [A end Sigma end Finsupp + +set_option linter.style.longFile 1900 diff --git a/Mathlib/Data/Finsupp/Defs.lean b/Mathlib/Data/Finsupp/Defs.lean index 27cd616250015..4e65162454d8b 100644 --- a/Mathlib/Data/Finsupp/Defs.lean +++ b/Mathlib/Data/Finsupp/Defs.lean @@ -910,6 +910,20 @@ theorem support_add_eq [DecidableEq α] {g₁ g₂ : α →₀ M} (h : Disjoint theorem single_add (a : α) (b₁ b₂ : M) : single a (b₁ + b₂) = single a b₁ + single a b₂ := (zipWith_single_single _ _ _ _ _).symm +theorem support_single_add {a : α} {b : M} {f : α →₀ M} (ha : a ∉ f.support) (hb : b ≠ 0) : + support (single a b + f) = cons a f.support ha := by + classical + have H := support_single_ne_zero a hb + rw [support_add_eq, H, cons_eq_insert, insert_eq] + rwa [H, disjoint_singleton_left] + +theorem support_add_single {a : α} {b : M} {f : α →₀ M} (ha : a ∉ f.support) (hb : b ≠ 0) : + support (f + single a b) = cons a f.support ha := by + classical + have H := support_single_ne_zero a hb + rw [support_add_eq, H, union_comm, cons_eq_insert, insert_eq] + rwa [H, disjoint_singleton_right] + instance instAddZeroClass : AddZeroClass (α →₀ M) := DFunLike.coe_injective.addZeroClass _ coe_zero coe_add diff --git a/Mathlib/Data/Fintype/Basic.lean b/Mathlib/Data/Fintype/Basic.lean index 93e4e1e02e765..8461081c88f2c 100644 --- a/Mathlib/Data/Fintype/Basic.lean +++ b/Mathlib/Data/Fintype/Basic.lean @@ -593,7 +593,7 @@ namespace Set variable {s t : Set α} -/-- Construct a finset enumerating a set `s`, given a `Fintype` instance. -/ +/-- Construct a finset enumerating a set `s`, given a `Fintype` instance. -/ def toFinset (s : Set α) [Fintype s] : Finset α := (@Finset.univ s _).map <| Function.Embedding.subtype _ diff --git a/Mathlib/Data/Int/Bitwise.lean b/Mathlib/Data/Int/Bitwise.lean index 646ee6284ae3e..664c817a6e578 100644 --- a/Mathlib/Data/Int/Bitwise.lean +++ b/Mathlib/Data/Int/Bitwise.lean @@ -24,7 +24,7 @@ def div2 : ℤ → ℤ | (n : ℕ) => n.div2 | -[n +1] => negSucc n.div2 -/-- `bodd n` returns `true` if `n` is odd-/ +/-- `bodd n` returns `true` if `n` is odd -/ def bodd : ℤ → Bool | (n : ℕ) => n.bodd | -[n +1] => not (n.bodd) @@ -81,7 +81,7 @@ def ldiff : ℤ → ℤ → ℤ | -[m +1], -[n +1] => Nat.ldiff n m -- Porting note: I don't know why `Nat.xor'` got the prime, but I'm matching this change here -/-- `xor` computes the bitwise `xor` of two natural numbers-/ +/-- `xor` computes the bitwise `xor` of two natural numbers -/ protected def xor : ℤ → ℤ → ℤ | (m : ℕ), (n : ℕ) => (m ^^^ n) | (m : ℕ), -[n +1] => -[(m ^^^ n) +1] diff --git a/Mathlib/Data/List/Basic.lean b/Mathlib/Data/List/Basic.lean index 5fdbd0133fd78..4465b274e778c 100644 --- a/Mathlib/Data/List/Basic.lean +++ b/Mathlib/Data/List/Basic.lean @@ -2449,3 +2449,5 @@ lemma lookup_graph (f : α → β) {a : α} {as : List α} (h : a ∈ as) : end lookup end List + +set_option linter.style.longFile 2700 diff --git a/Mathlib/Data/List/Chain.lean b/Mathlib/Data/List/Chain.lean index a6c2410414b7d..66a86676c4ae9 100644 --- a/Mathlib/Data/List/Chain.lean +++ b/Mathlib/Data/List/Chain.lean @@ -318,31 +318,52 @@ theorem exists_chain_of_relationReflTransGen (h : Relation.ReflTransGen r a b) : refine ⟨d :: l, Chain.cons e hl₁, ?_⟩ rwa [getLast_cons_cons] +/-- Given a chain from `a` to `b`, and a predicate true at `a`, if `r x y → p x → p y` then +the predicate is true everywhere in the chain. +That is, we can propagate the predicate down the chain. +-/ +theorem Chain.induction (p : α → Prop) (l : List α) (h : Chain r a l) + (carries : ∀ ⦃x y : α⦄, r x y → p x → p y) (initial : p a) : ∀ i ∈ l, p i := by + induction h with + | nil => simp + | @cons a b t hab _ h_ind => + simp only [mem_cons, forall_eq_or_imp] + exact ⟨carries hab initial, h_ind (carries hab initial)⟩ + +/-- A version of `List.Chain.induction` for `List.Chain'` +-/ +theorem Chain'.induction (p : α → Prop) (l : List α) (h : Chain' r l) + (carries : ∀ ⦃x y : α⦄, r x y → p x → p y) (initial : (lne : l ≠ []) → p (l.head lne)) : + ∀ i ∈ l, p i := by + unfold Chain' at h + split at h + · simp + · simp_all only [ne_eq, not_false_eq_true, head_cons, true_implies, mem_cons, forall_eq_or_imp, + true_and] + exact h.induction p _ carries initial + /-- Given a chain from `a` to `b`, and a predicate true at `b`, if `r x y → p y → p x` then the predicate is true everywhere in the chain and at `a`. That is, we can propagate the predicate up the chain. -/ -theorem Chain.induction (p : α → Prop) (l : List α) (h : Chain r a l) +theorem Chain.backwards_induction (p : α → Prop) (l : List α) (h : Chain r a l) (hb : getLast (a :: l) (cons_ne_nil _ _) = b) (carries : ∀ ⦃x y : α⦄, r x y → p y → p x) (final : p b) : ∀ i ∈ a :: l, p i := by - induction' l with _ _ l_ih generalizing a - · cases hb - simpa using final - · rw [chain_cons] at h - simp only [mem_cons] - rintro _ (rfl | H) - · apply carries h.1 (l_ih h.2 hb _ (mem_cons.2 (Or.inl rfl))) - · apply l_ih h.2 hb _ (mem_cons.2 H) + have : Chain' (flip (flip r)) (a :: l) := by simpa [Chain'] + replace this := chain'_reverse.mpr this + simp_rw (config := {singlePass := true}) [← List.mem_reverse] + apply this.induction _ _ (fun _ _ h ↦ carries h) + simpa only [ne_eq, reverse_eq_nil_iff, not_false_eq_true, head_reverse, forall_true_left, hb] /-- Given a chain from `a` to `b`, and a predicate true at `b`, if `r x y → p y → p x` then the predicate is true at `a`. That is, we can propagate the predicate all the way up the chain. -/ @[elab_as_elim] -theorem Chain.induction_head (p : α → Prop) (l : List α) (h : Chain r a l) +theorem Chain.backwards_induction_head (p : α → Prop) (l : List α) (h : Chain r a l) (hb : getLast (a :: l) (cons_ne_nil _ _) = b) (carries : ∀ ⦃x y : α⦄, r x y → p y → p x) (final : p b) : p a := - (Chain.induction p l h hb carries final) _ (mem_cons_self _ _) + (Chain.backwards_induction p l h hb carries final) _ (mem_cons_self _ _) /-- If there is an `r`-chain starting from `a` and ending at `b`, then `a` and `b` are related by the @@ -350,7 +371,7 @@ reflexive transitive closure of `r`. The converse of `exists_chain_of_relationRe -/ theorem relationReflTransGen_of_exists_chain (l : List α) (hl₁ : Chain r a l) (hl₂ : getLast (a :: l) (cons_ne_nil _ _) = b) : Relation.ReflTransGen r a b := - Chain.induction_head _ l hl₁ hl₂ (fun _ _ => Relation.ReflTransGen.head) + Chain.backwards_induction_head _ l hl₁ hl₂ (fun _ _ => Relation.ReflTransGen.head) Relation.ReflTransGen.refl theorem Chain'.cons_of_le [LinearOrder α] {a : α} {as m : List α} @@ -376,6 +397,25 @@ theorem Chain'.cons_of_le [LinearOrder α] {a : α} {as m : List α} exact (List.lt_iff_lex_lt _ _).mp (List.lt.head _ _ hh) · simp_all only [List.cons.injEq, le_refl] +lemma Chain'.chain {α : Type*} {R : α → α → Prop} {l : List α} {v : α} + (hl : l.Chain' R) (hv : (lne : l ≠ []) → R v (l.head lne)) : l.Chain R v := by + rw [List.chain_iff_get] + constructor + · intro h + rw [List.get_mk_zero] + apply hv + · exact List.chain'_iff_get.mp hl + +lemma Chain'.iterate_eq_of_apply_eq {α : Type*} {f : α → α} {l : List α} + (hl : l.Chain' (fun x y ↦ f x = y)) (i : ℕ) (hi : i < l.length) : + f^[i] l[0] = l[i] := by + induction' i with i h + · rfl + · rw [Function.iterate_succ', Function.comp_apply, h (by omega)] + rw [List.chain'_iff_get] at hl + apply hl + omega + end List diff --git a/Mathlib/Data/List/Pi.lean b/Mathlib/Data/List/Pi.lean index 25244772bc6f4..629d8a1e4f855 100644 --- a/Mathlib/Data/List/Pi.lean +++ b/Mathlib/Data/List/Pi.lean @@ -24,12 +24,12 @@ def nil (α : ι → Sort*) : (∀ i ∈ ([] : List ι), α i) := variable {i : ι} {l : List ι} -/-- Given `f` a function whose domain is `i :: l`, get its value at `i`. -/ +/-- Given `f` a function whose domain is `i :: l`, get its value at `i`. -/ def head (f : ∀ j ∈ i :: l, α j) : α i := f i (mem_cons_self _ _) /-- Given `f` a function whose domain is `i :: l`, produce a function whose domain -is restricted to `l`. -/ +is restricted to `l`. -/ def tail (f : ∀ j ∈ i :: l, α j) : ∀ j ∈ l, α j := fun j hj ↦ f j (mem_cons_of_mem _ hj) diff --git a/Mathlib/Data/Matrix/Basic.lean b/Mathlib/Data/Matrix/Basic.lean index 83b238d18c581..1b436af496178 100644 --- a/Mathlib/Data/Matrix/Basic.lean +++ b/Mathlib/Data/Matrix/Basic.lean @@ -2533,3 +2533,5 @@ theorem map_mulVec [NonAssocSemiring R] [NonAssocSemiring S] (f : R →+* S) (M simp only [Matrix.mulVec, Matrix.map_apply, RingHom.map_dotProduct, Function.comp] end RingHom + +set_option linter.style.longFile 2700 diff --git a/Mathlib/Data/Matrix/ColumnRowPartitioned.lean b/Mathlib/Data/Matrix/ColumnRowPartitioned.lean index 8d0ba9f8ba139..6961195e3a83e 100644 --- a/Mathlib/Data/Matrix/ColumnRowPartitioned.lean +++ b/Mathlib/Data/Matrix/ColumnRowPartitioned.lean @@ -74,11 +74,11 @@ lemma toRows₂_apply (A : Matrix (m₁ ⊕ m₂) n R) (i : m₂) (j : n) : (toRows₂ A) i j = A (Sum.inr i) j := rfl @[simp] -lemma toRows₁_fromRows (A₁ : Matrix m₁ n R) (A₂ : Matrix m₂ n R) : +lemma toRows₁_fromRows (A₁ : Matrix m₁ n R) (A₂ : Matrix m₂ n R) : toRows₁ (fromRows A₁ A₂) = A₁ := rfl @[simp] -lemma toRows₂_fromRows (A₁ : Matrix m₁ n R) (A₂ : Matrix m₂ n R) : +lemma toRows₂_fromRows (A₁ : Matrix m₁ n R) (A₂ : Matrix m₂ n R) : toRows₂ (fromRows A₁ A₂) = A₂ := rfl @[simp] diff --git a/Mathlib/Data/Matrix/Composition.lean b/Mathlib/Data/Matrix/Composition.lean index 31de61ff426dd..de52659e526d6 100644 --- a/Mathlib/Data/Matrix/Composition.lean +++ b/Mathlib/Data/Matrix/Composition.lean @@ -24,7 +24,7 @@ Semiring, and Algebra over a CommSemiring K. namespace Matrix -variable (I J K L R : Type*) +variable (I J K L R : Type*) /-- I by J matrix where each entry is a K by L matrix is equivalent to I × K by J × L matrix -/ diff --git a/Mathlib/Data/Matroid/Basic.lean b/Mathlib/Data/Matroid/Basic.lean index d2f447b1e4ab5..5f098b5a7e053 100644 --- a/Mathlib/Data/Matroid/Basic.lean +++ b/Mathlib/Data/Matroid/Basic.lean @@ -169,7 +169,7 @@ def Matroid.ExchangeProperty {α : Type _} (P : Set α → Prop) : Prop := ∀ X Y, P X → P Y → ∀ a ∈ X \ Y, ∃ b ∈ Y \ X, P (insert b (X \ {a})) /-- A set `X` has the maximal subset property for a predicate `P` if every subset of `X` satisfying - `P` is contained in a maximal subset of `X` satisfying `P`. -/ + `P` is contained in a maximal subset of `X` satisfying `P`. -/ def Matroid.ExistsMaximalSubsetProperty {α : Type _} (P : Set α → Prop) (X : Set α) : Prop := ∀ I, P I → I ⊆ X → ∃ J, I ⊆ J ∧ Maximal (fun K ↦ P K ∧ K ⊆ X) J @@ -713,7 +713,7 @@ def Basis (M : Matroid α) (I X : Set α) : Prop := Maximal (fun A ↦ M.Indep A ∧ A ⊆ X) I ∧ X ⊆ M.E /-- A `Basis'` is a basis without the requirement that `X ⊆ M.E`. This is convenient for some - API building, especially when working with rank and closure. -/ + API building, especially when working with rank and closure. -/ def Basis' (M : Matroid α) (I X : Set α) : Prop := Maximal (fun A ↦ M.Indep A ∧ A ⊆ X) I diff --git a/Mathlib/Data/Matroid/Map.lean b/Mathlib/Data/Matroid/Map.lean index b231376efdada..bf22fe80c5b92 100644 --- a/Mathlib/Data/Matroid/Map.lean +++ b/Mathlib/Data/Matroid/Map.lean @@ -501,7 +501,7 @@ end map section mapSetEquiv /-- Map `M : Matroid α` to a `Matroid β` with ground set `E` using an equivalence `M.E ≃ E`. -Defined using `Matroid.ofExistsMatroid` for better defeq. -/ +Defined using `Matroid.ofExistsMatroid` for better defeq. -/ def mapSetEquiv (M : Matroid α) {E : Set β} (e : M.E ≃ E) : Matroid β := Matroid.ofExistsMatroid E (fun I ↦ (M.Indep ↑(e.symm '' (E ↓∩ I)) ∧ I ⊆ E)) ⟨M.mapSetEmbedding (e.toEmbedding.trans <| Function.Embedding.subtype _), by diff --git a/Mathlib/Data/Matroid/Restrict.lean b/Mathlib/Data/Matroid/Restrict.lean index 46d88f70b7cf7..013d3c6c68740 100644 --- a/Mathlib/Data/Matroid/Restrict.lean +++ b/Mathlib/Data/Matroid/Restrict.lean @@ -36,7 +36,7 @@ It also proves some `Basis` analogues of `Base` lemmas that, while they could be ## Implementation Notes Since `R` and `M.E` are both terms in `Set α`, to define the restriction `M ↾ R`, -we need to either insist that `R ⊆ M.E`, or to say what happens when `R` contains the junk +we need to either insist that `R ⊆ M.E`, or to say what happens when `R` contains the junk outside `M.E`. It turns out that `R ⊆ M.E` is just an unnecessary hypothesis; if we say the restriction @@ -115,7 +115,7 @@ section restrict /-- Change the ground set of a matroid to some `R : Set α`. The independent sets of the restriction are the independent subsets of the new ground set. Most commonly used when `R ⊆ M.E`, - but it is convenient not to require this. The elements of `R \ M.E` become 'loops'. -/ + but it is convenient not to require this. The elements of `R \ M.E` become 'loops'. -/ def restrict (M : Matroid α) (R : Set α) : Matroid α := (M.restrictIndepMatroid R).matroid /-- `M ↾ R` means `M.restrict R`. -/ diff --git a/Mathlib/Data/Multiset/Basic.lean b/Mathlib/Data/Multiset/Basic.lean index 84d90d90e8178..ed2e69a1ace4b 100644 --- a/Mathlib/Data/Multiset/Basic.lean +++ b/Mathlib/Data/Multiset/Basic.lean @@ -26,7 +26,7 @@ open List Subtype Nat Function variable {α : Type*} {β : Type v} {γ : Type*} /-- `Multiset α` is the quotient of `List α` by list permutation. The result - is a type of finite sets with duplicates allowed. -/ + is a type of finite sets with duplicates allowed. -/ def Multiset.{u} (α : Type u) : Type u := Quotient (List.isSetoid α) @@ -2737,3 +2737,5 @@ theorem coe_subsingletonEquiv [Subsingleton α] : @[deprecated (since := "2023-12-27")] alias card_lt_of_lt := card_lt_card end Multiset + +set_option linter.style.longFile 2900 diff --git a/Mathlib/Data/NNReal/Basic.lean b/Mathlib/Data/NNReal/Basic.lean index f20ef830308b8..5320cfd712a80 100644 --- a/Mathlib/Data/NNReal/Basic.lean +++ b/Mathlib/Data/NNReal/Basic.lean @@ -155,6 +155,9 @@ protected theorem coe_injective : Injective ((↑) : ℝ≥0 → ℝ) := Subtype @[simp, norm_cast] lemma coe_one : ((1 : ℝ≥0) : ℝ) = 1 := rfl +@[simp] lemma mk_zero : (⟨0, le_rfl⟩ : ℝ≥0) = 0 := rfl +@[simp] lemma mk_one : (⟨1, zero_le_one⟩ : ℝ≥0) = 1 := rfl + @[simp, norm_cast] protected theorem coe_add (r₁ r₂ : ℝ≥0) : ((r₁ + r₂ : ℝ≥0) : ℝ) = r₁ + r₂ := rfl diff --git a/Mathlib/Data/Nat/Bits.lean b/Mathlib/Data/Nat/Bits.lean index 5995d94fe4549..2ce78c870ed24 100644 --- a/Mathlib/Data/Nat/Bits.lean +++ b/Mathlib/Data/Nat/Bits.lean @@ -43,7 +43,7 @@ def boddDiv2 : ℕ → Bool × ℕ /-- `div2 n = ⌊n/2⌋` the greatest integer smaller than `n/2`-/ def div2 (n : ℕ) : ℕ := (boddDiv2 n).2 -/-- `bodd n` returns `true` if `n` is odd-/ +/-- `bodd n` returns `true` if `n` is odd -/ def bodd (n : ℕ) : Bool := (boddDiv2 n).1 @[simp] lemma bodd_zero : bodd 0 = false := rfl @@ -132,7 +132,7 @@ lemma bit_zero : bit false 0 = 0 := /-- `shiftLeft' b m n` performs a left shift of `m` `n` times and adds the bit `b` as the least significant bit each time. - Returns the corresponding natural number-/ + Returns the corresponding natural number -/ def shiftLeft' (b : Bool) (m : ℕ) : ℕ → ℕ | 0 => m | n + 1 => bit b (shiftLeft' b m n) diff --git a/Mathlib/Data/Nat/Cast/Defs.lean b/Mathlib/Data/Nat/Cast/Defs.lean index 0a184083269a5..c346fe012240d 100644 --- a/Mathlib/Data/Nat/Cast/Defs.lean +++ b/Mathlib/Data/Nat/Cast/Defs.lean @@ -83,7 +83,7 @@ class AddMonoidWithOne (R : Type*) extends NatCast R, AddMonoid R, One R where /-- The canonical map `ℕ → R` is a homomorphism. -/ natCast_succ : ∀ n, natCast (n + 1) = natCast n + 1 := by intros; rfl -/-- An `AddCommMonoidWithOne` is an `AddMonoidWithOne` satisfying `a + b = b + a`. -/ +/-- An `AddCommMonoidWithOne` is an `AddMonoidWithOne` satisfying `a + b = b + a`. -/ class AddCommMonoidWithOne (R : Type*) extends AddMonoidWithOne R, AddCommMonoid R library_note "coercion into rings" diff --git a/Mathlib/Data/Nat/Choose/Bounds.lean b/Mathlib/Data/Nat/Choose/Bounds.lean index 22dc4a8bb5371..d4b21ddf606d9 100644 --- a/Mathlib/Data/Nat/Choose/Bounds.lean +++ b/Mathlib/Data/Nat/Choose/Bounds.lean @@ -15,7 +15,7 @@ bounds `n^r/r^r ≤ n.choose r ≤ e^r n^r/r^r` in the future. ## Main declarations -* `Nat.choose_le_pow`: `n.choose r ≤ n^r / r!` +* `Nat.choose_le_pow_div`: `n.choose r ≤ n^r / r!` * `Nat.pow_le_choose`: `(n + 1 - r)^r / r! ≤ n.choose r`. Beware of the fishy ℕ-subtraction. -/ @@ -26,13 +26,22 @@ variable {α : Type*} [LinearOrderedSemifield α] namespace Nat -theorem choose_le_pow (r n : ℕ) : (n.choose r : α) ≤ (n ^ r : α) / r ! := by +theorem choose_le_pow_div (r n : ℕ) : (n.choose r : α) ≤ (n ^ r : α) / r ! := by rw [le_div_iff₀'] · norm_cast rw [← Nat.descFactorial_eq_factorial_mul_choose] exact n.descFactorial_le_pow r exact mod_cast r.factorial_pos +lemma choose_le_descFactorial (n k : ℕ) : n.choose k ≤ n.descFactorial k := by + rw [choose_eq_descFactorial_div_factorial] + exact Nat.div_le_self _ _ + +/-- This lemma was changed on 2024/08/29, the old statement is available +in `Nat.choose_le_pow_div`. -/ +lemma choose_le_pow (n k : ℕ) : n.choose k ≤ n ^ k := + (choose_le_descFactorial n k).trans (descFactorial_le_pow n k) + -- horrific casting is due to ℕ-subtraction theorem pow_le_choose (r n : ℕ) : ((n + 1 - r : ℕ) ^ r : α) / r ! ≤ n.choose r := by rw [div_le_iff₀'] diff --git a/Mathlib/Data/Nat/Choose/Sum.lean b/Mathlib/Data/Nat/Choose/Sum.lean index 0ab264a555cb6..d9bafecbbe840 100644 --- a/Mathlib/Data/Nat/Choose/Sum.lean +++ b/Mathlib/Data/Nat/Choose/Sum.lean @@ -116,7 +116,7 @@ theorem four_pow_le_two_mul_add_one_mul_central_binom (n : ℕ) : _ ≤ ∑ m ∈ range (2 * n + 1), (2 * n).choose (2 * n / 2) := by gcongr; apply choose_le_middle _ = (2 * n + 1) * choose (2 * n) n := by simp -/-- **Zhu Shijie's identity** aka hockey-stick identity. -/ +/-- **Zhu Shijie's identity** aka hockey-stick identity, version with `Icc`. -/ theorem sum_Icc_choose (n k : ℕ) : ∑ m ∈ Icc k n, m.choose k = (n + 1).choose (k + 1) := by rcases lt_or_le n k with h | h · rw [choose_eq_zero_of_lt (by omega), Icc_eq_empty_of_lt h, sum_empty] @@ -126,6 +126,20 @@ theorem sum_Icc_choose (n k : ℕ) : ∑ m ∈ Icc k n, m.choose k = (n + 1).cho rw [← Ico_insert_right (by omega), sum_insert (by simp), show Ico k (n + 1) = Icc k n by rfl, ih, choose_succ_succ' (n + 1)] +/-- **Zhu Shijie's identity** aka hockey-stick identity, version with `range`. +Summing `(i + k).choose k` for `i ∈ [0, n]` gives `(n + k + 1).choose (k + 1)`. + +Combinatorial interpretation: `(i + k).choose k` is the number of decompositions of `[0, i)` in +`k + 1` (possibly empty) intervals (this follows from a stars and bars description). In particular, +`(n + k + 1).choose (k + 1)` corresponds to decomposing `[0, n)` into `k + 2` intervals. +By putting away the last interval (of some length `n - i`), +we have to decompose the remaining interval `[0, i)` into `k + 1` intervals, hence the sum. -/ +lemma sum_range_add_choose (n k : ℕ) : + ∑ i ∈ Finset.range (n + 1), (i + k).choose k = (n + k + 1).choose (k + 1) := by + rw [← sum_Icc_choose, range_eq_Ico] + convert (sum_map _ (addRightEmbedding k) (·.choose k)).symm using 2 + rw [map_add_right_Ico, zero_add, add_right_comm, Nat.Ico_succ_right] + end Nat theorem Int.alternating_sum_range_choose {n : ℕ} : diff --git a/Mathlib/Data/Nat/Digits.lean b/Mathlib/Data/Nat/Digits.lean index 3465ed5369aa7..df846a781af97 100644 --- a/Mathlib/Data/Nat/Digits.lean +++ b/Mathlib/Data/Nat/Digits.lean @@ -345,7 +345,7 @@ theorem mul_ofDigits (n : ℕ) {b : ℕ} {l : List ℕ} : rw [List.map_cons, ofDigits_cons, ofDigits_cons, ← ih] ring -/-- The addition of ofDigits of two lists is equal to ofDigits of digit-wise addition of them-/ +/-- The addition of ofDigits of two lists is equal to ofDigits of digit-wise addition of them -/ theorem ofDigits_add_ofDigits_eq_ofDigits_zipWith_of_length_eq {b : ℕ} {l1 l2 : List ℕ} (h : l1.length = l2.length) : ofDigits b l1 + ofDigits b l2 = ofDigits b (l1.zipWith (· + ·) l2) := by diff --git a/Mathlib/Data/Nat/Factorization/Basic.lean b/Mathlib/Data/Nat/Factorization/Basic.lean index 62885ed5181d6..2dcb6d57355ac 100644 --- a/Mathlib/Data/Nat/Factorization/Basic.lean +++ b/Mathlib/Data/Nat/Factorization/Basic.lean @@ -530,7 +530,7 @@ theorem prod_pow_prime_padicValNat (n : Nat) (hn : n ≠ 0) (m : Nat) (pr : n < -- TODO: Port lemmas from `Data/Nat/Multiplicity` to here, re-written in terms of `factorization` /-- Exactly `n / p` naturals in `[1, n]` are multiples of `p`. -See `Nat.card_multiples'` for an alternative spelling of the statement. -/ +See `Nat.card_multiples'` for an alternative spelling of the statement. -/ theorem card_multiples (n p : ℕ) : card ((Finset.range n).filter fun e => p ∣ e + 1) = n / p := by induction' n with n hn · simp diff --git a/Mathlib/Data/Nat/Upto.lean b/Mathlib/Data/Nat/Upto.lean index 47b6802fa1c14..f62ea9e9062d1 100644 --- a/Mathlib/Data/Nat/Upto.lean +++ b/Mathlib/Data/Nat/Upto.lean @@ -28,7 +28,7 @@ no `j` less than `i` satisfies `p`. This is an initial segment of the natural numbers, up to and including the first value satisfying `p`. We will be particularly interested in the case where there exists a value -satisfying `p`, because in this case the `>` relation is well-founded. -/ +satisfying `p`, because in this case the `>` relation is well-founded. -/ abbrev Upto (p : ℕ → Prop) : Type := { i : ℕ // ∀ j < i, ¬p j } diff --git a/Mathlib/Data/Num/Lemmas.lean b/Mathlib/Data/Num/Lemmas.lean index c3669ef62772a..ac946c8f455bc 100644 --- a/Mathlib/Data/Num/Lemmas.lean +++ b/Mathlib/Data/Num/Lemmas.lean @@ -1576,3 +1576,5 @@ instance SNum.lt : LT SNum := instance SNum.le : LE SNum := ⟨fun a b => (a : ℤ) ≤ b⟩ + +set_option linter.style.longFile 1700 diff --git a/Mathlib/Data/Ordmap/Ordset.lean b/Mathlib/Data/Ordmap/Ordset.lean index fc25de56b3862..131c4b17eee60 100644 --- a/Mathlib/Data/Ordmap/Ordset.lean +++ b/Mathlib/Data/Ordmap/Ordset.lean @@ -1578,3 +1578,5 @@ def map {β} [Preorder β] (f : α → β) (f_strict_mono : StrictMono f) (s : O ⟨Ordnode.map f s.val, Ordnode.map.valid f_strict_mono s.property⟩ end Ordset + +set_option linter.style.longFile 1700 diff --git a/Mathlib/Data/PFun.lean b/Mathlib/Data/PFun.lean index 3e342591b8463..d5759dbf56966 100644 --- a/Mathlib/Data/PFun.lean +++ b/Mathlib/Data/PFun.lean @@ -58,7 +58,7 @@ open Function def PFun (α β : Type*) := α → Part β -/-- `α →. β` is notation for the type `PFun α β` of partial functions from `α` to `β`. -/ +/-- `α →. β` is notation for the type `PFun α β` of partial functions from `α` to `β`. -/ infixr:25 " →. " => PFun namespace PFun diff --git a/Mathlib/Data/PFunctor/Multivariate/M.lean b/Mathlib/Data/PFunctor/Multivariate/M.lean index 8a40846b7c6fc..3e892578847dd 100644 --- a/Mathlib/Data/PFunctor/Multivariate/M.lean +++ b/Mathlib/Data/PFunctor/Multivariate/M.lean @@ -58,7 +58,7 @@ variable {n : ℕ} (P : MvPFunctor.{u} (n + 1)) /-- A path from the root of a tree to one of its node -/ inductive M.Path : P.last.M → Fin2 n → Type u - | root (x : P.last.M) + | root (x : P.last.M) (a : P.A) (f : P.last.B a → P.last.M) (h : PFunctor.M.dest x = ⟨a, f⟩) @@ -268,7 +268,7 @@ theorem M.bisim₀ {α : TypeVec n} (R : P.M α → P.M α → Prop) (h₀ : Equ intro i replace h₁ := congr_fun (congr_fun h₁ Fin2.fz) i simp only [TypeVec.comp, appendFun, splitFun] at h₁ - replace h₁ := Quot.exact _ h₁ + replace h₁ := Quot.eqvGen_exact _ h₁ rw [h₀.eqvGen_iff] at h₁ exact h₁ diff --git a/Mathlib/Data/PNat/Xgcd.lean b/Mathlib/Data/PNat/Xgcd.lean index 03c2d2cb0227d..f5c3a61a1fe5f 100644 --- a/Mathlib/Data/PNat/Xgcd.lean +++ b/Mathlib/Data/PNat/Xgcd.lean @@ -202,7 +202,7 @@ theorem flip_v : (flip u).v = u.v.swap := by · simp only ring -/-- Properties of division with remainder for a / b. -/ +/-- Properties of division with remainder for a / b. -/ theorem rq_eq : u.r + (u.bp + 1) * u.q = u.ap + 1 := Nat.mod_add_div (u.ap + 1) (u.bp + 1) diff --git a/Mathlib/Data/Prod/Lex.lean b/Mathlib/Data/Prod/Lex.lean index 6aa1e4d947f7b..f55eac2c324de 100644 --- a/Mathlib/Data/Prod/Lex.lean +++ b/Mathlib/Data/Prod/Lex.lean @@ -41,7 +41,7 @@ instance decidableEq (α β : Type*) [DecidableEq α] [DecidableEq β] : Decidab instance inhabited (α β : Type*) [Inhabited α] [Inhabited β] : Inhabited (α ×ₗ β) := instInhabitedProd -/-- Dictionary / lexicographic ordering on pairs. -/ +/-- Dictionary / lexicographic ordering on pairs. -/ instance instLE (α β : Type*) [LT α] [LE β] : LE (α ×ₗ β) where le := Prod.Lex (· < ·) (· ≤ ·) instance instLT (α β : Type*) [LT α] [LT β] : LT (α ×ₗ β) where lt := Prod.Lex (· < ·) (· < ·) diff --git a/Mathlib/Data/Quot.lean b/Mathlib/Data/Quot.lean index 96c565a5a7a4f..e17474cc74503 100644 --- a/Mathlib/Data/Quot.lean +++ b/Mathlib/Data/Quot.lean @@ -267,7 +267,7 @@ end Quotient theorem Quot.eq {α : Type*} {r : α → α → Prop} {x y : α} : Quot.mk r x = Quot.mk r y ↔ EqvGen r x y := - ⟨Quot.exact r, Quot.EqvGen_sound⟩ + ⟨Quot.eqvGen_exact r, Quot.eqvGen_sound⟩ @[simp] theorem Quotient.eq [r : Setoid α] {x y : α} : Quotient.mk r x = ⟦y⟧ ↔ x ≈ y := diff --git a/Mathlib/Data/Real/EReal.lean b/Mathlib/Data/Real/EReal.lean index d0a0be313b72f..4ff49b8b9459b 100644 --- a/Mathlib/Data/Real/EReal.lean +++ b/Mathlib/Data/Real/EReal.lean @@ -1560,7 +1560,7 @@ lemma div_right_distrib_of_nonneg {a b c : EReal} (h : 0 ≤ a) (h' : 0 ≤ b) : (a + b) / c = (a / c) + (b / c) := EReal.right_distrib_of_nonneg h h' -/-! #### Division and Order s-/ +/-! #### Division and Order s -/ lemma monotone_div_right_of_nonneg {b : EReal} (h : 0 ≤ b) : Monotone fun a ↦ a / b := fun _ _ h' ↦ mul_le_mul_of_nonneg_right h' (inv_nonneg_of_nonneg h) @@ -1680,3 +1680,5 @@ unsafe def positivity_coe_ennreal_ereal : expr → tactic strictness end Tactic -/ + +set_option linter.style.longFile 1800 diff --git a/Mathlib/Data/Real/Hyperreal.lean b/Mathlib/Data/Real/Hyperreal.lean index 3ec6b4835c02e..68aee623dbde7 100644 --- a/Mathlib/Data/Real/Hyperreal.lean +++ b/Mathlib/Data/Real/Hyperreal.lean @@ -127,11 +127,11 @@ theorem ofSeq_surjective : Function.Surjective ofSeq := Quot.exists_rep theorem ofSeq_lt_ofSeq {f g : ℕ → ℝ} : ofSeq f < ofSeq g ↔ ∀ᶠ n in hyperfilter ℕ, f n < g n := Germ.coe_lt -/-- A sample infinitesimal hyperreal-/ +/-- A sample infinitesimal hyperreal -/ noncomputable def epsilon : ℝ* := ofSeq fun n => n⁻¹ -/-- A sample infinite hyperreal-/ +/-- A sample infinite hyperreal -/ noncomputable def omega : ℝ* := ofSeq Nat.cast @[inherit_doc] scoped notation "ε" => Hyperreal.epsilon diff --git a/Mathlib/Data/Real/Sqrt.lean b/Mathlib/Data/Real/Sqrt.lean index 6780b6ca40871..48f8aad052901 100644 --- a/Mathlib/Data/Real/Sqrt.lean +++ b/Mathlib/Data/Real/Sqrt.lean @@ -127,8 +127,7 @@ theorem continuous_sqrt : Continuous (√· : ℝ → ℝ) := theorem sqrt_eq_zero_of_nonpos (h : x ≤ 0) : sqrt x = 0 := by simp [sqrt, Real.toNNReal_eq_zero.2 h] -theorem sqrt_nonneg (x : ℝ) : 0 ≤ √x := - NNReal.coe_nonneg _ +@[simp] theorem sqrt_nonneg (x : ℝ) : 0 ≤ √x := NNReal.coe_nonneg _ @[simp] theorem mul_self_sqrt (h : 0 ≤ x) : √x * √x = x := by diff --git a/Mathlib/Data/Rel.lean b/Mathlib/Data/Rel.lean index a0fbadb670218..27adb8a69b26d 100644 --- a/Mathlib/Data/Rel.lean +++ b/Mathlib/Data/Rel.lean @@ -333,7 +333,7 @@ theorem graph_injective : Injective (graph : (α → β) → Rel α β) := by @[simp] lemma graph_inj {f g : α → β} : f.graph = g.graph ↔ f = g := graph_injective.eq_iff -theorem graph_id : graph id = @Eq α := by simp (config := { unfoldPartialApp := true }) [graph] +theorem graph_id : graph id = @Eq α := by simp (config := { unfoldPartialApp := true }) [graph] theorem graph_comp {f : β → γ} {g : α → β} : graph (f ∘ g) = Rel.comp (graph g) (graph f) := by ext x y diff --git a/Mathlib/Data/Seq/Computation.lean b/Mathlib/Data/Seq/Computation.lean index 9b4a265a6475b..89c1a50b68a71 100644 --- a/Mathlib/Data/Seq/Computation.lean +++ b/Mathlib/Data/Seq/Computation.lean @@ -236,10 +236,10 @@ section Bisim variable (R : Computation α → Computation α → Prop) -/-- bisimilarity relation-/ +/-- bisimilarity relation -/ local infixl:50 " ~ " => R -/-- Bisimilarity over a sum of `Computation`s-/ +/-- Bisimilarity over a sum of `Computation`s -/ def BisimO : α ⊕ (Computation α) → α ⊕ (Computation α) → Prop | Sum.inl a, Sum.inl a' => a = a' | Sum.inr s, Sum.inr s' => R s s' @@ -247,7 +247,7 @@ def BisimO : α ⊕ (Computation α) → α ⊕ (Computation α) → Prop attribute [simp] BisimO -/-- Attribute expressing bisimilarity over two `Computation`s-/ +/-- Attribute expressing bisimilarity over two `Computation`s -/ def IsBisimulation := ∀ ⦃s₁ s₂⦄, s₁ ~ s₂ → BisimO R (destruct s₁) (destruct s₂) @@ -279,7 +279,7 @@ end Bisim -- It's more of a stretch to use ∈ for this relation, but it -- asserts that the computation limits to the given value. -/-- Assertion that a `Computation` limits to a given value-/ +/-- Assertion that a `Computation` limits to a given value -/ protected def Mem (a : α) (s : Computation α) := some a ∈ s.1 @@ -519,7 +519,7 @@ theorem eq_thinkN' (s : Computation α) [_h : Terminates s] : s = thinkN (pure (get s)) (length s) := eq_thinkN (results_of_terminates _) -/-- Recursor based on membership-/ +/-- Recursor based on membership -/ def memRecOn {C : Computation α → Sort v} {a s} (M : a ∈ s) (h1 : C (pure a)) (h2 : ∀ s, C s → C (think s)) : C s := by haveI T := terminates_of_mem M @@ -820,7 +820,7 @@ theorem orElse_empty (c : Computation α) : (c <|> empty α) = c := by def Equiv (c₁ c₂ : Computation α) : Prop := ∀ a, a ∈ c₁ ↔ a ∈ c₂ -/-- equivalence relation for computations-/ +/-- equivalence relation for computations -/ scoped infixl:50 " ~ " => Equiv @[refl] @@ -1041,7 +1041,7 @@ theorem map_congr {s1 s2 : Computation α} {f : α → β} rw [← lift_eq_iff_equiv] exact liftRel_map Eq _ ((lift_eq_iff_equiv _ _).2 h1) fun {a} b => congr_arg _ -/-- Alternate definition of `LiftRel` over relations between `Computation`s-/ +/-- Alternate definition of `LiftRel` over relations between `Computation`s -/ def LiftRelAux (R : α → β → Prop) (C : Computation α → Computation β → Prop) : α ⊕ (Computation α) → β ⊕ (Computation β) → Prop | Sum.inl a, Sum.inl b => R a b diff --git a/Mathlib/Data/Seq/Seq.lean b/Mathlib/Data/Seq/Seq.lean index 974c780ddf181..e8dd7bae94d42 100644 --- a/Mathlib/Data/Seq/Seq.lean +++ b/Mathlib/Data/Seq/Seq.lean @@ -258,7 +258,7 @@ theorem mem_rec_on {C : Seq α → Prop} {a s} (M : a ∈ s) rw [h_eq] at e apply h1 _ _ (Or.inr (IH e)) -/-- Corecursor over pairs of `Option` values-/ +/-- Corecursor over pairs of `Option` values -/ def Corec.f (f : β → Option (α × β)) : Option β → Option α × Option β | none => (none, none) | some b => @@ -316,7 +316,7 @@ def BisimO : Option (Seq1 α) → Option (Seq1 α) → Prop attribute [simp] BisimO -/-- a relation is bisimilar if it meets the `BisimO` test-/ +/-- a relation is bisimilar if it meets the `BisimO` test -/ def IsBisimulation := ∀ ⦃s₁ s₂⦄, s₁ ~ s₂ → BisimO R (destruct s₁) (destruct s₂) diff --git a/Mathlib/Data/Seq/WSeq.lean b/Mathlib/Data/Seq/WSeq.lean index 9d86f9ce4e599..c6af34fee5015 100644 --- a/Mathlib/Data/Seq/WSeq.lean +++ b/Mathlib/Data/Seq/WSeq.lean @@ -105,7 +105,7 @@ def recOn {C : WSeq α → Sort v} (s : WSeq α) (h1 : C nil) (h2 : ∀ x s, C ( (h3 : ∀ s, C (think s)) : C s := Seq.recOn s h1 fun o => Option.recOn o h3 h2 -/-- membership for weak sequences-/ +/-- membership for weak sequences -/ protected def Mem (a : α) (s : WSeq α) := Seq.Mem (some a) s @@ -406,7 +406,7 @@ theorem LiftRelO.imp_right (R : α → β → Prop) {C D : WSeq α → WSeq β (H : ∀ s t, C s t → D s t) {o p} : LiftRelO R C o p → LiftRelO R D o p := LiftRelO.imp (fun _ _ => id) H -/-- Definition of bisimilarity for weak sequences-/ +/-- Definition of bisimilarity for weak sequences -/ @[simp] def BisimO (R : WSeq α → WSeq α → Prop) : Option (α × WSeq α) → Option (α × WSeq α) → Prop := LiftRelO (· = ·) R @@ -684,7 +684,7 @@ theorem append_nil (s : WSeq α) : append s nil = s := theorem append_assoc (s t u : WSeq α) : append (append s t) u = append s (append t u) := Seq.append_assoc _ _ _ -/-- auxiliary definition of tail over weak sequences-/ +/-- auxiliary definition of tail over weak sequences -/ @[simp] def tail.aux : Option (α × WSeq α) → Computation (Option (α × WSeq α)) | none => Computation.pure none @@ -694,7 +694,7 @@ theorem destruct_tail (s : WSeq α) : destruct (tail s) = destruct s >>= tail.au simp only [tail, destruct_flatten, tail.aux]; rw [← bind_pure_comp, LawfulMonad.bind_assoc] apply congr_arg; ext1 (_ | ⟨a, s⟩) <;> apply (@pure_bind Computation _ _ _ _ _ _).trans _ <;> simp -/-- auxiliary definition of drop over weak sequences-/ +/-- auxiliary definition of drop over weak sequences -/ @[simp] def drop.aux : ℕ → Option (α × WSeq α) → Computation (Option (α × WSeq α)) | 0 => Computation.pure @@ -1330,7 +1330,7 @@ theorem liftRel_map {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 : theorem map_congr (f : α → β) {s t : WSeq α} (h : s ~ʷ t) : map f s ~ʷ map f t := liftRel_map _ _ h fun {_ _} => congr_arg _ -/-- auxiliary definition of `destruct_append` over weak sequences-/ +/-- auxiliary definition of `destruct_append` over weak sequences -/ @[simp] def destruct_append.aux (t : WSeq α) : Option (α × WSeq α) → Computation (Option (α × WSeq α)) | none => destruct t @@ -1349,7 +1349,7 @@ theorem destruct_append (s t : WSeq α) : · refine ⟨nil, t, ?_, ?_⟩ <;> simp · exact ⟨s, t, rfl, rfl⟩ -/-- auxiliary definition of `destruct_join` over weak sequences-/ +/-- auxiliary definition of `destruct_join` over weak sequences -/ @[simp] def destruct_join.aux : Option (WSeq α × WSeq (WSeq α)) → Computation (Option (α × WSeq α)) | none => Computation.pure none @@ -1622,3 +1622,5 @@ instance lawfulMonad : LawfulMonad WSeq := end WSeq end Stream' + +set_option linter.style.longFile 1800 diff --git a/Mathlib/Data/Set/Basic.lean b/Mathlib/Data/Set/Basic.lean index 040bc43d60d9f..32c7799606dac 100644 --- a/Mathlib/Data/Set/Basic.lean +++ b/Mathlib/Data/Set/Basic.lean @@ -2172,3 +2172,5 @@ end Disjoint @[simp] theorem Prop.compl_singleton (p : Prop) : ({p}ᶜ : Set Prop) = {¬p} := ext fun q ↦ by simpa [@Iff.comm q] using not_iff + +set_option linter.style.longFile 2300 diff --git a/Mathlib/Data/Set/Countable.lean b/Mathlib/Data/Set/Countable.lean index bd1f3720faffe..8186f8d4a92d8 100644 --- a/Mathlib/Data/Set/Countable.lean +++ b/Mathlib/Data/Set/Countable.lean @@ -257,6 +257,10 @@ theorem countable_setOf_finite_subset {s : Set α} (hs : s.Countable) : lift t to Finset s using ht.of_finite_image Subtype.val_injective.injOn exact mem_range_self _ +/-- The set of finite sets in a countable type is countable. -/ +theorem Countable.setOf_finite [Countable α] : {s : Set α | s.Finite}.Countable := by + simpa using countable_setOf_finite_subset countable_univ + theorem countable_univ_pi {π : α → Type*} [Finite α] {s : ∀ a, Set (π a)} (hs : ∀ a, (s a).Countable) : (pi univ s).Countable := have := fun a ↦ (hs a).to_subtype; .of_equiv _ (Equiv.Set.univPi s).symm diff --git a/Mathlib/Data/Set/Finite.lean b/Mathlib/Data/Set/Finite.lean index 933b71188dd78..7696a86f0a8e0 100644 --- a/Mathlib/Data/Set/Finite.lean +++ b/Mathlib/Data/Set/Finite.lean @@ -1563,3 +1563,5 @@ theorem DirectedOn.exists_mem_subset_of_finset_subset_biUnion {α ι : Type*} {f rw [Set.biUnion_eq_iUnion] at hs haveI := hn.coe_sort simpa using (directed_comp.2 hc.directed_val).exists_mem_subset_of_finset_subset_biUnion hs + +set_option linter.style.longFile 1700 diff --git a/Mathlib/Data/Set/Function.lean b/Mathlib/Data/Set/Function.lean index 41e0b2257e3c0..56e1886f2c539 100644 --- a/Mathlib/Data/Set/Function.lean +++ b/Mathlib/Data/Set/Function.lean @@ -253,7 +253,7 @@ theorem EqOn.congr_strictAntiOn (h : s.EqOn f₁ f₂) : StrictAntiOn f₁ s ↔ end Order -/-! ### Monotonicity lemmas-/ +/-! ### Monotonicity lemmas -/ section Mono variable {s s₁ s₂ : Set α} {f f₁ f₂ : α → β} [Preorder α] [Preorder β] @@ -1741,3 +1741,5 @@ lemma bijOn_swap (ha : a ∈ s) (hb : b ∈ s) : BijOn (swap a b) s s := simp [*, swap_apply_of_ne_of_ne] end Equiv + +set_option linter.style.longFile 1900 diff --git a/Mathlib/Data/Set/Lattice.lean b/Mathlib/Data/Set/Lattice.lean index 44297c6dee25b..fbff041791382 100644 --- a/Mathlib/Data/Set/Lattice.lean +++ b/Mathlib/Data/Set/Lattice.lean @@ -1935,3 +1935,5 @@ lemma forall_sUnion {S : Set (Set α)} {p : α → Prop} : lemma exists_sUnion {S : Set (Set α)} {p : α → Prop} : (∃ x ∈ ⋃₀ S, p x) ↔ ∃ s ∈ S, ∃ x ∈ s, p x := by simp_rw [← exists_prop, ← iSup_Prop_eq, iSup_sUnion] + +set_option linter.style.longFile 2100 diff --git a/Mathlib/Data/Setoid/Partition.lean b/Mathlib/Data/Setoid/Partition.lean index ecf06ea7c220d..1cc028237c179 100644 --- a/Mathlib/Data/Setoid/Partition.lean +++ b/Mathlib/Data/Setoid/Partition.lean @@ -301,7 +301,7 @@ This type is primarily useful for definitional control of `s` - if this is not n structure IndexedPartition {ι α : Type*} (s : ι → Set α) where /-- two indexes are equal if they are equal in membership -/ eq_of_mem : ∀ {x i j}, x ∈ s i → x ∈ s j → i = j - /-- sends an index to an element of the corresponding set-/ + /-- sends an index to an element of the corresponding set -/ some : ι → α /-- membership invariance for `some`-/ some_mem : ∀ i, some i ∈ s i diff --git a/Mathlib/Data/Stream/Init.lean b/Mathlib/Data/Stream/Init.lean index 7f714ab54b4df..97d97a6c35d53 100644 --- a/Mathlib/Data/Stream/Init.lean +++ b/Mathlib/Data/Stream/Init.lean @@ -12,7 +12,7 @@ import Mathlib.Data.List.Basic Porting note: This file used to be in the core library. It was moved to `mathlib` and renamed to `init` to avoid -name clashes. -/ +name clashes. -/ open Nat Function Option diff --git a/Mathlib/Data/Vector/Defs.lean b/Mathlib/Data/Vector/Defs.lean index 46d770bdb44cf..eb91d0e438ce4 100644 --- a/Mathlib/Data/Vector/Defs.lean +++ b/Mathlib/Data/Vector/Defs.lean @@ -52,7 +52,7 @@ def head : Vector α (Nat.succ n) → α theorem head_cons (a : α) : ∀ v : Vector α n, head (cons a v) = a | ⟨_, _⟩ => rfl -/-- The tail of a vector, with an empty vector having empty tail. -/ +/-- The tail of a vector, with an empty vector having empty tail. -/ def tail : Vector α n → Vector α (n - 1) | ⟨[], h⟩ => ⟨[], congrArg pred h⟩ | ⟨_ :: v, h⟩ => ⟨v, congrArg pred h⟩ @@ -154,7 +154,7 @@ def mapAccumr₂ (f : α → β → σ → σ × φ) : Vector α n → Vector β end Accum -/-! ### Shift Primitives-/ +/-! ### Shift Primitives -/ section Shift /-- `shiftLeftFill v i` is the vector obtained by left-shifting `v` `i` times and padding with the @@ -181,7 +181,7 @@ protected theorem eq_nil (v : Vector α 0) : v = nil := v.eq nil (List.eq_nil_of_length_eq_zero v.2) /-- Vector of length from a list `v` -with witness that `v` has length `n` maps to `v` under `toList`. -/ +with witness that `v` has length `n` maps to `v` under `toList`. -/ @[simp] theorem toList_mk (v : List α) (P : List.length v = n) : toList (Subtype.mk v P) = v := rfl diff --git a/Mathlib/Data/ZMod/Basic.lean b/Mathlib/Data/ZMod/Basic.lean index 4cec208120d73..0e84d37f5fb66 100644 --- a/Mathlib/Data/ZMod/Basic.lean +++ b/Mathlib/Data/ZMod/Basic.lean @@ -446,7 +446,7 @@ noncomputable def ringEquiv [Fintype R] (h : Fintype.card R = n) : ZMod n ≃+* /-- The unique ring isomorphism between `ZMod p` and a ring `R` of cardinality a prime `p`. If you need any property of this isomorphism, first of all use `ringEquivOfPrime_eq_ringEquiv` -below (after `have : CharP R p := ...`) and deduce it by the results about `ZMod.ringEquiv`. -/ +below (after `have : CharP R p := ...`) and deduce it by the results about `ZMod.ringEquiv`. -/ noncomputable def ringEquivOfPrime [Fintype R] {p : ℕ} (hp : p.Prime) (hR : Fintype.card R = p) : ZMod p ≃+* R := have : Nontrivial R := Fintype.one_lt_card_iff_nontrivial.1 (hR ▸ hp.one_lt) @@ -1476,6 +1476,8 @@ lemma pow_pow_zmod_val_inv (hn : (Nat.card α).Coprime n) (a : α) : end Group +open ZMod + /-- The range of `(m * · + k)` on natural numbers is the set of elements `≥ k` in the residue class of `k` mod `m`. -/ lemma Nat.range_mul_add (m k : ℕ) : @@ -1489,3 +1491,17 @@ lemma Nat.range_mul_add (m k : ℕ) : simp only [ha, Nat.cast_add, add_right_eq_self, ZMod.natCast_zmod_eq_zero_iff_dvd] at H₁ obtain ⟨b, rfl⟩ := H₁ exact ⟨b, ha⟩ + +/-- Equivalence between `ℕ` and `ZMod N × ℕ`, sending `n` to `(n mod N, n / N)`. -/ +def Nat.residueClassesEquiv (N : ℕ) [NeZero N] : ℕ ≃ ZMod N × ℕ where + toFun n := (↑n, n / N) + invFun p := p.1.val + N * p.2 + left_inv n := by simpa only [val_natCast] using mod_add_div n N + right_inv p := by + ext1 + · simp only [add_comm p.1.val, cast_add, cast_mul, natCast_self, zero_mul, natCast_val, + cast_id', id_eq, zero_add] + · simp only [add_comm p.1.val, mul_add_div (NeZero.pos _), + (Nat.div_eq_zero_iff <| (NeZero.pos _)).2 p.1.val_lt, add_zero] + +set_option linter.style.longFile 1700 diff --git a/Mathlib/Dynamics/Ergodic/Conservative.lean b/Mathlib/Dynamics/Ergodic/Conservative.lean index 4853d8c9c1bfc..7e924b8864da3 100644 --- a/Mathlib/Dynamics/Ergodic/Conservative.lean +++ b/Mathlib/Dynamics/Ergodic/Conservative.lean @@ -147,7 +147,7 @@ theorem measure_inter_frequently_image_mem_eq (hf : Conservative f μ) (hs : Nul /-- Poincaré recurrence theorem: if `f` is a conservative dynamical system and `s` is a measurable set, then for `μ`-a.e. `x`, if the orbit of `x` visits `s` at least once, then it visits `s` -infinitely many times. -/ +infinitely many times. -/ theorem ae_forall_image_mem_imp_frequently_image_mem (hf : Conservative f μ) (hs : NullMeasurableSet s μ) : ∀ᵐ x ∂μ, ∀ k, f^[k] x ∈ s → ∃ᶠ n in atTop, f^[n] x ∈ s := by refine ae_all_iff.2 fun k => ?_ diff --git a/Mathlib/Dynamics/Ergodic/Ergodic.lean b/Mathlib/Dynamics/Ergodic/Ergodic.lean index 4316c1c557a29..2efbb69a9f654 100644 --- a/Mathlib/Dynamics/Ergodic/Ergodic.lean +++ b/Mathlib/Dynamics/Ergodic/Ergodic.lean @@ -138,23 +138,21 @@ theorem quasiErgodic (hf : Ergodic f μ) : QuasiErgodic f μ := { hf.toPreErgodic, hf.toMeasurePreserving.quasiMeasurePreserving with } /-- See also `Ergodic.ae_empty_or_univ_of_preimage_ae_le`. -/ -theorem ae_empty_or_univ_of_preimage_ae_le' (hf : Ergodic f μ) (hs : MeasurableSet s) +theorem ae_empty_or_univ_of_preimage_ae_le' (hf : Ergodic f μ) (hs : NullMeasurableSet s μ) (hs' : f ⁻¹' s ≤ᵐ[μ] s) (h_fin : μ s ≠ ∞) : s =ᵐ[μ] (∅ : Set α) ∨ s =ᵐ[μ] univ := by - refine hf.quasiErgodic.ae_empty_or_univ' hs ?_ - refine ae_eq_of_ae_subset_of_measure_ge hs' - (hf.measure_preimage hs.nullMeasurableSet).symm.le ?_ h_fin - exact measurableSet_preimage hf.measurable hs + refine hf.quasiErgodic.ae_empty_or_univ₀ hs ?_ + refine ae_eq_of_ae_subset_of_measure_ge hs' (hf.measure_preimage hs).ge ?_ h_fin + exact hs.preimage hf.quasiMeasurePreserving /-- See also `Ergodic.ae_empty_or_univ_of_ae_le_preimage`. -/ -theorem ae_empty_or_univ_of_ae_le_preimage' (hf : Ergodic f μ) (hs : MeasurableSet s) +theorem ae_empty_or_univ_of_ae_le_preimage' (hf : Ergodic f μ) (hs : NullMeasurableSet s μ) (hs' : s ≤ᵐ[μ] f ⁻¹' s) (h_fin : μ s ≠ ∞) : s =ᵐ[μ] (∅ : Set α) ∨ s =ᵐ[μ] univ := by - replace h_fin : μ (f ⁻¹' s) ≠ ∞ := by rwa [hf.measure_preimage hs.nullMeasurableSet] - refine hf.quasiErgodic.ae_empty_or_univ' hs ?_ - exact (ae_eq_of_ae_subset_of_measure_ge hs' - (hf.measure_preimage hs.nullMeasurableSet).le hs h_fin).symm + replace h_fin : μ (f ⁻¹' s) ≠ ∞ := by rwa [hf.measure_preimage hs] + refine hf.quasiErgodic.ae_empty_or_univ₀ hs ?_ + exact (ae_eq_of_ae_subset_of_measure_ge hs' (hf.measure_preimage hs).le hs h_fin).symm /-- See also `Ergodic.ae_empty_or_univ_of_image_ae_le`. -/ -theorem ae_empty_or_univ_of_image_ae_le' (hf : Ergodic f μ) (hs : MeasurableSet s) +theorem ae_empty_or_univ_of_image_ae_le' (hf : Ergodic f μ) (hs : NullMeasurableSet s μ) (hs' : f '' s ≤ᵐ[μ] s) (h_fin : μ s ≠ ∞) : s =ᵐ[μ] (∅ : Set α) ∨ s =ᵐ[μ] univ := by replace hs' : s ≤ᵐ[μ] f ⁻¹' s := (HasSubset.Subset.eventuallyLE (subset_preimage_image f s)).trans @@ -165,15 +163,15 @@ section IsFiniteMeasure variable [IsFiniteMeasure μ] -theorem ae_empty_or_univ_of_preimage_ae_le (hf : Ergodic f μ) (hs : MeasurableSet s) +theorem ae_empty_or_univ_of_preimage_ae_le (hf : Ergodic f μ) (hs : NullMeasurableSet s μ) (hs' : f ⁻¹' s ≤ᵐ[μ] s) : s =ᵐ[μ] (∅ : Set α) ∨ s =ᵐ[μ] univ := ae_empty_or_univ_of_preimage_ae_le' hf hs hs' <| measure_ne_top μ s -theorem ae_empty_or_univ_of_ae_le_preimage (hf : Ergodic f μ) (hs : MeasurableSet s) +theorem ae_empty_or_univ_of_ae_le_preimage (hf : Ergodic f μ) (hs : NullMeasurableSet s μ) (hs' : s ≤ᵐ[μ] f ⁻¹' s) : s =ᵐ[μ] (∅ : Set α) ∨ s =ᵐ[μ] univ := ae_empty_or_univ_of_ae_le_preimage' hf hs hs' <| measure_ne_top μ s -theorem ae_empty_or_univ_of_image_ae_le (hf : Ergodic f μ) (hs : MeasurableSet s) +theorem ae_empty_or_univ_of_image_ae_le (hf : Ergodic f μ) (hs : NullMeasurableSet s μ) (hs' : f '' s ≤ᵐ[μ] s) : s =ᵐ[μ] (∅ : Set α) ∨ s =ᵐ[μ] univ := ae_empty_or_univ_of_image_ae_le' hf hs hs' <| measure_ne_top μ s diff --git a/Mathlib/FieldTheory/Adjoin.lean b/Mathlib/FieldTheory/Adjoin.lean index ba316a0f73367..a8dcc93cf1f90 100644 --- a/Mathlib/FieldTheory/Adjoin.lean +++ b/Mathlib/FieldTheory/Adjoin.lean @@ -356,12 +356,12 @@ theorem adjoin_adjoin_left (T : Set E) : apply Set.eq_of_subset_of_subset <;> rw [adjoin_subset_adjoin_iff] <;> constructor · rintro _ ⟨⟨x, hx⟩, rfl⟩; exact adjoin.mono _ _ _ Set.subset_union_left hx · exact subset_adjoin_of_subset_right _ _ Set.subset_union_right --- Porting note: orginal proof times out +-- Porting note: original proof times out · rintro x ⟨f, rfl⟩ refine Subfield.subset_closure ?_ left exact ⟨f, rfl⟩ --- Porting note: orginal proof times out +-- Porting note: original proof times out · refine Set.union_subset (fun x hx => Subfield.subset_closure ?_) (fun x hx => Subfield.subset_closure ?_) · left diff --git a/Mathlib/FieldTheory/Extension.lean b/Mathlib/FieldTheory/Extension.lean index 4fca6eb496228..abfd3dbf451d7 100644 --- a/Mathlib/FieldTheory/Extension.lean +++ b/Mathlib/FieldTheory/Extension.lean @@ -144,7 +144,7 @@ end variable (hK : ∀ s ∈ S, IsIntegral F s ∧ (minpoly F s).Splits (algebraMap F K)) (hK' : ∀ s : E, IsIntegral F s ∧ (minpoly F s).Splits (algebraMap F K)) - {L : IntermediateField F E} (f : L →ₐ[F] K) (hL : L ≤ adjoin F S) {x : E} {y : K} + {L : IntermediateField F E} (f : L →ₐ[F] K) (hL : L ≤ adjoin F S) {x : E} {y : K} section include hK diff --git a/Mathlib/FieldTheory/Finite/GaloisField.lean b/Mathlib/FieldTheory/Finite/GaloisField.lean index c2262e4cf2be6..baca752d4d5c6 100644 --- a/Mathlib/FieldTheory/Finite/GaloisField.lean +++ b/Mathlib/FieldTheory/Finite/GaloisField.lean @@ -92,7 +92,7 @@ theorem finrank {n} (h : n ≠ 0) : FiniteDimensional.finrank (ZMod p) (GaloisFi set g_poly := (X ^ p ^ n - X : (ZMod p)[X]) have hp : 1 < p := h_prime.out.one_lt have aux : g_poly ≠ 0 := FiniteField.X_pow_card_pow_sub_X_ne_zero _ h hp - -- Porting note: in the statment of `key`, replaced `g_poly` by its value otherwise the + -- Porting note: in the statement of `key`, replaced `g_poly` by its value otherwise the -- proof fails have key : Fintype.card (g_poly.rootSet (GaloisField p n)) = g_poly.natDegree := card_rootSet_eq_natDegree (galois_poly_separable p _ (dvd_pow (dvd_refl p) h)) @@ -189,7 +189,7 @@ namespace FiniteField variable {K : Type*} [Field K] [Fintype K] {K' : Type*} [Field K'] [Fintype K'] /-- Uniqueness of finite fields: - Any two finite fields of the same cardinality are (possibly non canonically) isomorphic-/ + Any two finite fields of the same cardinality are (possibly non canonically) isomorphic -/ def algEquivOfCardEq (p : ℕ) [h_prime : Fact p.Prime] [Algebra (ZMod p) K] [Algebra (ZMod p) K'] (hKK' : Fintype.card K = Fintype.card K') : K ≃ₐ[ZMod p] K' := by have : CharP K p := by rw [← Algebra.charP_iff (ZMod p) K p]; exact ZMod.charP p @@ -203,7 +203,7 @@ def algEquivOfCardEq (p : ℕ) [h_prime : Fact p.Prime] [Algebra (ZMod p) K] [Al exact AlgEquiv.trans hGalK hK'Gal /-- Uniqueness of finite fields: - Any two finite fields of the same cardinality are (possibly non canonically) isomorphic-/ + Any two finite fields of the same cardinality are (possibly non canonically) isomorphic -/ def ringEquivOfCardEq (hKK' : Fintype.card K = Fintype.card K') : K ≃+* K' := by choose p _char_p_K using CharP.exists K choose p' _char_p'_K' using CharP.exists K' diff --git a/Mathlib/FieldTheory/Galois.lean b/Mathlib/FieldTheory/Galois.lean index 97c0878478581..a2721a1b5cc58 100644 --- a/Mathlib/FieldTheory/Galois.lean +++ b/Mathlib/FieldTheory/Galois.lean @@ -388,7 +388,7 @@ theorem of_separable_splitting_field [sp : p.IsSplittingField F E] (hp : p.Separ refine LinearEquiv.finrank_eq ?_ rfl -/-- Equivalent characterizations of a Galois extension of finite degree-/ +/-- Equivalent characterizations of a Galois extension of finite degree -/ theorem tfae [FiniteDimensional F E] : List.TFAE [ IsGalois F E, IntermediateField.fixedField (⊤ : Subgroup (E ≃ₐ[F] E)) = ⊥, diff --git a/Mathlib/FieldTheory/IntermediateField/Algebraic.lean b/Mathlib/FieldTheory/IntermediateField/Algebraic.lean index c546c92eb2c36..d6010e14e4897 100644 --- a/Mathlib/FieldTheory/IntermediateField/Algebraic.lean +++ b/Mathlib/FieldTheory/IntermediateField/Algebraic.lean @@ -96,7 +96,7 @@ theorem minpoly_eq (x : S) : minpoly K x = minpoly K (x : L) := end IntermediateField -/-- If `L/K` is algebraic, the `K`-subalgebras of `L` are all fields. -/ +/-- If `L/K` is algebraic, the `K`-subalgebras of `L` are all fields. -/ def subalgebraEquivIntermediateField [Algebra.IsAlgebraic K L] : Subalgebra K L ≃o IntermediateField K L where toFun S := S.toIntermediateField fun x hx => S.inv_mem_of_algebraic diff --git a/Mathlib/FieldTheory/PerfectClosure.lean b/Mathlib/FieldTheory/PerfectClosure.lean index 06db163e5553c..b88e876167509 100644 --- a/Mathlib/FieldTheory/PerfectClosure.lean +++ b/Mathlib/FieldTheory/PerfectClosure.lean @@ -317,7 +317,7 @@ theorem mk_eq_iff (x y : ℕ × K) : mk K p x = mk K p y ↔ ∃ z, (frobenius K p)^[y.1 + z] x.2 = (frobenius K p)^[x.1 + z] y.2 := by constructor · intro H - replace H := Quot.exact _ H + replace H := Quot.eqvGen_exact _ H induction H with | rel x y H => cases' H with n x; exact ⟨0, rfl⟩ | refl H => exact ⟨0, rfl⟩ diff --git a/Mathlib/FieldTheory/PolynomialGaloisGroup.lean b/Mathlib/FieldTheory/PolynomialGaloisGroup.lean index 3c936d1dc75f4..159fca2636398 100644 --- a/Mathlib/FieldTheory/PolynomialGaloisGroup.lean +++ b/Mathlib/FieldTheory/PolynomialGaloisGroup.lean @@ -253,7 +253,7 @@ theorem restrictDvd_surjective (hpq : p ∣ q) (hq : q ≠ 0) : variable (p q) -/-- The Galois group of a product maps into the product of the Galois groups. -/ +/-- The Galois group of a product maps into the product of the Galois groups. -/ def restrictProd : (p * q).Gal →* p.Gal × q.Gal := MonoidHom.prod (restrictDvd (dvd_mul_right p q)) (restrictDvd (dvd_mul_left q p)) diff --git a/Mathlib/FieldTheory/PurelyInseparable.lean b/Mathlib/FieldTheory/PurelyInseparable.lean index 9f3dcfba2c056..77e7df9c03eba 100644 --- a/Mathlib/FieldTheory/PurelyInseparable.lean +++ b/Mathlib/FieldTheory/PurelyInseparable.lean @@ -282,7 +282,7 @@ theorem mem_perfectClosure_iff_pow_mem (q : ℕ) [ExpChar F q] {x : E} : x ∈ perfectClosure F E ↔ ∃ n : ℕ, x ^ q ^ n ∈ (algebraMap F E).range := by rw [mem_perfectClosure_iff, ringExpChar.eq F q] -/-- An element is contained in the relative perfect closure if and only if its mininal polynomial +/-- An element is contained in the relative perfect closure if and only if its minimal polynomial has separable degree one. -/ theorem mem_perfectClosure_iff_natSepDegree_eq_one {x : E} : x ∈ perfectClosure F E ↔ (minpoly F x).natSepDegree = 1 := by @@ -629,7 +629,7 @@ namespace IntermediateField instance isPurelyInseparable_bot : IsPurelyInseparable F (⊥ : IntermediateField F E) := (botEquiv F E).symm.isPurelyInseparable -/-- `F⟮x⟯ / F` is a purely inseparable extension if and only if the mininal polynomial of `x` +/-- `F⟮x⟯ / F` is a purely inseparable extension if and only if the minimal polynomial of `x` has separable degree one. -/ theorem isPurelyInseparable_adjoin_simple_iff_natSepDegree_eq_one {x : E} : IsPurelyInseparable F F⟮x⟯ ↔ (minpoly F x).natSepDegree = 1 := by diff --git a/Mathlib/FieldTheory/RatFunc/Defs.lean b/Mathlib/FieldTheory/RatFunc/Defs.lean index b1ffa6109ae6d..b45d1838b3eb7 100644 --- a/Mathlib/FieldTheory/RatFunc/Defs.lean +++ b/Mathlib/FieldTheory/RatFunc/Defs.lean @@ -63,7 +63,7 @@ the maps between `RatFunc K` and another field of fractions of `K[X]`, especially `FractionRing K[X]`, are given by `IsLocalization.algEquiv`. -/ structure RatFunc [CommRing K] : Type u where ofFractionRing :: -/-- the coercion to the fraction ring of the polynomial ring-/ +/-- the coercion to the fraction ring of the polynomial ring -/ toFractionRing : FractionRing K[X] namespace RatFunc diff --git a/Mathlib/Geometry/Euclidean/Circumcenter.lean b/Mathlib/Geometry/Euclidean/Circumcenter.lean index 6ab81a7fe36a9..137f90c80106a 100644 --- a/Mathlib/Geometry/Euclidean/Circumcenter.lean +++ b/Mathlib/Geometry/Euclidean/Circumcenter.lean @@ -427,7 +427,7 @@ theorem dist_circumcenter_sq_eq_sq_sub_circumradius {n : ℕ} {r : ℝ} (s : Sim /-- If there exists a distance that a point has from all vertices of a simplex, the orthogonal projection of that point onto the subspace -spanned by that simplex is its circumcenter. -/ +spanned by that simplex is its circumcenter. -/ theorem orthogonalProjection_eq_circumcenter_of_exists_dist_eq {n : ℕ} (s : Simplex ℝ P n) {p : P} (hr : ∃ r, ∀ i, dist (s.points i) p = r) : ↑(s.orthogonalProjectionSpan p) = s.circumcenter := by @@ -445,7 +445,7 @@ theorem orthogonalProjection_eq_circumcenter_of_exists_dist_eq {n : ℕ} (s : Si /-- If a point has the same distance from all vertices of a simplex, the orthogonal projection of that point onto the subspace spanned by -that simplex is its circumcenter. -/ +that simplex is its circumcenter. -/ theorem orthogonalProjection_eq_circumcenter_of_dist_eq {n : ℕ} (s : Simplex ℝ P n) {p : P} {r : ℝ} (hr : ∀ i, dist (s.points i) p = r) : ↑(s.orthogonalProjectionSpan p) = s.circumcenter := s.orthogonalProjection_eq_circumcenter_of_exists_dist_eq ⟨r, hr⟩ diff --git a/Mathlib/Geometry/Manifold/Instances/Sphere.lean b/Mathlib/Geometry/Manifold/Instances/Sphere.lean index 41a32a5f566cb..21821c1f74e99 100644 --- a/Mathlib/Geometry/Manifold/Instances/Sphere.lean +++ b/Mathlib/Geometry/Manifold/Instances/Sphere.lean @@ -421,7 +421,7 @@ instance (n : ℕ) : haveI := Fact.mk (@finrank_euclideanSpace_fin ℝ _ (n + 1)) EuclideanSpace.instSmoothManifoldWithCornersSphere -/-- The inclusion map (i.e., `coe`) from the sphere in `E` to `E` is smooth. -/ +/-- The inclusion map (i.e., `coe`) from the sphere in `E` to `E` is smooth. -/ theorem contMDiff_coe_sphere {n : ℕ} [Fact (finrank ℝ E = n + 1)] : ContMDiff (𝓡 n) 𝓘(ℝ, E) ∞ ((↑) : sphere (0 : E) 1 → E) := by -- Porting note: trouble with filling these implicit variables in the instance diff --git a/Mathlib/Geometry/Manifold/IntegralCurve.lean b/Mathlib/Geometry/Manifold/IntegralCurve.lean index beb8c885abb24..01130e726c4b7 100644 --- a/Mathlib/Geometry/Manifold/IntegralCurve.lean +++ b/Mathlib/Geometry/Manifold/IntegralCurve.lean @@ -492,7 +492,7 @@ theorem isIntegralCurve_eq_of_contMDiff (hγt : ∀ t, I.IsInteriorPoint (γ t)) obtain ⟨hS₂, hS₃⟩ := abs_lt.mp hS₂ exact ⟨T + S, by constructor <;> constructor <;> linarith⟩ exact isIntegralCurveOn_Ioo_eqOn_of_contMDiff ht (fun t _ ↦ hγt t) hv - ((hγ.isIntegralCurveOn _).mono (subset_univ _)) + ((hγ.isIntegralCurveOn _).mono (subset_univ _)) ((hγ'.isIntegralCurveOn _).mono (subset_univ _)) h ht₀ theorem isIntegralCurve_Ioo_eq_of_contMDiff_boundaryless [BoundarylessManifold I M] diff --git a/Mathlib/Geometry/Manifold/SmoothManifoldWithCorners.lean b/Mathlib/Geometry/Manifold/SmoothManifoldWithCorners.lean index f051aa094ef52..b252d909311ac 100644 --- a/Mathlib/Geometry/Manifold/SmoothManifoldWithCorners.lean +++ b/Mathlib/Geometry/Manifold/SmoothManifoldWithCorners.lean @@ -427,7 +427,7 @@ section Boundaryless /-- Property ensuring that the model with corners `I` defines manifolds without boundary. This differs from the more general `BoundarylessManifold`, which requires every point on the manifold - to be an interior point. -/ + to be an interior point. -/ class ModelWithCorners.Boundaryless {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {H : Type*} [TopologicalSpace H] (I : ModelWithCorners 𝕜 E H) : Prop where diff --git a/Mathlib/Geometry/RingedSpace/OpenImmersion.lean b/Mathlib/Geometry/RingedSpace/OpenImmersion.lean index 06448493da24d..5c5349f4adc95 100644 --- a/Mathlib/Geometry/RingedSpace/OpenImmersion.lean +++ b/Mathlib/Geometry/RingedSpace/OpenImmersion.lean @@ -69,7 +69,7 @@ class PresheafedSpace.IsOpenImmersion {X Y : PresheafedSpace C} (f : X ⟶ Y) : /-- the underlying continuous map of underlying spaces from the source to an open subset of the target. -/ base_open : OpenEmbedding f.base - /-- the underlying sheaf morphism is an isomorphism on each open subset-/ + /-- the underlying sheaf morphism is an isomorphism on each open subset -/ c_iso : ∀ U : Opens X, IsIso (f.c.app (op (base_open.isOpenMap.functor.obj U))) /-- A morphism of SheafedSpaces is an open immersion if it is an open immersion as a morphism diff --git a/Mathlib/Geometry/RingedSpace/PresheafedSpace/HasColimits.lean b/Mathlib/Geometry/RingedSpace/PresheafedSpace/HasColimits.lean index 1a3dd8fdd7585..91683f96c4d14 100644 --- a/Mathlib/Geometry/RingedSpace/PresheafedSpace/HasColimits.lean +++ b/Mathlib/Geometry/RingedSpace/PresheafedSpace/HasColimits.lean @@ -97,7 +97,7 @@ def pushforwardDiagramToColimit (F : J ⥤ PresheafedSpace.{_, _, v} C) : obj j := op (colimit.ι (F ⋙ PresheafedSpace.forget C) j _* (F.obj j).presheaf) map {j j'} f := ((pushforward C (colimit.ι (F ⋙ PresheafedSpace.forget C) j')).map (F.map f).c ≫ - (Pushforward.comp ((F ⋙ PresheafedSpace.forget C).map f) + (Pushforward.comp ((F ⋙ PresheafedSpace.forget C).map f) (colimit.ι (F ⋙ PresheafedSpace.forget C) j') (F.obj j).presheaf).inv ≫ (pushforwardEq (colimit.w (F ⋙ PresheafedSpace.forget C) f) (F.obj j).presheaf).hom).op map_id j := by diff --git a/Mathlib/GroupTheory/FreeGroup/Basic.lean b/Mathlib/GroupTheory/FreeGroup/Basic.lean index 74da573c0472e..6b18a57684cb5 100644 --- a/Mathlib/GroupTheory/FreeGroup/Basic.lean +++ b/Mathlib/GroupTheory/FreeGroup/Basic.lean @@ -538,7 +538,7 @@ def of (x : α) : FreeGroup α := @[to_additive] theorem Red.exact : mk L₁ = mk L₂ ↔ Join Red L₁ L₂ := calc - mk L₁ = mk L₂ ↔ EqvGen Red.Step L₁ L₂ := Iff.intro (Quot.exact _) Quot.EqvGen_sound + mk L₁ = mk L₂ ↔ EqvGen Red.Step L₁ L₂ := Iff.intro (Quot.eqvGen_exact _) Quot.eqvGen_sound _ ↔ Join Red L₁ L₂ := eqvGen_step_iff_join_red /-- The canonical map from the type to the free group is an injection. -/ diff --git a/Mathlib/GroupTheory/FreeGroup/IsFreeGroup.lean b/Mathlib/GroupTheory/FreeGroup/IsFreeGroup.lean index ff82a3c54c8d9..5999f4a20b721 100644 --- a/Mathlib/GroupTheory/FreeGroup/IsFreeGroup.lean +++ b/Mathlib/GroupTheory/FreeGroup/IsFreeGroup.lean @@ -149,7 +149,7 @@ def ofLift {G : Type u} [Group G] (X : Type u) (of : X → G) /-- If a group satisfies the universal property of a free group with respect to a given type, then it admits a free group basis based on this type. Here -the universal property is expressed as in `IsFreeGroup.unique_lift`. -/ +the universal property is expressed as in `IsFreeGroup.unique_lift`. -/ def ofUniqueLift {G : Type u} [Group G] (X : Type u) (of : X → G) (h : ∀ {H : Type u} [Group H] (f : X → H), ∃! F : G →* H, ∀ a, F (of a) = f a) : FreeGroupBasis X G := @@ -212,7 +212,7 @@ theorem ext_hom ⦃f g : G →* H⦄ (h : ∀ a : Generators G, f (of a) = g (of group extends in a unique way to a homomorphism from `G`. Note that since `IsFreeGroup.lift` is expressed as a bijection, it already -expresses the universal property. -/ +expresses the universal property. -/ theorem unique_lift (f : Generators G → H) : ∃! F : G →* H, ∀ a, F (of a) = f a := by simpa only [Function.funext_iff] using lift.symm.bijective.existsUnique f @@ -226,7 +226,7 @@ lemma ofLift {G : Type u} [Group G] (X : Type u) (of : X → G) (FreeGroupBasis.ofLift X of lift lift_of).isFreeGroup /-- If a group satisfies the universal property of a free group with respect to a given type, then -it is free. Here the universal property is expressed as in `IsFreeGroup.unique_lift`. -/ +it is free. Here the universal property is expressed as in `IsFreeGroup.unique_lift`. -/ lemma ofUniqueLift {G : Type u} [Group G] (X : Type u) (of : X → G) (h : ∀ {H : Type u} [Group H] (f : X → H), ∃! F : G →* H, ∀ a, F (of a) = f a) : IsFreeGroup G := diff --git a/Mathlib/GroupTheory/GroupAction/Hom.lean b/Mathlib/GroupTheory/GroupAction/Hom.lean index d843581eba0b4..2a9db62dd963a 100644 --- a/Mathlib/GroupTheory/GroupAction/Hom.lean +++ b/Mathlib/GroupTheory/GroupAction/Hom.lean @@ -59,7 +59,7 @@ variable (Z : Type*) [SMul P Z] /-- Equivariant functions : When `φ : M → N` is a function, and types `X` and `Y` are endowed with actions of `M` and `N`, -a function `f : X → Y` is `φ`-equivariant if `f (m • x) = (φ m) • (f x)`. -/ +a function `f : X → Y` is `φ`-equivariant if `f (m • x) = (φ m) • (f x)`. -/ -- Porting note(#5171): this linter isn't ported yet. -- @[nolint has_nonempty_instance] structure MulActionHom where diff --git a/Mathlib/GroupTheory/GroupAction/SubMulAction.lean b/Mathlib/GroupTheory/GroupAction/SubMulAction.lean index 0d6267151258e..6f4c858afeb02 100644 --- a/Mathlib/GroupTheory/GroupAction/SubMulAction.lean +++ b/Mathlib/GroupTheory/GroupAction/SubMulAction.lean @@ -153,7 +153,7 @@ end OfTower end SetLike -/-- A SubMulAction is a set which is closed under scalar multiplication. -/ +/-- A SubMulAction is a set which is closed under scalar multiplication. -/ structure SubMulAction (R : Type u) (M : Type v) [SMul R M] : Type v where /-- The underlying set of a `SubMulAction`. -/ carrier : Set M @@ -243,7 +243,7 @@ variable [Monoid R] [MulAction R M] {A : Type*} [SetLike A M] variable [hA : SMulMemClass A R M] (S' : A) -- Prefer subclasses of `MulAction` over `SMulMemClass`. -/-- A `SubMulAction` of a `MulAction` is a `MulAction`. -/ +/-- A `SubMulAction` of a `MulAction` is a `MulAction`. -/ instance (priority := 75) toMulAction : MulAction R S' := Subtype.coe_injective.mulAction Subtype.val (SetLike.val_smul S') diff --git a/Mathlib/GroupTheory/HNNExtension.lean b/Mathlib/GroupTheory/HNNExtension.lean index 477f83de90efd..80ce314e091e1 100644 --- a/Mathlib/GroupTheory/HNNExtension.lean +++ b/Mathlib/GroupTheory/HNNExtension.lean @@ -42,7 +42,7 @@ def HNNExtension.con (G : Type*) [Group G] (A B : Subgroup G) (φ : A ≃* B) : /-- The HNN Extension of a group `G`, `HNNExtension G A B φ`. Given a group `G`, subgroups `A` and `B` and an isomorphism `φ` of `A` and `B`, we adjoin a letter `t` to `G`, such that for any `a ∈ A`, the conjugate of `of a` by `t` is `of (φ a)`, where `of` is the canonical -map from `G` into the `HNNExtension`. -/ +map from `G` into the `HNNExtension`. -/ def HNNExtension (G : Type*) [Group G] (A B : Subgroup G) (φ : A ≃* B) : Type _ := (HNNExtension.con G A B φ).Quotient @@ -281,7 +281,7 @@ def cons (g : G) (u : ℤˣ) (w : NormalWord d) (h1 : w.head ∈ d.set u) rintro ⟨u', g'⟩ hu' hw1 exact h2 _ (by simp_all) hw1 } -/-- A recursor to induct on a `NormalWord`, by proving the propert is preserved under `cons` -/ +/-- A recursor to induct on a `NormalWord`, by proving the property is preserved under `cons` -/ @[elab_as_elim] def consRecOn {motive : NormalWord d → Sort*} (w : NormalWord d) (ofGroup : ∀g, motive (ofGroup g)) @@ -347,7 +347,7 @@ theorem unitsSMulGroup_snd (u : ℤˣ) (g : G) : variable {d} -/-- `Cancels u w` is a predicate expressing whether `t^u` cancels with some occurence +/-- `Cancels u w` is a predicate expressing whether `t^u` cancels with some occurrence of `t^-u` when we multiply `t^u` by `w`. -/ def Cancels (u : ℤˣ) (w : NormalWord d) : Prop := (w.head ∈ (toSubgroup A B u : Subgroup G)) ∧ w.toList.head?.map Prod.fst = some (-u) @@ -653,9 +653,9 @@ theorem exists_normalWord_prod_eq simp [mul_assoc, unitsSMulGroup, (d.compl _).coe_equiv_snd_eq_one_iff_mem] /-- Two reduced words representing the same element of the `HNNExtension G A B φ` have the same -length corresponding list, with the same pattern of occurences of `t^1` and `t^(-1)`, +length corresponding list, with the same pattern of occurrences of `t^1` and `t^(-1)`, and also the `head` is in the same left coset of `toSubgroup A B (-u)`, where `u : ℤˣ` -is the exponent of the first occurence of `t` in the word. -/ +is the exponent of the first occurrence of `t` in the word. -/ theorem map_fst_eq_and_of_prod_eq {w₁ w₂ : ReducedWord G A B} (hprod : w₁.prod φ = w₂.prod φ) : w₁.toList.map Prod.fst = w₂.toList.map Prod.fst ∧ @@ -674,7 +674,7 @@ theorem map_fst_eq_and_of_prod_eq {w₁ w₂ : ReducedWord G A B} rwa [← List.head?_map, ← hw₂'2, hw₁'2, List.head?_map] /-- **Britton's Lemma**. Any reduced word whose product is an element of `G`, has no -occurences of `t`. -/ +occurrences of `t`. -/ theorem toList_eq_nil_of_mem_of_range (w : ReducedWord G A B) (hw : w.prod φ ∈ (of.range : Subgroup (HNNExtension G A B φ))) : w.toList = [] := by diff --git a/Mathlib/GroupTheory/MonoidLocalization/MonoidWithZero.lean b/Mathlib/GroupTheory/MonoidLocalization/MonoidWithZero.lean index b0c5d7e2cac4a..3c6c5f38a066e 100644 --- a/Mathlib/GroupTheory/MonoidLocalization/MonoidWithZero.lean +++ b/Mathlib/GroupTheory/MonoidLocalization/MonoidWithZero.lean @@ -42,7 +42,7 @@ namespace Submonoid variable {S N} in /-- If `S` contains `0` then the localization at `S` is trivial. -/ -theorem LocalizationMap.subsingleton (f : Submonoid.LocalizationMap S N) (h : 0 ∈ S) : +theorem LocalizationMap.subsingleton (f : Submonoid.LocalizationMap S N) (h : 0 ∈ S) : Subsingleton N := by refine ⟨fun a b ↦ ?_⟩ rw [← LocalizationMap.mk'_sec f a, ← LocalizationMap.mk'_sec f b, LocalizationMap.eq] @@ -152,7 +152,7 @@ theorem leftCancelMulZero_of_le_isLeftRegular /-- Given a Localization map `f : M →*₀ N` for a Submonoid `S ⊆ M`, if `M` is a cancellative monoid with zero, and all elements of `S` are -regular, then N is a cancellative monoid with zero. -/ +regular, then N is a cancellative monoid with zero. -/ theorem isLeftRegular_of_le_isCancelMulZero (f : LocalizationWithZeroMap S N) [IsCancelMulZero M] (h : ∀ ⦃x⦄, x ∈ S → IsRegular x) : IsCancelMulZero N := by have : IsLeftCancelMulZero N := diff --git a/Mathlib/GroupTheory/PushoutI.lean b/Mathlib/GroupTheory/PushoutI.lean index 6f3baeb1be190..a168bf23400a0 100644 --- a/Mathlib/GroupTheory/PushoutI.lean +++ b/Mathlib/GroupTheory/PushoutI.lean @@ -301,7 +301,7 @@ theorem prod_empty : (empty : NormalWord d).prod = 1 := by simp [prod, empty] /-- A constructor that multiplies a `NormalWord` by an element, with condition to make -sure the underlying list does get longer. -/ +sure the underlying list does get longer. -/ @[simps!] noncomputable def cons {i} (g : G i) (w : NormalWord d) (hmw : w.fstIdx ≠ some i) (hgr : g ∉ (φ i).range) : NormalWord d := @@ -328,7 +328,7 @@ variable [DecidableEq ι] [∀ i, DecidableEq (G i)] /-- Given a word in `CoprodI`, if every letter is in the transversal and when we multiply by an element of the base group it still has this property, -then the element of the base group we multiplied by was one. -/ +then the element of the base group we multiplied by was one. -/ theorem eq_one_of_smul_normalized (w : CoprodI.Word G) {i : ι} (h : H) (hw : ∀ i g, ⟨i, g⟩ ∈ w.toList → g ∈ d.set i) (hφw : ∀ j g, ⟨j, g⟩ ∈ (CoprodI.of (φ i h) • w).toList → g ∈ d.set j) : diff --git a/Mathlib/GroupTheory/SemidirectProduct.lean b/Mathlib/GroupTheory/SemidirectProduct.lean index 904d910b72cfa..6996df7ab8182 100644 --- a/Mathlib/GroupTheory/SemidirectProduct.lean +++ b/Mathlib/GroupTheory/SemidirectProduct.lean @@ -222,7 +222,7 @@ section Map variable {N₁ : Type*} {G₁ : Type*} [Group N₁] [Group G₁] {φ₁ : G₁ →* MulAut N₁} /-- Define a map from `N ⋊[φ] G` to `N₁ ⋊[φ₁] G₁` given maps `N →* N₁` and `G →* G₁` that - satisfy a commutativity condition `∀ n g, f₁ (φ g n) = φ₁ (f₂ g) (f₁ n)`. -/ + satisfy a commutativity condition `∀ n g, f₁ (φ g n) = φ₁ (f₂ g) (f₁ n)`. -/ def map (f₁ : N →* N₁) (f₂ : G →* G₁) (h : ∀ g : G, f₁.comp (φ g).toMonoidHom = (φ₁ (f₂ g)).toMonoidHom.comp f₁) : N ⋊[φ] G →* N₁ ⋊[φ₁] G₁ where diff --git a/Mathlib/GroupTheory/Sylow.lean b/Mathlib/GroupTheory/Sylow.lean index 45a76037e7714..e01444b54457b 100644 --- a/Mathlib/GroupTheory/Sylow.lean +++ b/Mathlib/GroupTheory/Sylow.lean @@ -458,7 +458,7 @@ def fixedPointsMulLeftCosetsEquivQuotient (H : Subgroup G) [Finite (H : Set G)] rfl) /-- If `H` is a `p`-subgroup of `G`, then the index of `H` inside its normalizer is congruent - mod `p` to the index of `H`. -/ + mod `p` to the index of `H`. -/ theorem card_quotient_normalizer_modEq_card_quotient [Finite G] {p : ℕ} {n : ℕ} [hp : Fact p.Prime] {H : Subgroup G} (hH : Nat.card H = p ^ n) : Nat.card (normalizer H ⧸ Subgroup.comap ((normalizer H).subtype : normalizer H →* G) H) ≡ @@ -467,7 +467,7 @@ theorem card_quotient_normalizer_modEq_card_quotient [Finite G] {p : ℕ} {n : exact ((IsPGroup.of_card hH).card_modEq_card_fixedPoints _).symm /-- If `H` is a subgroup of `G` of cardinality `p ^ n`, then the cardinality of the - normalizer of `H` is congruent mod `p ^ (n + 1)` to the cardinality of `G`. -/ + normalizer of `H` is congruent mod `p ^ (n + 1)` to the cardinality of `G`. -/ theorem card_normalizer_modEq_card [Finite G] {p : ℕ} {n : ℕ} [hp : Fact p.Prime] {H : Subgroup G} (hH : Nat.card H = p ^ n) : Nat.card (normalizer H) ≡ Nat.card G [MOD p ^ (n + 1)] := by have : H.subgroupOf (normalizer H) ≃ H := (subgroupOfEquivOfLe le_normalizer).toEquiv diff --git a/Mathlib/InformationTheory/Hamming.lean b/Mathlib/InformationTheory/Hamming.lean index 5f6eb9c5030e9..63b352144a998 100644 --- a/Mathlib/InformationTheory/Hamming.lean +++ b/Mathlib/InformationTheory/Hamming.lean @@ -262,12 +262,12 @@ instance (α) [Semiring α] (β : ι → Type*) [∀ i, AddCommMonoid (β i)] [ /-! API to/from the type synonym. -/ -/-- `Hamming.toHamming` is the identity function to the `Hamming` of a type. -/ +/-- `Hamming.toHamming` is the identity function to the `Hamming` of a type. -/ @[match_pattern] def toHamming : (∀ i, β i) ≃ Hamming β := Equiv.refl _ -/-- `Hamming.ofHamming` is the identity function from the `Hamming` of a type. -/ +/-- `Hamming.ofHamming` is the identity function from the `Hamming` of a type. -/ @[match_pattern] def ofHamming : Hamming β ≃ ∀ i, β i := Equiv.refl _ diff --git a/Mathlib/Init/Data/Quot.lean b/Mathlib/Init/Data/Quot.lean index 891d304ebce19..ea6fd10a176a4 100644 --- a/Mathlib/Init/Data/Quot.lean +++ b/Mathlib/Init/Data/Quot.lean @@ -3,8 +3,9 @@ Copyright (c) 2015 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Leonardo de Moura -/ - +import Batteries.Tactic.Alias import Mathlib.Init + /-! # Note about `Mathlib/Init/` The files in `Mathlib/Init` are leftovers from the port from Mathlib3. @@ -38,16 +39,18 @@ theorem EqvGen.is_equivalence : Equivalence (@EqvGen α r) := /-- `EqvGen.Setoid r` is the setoid generated by a relation `r`. The motivation for this definition is that `Quot r` behaves like `Quotient (EqvGen.Setoid r)`, -see for example `Quot.exact` and `Quot.EqvGen_sound`. +see for example `Quot.eqvGen_exact` and `Quot.eqvGen_sound`. -/ def EqvGen.Setoid : Setoid α := Setoid.mk _ (EqvGen.is_equivalence r) -theorem Quot.exact {a b : α} (H : Quot.mk r a = Quot.mk r b) : EqvGen r a b := +theorem Quot.eqvGen_exact {a b : α} (H : Quot.mk r a = Quot.mk r b) : EqvGen r a b := @Quotient.exact _ (EqvGen.Setoid r) a b (congrArg (Quot.lift (Quotient.mk (EqvGen.Setoid r)) (fun x y h ↦ Quot.sound (EqvGen.rel x y h))) H) -theorem Quot.EqvGen_sound {r : α → α → Prop} {a b : α} (H : EqvGen r a b) : +@[deprecated (since := "2024-08-29")] alias Quot.exact := Quot.eqvGen_exact + +theorem Quot.eqvGen_sound {r : α → α → Prop} {a b : α} (H : EqvGen r a b) : Quot.mk r a = Quot.mk r b := EqvGen.rec (fun _ _ h ↦ Quot.sound h) @@ -56,6 +59,8 @@ theorem Quot.EqvGen_sound {r : α → α → Prop} {a b : α} (H : EqvGen r a b) (fun _ _ _ _ _ IH₁ IH₂ ↦ Eq.trans IH₁ IH₂) H +@[deprecated (since := "2024-08-29")] alias Quot.EqvGen_sound := Quot.eqvGen_sound + end open Decidable diff --git a/Mathlib/Init/Logic.lean b/Mathlib/Init/Logic.lean index f6d926751096d..40c2fd17cf866 100644 --- a/Mathlib/Init/Logic.lean +++ b/Mathlib/Init/Logic.lean @@ -406,7 +406,7 @@ def RightCancelative := ∀ a b c, a * b = c * b → a = c def LeftDistributive := ∀ a b c, a * (b + c) = a * b + a * c def RightDistributive := ∀ a b c, (a + b) * c = a * c + b * c def RightCommutative (h : β → α → β) := ∀ b a₁ a₂, h (h b a₁) a₂ = h (h b a₂) a₁ -def LeftCommutative (h : α → β → β) := ∀ a₁ a₂ b, h a₁ (h a₂ b) = h a₂ (h a₁ b) +def LeftCommutative (h : α → β → β) := ∀ a₁ a₂ b, h a₁ (h a₂ b) = h a₂ (h a₁ b) theorem left_comm : Commutative f → Associative f → LeftCommutative f := fun hcomm hassoc a b c ↦ @@ -417,7 +417,7 @@ theorem left_comm : Commutative f → Associative f → LeftCommutative f := theorem right_comm : Commutative f → Associative f → RightCommutative f := fun hcomm hassoc a b c ↦ - calc (a*b)*c + calc (a*b)*c _ = a*(b*c) := hassoc a b c _ = a*(c*b) := hcomm b c ▸ rfl _ = (a*c)*b := Eq.symm (hassoc a c b) diff --git a/Mathlib/LinearAlgebra/AffineSpace/AffineSubspace.lean b/Mathlib/LinearAlgebra/AffineSpace/AffineSubspace.lean index 3dff1b6db9f72..f6144353a2434 100644 --- a/Mathlib/LinearAlgebra/AffineSpace/AffineSubspace.lean +++ b/Mathlib/LinearAlgebra/AffineSpace/AffineSubspace.lean @@ -1691,3 +1691,5 @@ theorem affineSpan_pair_parallel_iff_vectorSpan_eq {p₁ p₂ p₃ p₄ : P} : not_nonempty_iff_eq_empty] end AffineSubspace + +set_option linter.style.longFile 1800 diff --git a/Mathlib/LinearAlgebra/AffineSpace/ContinuousAffineEquiv.lean b/Mathlib/LinearAlgebra/AffineSpace/ContinuousAffineEquiv.lean index 546f23a3b7e1e..12ffbd6ace838 100644 --- a/Mathlib/LinearAlgebra/AffineSpace/ContinuousAffineEquiv.lean +++ b/Mathlib/LinearAlgebra/AffineSpace/ContinuousAffineEquiv.lean @@ -179,7 +179,7 @@ theorem symm_symm (e : P₁ ≃ᵃL[k] P₂) : e.symm.symm = e := rfl theorem symm_symm_apply (e : P₁ ≃ᵃL[k] P₂) (x : P₁) : e.symm.symm x = e x := rfl -theorem symm_apply_eq (e : P₁ ≃ᵃL[k] P₂) {x y} : e.symm x = y ↔ x = e y := +theorem symm_apply_eq (e : P₁ ≃ᵃL[k] P₂) {x y} : e.symm x = y ↔ x = e y := e.toAffineEquiv.symm_apply_eq theorem eq_symm_apply (e : P₁ ≃ᵃL[k] P₂) {x y} : y = e.symm x ↔ e y = x := diff --git a/Mathlib/LinearAlgebra/CliffordAlgebra/Equivs.lean b/Mathlib/LinearAlgebra/CliffordAlgebra/Equivs.lean index 64eab0f1101ed..30687d5b35594 100644 --- a/Mathlib/LinearAlgebra/CliffordAlgebra/Equivs.lean +++ b/Mathlib/LinearAlgebra/CliffordAlgebra/Equivs.lean @@ -358,7 +358,7 @@ variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M] theorem ι_mul_ι (r₁ r₂) : ι (0 : QuadraticForm R R) r₁ * ι (0 : QuadraticForm R R) r₂ = 0 := by rw [← mul_one r₁, ← mul_one r₂, ← smul_eq_mul R, ← smul_eq_mul R, LinearMap.map_smul, - LinearMap.map_smul, smul_mul_smul, ι_sq_scalar, QuadraticMap.zero_apply, RingHom.map_zero, + LinearMap.map_smul, smul_mul_smul_comm, ι_sq_scalar, QuadraticMap.zero_apply, RingHom.map_zero, smul_zero] /-- The clifford algebra over a 1-dimensional vector space with 0 quadratic form is isomorphic to diff --git a/Mathlib/LinearAlgebra/CliffordAlgebra/Even.lean b/Mathlib/LinearAlgebra/CliffordAlgebra/Even.lean index ab5a28a5dcedc..76bff36c9a4d1 100644 --- a/Mathlib/LinearAlgebra/CliffordAlgebra/Even.lean +++ b/Mathlib/LinearAlgebra/CliffordAlgebra/Even.lean @@ -125,7 +125,7 @@ variable {Q} namespace even.lift /-- An auxiliary submodule used to store the half-applied values of `f`. -This is the span of elements `f'` such that `∃ x m₂, ∀ m₁, f' m₁ = f m₁ m₂ * x`. -/ +This is the span of elements `f'` such that `∃ x m₂, ∀ m₁, f' m₁ = f m₁ m₂ * x`. -/ private def S : Submodule R (M →ₗ[R] A) := Submodule.span R {f' | ∃ x m₂, f' = LinearMap.lcomp R _ (f.bilin.flip m₂) (LinearMap.mulRight R x)} diff --git a/Mathlib/LinearAlgebra/CliffordAlgebra/EvenEquiv.lean b/Mathlib/LinearAlgebra/CliffordAlgebra/EvenEquiv.lean index ff16afc3d7f70..d699e29ff8b2d 100644 --- a/Mathlib/LinearAlgebra/CliffordAlgebra/EvenEquiv.lean +++ b/Mathlib/LinearAlgebra/CliffordAlgebra/EvenEquiv.lean @@ -187,7 +187,7 @@ theorem toEven_comp_ofEven : (toEven Q).comp (ofEven Q) = AlgHom.id R _ := have h2 : -(r₂ • e0 Q * v Q m₁) = v Q m₁ * r₂ • e0 Q := by rw [mul_smul_comm, smul_mul_assoc, ← smul_neg, neg_e0_mul_v] have h3 : -algebraMap R _ (r₁ * r₂) = r₁ • e0 Q * r₂ • e0 Q := by - rw [Algebra.algebraMap_eq_smul_one, smul_mul_smul, e0_mul_e0, smul_neg] + rw [Algebra.algebraMap_eq_smul_one, smul_mul_smul_comm, e0_mul_e0, smul_neg] rw [sub_eq_add_neg, sub_eq_add_neg, h1, h2, h3] _ = ι (Q' Q) (m₁, r₁) * ι (Q' Q) (m₂, r₂) := by rw [ι_eq_v_add_smul_e0, ι_eq_v_add_smul_e0, mul_add, add_mul, add_mul, add_assoc] diff --git a/Mathlib/LinearAlgebra/Dual.lean b/Mathlib/LinearAlgebra/Dual.lean index a2c10cf943b4e..b4d2e69e8d184 100644 --- a/Mathlib/LinearAlgebra/Dual.lean +++ b/Mathlib/LinearAlgebra/Dual.lean @@ -1079,7 +1079,7 @@ theorem dualAnnihilator_dualAnnihilator_eq (W : Subspace K V) : rw [dualCoannihilator, ← Module.mapEvalEquiv_symm_apply] at this rwa [← OrderIso.symm_apply_eq] -/-- The quotient by the dual is isomorphic to its dual annihilator. -/ +/-- The quotient by the dual is isomorphic to its dual annihilator. -/ -- Porting note (#11036): broken dot notation lean4#1910 LinearMap.range noncomputable def quotDualEquivAnnihilator (W : Subspace K V) : (Module.Dual K V ⧸ LinearMap.range W.dualLift) ≃ₗ[K] W.dualAnnihilator := @@ -1747,3 +1747,5 @@ noncomputable def dualDistribEquiv : Dual R M ⊗[R] Dual R N ≃ₗ[R] Dual R ( dualDistribEquivOfBasis (Module.Free.chooseBasis R M) (Module.Free.chooseBasis R N) end TensorProduct + +set_option linter.style.longFile 1900 diff --git a/Mathlib/LinearAlgebra/LinearIndependent.lean b/Mathlib/LinearAlgebra/LinearIndependent.lean index a2659a1e56194..c06db797d3a59 100644 --- a/Mathlib/LinearAlgebra/LinearIndependent.lean +++ b/Mathlib/LinearAlgebra/LinearIndependent.lean @@ -254,7 +254,7 @@ theorem LinearIndependent.map (hv : LinearIndependent R v) {f : M →ₗ[R] M'} LinearMap.ker_comp, hf_inj] exact fun _ => rfl -/-- If `v` is an injective family of vectors such that `f ∘ v` is linearly independent, then `v` +/-- If `v` is an injective family of vectors such that `f ∘ v` is linearly independent, then `v` spans a submodule disjoint from the kernel of `f` -/ theorem Submodule.range_ker_disjoint {f : M →ₗ[R] M'} (hv : LinearIndependent R (f ∘ v)) : diff --git a/Mathlib/LinearAlgebra/Matrix/Charpoly/LinearMap.lean b/Mathlib/LinearAlgebra/Matrix/Charpoly/LinearMap.lean index 6061db510ca97..73a35fa98fa85 100644 --- a/Mathlib/LinearAlgebra/Matrix/Charpoly/LinearMap.lean +++ b/Mathlib/LinearAlgebra/Matrix/Charpoly/LinearMap.lean @@ -28,7 +28,7 @@ variable (b : ι → M) open Polynomial Matrix /-- The composition of a matrix (as an endomorphism of `ι → R`) with the projection -`(ι → R) →ₗ[R] M`. -/ +`(ι → R) →ₗ[R] M`. -/ def PiToModule.fromMatrix [DecidableEq ι] : Matrix ι ι R →ₗ[R] (ι → R) →ₗ[R] M := (LinearMap.llcomp R _ _ _ (Fintype.linearCombination R R b)).comp algEquivMatrix'.symm.toLinearMap @@ -71,7 +71,7 @@ section variable {R} [DecidableEq ι] /-- We say that a matrix represents an endomorphism of `M` if the matrix acting on `ι → R` is -equal to `f` via the projection `(ι → R) →ₗ[R] M` given by a fixed (spanning) set. -/ +equal to `f` via the projection `(ι → R) →ₗ[R] M` given by a fixed (spanning) set. -/ def Matrix.Represents (A : Matrix ι ι R) (f : Module.End R M) : Prop := PiToModule.fromMatrix R b A = PiToModule.fromEnd R b f diff --git a/Mathlib/LinearAlgebra/Matrix/GeneralLinearGroup/Defs.lean b/Mathlib/LinearAlgebra/Matrix/GeneralLinearGroup/Defs.lean index 301e6932dcf83..50c1c2dfc8bb0 100644 --- a/Mathlib/LinearAlgebra/Matrix/GeneralLinearGroup/Defs.lean +++ b/Mathlib/LinearAlgebra/Matrix/GeneralLinearGroup/Defs.lean @@ -37,7 +37,7 @@ open LinearMap attribute [-instance] SpecialLinearGroup.instCoeFun /-- `GL n R` is the group of `n` by `n` `R`-matrices with unit determinant. -Defined as a subtype of matrices-/ +Defined as a subtype of matrices -/ abbrev GeneralLinearGroup (n : Type u) (R : Type v) [DecidableEq n] [Fintype n] [CommRing R] : Type _ := (Matrix n n R)ˣ @@ -69,7 +69,7 @@ def det : GL n R →* Rˣ where map_one' := Units.ext det_one map_mul' A B := Units.ext <| det_mul _ _ -/-- The `GL n R` and `Matrix.GeneralLinearGroup R n` groups are multiplicatively equivalent-/ +/-- The `GL n R` and `Matrix.GeneralLinearGroup R n` groups are multiplicatively equivalent -/ def toLin : GL n R ≃* LinearMap.GeneralLinearGroup R (n → R) := Units.mapEquiv toLinAlgEquiv'.toMulEquiv diff --git a/Mathlib/LinearAlgebra/Matrix/LDL.lean b/Mathlib/LinearAlgebra/Matrix/LDL.lean index 46bbe801bd60b..277c2bddd5c89 100644 --- a/Mathlib/LinearAlgebra/Matrix/LDL.lean +++ b/Mathlib/LinearAlgebra/Matrix/LDL.lean @@ -107,7 +107,7 @@ noncomputable def LDL.lower := (LDL.lowerInv hS)⁻¹ /-- **LDL decomposition**: any positive definite matrix `S` can be -decomposed as `S = LDLᴴ` where `L` is a lower-triangular matrix and `D` is a diagonal matrix. -/ +decomposed as `S = LDLᴴ` where `L` is a lower-triangular matrix and `D` is a diagonal matrix. -/ theorem LDL.lower_conj_diag : LDL.lower hS * LDL.diag hS * (LDL.lower hS)ᴴ = S := by rw [LDL.lower, conjTranspose_nonsing_inv, Matrix.mul_assoc, Matrix.inv_mul_eq_iff_eq_mul_of_invertible (LDL.lowerInv hS), diff --git a/Mathlib/LinearAlgebra/Matrix/PosDef.lean b/Mathlib/LinearAlgebra/Matrix/PosDef.lean index a982d1b30fdeb..941af97a89e99 100644 --- a/Mathlib/LinearAlgebra/Matrix/PosDef.lean +++ b/Mathlib/LinearAlgebra/Matrix/PosDef.lean @@ -18,7 +18,7 @@ of quadratic forms. Most results require `𝕜 = ℝ` or `ℂ`. * `Matrix.PosSemidef` : a matrix `M : Matrix n n 𝕜` is positive semidefinite if it is hermitian and `xᴴMx` is nonnegative for all `x`. -## Main results +## Main results * `Matrix.posSemidef_iff_eq_transpose_mul_self` : a matrix `M : Matrix n n 𝕜` is positive semidefinite iff it has the form `Bᴴ * B` for some `B`. diff --git a/Mathlib/LinearAlgebra/Matrix/SchurComplement.lean b/Mathlib/LinearAlgebra/Matrix/SchurComplement.lean index ea9e82931381e..cdee1596abde6 100644 --- a/Mathlib/LinearAlgebra/Matrix/SchurComplement.lean +++ b/Mathlib/LinearAlgebra/Matrix/SchurComplement.lean @@ -224,7 +224,7 @@ end Triangular section Block -/-! #### General 2×2 block matrices-/ +/-! #### General 2×2 block matrices -/ /-- A block matrix is invertible if the bottom right corner and the corresponding schur complement diff --git a/Mathlib/LinearAlgebra/Matrix/SesquilinearForm.lean b/Mathlib/LinearAlgebra/Matrix/SesquilinearForm.lean index 44fdd5263d583..13e2bba24b39b 100644 --- a/Mathlib/LinearAlgebra/Matrix/SesquilinearForm.lean +++ b/Mathlib/LinearAlgebra/Matrix/SesquilinearForm.lean @@ -485,7 +485,7 @@ end end ToMatrix -/-! ### Adjoint pairs-/ +/-! ### Adjoint pairs -/ section MatrixAdjoints @@ -623,7 +623,7 @@ end MatrixAdjoints namespace LinearMap -/-! ### Nondegenerate bilinear forms-/ +/-! ### Nondegenerate bilinear forms -/ section Det diff --git a/Mathlib/LinearAlgebra/Matrix/Spectrum.lean b/Mathlib/LinearAlgebra/Matrix/Spectrum.lean index d69134ff4820b..e20e0a672cfc3 100644 --- a/Mathlib/LinearAlgebra/Matrix/Spectrum.lean +++ b/Mathlib/LinearAlgebra/Matrix/Spectrum.lean @@ -17,7 +17,7 @@ the spectral theorem for linear maps (`LinearMap.IsSymmetric.eigenvectorBasis_ap ## Tags -spectral theorem, diagonalization theorem-/ +spectral theorem, diagonalization theorem -/ namespace Matrix diff --git a/Mathlib/LinearAlgebra/Matrix/ToLin.lean b/Mathlib/LinearAlgebra/Matrix/ToLin.lean index f7a4aba7c8c89..803a75b7be149 100644 --- a/Mathlib/LinearAlgebra/Matrix/ToLin.lean +++ b/Mathlib/LinearAlgebra/Matrix/ToLin.lean @@ -942,7 +942,7 @@ If `M₁` and `M₂` are modules with basis `b₁` and `b₂` respectively index by finite types `ι₁` and `ι₂`, then `Basis.linearMap b₁ b₂` is the basis of `M₁ →ₗ[R] M₂` indexed by `ι₂ × ι₁` where `(i, j)` indexes the linear map that sends `b j` to `b i` -and sends all other basis vectors to `0`. -/ +and sends all other basis vectors to `0`. -/ @[simps! (config := .lemmasOnly) repr_apply repr_symm_apply] noncomputable def linearMap (b₁ : Basis ι₁ R M₁) (b₂ : Basis ι₂ R M₂) : @@ -968,7 +968,7 @@ induced by a basis of the module. If `M` is a module with basis `b` indexed by a finite type `ι`, then `Basis.end b` is the basis of `Module.End R M` indexed by `ι × ι` where `(i, j)` indexes the linear map that sends `b j` to `b i` -and sends all other basis vectors to `0`. -/ +and sends all other basis vectors to `0`. -/ @[simps! (config := .lemmasOnly) repr_apply repr_symm_apply] noncomputable abbrev _root_.Basis.end (b : Basis ι R M) : Basis (ι × ι) R (Module.End R M) := diff --git a/Mathlib/LinearAlgebra/Multilinear/Basic.lean b/Mathlib/LinearAlgebra/Multilinear/Basic.lean index b9fed90e5e9ec..417f0dde15dc6 100644 --- a/Mathlib/LinearAlgebra/Multilinear/Basic.lean +++ b/Mathlib/LinearAlgebra/Multilinear/Basic.lean @@ -1771,3 +1771,5 @@ def range [Nonempty ι] (f : MultilinearMap R M₁ M₂) : SubMulAction R M₂ : end Submodule end MultilinearMap + +set_option linter.style.longFile 1900 diff --git a/Mathlib/LinearAlgebra/QuadraticForm/QuadraticModuleCat.lean b/Mathlib/LinearAlgebra/QuadraticForm/QuadraticModuleCat.lean index f316c983c328a..c05f820fefc9c 100644 --- a/Mathlib/LinearAlgebra/QuadraticForm/QuadraticModuleCat.lean +++ b/Mathlib/LinearAlgebra/QuadraticForm/QuadraticModuleCat.lean @@ -16,7 +16,7 @@ universe v u variable (R : Type u) [CommRing R] -/-- The category of quadratic modules; modules with an associated quadratic form-/ +/-- The category of quadratic modules; modules with an associated quadratic form -/ structure QuadraticModuleCat extends ModuleCat.{v} R where /-- The quadratic form associated with the module. -/ form : QuadraticForm R carrier diff --git a/Mathlib/LinearAlgebra/SesquilinearForm.lean b/Mathlib/LinearAlgebra/SesquilinearForm.lean index bd978ca7e48a4..e1ee9539064ba 100644 --- a/Mathlib/LinearAlgebra/SesquilinearForm.lean +++ b/Mathlib/LinearAlgebra/SesquilinearForm.lean @@ -460,7 +460,7 @@ end AddCommGroup end AdjointPair -/-! ### Self-adjoint pairs-/ +/-! ### Self-adjoint pairs -/ section SelfadjointPair diff --git a/Mathlib/LinearAlgebra/TensorProduct/Basic.lean b/Mathlib/LinearAlgebra/TensorProduct/Basic.lean index 6bbe92a9b4b88..bcb3daf37d060 100644 --- a/Mathlib/LinearAlgebra/TensorProduct/Basic.lean +++ b/Mathlib/LinearAlgebra/TensorProduct/Basic.lean @@ -669,7 +669,7 @@ theorem comm_tmul (m : M) (n : N) : (TensorProduct.comm R M N) (m ⊗ₜ n) = n theorem comm_symm_tmul (m : M) (n : N) : (TensorProduct.comm R M N).symm (n ⊗ₜ m) = m ⊗ₜ n := rfl -lemma lift_comp_comm_eq (f : M →ₗ[R] N →ₗ[R] P) : +lemma lift_comp_comm_eq (f : M →ₗ[R] N →ₗ[R] P) : lift f ∘ₗ TensorProduct.comm R N M = lift f.flip := ext rfl end diff --git a/Mathlib/Logic/Embedding/Set.lean b/Mathlib/Logic/Embedding/Set.lean index bff9f99b31ff2..0c0ce8045a169 100644 --- a/Mathlib/Logic/Embedding/Set.lean +++ b/Mathlib/Logic/Embedding/Set.lean @@ -90,7 +90,7 @@ variable {α : Type*} subtypes `{x // p x} ⊕ {x // q x}` such that `¬ p x` is sent to the right, when `Disjoint p q`. -See also `Equiv.sumCompl`, for when `IsCompl p q`. -/ +See also `Equiv.sumCompl`, for when `IsCompl p q`. -/ @[simps apply] def subtypeOrEquiv (p q : α → Prop) [DecidablePred p] (h : Disjoint p q) : { x // p x ∨ q x } ≃ { x // p x } ⊕ { x // q x } where diff --git a/Mathlib/Logic/Encodable/Basic.lean b/Mathlib/Logic/Encodable/Basic.lean index d6cac938c8892..60412ec201292 100644 --- a/Mathlib/Logic/Encodable/Basic.lean +++ b/Mathlib/Logic/Encodable/Basic.lean @@ -47,7 +47,7 @@ class Encodable (α : Type*) where --explicitly in Lean4 /-- Decoding from ℕ to Option α-/ decode : ℕ → Option α - /-- Invariant relationship between encoding and decoding-/ + /-- Invariant relationship between encoding and decoding -/ encodek : ∀ a, decode (encode a) = some a attribute [simp] Encodable.encodek diff --git a/Mathlib/Logic/Equiv/Basic.lean b/Mathlib/Logic/Equiv/Basic.lean index 6c45dd5766fce..bfe1a6a49682c 100644 --- a/Mathlib/Logic/Equiv/Basic.lean +++ b/Mathlib/Logic/Equiv/Basic.lean @@ -494,7 +494,7 @@ the sum of the two subtypes `{a // p a}` and its complement `{a // ¬ p a}` is naturally equivalent to `α`. See `subtypeOrEquiv` for sum types over subtypes `{x // p x}` and `{x // q x}` -that are not necessarily `IsCompl p q`. -/ +that are not necessarily `IsCompl p q`. -/ def sumCompl {α : Type*} (p : α → Prop) [DecidablePred p] : { a // p a } ⊕ { a // ¬p a } ≃ α where toFun := Sum.elim Subtype.val Subtype.val @@ -1832,3 +1832,5 @@ theorem piCongrLeft'_symm_update [DecidableEq α] [DecidableEq β] (P : α → S simp [(e.piCongrLeft' P).symm_apply_eq, piCongrLeft'_update] end Function + +set_option linter.style.longFile 2000 diff --git a/Mathlib/Logic/Equiv/Defs.lean b/Mathlib/Logic/Equiv/Defs.lean index 65d1a01f4dd18..f85dc2dee7a75 100644 --- a/Mathlib/Logic/Equiv/Defs.lean +++ b/Mathlib/Logic/Equiv/Defs.lean @@ -611,7 +611,7 @@ theorem sigmaCongrRight_symm {α} {β₁ β₂ : α → Type*} (F : ∀ a, β₁ theorem sigmaCongrRight_refl {α} {β : α → Type*} : (sigmaCongrRight fun a => Equiv.refl (β a)) = Equiv.refl (Σ a, β a) := rfl -/-- A `PSigma` with `Prop` fibers is equivalent to the subtype. -/ +/-- A `PSigma` with `Prop` fibers is equivalent to the subtype. -/ def psigmaEquivSubtype {α : Type v} (P : α → Prop) : (Σ' i, P i) ≃ Subtype P where toFun x := ⟨x.1, x.2⟩ invFun x := ⟨x.1, x.2⟩ diff --git a/Mathlib/Logic/Equiv/PartialEquiv.lean b/Mathlib/Logic/Equiv/PartialEquiv.lean index ccfde61a6ffb6..7d93cc552f446 100644 --- a/Mathlib/Logic/Equiv/PartialEquiv.lean +++ b/Mathlib/Logic/Equiv/PartialEquiv.lean @@ -719,7 +719,7 @@ theorem EqOnSource.restr {e e' : PartialEquiv α β} (he : e ≈ e') (s : Set α theorem EqOnSource.source_inter_preimage_eq {e e' : PartialEquiv α β} (he : e ≈ e') (s : Set β) : e.source ∩ e ⁻¹' s = e'.source ∩ e' ⁻¹' s := by rw [he.eqOn.inter_preimage_eq, source_eq he] -/-- Composition of a partial equivlance and its inverse is equivalent to +/-- Composition of a partial equivalence and its inverse is equivalent to the restriction of the identity to the source. -/ theorem self_trans_symm : e.trans e.symm ≈ ofSet e.source := by have A : (e.trans e.symm).source = e.source := by mfld_set_tac diff --git a/Mathlib/MeasureTheory/Constructions/BorelSpace/Basic.lean b/Mathlib/MeasureTheory/Constructions/BorelSpace/Basic.lean index c7a28a5184fbf..4e32c8b29d99a 100644 --- a/Mathlib/MeasureTheory/Constructions/BorelSpace/Basic.lean +++ b/Mathlib/MeasureTheory/Constructions/BorelSpace/Basic.lean @@ -267,6 +267,9 @@ theorem IsClosed.nullMeasurableSet {μ} (h : IsClosed s) : NullMeasurableSet s theorem IsCompact.measurableSet [T2Space α] (h : IsCompact s) : MeasurableSet s := h.isClosed.measurableSet +theorem IsCompact.nullMeasurableSet [T2Space α] {μ} (h : IsCompact s) : NullMeasurableSet s μ := + h.isClosed.nullMeasurableSet + /-- If two points are topologically inseparable, then they can't be separated by a Borel measurable set. -/ theorem Inseparable.mem_measurableSet_iff {x y : γ} (h : Inseparable x y) {s : Set γ} @@ -286,7 +289,7 @@ the measure of the closure of a compact set `K` is equal to the measure of `K`. See also `MeasureTheory.Measure.OuterRegular.measure_closure_eq_of_isCompact` for a version that assumes `μ` to be outer regular -but does not assume the `σ`-algebra to be Borel. -/ +but does not assume the `σ`-algebra to be Borel. -/ theorem IsCompact.measure_closure [R1Space γ] {K : Set γ} (hK : IsCompact K) (μ : Measure γ) : μ (closure K) = μ K := by refine le_antisymm ?_ (measure_mono subset_closure) @@ -624,7 +627,7 @@ instance _root_.ULift.instBorelSpace : BorelSpace (ULift α) := instance DiscreteMeasurableSpace.toBorelSpace {α : Type*} [TopologicalSpace α] [DiscreteTopology α] [MeasurableSpace α] [DiscreteMeasurableSpace α] : BorelSpace α := by - constructor; ext; simp [MeasurableSpace.measurableSet_generateFrom, measurableSet_discrete] + constructor; ext; simp [MeasurableSpace.measurableSet_generateFrom, MeasurableSet.of_discrete] protected theorem Embedding.measurableEmbedding {f : α → β} (h₁ : Embedding f) (h₂ : MeasurableSet (range f)) : MeasurableEmbedding f := diff --git a/Mathlib/MeasureTheory/Constructions/BorelSpace/Metric.lean b/Mathlib/MeasureTheory/Constructions/BorelSpace/Metric.lean index 8abe04e25e044..2a7e7bc08abc6 100644 --- a/Mathlib/MeasureTheory/Constructions/BorelSpace/Metric.lean +++ b/Mathlib/MeasureTheory/Constructions/BorelSpace/Metric.lean @@ -128,7 +128,7 @@ theorem tendsto_measure_cthickening {μ : Measure α} {s : Set α} have A : Tendsto (fun r => μ (cthickening r s)) (𝓝[Ioi 0] 0) (𝓝 (μ (closure s))) := by rw [closure_eq_iInter_cthickening] exact - tendsto_measure_biInter_gt (fun r _ => isClosed_cthickening.measurableSet) + tendsto_measure_biInter_gt (fun r _ => isClosed_cthickening.nullMeasurableSet) (fun i j _ ij => cthickening_mono ij _) hs have B : Tendsto (fun r => μ (cthickening r s)) (𝓝[Iic 0] 0) (𝓝 (μ (closure s))) := by apply Tendsto.congr' _ tendsto_const_nhds @@ -151,7 +151,7 @@ theorem tendsto_measure_thickening {μ : Measure α} {s : Set α} (hs : ∃ R > 0, μ (thickening R s) ≠ ∞) : Tendsto (fun r => μ (thickening r s)) (𝓝[>] 0) (𝓝 (μ (closure s))) := by rw [closure_eq_iInter_thickening] - exact tendsto_measure_biInter_gt (fun r _ => isOpen_thickening.measurableSet) + exact tendsto_measure_biInter_gt (fun r _ => isOpen_thickening.nullMeasurableSet) (fun i j _ ij => thickening_mono ij _) hs /-- If a closed set has a thickening with finite measure, then the measure of its diff --git a/Mathlib/MeasureTheory/Constructions/BorelSpace/Order.lean b/Mathlib/MeasureTheory/Constructions/BorelSpace/Order.lean index d848798cf7bd9..69da14e76bce5 100644 --- a/Mathlib/MeasureTheory/Constructions/BorelSpace/Order.lean +++ b/Mathlib/MeasureTheory/Constructions/BorelSpace/Order.lean @@ -398,8 +398,8 @@ theorem ext_of_Iic {α : Type*} [TopologicalSpace α] {m : MeasurableSpace α} · rcases exists_countable_dense_bot_top α with ⟨s, hsc, hsd, -, hst⟩ have : DirectedOn (· ≤ ·) s := directedOn_iff_directed.2 (Subtype.mono_coe _).directed_le simp only [← biSup_measure_Iic hsc (hsd.exists_ge' hst) this, h] - rw [← Iic_diff_Iic, measure_diff (Iic_subset_Iic.2 hlt.le) measurableSet_Iic, - measure_diff (Iic_subset_Iic.2 hlt.le) measurableSet_Iic, h a, h b] + rw [← Iic_diff_Iic, measure_diff (Iic_subset_Iic.2 hlt.le) measurableSet_Iic.nullMeasurableSet, + measure_diff (Iic_subset_Iic.2 hlt.le) measurableSet_Iic.nullMeasurableSet, h a, h b] · rw [← h a] exact (measure_lt_top μ _).ne · exact (measure_lt_top μ _).ne diff --git a/Mathlib/MeasureTheory/Constructions/BorelSpace/Real.lean b/Mathlib/MeasureTheory/Constructions/BorelSpace/Real.lean index 9e03eae8ea344..b566424678fd2 100644 --- a/Mathlib/MeasureTheory/Constructions/BorelSpace/Real.lean +++ b/Mathlib/MeasureTheory/Constructions/BorelSpace/Real.lean @@ -505,7 +505,7 @@ variable (μ : Measure ℝ) [IsFiniteMeasureOnCompacts μ] lemma tendsto_measure_Icc_nhdsWithin_right' (b : ℝ) : Tendsto (fun δ ↦ μ (Icc (b - δ) (b + δ))) (𝓝[>] (0 : ℝ)) (𝓝 (μ {b})) := by rw [Real.singleton_eq_inter_Icc] - apply tendsto_measure_biInter_gt (fun r hr ↦ measurableSet_Icc) + apply tendsto_measure_biInter_gt (fun r hr ↦ measurableSet_Icc.nullMeasurableSet) · intro r s _rpos hrs exact Icc_subset_Icc (by linarith) (by linarith) · exact ⟨1, zero_lt_one, isCompact_Icc.measure_ne_top⟩ diff --git a/Mathlib/MeasureTheory/Constructions/Prod/Basic.lean b/Mathlib/MeasureTheory/Constructions/Prod/Basic.lean index 7aa58edc685c0..a8e405fc234e1 100644 --- a/Mathlib/MeasureTheory/Constructions/Prod/Basic.lean +++ b/Mathlib/MeasureTheory/Constructions/Prod/Basic.lean @@ -1012,6 +1012,9 @@ theorem fst_map_prod_mk {X : α → β} {Y : α → γ} {μ : Measure α} (hY : Measurable Y) : (μ.map fun a => (X a, Y a)).fst = μ.map X := fst_map_prod_mk₀ hY.aemeasurable +@[gcongr] +theorem fst_mono {μ : Measure (α × β)} (h : ρ ≤ μ) : ρ.fst ≤ μ.fst := map_mono h measurable_fst + /-- Marginal measure on `β` obtained from a measure on `ρ` `α × β`, defined by `ρ.map Prod.snd`. -/ noncomputable def snd (ρ : Measure (α × β)) : Measure β := ρ.map Prod.snd @@ -1056,6 +1059,9 @@ theorem snd_map_prod_mk {X : α → β} {Y : α → γ} {μ : Measure α} (hX : (μ.map fun a => (X a, Y a)).snd = μ.map Y := snd_map_prod_mk₀ hX.aemeasurable +@[gcongr] +theorem snd_mono {μ : Measure (α × β)} (h : ρ ≤ μ) : ρ.snd ≤ μ.snd := map_mono h measurable_snd + @[simp] lemma fst_map_swap : (ρ.map Prod.swap).fst = ρ.snd := by rw [Measure.fst, Measure.map_map measurable_fst measurable_swap] rfl diff --git a/Mathlib/MeasureTheory/Covering/Besicovitch.lean b/Mathlib/MeasureTheory/Covering/Besicovitch.lean index 24f265572ac91..5fc2bf194df58 100644 --- a/Mathlib/MeasureTheory/Covering/Besicovitch.lean +++ b/Mathlib/MeasureTheory/Covering/Besicovitch.lean @@ -621,9 +621,9 @@ theorem exist_finset_disjoint_balls_large_measure (μ : Measure α) [IsFiniteMea rw [← diff_inter_self_eq_diff, measure_diff_le_iff_le_add _ inter_subset_right (measure_lt_top μ _).ne] swap - · apply MeasurableSet.inter _ omeas - haveI : Encodable (u i) := (u_count i).toEncodable - exact MeasurableSet.iUnion fun b => MeasurableSet.iUnion fun _ => measurableSet_closedBall + · exact .inter + (w.nullMeasurableSet_biUnion fun _ _ ↦ measurableSet_closedBall.nullMeasurableSet) + omeas.nullMeasurableSet calc μ o = 1 / (N + 1) * μ s + N / (N + 1) * μ s := by rw [μo, ← add_mul, ENNReal.div_add_div_same, add_comm, ENNReal.div_self, one_mul] <;> simp diff --git a/Mathlib/MeasureTheory/Decomposition/RadonNikodym.lean b/Mathlib/MeasureTheory/Decomposition/RadonNikodym.lean index ce2271b8b0ffc..48bb69b5fadb2 100644 --- a/Mathlib/MeasureTheory/Decomposition/RadonNikodym.lean +++ b/Mathlib/MeasureTheory/Decomposition/RadonNikodym.lean @@ -390,6 +390,12 @@ lemma integral_toReal_rnDeriv [SigmaFinite μ] [SigmaFinite ν] (hμν : μ ≪ ∫ x, (μ.rnDeriv ν x).toReal ∂ν = (μ Set.univ).toReal := by rw [← integral_univ, setIntegral_toReal_rnDeriv hμν Set.univ] +lemma integral_toReal_rnDeriv' [IsFiniteMeasure μ] [SigmaFinite ν] : + ∫ x, (μ.rnDeriv ν x).toReal ∂ν = (μ Set.univ).toReal - (μ.singularPart ν Set.univ).toReal := by + rw [← ENNReal.toReal_sub_of_le (μ.singularPart_le ν Set.univ) (measure_ne_top _ _), + ← Measure.sub_apply .univ (Measure.singularPart_le μ ν), Measure.measure_sub_singularPart, + ← Measure.setIntegral_toReal_rnDeriv_eq_withDensity, integral_univ] + end integral lemma rnDeriv_mul_rnDeriv {κ : Measure α} [SigmaFinite μ] [SigmaFinite ν] [SigmaFinite κ] diff --git a/Mathlib/MeasureTheory/Decomposition/SignedHahn.lean b/Mathlib/MeasureTheory/Decomposition/SignedHahn.lean index 054d7829fab2f..3891d1175c65d 100644 --- a/Mathlib/MeasureTheory/Decomposition/SignedHahn.lean +++ b/Mathlib/MeasureTheory/Decomposition/SignedHahn.lean @@ -81,7 +81,7 @@ To implement this in Lean, we define several auxiliary definitions. where `restrictNonposSeq s i 0 = someExistsOneDivLT s (i \ ∅)` and `restrictNonposSeq s i (n + 1) = someExistsOneDivLT s (i \ ⋃ k ≤ n, restrictNonposSeq k)`. - This definition represents the sequence $(A_n)$ in the proof as described above. + This definition represents the sequence $(A_n)$ in the proof as described above. With these definitions, we are able consider the case where the sequence terminates separately, allowing us to prove `exists_subset_restrict_nonpos`. diff --git a/Mathlib/MeasureTheory/Decomposition/UnsignedHahn.lean b/Mathlib/MeasureTheory/Decomposition/UnsignedHahn.lean index f6b3615d79356..de9f47a8ba7a8 100644 --- a/Mathlib/MeasureTheory/Decomposition/UnsignedHahn.lean +++ b/Mathlib/MeasureTheory/Decomposition/UnsignedHahn.lean @@ -56,9 +56,8 @@ theorem hahn_decomposition [IsFiniteMeasure μ] [IsFiniteMeasure ν] : have d_Inter (s : ℕ → Set α) (hs : ∀ n, MeasurableSet (s n)) (hm : ∀ n m, n ≤ m → s m ⊆ s n) : Tendsto (fun n => d (s n)) atTop (𝓝 (d (⋂ n, s n))) := by refine Tendsto.sub ?_ ?_ <;> - refine - NNReal.tendsto_coe.2 <| - (ENNReal.tendsto_toNNReal <| ?_).comp <| tendsto_measure_iInter hs hm ?_ + refine NNReal.tendsto_coe.2 <| (ENNReal.tendsto_toNNReal <| ?_).comp <| + tendsto_measure_iInter (fun n ↦ (hs n).nullMeasurableSet) hm ?_ exacts [hμ _, ⟨0, hμ _⟩, hν _, ⟨0, hν _⟩] have bdd_c : BddAbove c := by use (μ univ).toNNReal diff --git a/Mathlib/MeasureTheory/Function/AEEqFun.lean b/Mathlib/MeasureTheory/Function/AEEqFun.lean index cb6030efa880d..c0d68d263e2f8 100644 --- a/Mathlib/MeasureTheory/Function/AEEqFun.lean +++ b/Mathlib/MeasureTheory/Function/AEEqFun.lean @@ -93,7 +93,7 @@ variable (α) /-- The space of equivalence classes of almost everywhere strongly measurable functions, where two strongly measurable functions are equivalent if they agree almost everywhere, i.e., - they differ on a set of measure `0`. -/ + they differ on a set of measure `0`. -/ def AEEqFun (μ : Measure α) : Type _ := Quotient (μ.aeEqSetoid β) @@ -235,7 +235,7 @@ variable [TopologicalSpace γ] [MeasurableSpace β] {ν : MeasureTheory.Measure /-- Composition of an almost everywhere equal function and a quasi measure preserving function. This is an important special case of `AEEqFun.compQuasiMeasurePreserving`. We use a separate -definition so that lemmas that need `f` to be measure preserving can be `@[simp]` lemmas. -/ +definition so that lemmas that need `f` to be measure preserving can be `@[simp]` lemmas. -/ def compMeasurePreserving (g : β →ₘ[ν] γ) (f : α → β) (hf : MeasurePreserving f μ ν) : α →ₘ[μ] γ := g.compQuasiMeasurePreserving f hf.quasiMeasurePreserving diff --git a/Mathlib/MeasureTheory/Function/ContinuousMapDense.lean b/Mathlib/MeasureTheory/Function/ContinuousMapDense.lean index d16ec22981a70..be9517c3b1db9 100644 --- a/Mathlib/MeasureTheory/Function/ContinuousMapDense.lean +++ b/Mathlib/MeasureTheory/Function/ContinuousMapDense.lean @@ -366,7 +366,7 @@ namespace ContinuousMap /-- Continuous functions are dense in `MeasureTheory.Lp`, `1 ≤ p < ∞`. This theorem assumes that the domain is a compact space because otherwise `ContinuousMap.toLp` is undefined. Use -`BoundedContinuousFunction.toLp_denseRange` if the domain is not a compact space. -/ +`BoundedContinuousFunction.toLp_denseRange` if the domain is not a compact space. -/ theorem toLp_denseRange [CompactSpace α] [μ.WeaklyRegular] [IsFiniteMeasure μ] (hp : p ≠ ∞) : DenseRange (toLp p μ 𝕜 : C(α, E) →L[𝕜] Lp E p μ) := by refine (BoundedContinuousFunction.toLp_denseRange _ _ 𝕜 hp).mono ?_ diff --git a/Mathlib/MeasureTheory/Function/Egorov.lean b/Mathlib/MeasureTheory/Function/Egorov.lean index 402e64e727ca0..932a6fefb1d33 100644 --- a/Mathlib/MeasureTheory/Function/Egorov.lean +++ b/Mathlib/MeasureTheory/Function/Egorov.lean @@ -81,7 +81,8 @@ theorem measure_notConvergentSeq_tendsto_zero [SemilatticeSup ι] [Countable ι] rw [this] exact tendsto_const_nhds rw [← measure_inter_notConvergentSeq_eq_zero hfg n, Set.inter_iInter] - refine tendsto_measure_iInter (fun n => hsm.inter <| notConvergentSeq_measurableSet hf hg) + refine tendsto_measure_iInter + (fun n ↦ (hsm.inter <| notConvergentSeq_measurableSet hf hg).nullMeasurableSet) (fun k l hkl => Set.inter_subset_inter_right _ <| notConvergentSeq_antitone hkl) ⟨h.some, ne_top_of_le_ne_top hs (measure_mono Set.inter_subset_left)⟩ diff --git a/Mathlib/MeasureTheory/Function/LpSpace.lean b/Mathlib/MeasureTheory/Function/LpSpace.lean index cfd54d45970a3..d5eca9056cc76 100644 --- a/Mathlib/MeasureTheory/Function/LpSpace.lean +++ b/Mathlib/MeasureTheory/Function/LpSpace.lean @@ -1877,7 +1877,7 @@ theorem toLp_inj {f g : C(α, E)} [μ.IsOpenPosMeasure] [NormedField 𝕜] [Norm variable {μ} /-- If a sum of continuous functions `g n` is convergent, and the same sum converges in `Lᵖ` to `h`, -then in fact `g n` converges uniformly to `h`. -/ +then in fact `g n` converges uniformly to `h`. -/ theorem hasSum_of_hasSum_Lp {β : Type*} [μ.IsOpenPosMeasure] [NormedField 𝕜] [NormedSpace 𝕜 E] {g : β → C(α, E)} {f : C(α, E)} (hg : Summable g) (hg2 : HasSum (toLp (E := E) p μ 𝕜 ∘ g) (toLp (E := E) p μ 𝕜 f)) : HasSum g f := by @@ -1929,3 +1929,5 @@ theorem meas_ge_le_mul_pow_norm (f : Lp E p μ) (hp_ne_zero : p ≠ 0) (hp_ne_to end Lp end MeasureTheory + +set_option linter.style.longFile 2100 diff --git a/Mathlib/MeasureTheory/Function/SimpleFunc.lean b/Mathlib/MeasureTheory/Function/SimpleFunc.lean index 12cb38f0a28bf..fcde2b1ae94ab 100644 --- a/Mathlib/MeasureTheory/Function/SimpleFunc.lean +++ b/Mathlib/MeasureTheory/Function/SimpleFunc.lean @@ -812,7 +812,7 @@ theorem lintegral_eq_of_subset' (f : α →ₛ ℝ≥0∞) {s : Finset ℝ≥0 f.lintegral_eq_of_subset fun x hfx _ => hs <| Finset.mem_sdiff.2 ⟨f.mem_range_self x, mt Finset.mem_singleton.1 hfx⟩ -/-- Calculate the integral of `(g ∘ f)`, where `g : β → ℝ≥0∞` and `f : α →ₛ β`. -/ +/-- Calculate the integral of `(g ∘ f)`, where `g : β → ℝ≥0∞` and `f : α →ₛ β`. -/ theorem map_lintegral (g : β → ℝ≥0∞) (f : α →ₛ β) : (f.map g).lintegral μ = ∑ x ∈ f.range, g x * μ (f ⁻¹' {x}) := by simp only [lintegral, range_map] diff --git a/Mathlib/MeasureTheory/Function/StronglyMeasurable/Basic.lean b/Mathlib/MeasureTheory/Function/StronglyMeasurable/Basic.lean index 1825b6c071019..b2fb9342d5eb9 100644 --- a/Mathlib/MeasureTheory/Function/StronglyMeasurable/Basic.lean +++ b/Mathlib/MeasureTheory/Function/StronglyMeasurable/Basic.lean @@ -1880,3 +1880,5 @@ theorem stronglyMeasurable_uncurry_of_continuous_of_stronglyMeasurable {α β ι exact ((t_sf n).measurable.comp measurable_fst).subtype_mk end MeasureTheory + +set_option linter.style.longFile 2000 diff --git a/Mathlib/MeasureTheory/Group/Action.lean b/Mathlib/MeasureTheory/Group/Action.lean index 159a5bff0f4ff..28b06957d5abb 100644 --- a/Mathlib/MeasureTheory/Group/Action.lean +++ b/Mathlib/MeasureTheory/Group/Action.lean @@ -171,7 +171,7 @@ theorem smulInvariantMeasure_iterateMulAct section SMulHomClass universe uM uN uα uβ -variable {M : Type uM} {N : Type uN} {α : Type uα} {β : Type uβ} +variable {M : Type uM} {N : Type uN} {α : Type uα} {β : Type uβ} [MeasurableSpace M] [MeasurableSpace N] [MeasurableSpace α] [MeasurableSpace β] @[to_additive] diff --git a/Mathlib/MeasureTheory/Group/AddCircle.lean b/Mathlib/MeasureTheory/Group/AddCircle.lean index a48b34277aca2..38e54d654f75e 100644 --- a/Mathlib/MeasureTheory/Group/AddCircle.lean +++ b/Mathlib/MeasureTheory/Group/AddCircle.lean @@ -35,9 +35,9 @@ theorem closedBall_ae_eq_ball {x : AddCircle T} {ε : ℝ} : closedBall x ε = · rw [ball_eq_empty.mpr hε, ae_eq_empty, volume_closedBall, min_eq_right (by linarith [hT.out] : 2 * ε ≤ T), ENNReal.ofReal_eq_zero] exact mul_nonpos_of_nonneg_of_nonpos zero_le_two hε - · suffices volume (closedBall x ε) ≤ volume (ball x ε) by - exact (ae_eq_of_subset_of_measure_ge ball_subset_closedBall this measurableSet_ball - (measure_ne_top _ _)).symm + · suffices volume (closedBall x ε) ≤ volume (ball x ε) from + (ae_eq_of_subset_of_measure_ge ball_subset_closedBall this + measurableSet_ball.nullMeasurableSet (measure_ne_top _ _)).symm have : Tendsto (fun δ => volume (closedBall x δ)) (𝓝[<] ε) (𝓝 <| volume (closedBall x ε)) := by simp_rw [volume_closedBall] refine ENNReal.tendsto_ofReal (Tendsto.min tendsto_const_nhds <| Tendsto.const_mul _ ?_) diff --git a/Mathlib/MeasureTheory/Group/Arithmetic.lean b/Mathlib/MeasureTheory/Group/Arithmetic.lean index d58f14fb0b7a4..1893764f613b0 100644 --- a/Mathlib/MeasureTheory/Group/Arithmetic.lean +++ b/Mathlib/MeasureTheory/Group/Arithmetic.lean @@ -836,23 +836,23 @@ variable [MeasurableSpace α] [Mul α] [Div α] [Inv α] @[to_additive] -- See note [lower instance priority] instance (priority := 100) DiscreteMeasurableSpace.toMeasurableMul [DiscreteMeasurableSpace α] : MeasurableMul α where - measurable_const_mul _ := measurable_discrete _ - measurable_mul_const _ := measurable_discrete _ + measurable_const_mul _ := .of_discrete + measurable_mul_const _ := .of_discrete @[to_additive DiscreteMeasurableSpace.toMeasurableAdd₂] -- See note [lower instance priority] instance (priority := 100) DiscreteMeasurableSpace.toMeasurableMul₂ - [DiscreteMeasurableSpace (α × α)] : MeasurableMul₂ α := ⟨measurable_discrete _⟩ + [DiscreteMeasurableSpace (α × α)] : MeasurableMul₂ α := ⟨.of_discrete⟩ @[to_additive] -- See note [lower instance priority] instance (priority := 100) DiscreteMeasurableSpace.toMeasurableInv [DiscreteMeasurableSpace α] : - MeasurableInv α := ⟨measurable_discrete _⟩ + MeasurableInv α := ⟨.of_discrete⟩ @[to_additive] -- See note [lower instance priority] instance (priority := 100) DiscreteMeasurableSpace.toMeasurableDiv [DiscreteMeasurableSpace α] : MeasurableDiv α where - measurable_const_div _ := measurable_discrete _ - measurable_div_const _ := measurable_discrete _ + measurable_const_div _ := .of_discrete + measurable_div_const _ := .of_discrete @[to_additive DiscreteMeasurableSpace.toMeasurableSub₂] -- See note [lower instance priority] instance (priority := 100) DiscreteMeasurableSpace.toMeasurableDiv₂ - [DiscreteMeasurableSpace (α × α)] : MeasurableDiv₂ α := ⟨measurable_discrete _⟩ + [DiscreteMeasurableSpace (α × α)] : MeasurableDiv₂ α := ⟨.of_discrete⟩ diff --git a/Mathlib/MeasureTheory/Group/GeometryOfNumbers.lean b/Mathlib/MeasureTheory/Group/GeometryOfNumbers.lean index 9fd4d3c6d24d8..fb1be755747f1 100644 --- a/Mathlib/MeasureTheory/Group/GeometryOfNumbers.lean +++ b/Mathlib/MeasureTheory/Group/GeometryOfNumbers.lean @@ -57,7 +57,7 @@ theorem exists_pair_mem_lattice_not_disjoint_vadd [AddCommGroup L] [Countable L] /-- The **Minkowski Convex Body Theorem**. If `s` is a convex symmetric domain of `E` whose volume is large enough compared to the covolume of a lattice `L` of `E`, then it contains a non-zero -lattice point of `L`. -/ +lattice point of `L`. -/ theorem exists_ne_zero_mem_lattice_of_measure_mul_two_pow_lt_measure [NormedAddCommGroup E] [NormedSpace ℝ E] [BorelSpace E] [FiniteDimensional ℝ E] [IsAddHaarMeasure μ] {L : AddSubgroup E} [Countable L] (fund : IsAddFundamentalDomain L F μ) diff --git a/Mathlib/MeasureTheory/Group/Measure.lean b/Mathlib/MeasureTheory/Group/Measure.lean index ea0b382479f51..e02950b66d90f 100644 --- a/Mathlib/MeasureTheory/Group/Measure.lean +++ b/Mathlib/MeasureTheory/Group/Measure.lean @@ -470,7 +470,7 @@ lemma eventually_nhds_one_measure_smul_diff_lt [LocallyCompactSpace G] μ (g • k \ k) ≤ μ (U \ k) := by gcongr exact (smul_set_subset_smul hg).trans hVkU - _ < ε := measure_diff_lt_of_lt_add h'k.measurableSet hUk hk.measure_lt_top.ne hμUk + _ < ε := measure_diff_lt_of_lt_add h'k.nullMeasurableSet hUk hk.measure_lt_top.ne hμUk /-- Continuity of the measure of translates of a compact set: Given a closed compact set `k` in a topological group, @@ -728,14 +728,15 @@ a Haar measure. See also `MulEquiv.isHaarMeasure_map`. -/ "The image of an additive Haar measure under a continuous surjective proper additive group homomorphism is again an additive Haar measure. See also `AddEquiv.isAddHaarMeasure_map`."] theorem isHaarMeasure_map [BorelSpace G] [TopologicalGroup G] {H : Type*} [Group H] - [TopologicalSpace H] [MeasurableSpace H] [BorelSpace H] [T2Space H] [TopologicalGroup H] + [TopologicalSpace H] [MeasurableSpace H] [BorelSpace H] [TopologicalGroup H] (f : G →* H) (hf : Continuous f) (h_surj : Surjective f) (h_prop : Tendsto f (cocompact G) (cocompact H)) : IsHaarMeasure (Measure.map f μ) := { toIsMulLeftInvariant := isMulLeftInvariant_map f.toMulHom hf.measurable h_surj lt_top_of_isCompact := by intro K hK - rw [map_apply hf.measurable hK.measurableSet] - exact IsCompact.measure_lt_top ((⟨⟨f, hf⟩, h_prop⟩ : CocompactMap G H).isCompact_preimage hK) + rw [← hK.measure_closure, map_apply hf.measurable isClosed_closure.measurableSet] + set g : CocompactMap G H := ⟨⟨f, hf⟩, h_prop⟩ + exact IsCompact.measure_lt_top (g.isCompact_preimage_of_isClosed hK.closure isClosed_closure) toIsOpenPosMeasure := hf.isOpenPosMeasure_map h_surj } /-- The image of a finite Haar measure under a continuous surjective group homomorphism is again @@ -747,10 +748,9 @@ theorem isHaarMeasure_map_of_isFiniteMeasure [BorelSpace G] [TopologicalGroup G] {H : Type*} [Group H] [TopologicalSpace H] [MeasurableSpace H] [BorelSpace H] [TopologicalGroup H] [IsFiniteMeasure μ] (f : G →* H) (hf : Continuous f) (h_surj : Surjective f) : - IsHaarMeasure (Measure.map f μ) := - { toIsMulLeftInvariant := isMulLeftInvariant_map f.toMulHom hf.measurable h_surj - lt_top_of_isCompact := fun _K hK ↦ hK.measure_lt_top - toIsOpenPosMeasure := hf.isOpenPosMeasure_map h_surj } + IsHaarMeasure (Measure.map f μ) where + toIsMulLeftInvariant := isMulLeftInvariant_map f.toMulHom hf.measurable h_surj + toIsOpenPosMeasure := hf.isOpenPosMeasure_map h_surj /-- The image of a Haar measure under map of a left action is again a Haar measure. -/ @[to_additive @@ -780,20 +780,11 @@ nonrec theorem _root_.MulEquiv.isHaarMeasure_map [BorelSpace G] [TopologicalGrou [Group H] [TopologicalSpace H] [MeasurableSpace H] [BorelSpace H] [TopologicalGroup H] (e : G ≃* H) (he : Continuous e) (hesymm : Continuous e.symm) : IsHaarMeasure (Measure.map e μ) := - { toIsMulLeftInvariant := isMulLeftInvariant_map e.toMulHom he.measurable e.surjective - lt_top_of_isCompact := by - intro K hK - let F : G ≃ₜ H := { - e.toEquiv with - continuous_toFun := he - continuous_invFun := hesymm } - change map F.toMeasurableEquiv μ K < ∞ - rw [F.toMeasurableEquiv.map_apply K] - exact (F.isCompact_preimage.mpr hK).measure_lt_top - toIsOpenPosMeasure := he.isOpenPosMeasure_map e.surjective } + let f : G ≃ₜ H := .mk e + isHaarMeasure_map μ e he e.surjective f.closedEmbedding.tendsto_cocompact /-- A convenience wrapper for MeasureTheory.Measure.isAddHaarMeasure_map`. -/ -theorem _root_.ContinuousLinearEquiv.isAddHaarMeasure_map +instance _root_.ContinuousLinearEquiv.isAddHaarMeasure_map {E F R S : Type*} [Semiring R] [Semiring S] [AddCommGroup E] [Module R E] [AddCommGroup F] [Module S F] [TopologicalSpace E] [TopologicalAddGroup E] [TopologicalSpace F] diff --git a/Mathlib/MeasureTheory/Integral/Bochner.lean b/Mathlib/MeasureTheory/Integral/Bochner.lean index 7006ddbd18072..70ce71d146cf2 100644 --- a/Mathlib/MeasureTheory/Integral/Bochner.lean +++ b/Mathlib/MeasureTheory/Integral/Bochner.lean @@ -433,7 +433,7 @@ theorem norm_eq_integral (f : α →₁ₛ[μ] E) : ‖f‖ = ((toSimpleFunc f). section PosPart -/-- Positive part of a simple function in L1 space. -/ +/-- Positive part of a simple function in L1 space. -/ nonrec def posPart (f : α →₁ₛ[μ] ℝ) : α →₁ₛ[μ] ℝ := ⟨Lp.posPart (f : α →₁[μ] ℝ), by rcases f with ⟨f, s, hsf⟩ @@ -1000,7 +1000,7 @@ theorem continuous_of_dominated {F : X → α → G} {bound : α → ℝ} · simp [integral, hG, continuous_const] /-- The Bochner integral of a real-valued function `f : α → ℝ` is the difference between the - integral of the positive part of `f` and the integral of the negative part of `f`. -/ + integral of the positive part of `f` and the integral of the negative part of `f`. -/ theorem integral_eq_lintegral_pos_part_sub_lintegral_neg_part {f : α → ℝ} (hf : Integrable f μ) : ∫ a, f a ∂μ = ENNReal.toReal (∫⁻ a, .ofReal (f a) ∂μ) - ENNReal.toReal (∫⁻ a, .ofReal (-f a) ∂μ) := by @@ -1962,3 +1962,5 @@ def evalIntegral : PositivityExt where eval {u α} zα pα e := do | _ => throwError "not MeasureTheory.integral" end Mathlib.Meta.Positivity + +set_option linter.style.longFile 2100 diff --git a/Mathlib/MeasureTheory/Integral/DominatedConvergence.lean b/Mathlib/MeasureTheory/Integral/DominatedConvergence.lean index 0aa5977e8f9e6..7dc0c8c165627 100644 --- a/Mathlib/MeasureTheory/Integral/DominatedConvergence.lean +++ b/Mathlib/MeasureTheory/Integral/DominatedConvergence.lean @@ -255,8 +255,8 @@ variable {X : Type*} [TopologicalSpace X] [FirstCountableTopology X] /-- Continuity of interval integral with respect to a parameter, at a point within a set. Given `F : X → ℝ → E`, assume `F x` is ae-measurable on `[a, b]` for `x` in a - neighborhood of `x₀` within `s` and at `x₀`, and assume it is bounded by a function integrable - on `[a, b]` independent of `x` in a neighborhood of `x₀` within `s`. If `(fun x ↦ F x t)` + neighborhood of `x₀` within `s` and at `x₀`, and assume it is bounded by a function integrable + on `[a, b]` independent of `x` in a neighborhood of `x₀` within `s`. If `(fun x ↦ F x t)` is continuous at `x₀` within `s` for almost every `t` in `[a, b]` then the same holds for `(fun x ↦ ∫ t in a..b, F x t ∂μ) s x₀`. -/ theorem continuousWithinAt_of_dominated_interval {F : X → ℝ → E} {x₀ : X} {bound : ℝ → ℝ} {a b : ℝ} diff --git a/Mathlib/MeasureTheory/Integral/FundThmCalculus.lean b/Mathlib/MeasureTheory/Integral/FundThmCalculus.lean index 0ab09a7e17c02..d84c9db973bd2 100644 --- a/Mathlib/MeasureTheory/Integral/FundThmCalculus.lean +++ b/Mathlib/MeasureTheory/Integral/FundThmCalculus.lean @@ -1559,3 +1559,5 @@ theorem integral_deriv_comp_mul_deriv {f f' g g' : ℝ → ℝ} end Mul end intervalIntegral + +set_option linter.style.longFile 1700 diff --git a/Mathlib/MeasureTheory/Integral/IntegralEqImproper.lean b/Mathlib/MeasureTheory/Integral/IntegralEqImproper.lean index 4b9143054ef0c..902812d6d999d 100644 --- a/Mathlib/MeasureTheory/Integral/IntegralEqImproper.lean +++ b/Mathlib/MeasureTheory/Integral/IntegralEqImproper.lean @@ -1241,7 +1241,7 @@ theorem integral_mul_deriv_eq_deriv_mul [CompleteSpace A] (huv' : Integrable (u * v')) (hu'v : Integrable (u' * v)) (h_bot : Tendsto (u * v) atBot (𝓝 a')) (h_top : Tendsto (u * v) atTop (𝓝 b')) : ∫ (x : ℝ), u x * v' x = b' - a' - ∫ (x : ℝ), u' x * v x := - integral_bilinear_hasDerivAt_right_eq_sub (L := ContinuousLinearMap.mul ℝ A) + integral_bilinear_hasDerivAt_right_eq_sub (L := ContinuousLinearMap.mul ℝ A) hu hv huv' hu'v h_bot h_top /-- **Integration by parts on (-∞, ∞).** diff --git a/Mathlib/MeasureTheory/Integral/Lebesgue.lean b/Mathlib/MeasureTheory/Integral/Lebesgue.lean index abdfc4b04faa4..f6bd8137dbe0b 100644 --- a/Mathlib/MeasureTheory/Integral/Lebesgue.lean +++ b/Mathlib/MeasureTheory/Integral/Lebesgue.lean @@ -935,7 +935,7 @@ theorem setLintegral_pos_iff {f : α → ℝ≥0∞} (hf : Measurable f) {s : Se 0 < ∫⁻ a in s, f a ∂μ ↔ 0 < μ (Function.support f ∩ s) := by rw [lintegral_pos_iff_support hf, Measure.restrict_apply (measurableSet_support hf)] -/-- Weaker version of the monotone convergence theorem-/ +/-- Weaker version of the monotone convergence theorem -/ theorem lintegral_iSup_ae {f : ℕ → α → ℝ≥0∞} (hf : ∀ n, Measurable (f n)) (h_mono : ∀ n, ∀ᵐ a ∂μ, f n a ≤ f n.succ a) : ∫⁻ a, ⨆ n, f n a ∂μ = ⨆ n, ∫⁻ a, f n a ∂μ := by classical @@ -2059,3 +2059,5 @@ lemma tendsto_measure_of_ae_tendsto_indicator_of_isFiniteMeasure end TendstoIndicator -- section end MeasureTheory + +set_option linter.style.longFile 2200 diff --git a/Mathlib/MeasureTheory/Integral/SetIntegral.lean b/Mathlib/MeasureTheory/Integral/SetIntegral.lean index 5bf45198cc55b..f7e029875e697 100644 --- a/Mathlib/MeasureTheory/Integral/SetIntegral.lean +++ b/Mathlib/MeasureTheory/Integral/SetIntegral.lean @@ -233,7 +233,7 @@ theorem tendsto_setIntegral_of_monotone {ι : Type*} [Countable ι] [Semilattice rw [mem_closedBall_iff_norm', ← integral_diff (hsm i) hfi hsub, ← coe_nnnorm, NNReal.coe_le_coe, ← ENNReal.coe_le_coe] refine (ennnorm_integral_le_lintegral_ennnorm _).trans ?_ - rw [← withDensity_apply _ (hSm.diff (hsm _)), ← hν, measure_diff hsub (hsm _)] + rw [← withDensity_apply _ (hSm.diff (hsm _)), ← hν, measure_diff hsub (hsm _).nullMeasurableSet] exacts [tsub_le_iff_tsub_le.mp hi.1, (hi.2.trans_lt <| ENNReal.add_lt_top.2 ⟨hfi', ENNReal.coe_lt_top⟩).ne] @@ -255,14 +255,15 @@ theorem tendsto_setIntegral_of_antitone {ι : Type*} [Countable ι] [Semilattice simpa [hsm i₀, ν, ENNReal.ofReal, norm_toNNReal] using hi₀.norm.lintegral_lt_top.ne have νS : ν S ≠ ∞ := ((measure_mono (hsub i₀)).trans_lt νi₀.lt_top).ne have : ∀ᶠ i in atTop, ν (s i) ∈ Icc (ν S - ε) (ν S + ε) := by - apply tendsto_measure_iInter hsm h_anti ⟨i₀, νi₀⟩ + apply tendsto_measure_iInter (fun i ↦ (hsm i).nullMeasurableSet) h_anti ⟨i₀, νi₀⟩ apply ENNReal.Icc_mem_nhds νS (ENNReal.coe_pos.2 ε0).ne' filter_upwards [this, Ici_mem_atTop i₀] with i hi h'i rw [mem_closedBall_iff_norm, ← integral_diff hSm (hi₀.mono_set (h_anti h'i)) (hsub i), ← coe_nnnorm, NNReal.coe_le_coe, ← ENNReal.coe_le_coe] refine (ennnorm_integral_le_lintegral_ennnorm _).trans ?_ - rw [← withDensity_apply _ ((hsm _).diff hSm), ← hν, measure_diff (hsub i) hSm νS] - exact tsub_le_iff_left.2 hi.2 + rw [← withDensity_apply _ ((hsm _).diff hSm), ← hν, + measure_diff_le_iff_le_add hSm.nullMeasurableSet (hsub i) νS] + exact hi.2 @[deprecated (since := "2024-04-17")] alias tendsto_set_integral_of_antitone := tendsto_setIntegral_of_antitone @@ -1615,3 +1616,5 @@ lemma continuousOn_integral_of_compact_support hk hf hfs (integrableOn_const.2 (Or.inr hk.measure_lt_top)) (μ := μ) (g := fun _ ↦ 1) end ParametricIntegral + +set_option linter.style.longFile 1700 diff --git a/Mathlib/MeasureTheory/Integral/SetToL1.lean b/Mathlib/MeasureTheory/Integral/SetToL1.lean index 218126470c835..02f0849ff37db 100644 --- a/Mathlib/MeasureTheory/Integral/SetToL1.lean +++ b/Mathlib/MeasureTheory/Integral/SetToL1.lean @@ -1645,3 +1645,5 @@ theorem continuous_setToFun_of_dominated (hT : DominatedFinMeasAdditive μ T C) end Function end MeasureTheory + +set_option linter.style.longFile 1800 diff --git a/Mathlib/MeasureTheory/MeasurableSpace/Basic.lean b/Mathlib/MeasureTheory/MeasurableSpace/Basic.lean index 72f27d9b68033..f2827cef05cdd 100644 --- a/Mathlib/MeasureTheory/MeasurableSpace/Basic.lean +++ b/Mathlib/MeasureTheory/MeasurableSpace/Basic.lean @@ -1081,7 +1081,7 @@ lemma measurable_set_mem (a : α) : Measurable fun s : Set α ↦ a ∈ s := mea @[aesop safe 100 apply (rule_sets := [Measurable])] lemma measurable_set_not_mem (a : α) : Measurable fun s : Set α ↦ a ∉ s := - (measurable_discrete Not).comp <| measurable_set_mem a + (Measurable.of_discrete (f := Not)).comp <| measurable_set_mem a @[aesop safe 100 apply (rule_sets := [Measurable])] lemma measurableSet_mem (a : α) : MeasurableSet {s : Set α | a ∈ s} := @@ -1094,6 +1094,20 @@ lemma measurableSet_not_mem (a : α) : MeasurableSet {s : Set α | a ∉ s} := lemma measurable_compl : Measurable ((·ᶜ) : Set α → Set α) := measurable_set_iff.2 fun _ ↦ measurable_set_not_mem _ +lemma MeasurableSet.setOf_finite [Countable α] : MeasurableSet {s : Set α | s.Finite} := + Countable.setOf_finite.measurableSet + +lemma MeasurableSet.setOf_infinite [Countable α] : MeasurableSet {s : Set α | s.Infinite} := + .setOf_finite |> .compl + +lemma MeasurableSet.sep_finite [Countable α] {S : Set (Set α)} (hS : MeasurableSet S) : + MeasurableSet {s ∈ S | s.Finite} := + hS.inter .setOf_finite + +lemma MeasurableSet.sep_infinite [Countable α] {S : Set (Set α)} (hS : MeasurableSet S) : + MeasurableSet {s ∈ S | s.Infinite} := + hS.inter .setOf_infinite + end Set end Constructions diff --git a/Mathlib/MeasureTheory/MeasurableSpace/Defs.lean b/Mathlib/MeasureTheory/MeasurableSpace/Defs.lean index 24be3674a76da..47735c0e490cf 100644 --- a/Mathlib/MeasureTheory/MeasurableSpace/Defs.lean +++ b/Mathlib/MeasureTheory/MeasurableSpace/Defs.lean @@ -517,7 +517,7 @@ end MeasurableFunctions /-- A typeclass mixin for `MeasurableSpace`s such that all sets are measurable. -/ class DiscreteMeasurableSpace (α : Type*) [MeasurableSpace α] : Prop where - /-- Do not use this. Use `measurableSet_discrete` instead. -/ + /-- Do not use this. Use `MeasurableSet.of_discrete` instead. -/ forall_measurableSet : ∀ s : Set α, MeasurableSet s instance : @DiscreteMeasurableSpace α ⊤ := @@ -529,19 +529,24 @@ instance (priority := 100) MeasurableSingletonClass.toDiscreteMeasurableSpace [M forall_measurableSet _ := (Set.to_countable _).measurableSet section DiscreteMeasurableSpace -variable [MeasurableSpace α] [MeasurableSpace β] [DiscreteMeasurableSpace α] +variable [MeasurableSpace α] [MeasurableSpace β] [DiscreteMeasurableSpace α] {s : Set α} {f : α → β} -@[measurability] lemma measurableSet_discrete (s : Set α) : MeasurableSet s := +@[measurability] lemma MeasurableSet.of_discrete : MeasurableSet s := DiscreteMeasurableSpace.forall_measurableSet _ -@[measurability] -lemma measurable_discrete (f : α → β) : Measurable f := fun _ _ ↦ measurableSet_discrete _ +@[measurability] lemma Measurable.of_discrete : Measurable f := fun _ _ ↦ .of_discrete + +@[deprecated MeasurableSet.of_discrete (since := "2024-08-25")] +lemma measurableSet_discrete (s : Set α) : MeasurableSet s := .of_discrete + +@[deprecated MeasurableSet.of_discrete (since := "2024-08-25")] +lemma measurable_discrete (f : α → β) : Measurable f := .of_discrete /-- Warning: Creates a typeclass loop with `MeasurableSingletonClass.toDiscreteMeasurableSpace`. To be monitored. -/ -- See note [lower instance priority] instance (priority := 100) DiscreteMeasurableSpace.toMeasurableSingletonClass : MeasurableSingletonClass α where - measurableSet_singleton _ := measurableSet_discrete _ + measurableSet_singleton _ := .of_discrete end DiscreteMeasurableSpace diff --git a/Mathlib/MeasureTheory/Measure/Complex.lean b/Mathlib/MeasureTheory/Measure/Complex.lean index ccb2008885c00..decf1c54caa15 100644 --- a/Mathlib/MeasureTheory/Measure/Complex.lean +++ b/Mathlib/MeasureTheory/Measure/Complex.lean @@ -54,7 +54,7 @@ def re : ComplexMeasure α →ₗ[ℝ] SignedMeasure α := def im : ComplexMeasure α →ₗ[ℝ] SignedMeasure α := mapRangeₗ Complex.imCLM Complex.continuous_im -/-- Given `s` and `t` signed measures, `s + it` is a complex measure-/ +/-- Given `s` and `t` signed measures, `s + it` is a complex measure -/ @[simps!] def _root_.MeasureTheory.SignedMeasure.toComplexMeasure (s t : SignedMeasure α) : ComplexMeasure α where diff --git a/Mathlib/MeasureTheory/Measure/ContinuousPreimage.lean b/Mathlib/MeasureTheory/Measure/ContinuousPreimage.lean index ca19e7aa85cca..b98c2b2b39069 100644 --- a/Mathlib/MeasureTheory/Measure/ContinuousPreimage.lean +++ b/Mathlib/MeasureTheory/Measure/ContinuousPreimage.lean @@ -79,7 +79,7 @@ theorem tendsto_measure_symmDiff_preimage_nhds_zero obtain ⟨K, hKg, hKco, hKcl, hKμ⟩ : ∃ K, MapsTo g K s ∧ IsCompact K ∧ IsClosed K ∧ μ (g ⁻¹' s \ K) < ε / 2 := (hg.measurable hso.measurableSet).exists_isCompact_isClosed_diff_lt hνs' <| by simp [hε.ne'] - have hKm : MeasurableSet K := hKcl.measurableSet + have hKm : NullMeasurableSet K μ := hKcl.nullMeasurableSet -- Take `a` such that `f a` is measure preserving and maps `K` to `s`. -- This is possible, because `K` is a compact set and `s` is an open set. filter_upwards [hf, ContinuousMap.tendsto_nhds_compactOpen.mp hfg K hKco s hso hKg] with a hfa ha diff --git a/Mathlib/MeasureTheory/Measure/FiniteMeasureProd.lean b/Mathlib/MeasureTheory/Measure/FiniteMeasureProd.lean index 5ec34e572fd68..97ffeece7c11c 100644 --- a/Mathlib/MeasureTheory/Measure/FiniteMeasureProd.lean +++ b/Mathlib/MeasureTheory/Measure/FiniteMeasureProd.lean @@ -71,7 +71,7 @@ lemma prod_prod (s : Set α) (t : Set β) : μ.prod ν (s ×ˢ t) = μ s * ν t @[simp] lemma map_snd_prod : (μ.prod ν).map Prod.snd = μ univ • ν := by ext; simp lemma map_prod_map {α' : Type*} [MeasurableSpace α'] {β' : Type*} [MeasurableSpace β'] - {f : α → α'} {g : β → β'} (f_mble : Measurable f) (g_mble : Measurable g) : + {f : α → α'} {g : β → β'} (f_mble : Measurable f) (g_mble : Measurable g) : (μ.map f).prod (ν.map g) = (μ.prod ν).map (Prod.map f g) := by apply Subtype.ext simp only [val_eq_toMeasure, toMeasure_prod, toMeasure_map] diff --git a/Mathlib/MeasureTheory/Measure/Haar/NormedSpace.lean b/Mathlib/MeasureTheory/Measure/Haar/NormedSpace.lean index 23979e07b5cf8..29af339ad2552 100644 --- a/Mathlib/MeasureTheory/Measure/Haar/NormedSpace.lean +++ b/Mathlib/MeasureTheory/Measure/Haar/NormedSpace.lean @@ -30,23 +30,19 @@ example {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [Nontrivial E] [F [MeasurableSpace E] [BorelSpace E] (μ : Measure E) [IsAddHaarMeasure μ] : NoAtoms μ := by infer_instance -section ContinuousLinearEquiv +section LinearEquiv variable {𝕜 G H : Type*} [MeasurableSpace G] [MeasurableSpace H] [NontriviallyNormedField 𝕜] [TopologicalSpace G] [TopologicalSpace H] [AddCommGroup G] [AddCommGroup H] [TopologicalAddGroup G] [TopologicalAddGroup H] [Module 𝕜 G] [Module 𝕜 H] (μ : Measure G) - [IsAddHaarMeasure μ] [BorelSpace G] [BorelSpace H] [T2Space H] - -instance MapContinuousLinearEquiv.isAddHaarMeasure (e : G ≃L[𝕜] H) : IsAddHaarMeasure (μ.map e) := - e.toAddEquiv.isAddHaarMeasure_map _ e.continuous e.symm.continuous - -variable [CompleteSpace 𝕜] [T2Space G] [FiniteDimensional 𝕜 G] [ContinuousSMul 𝕜 G] - [ContinuousSMul 𝕜 H] + [IsAddHaarMeasure μ] [BorelSpace G] [BorelSpace H] + [CompleteSpace 𝕜] [T2Space G] [FiniteDimensional 𝕜 G] [ContinuousSMul 𝕜 G] + [ContinuousSMul 𝕜 H] [T2Space H] instance MapLinearEquiv.isAddHaarMeasure (e : G ≃ₗ[𝕜] H) : IsAddHaarMeasure (μ.map e) := - MapContinuousLinearEquiv.isAddHaarMeasure _ e.toContinuousLinearEquiv + e.toContinuousLinearEquiv.isAddHaarMeasure_map _ -end ContinuousLinearEquiv +end LinearEquiv variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [MeasurableSpace E] [BorelSpace E] [FiniteDimensional ℝ E] (μ : Measure E) [IsAddHaarMeasure μ] {F : Type*} [NormedAddCommGroup F] diff --git a/Mathlib/MeasureTheory/Measure/Haar/Unique.lean b/Mathlib/MeasureTheory/Measure/Haar/Unique.lean index e2880770c5856..0b75436b65433 100644 --- a/Mathlib/MeasureTheory/Measure/Haar/Unique.lean +++ b/Mathlib/MeasureTheory/Measure/Haar/Unique.lean @@ -573,7 +573,8 @@ lemma measure_isMulInvariant_eq_smul_of_isCompact_closure_of_innerRegularCompact exact t_comp.closure_of_subset diff_subset have B : μ' t = ν t := measure_preimage_isMulLeftInvariant_eq_smul_of_hasCompactSupport _ _ f_cont f_comp - rwa [measure_diff st hs, measure_diff st hs, ← B, ENNReal.sub_le_sub_iff_left] at A + rwa [measure_diff st hs.nullMeasurableSet, measure_diff st hs.nullMeasurableSet, ← B, + ENNReal.sub_le_sub_iff_left] at A · exact measure_mono st · exact t_comp.measure_lt_top.ne · exact ((measure_mono st).trans_lt t_comp.measure_lt_top).ne @@ -908,6 +909,32 @@ theorem absolutelyContinuous_isHaarMeasure [LocallyCompactSpace G] rw [haarMeasure_unique μ K, h, smul_smul] exact AbsolutelyContinuous.smul (Eq.absolutelyContinuous rfl) _ +/-- A continuous surjective monoid homomorphism of topological groups with compact codomain +is measure preserving, provided that the Haar measures on the domain and on the codomain +have the same total mass. +-/ +@[to_additive + "A continuous surjective additive monoid homomorphism of topological groups with compact codomain +is measure preserving, provided that the Haar measures on the domain and on the codomain +have the same total mass."] +theorem _root_.MonoidHom.measurePreserving + {H : Type*} [Group H] [TopologicalSpace H] [TopologicalGroup H] [CompactSpace H] + [MeasurableSpace H] [BorelSpace H] + {μ : Measure G} [IsHaarMeasure μ] {ν : Measure H} [IsHaarMeasure ν] + {f : G →* H} (hcont : Continuous f) (hsurj : Surjective f) (huniv : μ univ = ν univ) : + MeasurePreserving f μ ν where + measurable := hcont.measurable + map_eq := by + have : IsFiniteMeasure μ := ⟨by rw [huniv]; apply measure_lt_top⟩ + have : (μ.map f).IsHaarMeasure := isHaarMeasure_map_of_isFiniteMeasure μ f hcont hsurj + set C : ℝ≥0 := haarScalarFactor (μ.map f) ν + have hC : μ.map f = C • ν := isMulLeftInvariant_eq_smul_of_innerRegular _ _ + suffices C = 1 by rwa [this, one_smul] at hC + have : C * ν univ = 1 * ν univ := by + rw [one_mul, ← smul_eq_mul, ← ENNReal.smul_def, ← smul_apply, ← hC, + map_apply hcont.measurable .univ, preimage_univ, huniv] + rwa [ENNReal.mul_eq_mul_right (NeZero.ne _) (measure_ne_top _ _), ENNReal.coe_eq_one] at this + end Group section CommGroup @@ -968,22 +995,8 @@ instance (priority := 100) IsHaarMeasure.isInvInvariant_of_innerRegular @[to_additive] theorem measurePreserving_zpow [CompactSpace G] [RootableBy G ℤ] {n : ℤ} (hn : n ≠ 0) : MeasurePreserving (fun g : G => g ^ n) μ μ := - { measurable := (continuous_zpow n).measurable - map_eq := by - let f := @zpowGroupHom G _ n - have hf : Continuous f := continuous_zpow n - have : (μ.map f).IsHaarMeasure := - isHaarMeasure_map_of_isFiniteMeasure μ f hf (RootableBy.surjective_pow G ℤ hn) - let C : ℝ≥0∞ := haarScalarFactor (μ.map f) μ - have hC : μ.map f = C • μ := isMulLeftInvariant_eq_smul_of_innerRegular _ _ - suffices C = 1 by rwa [this, one_smul] at hC - have h_univ : (μ.map f) univ = μ univ := by - rw [map_apply_of_aemeasurable hf.measurable.aemeasurable MeasurableSet.univ, - preimage_univ] - have hμ₀ : μ univ ≠ 0 := IsOpenPosMeasure.open_pos univ isOpen_univ univ_nonempty - have hμ₁ : μ univ ≠ ∞ := CompactSpace.isFiniteMeasure.measure_univ_lt_top.ne - rwa [hC, smul_apply, Algebra.id.smul_eq_mul, mul_comm, ← ENNReal.eq_div_iff hμ₀ hμ₁, - ENNReal.div_self hμ₀ hμ₁] at h_univ } + (zpowGroupHom n).measurePreserving (continuous_zpow n) + (RootableBy.surjective_pow G ℤ hn) rfl @[to_additive] theorem MeasurePreserving.zpow [CompactSpace G] [RootableBy G ℤ] diff --git a/Mathlib/MeasureTheory/Measure/Lebesgue/EqHaar.lean b/Mathlib/MeasureTheory/Measure/Lebesgue/EqHaar.lean index 7411012c4e1c6..fb8dff12af177 100644 --- a/Mathlib/MeasureTheory/Measure/Lebesgue/EqHaar.lean +++ b/Mathlib/MeasureTheory/Measure/Lebesgue/EqHaar.lean @@ -492,7 +492,8 @@ theorem addHaar_sphere_of_ne_zero (x : E) {r : ℝ} (hr : r ≠ 0) : μ (sphere rcases hr.lt_or_lt with (h | h) · simp only [empty_diff, measure_empty, ← closedBall_diff_ball, closedBall_eq_empty.2 h] · rw [← closedBall_diff_ball, - measure_diff ball_subset_closedBall measurableSet_ball measure_ball_lt_top.ne, + measure_diff ball_subset_closedBall measurableSet_ball.nullMeasurableSet + measure_ball_lt_top.ne, addHaar_ball_of_pos μ _ h, addHaar_closedBall μ _ h.le, tsub_self] theorem addHaar_sphere [Nontrivial E] (x : E) (r : ℝ) : μ (sphere x r) = 0 := by @@ -696,7 +697,8 @@ theorem tendsto_addHaar_inter_smul_zero_of_density_zero (s : Set E) (x : E) (𝓝 (μ (⋂ n : ℕ, t \ closedBall 0 n))) := by have N : ∃ n : ℕ, μ (t \ closedBall 0 n) ≠ ∞ := ⟨0, ((measure_mono diff_subset).trans_lt h''t.lt_top).ne⟩ - refine tendsto_measure_iInter (fun n ↦ ht.diff measurableSet_closedBall) (fun m n hmn ↦ ?_) N + refine tendsto_measure_iInter (fun n ↦ (ht.diff measurableSet_closedBall).nullMeasurableSet) + (fun m n hmn ↦ ?_) N exact diff_subset_diff Subset.rfl (closedBall_subset_closedBall (Nat.cast_le.2 hmn)) have : ⋂ n : ℕ, t \ closedBall 0 n = ∅ := by simp_rw [diff_eq, ← inter_iInter, iInter_eq_compl_iUnion_compl, compl_compl, diff --git a/Mathlib/MeasureTheory/Measure/LevyProkhorovMetric.lean b/Mathlib/MeasureTheory/Measure/LevyProkhorovMetric.lean index a2b8a9ec9bdc4..5b7eb39f8469e 100644 --- a/Mathlib/MeasureTheory/Measure/LevyProkhorovMetric.lean +++ b/Mathlib/MeasureTheory/Measure/LevyProkhorovMetric.lean @@ -533,7 +533,7 @@ lemma ProbabilityMeasure.continuous_toLevyProkhorov [SeparableSpace Ω] : -- `P (⋃ n < N, Es n)ᶜ < ε/3`. obtain ⟨N, hN⟩ : ∃ N, P.toMeasure (⋃ j ∈ Iio N, Es j)ᶜ < ENNReal.ofReal (ε/3) := by have exhaust := @tendsto_measure_biUnion_Ici_zero_of_pairwise_disjoint Ω _ P.toMeasure _ - Es Es_mble Es_disjoint + Es (fun n ↦ (Es_mble n).nullMeasurableSet) Es_disjoint simp only [tendsto_atTop_nhds, Function.comp_apply] at exhaust obtain ⟨N, hN⟩ := exhaust (Iio (ENNReal.ofReal (ε / 3))) third_ε_pos' isOpen_Iio refine ⟨N, ?_⟩ diff --git a/Mathlib/MeasureTheory/Measure/MeasureSpace.lean b/Mathlib/MeasureTheory/Measure/MeasureSpace.lean index 88bbbe61b968b..414e6fefa1843 100644 --- a/Mathlib/MeasureTheory/Measure/MeasureSpace.lean +++ b/Mathlib/MeasureTheory/Measure/MeasureSpace.lean @@ -126,9 +126,10 @@ theorem measure_union_add_inter' (hs : MeasurableSet s) (t : Set α) : μ (s ∪ t) + μ (s ∩ t) = μ s + μ t := by rw [union_comm, inter_comm, measure_union_add_inter t hs, add_comm] -lemma measure_symmDiff_eq (hs : MeasurableSet s) (ht : MeasurableSet t) : +lemma measure_symmDiff_eq (hs : NullMeasurableSet s μ) (ht : NullMeasurableSet t μ) : μ (s ∆ t) = μ (s \ t) + μ (t \ s) := by - simpa only [symmDiff_def, sup_eq_union] using measure_union disjoint_sdiff_sdiff (ht.diff hs) + simpa only [symmDiff_def, sup_eq_union] + using measure_union₀ (ht.diff hs) disjoint_sdiff_sdiff.aedisjoint lemma measure_symmDiff_le (s t u : Set α) : μ (s ∆ u) ≤ μ (s ∆ t) + μ (t ∆ u) := @@ -205,14 +206,15 @@ theorem sum_measure_preimage_singleton (s : Finset β) {f : α → β} theorem measure_diff_null' (h : μ (s₁ ∩ s₂) = 0) : μ (s₁ \ s₂) = μ s₁ := measure_congr <| diff_ae_eq_self.2 h -theorem measure_add_diff (hs : MeasurableSet s) (t : Set α) : μ s + μ (t \ s) = μ (s ∪ t) := by - rw [← measure_union' disjoint_sdiff_right hs, union_diff_self] +theorem measure_add_diff (hs : NullMeasurableSet s μ) (t : Set α) : + μ s + μ (t \ s) = μ (s ∪ t) := by + rw [← measure_union₀' hs disjoint_sdiff_right.aedisjoint, union_diff_self] -theorem measure_diff' (s : Set α) (hm : MeasurableSet t) (h_fin : μ t ≠ ∞) : +theorem measure_diff' (s : Set α) (hm : NullMeasurableSet t μ) (h_fin : μ t ≠ ∞) : μ (s \ t) = μ (s ∪ t) - μ t := Eq.symm <| ENNReal.sub_eq_of_add_eq h_fin <| by rw [add_comm, measure_add_diff hm, union_comm] -theorem measure_diff (h : s₂ ⊆ s₁) (h₂ : MeasurableSet s₂) (h_fin : μ s₂ ≠ ∞) : +theorem measure_diff (h : s₂ ⊆ s₁) (h₂ : NullMeasurableSet s₂ μ) (h_fin : μ s₂ ≠ ∞) : μ (s₁ \ s₂) = μ s₁ - μ s₂ := by rw [measure_diff' _ h₂ h_fin, union_eq_self_of_subset_right h] theorem le_measure_diff : μ s₁ - μ s₂ ≤ μ (s₁ \ s₂) := @@ -238,13 +240,14 @@ then one has finite measure if and only if the other one does. -/ theorem measure_ne_top_iff_of_symmDiff (hμst : μ (s ∆ t) ≠ ∞) : μ s ≠ ∞ ↔ μ t ≠ ∞ := (measure_eq_top_iff_of_symmDiff hμst).ne -theorem measure_diff_lt_of_lt_add (hs : MeasurableSet s) (hst : s ⊆ t) (hs' : μ s ≠ ∞) {ε : ℝ≥0∞} - (h : μ t < μ s + ε) : μ (t \ s) < ε := by +theorem measure_diff_lt_of_lt_add (hs : NullMeasurableSet s μ) (hst : s ⊆ t) (hs' : μ s ≠ ∞) + {ε : ℝ≥0∞} (h : μ t < μ s + ε) : μ (t \ s) < ε := by rw [measure_diff hst hs hs']; rw [add_comm] at h exact ENNReal.sub_lt_of_lt_add (measure_mono hst) h -theorem measure_diff_le_iff_le_add (hs : MeasurableSet s) (hst : s ⊆ t) (hs' : μ s ≠ ∞) {ε : ℝ≥0∞} : - μ (t \ s) ≤ ε ↔ μ t ≤ μ s + ε := by rw [measure_diff hst hs hs', tsub_le_iff_left] +theorem measure_diff_le_iff_le_add (hs : NullMeasurableSet s μ) (hst : s ⊆ t) (hs' : μ s ≠ ∞) + {ε : ℝ≥0∞} : μ (t \ s) ≤ ε ↔ μ t ≤ μ s + ε := by + rw [measure_diff hst hs hs', tsub_le_iff_left] theorem measure_eq_measure_of_null_diff {s t : Set α} (hst : s ⊆ t) (h_nulldiff : μ (t \ s) = 0) : μ s = μ t := measure_congr <| @@ -295,15 +298,15 @@ theorem union_ae_eq_left_iff_ae_subset : (s ∪ t : Set α) =ᵐ[μ] s ↔ t ≤ theorem union_ae_eq_right_iff_ae_subset : (s ∪ t : Set α) =ᵐ[μ] t ↔ s ≤ᵐ[μ] t := by rw [union_comm, union_ae_eq_left_iff_ae_subset] -theorem ae_eq_of_ae_subset_of_measure_ge (h₁ : s ≤ᵐ[μ] t) (h₂ : μ t ≤ μ s) (hsm : MeasurableSet s) - (ht : μ t ≠ ∞) : s =ᵐ[μ] t := by +theorem ae_eq_of_ae_subset_of_measure_ge (h₁ : s ≤ᵐ[μ] t) (h₂ : μ t ≤ μ s) + (hsm : NullMeasurableSet s μ) (ht : μ t ≠ ∞) : s =ᵐ[μ] t := by refine eventuallyLE_antisymm_iff.mpr ⟨h₁, ae_le_set.mpr ?_⟩ replace h₂ : μ t = μ s := h₂.antisymm (measure_mono_ae h₁) replace ht : μ s ≠ ∞ := h₂ ▸ ht rw [measure_diff' t hsm ht, measure_congr (union_ae_eq_left_iff_ae_subset.mpr h₁), h₂, tsub_self] /-- If `s ⊆ t`, `μ t ≤ μ s`, `μ t ≠ ∞`, and `s` is measurable, then `s =ᵐ[μ] t`. -/ -theorem ae_eq_of_subset_of_measure_ge (h₁ : s ⊆ t) (h₂ : μ t ≤ μ s) (hsm : MeasurableSet s) +theorem ae_eq_of_subset_of_measure_ge (h₁ : s ⊆ t) (h₂ : μ t ≤ μ s) (hsm : NullMeasurableSet s μ) (ht : μ t ≠ ∞) : s =ᵐ[μ] t := ae_eq_of_ae_subset_of_measure_ge (HasSubset.Subset.eventuallyLE h₁) h₂ hsm ht @@ -325,7 +328,7 @@ theorem measure_iUnion_congr_of_subset [Countable β] {s : β → Set α} {t : measure_mono <| subset_inter ((hsub b).trans <| subset_toMeasurable _ _) ((subset_iUnion _ _).trans <| subset_toMeasurable _ _) - · exact (measurableSet_toMeasurable _ _).inter (measurableSet_toMeasurable _ _) + · measurability · rw [measure_toMeasurable] exact htop b calc @@ -472,13 +475,13 @@ theorem measure_biUnion_eq_iSup {s : ι → Set α} {t : Set ι} (ht : t.Countab /-- Continuity from above: the measure of the intersection of a decreasing sequence of measurable sets is the infimum of the measures. -/ -theorem measure_iInter_eq_iInf [Countable ι] {s : ι → Set α} (h : ∀ i, MeasurableSet (s i)) +theorem measure_iInter_eq_iInf [Countable ι] {s : ι → Set α} (h : ∀ i, NullMeasurableSet (s i) μ) (hd : Directed (· ⊇ ·) s) (hfin : ∃ i, μ (s i) ≠ ∞) : μ (⋂ i, s i) = ⨅ i, μ (s i) := by rcases hfin with ⟨k, hk⟩ have : ∀ t ⊆ s k, μ t ≠ ∞ := fun t ht => ne_top_of_le_ne_top hk (measure_mono ht) rw [← ENNReal.sub_sub_cancel hk (iInf_le _ k), ENNReal.sub_iInf, ← ENNReal.sub_sub_cancel hk (measure_mono (iInter_subset _ k)), ← - measure_diff (iInter_subset _ k) (MeasurableSet.iInter h) (this _ (iInter_subset _ k)), + measure_diff (iInter_subset _ k) (.iInter h) (this _ (iInter_subset _ k)), diff_iInter, measure_iUnion_eq_iSup] · congr 1 refine le_antisymm (iSup_mono' fun i => ?_) (iSup_mono fun i => ?_) @@ -486,17 +489,14 @@ theorem measure_iInter_eq_iInf [Countable ι] {s : ι → Set α} (h : ∀ i, Me use j rw [← measure_diff hjk (h _) (this _ hjk)] gcongr - · rw [tsub_le_iff_right, ← measure_union, Set.union_comm] - · exact measure_mono (diff_subset_iff.1 Subset.rfl) - · apply disjoint_sdiff_left - · apply h i + · apply le_measure_diff · exact hd.mono_comp _ fun _ _ => diff_subset_diff_right /-- Continuity from above: the measure of the intersection of a sequence of measurable sets is the infimum of the measures of the partial intersections. -/ theorem measure_iInter_eq_iInf' {α ι : Type*} [MeasurableSpace α] {μ : Measure α} [Countable ι] [Preorder ι] [IsDirected ι (· ≤ ·)] - {f : ι → Set α} (h : ∀ i, MeasurableSet (f i)) (hfin : ∃ i, μ (f i) ≠ ∞) : + {f : ι → Set α} (h : ∀ i, NullMeasurableSet (f i) μ) (hfin : ∃ i, μ (f i) ≠ ∞) : μ (⋂ i, f i) = ⨅ i, μ (⋂ j ≤ i, f j) := by let s := fun i ↦ ⋂ j ≤ i, f j have iInter_eq : ⋂ i, f i = ⋂ i, s i := by @@ -505,8 +505,8 @@ theorem measure_iInter_eq_iInf' {α ι : Type*} [MeasurableSpace α] {μ : Measu · intro h i rcases directed_of (· ≤ ·) i i with ⟨j, rij, -⟩ exact h j i rij - have ms : ∀ i, MeasurableSet (s i) := - fun i ↦ MeasurableSet.biInter (countable_univ.mono <| subset_univ _) fun i _ ↦ h i + have ms : ∀ i, NullMeasurableSet (s i) μ := + fun i ↦ .biInter (to_countable _) fun i _ ↦ h i have hd : Directed (· ⊇ ·) s := by intro i j rcases directed_of (· ≤ ·) i j with ⟨k, rik, rjk⟩ @@ -536,7 +536,7 @@ theorem tendsto_measure_iUnion' {α ι : Type*} [MeasurableSpace α] {μ : Measu /-- Continuity from above: the measure of the intersection of a decreasing sequence of measurable sets is the limit of the measures. -/ theorem tendsto_measure_iInter [Countable ι] [Preorder ι] [IsDirected ι (· ≤ ·)] {s : ι → Set α} - (hs : ∀ n, MeasurableSet (s n)) (hm : Antitone s) (hf : ∃ i, μ (s i) ≠ ∞) : + (hs : ∀ n, NullMeasurableSet (s n) μ) (hm : Antitone s) (hf : ∃ i, μ (s i) ≠ ∞) : Tendsto (μ ∘ s) atTop (𝓝 (μ (⋂ n, s n))) := by rw [measure_iInter_eq_iInf hs hm.directed_ge hf] exact tendsto_atTop_iInf fun n m hnm => measure_mono <| hm hnm @@ -544,7 +544,7 @@ theorem tendsto_measure_iInter [Countable ι] [Preorder ι] [IsDirected ι (· /-- Continuity from above: the measure of the intersection of a sequence of measurable sets such that one has finite measure is the limit of the measures of the partial intersections. -/ theorem tendsto_measure_iInter' {α ι : Type*} [MeasurableSpace α] {μ : Measure α} [Countable ι] - [Preorder ι] [IsDirected ι (· ≤ ·)] {f : ι → Set α} (hm : ∀ i, MeasurableSet (f i)) + [Preorder ι] [IsDirected ι (· ≤ ·)] {f : ι → Set α} (hm : ∀ i, NullMeasurableSet (f i) μ) (hf : ∃ i, μ (f i) ≠ ∞) : Tendsto (fun i ↦ μ (⋂ j ∈ {j | j ≤ i}, f j)) atTop (𝓝 (μ (⋂ i, f i))) := by rw [measure_iInter_eq_iInf' hm hf] @@ -555,7 +555,7 @@ theorem tendsto_measure_iInter' {α ι : Type*} [MeasurableSpace α] {μ : Measu sets indexed by a linear order with first countable topology is the limit of the measures. -/ theorem tendsto_measure_biInter_gt {ι : Type*} [LinearOrder ι] [TopologicalSpace ι] [OrderTopology ι] [DenselyOrdered ι] [FirstCountableTopology ι] {s : ι → Set α} - {a : ι} (hs : ∀ r > a, MeasurableSet (s r)) (hm : ∀ i j, a < i → i ≤ j → s i ⊆ s j) + {a : ι} (hs : ∀ r > a, NullMeasurableSet (s r) μ) (hm : ∀ i j, a < i → i ≤ j → s i ⊆ s j) (hf : ∃ r > a, μ (s r) ≠ ∞) : Tendsto (μ ∘ s) (𝓝[Ioi a] a) (𝓝 (μ (⋂ r > a, s r))) := by refine tendsto_order.2 ⟨fun l hl => ?_, fun L hL => ?_⟩ · filter_upwards [self_mem_nhdsWithin (s := Ioi a)] with r hr using hl.trans_le @@ -611,7 +611,7 @@ theorem measure_limsup_eq_zero {s : ℕ → Set α} (hs : (∑' i, μ (s i)) ≠ refine le_of_tendsto_of_tendsto' (tendsto_measure_iInter - (fun i => MeasurableSet.iUnion fun b => measurableSet_toMeasurable _ _) ?_ + (fun i => .iUnion fun b => (measurableSet_toMeasurable _ _).nullMeasurableSet) ?_ ⟨0, ne_top_of_le_ne_top ht (measure_iUnion_le t)⟩) (ENNReal.tendsto_sum_nat_add (μ ∘ t) ht) fun n => measure_iUnion_le _ intro n m hnm x @@ -2028,3 +2028,5 @@ theorem quasiMeasurePreserving_symm (μ : Measure α) (e : α ≃ᵐ β) : end MeasurableEquiv end + +set_option linter.style.longFile 2200 diff --git a/Mathlib/MeasureTheory/Measure/MeasureSpaceDef.lean b/Mathlib/MeasureTheory/Measure/MeasureSpaceDef.lean index 86b668b5e3a15..5dcc0f77d0243 100644 --- a/Mathlib/MeasureTheory/Measure/MeasureSpaceDef.lean +++ b/Mathlib/MeasureTheory/Measure/MeasureSpaceDef.lean @@ -378,6 +378,9 @@ theorem Measurable.aemeasurable (h : Measurable f) : AEMeasurable f μ := namespace AEMeasurable +lemma of_discrete [DiscreteMeasurableSpace α] : AEMeasurable f μ := + Measurable.of_discrete.aemeasurable + /-- Given an almost everywhere measurable function `f`, associate to it a measurable function that coincides with it almost everywhere. `f` is explicit in the definition to make sure that it shows in pretty-printing. -/ diff --git a/Mathlib/MeasureTheory/Measure/Regular.lean b/Mathlib/MeasureTheory/Measure/Regular.lean index f592f69d8eb29..cb00bad6d11e4 100644 --- a/Mathlib/MeasureTheory/Measure/Regular.lean +++ b/Mathlib/MeasureTheory/Measure/Regular.lean @@ -361,7 +361,7 @@ theorem _root_.MeasurableSet.exists_isOpen_diff_lt [OuterRegular μ] {A : Set α ∃ U, U ⊇ A ∧ IsOpen U ∧ μ U < ∞ ∧ μ (U \ A) < ε := by rcases A.exists_isOpen_lt_add hA' hε with ⟨U, hAU, hUo, hU⟩ use U, hAU, hUo, hU.trans_le le_top - exact measure_diff_lt_of_lt_add hA hAU hA' hU + exact measure_diff_lt_of_lt_add hA.nullMeasurableSet hAU hA' hU protected theorem map [OpensMeasurableSpace α] [MeasurableSpace β] [TopologicalSpace β] [BorelSpace β] (f : α ≃ₜ β) (μ : Measure α) [OuterRegular μ] : @@ -730,7 +730,7 @@ theorem _root_.MeasurableSet.exists_isCompact_diff_lt [OpensMeasurableSpace α] {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ K, K ⊆ A ∧ IsCompact K ∧ μ (A \ K) < ε := by rcases hA.exists_isCompact_lt_add h'A hε with ⟨K, hKA, hKc, hK⟩ - exact ⟨K, hKA, hKc, measure_diff_lt_of_lt_add hKc.measurableSet hKA + exact ⟨K, hKA, hKc, measure_diff_lt_of_lt_add hKc.nullMeasurableSet hKA (ne_top_of_le_ne_top h'A <| measure_mono hKA) hK⟩ /-- If `μ` is inner regular for finite measure sets with respect to compact sets, @@ -742,7 +742,7 @@ theorem _root_.MeasurableSet.exists_isCompact_isClosed_diff_lt [BorelSpace α] [ {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ K, K ⊆ A ∧ IsCompact K ∧ IsClosed K ∧ μ (A \ K) < ε := by rcases hA.exists_isCompact_isClosed_lt_add h'A hε with ⟨K, hKA, hKco, hKcl, hK⟩ - exact ⟨K, hKA, hKco, hKcl, measure_diff_lt_of_lt_add hKcl.measurableSet hKA + exact ⟨K, hKA, hKco, hKcl, measure_diff_lt_of_lt_add hKcl.nullMeasurableSet hKA (ne_top_of_le_ne_top h'A <| measure_mono hKA) hK⟩ /-- If `μ` is inner regular for finite measure sets with respect to compact sets, @@ -826,12 +826,12 @@ protected theorem _root_.MeasurableSet.exists_isOpen_symmDiff_lt [InnerRegularCo rcases hs.exists_isCompact_isClosed_diff_lt hμs this with ⟨K, hKs, hKco, hKcl, hμK⟩ rcases hKco.exists_isOpen_lt_add (μ := μ) this with ⟨U, hKU, hUo, hμU⟩ refine ⟨U, hUo, hμU.trans_le le_top, ?_⟩ - rw [← ENNReal.add_halves ε, measure_symmDiff_eq hUo.measurableSet hs] + rw [← ENNReal.add_halves ε, measure_symmDiff_eq hUo.nullMeasurableSet hs.nullMeasurableSet] gcongr · calc μ (U \ s) ≤ μ (U \ K) := by gcongr _ < ε / 2 := by - apply measure_diff_lt_of_lt_add hKcl.measurableSet hKU _ hμU + apply measure_diff_lt_of_lt_add hKcl.nullMeasurableSet hKU _ hμU exact ne_top_of_le_ne_top hμs (by gcongr) · exact lt_of_le_of_lt (by gcongr) hμK @@ -918,7 +918,7 @@ theorem _root_.MeasurableSet.exists_isClosed_diff_lt [OpensMeasurableSpace α] [ ⦃A : Set α⦄ (hA : MeasurableSet A) (h'A : μ A ≠ ∞) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ F, F ⊆ A ∧ IsClosed F ∧ μ (A \ F) < ε := by rcases hA.exists_isClosed_lt_add h'A hε with ⟨F, hFA, hFc, hF⟩ - exact ⟨F, hFA, hFc, measure_diff_lt_of_lt_add hFc.measurableSet hFA + exact ⟨F, hFA, hFc, measure_diff_lt_of_lt_add hFc.nullMeasurableSet hFA (ne_top_of_le_ne_top h'A <| measure_mono hFA) hF⟩ /-- Given a weakly regular measure, any measurable set of finite mass can be approximated from diff --git a/Mathlib/MeasureTheory/Measure/Restrict.lean b/Mathlib/MeasureTheory/Measure/Restrict.lean index c38f9cc1c8cef..99d9b00f136b2 100644 --- a/Mathlib/MeasureTheory/Measure/Restrict.lean +++ b/Mathlib/MeasureTheory/Measure/Restrict.lean @@ -76,11 +76,21 @@ theorem restrict_mono' {_m0 : MeasurableSpace α} ⦃s s' : Set α⦄ ⦃μ ν : _ = ν.restrict s' t := (restrict_apply ht).symm /-- Restriction of a measure to a subset is monotone both in set and in measure. -/ -@[mono] +@[mono, gcongr] theorem restrict_mono {_m0 : MeasurableSpace α} ⦃s s' : Set α⦄ (hs : s ⊆ s') ⦃μ ν : Measure α⦄ (hμν : μ ≤ ν) : μ.restrict s ≤ ν.restrict s' := restrict_mono' (ae_of_all _ hs) hμν +@[gcongr] +theorem restrict_mono_measure {_ : MeasurableSpace α} {μ ν : Measure α} (h : μ ≤ ν) (s : Set α) : + μ.restrict s ≤ ν.restrict s := + restrict_mono subset_rfl h + +@[gcongr] +theorem restrict_mono_set {_ : MeasurableSpace α} (μ : Measure α) {s t : Set α} (h : s ⊆ t) : + μ.restrict s ≤ μ.restrict t := + restrict_mono h le_rfl + theorem restrict_mono_ae (h : s ≤ᵐ[μ] t) : μ.restrict s ≤ μ.restrict t := restrict_mono' h (le_refl μ) @@ -307,11 +317,8 @@ measurable subsets of `s ∪ t`. -/ theorem restrict_union_congr : μ.restrict (s ∪ t) = ν.restrict (s ∪ t) ↔ μ.restrict s = ν.restrict s ∧ μ.restrict t = ν.restrict t := by - refine - ⟨fun h => - ⟨restrict_congr_mono subset_union_left h, - restrict_congr_mono subset_union_right h⟩, - ?_⟩ + refine ⟨fun h ↦ ⟨restrict_congr_mono subset_union_left h, + restrict_congr_mono subset_union_right h⟩, ?_⟩ rintro ⟨hs, ht⟩ ext1 u hu simp only [restrict_apply hu, inter_union_distrib_left] @@ -319,14 +326,14 @@ theorem restrict_union_congr : calc μ (u ∩ s ∪ u ∩ t) = μ (US ∪ u ∩ t) := measure_union_congr_of_subset hsub hμ.le Subset.rfl le_rfl - _ = μ US + μ ((u ∩ t) \ US) := (measure_add_diff hm _).symm + _ = μ US + μ ((u ∩ t) \ US) := (measure_add_diff hm.nullMeasurableSet _).symm _ = restrict μ s u + restrict μ t (u \ US) := by simp only [restrict_apply, hu, hu.diff hm, hμ, ← inter_comm t, inter_diff_assoc] _ = restrict ν s u + restrict ν t (u \ US) := by rw [hs, ht] _ = ν US + ν ((u ∩ t) \ US) := by simp only [restrict_apply, hu, hu.diff hm, hν, ← inter_comm t, inter_diff_assoc] - _ = ν (US ∪ u ∩ t) := measure_add_diff hm _ - _ = ν (u ∩ s ∪ u ∩ t) := Eq.symm <| measure_union_congr_of_subset hsub hν.le Subset.rfl le_rfl + _ = ν (US ∪ u ∩ t) := measure_add_diff hm.nullMeasurableSet _ + _ = ν (u ∩ s ∪ u ∩ t) := .symm <| measure_union_congr_of_subset hsub hν.le Subset.rfl le_rfl theorem restrict_finset_biUnion_congr {s : Finset ι} {t : ι → Set α} : μ.restrict (⋃ i ∈ s, t i) = ν.restrict (⋃ i ∈ s, t i) ↔ diff --git a/Mathlib/MeasureTheory/Measure/Stieltjes.lean b/Mathlib/MeasureTheory/Measure/Stieltjes.lean index 7399a3bc6bab9..150f72aaf7a86 100644 --- a/Mathlib/MeasureTheory/Measure/Stieltjes.lean +++ b/Mathlib/MeasureTheory/Measure/Stieltjes.lean @@ -373,8 +373,9 @@ theorem measure_singleton (a : ℝ) : f.measure {a} = ofReal (f a - leftLim f a) simp [le_antisymm this (hx 0).2] have L1 : Tendsto (fun n => f.measure (Ioc (u n) a)) atTop (𝓝 (f.measure {a})) := by rw [A] - refine tendsto_measure_iInter (fun n => measurableSet_Ioc) (fun m n hmn => ?_) ?_ - · exact Ioc_subset_Ioc (u_mono.monotone hmn) le_rfl + refine tendsto_measure_iInter (fun n => measurableSet_Ioc.nullMeasurableSet) + (fun m n hmn => ?_) ?_ + · exact Ioc_subset_Ioc_left (u_mono.monotone hmn) · exact ⟨0, by simpa only [measure_Ioc] using ENNReal.ofReal_ne_top⟩ have L2 : Tendsto (fun n => f.measure (Ioc (u n) a)) atTop (𝓝 (ofReal (f a - leftLim f a))) := by diff --git a/Mathlib/MeasureTheory/Measure/Typeclasses.lean b/Mathlib/MeasureTheory/Measure/Typeclasses.lean index c6eb904a1c082..d49809c77dc3e 100644 --- a/Mathlib/MeasureTheory/Measure/Typeclasses.lean +++ b/Mathlib/MeasureTheory/Measure/Typeclasses.lean @@ -143,13 +143,9 @@ theorem summable_measure_toReal [hμ : IsFiniteMeasure μ] {f : ℕ → Set α} exact ne_of_lt (measure_lt_top _ _) theorem ae_eq_univ_iff_measure_eq [IsFiniteMeasure μ] (hs : NullMeasurableSet s μ) : - s =ᵐ[μ] univ ↔ μ s = μ univ := by - refine ⟨measure_congr, fun h => ?_⟩ - obtain ⟨t, -, ht₁, ht₂⟩ := hs.exists_measurable_subset_ae_eq - exact - ht₂.symm.trans - (ae_eq_of_subset_of_measure_ge (subset_univ t) (Eq.le ((measure_congr ht₂).trans h).symm) ht₁ - (measure_ne_top μ univ)) + s =ᵐ[μ] univ ↔ μ s = μ univ := + ⟨measure_congr, fun h ↦ + (ae_eq_of_subset_of_measure_ge (subset_univ s) h.ge hs (measure_ne_top μ univ))⟩ theorem ae_iff_measure_eq [IsFiniteMeasure μ] {p : α → Prop} (hp : NullMeasurableSet { a | p a } μ) : (∀ᵐ a ∂μ, p a) ↔ μ { a | p a } = μ univ := by @@ -161,7 +157,7 @@ theorem ae_mem_iff_measure_eq [IsFiniteMeasure μ] {s : Set α} (hs : NullMeasur lemma tendsto_measure_biUnion_Ici_zero_of_pairwise_disjoint {X : Type*} [MeasurableSpace X] {μ : Measure X} [IsFiniteMeasure μ] - {Es : ℕ → Set X} (Es_mble : ∀ i, MeasurableSet (Es i)) + {Es : ℕ → Set X} (Es_mble : ∀ i, NullMeasurableSet (Es i) μ) (Es_disj : Pairwise fun n m ↦ Disjoint (Es n) (Es m)) : Tendsto (μ ∘ fun n ↦ ⋃ i ≥ n, Es i) atTop (𝓝 0) := by have decr : Antitone fun n ↦ ⋃ i ≥ n, Es i := @@ -174,15 +170,16 @@ lemma tendsto_measure_biUnion_Ici_zero_of_pairwise_disjoint obtain ⟨k, k_gt_j, x_in_Es_k⟩ := hx (j+1) have oops := (Es_disj (Nat.ne_of_lt k_gt_j)).ne_of_mem x_in_Es_j x_in_Es_k contradiction - have key := - tendsto_measure_iInter (μ := μ) (fun n ↦ by measurability) decr ⟨0, measure_ne_top _ _⟩ + -- TODO: `by measurability` fails + have key := tendsto_measure_iInter (μ := μ) (fun n ↦ .iUnion fun _ ↦ .iUnion fun _ ↦ Es_mble _) + decr ⟨0, measure_ne_top _ _⟩ simp only [nothing, measure_empty] at key convert key open scoped symmDiff theorem abs_toReal_measure_sub_le_measure_symmDiff' - (hs : MeasurableSet s) (ht : MeasurableSet t) (hs' : μ s ≠ ∞) (ht' : μ t ≠ ∞) : + (hs : NullMeasurableSet s μ) (ht : NullMeasurableSet t μ) (hs' : μ s ≠ ∞) (ht' : μ t ≠ ∞) : |(μ s).toReal - (μ t).toReal| ≤ (μ (s ∆ t)).toReal := by have hst : μ (s \ t) ≠ ∞ := (measure_lt_top_of_subset diff_subset hs').ne have hts : μ (t \ s) ≠ ∞ := (measure_lt_top_of_subset diff_subset ht').ne @@ -196,15 +193,18 @@ theorem abs_toReal_measure_sub_le_measure_symmDiff' abel theorem abs_toReal_measure_sub_le_measure_symmDiff [IsFiniteMeasure μ] - (hs : MeasurableSet s) (ht : MeasurableSet t) : + (hs : NullMeasurableSet s μ) (ht : NullMeasurableSet t μ) : |(μ s).toReal - (μ t).toReal| ≤ (μ (s ∆ t)).toReal := abs_toReal_measure_sub_le_measure_symmDiff' hs ht (measure_ne_top μ s) (measure_ne_top μ t) instance {s : Finset ι} {μ : ι → Measure α} [∀ i, IsFiniteMeasure (μ i)] : IsFiniteMeasure (∑ i ∈ s, μ i) where measure_univ_lt_top := by simp [measure_lt_top] -instance [Fintype ι] {μ : ι → Measure α} [∀ i, IsFiniteMeasure (μ i)] : - IsFiniteMeasure (.sum μ) where measure_univ_lt_top := by simp [measure_lt_top] +instance [Finite ι] {μ : ι → Measure α} [∀ i, IsFiniteMeasure (μ i)] : + IsFiniteMeasure (.sum μ) where + measure_univ_lt_top := by + cases nonempty_fintype ι + simp [measure_lt_top] end IsFiniteMeasure @@ -1542,3 +1542,5 @@ theorem measure_Ioo_lt_top : μ (Ioo a b) < ∞ := (measure_mono Ioo_subset_Icc_self).trans_lt measure_Icc_lt_top end MeasureIxx + +set_option linter.style.longFile 1700 diff --git a/Mathlib/MeasureTheory/Order/UpperLower.lean b/Mathlib/MeasureTheory/Order/UpperLower.lean index 5e56bec648560..6e04d112e9d58 100644 --- a/Mathlib/MeasureTheory/Order/UpperLower.lean +++ b/Mathlib/MeasureTheory/Order/UpperLower.lean @@ -116,7 +116,7 @@ private lemma aux₁ mul_div_mul_left _ _ (two_ne_zero' ℝ), div_right_comm, div_self, one_div] all_goals try positivity · simp_all - · measurability + · exact measurableSet_closedBall.nullMeasurableSet theorem IsUpperSet.null_frontier (hs : IsUpperSet s) : volume (frontier s) = 0 := by refine measure_mono_null (fun x hx ↦ ?_) diff --git a/Mathlib/MeasureTheory/OuterMeasure/Caratheodory.lean b/Mathlib/MeasureTheory/OuterMeasure/Caratheodory.lean index 04c80d5a09c16..167ea1437b67c 100644 --- a/Mathlib/MeasureTheory/OuterMeasure/Caratheodory.lean +++ b/Mathlib/MeasureTheory/OuterMeasure/Caratheodory.lean @@ -148,7 +148,7 @@ theorem f_iUnion {s : ℕ → Set α} (h : ∀ i, IsCaratheodory m (s i)) (hd : simp only [inter_comm, inter_univ, univ_inter] at this; simp only [this] exact m.mono (iUnion₂_subset fun i _ => subset_iUnion _ i) -/-- The Carathéodory-measurable sets for an outer measure `m` form a Dynkin system. -/ +/-- The Carathéodory-measurable sets for an outer measure `m` form a Dynkin system. -/ def caratheodoryDynkin : MeasurableSpace.DynkinSystem α where Has := IsCaratheodory m has_empty := isCaratheodory_empty m diff --git a/Mathlib/MeasureTheory/OuterMeasure/OfFunction.lean b/Mathlib/MeasureTheory/OuterMeasure/OfFunction.lean index 0e6784ff063d2..10ed5a919bc6b 100644 --- a/Mathlib/MeasureTheory/OuterMeasure/OfFunction.lean +++ b/Mathlib/MeasureTheory/OuterMeasure/OfFunction.lean @@ -128,7 +128,7 @@ theorem ofFunction_eq_sSup : OuterMeasure.ofFunction m m_empty = sSup { μ | ∀ E.g., if `α` is an (e)metric space and `m u = ∞` on any set of diameter `≥ r`, then this lemma implies that `μ (s ∪ t) = μ s + μ t` on any two sets such that `r ≤ edist x y` for all `x ∈ s` -and `y ∈ t`. -/ +and `y ∈ t`. -/ theorem ofFunction_union_of_top_of_nonempty_inter {s t : Set α} (h : ∀ u, (s ∩ u).Nonempty → (t ∩ u).Nonempty → m u = ∞) : OuterMeasure.ofFunction m m_empty (s ∪ t) = @@ -291,7 +291,7 @@ theorem comap_boundedBy {β} (f : β → α) E.g., if `α` is an (e)metric space and `m u = ∞` on any set of diameter `≥ r`, then this lemma implies that `μ (s ∪ t) = μ s + μ t` on any two sets such that `r ≤ edist x y` for all `x ∈ s` -and `y ∈ t`. -/ +and `y ∈ t`. -/ theorem boundedBy_union_of_top_of_nonempty_inter {s t : Set α} (h : ∀ u, (s ∩ u).Nonempty → (t ∩ u).Nonempty → m u = ∞) : boundedBy m (s ∪ t) = boundedBy m s + boundedBy m t := diff --git a/Mathlib/ModelTheory/Basic.lean b/Mathlib/ModelTheory/Basic.lean index 04ea4484a6189..9ad5c23c19d83 100644 --- a/Mathlib/ModelTheory/Basic.lean +++ b/Mathlib/ModelTheory/Basic.lean @@ -248,13 +248,13 @@ theorem card_mk₂ (c f₁ f₂ : Type u) (r₁ r₂ : Type v) : /-- Passes a `DecidableEq` instance on a type of function symbols through the `Language` constructor. Despite the fact that this is proven by `inferInstance`, it is still needed - -see the `example`s in `ModelTheory/Ring/Basic`. -/ +see the `example`s in `ModelTheory/Ring/Basic`. -/ instance instDecidableEqFunctions {f : ℕ → Type*} {R : ℕ → Type*} (n : ℕ) [DecidableEq (f n)] : DecidableEq ((⟨f, R⟩ : Language).Functions n) := inferInstance /-- Passes a `DecidableEq` instance on a type of relation symbols through the `Language` constructor. Despite the fact that this is proven by `inferInstance`, it is still needed - -see the `example`s in `ModelTheory/Ring/Basic`. -/ +see the `example`s in `ModelTheory/Ring/Basic`. -/ instance instDecidableEqRelations {f : ℕ → Type*} {R : ℕ → Type*} (n : ℕ) [DecidableEq (R n)] : DecidableEq ((⟨f, R⟩ : Language).Relations n) := inferInstance @@ -526,7 +526,7 @@ theorem id_comp (f : M →[L] N) : (id L N).comp f = f := end Hom /-- Any element of a `HomClass` can be realized as a first_order homomorphism. -/ -def HomClass.toHom {F M N} [L.Structure M] [L.Structure N] [FunLike F M N] +@[simps] def HomClass.toHom {F M N} [L.Structure M] [L.Structure N] [FunLike F M N] [HomClass L F M N] : F → M →[L] N := fun φ => ⟨φ, HomClass.map_fun φ, HomClass.map_rel φ⟩ @@ -681,7 +681,7 @@ theorem refl_toHom : (refl L M).toHom = Hom.id L M := end Embedding /-- Any element of an injective `StrongHomClass` can be realized as a first_order embedding. -/ -def StrongHomClass.toEmbedding {F M N} [L.Structure M] [L.Structure N] [FunLike F M N] +@[simps] def StrongHomClass.toEmbedding {F M N} [L.Structure M] [L.Structure N] [FunLike F M N] [EmbeddingLike F M N] [StrongHomClass L F M N] : F → M ↪[L] N := fun φ => ⟨⟨φ, EmbeddingLike.injective φ⟩, StrongHomClass.map_fun φ, StrongHomClass.map_rel φ⟩ @@ -895,7 +895,7 @@ theorem comp_right_inj (h : M ≃[L] N) (f g : N ≃[L] P) : f.comp h = g.comp h end Equiv /-- Any element of a bijective `StrongHomClass` can be realized as a first_order isomorphism. -/ -def StrongHomClass.toEquiv {F M N} [L.Structure M] [L.Structure N] [EquivLike F M N] +@[simps] def StrongHomClass.toEquiv {F M N} [L.Structure M] [L.Structure N] [EquivLike F M N] [StrongHomClass L F M N] : F → M ≃[L] N := fun φ => ⟨⟨φ, EquivLike.inv φ, EquivLike.left_inv φ, EquivLike.right_inv φ⟩, StrongHomClass.map_fun φ, StrongHomClass.map_rel φ⟩ diff --git a/Mathlib/ModelTheory/Fraisse.lean b/Mathlib/ModelTheory/Fraisse.lean index 6107ba6f5fdea..1318d2970ceb0 100644 --- a/Mathlib/ModelTheory/Fraisse.lean +++ b/Mathlib/ModelTheory/Fraisse.lean @@ -77,7 +77,7 @@ open Structure Substructure variable (L : Language.{u, v}) -/-! ### The Age of a Structure and Fraïssé Classes-/ +/-! ### The Age of a Structure and Fraïssé Classes -/ /-- The age of a structure `M` is the class of finitely-generated structures that embed into it. -/ @@ -88,7 +88,7 @@ variable {L} variable (K : Set (Bundled.{w} L.Structure)) /-- A class `K` has the hereditary property when all finitely-generated structures that embed into - structures in `K` are also in `K`. -/ + structures in `K` are also in `K`. -/ def Hereditary : Prop := ∀ M : Bundled.{w} L.Structure, M ∈ K → L.age M ⊆ K diff --git a/Mathlib/ModelTheory/LanguageMap.lean b/Mathlib/ModelTheory/LanguageMap.lean index a70065ee3ba7e..a242bb82ad36f 100644 --- a/Mathlib/ModelTheory/LanguageMap.lean +++ b/Mathlib/ModelTheory/LanguageMap.lean @@ -404,7 +404,7 @@ theorem card_withConstants : L[[α]].card = Cardinal.lift.{w'} L.card + Cardinal.lift.{max u v} #α := by rw [withConstants, card_sum, card_constantsOn] -/-- The language map adding constants. -/ +/-- The language map adding constants. -/ @[simps!] -- Porting note: add `!` to `simps` def lhomWithConstants : L →ᴸ L[[α]] := LHom.sumInl @@ -420,7 +420,7 @@ protected def con (a : α) : L[[α]].Constants := variable {L} (α) -/-- Adds constants to a language map. -/ +/-- Adds constants to a language map. -/ def LHom.addConstants {L' : Language} (φ : L →ᴸ L') : L[[α]] →ᴸ L'[[α]] := φ.sumMap (LHom.id _) @@ -429,7 +429,7 @@ instance paramsStructure (A : Set α) : (constantsOn A).Structure α := variable (L) -/-- The language map removing an empty constant set. -/ +/-- The language map removing an empty constant set. -/ @[simps] def LEquiv.addEmptyConstants [ie : IsEmpty α] : L ≃ᴸ L[[α]] where toLHom := lhomWithConstants L α @@ -451,7 +451,7 @@ theorem withConstants_relMap_sum_inl [L[[α]].Structure M] [(lhomWithConstants L {n} {R : L.Relations n} {x : Fin n → M} : @RelMap (L[[α]]) M _ n (Sum.inl R) x = RelMap R x := (lhomWithConstants L α).map_onRelation R x -/-- The language map extending the constant set. -/ +/-- The language map extending the constant set. -/ def lhomWithConstantsMap (f : α → β) : L[[α]] →ᴸ L[[β]] := LHom.sumMap (LHom.id L) (LHom.constantsOnMap f) diff --git a/Mathlib/ModelTheory/Skolem.lean b/Mathlib/ModelTheory/Skolem.lean index eefcbc6d811c1..bb14f4b42c70a 100644 --- a/Mathlib/ModelTheory/Skolem.lean +++ b/Mathlib/ModelTheory/Skolem.lean @@ -116,7 +116,7 @@ variable {M} /-- The **Downward Löwenheim–Skolem theorem** : If `s` is a set in an `L`-structure `M` and `κ` an infinite cardinal such that `max (#s, L.card) ≤ κ` and `κ ≤ # M`, then `M` has an elementary substructure containing `s` of - cardinality `κ`. -/ + cardinality `κ`. -/ theorem exists_elementarySubstructure_card_eq (s : Set M) (κ : Cardinal.{w'}) (h1 : ℵ₀ ≤ κ) (h2 : Cardinal.lift.{w'} #s ≤ Cardinal.lift.{w} κ) (h3 : Cardinal.lift.{w'} L.card ≤ Cardinal.lift.{max u v} κ) diff --git a/Mathlib/NumberTheory/ArithmeticFunction.lean b/Mathlib/NumberTheory/ArithmeticFunction.lean index ffd2563801e40..442363c3a7429 100644 --- a/Mathlib/NumberTheory/ArithmeticFunction.lean +++ b/Mathlib/NumberTheory/ArithmeticFunction.lean @@ -390,7 +390,7 @@ instance {M : Type*} [Semiring R] [AddCommMonoid M] [Module R M] : section Zeta -/-- `ζ 0 = 0`, otherwise `ζ x = 1`. The Dirichlet Series is the Riemann `ζ`. -/ +/-- `ζ 0 = 0`, otherwise `ζ x = 1`. The Dirichlet Series is the Riemann `ζ`. -/ def zeta : ArithmeticFunction ℕ := ⟨fun x => ite (x = 0) 0 1, rfl⟩ @@ -776,7 +776,7 @@ end IsMultiplicative section SpecialFunctions -/-- The identity on `ℕ` as an `ArithmeticFunction`. -/ +/-- The identity on `ℕ` as an `ArithmeticFunction`. -/ nonrec -- Porting note (#11445): added def id : ArithmeticFunction ℕ := ⟨id, rfl⟩ diff --git a/Mathlib/NumberTheory/Cyclotomic/CyclotomicCharacter.lean b/Mathlib/NumberTheory/Cyclotomic/CyclotomicCharacter.lean index 1f7a73c505206..f21a7f71b8882 100644 --- a/Mathlib/NumberTheory/Cyclotomic/CyclotomicCharacter.lean +++ b/Mathlib/NumberTheory/Cyclotomic/CyclotomicCharacter.lean @@ -195,7 +195,7 @@ lemma spec (g : L ≃+* L) {t : Lˣ} (ht : t ∈ rootsOfUnity n L) : congr 1 exact (ZMod.ringEquivCongr_val _ _).symm -lemma unique (g : L ≃+* L) {c : ZMod n} (hc : ∀ t ∈ rootsOfUnity n L, g t = t ^ c.val) : +lemma unique (g : L ≃+* L) {c : ZMod n} (hc : ∀ t ∈ rootsOfUnity n L, g t = t ^ c.val) : c = ModularCyclotomicCharacter L hn g := by change c = (ZMod.ringEquivCongr hn) (toFun n g) rw [← toFun_unique' n g (ZMod.ringEquivCongr hn.symm c) diff --git a/Mathlib/NumberTheory/EulerProduct/DirichletLSeries.lean b/Mathlib/NumberTheory/EulerProduct/DirichletLSeries.lean index 82d366d734cee..ba72ec28fdfcd 100644 --- a/Mathlib/NumberTheory/EulerProduct/DirichletLSeries.lean +++ b/Mathlib/NumberTheory/EulerProduct/DirichletLSeries.lean @@ -77,12 +77,8 @@ lemma summable_dirichletSummand {N : ℕ} (χ : DirichletCharacter ℂ N) (hs : open scoped LSeries.notation in lemma tsum_dirichletSummand {N : ℕ} (χ : DirichletCharacter ℂ N) (hs : 1 < s.re) : ∑' (n : ℕ), dirichletSummandHom χ (ne_zero_of_one_lt_re hs) n = L ↗χ s := by - simp only [LSeries, LSeries.term, dirichletSummandHom] - refine tsum_congr (fun n ↦ ?_) - rcases eq_or_ne n 0 with rfl | hn - · simp only [map_zero, ↓reduceIte] - · simp only [cpow_neg, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk, hn, ↓reduceIte, - Field.div_eq_mul_inv] + simp only [dirichletSummandHom, cpow_neg, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk, LSeries, + LSeries.term_of_ne_zero' (ne_zero_of_one_lt_re hs), div_eq_mul_inv] open Filter Nat Topology EulerProduct diff --git a/Mathlib/NumberTheory/FLT/Basic.lean b/Mathlib/NumberTheory/FLT/Basic.lean index 49253dbdcc2fd..908060bf6699e 100644 --- a/Mathlib/NumberTheory/FLT/Basic.lean +++ b/Mathlib/NumberTheory/FLT/Basic.lean @@ -175,7 +175,7 @@ lemma fermatLastTheoremWith_of_fermatLastTheoremWith_coprime {n : ℕ} {R : Type rw [← Finset.gcd_mul_left, gcd_eq_gcd_image, image_insert, image_insert, image_singleton, id_eq, id_eq, id_eq, ← hA, ← hB, ← hC] -lemma dvd_c_of_prime_of_dvd_a_of_dvd_b_of_FLT {n : ℕ} {p : ℤ} (hp : Prime p) {a b c : ℤ} +lemma dvd_c_of_prime_of_dvd_a_of_dvd_b_of_FLT {n : ℕ} {p : ℤ} (hp : Prime p) {a b c : ℤ} (hpa : p ∣ a) (hpb : p ∣ b) (HF : a ^ n + b ^ n + c ^ n = 0) : p ∣ c := by rcases eq_or_ne n 0 with rfl | hn · simp at HF diff --git a/Mathlib/NumberTheory/FLT/Three.lean b/Mathlib/NumberTheory/FLT/Three.lean index 328eb0d18caae..555bad3224e64 100644 --- a/Mathlib/NumberTheory/FLT/Three.lean +++ b/Mathlib/NumberTheory/FLT/Three.lean @@ -241,7 +241,7 @@ lemma Solution.exists_minimal : ∃ (S₁ : Solution hζ), S₁.isMinimal := by end DecidableRel /-- Given `S' : Solution'`, then `S'.a` and `S'.b` are both congruent to `1` modulo `λ ^ 4` or are -both congruent to `-1`. -/ +both congruent to `-1`. -/ lemma a_cube_b_cube_congr_one_or_neg_one : λ ^ 4 ∣ S'.a ^ 3 - 1 ∧ λ ^ 4 ∣ S'.b ^ 3 + 1 ∨ λ ^ 4 ∣ S'.a ^ 3 + 1 ∧ λ ^ 4 ∣ S'.b ^ 3 - 1 := by obtain ⟨z, hz⟩ := S'.hcdvd diff --git a/Mathlib/NumberTheory/Harmonic/GammaDeriv.lean b/Mathlib/NumberTheory/Harmonic/GammaDeriv.lean index a66d5d7a47b91..90e05ffd8ff51 100644 --- a/Mathlib/NumberTheory/Harmonic/GammaDeriv.lean +++ b/Mathlib/NumberTheory/Harmonic/GammaDeriv.lean @@ -4,12 +4,13 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: David Loeffler -/ -import Mathlib.NumberTheory.Harmonic.EulerMascheroni +import Mathlib.Analysis.Convex.Deriv import Mathlib.Analysis.SpecialFunctions.Gamma.Deligne import Mathlib.Data.Nat.Factorial.Basic +import Mathlib.NumberTheory.Harmonic.EulerMascheroni /-! -# Derivative of Γ at positive integers +# Derivative of Γ at positive integers We prove the formula for the derivative of `Real.Gamma` at a positive integer: diff --git a/Mathlib/NumberTheory/Harmonic/ZetaAsymp.lean b/Mathlib/NumberTheory/Harmonic/ZetaAsymp.lean index c5c6b9529953e..f19f1c0d3e7eb 100644 --- a/Mathlib/NumberTheory/Harmonic/ZetaAsymp.lean +++ b/Mathlib/NumberTheory/Harmonic/ZetaAsymp.lean @@ -37,7 +37,7 @@ namespace ZetaAsymptotics -- since the intermediate lemmas are of little interest in themselves we put them in a namespace /-! -## Definitions +## Definitions -/ /-- Auxiliary function used in studying zeta-function asymptotics. -/ diff --git a/Mathlib/NumberTheory/LSeries/Basic.lean b/Mathlib/NumberTheory/LSeries/Basic.lean index 027a30959131b..7221b06b0360f 100644 --- a/Mathlib/NumberTheory/LSeries/Basic.lean +++ b/Mathlib/NumberTheory/LSeries/Basic.lean @@ -77,6 +77,16 @@ lemma term_of_ne_zero {n : ℕ} (hn : n ≠ 0) (f : ℕ → ℂ) (s : ℂ) : term f s n = f n / n ^ s := if_neg hn +/-- +If `s ≠ 0`, then the `if .. then .. else` construction in `LSeries.term` isn't needed, since +`0 ^ s = 0`. +-/ +lemma term_of_ne_zero' {s : ℂ} (hs : s ≠ 0) (f : ℕ → ℂ) (n : ℕ) : + term f s n = f n / n ^ s := by + rcases eq_or_ne n 0 with rfl | hn + · rw [term_zero, Nat.cast_zero, zero_cpow hs, div_zero] + · rw [term_of_ne_zero hn] + lemma term_congr {f g : ℕ → ℂ} (h : ∀ {n}, n ≠ 0 → f n = g n) (s : ℂ) (n : ℕ) : term f s n = term g s n := by rcases eq_or_ne n 0 with hn | hn <;> simp [hn, h] diff --git a/Mathlib/NumberTheory/LSeries/DirichletContinuation.lean b/Mathlib/NumberTheory/LSeries/DirichletContinuation.lean new file mode 100644 index 0000000000000..dd4b132bc5130 --- /dev/null +++ b/Mathlib/NumberTheory/LSeries/DirichletContinuation.lean @@ -0,0 +1,70 @@ +/- +Copyright (c) 2024 David Loeffler. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: David Loeffler +-/ +import Mathlib.NumberTheory.LSeries.ZMod +import Mathlib.NumberTheory.DirichletCharacter.Basic + +/-! +# Analytic continuation of Dirichlet L-functions + +We show that if `χ` is a Dirichlet character `ZMod N → ℂ`, for a positive integer `N`, then the +L-series of `χ` has analytic continuation (away from a pole at `s = 1` if `χ` is trivial). + +All definitions and theorems are in the `DirichletCharacter` namespace. + +## Main definitions + +* `LFunction χ s`: the L-function, defined as a linear combination of Hurwitz zeta functions. + +## Main theorems + +* `LFunction_eq_LSeries`: if `1 < re s` then the `LFunction` coincides with the naive `LSeries`. +* `differentiable_LFunction`: if `χ` is nontrivial then `LFunction χ s` is differentiable + everywhere. +-/ + +open Complex + +namespace DirichletCharacter + +variable {N : ℕ} [NeZero N] + +/-- +The unique meromorphic function `ℂ → ℂ` which agrees with `∑' n : ℕ, χ n / n ^ s` wherever the +latter is convergent. This is constructed as a linear combination of Hurwitz zeta functions. + +Note that this is not the same as `LSeries χ`: they agree in the convergence range, but +`LSeries χ s` is defined to be `0` if `re s ≤ 1`. + -/ +noncomputable def LFunction (χ : DirichletCharacter ℂ N) (s : ℂ) : ℂ := ZMod.LFunction χ s + +/-- The L-function of the (unique) Dirichlet character mod 1 is the Riemann zeta function. +(Compare `DirichletCharacter.LSeries_modOne_eq`.) -/ +@[simp] lemma LFunction_modOne_eq {χ : DirichletCharacter ℂ 1} : + LFunction χ = riemannZeta := by + ext1; rw [LFunction, ZMod.LFunction_modOne_eq, (by rfl : (0 : ZMod 1) = 1), map_one, one_mul] + +/-- +For `1 < re s` the L-function of a Dirichlet character agrees with the sum of the naive Dirichlet +series. +-/ +lemma LFunction_eq_LSeries (χ : DirichletCharacter ℂ N) {s : ℂ} (hs : 1 < re s) : + LFunction χ s = LSeries (χ ·) s := + ZMod.LFunction_eq_LSeries χ hs + +/-- +The L-function of a Dirichlet character is differentiable, except at `s = 1` if the character is +trivial. +-/ +lemma differentiableAt_LFunction (χ : DirichletCharacter ℂ N) (s : ℂ) (hs : s ≠ 1 ∨ χ ≠ 1) : + DifferentiableAt ℂ (LFunction χ) s := + ZMod.differentiableAt_LFunction χ s (hs.imp_right χ.sum_eq_zero_of_ne_one) + +/-- The L-function of a non-trivial Dirichlet character is differentiable everywhere. -/ +lemma differentiable_LFunction {χ : DirichletCharacter ℂ N} (hχ : χ ≠ 1) : + Differentiable ℂ (LFunction χ) := + (differentiableAt_LFunction _ · <| Or.inr hχ) + +end DirichletCharacter diff --git a/Mathlib/NumberTheory/LSeries/HurwitzZeta.lean b/Mathlib/NumberTheory/LSeries/HurwitzZeta.lean index 79f23403685fc..69091d6315bba 100644 --- a/Mathlib/NumberTheory/LSeries/HurwitzZeta.lean +++ b/Mathlib/NumberTheory/LSeries/HurwitzZeta.lean @@ -142,11 +142,9 @@ lemma differentiable_expZeta_of_ne_zero {a : UnitAddCircle} (ha : a ≠ 0) : /-- Reformulation of `hasSum_expZeta_of_one_lt_re` using `LSeriesHasSum`. -/ lemma LSeriesHasSum_exp (a : ℝ) {s : ℂ} (hs : 1 < re s) : - LSeriesHasSum (cexp <| 2 * π * I * a * ·) s (expZeta a s) := by - refine (hasSum_expZeta_of_one_lt_re a hs).congr_fun (fun n ↦ ?_) - rcases eq_or_ne n 0 with rfl | hn - · rw [LSeries.term_zero, Nat.cast_zero, zero_cpow (ne_zero_of_one_lt_re hs), div_zero] - · apply LSeries.term_of_ne_zero hn + LSeriesHasSum (cexp <| 2 * π * I * a * ·) s (expZeta a s) := + (hasSum_expZeta_of_one_lt_re a hs).congr_fun + (LSeries.term_of_ne_zero' (ne_zero_of_one_lt_re hs) _) /-! ## The functional equation diff --git a/Mathlib/NumberTheory/LSeries/HurwitzZetaEven.lean b/Mathlib/NumberTheory/LSeries/HurwitzZetaEven.lean index 48fb9b87f7ce9..ac307e2324e77 100644 --- a/Mathlib/NumberTheory/LSeries/HurwitzZetaEven.lean +++ b/Mathlib/NumberTheory/LSeries/HurwitzZetaEven.lean @@ -768,12 +768,9 @@ lemma hasSum_nat_cosZeta (a : ℝ) {s : ℂ} (hs : 1 < re s) : /-- Reformulation of `hasSum_nat_cosZeta` using `LSeriesHasSum`. -/ lemma LSeriesHasSum_cos (a : ℝ) {s : ℂ} (hs : 1 < re s) : - LSeriesHasSum (Real.cos <| 2 * π * a * ·) s (cosZeta a s) := by - refine (hasSum_nat_cosZeta a hs).congr_fun (fun n ↦ ?_) - rcases eq_or_ne n 0 with rfl | hn - · rw [LSeries.term_zero, Nat.cast_zero, Nat.cast_zero, zero_cpow (ne_zero_of_one_lt_re hs), - div_zero] - · apply LSeries.term_of_ne_zero hn + LSeriesHasSum (Real.cos <| 2 * π * a * ·) s (cosZeta a s) := + (hasSum_nat_cosZeta a hs).congr_fun + (LSeries.term_of_ne_zero' (ne_zero_of_one_lt_re hs) _) /-! ## Functional equations for the un-completed zetas diff --git a/Mathlib/NumberTheory/LSeries/HurwitzZetaOdd.lean b/Mathlib/NumberTheory/LSeries/HurwitzZetaOdd.lean index e14ca16ba1108..cf70f0a830ee7 100644 --- a/Mathlib/NumberTheory/LSeries/HurwitzZetaOdd.lean +++ b/Mathlib/NumberTheory/LSeries/HurwitzZetaOdd.lean @@ -547,11 +547,9 @@ lemma hasSum_nat_sinZeta (a : ℝ) {s : ℂ} (hs : 1 < re s) : /-- Reformulation of `hasSum_nat_sinZeta` using `LSeriesHasSum`. -/ lemma LSeriesHasSum_sin (a : ℝ) {s : ℂ} (hs : 1 < re s) : - LSeriesHasSum (Real.sin <| 2 * π * a * ·) s (sinZeta a s) := by - refine (hasSum_nat_sinZeta a hs).congr_fun (fun n ↦ ?_) - rcases eq_or_ne n 0 with rfl | hn - · rw [LSeries.term_zero, Nat.cast_zero, mul_zero, Real.sin_zero, ofReal_zero, zero_div] - · apply LSeries.term_of_ne_zero hn + LSeriesHasSum (Real.sin <| 2 * π * a * ·) s (sinZeta a s) := + (hasSum_nat_sinZeta a hs).congr_fun + (LSeries.term_of_ne_zero' (ne_zero_of_one_lt_re hs) _) /-- The trivial zeroes of the odd Hurwitz zeta function. -/ theorem hurwitzZetaOdd_neg_two_mul_nat_sub_one (a : UnitAddCircle) (n : ℕ) : diff --git a/Mathlib/NumberTheory/LSeries/RiemannZeta.lean b/Mathlib/NumberTheory/LSeries/RiemannZeta.lean index e62b2028ff8b0..bcc35496bf6f6 100644 --- a/Mathlib/NumberTheory/LSeries/RiemannZeta.lean +++ b/Mathlib/NumberTheory/LSeries/RiemannZeta.lean @@ -158,7 +158,7 @@ def RiemannHypothesis : Prop := ∀ (s : ℂ) (_ : riemannZeta s = 0) (_ : ¬∃ n : ℕ, s = -2 * (n + 1)) (_ : s ≠ 1), s.re = 1 / 2 /-! -## Relating the Mellin transform to the Dirichlet series +## Relating the Mellin transform to the Dirichlet series -/ theorem completedZeta_eq_tsum_of_one_lt_re {s : ℂ} (hs : 1 < re s) : @@ -182,7 +182,7 @@ theorem zeta_eq_tsum_one_div_nat_cpow {s : ℂ} (hs : 1 < re s) : ofReal_one] using (hasSum_nat_cosZeta 0 hs).tsum_eq.symm /-- Alternate formulation of `zeta_eq_tsum_one_div_nat_cpow` with a `+ 1` (to avoid relying -on mathlib's conventions for `0 ^ s`). -/ +on mathlib's conventions for `0 ^ s`). -/ theorem zeta_eq_tsum_one_div_nat_add_one_cpow {s : ℂ} (hs : 1 < re s) : riemannZeta s = ∑' n : ℕ, 1 / (n + 1 : ℂ) ^ s := by have := zeta_eq_tsum_one_div_nat_cpow hs diff --git a/Mathlib/NumberTheory/LSeries/ZMod.lean b/Mathlib/NumberTheory/LSeries/ZMod.lean new file mode 100644 index 0000000000000..d7727a8fcffd7 --- /dev/null +++ b/Mathlib/NumberTheory/LSeries/ZMod.lean @@ -0,0 +1,200 @@ +/- +Copyright (c) 2024 David Loeffler. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: David Loeffler +-/ + +import Mathlib.Analysis.Fourier.ZMod +import Mathlib.Analysis.NormedSpace.Connected +import Mathlib.LinearAlgebra.Dimension.DivisionRing +import Mathlib.NumberTheory.LSeries.RiemannZeta +import Mathlib.Topology.Algebra.Module.Cardinality + +/-! +# L-series of functions on `ZMod N` + +We show that if `N` is a positive integer and `Φ : ZMod N → ℂ`, then the L-series of `Φ` has +analytic continuation (away from a pole at `s = 1` if `∑ j, Φ j ≠ 0`). + +The most familiar case is when `Φ` is a Dirichlet character, but the results here are valid +for general functions; for the specific case of Dirichlet characters see +`Mathlib.NumberTheory.LSeries.DirichletContinuation`. + +## Main definitions + +* `ZMod.LFunction Φ s`: the meromorphic continuation of the function `∑ n : ℕ, Φ n * n ^ (-s)`. + +## Main theorems + +* `ZMod.LFunction_eq_LSeries`: if `1 < re s` then the `LFunction` coincides with the naive + `LSeries`. +* `ZMod.differentiableAt_LFunction`: `ZMod.LFunction Φ` is differentiable at `s ∈ ℂ` if either + `s ≠ 1` or `∑ j, Φ j = 0`. +* `ZMod.LFunction_one_sub`: the functional equation relating `LFunction Φ (1 - s)` to + `LFunction (𝓕 Φ) s`, where `𝓕` is the Fourier transform. +-/ + +open HurwitzZeta Complex ZMod Finset Classical Topology Filter + +open scoped Real + +namespace ZMod + +variable {N : ℕ} [NeZero N] + +/-- If `Φ` is a periodic function, then the L-series of `Φ` converges for `1 < re s`. -/ +lemma LSeriesSummable_of_one_lt_re (Φ : ZMod N → ℂ) {s : ℂ} (hs : 1 < re s) : + LSeriesSummable (Φ ·) s := by + let c := max' _ <| univ_nonempty.image (Complex.abs ∘ Φ) + refine LSeriesSummable_of_bounded_of_one_lt_re (fun n _ ↦ le_max' _ _ ?_) (m := c) hs + exact mem_image_of_mem _ (mem_univ _) + +/-- +The unique meromorphic function `ℂ → ℂ` which agrees with `∑' n : ℕ, Φ n / n ^ s` wherever the +latter is convergent. This is constructed as a linear combination of Hurwitz zeta functions. + +Note that this is not the same as `LSeries Φ`: they agree in the convergence range, but +`LSeries Φ s` is defined to be `0` if `re s ≤ 1`. + -/ +noncomputable def LFunction (Φ : ZMod N → ℂ) (s : ℂ) : ℂ := + N ^ (-s) * ∑ j : ZMod N, Φ j * hurwitzZeta (toAddCircle j) s + +/-- The L-function of a function on `ZMod 1` is a scalar multiple of the Riemann zeta function. -/ +lemma LFunction_modOne_eq (Φ : ZMod 1 → ℂ) (s : ℂ) : + LFunction Φ s = Φ 0 * riemannZeta s := by + simp only [LFunction, Nat.cast_one, one_cpow, ← singleton_eq_univ (0 : ZMod 1), sum_singleton, + map_zero, hurwitzZeta_zero, one_mul] + +/-- For `1 < re s` the congruence L-function agrees with the sum of the Dirichlet series. -/ +lemma LFunction_eq_LSeries (Φ : ZMod N → ℂ) {s : ℂ} (hs : 1 < re s) : + LFunction Φ s = LSeries (Φ ·) s := by + rw [LFunction, LSeries, mul_sum, Nat.sumByResidueClasses (LSeriesSummable_of_one_lt_re Φ hs) N] + congr 1 with j + have : (j.val / N : ℝ) ∈ Set.Icc 0 1 := Set.mem_Icc.mpr ⟨by positivity, + (div_le_one (Nat.cast_pos.mpr <| NeZero.pos _)).mpr <| Nat.cast_le.mpr (val_lt j).le⟩ + rw [toAddCircle_apply, ← (hasSum_hurwitzZeta_of_one_lt_re this hs).tsum_eq, ← mul_assoc, + ← tsum_mul_left] + congr 1 with m + -- The following manipulation is slightly delicate because `(x * y) ^ s = x ^ s * y ^ s` is + -- false for general complex `x`, `y`, but it is true if `x` and `y` are non-negative reals, so + -- we have to carefully juggle coercions `ℕ → ℝ → ℂ`. + calc N ^ (-s) * Φ j * (1 / (m + (j.val / N : ℝ)) ^ s) + _ = Φ j * (N ^ (-s) * (1 / (m + (j.val / N : ℝ)) ^ s)) := by + rw [← mul_assoc, mul_comm _ (Φ _)] + _ = Φ j * (1 / (N : ℝ) ^ s * (1 / ((j.val + N * m) / N : ℝ) ^ s)) := by + simp only [cpow_neg, ← one_div, ofReal_div, ofReal_natCast, add_comm, add_div, ofReal_add, + ofReal_mul, mul_div_cancel_left₀ (m : ℂ) (Nat.cast_ne_zero.mpr (NeZero.ne N))] + _ = Φ j / ((N : ℝ) * ((j.val + N * m) / N : ℝ)) ^ s := by -- this is the delicate step! + rw [one_div_mul_one_div, mul_one_div, mul_cpow_ofReal_nonneg] <;> positivity + _ = Φ j / (N * (j.val + N * m) / N) ^ s := by + simp only [ofReal_natCast, ofReal_div, ofReal_add, ofReal_mul, mul_div_assoc] + _ = Φ j / (j.val + N * m) ^ s := by + rw [mul_div_cancel_left₀ _ (Nat.cast_ne_zero.mpr (NeZero.ne N))] + _ = Φ ↑(j.val + N * m) / (↑(j.val + N * m)) ^ s := by + simp only [Nat.cast_add, Nat.cast_mul, natCast_zmod_val, natCast_self, zero_mul, add_zero] + _ = LSeries.term (Φ ·) s (j.val + N * m) := by + rw [LSeries.term_of_ne_zero' (ne_zero_of_one_lt_re hs)] + +lemma differentiableAt_LFunction (Φ : ZMod N → ℂ) (s : ℂ) (hs : s ≠ 1 ∨ ∑ j, Φ j = 0) : + DifferentiableAt ℂ (LFunction Φ) s := by + apply (differentiable_neg.const_cpow (Or.inl <| NeZero.ne _) s).mul + rcases ne_or_eq s 1 with hs' | rfl + · exact .sum fun j _ ↦ (differentiableAt_hurwitzZeta _ hs').const_mul _ + · have := DifferentiableAt.sum (u := univ) fun j _ ↦ + (differentiableAt_hurwitzZeta_sub_one_div (toAddCircle j)).const_mul (Φ j) + simpa only [mul_sub, sum_sub_distrib, ← sum_mul, hs.neg_resolve_left rfl, zero_mul, sub_zero] + +lemma differentiable_LFunction_of_sum_zero {Φ : ZMod N → ℂ} (hΦ : ∑ j, Φ j = 0) : + Differentiable ℂ (LFunction Φ) := + fun s ↦ differentiableAt_LFunction Φ s (Or.inr hΦ) + +/-- The L-function of `Φ` has a residue at `s = 1` equal to the average value of `Φ`. -/ +lemma LFunction_residue_one (Φ : ZMod N → ℂ) : + Tendsto (fun s ↦ (s - 1) * LFunction Φ s) (𝓝[≠] 1) (𝓝 (∑ j, Φ j / N)) := by + simp only [sum_div, LFunction, mul_sum] + refine tendsto_finset_sum _ fun j _ ↦ ?_ + rw [(by ring : Φ j / N = Φ j * (1 / N * 1)), one_div, ← cpow_neg_one] + simp only [show ∀ a b c d : ℂ, a * (b * (c * d)) = c * (b * (a * d)) by intros; ring] + refine tendsto_const_nhds.mul (.mul ?_ <| hurwitzZeta_residue_one _) + exact ((continuous_neg.const_cpow (Or.inl <| NeZero.ne _)).tendsto _).mono_left + nhdsWithin_le_nhds + +/-- +The `LFunction` of the function `x ↦ e (j * x)`, where `e : ZMod N → ℂ` is the standard additive +character, is `expZeta (j / N)`. + +Note this is not at all obvious from the definitions, and we prove it by analytic continuation +from the convergence range. +-/ +lemma LFunction_stdAddChar_eq_expZeta (j : ZMod N) (s : ℂ) (hjs : j ≠ 0 ∨ s ≠ 1) : + LFunction (fun k ↦ stdAddChar (j * k)) s = expZeta (ZMod.toAddCircle j) s := by + let U := if j = 0 then {z : ℂ | z ≠ 1} else Set.univ -- region of analyticity of both functions + let V := {z : ℂ | 1 < re z} -- convergence region + have hUo : IsOpen U := by + by_cases h : j = 0 + · simpa only [h, ↓reduceIte, U] using isOpen_compl_singleton + · simp only [h, ↓reduceIte, isOpen_univ, U] + let f := LFunction (fun k ↦ stdAddChar (j * k)) + let g := expZeta (toAddCircle j) + have hU {u} : u ∈ U ↔ u ≠ 1 ∨ j ≠ 0 := by simp only [Set.mem_ite_univ_right, U]; tauto + -- hypotheses for uniqueness of analytic continuation + have hf : AnalyticOn ℂ f U := by + refine DifferentiableOn.analyticOn (fun u hu ↦ ?_) hUo + refine (differentiableAt_LFunction _ _ ((hU.mp hu).imp_right fun h ↦ ?_)).differentiableWithinAt + simp only [mul_comm j, AddChar.sum_mulShift _ (isPrimitive_stdAddChar _), h, + ↓reduceIte, CharP.cast_eq_zero, or_true] + have hg : AnalyticOn ℂ g U := by + refine DifferentiableOn.analyticOn (fun u hu ↦ ?_) hUo + refine (differentiableAt_expZeta _ _ ((hU.mp hu).imp_right fun h ↦ ?_)).differentiableWithinAt + rwa [ne_eq, toAddCircle_eq_zero] + have hUc : IsPreconnected U := by + by_cases h : j = 0 + · simpa only [h, ↓reduceIte, U] using + (isConnected_compl_singleton_of_one_lt_rank (by simp) _).isPreconnected + · simpa only [h, ↓reduceIte, U] using isPreconnected_univ + have hV : V ∈ 𝓝 2 := (continuous_re.isOpen_preimage _ isOpen_Ioi).mem_nhds (by simp) + have hUmem : 2 ∈ U := by simp [U] + have hUmem' : s ∈ U := hU.mpr hjs.symm + -- apply uniqueness result + refine hf.eqOn_of_preconnected_of_eventuallyEq hg hUc hUmem ?_ hUmem' + -- now remains to prove equality on `1 < re s` + filter_upwards [hV] with z hz + dsimp only [f, g] + rw [toAddCircle_apply, ← (hasSum_expZeta_of_one_lt_re (j.val / N) hz).tsum_eq, + LFunction_eq_LSeries _ hz, LSeries] + congr 1 with n + rw [LSeries.term_of_ne_zero' (ne_zero_of_one_lt_re hz), ofReal_div, ofReal_natCast, + ofReal_natCast, mul_assoc, div_mul_eq_mul_div, stdAddChar_apply] + have := ZMod.toCircle_intCast (N := N) (j.val * n) + conv_rhs at this => rw [Int.cast_mul, Int.cast_natCast, Int.cast_natCast, mul_div_assoc] + rw [← this, Int.cast_mul, Int.cast_natCast, Int.cast_natCast, natCast_zmod_val] + +/-- Explicit formula for the L-function of `𝓕 Φ`, where `𝓕` is the discrete Fourier transform. -/ +lemma LFunction_dft (Φ : ZMod N → ℂ) {s : ℂ} (hs : s ≠ 1) : + LFunction (𝓕 Φ) s = ∑ j : ZMod N, Φ j * expZeta (toAddCircle (-j)) s := by + simp only [← LFunction_stdAddChar_eq_expZeta _ _ (Or.inr hs), LFunction, mul_sum] + rw [sum_comm, dft_def] + simp only [sum_mul, mul_sum, Circle.smul_def, smul_eq_mul, stdAddChar_apply, ← mul_assoc] + congr 1 with j + congr 1 with k + rw [mul_assoc (Φ _), mul_comm (Φ _), neg_mul] + +/-- Functional equation for `ZMod` L-functions, in terms of discrete Fourier transform. -/ +theorem LFunction_one_sub (Φ : ZMod N → ℂ) {s : ℂ} (hs : ∀ (n : ℕ), s ≠ -↑n) (hs' : s ≠ 1) : + LFunction Φ (1 - s) = N ^ (s - 1) * (2 * π) ^ (-s) * Gamma s * + (cexp (π * I * s / 2) * LFunction (𝓕 Φ) s + + cexp (-π * I * s / 2) * LFunction (𝓕 fun x ↦ Φ (-x)) s) := by + rw [LFunction] + simp only [hurwitzZeta_one_sub _ hs (Or.inr hs'), mul_assoc _ _ (Gamma s)] + -- get rid of Gamma terms and power of N + generalize (2 * π) ^ (-s) * Gamma s = C + simp_rw [← mul_assoc, mul_comm _ C, mul_assoc, ← mul_sum, ← mul_assoc, mul_comm _ C, mul_assoc, + neg_sub] + congr 2 + -- now gather sum terms + rw [LFunction_dft _ hs', LFunction_dft _ hs'] + conv_rhs => enter [2, 2]; rw [← (Equiv.neg _).sum_comp _ _ (by simp), Equiv.neg_apply] + simp_rw [neg_neg, mul_sum, ← sum_add_distrib, ← mul_assoc, mul_comm _ (Φ _), mul_assoc, + ← mul_add, map_neg, add_comm] + +end ZMod diff --git a/Mathlib/NumberTheory/Liouville/LiouvilleWith.lean b/Mathlib/NumberTheory/Liouville/LiouvilleWith.lean index ac2e9e02f07f7..45980956c089e 100644 --- a/Mathlib/NumberTheory/Liouville/LiouvilleWith.lean +++ b/Mathlib/NumberTheory/Liouville/LiouvilleWith.lean @@ -103,7 +103,7 @@ theorem frequently_lt_rpow_neg (h : LiouvilleWith p x) (hlt : q < p) : refine ⟨m, hne, hlt.trans <| (div_lt_iff <| rpow_pos_of_pos hn _).2 ?_⟩ rwa [mul_comm, ← rpow_add hn, ← sub_eq_add_neg] -/-- The product of a Liouville number and a nonzero rational number is again a Liouville number. -/ +/-- The product of a Liouville number and a nonzero rational number is again a Liouville number. -/ theorem mul_rat (h : LiouvilleWith p x) (hr : r ≠ 0) : LiouvilleWith p (x * r) := by rcases h.exists_pos with ⟨C, _hC₀, hC⟩ refine ⟨r.den ^ p * (|r| * C), (tendsto_id.nsmul_atTop r.pos).frequently (hC.mono ?_)⟩ diff --git a/Mathlib/NumberTheory/Modular.lean b/Mathlib/NumberTheory/Modular.lean index e14a58682b9f1..812b9760b6b67 100644 --- a/Mathlib/NumberTheory/Modular.lean +++ b/Mathlib/NumberTheory/Modular.lean @@ -289,7 +289,7 @@ theorem exists_max_im : ∃ g : SL(2, ℤ), ∀ g' : SL(2, ℤ), (g' • z).im · exact normSq_denom_pos g z /-- Given `z : ℍ` and a bottom row `(c,d)`, among the `g : SL(2,ℤ)` with this bottom row, minimize - `|(g•z).re|`. -/ + `|(g•z).re|`. -/ theorem exists_row_one_eq_and_min_re {cd : Fin 2 → ℤ} (hcd : IsCoprime (cd 0) (cd 1)) : ∃ g : SL(2, ℤ), (↑ₘg) 1 = cd ∧ ∀ g' : SL(2, ℤ), (↑ₘg) 1 = (↑ₘg') 1 → |(g • z).re| ≤ |(g' • z).re| := by diff --git a/Mathlib/NumberTheory/ModularForms/EisensteinSeries/UniformConvergence.lean b/Mathlib/NumberTheory/ModularForms/EisensteinSeries/UniformConvergence.lean index 0b6f47e0894a7..2ff96d352b04b 100644 --- a/Mathlib/NumberTheory/ModularForms/EisensteinSeries/UniformConvergence.lean +++ b/Mathlib/NumberTheory/ModularForms/EisensteinSeries/UniformConvergence.lean @@ -56,7 +56,7 @@ lemma r1_pos : 0 < r1 z := by dsimp only [r1] positivity -/-- For `c, d ∈ ℝ` with `1 ≤ d ^ 2`, we have `r1 z ≤ |c * z + d| ^ 2`. -/ +/-- For `c, d ∈ ℝ` with `1 ≤ d ^ 2`, we have `r1 z ≤ |c * z + d| ^ 2`. -/ lemma r1_aux_bound (c : ℝ) {d : ℝ} (hd : 1 ≤ d ^ 2) : r1 z ≤ (c * z.re + d) ^ 2 + (c * z.im) ^ 2 := by have H1 : (c * z.re + d) ^ 2 + (c * z.im) ^ 2 = diff --git a/Mathlib/NumberTheory/ModularForms/JacobiTheta/Bounds.lean b/Mathlib/NumberTheory/ModularForms/JacobiTheta/Bounds.lean index f1931f2f1bb78..5af4baf5ed34a 100644 --- a/Mathlib/NumberTheory/ModularForms/JacobiTheta/Bounds.lean +++ b/Mathlib/NumberTheory/ModularForms/JacobiTheta/Bounds.lean @@ -7,7 +7,7 @@ Authors: David Loeffler import Mathlib.NumberTheory.ModularForms.JacobiTheta.TwoVariable /-! -# Asymptotic bounds for Jacobi theta functions +# Asymptotic bounds for Jacobi theta functions The goal of this file is to establish some technical lemmas about the asymptotics of the sums diff --git a/Mathlib/NumberTheory/ModularForms/JacobiTheta/TwoVariable.lean b/Mathlib/NumberTheory/ModularForms/JacobiTheta/TwoVariable.lean index 1740046e80dae..fb58da50e6f50 100644 --- a/Mathlib/NumberTheory/ModularForms/JacobiTheta/TwoVariable.lean +++ b/Mathlib/NumberTheory/ModularForms/JacobiTheta/TwoVariable.lean @@ -285,7 +285,7 @@ lemma jacobiTheta₂'_undef (z : ℂ) {τ : ℂ} (hτ : im τ ≤ 0) : jacobiThe exact not_lt.mpr hτ /-! -## Derivatives and continuity +## Derivatives and continuity -/ lemma hasFDerivAt_jacobiTheta₂ (z : ℂ) {τ : ℂ} (hτ : 0 < im τ) : @@ -373,7 +373,7 @@ lemma continuousAt_jacobiTheta₂' (z : ℂ) {τ : ℂ} (hτ : 0 < im τ) : · exact norm_jacobiTheta₂'_term_le hT (le_of_lt hz') (le_of_lt hτ') n /-! -## Periodicity and conjugation +## Periodicity and conjugation -/ /-- The two-variable Jacobi theta function is periodic in `τ` with period 2. -/ diff --git a/Mathlib/NumberTheory/MulChar/Basic.lean b/Mathlib/NumberTheory/MulChar/Basic.lean index f9a5760d1bcda..7c8c94626c010 100644 --- a/Mathlib/NumberTheory/MulChar/Basic.lean +++ b/Mathlib/NumberTheory/MulChar/Basic.lean @@ -454,7 +454,7 @@ lemma injective_ringHomComp {f : R' →+* R''} (hf : Function.Injective f) : lemma ringHomComp_eq_one_iff {f : R' →+* R''} (hf : Function.Injective f) {χ : MulChar R R'} : χ.ringHomComp f = 1 ↔ χ = 1 := by - conv_lhs => rw [← (show (1 : MulChar R R').ringHomComp f = 1 by ext; simp)] + conv_lhs => rw [← (show (1 : MulChar R R').ringHomComp f = 1 by ext; simp)] exact (injective_ringHomComp hf).eq_iff lemma ringHomComp_ne_one_iff {f : R' →+* R''} (hf : Function.Injective f) {χ : MulChar R R'} : diff --git a/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/Basic.lean b/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/Basic.lean index 5e0cd9a7ebdb7..ca7e6d3df61e9 100644 --- a/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/Basic.lean +++ b/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/Basic.lean @@ -278,7 +278,7 @@ def normAtPlace (w : InfinitePlace K) : (E K) →*₀ ℝ where map_one' := by simp map_mul' x y := by split_ifs <;> simp -theorem normAtPlace_nonneg (w : InfinitePlace K) (x : E K) : +theorem normAtPlace_nonneg (w : InfinitePlace K) (x : E K) : 0 ≤ normAtPlace w x := by rw [normAtPlace, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk] split_ifs <;> exact norm_nonneg _ diff --git a/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/ConvexBody.lean b/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/ConvexBody.lean index 6bf5d0e285fa8..2f899955077a2 100644 --- a/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/ConvexBody.lean +++ b/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/ConvexBody.lean @@ -195,8 +195,8 @@ theorem convexBodyLT'_convex : Convex ℝ (convexBodyLT' K f w₀) := by refine Convex.prod (convex_pi (fun _ _ => convex_ball _ _)) (convex_pi (fun _ _ => ?_)) split_ifs · simp_rw [abs_lt] - refine Convex.inter ((convex_halfspace_re_gt _).inter (convex_halfspace_re_lt _)) - ((convex_halfspace_im_gt _).inter (convex_halfspace_im_lt _)) + refine Convex.inter ((convex_halfspace_re_gt _).inter (convex_halfspace_re_lt _)) + ((convex_halfspace_im_gt _).inter (convex_halfspace_im_lt _)) · exact convex_ball _ _ open MeasureTheory MeasureTheory.Measure diff --git a/Mathlib/NumberTheory/NumberField/Embeddings.lean b/Mathlib/NumberTheory/NumberField/Embeddings.lean index d3f1dd0fe2cb7..d2421c79c769e 100644 --- a/Mathlib/NumberTheory/NumberField/Embeddings.lean +++ b/Mathlib/NumberTheory/NumberField/Embeddings.lean @@ -483,7 +483,7 @@ section NumberField variable [NumberField K] /-- The infinite part of the product formula : for `x ∈ K`, we have `Π_w ‖x‖_w = |norm(x)|` where -`‖·‖_w` is the normalized absolute value for `w`. -/ +`‖·‖_w` is the normalized absolute value for `w`. -/ theorem prod_eq_abs_norm (x : K) : ∏ w : InfinitePlace K, w x ^ mult w = abs (Algebra.norm ℚ x) := by convert (congr_arg Complex.abs (@Algebra.norm_eq_prod_embeddings ℚ _ _ _ _ ℂ _ _ _ _ _ x)).symm diff --git a/Mathlib/NumberTheory/NumberField/FractionalIdeal.lean b/Mathlib/NumberTheory/NumberField/FractionalIdeal.lean index 371f141943b5f..3d5cc80dab357 100644 --- a/Mathlib/NumberTheory/NumberField/FractionalIdeal.lean +++ b/Mathlib/NumberTheory/NumberField/FractionalIdeal.lean @@ -103,7 +103,7 @@ open Module /-- The absolute value of the determinant of the base change from `integralBasis` to `basisOfFractionalIdeal I` is equal to the norm of `I`. -/ -theorem det_basisOfFractionalIdeal_eq_absNorm (I : (FractionalIdeal (𝓞 K)⁰ K)ˣ) +theorem det_basisOfFractionalIdeal_eq_absNorm (I : (FractionalIdeal (𝓞 K)⁰ K)ˣ) (e : (Free.ChooseBasisIndex ℤ (𝓞 K)) ≃ (Free.ChooseBasisIndex ℤ I)) : |(integralBasis K).det ((basisOfFractionalIdeal K I).reindex e.symm)| = FractionalIdeal.absNorm I.1 := by diff --git a/Mathlib/NumberTheory/Padics/PadicIntegers.lean b/Mathlib/NumberTheory/Padics/PadicIntegers.lean index b7a318c97639b..5e22e36d43bd8 100644 --- a/Mathlib/NumberTheory/Padics/PadicIntegers.lean +++ b/Mathlib/NumberTheory/Padics/PadicIntegers.lean @@ -334,7 +334,7 @@ theorem norm_int_le_pow_iff_dvd {k : ℤ} {n : ℕ} : /-! ### Valuation on `ℤ_[p]` -/ -/-- `PadicInt.valuation` lifts the `p`-adic valuation on `ℚ` to `ℤ_[p]`. -/ +/-- `PadicInt.valuation` lifts the `p`-adic valuation on `ℚ` to `ℤ_[p]`. -/ def valuation (x : ℤ_[p]) := Padic.valuation (x : ℚ_[p]) diff --git a/Mathlib/NumberTheory/WellApproximable.lean b/Mathlib/NumberTheory/WellApproximable.lean index 46e2e5d3371ff..7b72f49ff60e8 100644 --- a/Mathlib/NumberTheory/WellApproximable.lean +++ b/Mathlib/NumberTheory/WellApproximable.lean @@ -248,7 +248,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto let f : 𝕊 → 𝕊 := fun y => (p : ℕ) • y suffices f '' A p ⊆ blimsup (fun n => approxAddOrderOf 𝕊 n (p * δ n)) atTop fun n => 0 < n ∧ p∤n by - apply (ergodic_nsmul hp.one_lt).ae_empty_or_univ_of_image_ae_le (hA₀ p) + apply (ergodic_nsmul hp.one_lt).ae_empty_or_univ_of_image_ae_le (hA₀ p).nullMeasurableSet apply (HasSubset.Subset.eventuallyLE this).congr EventuallyEq.rfl exact blimsup_thickening_mul_ae_eq μ (fun n => 0 < n ∧ p∤n) (fun n => {y | addOrderOf y = n}) (Nat.cast_pos.mpr hp.pos) _ hδ @@ -261,7 +261,8 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto let f : 𝕊 → 𝕊 := fun y => p • y + x suffices f '' B p ⊆ blimsup (fun n => approxAddOrderOf 𝕊 n (p * δ n)) atTop fun n => 0 < n ∧ p∣∣n by - apply (ergodic_nsmul_add x hp.one_lt).ae_empty_or_univ_of_image_ae_le (hB₀ p) + apply (ergodic_nsmul_add x hp.one_lt).ae_empty_or_univ_of_image_ae_le + (hB₀ p).nullMeasurableSet apply (HasSubset.Subset.eventuallyLE this).congr EventuallyEq.rfl exact blimsup_thickening_mul_ae_eq μ (fun n => 0 < n ∧ p∣∣n) (fun n => {y | addOrderOf y = n}) (Nat.cast_pos.mpr hp.pos) _ hδ diff --git a/Mathlib/Order/Basic.lean b/Mathlib/Order/Basic.lean index 663f2c7b91967..22337e909a51a 100644 --- a/Mathlib/Order/Basic.lean +++ b/Mathlib/Order/Basic.lean @@ -442,7 +442,7 @@ theorem eq_of_forall_lt_iff [LinearOrder α] {a b : α} (h : ∀ c, c < a ↔ c theorem eq_of_forall_gt_iff [LinearOrder α] {a b : α} (h : ∀ c, a < c ↔ b < c) : a = b := (le_of_forall_lt' fun _ ↦ (h _).2).antisymm <| le_of_forall_lt' fun _ ↦ (h _).1 -/-- A symmetric relation implies two values are equal, when it implies they're less-equal. -/ +/-- A symmetric relation implies two values are equal, when it implies they're less-equal. -/ theorem rel_imp_eq_of_rel_imp_le [PartialOrder β] (r : α → α → Prop) [IsSymm α r] {f : α → β} (h : ∀ a b, r a b → f a ≤ f b) {a b : α} : r a b → f a = f b := fun hab ↦ le_antisymm (h a b hab) (h b a <| symm hab) diff --git a/Mathlib/Order/BoundedOrder.lean b/Mathlib/Order/BoundedOrder.lean index d4039a093f12d..eebe3d3ddcdd1 100644 --- a/Mathlib/Order/BoundedOrder.lean +++ b/Mathlib/Order/BoundedOrder.lean @@ -144,6 +144,9 @@ theorem StrictMono.apply_eq_top_iff (hf : StrictMono f) : f a = f ⊤ ↔ a = theorem StrictAnti.apply_eq_top_iff (hf : StrictAnti f) : f a = f ⊤ ↔ a = ⊤ := ⟨fun h => not_lt_top_iff.1 fun ha => (hf ha).ne' h, congr_arg _⟩ +lemma top_not_mem_iff {s : Set α} : ⊤ ∉ s ↔ ∀ x ∈ s, x < ⊤ := + ⟨fun h x hx ↦ Ne.lt_top (fun hx' : x = ⊤ ↦ h (hx' ▸ hx)), fun h h₀ ↦ (h ⊤ h₀).false⟩ + variable [Nontrivial α] theorem not_isMin_top : ¬IsMin (⊤ : α) := fun h => @@ -313,6 +316,9 @@ theorem StrictMono.apply_eq_bot_iff (hf : StrictMono f) : f a = f ⊥ ↔ a = theorem StrictAnti.apply_eq_bot_iff (hf : StrictAnti f) : f a = f ⊥ ↔ a = ⊥ := hf.dual.apply_eq_top_iff +lemma bot_not_mem_iff {s : Set α} : ⊥ ∉ s ↔ ∀ x ∈ s, ⊥ < x := + top_not_mem_iff (α := αᵒᵈ) + variable [Nontrivial α] theorem not_isMax_bot : ¬IsMax (⊥ : α) := diff --git a/Mathlib/Order/CompleteLattice.lean b/Mathlib/Order/CompleteLattice.lean index 9e27855231d95..3322b2a4fe92b 100644 --- a/Mathlib/Order/CompleteLattice.lean +++ b/Mathlib/Order/CompleteLattice.lean @@ -1719,3 +1719,5 @@ instance instCompleteLinearOrder : CompleteLinearOrder PUnit where top_sdiff := by intros; trivial end PUnit + +set_option linter.style.longFile 1900 diff --git a/Mathlib/Order/CompleteLatticeIntervals.lean b/Mathlib/Order/CompleteLatticeIntervals.lean index 44fa32da464fc..149df0ed5225d 100644 --- a/Mathlib/Order/CompleteLatticeIntervals.lean +++ b/Mathlib/Order/CompleteLatticeIntervals.lean @@ -52,7 +52,7 @@ theorem subset_sSup_def [Inhabited s] : rfl theorem subset_sSup_of_within [Inhabited s] {t : Set s} - (h' : t.Nonempty) (h'' : BddAbove t) (h : sSup ((↑) '' t : Set α) ∈ s) : + (h' : t.Nonempty) (h'' : BddAbove t) (h : sSup ((↑) '' t : Set α) ∈ s) : sSup ((↑) '' t : Set α) = (@sSup s _ t : α) := by simp [dif_pos, h, h', h''] theorem subset_sSup_emptyset [Inhabited s] : diff --git a/Mathlib/Order/ConditionallyCompleteLattice/Basic.lean b/Mathlib/Order/ConditionallyCompleteLattice/Basic.lean index 206708c8c5347..b65457aeeec04 100644 --- a/Mathlib/Order/ConditionallyCompleteLattice/Basic.lean +++ b/Mathlib/Order/ConditionallyCompleteLattice/Basic.lean @@ -155,7 +155,7 @@ every nonempty subset which is bounded below has an infimum. Typical examples are real numbers or natural numbers. To differentiate the statements from the corresponding statements in (unconditional) -complete lattices, we prefix sInf and subₛ by a c everywhere. The same statements should +complete lattices, we prefix `sInf` and `sSup` by a `c` everywhere. The same statements should hold in both worlds, sometimes with additional assumptions of nonemptiness or boundedness. -/ class ConditionallyCompleteLattice (α : Type*) extends Lattice α, SupSet α, InfSet α where @@ -175,7 +175,7 @@ every nonempty subset which is bounded below has an infimum. Typical examples are real numbers or natural numbers. To differentiate the statements from the corresponding statements in (unconditional) -complete linear orders, we prefix sInf and sSup by a c everywhere. The same statements should +complete linear orders, we prefix `sInf` and `sSup` by a `c` everywhere. The same statements should hold in both worlds, sometimes with additional assumptions of nonemptiness or boundedness. -/ class ConditionallyCompleteLinearOrder (α : Type*) extends ConditionallyCompleteLattice α where @@ -215,7 +215,7 @@ every nonempty subset which is bounded above has a supremum, and every nonempty bounded below) has an infimum. A typical example is the natural numbers. To differentiate the statements from the corresponding statements in (unconditional) -complete linear orders, we prefix `sInf` and `sSup` by a c everywhere. The same statements should +complete linear orders, we prefix `sInf` and `sSup` by a `c` everywhere. The same statements should hold in both worlds, sometimes with additional assumptions of nonemptiness or boundedness. -/ class ConditionallyCompleteLinearOrderBot (α : Type*) extends ConditionallyCompleteLinearOrder α, @@ -591,12 +591,12 @@ theorem exists_between_of_forall_le (sne : s.Nonempty) (tne : t.Nonempty) (hst : ∀ x ∈ s, ∀ y ∈ t, x ≤ y) : (upperBounds s ∩ lowerBounds t).Nonempty := ⟨sInf t, fun x hx => le_csInf tne <| hst x hx, fun _ hy => csInf_le (sne.mono hst) hy⟩ -/-- The supremum of a singleton is the element of the singleton-/ +/-- The supremum of a singleton is the element of the singleton -/ @[simp] theorem csSup_singleton (a : α) : sSup {a} = a := isGreatest_singleton.csSup_eq -/-- The infimum of a singleton is the element of the singleton-/ +/-- The infimum of a singleton is the element of the singleton -/ @[simp] theorem csInf_singleton (a : α) : sInf {a} = a := isLeast_singleton.csInf_eq @@ -698,18 +698,18 @@ theorem csSup_Ioc (h : a < b) : sSup (Ioc a b) = b := theorem csSup_Ioo [DenselyOrdered α] (h : a < b) : sSup (Ioo a b) = b := (isLUB_Ioo h).csSup_eq (nonempty_Ioo.2 h) -/-- The indexed supremum of a function is bounded above by a uniform bound-/ +/-- The indexed supremum of a function is bounded above by a uniform bound -/ theorem ciSup_le [Nonempty ι] {f : ι → α} {c : α} (H : ∀ x, f x ≤ c) : iSup f ≤ c := csSup_le (range_nonempty f) (by rwa [forall_mem_range]) -/-- The indexed supremum of a function is bounded below by the value taken at one point-/ +/-- The indexed supremum of a function is bounded below by the value taken at one point -/ theorem le_ciSup {f : ι → α} (H : BddAbove (range f)) (c : ι) : f c ≤ iSup f := le_csSup H (mem_range_self _) theorem le_ciSup_of_le {f : ι → α} (H : BddAbove (range f)) (c : ι) (h : a ≤ f c) : a ≤ iSup f := le_trans h (le_ciSup H c) -/-- The indexed supremum of two functions are comparable if the functions are pointwise comparable-/ +/-- The indexed suprema of two functions are comparable if the functions are pointwise comparable -/ theorem ciSup_mono {f g : ι → α} (B : BddAbove (range g)) (H : ∀ x, f x ≤ g x) : iSup f ≤ iSup g := by cases isEmpty_or_nonempty ι @@ -720,15 +720,15 @@ theorem le_ciSup_set {f : β → α} {s : Set β} (H : BddAbove (f '' s)) {c : f c ≤ ⨆ i : s, f i := (le_csSup H <| mem_image_of_mem f hc).trans_eq sSup_image' -/-- The indexed infimum of two functions are comparable if the functions are pointwise comparable-/ +/-- The indexed infimum of two functions are comparable if the functions are pointwise comparable -/ theorem ciInf_mono {f g : ι → α} (B : BddBelow (range f)) (H : ∀ x, f x ≤ g x) : iInf f ≤ iInf g := ciSup_mono (α := αᵒᵈ) B H -/-- The indexed minimum of a function is bounded below by a uniform lower bound-/ +/-- The indexed minimum of a function is bounded below by a uniform lower bound -/ theorem le_ciInf [Nonempty ι] {f : ι → α} {c : α} (H : ∀ x, c ≤ f x) : c ≤ iInf f := ciSup_le (α := αᵒᵈ) H -/-- The indexed infimum of a function is bounded above by the value taken at one point-/ +/-- The indexed infimum of a function is bounded above by the value taken at one point -/ theorem ciInf_le {f : ι → α} (H : BddBelow (range f)) (c : ι) : iInf f ≤ f c := le_ciSup (α := αᵒᵈ) H c @@ -1639,3 +1639,5 @@ lemma iInf_coe_lt_top : ⨅ i, (f i : WithTop α) < ⊤ ↔ Nonempty ι := by end WithTop end WithTopBot + +set_option linter.style.longFile 1700 diff --git a/Mathlib/Order/Directed.lean b/Mathlib/Order/Directed.lean index 8ab4e604c1f95..311f396d99159 100644 --- a/Mathlib/Order/Directed.lean +++ b/Mathlib/Order/Directed.lean @@ -40,7 +40,7 @@ variable {α : Type u} {β : Type v} {ι : Sort w} (r r' s : α → α → Prop) local infixl:50 " ≼ " => r /-- A family of elements of α is directed (with respect to a relation `≼` on α) - if there is a member of the family `≼`-above any pair in the family. -/ + if there is a member of the family `≼`-above any pair in the family. -/ def Directed (f : ι → α) := ∀ x y, ∃ z, f x ≼ f z ∧ f y ≼ f z diff --git a/Mathlib/Order/Filter/AtTopBot.lean b/Mathlib/Order/Filter/AtTopBot.lean index b108dbc04048d..f2419d48383d7 100644 --- a/Mathlib/Order/Filter/AtTopBot.lean +++ b/Mathlib/Order/Filter/AtTopBot.lean @@ -1321,6 +1321,18 @@ theorem prod_atTop_atTop_eq [Preorder α] [Preorder β] : · subsingleton simpa [atTop, prod_iInf_left, prod_iInf_right, iInf_prod] using iInf_comm +lemma tendsto_finset_prod_atTop : + Tendsto (fun (p : Finset ι × Finset ι') ↦ p.1 ×ˢ p.2) atTop atTop := by + classical + apply Monotone.tendsto_atTop_atTop + · intro p q hpq + simpa using Finset.product_subset_product hpq.1 hpq.2 + · intro b + use (Finset.image Prod.fst b, Finset.image Prod.snd b) + rintro ⟨d1, d2⟩ hd + simp only [Finset.mem_product, Finset.mem_image, Prod.exists, exists_and_right, exists_eq_right] + exact ⟨⟨d2, hd⟩, ⟨d1, hd⟩⟩ + theorem prod_atBot_atBot_eq [Preorder α] [Preorder β] : (atBot : Filter α) ×ˢ (atBot : Filter β) = (atBot : Filter (α × β)) := @prod_atTop_atTop_eq αᵒᵈ βᵒᵈ _ _ @@ -1831,3 +1843,5 @@ filters `atTop.map (fun s ↦ ∑ i ∈ s, f (g i))` and `atTop.map (fun s ↦ This lemma is used to prove the equality `∑' x, f (g x) = ∑' y, f y` under the same assumptions. -/ add_decl_doc Function.Injective.map_atTop_finset_sum_eq + +set_option linter.style.longFile 2000 diff --git a/Mathlib/Order/Filter/Bases.lean b/Mathlib/Order/Filter/Bases.lean index dee2d71c9f043..b265a017c0756 100644 --- a/Mathlib/Order/Filter/Bases.lean +++ b/Mathlib/Order/Filter/Bases.lean @@ -671,7 +671,7 @@ theorem hasBasis_iInf_principal {s : ι → Set α} (h : Directed (· ≥ ·) s) simpa only [true_and] using mem_iInf_of_directed (h.mono_comp monotone_principal.dual) t⟩ /-- If `s : ι → Set α` is an indexed family of sets, then finite intersections of `s i` form a basis -of `⨅ i, 𝓟 (s i)`. -/ +of `⨅ i, 𝓟 (s i)`. -/ theorem hasBasis_iInf_principal_finite {ι : Type*} (s : ι → Set α) : (⨅ i, 𝓟 (s i)).HasBasis (fun t : Set ι => t.Finite) fun t => ⋂ i ∈ t, s i := by refine ⟨fun U => (mem_iInf_finite _).trans ?_⟩ diff --git a/Mathlib/Order/Filter/Basic.lean b/Mathlib/Order/Filter/Basic.lean index effd009d22e4c..0349952c57f48 100644 --- a/Mathlib/Order/Filter/Basic.lean +++ b/Mathlib/Order/Filter/Basic.lean @@ -2922,3 +2922,5 @@ lemma compl_mem_comk {p : Set α → Prop} {he hmono hunion s} : simp end Filter + +set_option linter.style.longFile 3000 diff --git a/Mathlib/Order/Filter/Ultrafilter.lean b/Mathlib/Order/Filter/Ultrafilter.lean index d73a8c74c3df8..192de04a2bd4f 100644 --- a/Mathlib/Order/Filter/Ultrafilter.lean +++ b/Mathlib/Order/Filter/Ultrafilter.lean @@ -115,7 +115,7 @@ theorem diff_mem_iff (f : Ultrafilter α) : s \ t ∈ f ↔ s ∈ f ∧ t ∉ f inter_mem_iff.trans <| and_congr Iff.rfl compl_mem_iff_not_mem /-- If `sᶜ ∉ f ↔ s ∈ f`, then `f` is an ultrafilter. The other implication is given by -`Ultrafilter.compl_not_mem_iff`. -/ +`Ultrafilter.compl_not_mem_iff`. -/ def ofComplNotMemIff (f : Filter α) (h : ∀ s, sᶜ ∉ f ↔ s ∈ f) : Ultrafilter α where toFilter := f neBot' := ⟨fun hf => by simp [hf] at h⟩ diff --git a/Mathlib/Order/Hom/Basic.lean b/Mathlib/Order/Hom/Basic.lean index 2406d1a0a7c88..5a3d3bd055a2d 100644 --- a/Mathlib/Order/Hom/Basic.lean +++ b/Mathlib/Order/Hom/Basic.lean @@ -426,7 +426,7 @@ def coeFnHom : (α →o β) →o α → β where monotone' _ _ h := h /-- Function application `fun f => f a` (for fixed `a`) is a monotone function from the -monotone function space `α →o β` to `β`. See also `Pi.evalOrderHom`. -/ +monotone function space `α →o β` to `β`. See also `Pi.evalOrderHom`. -/ @[simps! (config := .asFn)] def apply (x : α) : (α →o β) →o β := (Pi.evalOrderHom x).comp coeFnHom @@ -447,7 +447,7 @@ def piIso : (α →o ∀ i, π i) ≃o ∀ i, α →o π i where right_inv _ := rfl map_rel_iff' := forall_swap -/-- `Subtype.val` as a bundled monotone function. -/ +/-- `Subtype.val` as a bundled monotone function. -/ @[simps (config := .asFn)] def Subtype.val (p : α → Prop) : Subtype p →o α := ⟨_root_.Subtype.val, fun _ _ h => h⟩ diff --git a/Mathlib/Order/Hom/Lattice.lean b/Mathlib/Order/Hom/Lattice.lean index a6513d866da90..94af3f7566504 100644 --- a/Mathlib/Order/Hom/Lattice.lean +++ b/Mathlib/Order/Hom/Lattice.lean @@ -474,6 +474,24 @@ theorem bot_apply [Bot β] (a : α) : (⊥ : SupHom α β) a = ⊥ := theorem top_apply [Top β] (a : α) : (⊤ : SupHom α β) a = ⊤ := rfl +/-- `Subtype.val` as a `SupHom`. -/ +def subtypeVal {P : β → Prop} + (Psup : ∀ ⦃x y : β⦄, P x → P y → P (x ⊔ y)) : + letI := Subtype.semilatticeSup Psup + SupHom {x : β // P x} β := + letI := Subtype.semilatticeSup Psup + .mk Subtype.val (by simp) + +@[simp] +lemma subtypeVal_apply {P : β → Prop} + (Psup : ∀ ⦃x y : β⦄, P x → P y → P (x ⊔ y)) (x : {x : β // P x}) : + subtypeVal Psup x = x := rfl + +@[simp] +lemma subtypeVal_coe {P : β → Prop} + (Psup : ∀ ⦃x y : β⦄, P x → P y → P (x ⊔ y)) : + ⇑(subtypeVal Psup) = Subtype.val := rfl + end SupHom /-! ### Infimum homomorphisms -/ @@ -632,6 +650,24 @@ theorem bot_apply [Bot β] (a : α) : (⊥ : InfHom α β) a = ⊥ := theorem top_apply [Top β] (a : α) : (⊤ : InfHom α β) a = ⊤ := rfl +/-- `Subtype.val` as an `InfHom`. -/ +def subtypeVal {P : β → Prop} + (Pinf : ∀ ⦃x y : β⦄, P x → P y → P (x ⊓ y)) : + letI := Subtype.semilatticeInf Pinf + InfHom {x : β // P x} β := + letI := Subtype.semilatticeInf Pinf + .mk Subtype.val (by simp) + +@[simp] +lemma subtypeVal_apply {P : β → Prop} + (Pinf : ∀ ⦃x y : β⦄, P x → P y → P (x ⊓ y)) (x : {x : β // P x}) : + subtypeVal Pinf x = x := rfl + +@[simp] +lemma subtypeVal_coe {P : β → Prop} + (Pinf : ∀ ⦃x y : β⦄, P x → P y → P (x ⊓ y)) : + ⇑(subtypeVal Pinf) = Subtype.val := rfl + end InfHom /-! ### Finitary supremum homomorphisms -/ @@ -762,6 +798,26 @@ theorem sup_apply (f g : SupBotHom α β) (a : α) : (f ⊔ g) a = f a ⊔ g a : theorem bot_apply (a : α) : (⊥ : SupBotHom α β) a = ⊥ := rfl +/-- `Subtype.val` as a `SupBotHom`. -/ +def subtypeVal {P : β → Prop} + (Pbot : P ⊥) (Psup : ∀ ⦃x y : β⦄, P x → P y → P (x ⊔ y)) : + letI := Subtype.orderBot Pbot + letI := Subtype.semilatticeSup Psup + SupBotHom {x : β // P x} β := + letI := Subtype.orderBot Pbot + letI := Subtype.semilatticeSup Psup + .mk (SupHom.subtypeVal Psup) (by simp [Subtype.coe_bot Pbot]) + +@[simp] +lemma subtypeVal_apply {P : β → Prop} + (Pbot : P ⊥) (Psup : ∀ ⦃x y : β⦄, P x → P y → P (x ⊔ y)) (x : {x : β // P x}) : + subtypeVal Pbot Psup x = x := rfl + +@[simp] +lemma subtypeVal_coe {P : β → Prop} + (Pbot : P ⊥) (Psup : ∀ ⦃x y : β⦄, P x → P y → P (x ⊔ y)) : + ⇑(subtypeVal Pbot Psup) = Subtype.val := rfl + end SupBotHom /-! ### Finitary infimum homomorphisms -/ @@ -893,6 +949,26 @@ theorem inf_apply (f g : InfTopHom α β) (a : α) : (f ⊓ g) a = f a ⊓ g a : theorem top_apply (a : α) : (⊤ : InfTopHom α β) a = ⊤ := rfl +/-- `Subtype.val` as an `InfTopHom`. -/ +def subtypeVal {P : β → Prop} + (Ptop : P ⊤) (Pinf : ∀ ⦃x y : β⦄, P x → P y → P (x ⊓ y)) : + letI := Subtype.orderTop Ptop + letI := Subtype.semilatticeInf Pinf + InfTopHom {x : β // P x} β := + letI := Subtype.orderTop Ptop + letI := Subtype.semilatticeInf Pinf + .mk (InfHom.subtypeVal Pinf) (by simp [Subtype.coe_top Ptop]) + +@[simp] +lemma subtypeVal_apply {P : β → Prop} + (Ptop : P ⊤) (Pinf : ∀ ⦃x y : β⦄, P x → P y → P (x ⊓ y)) (x : {x : β // P x}) : + subtypeVal Ptop Pinf x = x := rfl + +@[simp] +lemma subtypeVal_coe {P : β → Prop} + (Ptop : P ⊤) (Pinf : ∀ ⦃x y : β⦄, P x → P y → P (x ⊓ y)) : + ⇑(subtypeVal Ptop Pinf) = Subtype.val := rfl + end InfTopHom /-! ### Lattice homomorphisms -/ @@ -1013,6 +1089,25 @@ theorem cancel_left {g : LatticeHom β γ} {f₁ f₂ : LatticeHom α β} (hg : ⟨fun h => LatticeHom.ext fun a => hg <| by rw [← LatticeHom.comp_apply, h, LatticeHom.comp_apply], congr_arg _⟩ +/-- `Subtype.val` as a `LatticeHom`. -/ +def subtypeVal {P : β → Prop} + (Psup : ∀ ⦃x y⦄, P x → P y → P (x ⊔ y)) (Pinf : ∀ ⦃x y⦄, P x → P y → P (x ⊓ y)) : + letI := Subtype.lattice Psup Pinf + LatticeHom {x : β // P x} β := + letI := Subtype.lattice Psup Pinf + .mk (SupHom.subtypeVal Psup) (by simp) + +@[simp] +lemma subtypeVal_apply {P : β → Prop} + (Psup : ∀ ⦃x y⦄, P x → P y → P (x ⊔ y)) (Pinf : ∀ ⦃x y⦄, P x → P y → P (x ⊓ y)) + (x : {x : β // P x}) : + subtypeVal Psup Pinf x = x := rfl + +@[simp] +lemma subtypeVal_coe {P : β → Prop} + (Psup : ∀ ⦃x y⦄, P x → P y → P (x ⊔ y)) (Pinf : ∀ ⦃x y⦄, P x → P y → P (x ⊓ y)) : + ⇑(subtypeVal Psup Pinf) = Subtype.val := rfl + end LatticeHom namespace OrderHomClass @@ -1184,6 +1279,27 @@ theorem cancel_left {g : BoundedLatticeHom β γ} {f₁ f₂ : BoundedLatticeHom g.comp f₁ = g.comp f₂ ↔ f₁ = f₂ := ⟨fun h => ext fun a => hg <| by rw [← comp_apply, h, comp_apply], congr_arg _⟩ +/-- `Subtype.val` as a `BoundedLatticeHom`. -/ +def subtypeVal {P : β → Prop} (Pbot : P ⊥) (Ptop : P ⊤) + (Psup : ∀ ⦃x y⦄, P x → P y → P (x ⊔ y)) (Pinf : ∀ ⦃x y⦄, P x → P y → P (x ⊓ y)) : + letI := Subtype.lattice Psup Pinf + letI := Subtype.boundedOrder Pbot Ptop + BoundedLatticeHom {x : β // P x} β := + letI := Subtype.lattice Psup Pinf + letI := Subtype.boundedOrder Pbot Ptop + .mk (.subtypeVal Psup Pinf) (by simp [Subtype.coe_top Ptop]) (by simp [Subtype.coe_bot Pbot]) + +@[simp] +lemma subtypeVal_apply {P : β → Prop} + (Pbot : P ⊥) (Ptop : P ⊤) (Psup : ∀ ⦃x y⦄, P x → P y → P (x ⊔ y)) + (Pinf : ∀ ⦃x y⦄, P x → P y → P (x ⊓ y)) (x : {x : β // P x}) : + subtypeVal Pbot Ptop Psup Pinf x = x := rfl + +@[simp] +lemma subtypeVal_coe {P : β → Prop} (Pbot : P ⊥) (Ptop : P ⊤) + (Psup : ∀ ⦃x y⦄, P x → P y → P (x ⊔ y)) (Pinf : ∀ ⦃x y⦄, P x → P y → P (x ⊓ y)) : + ⇑(subtypeVal Pbot Ptop Psup Pinf) = Subtype.val := rfl + end BoundedLatticeHom /-! ### Dual homs -/ @@ -1660,3 +1776,5 @@ def withTopWithBot' [BoundedOrder β] (f : LatticeHom α β) : map_bot' := rfl end LatticeHom + +set_option linter.style.longFile 1800 diff --git a/Mathlib/Order/Interval/Finset/Basic.lean b/Mathlib/Order/Interval/Finset/Basic.lean index cd0f3a4b760b2..e0b90ecd39119 100644 --- a/Mathlib/Order/Interval/Finset/Basic.lean +++ b/Mathlib/Order/Interval/Finset/Basic.lean @@ -334,6 +334,12 @@ lemma nonempty_Ici : (Ici a).Nonempty := ⟨a, mem_Ici.2 le_rfl⟩ @[simp, aesop safe apply (rule_sets := [finsetNonempty])] lemma nonempty_Ioi : (Ioi a).Nonempty ↔ ¬ IsMax a := by simp [Finset.Nonempty] +theorem Ici_subset_Ici : Ici a ⊆ Ici b ↔ b ≤ a := by + simpa [← coe_subset] using Set.Ici_subset_Ici + +theorem Ioi_subset_Ioi (h : a ≤ b) : Ioi b ⊆ Ioi a := by + simpa [← coe_subset] using Set.Ioi_subset_Ioi h + variable [LocallyFiniteOrder α] theorem Icc_subset_Ici_self : Icc a b ⊆ Ici a := by @@ -363,6 +369,12 @@ variable [LocallyFiniteOrderBot α] @[simp] lemma nonempty_Iic : (Iic a).Nonempty := ⟨a, mem_Iic.2 le_rfl⟩ @[simp] lemma nonempty_Iio : (Iio a).Nonempty ↔ ¬ IsMin a := by simp [Finset.Nonempty] +theorem Iic_subset_Iic : Iic a ⊆ Iic b ↔ a ≤ b := by + simpa [← coe_subset] using Set.Iic_subset_Iic + +theorem Iio_subset_Iio (h : a ≤ b) : Iio a ⊆ Iio b := by + simpa [← coe_subset] using Set.Iio_subset_Iio h + variable [LocallyFiniteOrder α] theorem Icc_subset_Iic_self : Icc a b ⊆ Iic b := by diff --git a/Mathlib/Order/Interval/Set/Basic.lean b/Mathlib/Order/Interval/Set/Basic.lean index a8522056697d5..476e9db92cbb2 100644 --- a/Mathlib/Order/Interval/Set/Basic.lean +++ b/Mathlib/Order/Interval/Set/Basic.lean @@ -1650,3 +1650,5 @@ instance : NoMaxOrder (Set.Iio x) := exact ⟨⟨b, hb₂⟩, hb₁⟩⟩ end Dense + +set_option linter.style.longFile 1800 diff --git a/Mathlib/Order/IsWellOrderLimitElement.lean b/Mathlib/Order/IsWellOrderLimitElement.lean index 1628b90dac2f6..2d6bde7b9282b 100644 --- a/Mathlib/Order/IsWellOrderLimitElement.lean +++ b/Mathlib/Order/IsWellOrderLimitElement.lean @@ -25,7 +25,7 @@ section variable [IsWellOrder α (· < ·)] /-- Given an element `a : α` in a well ordered set, this is the successor of `a`, -i.e. the smallest element stricly greater than `a` if it exists (or `a` itself otherwise). -/ +i.e. the smallest element strictly greater than `a` if it exists (or `a` itself otherwise). -/ noncomputable def wellOrderSucc (a : α) : α := (IsWellFounded.wf (r := (· < ·))).succ a diff --git a/Mathlib/Order/KonigLemma.lean b/Mathlib/Order/KonigLemma.lean index 64ff1a4d6bd67..7e5c422c3fc04 100644 --- a/Mathlib/Order/KonigLemma.lean +++ b/Mathlib/Order/KonigLemma.lean @@ -69,7 +69,7 @@ theorem exists_orderEmbedding_covby_of_forall_covby_finite (hfin : ∀ (a : α), obtain ⟨f, hf⟩ := exists_seq_covby_of_forall_covby_finite hfin hb exact ⟨OrderEmbedding.ofStrictMono f (strictMono_nat_of_lt_succ (fun i ↦ (hf.2 i).lt)), hf⟩ -/-- A version of Kőnig's lemma where the sequence starts at the minimum of an infinite order. -/ +/-- A version of Kőnig's lemma where the sequence starts at the minimum of an infinite order. -/ theorem exists_orderEmbedding_covby_of_forall_covby_finite_of_bot [OrderBot α] [Infinite α] (hfin : ∀ (a : α), {x | a ⋖ x}.Finite) : ∃ f : ℕ ↪o α, f 0 = ⊥ ∧ ∀ i, f i ⋖ f (i+1) := exists_orderEmbedding_covby_of_forall_covby_finite hfin (by simpa using infinite_univ) diff --git a/Mathlib/Order/Lattice.lean b/Mathlib/Order/Lattice.lean index 26522df88f179..14c95550af930 100644 --- a/Mathlib/Order/Lattice.lean +++ b/Mathlib/Order/Lattice.lean @@ -196,7 +196,7 @@ instance : Std.Commutative (α := α) (· ⊔ ·) := ⟨sup_comm⟩ theorem sup_assoc (a b c : α) : a ⊔ b ⊔ c = a ⊔ (b ⊔ c) := eq_of_forall_ge_iff fun x => by simp only [sup_le_iff]; rw [and_assoc] -instance : Std.Associative (α := α) (· ⊔ ·) := ⟨sup_assoc⟩ +instance : Std.Associative (α := α) (· ⊔ ·) := ⟨sup_assoc⟩ theorem sup_left_right_swap (a b c : α) : a ⊔ b ⊔ c = c ⊔ b ⊔ a := by rw [sup_comm, sup_comm a, sup_assoc] diff --git a/Mathlib/Order/LiminfLimsup.lean b/Mathlib/Order/LiminfLimsup.lean index 2661fb80c53a6..4df96a9769fd9 100644 --- a/Mathlib/Order/LiminfLimsup.lean +++ b/Mathlib/Order/LiminfLimsup.lean @@ -1707,3 +1707,5 @@ lemma Antitone.isCoboundedUnder_ge_of_isCobounded {f : R → S} (f_decr : Antito Monotone.isCoboundedUnder_le_of_isCobounded (S := Sᵒᵈ) f_decr cobdd end frequently_bounded + +set_option linter.style.longFile 1800 diff --git a/Mathlib/Order/ModularLattice.lean b/Mathlib/Order/ModularLattice.lean index 5c8d4fa9e256e..76b1789fce3e3 100644 --- a/Mathlib/Order/ModularLattice.lean +++ b/Mathlib/Order/ModularLattice.lean @@ -237,7 +237,7 @@ theorem wellFounded_lt_exact_sequence {β γ : Type*} [PartialOrder β] [Preorde (InvImage.wf _ (h₁.wf.prod_lex h₂.wf))⟩ /-- A generalization of the theorem that if `N` is a submodule of `M` and - `N` and `M / N` are both Noetherian, then `M` is Noetherian. -/ + `N` and `M / N` are both Noetherian, then `M` is Noetherian. -/ theorem wellFounded_gt_exact_sequence {β γ : Type*} [Preorder β] [PartialOrder γ] [WellFoundedGT β] [WellFoundedGT γ] (K : α) (f₁ : β → α) (f₂ : α → β) (g₁ : γ → α) (g₂ : α → γ) (gci : GaloisCoinsertion f₁ f₂) diff --git a/Mathlib/Order/Monotone/Monovary.lean b/Mathlib/Order/Monotone/Monovary.lean index 8b2766ecaefea..4c25c914b2698 100644 --- a/Mathlib/Order/Monotone/Monovary.lean +++ b/Mathlib/Order/Monotone/Monovary.lean @@ -249,7 +249,7 @@ end PartialOrder variable [LinearOrder ι] /- Porting note: Due to a bug in `alias`, many of the below lemmas have dot notation removed in the -proof-/ +proof -/ protected theorem Monotone.monovary (hf : Monotone f) (hg : Monotone g) : Monovary f g := fun _ _ hij => hf (hg.reflect_lt hij).le diff --git a/Mathlib/Order/OmegaCompletePartialOrder.lean b/Mathlib/Order/OmegaCompletePartialOrder.lean index 91826bf421721..650b9313fdb80 100644 --- a/Mathlib/Order/OmegaCompletePartialOrder.lean +++ b/Mathlib/Order/OmegaCompletePartialOrder.lean @@ -729,7 +729,7 @@ instance : OmegaCompletePartialOrder (α →𝒄 β) := namespace Prod -/-- The application of continuous functions as a continuous function. -/ +/-- The application of continuous functions as a continuous function. -/ @[simps] def apply : (α →𝒄 β) × α →𝒄 β where toFun f := f.1 f.2 diff --git a/Mathlib/Order/Partition/Finpartition.lean b/Mathlib/Order/Partition/Finpartition.lean index 13a431112afd8..ac05d45f31ebb 100644 --- a/Mathlib/Order/Partition/Finpartition.lean +++ b/Mathlib/Order/Partition/Finpartition.lean @@ -67,7 +67,7 @@ structure Finpartition [Lattice α] [OrderBot α] (a : α) where supIndep : parts.SupIndep id /-- The supremum of the partition is `a` -/ sup_parts : parts.sup id = a - /-- No element of the partition is bottom-/ + /-- No element of the partition is bottom -/ not_bot_mem : ⊥ ∉ parts deriving DecidableEq diff --git a/Mathlib/Order/RelClasses.lean b/Mathlib/Order/RelClasses.lean index 1981aaa5b754d..dcfbcc1773326 100644 --- a/Mathlib/Order/RelClasses.lean +++ b/Mathlib/Order/RelClasses.lean @@ -41,21 +41,21 @@ theorem antisymm_iff [IsRefl α r] [IsAntisymm α r] {a b : α} : r a b ∧ r b /-- A version of `antisymm` with `r` explicit. -This lemma matches the lemmas from lean core in `Init.Algebra.Classes`, but is missing there. -/ +This lemma matches the lemmas from lean core in `Init.Algebra.Classes`, but is missing there. -/ @[elab_without_expected_type] theorem antisymm_of (r : α → α → Prop) [IsAntisymm α r] {a b : α} : r a b → r b a → a = b := antisymm /-- A version of `antisymm'` with `r` explicit. -This lemma matches the lemmas from lean core in `Init.Algebra.Classes`, but is missing there. -/ +This lemma matches the lemmas from lean core in `Init.Algebra.Classes`, but is missing there. -/ @[elab_without_expected_type] theorem antisymm_of' (r : α → α → Prop) [IsAntisymm α r] {a b : α} : r a b → r b a → b = a := antisymm' /-- A version of `comm` with `r` explicit. -This lemma matches the lemmas from lean core in `Init.Algebra.Classes`, but is missing there. -/ +This lemma matches the lemmas from lean core in `Init.Algebra.Classes`, but is missing there. -/ theorem comm_of (r : α → α → Prop) [IsSymm α r] {a b : α} : r a b ↔ r b a := comm @@ -199,7 +199,7 @@ theorem IsStrictTotalOrder.swap (r) [IsStrictTotalOrder α r] : IsStrictTotalOrd /-- A connected order is one satisfying the condition `a < c → a < b ∨ b < c`. This is recognizable as an intuitionistic substitute for `a ≤ b ∨ b ≤ a` on the constructive reals, and is also known as negative transitivity, - since the contrapositive asserts transitivity of the relation `¬ a < b`. -/ + since the contrapositive asserts transitivity of the relation `¬ a < b`. -/ class IsOrderConnected (α : Type u) (lt : α → α → Prop) : Prop where /-- A connected order is one satisfying the condition `a < c → a < b ∨ b < c`. -/ conn : ∀ a b c, lt a c → lt a b ∨ lt b c diff --git a/Mathlib/Order/RelSeries.lean b/Mathlib/Order/RelSeries.lean index e3396ccf701b7..3878bb7461dba 100644 --- a/Mathlib/Order/RelSeries.lean +++ b/Mathlib/Order/RelSeries.lean @@ -100,7 +100,7 @@ lemma toList_chain' (x : RelSeries r) : x.toList.Chain' r := by lemma toList_ne_nil (x : RelSeries r) : x.toList ≠ [] := fun m => List.eq_nil_iff_forall_not_mem.mp m (x 0) <| (List.mem_ofFn _ _).mpr ⟨_, rfl⟩ -/-- Every nonempty list satisfying the chain condition gives a relation series-/ +/-- Every nonempty list satisfying the chain condition gives a relation series -/ @[simps] def fromListChain' (x : List α) (x_ne_nil : x ≠ []) (hx : x.Chain' r) : RelSeries r where length := x.length - 1 diff --git a/Mathlib/Order/SuccPred/Basic.lean b/Mathlib/Order/SuccPred/Basic.lean index 35cdbb68b9f82..eab13f1846fc3 100644 --- a/Mathlib/Order/SuccPred/Basic.lean +++ b/Mathlib/Order/SuccPred/Basic.lean @@ -51,11 +51,11 @@ variable {α β : Type*} /-- Order equipped with a sensible successor function. -/ @[ext] class SuccOrder (α : Type*) [Preorder α] where - /-- Successor function-/ + /-- Successor function -/ succ : α → α /-- Proof of basic ordering with respect to `succ`-/ le_succ : ∀ a, a ≤ succ a - /-- Proof of interaction between `succ` and maximal element-/ + /-- Proof of interaction between `succ` and maximal element -/ max_of_succ_le {a} : succ a ≤ a → IsMax a /-- Proof that `succ a` is the least element greater than `a`-/ succ_le_of_lt {a b} : a < b → succ a ≤ b @@ -63,11 +63,11 @@ class SuccOrder (α : Type*) [Preorder α] where /-- Order equipped with a sensible predecessor function. -/ @[ext] class PredOrder (α : Type*) [Preorder α] where - /-- Predecessor function-/ + /-- Predecessor function -/ pred : α → α /-- Proof of basic ordering with respect to `pred`-/ pred_le : ∀ a, pred a ≤ a - /-- Proof of interaction between `pred` and minimal element-/ + /-- Proof of interaction between `pred` and minimal element -/ min_of_le_pred {a} : a ≤ pred a → IsMin a /-- Proof that `pred b` is the greatest element less than `b`-/ le_pred_of_lt {a b} : a < b → a ≤ pred b @@ -1356,11 +1356,11 @@ lemma StrictAnti.not_bddBelow_range [NoMaxOrder α] [PredOrder β] [IsPredArchim end bdd_range -section IsWellOrder +section IsWellFounded -variable [LinearOrder α] +variable [PartialOrder α] -instance (priority := 100) IsWellOrder.toIsPredArchimedean [h : IsWellOrder α (· < ·)] +instance (priority := 100) WellFoundedLT.toIsPredArchimedean [h : WellFoundedLT α] [PredOrder α] : IsPredArchimedean α := ⟨fun {a b} => by refine WellFounded.fix (C := fun b => a ≤ b → ∃ n, Nat.iterate pred n b = a) @@ -1369,19 +1369,19 @@ instance (priority := 100) IsWellOrder.toIsPredArchimedean [h : IsWellOrder α ( replace hab := eq_or_lt_of_le hab rcases hab with (rfl | hab) · exact ⟨0, rfl⟩ - rcases le_or_lt b (pred b) with hb | hb - · cases (min_of_le_pred hb).not_lt hab + rcases eq_or_lt_of_le (pred_le b) with hb | hb + · cases (min_of_le_pred hb.ge).not_lt hab dsimp at ih obtain ⟨k, hk⟩ := ih (pred b) hb (le_pred_of_lt hab) refine ⟨k + 1, ?_⟩ rw [iterate_add_apply, iterate_one, hk]⟩ -instance (priority := 100) IsWellOrder.toIsSuccArchimedean [h : IsWellOrder α (· > ·)] +instance (priority := 100) WellFoundedGT.toIsSuccArchimedean [h : WellFoundedGT α] [SuccOrder α] : IsSuccArchimedean α := let h : IsPredArchimedean αᵒᵈ := by infer_instance ⟨h.1⟩ -end IsWellOrder +end IsWellFounded section OrderBot diff --git a/Mathlib/Order/SymmDiff.lean b/Mathlib/Order/SymmDiff.lean index f16a508003350..8805a9c3184ad 100644 --- a/Mathlib/Order/SymmDiff.lean +++ b/Mathlib/Order/SymmDiff.lean @@ -397,7 +397,7 @@ theorem symmDiff_symmDiff_right : theorem symmDiff_assoc : a ∆ b ∆ c = a ∆ (b ∆ c) := by rw [symmDiff_symmDiff_left, symmDiff_symmDiff_right] -instance symmDiff_isAssociative : Std.Associative (α := α) (· ∆ ·) := +instance symmDiff_isAssociative : Std.Associative (α := α) (· ∆ ·) := ⟨symmDiff_assoc⟩ theorem symmDiff_left_comm : a ∆ (b ∆ c) = b ∆ (a ∆ c) := by diff --git a/Mathlib/Order/Synonym.lean b/Mathlib/Order/Synonym.lean index 70558d627478e..1ff3b4dca5241 100644 --- a/Mathlib/Order/Synonym.lean +++ b/Mathlib/Order/Synonym.lean @@ -44,11 +44,11 @@ namespace OrderDual instance [h : Nontrivial α] : Nontrivial αᵒᵈ := h -/-- `toDual` is the identity function to the `OrderDual` of a linear order. -/ +/-- `toDual` is the identity function to the `OrderDual` of a linear order. -/ def toDual : α ≃ αᵒᵈ := Equiv.refl _ -/-- `ofDual` is the identity function from the `OrderDual` of a linear order. -/ +/-- `ofDual` is the identity function from the `OrderDual` of a linear order. -/ def ofDual : αᵒᵈ ≃ α := Equiv.refl _ @@ -134,12 +134,12 @@ end OrderDual def Lex (α : Type*) := α -/-- `toLex` is the identity function to the `Lex` of a type. -/ +/-- `toLex` is the identity function to the `Lex` of a type. -/ @[match_pattern] def toLex : α ≃ Lex α := Equiv.refl _ -/-- `ofLex` is the identity function from the `Lex` of a type. -/ +/-- `ofLex` is the identity function from the `Lex` of a type. -/ @[match_pattern] def ofLex : Lex α ≃ α := Equiv.refl _ diff --git a/Mathlib/Order/UpperLower/Basic.lean b/Mathlib/Order/UpperLower/Basic.lean index efe287062c81e..1c2dbcf53ed26 100644 --- a/Mathlib/Order/UpperLower/Basic.lean +++ b/Mathlib/Order/UpperLower/Basic.lean @@ -1802,3 +1802,5 @@ theorem lowerClosure_prod (s : Set α) (t : Set β) : simp [Prod.le_def, @and_and_and_comm _ (_ ∈ t)] end Preorder + +set_option linter.style.longFile 1900 diff --git a/Mathlib/Order/WellFoundedSet.lean b/Mathlib/Order/WellFoundedSet.lean index 84f0ca38e5c7b..5e939f8f9b787 100644 --- a/Mathlib/Order/WellFoundedSet.lean +++ b/Mathlib/Order/WellFoundedSet.lean @@ -695,7 +695,7 @@ theorem iff_not_exists_isMinBadSeq (rk : α → ℕ) {s : Set α} : /-- Higman's Lemma, which states that for any reflexive, transitive relation `r` which is partially well-ordered on a set `s`, the relation `List.SublistForall₂ r` is partially well-ordered on the set of lists of elements of `s`. That relation is defined so that - `List.SublistForall₂ r l₁ l₂` whenever `l₁` related pointwise by `r` to a sublist of `l₂`. -/ + `List.SublistForall₂ r l₁ l₂` whenever `l₁` related pointwise by `r` to a sublist of `l₂`. -/ theorem partiallyWellOrderedOn_sublistForall₂ (r : α → α → Prop) [IsRefl α r] [IsTrans α r] {s : Set α} (h : s.PartiallyWellOrderedOn r) : { l : List α | ∀ x, x ∈ l → x ∈ s }.PartiallyWellOrderedOn (List.SublistForall₂ r) := by diff --git a/Mathlib/Probability/Distributions/Exponential.lean b/Mathlib/Probability/Distributions/Exponential.lean index fb141c97472bc..2a2c503ce5f51 100644 --- a/Mathlib/Probability/Distributions/Exponential.lean +++ b/Mathlib/Probability/Distributions/Exponential.lean @@ -73,7 +73,7 @@ lemma measurable_exponentialPDFReal (r : ℝ) : Measurable (exponentialPDFReal r lemma exponentialPDFReal_pos {x r : ℝ} (hr : 0 < r) (hx : 0 < x) : 0 < exponentialPDFReal r x := gammaPDFReal_pos zero_lt_one hr hx -/-- The exponential pdf is nonnegative-/ +/-- The exponential pdf is nonnegative -/ lemma exponentialPDFReal_nonneg {r : ℝ} (hr : 0 < r) (x : ℝ) : 0 ≤ exponentialPDFReal r x := gammaPDFReal_nonneg zero_lt_one hr x diff --git a/Mathlib/Probability/Distributions/Gaussian.lean b/Mathlib/Probability/Distributions/Gaussian.lean index b31dba6a5ddf3..6293ed30a4ed9 100644 --- a/Mathlib/Probability/Distributions/Gaussian.lean +++ b/Mathlib/Probability/Distributions/Gaussian.lean @@ -93,7 +93,7 @@ lemma integrable_gaussianPDFReal (μ : ℝ) (v : ℝ≥0) : field_simp exact Integrable.comp_sub_right hg μ -/-- The gaussian distribution pdf integrates to 1 when the variance is not zero. -/ +/-- The gaussian distribution pdf integrates to 1 when the variance is not zero. -/ lemma lintegral_gaussianPDFReal_eq_one (μ : ℝ) {v : ℝ≥0} (h : v ≠ 0) : ∫⁻ x, ENNReal.ofReal (gaussianPDFReal μ v x) = 1 := by rw [← ENNReal.toReal_eq_one_iff] @@ -112,7 +112,7 @@ lemma lintegral_gaussianPDFReal_eq_one (μ : ℝ) {v : ℝ≥0} (h : v ≠ 0) : ring · positivity -/-- The gaussian distribution pdf integrates to 1 when the variance is not zero. -/ +/-- The gaussian distribution pdf integrates to 1 when the variance is not zero. -/ lemma integral_gaussianPDFReal_eq_one (μ : ℝ) {v : ℝ≥0} (hv : v ≠ 0) : ∫ x, gaussianPDFReal μ v x = 1 := by have h := lintegral_gaussianPDFReal_eq_one μ hv diff --git a/Mathlib/Probability/Independence/Basic.lean b/Mathlib/Probability/Independence/Basic.lean index 37bd8bdc8c405..88039bcea16f4 100644 --- a/Mathlib/Probability/Independence/Basic.lean +++ b/Mathlib/Probability/Independence/Basic.lean @@ -327,7 +327,7 @@ end Indep section FromIndepToIndep -variable {m : ι → MeasurableSpace Ω} {_mΩ : MeasurableSpace Ω} {μ : Measure Ω} +variable {m : ι → MeasurableSpace Ω} {_mΩ : MeasurableSpace Ω} {μ : Measure Ω} theorem iIndepSets.indepSets {s : ι → Set (Set Ω)} (h_indep : iIndepSets s μ) {i j : ι} (hij : i ≠ j) : IndepSets (s i) (s j) μ := diff --git a/Mathlib/Probability/Independence/Kernel.lean b/Mathlib/Probability/Independence/Kernel.lean index c07e53b9ec329..08f575f7d71e5 100644 --- a/Mathlib/Probability/Independence/Kernel.lean +++ b/Mathlib/Probability/Independence/Kernel.lean @@ -390,7 +390,8 @@ theorem IndepSets.indep_aux {m₂ m : MeasurableSpace Ω} have : t1 ∩ tᶜ = t1 \ (t1 ∩ t) := by rw [Set.diff_self_inter, Set.diff_eq_compl_inter, Set.inter_comm] rw [this, - measure_diff Set.inter_subset_left (ht1m.inter (h2 _ ht)) (measure_ne_top (κ a) _), + measure_diff Set.inter_subset_left (ht1m.inter (h2 _ ht)).nullMeasurableSet + (measure_ne_top (κ a) _), measure_compl (h2 _ ht) (measure_ne_top (κ a) t), measure_univ, ENNReal.mul_sub (fun _ _ ↦ measure_ne_top (κ a) _), mul_one, ha] · intros f hf_disj hf_meas h @@ -428,7 +429,7 @@ theorem IndepSets.indep {m1 m2 m : MeasurableSpace Ω} {κ : Kernel α Ω} {μ : have : tᶜ ∩ t2 = t2 \ (t ∩ t2) := by rw [Set.inter_comm t, Set.diff_self_inter, Set.diff_eq_compl_inter] rw [this, Set.inter_comm t t2, - measure_diff Set.inter_subset_left ((h2 _ ht2).inter (h1 _ ht)) + measure_diff Set.inter_subset_left ((h2 _ ht2).inter (h1 _ ht)).nullMeasurableSet (measure_ne_top (κ a) _), Set.inter_comm, ha, measure_compl (h1 _ ht) (measure_ne_top (κ a) t), measure_univ, mul_comm (1 - κ a t), ENNReal.mul_sub (fun _ _ ↦ measure_ne_top (κ a) _), mul_one, mul_comm] diff --git a/Mathlib/Probability/Kernel/Basic.lean b/Mathlib/Probability/Kernel/Basic.lean index 2ba8229ef510e..e958feff072c9 100644 --- a/Mathlib/Probability/Kernel/Basic.lean +++ b/Mathlib/Probability/Kernel/Basic.lean @@ -73,8 +73,6 @@ scoped notation "Kernel[" mα "]" α:arg β:arg => @Kernel α β mα _ /-- Notation for `Kernel` with respect to a non-standard σ-algebra in the domain and codomain. -/ scoped notation "Kernel[" mα ", " mβ "]" α:arg β:arg => @Kernel α β mα mβ -initialize_simps_projections Kernel (toFun → apply) - variable {α β ι : Type*} {mα : MeasurableSpace α} {mβ : MeasurableSpace β} namespace Kernel @@ -84,6 +82,9 @@ instance instFunLike : FunLike (Kernel α β) α (Measure β) where coe_injective' f g h := by cases f; cases g; congr lemma measurable (κ : Kernel α β) : Measurable κ := κ.measurable' +@[simp, norm_cast] lemma coe_mk (f : α → Measure β) (hf) : mk f hf = f := rfl + +initialize_simps_projections Kernel (toFun → apply) instance instZero : Zero (Kernel α β) where zero := ⟨0, measurable_zero⟩ noncomputable instance instAdd : Add (Kernel α β) where add κ η := ⟨κ + η, κ.2.add η.2⟩ diff --git a/Mathlib/Probability/Kernel/Composition.lean b/Mathlib/Probability/Kernel/Composition.lean index 39106448b1afa..8764241a57818 100644 --- a/Mathlib/Probability/Kernel/Composition.lean +++ b/Mathlib/Probability/Kernel/Composition.lean @@ -96,16 +96,14 @@ theorem compProdFun_iUnion (κ : Kernel α β) (η : Kernel (α × β) γ) [IsSF (f : ℕ → Set (β × γ)) (hf_meas : ∀ i, MeasurableSet (f i)) (hf_disj : Pairwise (Disjoint on f)) : compProdFun κ η a (⋃ i, f i) = ∑' i, compProdFun κ η a (f i) := by - have h_Union : - (fun b => η (a, b) {c : γ | (b, c) ∈ ⋃ i, f i}) = fun b => - η (a, b) (⋃ i, {c : γ | (b, c) ∈ f i}) := by + have h_Union : (fun b ↦ η (a, b) {c : γ | (b, c) ∈ ⋃ i, f i}) + = fun b ↦ η (a, b) (⋃ i, {c : γ | (b, c) ∈ f i}) := by ext1 b congr with c simp only [Set.mem_iUnion, Set.iSup_eq_iUnion, Set.mem_setOf_eq] rw [compProdFun, h_Union] - have h_tsum : - (fun b => η (a, b) (⋃ i, {c : γ | (b, c) ∈ f i})) = fun b => - ∑' i, η (a, b) {c : γ | (b, c) ∈ f i} := by + have h_tsum : (fun b ↦ η (a, b) (⋃ i, {c : γ | (b, c) ∈ f i})) + = fun b ↦ ∑' i, η (a, b) {c : γ | (b, c) ∈ f i} := by ext1 b rw [measure_iUnion] · intro i j hij s hsi hsj c hcs @@ -113,9 +111,7 @@ theorem compProdFun_iUnion (κ : Kernel α β) (η : Kernel (α × β) γ) [IsSF have hbcj : {(b, c)} ⊆ f j := by rw [Set.singleton_subset_iff]; exact hsj hcs simpa only [Set.bot_eq_empty, Set.le_eq_subset, Set.singleton_subset_iff, Set.mem_empty_iff_false] using hf_disj hij hbci hbcj - · -- Porting note: behavior of `@` changed relative to lean 3, was - -- exact fun i => (@measurable_prod_mk_left β γ _ _ b) _ (hf_meas i) - exact fun i => (@measurable_prod_mk_left β γ _ _ b) (hf_meas i) + · exact fun i ↦ measurable_prod_mk_left (hf_meas i) rw [h_tsum, lintegral_tsum] · rfl · intro i @@ -126,15 +122,13 @@ theorem compProdFun_iUnion (κ : Kernel α β) (η : Kernel (α × β) γ) [IsSF theorem compProdFun_tsum_right (κ : Kernel α β) (η : Kernel (α × β) γ) [IsSFiniteKernel η] (a : α) (hs : MeasurableSet s) : compProdFun κ η a s = ∑' n, compProdFun κ (seq η n) a s := by simp_rw [compProdFun, (measure_sum_seq η _).symm] - have : - ∫⁻ b, Measure.sum (fun n => seq η n (a, b)) {c : γ | (b, c) ∈ s} ∂κ a = - ∫⁻ b, ∑' n, seq η n (a, b) {c : γ | (b, c) ∈ s} ∂κ a := by - congr - ext1 b + have : ∫⁻ b, Measure.sum (fun n => seq η n (a, b)) {c : γ | (b, c) ∈ s} ∂κ a + = ∫⁻ b, ∑' n, seq η n (a, b) {c : γ | (b, c) ∈ s} ∂κ a := by + congr with b rw [Measure.sum_apply] exact measurable_prod_mk_left hs rw [this, lintegral_tsum] - exact fun n => ((measurable_kernel_prod_mk_left (κ := (seq η n)) + exact fun n ↦ ((measurable_kernel_prod_mk_left (κ := (seq η n)) ((measurable_fst.snd.prod_mk measurable_snd) hs)).comp measurable_prod_mk_left).aemeasurable theorem compProdFun_tsum_left (κ : Kernel α β) (η : Kernel (α × β) γ) [IsSFiniteKernel κ] (a : α) @@ -146,34 +140,21 @@ theorem compProdFun_eq_tsum (κ : Kernel α β) [IsSFiniteKernel κ] (η : Kerne compProdFun κ η a s = ∑' (n) (m), compProdFun (seq κ n) (seq η m) a s := by simp_rw [compProdFun_tsum_left κ η a s, compProdFun_tsum_right _ η a hs] -/-- Auxiliary lemma for `measurable_compProdFun`. -/ -theorem measurable_compProdFun_of_finite (κ : Kernel α β) [IsFiniteKernel κ] (η : Kernel (α × β) γ) - [IsFiniteKernel η] (hs : MeasurableSet s) : Measurable fun a => compProdFun κ η a s := by +theorem measurable_compProdFun (κ : Kernel α β) [IsSFiniteKernel κ] (η : Kernel (α × β) γ) + [IsSFiniteKernel η] (hs : MeasurableSet s) : + Measurable fun a ↦ compProdFun κ η a s := by simp only [compProdFun] have h_meas : Measurable (Function.uncurry fun a b => η (a, b) {c : γ | (b, c) ∈ s}) := by - have : - (Function.uncurry fun a b => η (a, b) {c : γ | (b, c) ∈ s}) = fun p => - η p {c : γ | (p.2, c) ∈ s} := by + have : (Function.uncurry fun a b => η (a, b) {c : γ | (b, c) ∈ s}) + = fun p ↦ η p {c : γ | (p.2, c) ∈ s} := by ext1 p rw [Function.uncurry_apply_pair] rw [this] exact measurable_kernel_prod_mk_left (measurable_fst.snd.prod_mk measurable_snd hs) exact h_meas.lintegral_kernel_prod_right -theorem measurable_compProdFun (κ : Kernel α β) [IsSFiniteKernel κ] (η : Kernel (α × β) γ) - [IsSFiniteKernel η] (hs : MeasurableSet s) : Measurable fun a => compProdFun κ η a s := by - simp_rw [compProdFun_tsum_right κ η _ hs] - refine Measurable.ennreal_tsum fun n => ?_ - simp only [compProdFun] - have h_meas : Measurable (Function.uncurry fun a b => seq η n (a, b) {c : γ | (b, c) ∈ s}) := by - have : - (Function.uncurry fun a b => seq η n (a, b) {c : γ | (b, c) ∈ s}) = fun p => - seq η n p {c : γ | (p.2, c) ∈ s} := by - ext1 p - rw [Function.uncurry_apply_pair] - rw [this] - exact measurable_kernel_prod_mk_left (measurable_fst.snd.prod_mk measurable_snd hs) - exact h_meas.lintegral_kernel_prod_right +@[deprecated (since := "2024-08-30")] +alias measurable_compProdFun_of_finite := measurable_compProdFun open scoped Classical @@ -182,23 +163,22 @@ open scoped Classical (see `ProbabilityTheory.Kernel.lintegral_compProd`). If either of the kernels is not s-finite, `compProd` is given the junk value 0. -/ noncomputable def compProd (κ : Kernel α β) (η : Kernel (α × β) γ) : Kernel α (β × γ) := -if h : IsSFiniteKernel κ ∧ IsSFiniteKernel η then -{ toFun := fun a ↦ - Measure.ofMeasurable (fun s _ => compProdFun κ η a s) (compProdFun_empty κ η a) - (@compProdFun_iUnion _ _ _ _ _ _ κ η h.2 a) - measurable' := by - have : IsSFiniteKernel κ := h.1 - have : IsSFiniteKernel η := h.2 - refine Measure.measurable_of_measurable_coe _ fun s hs => ?_ - have : - (fun a => - Measure.ofMeasurable (fun s _ => compProdFun κ η a s) (compProdFun_empty κ η a) - (compProdFun_iUnion κ η a) s) = - fun a => compProdFun κ η a s := by - ext1 a; rwa [Measure.ofMeasurable_apply] - rw [this] - exact measurable_compProdFun κ η hs } -else 0 + if h : IsSFiniteKernel κ ∧ IsSFiniteKernel η then + { toFun := fun a ↦ + have : IsSFiniteKernel η := h.2 + Measure.ofMeasurable (fun s _ ↦ compProdFun κ η a s) (compProdFun_empty κ η a) + (compProdFun_iUnion κ η a) + measurable' := by + have : IsSFiniteKernel κ := h.1 + have : IsSFiniteKernel η := h.2 + refine Measure.measurable_of_measurable_coe _ fun s hs ↦ ?_ + have : (fun a ↦ Measure.ofMeasurable (fun s _ ↦ compProdFun κ η a s) (compProdFun_empty κ η a) + (compProdFun_iUnion κ η a) s) + = fun a ↦ compProdFun κ η a s := by + ext1 a; rwa [Measure.ofMeasurable_apply] + rw [this] + exact measurable_compProdFun κ η hs } + else 0 scoped[ProbabilityTheory] infixl:100 " ⊗ₖ " => ProbabilityTheory.Kernel.compProd diff --git a/Mathlib/Probability/Kernel/Disintegration/CDFToKernel.lean b/Mathlib/Probability/Kernel/Disintegration/CDFToKernel.lean index a2a9b77161b60..18005da5094fd 100644 --- a/Mathlib/Probability/Kernel/Disintegration/CDFToKernel.lean +++ b/Mathlib/Probability/Kernel/Disintegration/CDFToKernel.lean @@ -147,7 +147,7 @@ lemma setLIntegral_stieltjesOfMeasurableRat [IsFiniteKernel κ] (hf : IsRatCondK · exact mod_cast ha.le · refine le_of_forall_lt_rat_imp_le fun q hq ↦ h q ?_ exact mod_cast hq - · exact fun _ ↦ measurableSet_Iic + · exact fun _ ↦ measurableSet_Iic.nullMeasurableSet · refine Monotone.directed_ge fun r r' hrr' ↦ Iic_subset_Iic.mpr ?_ exact mod_cast hrr' · obtain ⟨q, hq⟩ := exists_rat_gt x @@ -172,7 +172,7 @@ lemma setLIntegral_stieltjesOfMeasurableRat [IsFiniteKernel κ] (hf : IsRatCondK congr with y simp only [mem_iInter, mem_Iic, Subtype.forall, Subtype.coe_mk] exact ⟨le_of_forall_lt_rat_imp_le, fun hyx q hq ↦ hyx.trans hq.le⟩ - · exact fun i ↦ hs.prod measurableSet_Iic + · exact fun i ↦ (hs.prod measurableSet_Iic).nullMeasurableSet · refine Monotone.directed_ge fun i j hij ↦ ?_ refine prod_subset_prod_iff.mpr (Or.inl ⟨subset_rfl, Iic_subset_Iic.mpr ?_⟩) exact mod_cast hij @@ -355,7 +355,7 @@ lemma _root_.MeasureTheory.Measure.iInf_rat_gt_prod_Iic {ρ : Measure (α × ℝ · refine le_of_forall_lt_rat_imp_le fun q htq ↦ h q ?_ exact mod_cast htq · exact mod_cast hta.le - · exact fun _ => hs.prod measurableSet_Iic + · exact fun _ => (hs.prod measurableSet_Iic).nullMeasurableSet · refine Monotone.directed_ge fun r r' hrr' ↦ prod_subset_prod_iff.mpr (Or.inl ⟨subset_rfl, ?_⟩) refine Iic_subset_Iic.mpr ?_ exact mod_cast hrr' @@ -589,7 +589,7 @@ lemma setLIntegral_toKernel_prod [IsFiniteKernel κ] (hf : IsCondKernelCDF f κ _ = κ a (s ×ˢ univ) - κ a (s ×ˢ t) := by rw [setLIntegral_toKernel_univ hf a hs, ht_lintegral] _ = κ a (s ×ˢ tᶜ) := by - rw [← measure_diff _ (hs.prod ht) (measure_ne_top _ _)] + rw [← measure_diff _ (hs.prod ht).nullMeasurableSet (measure_ne_top _ _)] · rw [prod_diff_prod, compl_eq_univ_diff] simp only [diff_self, empty_prod, union_empty] · rw [prod_subset_prod_iff] diff --git a/Mathlib/Probability/Kernel/Disintegration/CondCDF.lean b/Mathlib/Probability/Kernel/Disintegration/CondCDF.lean index 0659092ade23a..4b5aac1603122 100644 --- a/Mathlib/Probability/Kernel/Disintegration/CondCDF.lean +++ b/Mathlib/Probability/Kernel/Disintegration/CondCDF.lean @@ -50,23 +50,18 @@ noncomputable def IicSnd (r : ℝ) : Measure α := theorem IicSnd_apply (r : ℝ) {s : Set α} (hs : MeasurableSet s) : ρ.IicSnd r s = ρ (s ×ˢ Iic r) := by - rw [IicSnd, fst_apply hs, - restrict_apply' (MeasurableSet.univ.prod (measurableSet_Iic : MeasurableSet (Iic r))), ← - prod_univ, prod_inter_prod, inter_univ, univ_inter] + rw [IicSnd, fst_apply hs, restrict_apply' (MeasurableSet.univ.prod measurableSet_Iic), + univ_prod, Set.prod_eq] theorem IicSnd_univ (r : ℝ) : ρ.IicSnd r univ = ρ (univ ×ˢ Iic r) := IicSnd_apply ρ r MeasurableSet.univ +@[gcongr] theorem IicSnd_mono {r r' : ℝ} (h_le : r ≤ r') : ρ.IicSnd r ≤ ρ.IicSnd r' := by - refine Measure.le_iff.2 fun s hs ↦ ?_ - simp_rw [IicSnd_apply ρ _ hs] - refine measure_mono (prod_subset_prod_iff.mpr (Or.inl ⟨subset_rfl, Iic_subset_Iic.mpr ?_⟩)) - exact mod_cast h_le + unfold IicSnd; gcongr -theorem IicSnd_le_fst (r : ℝ) : ρ.IicSnd r ≤ ρ.fst := by - refine Measure.le_iff.2 fun s hs ↦ ?_ - simp_rw [fst_apply hs, IicSnd_apply ρ r hs] - exact measure_mono (prod_subset_preimage_fst _ _) +theorem IicSnd_le_fst (r : ℝ) : ρ.IicSnd r ≤ ρ.fst := + fst_mono restrict_le_self theorem IicSnd_ac_fst (r : ℝ) : ρ.IicSnd r ≪ ρ.fst := Measure.absolutelyContinuous_of_le (IicSnd_le_fst ρ r) @@ -106,8 +101,9 @@ theorem tendsto_IicSnd_atBot [IsFiniteMeasure ρ] {s : Set α} (hs : MeasurableS simp_rw [neg_neg] rw [h_fun_eq] exact h_neg.comp tendsto_neg_atBot_atTop - refine tendsto_measure_iInter (fun q ↦ hs.prod measurableSet_Iic) ?_ ⟨0, measure_ne_top ρ _⟩ - refine fun q r hqr ↦ prod_subset_prod_iff.mpr (Or.inl ⟨subset_rfl, fun x hx ↦ ?_⟩) + refine tendsto_measure_iInter (fun q ↦ (hs.prod measurableSet_Iic).nullMeasurableSet) + ?_ ⟨0, measure_ne_top ρ _⟩ + refine fun q r hqr ↦ Set.prod_mono subset_rfl fun x hx ↦ ?_ simp only [Rat.cast_neg, mem_Iic] at hx ⊢ refine hx.trans (neg_le_neg ?_) exact mod_cast hqr @@ -126,7 +122,7 @@ attribute [local instance] MeasureTheory.Measure.IsFiniteMeasure.IicSnd We build towards the definition of `ProbabilityTheory.condCDF`. We first define `ProbabilityTheory.preCDF`, a function defined on `α × ℚ` with the properties of a cdf almost -everywhere. -/ +everywhere. -/ /-- `preCDF` is the Radon-Nikodym derivative of `ρ.IicSnd` with respect to `ρ.fst` at each `r : ℚ`. This function `ℚ → α → ℝ≥0∞` is such that for almost all `a : α`, the function `ℚ → ℝ≥0∞` diff --git a/Mathlib/Probability/Kernel/Disintegration/Density.lean b/Mathlib/Probability/Kernel/Disintegration/Density.lean index 8b2f314be1286..77a32c6fbfe53 100644 --- a/Mathlib/Probability/Kernel/Disintegration/Density.lean +++ b/Mathlib/Probability/Kernel/Disintegration/Density.lean @@ -385,7 +385,7 @@ lemma tendsto_densityProcess_atTop_empty_of_antitone (κ : Kernel α (γ × β)) ?_ ?_ ?_ · convert h rw [← prod_iInter, hseq_iInter] - · exact fun m ↦ MeasurableSet.prod (measurableSet_countablePartitionSet _ _) (hseq_meas m) + · exact fun m ↦ ((measurableSet_countablePartitionSet _ _).prod (hseq_meas m)).nullMeasurableSet · intro m m' hmm' simp only [le_eq_subset, prod_subset_prod_iff, subset_rfl, true_and] exact Or.inl <| hseq hmm' @@ -599,7 +599,7 @@ lemma setIntegral_density (hκν : fst κ ≤ ν) [IsFiniteKernel ν] have : Aᶜ ×ˢ s = univ ×ˢ s \ A ×ˢ s := by rw [prod_diff_prod, compl_eq_univ_diff] simp - rw [this, measure_diff (by intro x; simp) (hA.prod hs) (measure_ne_top (κ a) _), + rw [this, measure_diff (by intro; simp) (hA.prod hs).nullMeasurableSet (measure_ne_top (κ a) _), ENNReal.toReal_sub_of_le (measure_mono (by intro x; simp)) (measure_ne_top _ _)] rw [eq_tsub_iff_add_eq_of_le, add_comm] · exact h @@ -677,7 +677,7 @@ lemma tendsto_integral_density_of_antitone (hκν : fst κ ≤ ν) [IsFiniteKern · simp refine h_cont.tendsto.comp ?_ have h := tendsto_measure_iInter (s := fun m ↦ univ ×ˢ seq m) (μ := κ a) - (fun m ↦ MeasurableSet.univ.prod (hseq_meas m)) ?_ ?_ + (fun m ↦ (MeasurableSet.univ.prod (hseq_meas m)).nullMeasurableSet) ?_ ?_ rotate_left · intro n m hnm x; simp only [mem_prod, mem_univ, true_and]; exact fun h ↦ hseq hnm h · refine ⟨0, measure_ne_top _ _⟩ diff --git a/Mathlib/Probability/Kernel/IntegralCompProd.lean b/Mathlib/Probability/Kernel/IntegralCompProd.lean index 6e080b423d194..8b7eefdaa464a 100644 --- a/Mathlib/Probability/Kernel/IntegralCompProd.lean +++ b/Mathlib/Probability/Kernel/IntegralCompProd.lean @@ -249,7 +249,7 @@ theorem integral_compProd : theorem setIntegral_compProd {f : β × γ → E} {s : Set β} {t : Set γ} (hs : MeasurableSet s) (ht : MeasurableSet t) (hf : IntegrableOn f (s ×ˢ t) ((κ ⊗ₖ η) a)) : ∫ z in s ×ˢ t, f z ∂(κ ⊗ₖ η) a = ∫ x in s, ∫ y in t, f (x, y) ∂η (a, x) ∂κ a := by - -- Porting note: `compProd_restrict` needed some explicit argumnts + -- Porting note: `compProd_restrict` needed some explicit arguments rw [← Kernel.restrict_apply (κ ⊗ₖ η) (hs.prod ht), ← compProd_restrict hs ht, integral_compProd] · simp_rw [Kernel.restrict_apply] · rw [compProd_restrict, Kernel.restrict_apply]; exact hf diff --git a/Mathlib/Probability/Kernel/MeasurableIntegral.lean b/Mathlib/Probability/Kernel/MeasurableIntegral.lean index 6790cc25384d2..312093ef4376d 100644 --- a/Mathlib/Probability/Kernel/MeasurableIntegral.lean +++ b/Mathlib/Probability/Kernel/MeasurableIntegral.lean @@ -71,7 +71,7 @@ theorem measurable_kernel_prod_mk_left_of_finite {t : Set (α × β)} (ht : Meas κ a Set.univ - κ a (Prod.mk a ⁻¹' t') := by ext1 a rw [← Set.diff_inter_self_eq_diff, Set.inter_univ, measure_diff (Set.subset_univ _)] - · exact (@measurable_prod_mk_left α β _ _ a) ht' + · exact (measurable_prod_mk_left ht').nullMeasurableSet · exact measure_ne_top _ _ rw [this] exact Measurable.sub (Kernel.measurable_coe κ MeasurableSet.univ) h_meas diff --git a/Mathlib/Probability/Kernel/RadonNikodym.lean b/Mathlib/Probability/Kernel/RadonNikodym.lean index 7f5426267ce77..f08e09c449f61 100644 --- a/Mathlib/Probability/Kernel/RadonNikodym.lean +++ b/Mathlib/Probability/Kernel/RadonNikodym.lean @@ -69,9 +69,9 @@ Theorem 1.28 in [O. Kallenberg, Random Measures, Theory and Applications][kallen -/ -open MeasureTheory Set Filter +open MeasureTheory Set Filter ENNReal -open scoped NNReal ENNReal MeasureTheory Topology ProbabilityTheory +open scoped NNReal MeasureTheory Topology ProbabilityTheory namespace ProbabilityTheory.Kernel @@ -157,8 +157,7 @@ lemma withDensity_rnDerivAux (κ η : Kernel α γ) [IsFiniteKernel κ] [IsFinit rw [Kernel.withDensity_apply'] swap · exact (measurable_rnDerivAux _ _).ennreal_ofReal - have : ∀ b, (Real.toNNReal b : ℝ≥0∞) = ENNReal.ofReal b := fun _ ↦ rfl - simp_rw [this] + simp_rw [ofNNReal_toNNReal] exact setLIntegral_rnDerivAux κ η a hs lemma withDensity_one_sub_rnDerivAux (κ η : Kernel α γ) [IsFiniteKernel κ] [IsFiniteKernel η] : @@ -217,11 +216,10 @@ lemma measurableSet_mutuallySingularSetSlice (κ η : Kernel α γ) (a : α) : lemma measure_mutuallySingularSetSlice (κ η : Kernel α γ) [IsFiniteKernel κ] [IsFiniteKernel η] (a : α) : η a (mutuallySingularSetSlice κ η a) = 0 := by - have h_coe : ∀ b, (Real.toNNReal b : ℝ≥0∞) = ENNReal.ofReal b := fun _ ↦ rfl suffices withDensity (κ + η) (fun a x ↦ Real.toNNReal (1 - rnDerivAux κ (κ + η) a x)) a {x | 1 ≤ rnDerivAux κ (κ + η) a x} = 0 by rwa [withDensity_one_sub_rnDerivAux κ η] at this - simp_rw [h_coe] + simp_rw [ofNNReal_toNNReal] rw [Kernel.withDensity_apply', lintegral_eq_zero_iff, EventuallyEq, ae_restrict_iff] rotate_left · exact (measurable_const.sub @@ -289,10 +287,9 @@ lemma measurable_singularPart_fun_right (κ η : Kernel α γ) (a : α) : lemma singularPart_compl_mutuallySingularSetSlice (κ η : Kernel α γ) [IsSFiniteKernel κ] [IsSFiniteKernel η] (a : α) : singularPart κ η a (mutuallySingularSetSlice κ η a)ᶜ = 0 := by - have h_coe : ∀ b, (Real.toNNReal b : ℝ≥0∞) = ENNReal.ofReal b := fun _ ↦ rfl rw [singularPart, Kernel.withDensity_apply', lintegral_eq_zero_iff, EventuallyEq, ae_restrict_iff] - all_goals simp_rw [h_coe] + all_goals simp_rw [ofNNReal_toNNReal] rotate_left · exact measurableSet_preimage (measurable_singularPart_fun_right κ η a) (measurableSet_singleton _) @@ -351,7 +348,6 @@ lemma withDensity_rnDeriv_of_subset_compl_mutuallySingularSetSlice [IsFiniteKernel κ] [IsFiniteKernel η] {a : α} {s : Set γ} (hsm : MeasurableSet s) (hs : s ⊆ (mutuallySingularSetSlice κ η a)ᶜ) : withDensity η (rnDeriv κ η) a s = κ a s := by - have h_coe : ∀ b, (Real.toNNReal b : ℝ≥0∞) = ENNReal.ofReal b := fun _ ↦ rfl have : withDensity η (rnDeriv κ η) = withDensity (withDensity (κ + η) (fun a x ↦ Real.toNNReal (1 - rnDerivAux κ (κ + η) a x))) (rnDeriv κ η) := by @@ -374,8 +370,8 @@ lemma withDensity_rnDeriv_of_subset_compl_mutuallySingularSetSlice ENNReal.ofReal (1 - rnDerivAux κ (κ + η) a x)) ∂(κ + η) a _ = ∫⁻ x in s, ENNReal.ofReal (rnDerivAux κ (κ + η) a x) ∂(κ + η) a := by refine setLIntegral_congr_fun hsm (ae_of_all _ fun x hx ↦ ?_) - rw [h_coe, ← ENNReal.ofReal_div_of_pos, div_eq_inv_mul, ← ENNReal.ofReal_mul, ← mul_assoc, - mul_inv_cancel₀, one_mul] + rw [ofNNReal_toNNReal, ← ENNReal.ofReal_div_of_pos, div_eq_inv_mul, ← ENNReal.ofReal_mul, + ← mul_assoc, mul_inv_cancel₀, one_mul] · rw [ne_eq, sub_eq_zero] exact (hs' x hx).ne' · simp [(hs' x hx).le] @@ -391,7 +387,7 @@ lemma mutuallySingular_singularPart (κ η : Kernel α γ) [IsFiniteKernel κ] [ measure_mutuallySingularSetSlice κ η a, singularPart_compl_mutuallySingularSetSlice κ η a⟩ /-- Lebesgue decomposition of a finite kernel `κ` with respect to another one `η`. -`κ` is the sum of an abolutely continuous part `withDensity η (rnDeriv κ η)` and a singular part +`κ` is the sum of an absolutely continuous part `withDensity η (rnDeriv κ η)` and a singular part `singularPart κ η`. -/ lemma rnDeriv_add_singularPart (κ η : Kernel α γ) [IsFiniteKernel κ] [IsFiniteKernel η] : withDensity η (rnDeriv κ η) + singularPart κ η = κ := by diff --git a/Mathlib/Probability/Martingale/BorelCantelli.lean b/Mathlib/Probability/Martingale/BorelCantelli.lean index bf606fa145ff1..fffa57f7af53e 100644 --- a/Mathlib/Probability/Martingale/BorelCantelli.lean +++ b/Mathlib/Probability/Martingale/BorelCantelli.lean @@ -61,7 +61,7 @@ theorem leastGE_le {i : ℕ} {r : ℝ} (ω : Ω) : leastGE f r i ω ≤ i := -- The following four lemmas shows `leastGE` behaves like a stopped process. Ideally we should -- define `leastGE` as a stopping time and take its stopped process. However, we can't do that --- with our current definition since a stopping time takes only finite indicies. An upcomming +-- with our current definition since a stopping time takes only finite indices. An upcoming -- refactor should hopefully make it possible to have stopping times taking infinity as a value theorem leastGE_mono {n m : ℕ} (hnm : n ≤ m) (r : ℝ) (ω : Ω) : leastGE f r n ω ≤ leastGE f r m ω := hitting_mono hnm diff --git a/Mathlib/Probability/Martingale/Convergence.lean b/Mathlib/Probability/Martingale/Convergence.lean index a9308ef0c2aab..831ab2d4dae51 100644 --- a/Mathlib/Probability/Martingale/Convergence.lean +++ b/Mathlib/Probability/Martingale/Convergence.lean @@ -269,12 +269,12 @@ $(f_n)_n$ is a martingale by the tower property for conditional expectations. Fu $(f_n)_n$ is uniformly integrable in the probability sense. Indeed, as a single function is uniformly integrable in the measure theory sense, for all $\epsilon > 0$, there exists some $\delta > 0$ such that for all measurable set $A$ with $\mu(A) < δ$, we have -$\mathbb{E}|h|\mathbf{1}_A < \epsilon$. So, since for sufficently large $\lambda$, by the Markov +$\mathbb{E}|h|\mathbf{1}_A < \epsilon$. So, since for sufficiently large $\lambda$, by the Markov inequality, we have for all $n$, $$ \mu(|f_n| \ge \lambda) \le \lambda^{-1}\mathbb{E}|f_n| \le \lambda^{-1}\mathbb|g| < \delta, $$ -we have for sufficently large $\lambda$, for all $n$, +we have for sufficiently large $\lambda$, for all $n$, $$ \mathbb{E}|f_n|\mathbf{1}_{|f_n| \ge \lambda} \le \mathbb|g|\mathbf{1}_{|f_n| \ge \lambda} < \epsilon, diff --git a/Mathlib/Probability/Martingale/OptionalStopping.lean b/Mathlib/Probability/Martingale/OptionalStopping.lean index 9ccbef6e43662..fee8f4ea1c1a3 100644 --- a/Mathlib/Probability/Martingale/OptionalStopping.lean +++ b/Mathlib/Probability/Martingale/OptionalStopping.lean @@ -130,7 +130,7 @@ theorem smul_le_stoppedValue_hitting [IsFiniteMeasure μ] (hsub : Submartingale we have `ε • μ {ε ≤ f* n} ≤ ∫ ω in {ε ≤ f* n}, f n` where `f* n ω = max_{k ≤ n}, f k ω`. In some literature, the Doob's maximal inequality refers to what we call Doob's Lp inequality -(which is a corollary of this lemma and will be proved in an upcomming PR). -/ +(which is a corollary of this lemma and will be proved in an upcoming PR). -/ theorem maximal_ineq [IsFiniteMeasure μ] (hsub : Submartingale f 𝒢 μ) (hnonneg : 0 ≤ f) {ε : ℝ≥0} (n : ℕ) : ε • μ {ω | (ε : ℝ) ≤ (range (n + 1)).sup' nonempty_range_succ fun k => f k ω} ≤ ENNReal.ofReal (∫ ω in {ω | (ε : ℝ) ≤ (range (n + 1)).sup' nonempty_range_succ fun k => f k ω}, diff --git a/Mathlib/Probability/Process/Stopping.lean b/Mathlib/Probability/Process/Stopping.lean index 23d8793910896..9d48460885ec5 100644 --- a/Mathlib/Probability/Process/Stopping.lean +++ b/Mathlib/Probability/Process/Stopping.lean @@ -704,7 +704,7 @@ variable [LinearOrder ι] /-- Given a map `u : ι → Ω → E`, the stopped process with respect to `τ` is `u i ω` if `i ≤ τ ω`, and `u (τ ω) ω` otherwise. -Intuitively, the stopped process stops evolving once the stopping time has occured. -/ +Intuitively, the stopped process stops evolving once the stopping time has occurred. -/ def stoppedProcess (u : ι → Ω → β) (τ : Ω → ι) : ι → Ω → β := fun i ω => u (min i (τ ω)) ω theorem stoppedProcess_eq_stoppedValue {u : ι → Ω → β} {τ : Ω → ι} : diff --git a/Mathlib/Probability/StrongLaw.lean b/Mathlib/Probability/StrongLaw.lean index 17244a35ade7a..ec1e988d50e44 100644 --- a/Mathlib/Probability/StrongLaw.lean +++ b/Mathlib/Probability/StrongLaw.lean @@ -380,11 +380,11 @@ theorem strong_law_aux1 {c : ℝ} (c_one : 1 < c) {ε : ℝ} (εpos : 0 < ε) : ε * ⌊c ^ n⌋₊ := by /- Let `S n = ∑ i ∈ range n, Y i` where `Y i = truncation (X i) i`. We should show that `|S k - 𝔼[S k]| / k ≤ ε` along the sequence of powers of `c`. For this, we apply Borel-Cantelli: - it suffices to show that the converse probabilites are summable. From Chebyshev inequality, this - will follow from a variance control `∑' Var[S (c^i)] / (c^i)^2 < ∞`. This is checked in `I2` - using pairwise independence to expand the variance of the sum as the sum of the variances, + it suffices to show that the converse probabilities are summable. From Chebyshev inequality, + this will follow from a variance control `∑' Var[S (c^i)] / (c^i)^2 < ∞`. This is checked in + `I2` using pairwise independence to expand the variance of the sum as the sum of the variances, and then a straightforward but tedious computation (essentially boiling down to the fact that - the sum of `1/(c ^ i)^2` beyong a threshold `j` is comparable to `1/j^2`). + the sum of `1/(c ^ i)^2` beyond a threshold `j` is comparable to `1/j^2`). Note that we have written `c^i` in the above proof sketch, but rigorously one should put integer parts everywhere, making things more painful. We write `u i = ⌊c^i⌋₊` for brevity. -/ have c_pos : 0 < c := zero_lt_one.trans c_one diff --git a/Mathlib/RepresentationTheory/FDRep.lean b/Mathlib/RepresentationTheory/FDRep.lean index 8cc68e7568dae..b45a965988b28 100644 --- a/Mathlib/RepresentationTheory/FDRep.lean +++ b/Mathlib/RepresentationTheory/FDRep.lean @@ -118,7 +118,7 @@ open FiniteDimensional open scoped Classical --- We need to provide this instance explicitely as otherwise `finrank_hom_simple_simple` gives a +-- We need to provide this instance explicitly as otherwise `finrank_hom_simple_simple` gives a -- deterministic timeout. instance : HasKernels (FDRep k G) := by infer_instance diff --git a/Mathlib/RingTheory/Adjoin/Basic.lean b/Mathlib/RingTheory/Adjoin/Basic.lean index 5e47685ea2005..83e58942dce2b 100644 --- a/Mathlib/RingTheory/Adjoin/Basic.lean +++ b/Mathlib/RingTheory/Adjoin/Basic.lean @@ -251,7 +251,7 @@ theorem adjoin_inl_union_inr_eq_prod (s) (t) : simpa [P] using Subalgebra.add_mem _ Ha Hb /-- If all elements of `s : Set A` commute pairwise, then `adjoin R s` is a commutative -semiring. -/ +semiring. -/ def adjoinCommSemiringOfComm {s : Set A} (hcomm : ∀ a ∈ s, ∀ b ∈ s, a * b = b * a) : CommSemiring (adjoin R s) := { (adjoin R s).toSemiring with @@ -403,7 +403,7 @@ theorem adjoin_eq_ring_closure (s : Set A) : variable (R) /-- If all elements of `s : Set A` commute pairwise, then `adjoin R s` is a commutative -ring. -/ +ring. -/ def adjoinCommRingOfComm {s : Set A} (hcomm : ∀ a ∈ s, ∀ b ∈ s, a * b = b * a) : CommRing (adjoin R s) := { (adjoin R s).toRing, adjoinCommSemiringOfComm R hcomm with } diff --git a/Mathlib/RingTheory/AdjoinRoot.lean b/Mathlib/RingTheory/AdjoinRoot.lean index 75dc495a1ff01..7532a1f66cbdf 100644 --- a/Mathlib/RingTheory/AdjoinRoot.lean +++ b/Mathlib/RingTheory/AdjoinRoot.lean @@ -736,7 +736,7 @@ theorem quotAdjoinRootEquivQuotPolynomialQuot_symm_mk_mk (p : R[X]) : quotMapCMapSpanMkEquivQuotMapCQuotMapSpanMk_symm_quotQuotMk, quotMapOfEquivQuotMapCMapSpanMk_symm_mk] -/-- Promote `AdjoinRoot.quotAdjoinRootEquivQuotPolynomialQuot` to an alg_equiv. -/ +/-- Promote `AdjoinRoot.quotAdjoinRootEquivQuotPolynomialQuot` to an alg_equiv. -/ @[simps!] noncomputable def quotEquivQuotMap (f : R[X]) (I : Ideal R) : (AdjoinRoot f ⧸ Ideal.map (of f) I) ≃ₐ[R] diff --git a/Mathlib/RingTheory/Bialgebra/Equiv.lean b/Mathlib/RingTheory/Bialgebra/Equiv.lean index a94379991aff9..c0160257534d0 100644 --- a/Mathlib/RingTheory/Bialgebra/Equiv.lean +++ b/Mathlib/RingTheory/Bialgebra/Equiv.lean @@ -39,7 +39,7 @@ attribute [nolint docBlame] BialgEquiv.toCoalgEquiv notation:50 A " ≃ₐc[" R "] " B => BialgEquiv R A B /-- `BialgEquivClass F R A B` asserts `F` is a type of bundled bialgebra equivalences -from `A` to `B`. -/ +from `A` to `B`. -/ class BialgEquivClass (F : Type*) (R A B : outParam Type*) [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B] [CoalgebraStruct R A] [CoalgebraStruct R B] [EquivLike F A B] diff --git a/Mathlib/RingTheory/Bialgebra/Hom.lean b/Mathlib/RingTheory/Bialgebra/Hom.lean index fe171794c8b66..f1b2923cd334c 100644 --- a/Mathlib/RingTheory/Bialgebra/Hom.lean +++ b/Mathlib/RingTheory/Bialgebra/Hom.lean @@ -45,7 +45,7 @@ infixr:25 " →ₐc " => BialgHom _ notation:25 A " →ₐc[" R "] " B => BialgHom R A B /-- `BialgHomClass F R A B` asserts `F` is a type of bundled bialgebra homomorphisms -from `A` to `B`. -/ +from `A` to `B`. -/ class BialgHomClass (F : Type*) (R A B : outParam Type*) [CommSemiring R] [Semiring A] [Algebra R A] [Semiring B] [Algebra R B] [CoalgebraStruct R A] [CoalgebraStruct R B] [FunLike F A B] diff --git a/Mathlib/RingTheory/Binomial.lean b/Mathlib/RingTheory/Binomial.lean index 31d44ff0e4ac7..15a2aa5a77e33 100644 --- a/Mathlib/RingTheory/Binomial.lean +++ b/Mathlib/RingTheory/Binomial.lean @@ -452,7 +452,7 @@ theorem choose_smul_choose [NatPowAssoc R] (r : R) (n k : ℕ) (hkn : k ≤ n) : refine nsmul_right_injective (Nat.factorial n) (Nat.factorial_ne_zero n) ?_ simp only rw [nsmul_left_comm, ← descPochhammer_eq_factorial_smul_choose, - ← Nat.choose_mul_factorial_mul_factorial hkn, ← smul_mul_smul, + ← Nat.choose_mul_factorial_mul_factorial hkn, ← smul_mul_smul_comm, ← descPochhammer_eq_factorial_smul_choose, mul_nsmul', ← descPochhammer_eq_factorial_smul_choose, smul_mul_assoc] nth_rw 2 [← Nat.sub_add_cancel hkn] diff --git a/Mathlib/RingTheory/Coalgebra/Equiv.lean b/Mathlib/RingTheory/Coalgebra/Equiv.lean index 5b15a25b51a3b..f1e8563bdc49c 100644 --- a/Mathlib/RingTheory/Coalgebra/Equiv.lean +++ b/Mathlib/RingTheory/Coalgebra/Equiv.lean @@ -38,7 +38,7 @@ attribute [nolint docBlame] CoalgEquiv.toLinearEquiv notation:50 A " ≃ₗc[" R "] " B => CoalgEquiv R A B /-- `CoalgEquivClass F R A B` asserts `F` is a type of bundled coalgebra equivalences -from `A` to `B`. -/ +from `A` to `B`. -/ class CoalgEquivClass (F : Type*) (R A B : outParam Type*) [CommSemiring R] [AddCommMonoid A] [AddCommMonoid B] [Module R A] [Module R B] [CoalgebraStruct R A] [CoalgebraStruct R B] [EquivLike F A B] diff --git a/Mathlib/RingTheory/Coalgebra/Hom.lean b/Mathlib/RingTheory/Coalgebra/Hom.lean index 75d7d5fd60d0e..b10428555036d 100644 --- a/Mathlib/RingTheory/Coalgebra/Hom.lean +++ b/Mathlib/RingTheory/Coalgebra/Hom.lean @@ -43,7 +43,7 @@ infixr:25 " →ₗc " => CoalgHom _ notation:25 A " →ₗc[" R "] " B => CoalgHom R A B /-- `CoalgHomClass F R A B` asserts `F` is a type of bundled coalgebra homomorphisms -from `A` to `B`. -/ +from `A` to `B`. -/ class CoalgHomClass (F : Type*) (R A B : outParam Type*) [CommSemiring R] [AddCommMonoid A] [Module R A] [AddCommMonoid B] [Module R B] [CoalgebraStruct R A] [CoalgebraStruct R B] [FunLike F A B] @@ -312,7 +312,7 @@ def Repr.induced {a : A} (repr : Repr R a) lemma sum_tmul_counit_apply_eq {F : Type*} [FunLike F A B] [CoalgHomClass F R A B] (φ : F) {a : A} (repr : Repr R a) : ∑ i ∈ repr.index, counit (R := R) (repr.left i) ⊗ₜ φ (repr.right i) = 1 ⊗ₜ[R] φ a := by - simp [← sum_counit_tmul_eq (repr.induced φ)] + simp [← sum_counit_tmul_eq (repr.induced φ)] @[simp] lemma sum_tmul_apply_counit_eq diff --git a/Mathlib/RingTheory/Coprime/Basic.lean b/Mathlib/RingTheory/Coprime/Basic.lean index ea3e3dce7eff2..851c87915e7a1 100644 --- a/Mathlib/RingTheory/Coprime/Basic.lean +++ b/Mathlib/RingTheory/Coprime/Basic.lean @@ -232,7 +232,7 @@ variable {R G : Type*} [CommSemiring R] [Group G] [MulAction G R] [SMulCommClass theorem isCoprime_group_smul_left : IsCoprime (x • y) z ↔ IsCoprime y z := ⟨fun ⟨a, b, h⟩ => ⟨x • a, b, by rwa [smul_mul_assoc, ← mul_smul_comm]⟩, fun ⟨a, b, h⟩ => - ⟨x⁻¹ • a, b, by rwa [smul_mul_smul, inv_mul_cancel, one_smul]⟩⟩ + ⟨x⁻¹ • a, b, by rwa [smul_mul_smul_comm, inv_mul_cancel, one_smul]⟩⟩ theorem isCoprime_group_smul_right : IsCoprime y (x • z) ↔ IsCoprime y z := isCoprime_comm.trans <| (isCoprime_group_smul_left x z y).trans isCoprime_comm diff --git a/Mathlib/RingTheory/DedekindDomain/Factorization.lean b/Mathlib/RingTheory/DedekindDomain/Factorization.lean index 21265293630ad..9c8f207b3ee90 100644 --- a/Mathlib/RingTheory/DedekindDomain/Factorization.lean +++ b/Mathlib/RingTheory/DedekindDomain/Factorization.lean @@ -406,7 +406,7 @@ theorem count_neg_zpow (n : ℤ) (I : FractionalIdeal R⁰ K) : ← zpow_add₀ hI, neg_add_cancel, zpow_zero] exact count_one K v -theorem count_inv (I : FractionalIdeal R⁰ K) : +theorem count_inv (I : FractionalIdeal R⁰ K) : count K v (I⁻¹) = - count K v I := by rw [← zpow_neg_one, count_neg_zpow K v (1 : ℤ) I, zpow_one] diff --git a/Mathlib/RingTheory/EssentialFiniteness.lean b/Mathlib/RingTheory/EssentialFiniteness.lean index 65b40d237017c..c23b4328ea0fb 100644 --- a/Mathlib/RingTheory/EssentialFiniteness.lean +++ b/Mathlib/RingTheory/EssentialFiniteness.lean @@ -34,7 +34,7 @@ class EssFiniteType : Prop where IsLocalization ((IsUnit.submonoid S).comap (algebraMap (adjoin R (s : Set S)) S)) S /-- Let `S` be an `R`-algebra essentially of finite type, this is a choice of a finset `s ⊆ S` -such that `S` is the localization of `R[s]`. -/ +such that `S` is the localization of `R[s]`. -/ noncomputable def EssFiniteType.finset [h : EssFiniteType R S] : Finset S := h.cond.choose diff --git a/Mathlib/RingTheory/Flat/Basic.lean b/Mathlib/RingTheory/Flat/Basic.lean index 6398e62b89386..7592d42a7c793 100644 --- a/Mathlib/RingTheory/Flat/Basic.lean +++ b/Mathlib/RingTheory/Flat/Basic.lean @@ -3,17 +3,16 @@ Copyright (c) 2020 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Jujian Zhang -/ -import Mathlib.RingTheory.Noetherian -import Mathlib.Algebra.DirectSum.Module import Mathlib.Algebra.DirectSum.Finsupp -import Mathlib.Algebra.Module.Projective -import Mathlib.Algebra.Module.Injective +import Mathlib.Algebra.DirectSum.Module +import Mathlib.Algebra.Exact import Mathlib.Algebra.Module.CharacterModule +import Mathlib.Algebra.Module.Injective +import Mathlib.Algebra.Module.Projective import Mathlib.LinearAlgebra.DirectSum.TensorProduct import Mathlib.LinearAlgebra.FreeModule.Basic -import Mathlib.Algebra.Module.Projective import Mathlib.LinearAlgebra.TensorProduct.RightExactness -import Mathlib.Algebra.Exact +import Mathlib.RingTheory.Noetherian /-! # Flat modules diff --git a/Mathlib/RingTheory/Generators.lean b/Mathlib/RingTheory/Generators.lean index 147df9df37990..674ad9174b4c1 100644 --- a/Mathlib/RingTheory/Generators.lean +++ b/Mathlib/RingTheory/Generators.lean @@ -45,7 +45,7 @@ variable (R : Type u) (S : Type v) [CommRing R] [CommRing S] [Algebra R S] 2. `val : vars → S`: The assignment of each variable to a value in `S`. 3. `σ`: A section of `R[X] → S`. -/ structure Algebra.Generators where - /-- The type of variables. -/ + /-- The type of variables. -/ vars : Type w /-- The assignment of each variable to a value in `S`. -/ val : vars → S @@ -381,10 +381,10 @@ instance : AddCommGroup P.Cotangent := inferInstanceAs (AddCommGroup P.ker.Cotan variable {P} -/-- The identity map `P.ker.Cotangent → P.Cotangent` into the type synonym. -/ +/-- The identity map `P.ker.Cotangent → P.Cotangent` into the type synonym. -/ def Cotangent.of (x : P.ker.Cotangent) : P.Cotangent := x -/-- The identity map `P.Cotangent → P.ker.Cotangent` from the type synonym. -/ +/-- The identity map `P.Cotangent → P.ker.Cotangent` from the type synonym. -/ def Cotangent.val (x : P.Cotangent) : P.ker.Cotangent := x @[ext] diff --git a/Mathlib/RingTheory/GradedAlgebra/Basic.lean b/Mathlib/RingTheory/GradedAlgebra/Basic.lean index 458f9d5da4ef5..0d6693692b34f 100644 --- a/Mathlib/RingTheory/GradedAlgebra/Basic.lean +++ b/Mathlib/RingTheory/GradedAlgebra/Basic.lean @@ -207,7 +207,7 @@ end DirectSum open DirectSum -/-- The projection maps of graded algebra-/ +/-- The projection maps of graded algebra -/ def GradedAlgebra.proj (𝒜 : ι → Submodule R A) [GradedAlgebra 𝒜] (i : ι) : A →ₗ[R] A := (𝒜 i).subtype.comp <| (DFinsupp.lapply i).comp <| (decomposeAlgEquiv 𝒜).toAlgHom.toLinearMap diff --git a/Mathlib/RingTheory/HahnSeries/PowerSeries.lean b/Mathlib/RingTheory/HahnSeries/PowerSeries.lean index e37029a7b20db..1441d746ae5c7 100644 --- a/Mathlib/RingTheory/HahnSeries/PowerSeries.lean +++ b/Mathlib/RingTheory/HahnSeries/PowerSeries.lean @@ -87,7 +87,7 @@ theorem ofPowerSeries_injective : Function.Injective (ofPowerSeries Γ R) := embDomain_injective.comp toPowerSeries.symm.injective /-@[simp] Porting note: removing simp. RHS is more complicated and it makes linter -failures elsewhere-/ +failures elsewhere -/ theorem ofPowerSeries_apply (x : PowerSeries R) : ofPowerSeries Γ R x = HahnSeries.embDomain diff --git a/Mathlib/RingTheory/HahnSeries/Valuation.lean b/Mathlib/RingTheory/HahnSeries/Valuation.lean index 86b6d16e4a9a0..95c72f7dfe144 100644 --- a/Mathlib/RingTheory/HahnSeries/Valuation.lean +++ b/Mathlib/RingTheory/HahnSeries/Valuation.lean @@ -35,7 +35,7 @@ section Valuation variable (Γ R) [LinearOrderedCancelAddCommMonoid Γ] [Ring R] [IsDomain R] /-- The additive valuation on `HahnSeries Γ R`, returning the smallest index at which - a Hahn Series has a nonzero coefficient, or `⊤` for the 0 series. -/ + a Hahn Series has a nonzero coefficient, or `⊤` for the 0 series. -/ def addVal : AddValuation (HahnSeries Γ R) (WithTop Γ) := AddValuation.of orderTop orderTop_zero (orderTop_one) (fun x y => min_orderTop_le_orderTop_add) fun x y => by diff --git a/Mathlib/RingTheory/Ideal/Basic.lean b/Mathlib/RingTheory/Ideal/Basic.lean index 842ae58530aa9..0cc3762ebc2a3 100644 --- a/Mathlib/RingTheory/Ideal/Basic.lean +++ b/Mathlib/RingTheory/Ideal/Basic.lean @@ -35,7 +35,7 @@ open Set Function open Pointwise /-- A (left) ideal in a semiring `R` is an additive submonoid `s` such that -`a * b ∈ s` whenever `b ∈ s`. If `R` is a ring, then `s` is an additive subgroup. -/ +`a * b ∈ s` whenever `b ∈ s`. If `R` is a ring, then `s` is an additive subgroup. -/ abbrev Ideal (R : Type u) [Semiring R] := Submodule R R diff --git a/Mathlib/RingTheory/Kaehler/Basic.lean b/Mathlib/RingTheory/Kaehler/Basic.lean index 86e28d6dc447c..5e6d63a739b96 100644 --- a/Mathlib/RingTheory/Kaehler/Basic.lean +++ b/Mathlib/RingTheory/Kaehler/Basic.lean @@ -320,7 +320,7 @@ theorem KaehlerDifferential.tensorProductTo_surjective : exact ⟨x, KaehlerDifferential.D_tensorProductTo x⟩ /-- The `S`-linear maps from `Ω[S⁄R]` to `M` are (`S`-linearly) equivalent to `R`-derivations -from `S` to `M`. -/ +from `S` to `M`. -/ @[simps! symm_apply apply_apply] def KaehlerDifferential.linearMapEquivDerivation : (Ω[S⁄R] →ₗ[S] M) ≃ₗ[S] Derivation R S M := { Derivation.llcomp.flip <| KaehlerDifferential.D R S with diff --git a/Mathlib/RingTheory/LaurentSeries.lean b/Mathlib/RingTheory/LaurentSeries.lean index 7ea03ca4e499d..e05bf0496cf21 100644 --- a/Mathlib/RingTheory/LaurentSeries.lean +++ b/Mathlib/RingTheory/LaurentSeries.lean @@ -101,7 +101,7 @@ theorem coeff_coe_powerSeries (x : PowerSeries R) (n : ℕ) : /-- This is a power series that can be multiplied by an integer power of `X` to give our Laurent series. If the Laurent series is nonzero, `powerSeriesPart` has a nonzero - constant term. -/ + constant term. -/ def powerSeriesPart (x : LaurentSeries R) : PowerSeries R := PowerSeries.mk fun n => x.coeff (x.order + n) diff --git a/Mathlib/RingTheory/LittleWedderburn.lean b/Mathlib/RingTheory/LittleWedderburn.lean index bb054fb0dc9a4..008ec6379f2f2 100644 --- a/Mathlib/RingTheory/LittleWedderburn.lean +++ b/Mathlib/RingTheory/LittleWedderburn.lean @@ -96,7 +96,7 @@ private theorem center_eq_top [Finite D] (hD : InductionHyp D) : Subring.center refine not_le_of_lt hZ.lt_top (fun y _ ↦ Subring.mem_center_iff.mpr fun z ↦ ?_) obtain ⟨r, rfl⟩ := hx y obtain ⟨s, rfl⟩ := hx z - rw [smul_mul_smul, smul_mul_smul, mul_comm] + rw [smul_mul_smul_comm, smul_mul_smul_comm, mul_comm] rw [Nat.cast_sum] apply Finset.dvd_sum rintro ⟨x⟩ hx diff --git a/Mathlib/RingTheory/MvPolynomial/WeightedHomogeneous.lean b/Mathlib/RingTheory/MvPolynomial/WeightedHomogeneous.lean index bf1081b37296f..a5d6459f7d56f 100644 --- a/Mathlib/RingTheory/MvPolynomial/WeightedHomogeneous.lean +++ b/Mathlib/RingTheory/MvPolynomial/WeightedHomogeneous.lean @@ -582,7 +582,7 @@ theorem weightedHomogeneousComponent_eq_zero_of_not_mem [DecidableEq M] variable (R) -/-- The `decompose'` argument of `weightedDecomposition`. -/ +/-- The `decompose'` argument of `weightedDecomposition`. -/ def decompose' [DecidableEq M] := fun φ : MvPolynomial σ R => DirectSum.mk (fun i : M => ↥(weightedHomogeneousSubmodule R w i)) (Finset.image (weight w) φ.support) fun m => diff --git a/Mathlib/RingTheory/Nakayama.lean b/Mathlib/RingTheory/Nakayama.lean index 3c19bfdae99d5..2cf0c3850d107 100644 --- a/Mathlib/RingTheory/Nakayama.lean +++ b/Mathlib/RingTheory/Nakayama.lean @@ -46,7 +46,7 @@ namespace Submodule /-- **Nakayama's Lemma** - A slightly more general version of (2) in [Stacks 00DV](https://stacks.math.columbia.edu/tag/00DV). -See also `eq_bot_of_le_smul_of_le_jacobson_bot` for the special case when `J = ⊥`. -/ +See also `eq_bot_of_le_smul_of_le_jacobson_bot` for the special case when `J = ⊥`. -/ theorem eq_smul_of_le_smul_of_le_jacobson {I J : Ideal R} {N : Submodule R M} (hN : N.FG) (hIN : N ≤ I • N) (hIjac : I ≤ jacobson J) : N = J • N := by refine le_antisymm ?_ (Submodule.smul_le.2 fun _ _ _ => Submodule.smul_mem _ _) @@ -123,7 +123,7 @@ theorem sup_eq_sup_smul_of_le_smul_of_le_jacobson {I J : Ideal R} {N N' : Submod /-- **Nakayama's Lemma** - A slightly more general version of (4) in [Stacks 00DV](https://stacks.math.columbia.edu/tag/00DV). -See also `smul_le_of_le_smul_of_le_jacobson_bot` for the special case when `J = ⊥`. -/ +See also `smul_le_of_le_smul_of_le_jacobson_bot` for the special case when `J = ⊥`. -/ theorem sup_smul_eq_sup_smul_of_le_smul_of_le_jacobson {I J : Ideal R} {N N' : Submodule R M} (hN' : N'.FG) (hIJ : I ≤ jacobson J) (hNN : N' ≤ N ⊔ I • N') : N ⊔ I • N' = N ⊔ J • N' := ((sup_le_sup_left smul_le_right _).antisymm (sup_le le_sup_left hNN)).trans diff --git a/Mathlib/RingTheory/NonUnitalSubring/Basic.lean b/Mathlib/RingTheory/NonUnitalSubring/Basic.lean index 0a1478bc862f1..3d5642917f222 100644 --- a/Mathlib/RingTheory/NonUnitalSubring/Basic.lean +++ b/Mathlib/RingTheory/NonUnitalSubring/Basic.lean @@ -743,7 +743,7 @@ theorem mem_closure_iff {s : Set R} {x} : mul_mem hx hy) (zero_mem _) (fun x y hx hy => add_mem hx hy) fun x hx => neg_mem hx⟩ -/-- If all elements of `s : Set A` commute pairwise, then `closure s` is a commutative ring. -/ +/-- If all elements of `s : Set A` commute pairwise, then `closure s` is a commutative ring. -/ def closureNonUnitalCommRingOfComm {R : Type u} [NonUnitalRing R] {s : Set R} (hcomm : ∀ a ∈ s, ∀ b ∈ s, a * b = b * a) : NonUnitalCommRing (closure s) := { (closure s).toNonUnitalRing with diff --git a/Mathlib/RingTheory/Polynomial/Basic.lean b/Mathlib/RingTheory/Polynomial/Basic.lean index 4c1c2f5af2002..f8a24b9466bbf 100644 --- a/Mathlib/RingTheory/Polynomial/Basic.lean +++ b/Mathlib/RingTheory/Polynomial/Basic.lean @@ -173,6 +173,34 @@ theorem degreeLT_succ_eq_degreeLE {n : ℕ} : degreeLT R (n + 1) = degreeLE R n · rw [mem_degreeLT, mem_degreeLE, ← natDegree_lt_iff_degree_lt (by rwa [ne_eq]), ← natDegree_le_iff_degree_le, Nat.lt_succ] +/-- The equivalence between monic polynomials of degree `n` and polynomials of degree less than +`n`, formed by adding a term `X ^ n`. -/ +def monicEquivDegreeLT [Nontrivial R] (n : ℕ) : + { p : R[X] // p.Monic ∧ p.natDegree = n } ≃ degreeLT R n where + toFun p := ⟨p.1.eraseLead, by + rcases p with ⟨p, hp, rfl⟩ + simp only [mem_degreeLT] + refine lt_of_lt_of_le ?_ degree_le_natDegree + exact degree_eraseLead_lt (ne_zero_of_ne_zero_of_monic one_ne_zero hp)⟩ + invFun := fun p => + ⟨X^n + p.1, monic_X_pow_add (mem_degreeLT.1 p.2), by + rw [natDegree_add_eq_left_of_degree_lt] + · simp + · simp [mem_degreeLT.1 p.2]⟩ + left_inv := by + rintro ⟨p, hp, rfl⟩ + ext1 + simp only + conv_rhs => rw [← eraseLead_add_C_mul_X_pow p] + simp [Monic.def.1 hp, add_comm] + right_inv := by + rintro ⟨p, hp⟩ + ext1 + simp only + rw [eraseLead_add_of_degree_lt_left] + · simp + · simp [mem_degreeLT.1 hp] + /-- For every polynomial `p` in the span of a set `s : Set R[X]`, there exists a polynomial of `p' ∈ s` with higher degree. See also `Polynomial.exists_degree_le_of_mem_span_of_finite`. -/ theorem exists_degree_le_of_mem_span {s : Set R[X]} {p : R[X]} @@ -219,7 +247,7 @@ theorem span_of_finite_le_degreeLT {s : Set R[X]} (s_fin : s.Finite) : exact ⟨n + 1, by rwa [degreeLT_succ_eq_degreeLE]⟩ /-- If `R` is a nontrivial ring, the polynomials `R[X]` are not finite as an `R`-module. When `R` is -a field, this is equivalent to `R[X]` being an infinite-dimensional vector space over `R`. -/ +a field, this is equivalent to `R[X]` being an infinite-dimensional vector space over `R`. -/ theorem not_finite [Nontrivial R] : ¬ Module.Finite R R[X] := by rw [Module.finite_def, Submodule.fg_def] push_neg diff --git a/Mathlib/RingTheory/Polynomial/Content.lean b/Mathlib/RingTheory/Polynomial/Content.lean index 273f4f4ba8827..c92ff552d810e 100644 --- a/Mathlib/RingTheory/Polynomial/Content.lean +++ b/Mathlib/RingTheory/Polynomial/Content.lean @@ -207,7 +207,7 @@ theorem IsPrimitive.content_eq_one {p : R[X]} (hp : p.IsPrimitive) : p.content = section PrimPart /-- The primitive part of a polynomial `p` is the primitive polynomial gained by dividing `p` by - `p.content`. If `p = 0`, then `p.primPart = 1`. -/ + `p.content`. If `p = 0`, then `p.primPart = 1`. -/ noncomputable def primPart (p : R[X]) : R[X] := letI := Classical.decEq R if p = 0 then 1 else Classical.choose (C_content_dvd p) diff --git a/Mathlib/RingTheory/PowerSeries/Order.lean b/Mathlib/RingTheory/PowerSeries/Order.lean index f73b2bb21d977..cec9d16a7d726 100644 --- a/Mathlib/RingTheory/PowerSeries/Order.lean +++ b/Mathlib/RingTheory/PowerSeries/Order.lean @@ -272,7 +272,7 @@ theorem order_eq_multiplicity_X {R : Type*} [Semiring R] [@DecidableRel R⟦X⟧ exact Nat.lt_succ_self _ /-- Given a non-zero power series `f`, `divided_by_X_pow_order f` is the power series obtained by - dividing out the largest power of X that divides `f`, that is its order-/ + dividing out the largest power of X that divides `f`, that is its order -/ def divided_by_X_pow_order {f : PowerSeries R} (hf : f ≠ 0) : R⟦X⟧ := (exists_eq_mul_right_of_dvd (X_pow_order_dvd (order_finite_iff_ne_zero.2 hf))).choose diff --git a/Mathlib/RingTheory/Presentation.lean b/Mathlib/RingTheory/Presentation.lean index 5dfe5599b9bc1..b7d31cd531382 100644 --- a/Mathlib/RingTheory/Presentation.lean +++ b/Mathlib/RingTheory/Presentation.lean @@ -56,7 +56,7 @@ each relation to a polynomial in the generators. -/ @[nolint checkUnivs] structure Algebra.Presentation extends Algebra.Generators.{w} R S where - /-- The type of relations. -/ + /-- The type of relations. -/ rels : Type t /-- The assignment of each relation to a polynomial in the generators. -/ relation : rels → toGenerators.Ring diff --git a/Mathlib/RingTheory/TensorProduct/Basic.lean b/Mathlib/RingTheory/TensorProduct/Basic.lean index 228b5be3855a4..4319a9c0583ba 100644 --- a/Mathlib/RingTheory/TensorProduct/Basic.lean +++ b/Mathlib/RingTheory/TensorProduct/Basic.lean @@ -779,7 +779,7 @@ Note that if `A` is commutative this can be instantiated with `S = A`. -/ protected nonrec def rid : A ⊗[R] R ≃ₐ[S] A := algEquivOfLinearEquivTensorProduct (AlgebraTensorModule.rid R S A) - (fun a₁ a₂ r₁ r₂ => smul_mul_smul r₁ r₂ a₁ a₂ |>.symm) + (fun a₁ a₂ r₁ r₂ => smul_mul_smul_comm r₁ a₁ r₂ a₂ |>.symm) (one_smul R _) @[simp] theorem rid_toLinearEquiv : diff --git a/Mathlib/RingTheory/UniqueFactorizationDomain.lean b/Mathlib/RingTheory/UniqueFactorizationDomain.lean index 6c8cde46f8b98..37edad2347602 100644 --- a/Mathlib/RingTheory/UniqueFactorizationDomain.lean +++ b/Mathlib/RingTheory/UniqueFactorizationDomain.lean @@ -1975,3 +1975,5 @@ lemma factors_multiset_prod_of_irreducible {s : Multiset ℕ} (h : ∀ x : ℕ, exact fun con ↦ not_irreducible_zero (h 0 con) end Nat + +set_option linter.style.longFile 2100 diff --git a/Mathlib/SetTheory/Cardinal/Basic.lean b/Mathlib/SetTheory/Cardinal/Basic.lean index bf03366d250b6..47c10c835097e 100644 --- a/Mathlib/SetTheory/Cardinal/Basic.lean +++ b/Mathlib/SetTheory/Cardinal/Basic.lean @@ -1993,3 +1993,5 @@ end Cardinal -- failed -- end Tactic + +set_option linter.style.longFile 2100 diff --git a/Mathlib/SetTheory/Cardinal/CountableCover.lean b/Mathlib/SetTheory/Cardinal/CountableCover.lean index 35f9e9f8483e6..65caa5dd364f5 100644 --- a/Mathlib/SetTheory/Cardinal/CountableCover.lean +++ b/Mathlib/SetTheory/Cardinal/CountableCover.lean @@ -25,7 +25,7 @@ universe u v /-- If a set `t` is eventually covered by a countable family of sets, all with cardinality at most `a`, then the cardinality of `t` is also bounded by `a`. -Supersed by `mk_le_of_countable_eventually_mem` which does not assume +Superseded by `mk_le_of_countable_eventually_mem` which does not assume that the indexing set lives in the same universe. -/ lemma mk_subtype_le_of_countable_eventually_mem_aux {α ι : Type u} {a : Cardinal} [Countable ι] {f : ι → Set α} {l : Filter ι} [NeBot l] diff --git a/Mathlib/SetTheory/Game/Basic.lean b/Mathlib/SetTheory/Game/Basic.lean index b8a4c1008298e..3d4dbdefcd7a7 100644 --- a/Mathlib/SetTheory/Game/Basic.lean +++ b/Mathlib/SetTheory/Game/Basic.lean @@ -134,7 +134,7 @@ end Game namespace PGame --- Porting note: In a lot of places, I had to add explicitely that the quotient element was a Game. +-- Porting note: In a lot of places, I had to add explicitly that the quotient element was a Game. -- In Lean4, quotients don't have the setoid as an instance argument, -- but as an explicit argument, see https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/confusion.20between.20equivalence.20and.20instance.20setoid/near/360822354 theorem le_iff_game_le {x y : PGame} : x ≤ y ↔ (⟦x⟧ : Game) ≤ ⟦y⟧ := diff --git a/Mathlib/SetTheory/Game/Nim.lean b/Mathlib/SetTheory/Game/Nim.lean index 6ed82c179218b..9253e4a97b9c6 100644 --- a/Mathlib/SetTheory/Game/Nim.lean +++ b/Mathlib/SetTheory/Game/Nim.lean @@ -65,11 +65,11 @@ theorem moveLeft_nim_hEq (o : Ordinal) : theorem moveRight_nim_hEq (o : Ordinal) : HEq (nim o).moveRight fun i : o.toType => nim ((enumIsoToType o).symm i) := by rw [nim_def]; rfl -/-- Turns an ordinal less than `o` into a left move for `nim o` and viceversa. -/ +/-- Turns an ordinal less than `o` into a left move for `nim o` and vice versa. -/ noncomputable def toLeftMovesNim {o : Ordinal} : Set.Iio o ≃ (nim o).LeftMoves := (enumIsoToType o).toEquiv.trans (Equiv.cast (leftMoves_nim o).symm) -/-- Turns an ordinal less than `o` into a right move for `nim o` and viceversa. -/ +/-- Turns an ordinal less than `o` into a right move for `nim o` and vice versa. -/ noncomputable def toRightMovesNim {o : Ordinal} : Set.Iio o ≃ (nim o).RightMoves := (enumIsoToType o).toEquiv.trans (Equiv.cast (rightMoves_nim o).symm) diff --git a/Mathlib/SetTheory/Game/PGame.lean b/Mathlib/SetTheory/Game/PGame.lean index 2f4a23900dd0c..31ab930d55c1c 100644 --- a/Mathlib/SetTheory/Game/PGame.lean +++ b/Mathlib/SetTheory/Game/PGame.lean @@ -676,7 +676,7 @@ instance : IsEquiv _ PGame.Equiv where trans := fun _ _ _ ⟨xy, yx⟩ ⟨yz, zy⟩ => ⟨xy.trans yz, zy.trans yx⟩ symm _ _ := And.symm --- Porting note: moved the setoid instance from Basic.lean to here +-- Porting note: moved the setoid instance from Basic.lean to here instance setoid : Setoid PGame := ⟨Equiv, refl, symm, Trans.trans⟩ @@ -1759,3 +1759,5 @@ theorem zero_lf_one : (0 : PGame) ⧏ 1 := end PGame end SetTheory + +set_option linter.style.longFile 1900 diff --git a/Mathlib/SetTheory/Ordinal/Arithmetic.lean b/Mathlib/SetTheory/Ordinal/Arithmetic.lean index bbfc46be66810..9935d340e56af 100644 --- a/Mathlib/SetTheory/Ordinal/Arithmetic.lean +++ b/Mathlib/SetTheory/Ordinal/Arithmetic.lean @@ -339,7 +339,7 @@ theorem mk_initialSeg (o : Ordinal.{u}) : /-- A normal ordinal function is a strictly increasing function which is order-continuous, i.e., the image `f o` of a limit ordinal `o` is the sup of `f a` for - `a < o`. -/ + `a < o`. -/ def IsNormal (f : Ordinal → Ordinal) : Prop := (∀ o, f o < f (succ o)) ∧ ∀ o, IsLimit o → ∀ a, f o ≤ a ↔ ∀ b < o, f b ≤ a @@ -450,7 +450,7 @@ theorem add_isLimit (a) {b} : IsLimit b → IsLimit (a + b) := alias IsLimit.add := add_isLimit -/-! ### Subtraction on ordinals-/ +/-! ### Subtraction on ordinals -/ /-- The set in the definition of subtraction is nonempty. -/ @@ -537,7 +537,7 @@ theorem one_add_omega : 1 + ω = ω := by theorem one_add_of_omega_le {o} (h : ω ≤ o) : 1 + o = o := by rw [← Ordinal.add_sub_cancel_of_le h, ← add_assoc, one_add_omega] -/-! ### Multiplication of ordinals-/ +/-! ### Multiplication of ordinals -/ /-- The multiplication of ordinals `o₁` and `o₂` is the (well founded) lexicographic order on @@ -2263,3 +2263,5 @@ theorem rank_strictAnti [Preorder α] [WellFoundedGT α] : StrictAnti (rank <| @wellFounded_gt α _ _) := fun _ _ => rank_lt_of_rel wellFounded_gt end WellFounded + +set_option linter.style.longFile 2400 diff --git a/Mathlib/SetTheory/Ordinal/FixedPointApproximants.lean b/Mathlib/SetTheory/Ordinal/FixedPointApproximants.lean index 22ea84fdfe087..7cb80b64b2db5 100644 --- a/Mathlib/SetTheory/Ordinal/FixedPointApproximants.lean +++ b/Mathlib/SetTheory/Ordinal/FixedPointApproximants.lean @@ -145,7 +145,7 @@ theorem exists_lfpApprox_eq_lfpApprox : ∃ a < ord <| succ #α, ∃ b < ord <| · exact h_fab /-- If there are distinct ordinals with equal value then - every value succeding the smaller ordinal are fixed points -/ + every value succeeding the smaller ordinal are fixed points -/ lemma lfpApprox_mem_fixedPoints_of_eq {a b c : Ordinal} (h_init : x ≤ f x) (h_ab : a < b) (h_ac : a ≤ c) (h_fab : lfpApprox f x a = lfpApprox f x b) : lfpApprox f x c ∈ fixedPoints f := by diff --git a/Mathlib/SetTheory/Surreal/Multiplication.lean b/Mathlib/SetTheory/Surreal/Multiplication.lean index 3f931a7db4fd7..29f0f225bedb8 100644 --- a/Mathlib/SetTheory/Surreal/Multiplication.lean +++ b/Mathlib/SetTheory/Surreal/Multiplication.lean @@ -173,7 +173,7 @@ open Relation /-- The relation specifying when a list of (pregame) arguments is considered simpler than another: `ArgsRel a₁ a₂` is true if `a₁`, considered as a multiset, can be obtained from `a₂` by - repeatedly removing a pregame from `a₂` and adding back one or two options of the pregame. -/ + repeatedly removing a pregame from `a₂` and adding back one or two options of the pregame. -/ def ArgsRel := InvImage (TransGen <| CutExpand IsOption) Args.toMultiset /-- `ArgsRel` is well-founded. -/ @@ -463,7 +463,7 @@ theorem Equiv.mul_congr_left (hx₁ : x₁.Numeric) (hx₂ : x₂.Numeric) (hy : (he : x₁ ≈ x₂) : x₁ * y ≈ x₂ * y := equiv_iff_game_eq.2 <| (P24 hx₁ hx₂ hy).1 he -theorem Equiv.mul_congr_right (hx : x.Numeric) (hy₁ : y₁.Numeric) (hy₂ : y₂.Numeric) +theorem Equiv.mul_congr_right (hx : x.Numeric) (hy₁ : y₁.Numeric) (hy₂ : y₂.Numeric) (he : y₁ ≈ y₂) : x * y₁ ≈ x * y₂ := .trans (mul_comm_equiv _ _) <| .trans (mul_congr_left hy₁ hy₂ hx he) (mul_comm_equiv _ _) diff --git a/Mathlib/SetTheory/ZFC/Basic.lean b/Mathlib/SetTheory/ZFC/Basic.lean index c6408760cb942..8e729f2ef711b 100644 --- a/Mathlib/SetTheory/ZFC/Basic.lean +++ b/Mathlib/SetTheory/ZFC/Basic.lean @@ -1564,3 +1564,5 @@ noncomputable def toSet_equiv : ZFSet.{u} ≃ {s : Set ZFSet.{u} // Small.{u, u+ right_inv s := Subtype.coe_injective <| toSet_equiv_aux s.2 end ZFSet + +set_option linter.style.longFile 1700 diff --git a/Mathlib/Tactic/CC/Addition.lean b/Mathlib/Tactic/CC/Addition.lean index 466bca911a779..3c63cb79c8fa9 100644 --- a/Mathlib/Tactic/CC/Addition.lean +++ b/Mathlib/Tactic/CC/Addition.lean @@ -2099,3 +2099,5 @@ def add (type : Expr) (proof : Expr) : CCM Unit := do end CCM end Mathlib.Tactic.CC + +set_option linter.style.longFile 2300 diff --git a/Mathlib/Tactic/CC/Datatypes.lean b/Mathlib/Tactic/CC/Datatypes.lean index 829f0375c5cf8..6c11094d2ff5a 100644 --- a/Mathlib/Tactic/CC/Datatypes.lean +++ b/Mathlib/Tactic/CC/Datatypes.lean @@ -667,7 +667,7 @@ end CCState /-- The congruence closure module (optionally) uses a normalizer. The idea is to use it (if available) to normalize auxiliary expressions - produced by internal propagation rules (e.g., subsingleton propagator). -/ + produced by internal propagation rules (e.g., subsingleton propagator). -/ structure CCNormalizer where normalize : Expr → MetaM Expr diff --git a/Mathlib/Tactic/CategoryTheory/Reassoc.lean b/Mathlib/Tactic/CategoryTheory/Reassoc.lean index d83662642b472..eedc010454f06 100644 --- a/Mathlib/Tactic/CategoryTheory/Reassoc.lean +++ b/Mathlib/Tactic/CategoryTheory/Reassoc.lean @@ -29,7 +29,7 @@ namespace CategoryTheory variable {C : Type*} [Category C] -/-- A variant of `eq_whisker` with a more convenient argument order for use in tactics. -/ +/-- A variant of `eq_whisker` with a more convenient argument order for use in tactics. -/ theorem eq_whisker' {X Y : C} {f g : X ⟶ Y} (w : f = g) {Z : C} (h : Y ⟶ Z) : f ≫ h = g ≫ h := by rw [w] diff --git a/Mathlib/Tactic/DefEqTransformations.lean b/Mathlib/Tactic/DefEqTransformations.lean index f84e06c214a9f..1bd541cc82ae7 100644 --- a/Mathlib/Tactic/DefEqTransformations.lean +++ b/Mathlib/Tactic/DefEqTransformations.lean @@ -247,7 +247,7 @@ elab "eta_reduce" : conv => runDefEqConvTactic etaReduceAll /-- Eta expand every sub-expression in the given expression. -As a side-effect, beta reduces any pre-existing instances of eta expanded terms. -/ +As a side-effect, beta reduces any pre-existing instances of eta expanded terms. -/ partial def etaExpandAll (e : Expr) : MetaM Expr := do let betaOrApp (f : Expr) (args : Array Expr) : Expr := if f.etaExpanded?.isSome then f.beta args else mkAppN f args diff --git a/Mathlib/Tactic/FunProp/ContDiff.lean b/Mathlib/Tactic/FunProp/ContDiff.lean index 636f5fa0db5bf..adc20fffe2b95 100644 --- a/Mathlib/Tactic/FunProp/ContDiff.lean +++ b/Mathlib/Tactic/FunProp/ContDiff.lean @@ -81,7 +81,7 @@ variable {F : Type*} [NormedAddCommGroup F] [NormedSpace K F] and `funProp` can't work with such theorem. The theorem should be state where `n` is explicitly the smallest possible value i.e. `n=m+1`. -In conjunction with `ContDiff.of_le` we can recover the full power of the original theorem. -/ +In conjunction with `ContDiff.of_le` we can recover the full power of the original theorem. -/ theorem ContDiff.differentiable_iteratedDeriv' {m : ℕ} {f : K → F} (hf : ContDiff K (m+1) f) : Differentiable K (iteratedDeriv m f) := ContDiff.differentiable_iteratedDeriv m hf (Nat.cast_lt.mpr m.lt_succ_self) diff --git a/Mathlib/Tactic/FunProp/Core.lean b/Mathlib/Tactic/FunProp/Core.lean index 3e570580848bc..08844f5b90093 100644 --- a/Mathlib/Tactic/FunProp/Core.lean +++ b/Mathlib/Tactic/FunProp/Core.lean @@ -39,28 +39,23 @@ synthesized value{indentExpr val}\nis not definitionally equal to{indentExpr x}" return false -/-- Synthesize arguments `xs` either with typeclass synthesis, -with `fun_prop` or with a discharger. -/ -def synthesizeArgs (thmId : Origin) (xs : Array Expr) (bis : Array BinderInfo) + +/-- Synthesize arguments `xs` either with typeclass synthesis, with `fun_prop` or with +discharger. -/ +def synthesizeArgs (thmId : Origin) (xs : Array Expr) (funProp : Expr → FunPropM (Option Result)) : FunPropM Bool := do let mut postponed : Array Expr := #[] - for x in xs, bi in bis do + for x in xs do let type ← inferType x - if bi.isInstImplicit then - unless (← synthesizeInstance thmId x type) do - logError s!"Failed to synthesize instance `{← ppExpr type}` \ - when applying theorem `{← ppOrigin' thmId}`." - return false - else if (← instantiateMVars x).isMVar then + if (← instantiateMVars x).isMVar then -- try type class if (← isClass? type).isSome then if (← synthesizeInstance thmId x type) then continue - - -- try function property - if (← isFunProp type.getForallBody) then + else if (← isFunProp type.getForallBody) then + -- try function property if let .some ⟨proof⟩ ← funProp type then if (← isDefEq x proof) then continue @@ -104,14 +99,14 @@ def synthesizeArgs (thmId : Origin) (xs : Array Expr) (bis : Array BinderInfo) /-- Try to apply theorem - core function -/ -def tryTheoremCore (xs : Array Expr) (bis : Array BinderInfo) (val : Expr) (type : Expr) (e : Expr) +def tryTheoremCore (xs : Array Expr) (val : Expr) (type : Expr) (e : Expr) (thmId : Origin) (funProp : Expr → FunPropM (Option Result)) : FunPropM (Option Result) := do withTraceNode `Meta.Tactic.fun_prop (fun r => return s!"[{ExceptToEmoji.toEmoji r}] applying: {← ppOrigin' thmId}") do if (← isDefEq type e) then - if ¬(← synthesizeArgs thmId xs bis funProp) then + if ¬(← synthesizeArgs thmId xs funProp) then return none let proof ← instantiateMVars (mkAppN val xs) @@ -129,7 +124,7 @@ def tryTheoremWithHint? (e : Expr) (thmOrigin : Origin) let go : FunPropM (Option Result) := do let thmProof ← thmOrigin.getValue let type ← inferType thmProof - let (xs, bis, type) ← forallMetaTelescope type + let (xs, _, type) ← forallMetaTelescope type for (i,x) in hint do try @@ -139,7 +134,7 @@ def tryTheoremWithHint? (e : Expr) (thmOrigin : Origin) trace[Meta.Tactic.fun_trans] "failed to use hint {i} `{← ppExpr x} when applying theorem {← ppOrigin thmOrigin}" - tryTheoremCore xs bis thmProof type e thmOrigin funProp + tryTheoremCore xs thmProof type e thmOrigin funProp -- `simp` introduces new meta variable context depth for some reason -- This is probably to avoid mvar assignment when trying a theorem fails @@ -228,7 +223,7 @@ Try to prove `e` using *composition lambda theorem*. For example, `e = q(Continuous fun x => f (g x))` and `funPropDecl` is `FunPropDecl` for `Continuous` -You also have to provide the functions `f` and `g`. -/ +You also have to provide the functions `f` and `g`. -/ def applyCompRule (funPropDecl : FunPropDecl) (e f g : Expr) (funProp : Expr → FunPropM (Option Result)) : FunPropM (Option Result) := do @@ -346,7 +341,7 @@ def applyMorRules (funPropDecl : FunPropDecl) (e : Expr) (fData : FunctionData) trace[Debug.Meta.Tactic.fun_prop] "no theorem matched" return none -/-- Prove function property of using *transition theorems*. -/ +/-- Prove function property of using *transition theorems*. -/ def applyTransitionRules (e : Expr) (funProp : Expr → FunPropM (Option Result)) : FunPropM (Option Result) := do withIncreasedTransitionDepth do diff --git a/Mathlib/Tactic/FunProp/Mor.lean b/Mathlib/Tactic/FunProp/Mor.lean index 29a860cf1bdf2..4ac97d317ff1c 100644 --- a/Mathlib/Tactic/FunProp/Mor.lean +++ b/Mathlib/Tactic/FunProp/Mor.lean @@ -89,7 +89,7 @@ Weak normal head form of an expression involving morphism applications. For example calling this on `coe (f a) b` will put `f` in weak normal head form instead of `coe`. -/ -def whnf (e : Expr) (cfg : WhnfCoreConfig := {}) : MetaM Expr := +def whnf (e : Expr) (cfg : WhnfCoreConfig := {}) : MetaM Expr := whnfPred e (fun _ => return false) cfg diff --git a/Mathlib/Tactic/FunProp/Types.lean b/Mathlib/Tactic/FunProp/Types.lean index e206436640a9e..6f12b788e1928 100644 --- a/Mathlib/Tactic/FunProp/Types.lean +++ b/Mathlib/Tactic/FunProp/Types.lean @@ -153,7 +153,7 @@ function property like continuity from another property like differentiability. The main reason is that if the user forgets to add a continuity theorem for function `foo` then `fun_prop` should report that there is a continuity theorem for `foo` missing. If we would log messages `transitionDepth > 0` then user will see messages saying that there is a missing theorem -for differentiability, smoothness, ... for `foo`. -/ +for differentiability, smoothness, ... for `foo`. -/ def logError (msg : String) : FunPropM Unit := do if (← read).transitionDepth = 0 then modify fun s => diff --git a/Mathlib/Tactic/GeneralizeProofs.lean b/Mathlib/Tactic/GeneralizeProofs.lean index 8bb825b5909f9..66db02468e3c5 100644 --- a/Mathlib/Tactic/GeneralizeProofs.lean +++ b/Mathlib/Tactic/GeneralizeProofs.lean @@ -152,7 +152,7 @@ def appArgExpectedTypes (f : Expr) (args : Array Expr) (ty? : Option Expr) : -- Try using the expected type, but (*) below might find a bad solution (guard ty?.isSome *> go f args ty?) <|> go f args none where - /-- Core implementation for `appArgExpectedTypes`. -/ + /-- Core implementation for `appArgExpectedTypes`. -/ go (f : Expr) (args : Array Expr) (ty? : Option Expr) : MetaM (Array (Option Expr)) := do -- Metavariables for each argument to `f`: let mut margs := #[] diff --git a/Mathlib/Tactic/HelpCmd.lean b/Mathlib/Tactic/HelpCmd.lean index 5587ad008455a..1dafab19653f5 100644 --- a/Mathlib/Tactic/HelpCmd.lean +++ b/Mathlib/Tactic/HelpCmd.lean @@ -69,7 +69,7 @@ private def elabHelpOption (id : Option Ident) : CommandElabM Unit := do | .ofInt val => s!"Int := {repr val}" | .ofSyntax val => s!"Syntax := {repr val}" if let some val := opts.find (.mkSimple name) then - msg1 := s!"{msg1} (currently: {val})" + msg1 := s!"{msg1} (currently: {val})" msg := msg ++ .nest 2 (f!"option {name} : {msg1}" ++ .line ++ decl.descr) ++ .line ++ .line logInfo msg diff --git a/Mathlib/Tactic/IrreducibleDef.lean b/Mathlib/Tactic/IrreducibleDef.lean index 2d3987da6409c..bfdf7272c85bd 100644 --- a/Mathlib/Tactic/IrreducibleDef.lean +++ b/Mathlib/Tactic/IrreducibleDef.lean @@ -50,7 +50,7 @@ local elab "eta_helper " t:term : term => do let lhs := (mkAppN lhs xs).headBeta mkForallFVars xs <|← mkEq lhs rhs -/-- `val_proj x` elabs to the *primitive projection* `@x.val`. -/ +/-- `val_proj x` elabs to the *primitive projection* `@x.val`. -/ local elab "val_proj " e:term : term => do let e ← elabTerm (← `(($e : Subtype _))) none return mkProj ``Subtype 0 e diff --git a/Mathlib/Tactic/Linarith/Preprocessing.lean b/Mathlib/Tactic/Linarith/Preprocessing.lean index 8d0a1bbd44edd..2a496d4cd5670 100644 --- a/Mathlib/Tactic/Linarith/Preprocessing.lean +++ b/Mathlib/Tactic/Linarith/Preprocessing.lean @@ -306,7 +306,7 @@ section nlinarith `findSquares s e` collects all terms of the form `a ^ 2` and `a * a` that appear in `e` and adds them to the set `s`. A pair `(i, true)` is added to `s` when `atoms[i]^2` appears in `e`, -and `(i, false)` is added to `s` when `atoms[i]*atoms[i]` appears in `e`. -/ +and `(i, false)` is added to `s` when `atoms[i]*atoms[i]` appears in `e`. -/ partial def findSquares (s : RBSet (Nat × Bool) lexOrd.compare) (e : Expr) : AtomM (RBSet (Nat × Bool) lexOrd.compare) := -- Completely traversing the expression is non-ideal, diff --git a/Mathlib/Tactic/Linter/AdmitLinter.lean b/Mathlib/Tactic/Linter/AdmitLinter.lean index cc7fdbfb2ce62..602952c5a6692 100644 --- a/Mathlib/Tactic/Linter/AdmitLinter.lean +++ b/Mathlib/Tactic/Linter/AdmitLinter.lean @@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Damiano Testa, Adomas Baliuka -/ import Lean.Elab.Command -import Lean.Linter.Util /-! # The "admit" linter diff --git a/Mathlib/Tactic/Linter/GlobalAttributeIn.lean b/Mathlib/Tactic/Linter/GlobalAttributeIn.lean index 578c12d114d36..6a6c49e09f4ad 100644 --- a/Mathlib/Tactic/Linter/GlobalAttributeIn.lean +++ b/Mathlib/Tactic/Linter/GlobalAttributeIn.lean @@ -5,7 +5,6 @@ Authors: Michael Rothgang, Damiano Testa -/ import Lean.Elab.Command -import Lean.Linter.Util /-! # Linter for `attribute [...] in` declarations diff --git a/Mathlib/Tactic/Linter/HashCommandLinter.lean b/Mathlib/Tactic/Linter/HashCommandLinter.lean index fcb0b9cbaba7e..bf4f7378724d2 100644 --- a/Mathlib/Tactic/Linter/HashCommandLinter.lean +++ b/Mathlib/Tactic/Linter/HashCommandLinter.lean @@ -5,7 +5,6 @@ Authors: Damiano Testa -/ import Lean.Elab.Command -import Lean.Linter.Util /-! # `#`-command linter diff --git a/Mathlib/Tactic/Linter/Lint.lean b/Mathlib/Tactic/Linter/Lint.lean index b7045eb799f9c..11dcd40a2654a 100644 --- a/Mathlib/Tactic/Linter/Lint.lean +++ b/Mathlib/Tactic/Linter/Lint.lean @@ -3,8 +3,6 @@ Copyright (c) 2023 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn -/ - -import Lean.Linter.Util import Batteries.Tactic.Lint /-! @@ -292,6 +290,73 @@ initialize addLinter lambdaSyntaxLinter end Style.lambdaSyntax +/-! +# The "longFile" linter + +The "longFile" linter emits a warning on files which are longer than a certain number of lines +(1500 by default). +-/ + +/-- +The "longFile" linter emits a warning on files which are longer than a certain number of lines +(1500 by default). If this option is set to `N` lines, the linter warns once a file has more than +`N` lines. A value of `0` silences the linter entirely. +-/ +register_option linter.style.longFile : Nat := { + defValue := 1500 + descr := "enable the longFile linter" +} + +namespace Style.longFile + +@[inherit_doc Mathlib.Linter.linter.style.longFile] +def longFileLinter : Linter where run := withSetOptionIn fun stx ↦ do + let linterBound := linter.style.longFile.get (← getOptions) + if linterBound == 0 then + return + let defValue := linter.style.longFile.defValue + let smallOption := match stx with + | `(set_option linter.style.longFile $x) => TSyntax.getNat ⟨x.raw⟩ ≤ defValue + | _ => false + if smallOption then + logWarningAt stx <| .tagged linter.style.longFile.name + m!"The default value of the `longFile` linter is {defValue}.\n\ + The current value of {linterBound} does not exceed the allowed bound.\n\ + Please, remove the `set_option linter.style.longFile {linterBound}`." + else + -- Thanks to the above check, the linter option is either not set (and hence equal + -- to the default) or set to some value *larger* than the default. + -- `Parser.isTerminalCommand` allows `stx` to be `#exit`: this is useful for tests. + unless Parser.isTerminalCommand stx do return + -- We exclude `Mathlib.lean` from the linter: it exceeds linter's default number of allowed + -- lines, and it is an auto-generated import-only file. + -- TODO: if there are more such files, revise the implementation. + if (← getMainModule) == `Mathlib then return + if let some init := stx.getTailPos? then + -- the last line: we subtract 1, since the last line is expected to be empty + let lastLine := ((← getFileMap).toPosition init).line + if lastLine ≤ defValue && defValue < linterBound then + logWarningAt stx <| .tagged linter.style.longFile.name + m!"The default value of the `longFile` linter is {defValue}.\n\ + This file is {lastLine} lines long which does not exceed the allowed bound.\n\ + Please, remove the `set_option linter.style.longFile {linterBound}`." + else + -- `candidate` is divisible by `100` and satisfies `lastLine + 100 < candidate ≤ lastLine + 200` + -- note that either `lastLine ≤ defValue` and `defValue = linterBound` hold or + -- `candidate` is necessarily bigger than `lastLine` and hence bigger than `defValue` + let candidate := (lastLine / 100) * 100 + 200 + let candidate := max candidate defValue + if linterBound < lastLine then + logWarningAt stx <| .tagged linter.style.longFile.name + m!"This file is {lastLine} lines long, but the limit is {linterBound}.\n\n\ + You can extend the allowed length of the file using \ + `set_option linter.style.longFile {candidate}`.\n\ + You can completely disable this linter by setting the length limit to `0`." + +initialize addLinter longFileLinter + +end Style.longFile + /-! # The "longLine linter" -/ /-- The "longLine" linter emits a warning on lines longer than 100 characters. diff --git a/Mathlib/Tactic/Linter/OldObtain.lean b/Mathlib/Tactic/Linter/OldObtain.lean index 23fcde9407eab..0fd427c77bbfe 100644 --- a/Mathlib/Tactic/Linter/OldObtain.lean +++ b/Mathlib/Tactic/Linter/OldObtain.lean @@ -5,7 +5,6 @@ Authors: Michael Rothgang -/ import Lean.Elab.Command -import Lean.Linter.Util /-! # The `oldObtain` linter, against stream-of-conciousness `obtain` diff --git a/Mathlib/Tactic/Linter/RefineLinter.lean b/Mathlib/Tactic/Linter/RefineLinter.lean index 2c06e8b46132a..7bbc39eee11dc 100644 --- a/Mathlib/Tactic/Linter/RefineLinter.lean +++ b/Mathlib/Tactic/Linter/RefineLinter.lean @@ -5,7 +5,6 @@ Authors: Damiano Testa -/ import Lean.Elab.Command -import Lean.Linter.Util /-! # The "refine" linter diff --git a/Mathlib/Tactic/Linter/Style.lean b/Mathlib/Tactic/Linter/Style.lean index a039d920fa6b1..1f737feb7c3ef 100644 --- a/Mathlib/Tactic/Linter/Style.lean +++ b/Mathlib/Tactic/Linter/Style.lean @@ -5,7 +5,6 @@ Authors: Michael Rothgang -/ import Lean.Elab.Command -import Lean.Linter.Util /-! ## Style linters diff --git a/Mathlib/Tactic/Linter/TextBased.lean b/Mathlib/Tactic/Linter/TextBased.lean index ea9430649d8b7..8689ed04b9ac5 100644 --- a/Mathlib/Tactic/Linter/TextBased.lean +++ b/Mathlib/Tactic/Linter/TextBased.lean @@ -26,6 +26,12 @@ these are gradually being rewritten in Lean. This linter maintains a list of exceptions, for legacy reasons. Ideally, the length of the list of exceptions tends to 0. +The `longFile` and the `longLine` *syntax* linter take care of flagging lines that exceed the +100 character limit and files that exceed the 1500 line limit. +The text-based versions of this file are still used for the files where the linter is not imported. +This means that the exceptions for the text-based linters are shorter, as they do not need to +include those handled with `set_option linter.style.longFile x`/`set_option linter.longLine false`. + An executable running all these linters is defined in `scripts/lint-style.lean`. -/ @@ -56,11 +62,6 @@ inductive StyleError where /-- Lint against "too broad" imports, such as `Mathlib.Tactic` or any module in `Lake` (unless carefully measured) -/ | broadImport (module : BroadImports) - /-- The current file was too large: this error contains the current number of lines - as well as a size limit (slightly larger). On future runs, this linter will allow this file - to grow up to this limit. - For diagnostic purposes, this may also contain a previous size limit, which is now exceeded. -/ - | fileTooLong (numberLines : ℕ) (newSizeLimit : ℕ) (previousLimit : Option ℕ) : StyleError deriving BEq /-- How to format style errors -/ @@ -76,7 +77,7 @@ inductive ErrorFormat deriving BEq /-- Create the underlying error message for a given `StyleError`. -/ -def StyleError.errorMessage (err : StyleError) (style : ErrorFormat) : String := match err with +def StyleError.errorMessage (err : StyleError) : String := match err with | StyleError.copyright (some context) => s!"Malformed or missing copyright header: {context}" | StyleError.copyright none => "Malformed or missing copyright header" | StyleError.authors => @@ -89,16 +90,6 @@ def StyleError.errorMessage (err : StyleError) (style : ErrorFormat) : String := "In the past, importing 'Lake' in mathlib has led to dramatic slow-downs of the linter (see \ e.g. mathlib4#13779). Please consider carefully if this import is useful and make sure to \ benchmark it. If this is fine, feel free to allow this linter." - | StyleError.fileTooLong currentSize sizeLimit previousLimit => - match style with - | ErrorFormat.github => - if let some n := previousLimit then - s!"file contains {currentSize} lines (at most {n} allowed), try to split it up" - else - s!"file contains {currentSize} lines, try to split it up" - | ErrorFormat.exceptionsFile => - s!"{sizeLimit} file contains {currentSize} lines, try to split it up" - | ErrorFormat.humanReadable => s!"file contains {currentSize} lines, try to split it up" /-- The error code for a given style error. Keep this in sync with `parse?_errorContext` below! -/ -- FUTURE: we're matching the old codes in `lint-style.py` for compatibility; @@ -108,7 +99,6 @@ def StyleError.errorCode (err : StyleError) : String := match err with | StyleError.authors => "ERR_AUT" | StyleError.adaptationNote => "ERR_ADN" | StyleError.broadImport _ => "ERR_IMP" - | StyleError.fileTooLong _ _ _ => "ERR_NUM_LIN" /-- Context for a style error: the actual error, the line number in the file we're reading and the path to the file. -/ @@ -138,23 +128,14 @@ inductive ComparisonResult and, if it is, if we prefer replacing the new exception or keeping the previous one. -/ def compare (existing new : ErrorContext) : ComparisonResult := -- Two comparable error contexts must have the same path. - if existing.path != new.path then - ComparisonResult.Different + -- To avoid issues with different path separators across different operating systems, + -- we compare the set of path components instead. + if existing.path.components != new.path.components then ComparisonResult.Different -- We entirely ignore their line numbers: not sure if this is best. -- NB: keep the following in sync with `parse?_errorContext` below. -- Generally, comparable errors must have equal `StyleError`s, but there are some exceptions. else match (existing.error, new.error) with - -- File length errors are the biggest exceptions: generally, we prefer to keep the - -- existing entry, *except* when a newer entry is much shorter. - | (StyleError.fileTooLong n nLimit _, StyleError.fileTooLong m _mLimit _) => - -- The only exception are "file too long" errors. - -- If a file got much longer, the existing exception does not apply; - if m > nLimit then ComparisonResult.Different - -- if it does apply, we prefer to keep the existing entry, - -- *unless* the newer entry is much shorter. - else if m + 200 <= n then ComparisonResult.Comparable false - else ComparisonResult.Comparable true -- We do *not* care about the *kind* of wrong copyright, -- nor about the particular length of a too long line. | (StyleError.copyright _, StyleError.copyright _) => ComparisonResult.Comparable true @@ -170,7 +151,7 @@ def ErrorContext.find?_comparable (e : ErrorContext) (exceptions : Array ErrorCo `style` specifies if the error should be formatted for humans to read, github problem matchers to consume, or for the style exceptions file. -/ def outputMessage (errctx : ErrorContext) (style : ErrorFormat) : String := - let errorMessage := errctx.error.errorMessage style + let errorMessage := errctx.error.errorMessage match style with | ErrorFormat.github => -- We are outputting for github: duplicate file path, line number and error code, @@ -209,15 +190,6 @@ def parse?_errorContext (line : String) : Option ErrorContext := Id.run do some (StyleError.broadImport BroadImports.TacticFolder) else some (StyleError.broadImport BroadImports.Lake) - | "ERR_NUM_LIN" => - -- Parse the error message in the script. `none` indicates invalid input. - match (errorMessage.get? 0, errorMessage.get? 3) with - | (some limit, some current) => - match (String.toNat? limit, String.toNat? current) with - | (some sizeLimit, some currentSize) => - some (StyleError.fileTooLong currentSize sizeLimit (some sizeLimit)) - | _ => none - | _ => none | _ => none match String.toNat? lineNumber with | some n => err.map fun e ↦ (ErrorContext.mk e n path) @@ -340,23 +312,6 @@ def isImportsOnlyFile (lines : Array String) : Bool := -- this is in fact not necessary. (It is needed for `Tactic/Linter.lean`, though.) lines.all (fun line ↦ line.startsWith "import " || line == "" || line.startsWith "-- ") -/-- Error if a collection of lines is too large. "Too large" means more than 1500 lines -**and** longer than an optional previous limit. -If the file is too large, return a matching `StyleError`, which includes a new size limit -(which is somewhat larger than the current size). -/ -def checkFileLength (lines : Array String) (existingLimit : Option ℕ) : Option StyleError := - Id.run do - if lines.size > 1500 then - let isLarger : Bool := match existingLimit with - | some mark => lines.size > mark - | none => true - if isLarger then - -- We add about 200 lines of slack to the current file size: small PRs will be unaffected, - -- but sufficiently large PRs will get nudged towards splitting up this file. - return some (StyleError.fileTooLong lines.size - ((Nat.div lines.size 100) * 100 + 200) existingLimit) - none - end /-- All text-based linters registered in this file. -/ @@ -377,17 +332,14 @@ inductive OutputSetting : Type deriving BEq /-- Read a file and apply all text-based linters. Return a list of all unexpected errors. -`sizeLimit` is any pre-existing limit on this file's size. -`exceptions` are any other style exceptions. -/ -def lintFile (path : FilePath) (sizeLimit : Option ℕ) (exceptions : Array ErrorContext) : +`exceptions` are any pre-existing style exceptions for this file. -/ +def lintFile (path : FilePath) (exceptions : Array ErrorContext) : IO (Array ErrorContext) := do let lines ← IO.FS.lines path -- We don't need to run any checks on imports-only files. if isImportsOnlyFile lines then return #[] let mut errors := #[] - if let some (StyleError.fileTooLong n limit ex) := checkFileLength lines sizeLimit then - errors := #[ErrorContext.mk (StyleError.fileTooLong n limit ex) 1 path] let allOutput := (Array.map (fun lint ↦ (Array.map (fun (e, n) ↦ ErrorContext.mk e n path)) (lint lines))) allLinters -- This list is not sorted: for github, this is fine. @@ -416,18 +368,12 @@ def lintModules (moduleNames : Array String) (mode : OutputSetting) (fix : Bool) for module in moduleNames do -- Convert the module name to a file name, then lint that file. let path := (mkFilePath (module.split (· == '.'))).addExtension "lean" - -- Find all size limits for this given file. - -- If several size limits are given (unlikely in practice), we use the first one. - let sizeLimits := (styleExceptions.filter (fun ex ↦ ex.path == path)).filterMap (fun errctx ↦ - match errctx.error with - | StyleError.fileTooLong _ limit _ => some limit - | _ => none) let errors := if let OutputSetting.print _ := mode then - ← lintFile path (sizeLimits.get? 0) styleExceptions + ← lintFile path styleExceptions else -- In "update" mode, we ignore the exceptions file (and only take `nolints` into account). - ← lintFile path none (parseStyleExceptions nolints) + ← lintFile path (parseStyleExceptions nolints) if errors.size > 0 then allUnexpectedErrors := allUnexpectedErrors.append errors numberErrorFiles := numberErrorFiles + 1 diff --git a/Mathlib/Tactic/Linter/UnusedTactic.lean b/Mathlib/Tactic/Linter/UnusedTactic.lean index 47d9b5ebc2141..f04f6e76c29ce 100644 --- a/Mathlib/Tactic/Linter/UnusedTactic.lean +++ b/Mathlib/Tactic/Linter/UnusedTactic.lean @@ -5,7 +5,7 @@ Authors: Damiano Testa -/ import Lean.Elab.Command -import Lean.Linter.Util +import Batteries.Tactic.Unreachable /-! # The unused tactic linter diff --git a/Mathlib/Tactic/Peel.lean b/Mathlib/Tactic/Peel.lean index b3ab2443710a5..0428aed375d7c 100644 --- a/Mathlib/Tactic/Peel.lean +++ b/Mathlib/Tactic/Peel.lean @@ -225,7 +225,7 @@ def peelArgsIff (l : List Name) : TacticM Unit := withMainContext do elab_rules : tactic | `(tactic| peel $[$num?:num]? $e:term $[with $l?* $n?]?) => withMainContext do /- we use `elabTermForApply` instead of `elabTerm` so that terms passed to `peel` can contain - quantifiers with implicit bound variables without causing errors or requiring `@`. -/ + quantifiers with implicit bound variables without causing errors or requiring `@`. -/ let e ← elabTermForApply e false let n? := n?.bind fun n => if n.raw.isIdent then pure n.raw.getId else none let l := (l?.getD #[]).map getNameOfIdent' |>.toList diff --git a/Mathlib/Tactic/PushNeg.lean b/Mathlib/Tactic/PushNeg.lean index ec451c4c090af..07699624b4fc5 100644 --- a/Mathlib/Tactic/PushNeg.lean +++ b/Mathlib/Tactic/PushNeg.lean @@ -5,11 +5,10 @@ Authors: Patrick Massot, Simon Hudon, Alice Laroche, Frédéric Dupuis, Jireh Lo -/ import Lean.Elab.Tactic.Location +import Mathlib.Data.Set.Defs import Mathlib.Logic.Basic import Mathlib.Order.Defs import Mathlib.Tactic.Conv -import Mathlib.Data.Set.Defs -import Lean.Elab.Tactic.Location /-! # The `push_neg` tactic diff --git a/Mathlib/Tactic/SlimCheck.lean b/Mathlib/Tactic/SlimCheck.lean index e5088f231ead7..66c0e52fbbb68 100644 --- a/Mathlib/Tactic/SlimCheck.lean +++ b/Mathlib/Tactic/SlimCheck.lean @@ -181,7 +181,7 @@ elab_rules : tactic | `(tactic| slim_check $[$cfg]?) => withMainContext do Failed to create a `testable` instance for `{tgt}`.\ \nWhat to do:\ \n1. make sure that the types you are using have `SlimCheck.SampleableExt` instances\ - \n (you can use `#sample my_type` if you are unsure);\ + \n (you can use `#sample my_type` if you are unsure);\ \n2. make sure that the relations and predicates that your proposition use are decidable;\ \n3. make sure that instances of `SlimCheck.Testable` exist that, when combined,\ \n apply to your decorated proposition:\ diff --git a/Mathlib/Tactic/TermCongr.lean b/Mathlib/Tactic/TermCongr.lean index 11ff9166739ac..5ec0c3b92a6bf 100644 --- a/Mathlib/Tactic/TermCongr.lean +++ b/Mathlib/Tactic/TermCongr.lean @@ -139,7 +139,7 @@ def cHole? (e : Expr) (mvarCounterSaved? : Option Nat := none) : Option (Bool × return (forLhs, val, pf) | _ => none -/-- Returns any subexpression that is a recent congruence hole. -/ +/-- Returns any subexpression that is a recent congruence hole. -/ def hasCHole (mvarCounterSaved : Nat) (e : Expr) : Option Expr := e.find? fun e' => (cHole? e' mvarCounterSaved).isSome diff --git a/Mathlib/Tactic/ToAdditive/Frontend.lean b/Mathlib/Tactic/ToAdditive/Frontend.lean index 31cfea1e8b165..5b688af68cf4e 100644 --- a/Mathlib/Tactic/ToAdditive/Frontend.lean +++ b/Mathlib/Tactic/ToAdditive/Frontend.lean @@ -1506,3 +1506,5 @@ initialize registerBuiltinAttribute { } end ToAdditive + +set_option linter.style.longFile 1700 diff --git a/Mathlib/Tactic/Variable.lean b/Mathlib/Tactic/Variable.lean index ae6e4f39f4ddb..ce1dd2966519a 100644 --- a/Mathlib/Tactic/Variable.lean +++ b/Mathlib/Tactic/Variable.lean @@ -250,7 +250,7 @@ def elabVariables : CommandElab := fun stx => where extendScope (binders : TSyntaxArray ``bracketedBinder) : CommandElabM Unit := do for binder in binders do - let varUIds ← getBracketedBinderIds binder |>.mapM + let varUIds ← (← getBracketedBinderIds binder) |>.mapM (withFreshMacroScope ∘ MonadQuotation.addMacroScope) modifyScope fun scope => { scope with varDecls := scope.varDecls.push binder, varUIds := scope.varUIds ++ varUIds } @@ -270,7 +270,7 @@ where Term.withAutoBoundImplicit <| Term.elabBinders binders fun _ => pure () -- Filter out omitted binders let binders' : TSyntaxArray ``bracketedBinder := - (binders.zip toOmit).filterMap fun (b, omit) => if omit then none else some b + (binders.zip toOmit).filterMap fun (b, toOmit) => if toOmit then none else some b if let some expectedBinders := expectedBinders? then trace[«variable?»] "checking expected binders" /- We re-elaborate the binders to create an expression that represents the entire resulting diff --git a/Mathlib/Testing/SlimCheck/Gen.lean b/Mathlib/Testing/SlimCheck/Gen.lean index da7ccace2053e..0f3d66842989e 100644 --- a/Mathlib/Testing/SlimCheck/Gen.lean +++ b/Mathlib/Testing/SlimCheck/Gen.lean @@ -111,7 +111,7 @@ def prodOf {α : Type u} {β : Type v} (x : Gen α) (y : Gen β) : Gen (α × β end Gen -/-- Execute a `Gen` inside the `IO` monad using `size` as the example size-/ +/-- Execute a `Gen` inside the `IO` monad using `size` as the example size -/ def Gen.run {α : Type} (x : Gen α) (size : Nat) : BaseIO α := letI : MonadLift Id BaseIO := ⟨fun f => pure <| Id.run f⟩ IO.runRand (ReaderT.run x ⟨size⟩:) diff --git a/Mathlib/Testing/SlimCheck/Sampleable.lean b/Mathlib/Testing/SlimCheck/Sampleable.lean index b2c011792955b..f5cedcf3cb680 100644 --- a/Mathlib/Testing/SlimCheck/Sampleable.lean +++ b/Mathlib/Testing/SlimCheck/Sampleable.lean @@ -220,7 +220,7 @@ instance Bool.sampleableExt : SampleableExt Bool := /-- This can be specialized into customized `SampleableExt Char` instances. The resulting instance has `1 / length` chances of making an unrestricted choice of characters -and it otherwise chooses a character from `chars` with uniform probabilities. -/ +and it otherwise chooses a character from `chars` with uniform probabilities. -/ def Char.sampleable (length : Nat) (chars : List Char) (pos : 0 < chars.length) : SampleableExt Char := mkSelfContained do @@ -256,7 +256,7 @@ instance List.sampleableExt [SampleableExt α] : SampleableExt (List α) where end Samplers -/-- An annotation for values that should never get shrinked. -/ +/-- An annotation for values that should never get shrunk. -/ def NoShrink (α : Type u) := α namespace NoShrink diff --git a/Mathlib/Topology/Algebra/Algebra.lean b/Mathlib/Topology/Algebra/Algebra.lean index c229209194995..bcc728324280b 100644 --- a/Mathlib/Topology/Algebra/Algebra.lean +++ b/Mathlib/Topology/Algebra/Algebra.lean @@ -241,7 +241,7 @@ whose `TopologicalClosure` is `⊤` is sent to another such submodule. That is, the image of a dense subalgebra under a map with dense range is dense. -/ theorem _root_.DenseRange.topologicalClosure_map_subalgebra - [TopologicalSemiring B] {f : A →A[R] B} (hf' : DenseRange f) {s : Subalgebra R A} + [TopologicalSemiring B] {f : A →A[R] B} (hf' : DenseRange f) {s : Subalgebra R A} (hs : s.topologicalClosure = ⊤) : (s.map (f : A →ₐ[R] B)).topologicalClosure = ⊤ := by rw [SetLike.ext'_iff] at hs ⊢ simp only [Subalgebra.topologicalClosure_coe, coe_top, ← dense_iff_closure_eq, Subalgebra.coe_map, @@ -408,7 +408,7 @@ theorem fst_comp_prod (f : A →A[R] B) (g : A →A[R] C) : ext fun _x => rfl @[simp] -theorem snd_comp_prod (f : A →A[R] B) (g : A →A[R] C) : +theorem snd_comp_prod (f : A →A[R] B) (g : A →A[R] C) : (snd R B C).comp (f.prod g) = g := ext fun _x => rfl diff --git a/Mathlib/Topology/Algebra/Group/Basic.lean b/Mathlib/Topology/Algebra/Group/Basic.lean index 36c67204cd37c..4a1d0f84e6918 100644 --- a/Mathlib/Topology/Algebra/Group/Basic.lean +++ b/Mathlib/Topology/Algebra/Group/Basic.lean @@ -1915,3 +1915,5 @@ theorem coinduced_continuous {α β : Type*} [t : TopologicalSpace α] [Group β exact continuous_iff_coinduced_le.2 ht' end GroupTopology + +set_option linter.style.longFile 2100 diff --git a/Mathlib/Topology/Algebra/InfiniteSum/Module.lean b/Mathlib/Topology/Algebra/InfiniteSum/Module.lean index 1201d78d799cc..e8ef8f1cd13dc 100644 --- a/Mathlib/Topology/Algebra/InfiniteSum/Module.lean +++ b/Mathlib/Topology/Algebra/InfiniteSum/Module.lean @@ -240,7 +240,7 @@ variable {G : Type*} [Group G] {Γ : Subgroup G} @[to_additive "Given a subgroup `Γ` of an additive group `G`, and a function `f : G → M`, we automorphize `f` to a function `G ⧸ Γ → M` by summing over `Γ` orbits, `g ↦ ∑' (γ : Γ), f(γ • g)`."] -noncomputable def QuotientGroup.automorphize (f : G → M) : G ⧸ Γ → M := MulAction.automorphize f +noncomputable def QuotientGroup.automorphize (f : G → M) : G ⧸ Γ → M := MulAction.automorphize f /-- Automorphization of a function into an `R`-`Module` distributes, that is, commutes with the `R`-scalar multiplication. -/ diff --git a/Mathlib/Topology/Algebra/InfiniteSum/NatInt.lean b/Mathlib/Topology/Algebra/InfiniteSum/NatInt.lean index 09d1d25020184..595419777ddfb 100644 --- a/Mathlib/Topology/Algebra/InfiniteSum/NatInt.lean +++ b/Mathlib/Topology/Algebra/InfiniteSum/NatInt.lean @@ -358,7 +358,7 @@ lemma HasProd.of_nat_of_neg_add_one {f : ℤ → M} @[to_additive Summable.of_nat_of_neg_add_one] lemma Multipliable.of_nat_of_neg_add_one {f : ℤ → M} - (hf₁ : Multipliable fun n : ℕ ↦ f n) (hf₂ : Multipliable fun n : ℕ ↦ f (-(n + 1))) : + (hf₁ : Multipliable fun n : ℕ ↦ f n) (hf₂ : Multipliable fun n : ℕ ↦ f (-(n + 1))) : Multipliable f := (hf₁.hasProd.of_nat_of_neg_add_one hf₂.hasProd).multipliable diff --git a/Mathlib/Topology/Algebra/Module/Basic.lean b/Mathlib/Topology/Algebra/Module/Basic.lean index b8f56f0dc9762..fd43144f79855 100644 --- a/Mathlib/Topology/Algebra/Module/Basic.lean +++ b/Mathlib/Topology/Algebra/Module/Basic.lean @@ -252,7 +252,7 @@ class ContinuousSemilinearMapClass (F : Type*) {R S : outParam Type*} [Semiring /-- `ContinuousLinearMapClass F R M M₂` asserts `F` is a type of bundled continuous `R`-linear maps `M → M₂`. This is an abbreviation for -`ContinuousSemilinearMapClass F (RingHom.id R) M M₂`. -/ +`ContinuousSemilinearMapClass F (RingHom.id R) M M₂`. -/ abbrev ContinuousLinearMapClass (F : Type*) (R : outParam Type*) [Semiring R] (M : outParam Type*) [TopologicalSpace M] [AddCommMonoid M] (M₂ : outParam Type*) [TopologicalSpace M₂] [AddCommMonoid M₂] [Module R M] [Module R M₂] [FunLike F M M₂] := @@ -1760,7 +1760,7 @@ theorem coe_refl : ↑(ContinuousLinearEquiv.refl R₁ M₁) = ContinuousLinearM theorem coe_refl' : ⇑(ContinuousLinearEquiv.refl R₁ M₁) = id := rfl -/-- The inverse of a continuous linear equivalence as a continuous linear equivalence-/ +/-- The inverse of a continuous linear equivalence as a continuous linear equivalence -/ @[symm] protected def symm (e : M₁ ≃SL[σ₁₂] M₂) : M₂ ≃SL[σ₂₁] M₁ := { e.toLinearEquiv.symm with @@ -2389,3 +2389,5 @@ instance t3_quotient_of_isClosed [TopologicalAddGroup M] [IsClosed (S : Set M)] end Submodule end Quotient + +set_option linter.style.longFile 2500 diff --git a/Mathlib/Topology/Algebra/Module/CharacterSpace.lean b/Mathlib/Topology/Algebra/Module/CharacterSpace.lean index 98892800dddf3..aa4aeffcdfcb1 100644 --- a/Mathlib/Topology/Algebra/Module/CharacterSpace.lean +++ b/Mathlib/Topology/Algebra/Module/CharacterSpace.lean @@ -212,7 +212,7 @@ variable (𝕜 A) [CommRing 𝕜] [NoZeroDivisors 𝕜] [TopologicalSpace 𝕜] /-- The **Gelfand transform** is an algebra homomorphism (over `𝕜`) from a topological `𝕜`-algebra `A` into the `𝕜`-algebra of continuous `𝕜`-valued functions on the `characterSpace 𝕜 A`. -The character space itself consists of all algebra homomorphisms from `A` to `𝕜`. -/ +The character space itself consists of all algebra homomorphisms from `A` to `𝕜`. -/ @[simps] def gelfandTransform : A →ₐ[𝕜] C(characterSpace 𝕜 A, 𝕜) where toFun a := diff --git a/Mathlib/Topology/Algebra/OpenSubgroup.lean b/Mathlib/Topology/Algebra/OpenSubgroup.lean index 025b15e34f7a6..5512c7f43dcb2 100644 --- a/Mathlib/Topology/Algebra/OpenSubgroup.lean +++ b/Mathlib/Topology/Algebra/OpenSubgroup.lean @@ -10,7 +10,7 @@ import Mathlib.Topology.Sets.Opens /-! # Open subgroups of a topological groups -This files builds the lattice `OpenSubgroup G` of open subgroups in a topological group `G`, +This files builds the lattice `OpenSubgroup G` of open subgroups in a topological group `G`, and its additive version `OpenAddSubgroup`. This lattice has a top element, the subgroup of all elements, but no bottom element in general. The trivial subgroup which is the natural candidate bottom has no reason to be open (this happens only in discrete groups). diff --git a/Mathlib/Topology/Algebra/Order/LiminfLimsup.lean b/Mathlib/Topology/Algebra/Order/LiminfLimsup.lean index 76d0241ae2ffb..43ef0e855d0da 100644 --- a/Mathlib/Topology/Algebra/Order/LiminfLimsup.lean +++ b/Mathlib/Topology/Algebra/Order/LiminfLimsup.lean @@ -303,7 +303,7 @@ theorem Antitone.map_limsSup_of_continuousAt {F : Filter R} [NeBot F] {f : R → (cobdd : F.IsCobounded (· ≤ ·) := by isBoundedDefault) : f F.limsSup = F.liminf f := by apply le_antisymm - · rw [limsSup, f_decr.map_sInf_of_continuousAt' f_cont bdd_above cobdd] + · rw [limsSup, f_decr.map_csInf_of_continuousAt f_cont bdd_above cobdd] apply le_of_forall_lt intro c hc simp only [liminf, limsInf, eventually_map] at hc ⊢ diff --git a/Mathlib/Topology/Algebra/Ring/Basic.lean b/Mathlib/Topology/Algebra/Ring/Basic.lean index 625d49d63a27c..94cf82277f373 100644 --- a/Mathlib/Topology/Algebra/Ring/Basic.lean +++ b/Mathlib/Topology/Algebra/Ring/Basic.lean @@ -40,7 +40,7 @@ The `TopologicalSemiring` class should *only* be instantiated in the presence of `NonUnitalNonAssocSemiring` instance; if there is an instance of `NonUnitalNonAssocRing`, then `TopologicalRing` should be used. Note: in the presence of `NonAssocRing`, these classes are mathematically equivalent (see `TopologicalSemiring.continuousNeg_of_mul` or -`TopologicalSemiring.toTopologicalRing`). -/ +`TopologicalSemiring.toTopologicalRing`). -/ class TopologicalSemiring [TopologicalSpace α] [NonUnitalNonAssocSemiring α] extends ContinuousAdd α, ContinuousMul α : Prop diff --git a/Mathlib/Topology/Algebra/UniformGroup.lean b/Mathlib/Topology/Algebra/UniformGroup.lean index 80a4a5419140b..991b6bcbc28af 100644 --- a/Mathlib/Topology/Algebra/UniformGroup.lean +++ b/Mathlib/Topology/Algebra/UniformGroup.lean @@ -850,7 +850,7 @@ already equipped with a uniform structure. Even though `G` is equipped with a uniform structure, the quotient `G ⧸ N` does not inherit a uniform structure, so it is still provided manually via `TopologicalGroup.toUniformSpace`. In the most common use cases, this coincides (definitionally) with the uniform structure on the -quotient obtained via other means. -/ +quotient obtained via other means. -/ @[to_additive "The quotient `G ⧸ N` of a complete first countable uniform additive group `G` by a normal additive subgroup is itself complete. Consequently, quotients of Banach spaces by subspaces are complete. In contrast to `QuotientAddGroup.completeSpace'`, in this version diff --git a/Mathlib/Topology/Bases.lean b/Mathlib/Topology/Bases.lean index 7930817c3788d..fac6969612eff 100644 --- a/Mathlib/Topology/Bases.lean +++ b/Mathlib/Topology/Bases.lean @@ -65,7 +65,7 @@ variable {α : Type u} {β : Type*} [t : TopologicalSpace α] {B : Set (Set α)} it suffices to take unions of the basis sets to get a topology (without taking finite intersections as well). -/ structure IsTopologicalBasis (s : Set (Set α)) : Prop where - /-- For every point `x`, the set of `t ∈ s` such that `x ∈ t` is directed downwards. -/ + /-- For every point `x`, the set of `t ∈ s` such that `x ∈ t` is directed downwards. -/ exists_subset_inter : ∀ t₁ ∈ s, ∀ t₂ ∈ s, ∀ x ∈ t₁ ∩ t₂, ∃ t₃ ∈ s, x ∈ t₃ ∧ t₃ ⊆ t₁ ∩ t₂ /-- The sets from `s` cover the whole space. -/ sUnion_eq : ⋃₀ s = univ diff --git a/Mathlib/Topology/Basic.lean b/Mathlib/Topology/Basic.lean index 6c821ade241e9..1833ed321b701 100644 --- a/Mathlib/Topology/Basic.lean +++ b/Mathlib/Topology/Basic.lean @@ -128,7 +128,7 @@ theorem Set.Finite.isOpen_biInter {s : Set α} {f : α → Set X} (hs : s.Finite theorem isOpen_iInter_of_finite [Finite ι] {s : ι → Set X} (h : ∀ i, IsOpen (s i)) : IsOpen (⋂ i, s i) := - (finite_range _).isOpen_sInter (forall_mem_range.2 h) + (finite_range _).isOpen_sInter (forall_mem_range.2 h) theorem isOpen_biInter_finset {s : Finset α} {f : α → Set X} (h : ∀ i ∈ s, IsOpen (f i)) : IsOpen (⋂ i ∈ s, f i) := @@ -1738,3 +1738,5 @@ example [TopologicalSpace X] [TopologicalSpace Y] {x₀ : X} (f : X → X → Y) -- hf.comp_of_eq (continuousAt_id.prod continuousAt_id) rfl -- works ``` -/ + +set_option linter.style.longFile 1900 diff --git a/Mathlib/Topology/Category/CompHaus/Basic.lean b/Mathlib/Topology/Category/CompHaus/Basic.lean index 19e8edca81f80..a8cc32f86ae14 100644 --- a/Mathlib/Topology/Category/CompHaus/Basic.lean +++ b/Mathlib/Topology/Category/CompHaus/Basic.lean @@ -219,6 +219,6 @@ theorem epi_iff_surjective {X Y : CompHaus.{u}} (f : X ⟶ Y) : Epi f ↔ Functi end CompHaus -/-- Every `CompHausLike` admits a functor to `CompHaus`. -/ +/-- Every `CompHausLike` admits a functor to `CompHaus`. -/ abbrev compHausLikeToCompHaus (P : TopCat → Prop) : CompHausLike P ⥤ CompHaus := CompHausLike.toCompHausLike (by simp only [implies_true]) diff --git a/Mathlib/Topology/Category/CompHausLike/Basic.lean b/Mathlib/Topology/Category/CompHausLike/Basic.lean index 05401767a1c2c..8a216fc1289cc 100644 --- a/Mathlib/Topology/Category/CompHausLike/Basic.lean +++ b/Mathlib/Topology/Category/CompHausLike/Basic.lean @@ -49,7 +49,7 @@ instance hasForget₂ : HasForget₂ (CompHausLike P) TopCat := variable (X : Type u) [TopologicalSpace X] [CompactSpace X] [T2Space X] -/-- This wraps the predicate `P : TopCat → Prop` in a typeclass. -/ +/-- This wraps the predicate `P : TopCat → Prop` in a typeclass. -/ class HasProp : Prop where hasProp : P (TopCat.of X) @@ -91,7 +91,7 @@ instance (X : CompHausLike.{u} P) : T2Space ((forget (CompHausLike P)).obj X) := variable {P} -/-- If `P` imples `P'`, then there is a functor from `CompHausLike P` to `CompHausLike P'`. -/ +/-- If `P` imples `P'`, then there is a functor from `CompHausLike P` to `CompHausLike P'`. -/ @[simps] def toCompHausLike {P P' : TopCat → Prop} (h : ∀ (X : CompHausLike P), P X.toTop → P' X.toTop) : CompHausLike P ⥤ CompHausLike P' where @@ -104,7 +104,7 @@ section variable {P P' : TopCat → Prop} (h : ∀ (X : CompHausLike P), P X.toTop → P' X.toTop) -/-- If `P` imples `P'`, then the functor from `CompHausLike P` to `CompHausLike P'` is fully +/-- If `P` imples `P'`, then the functor from `CompHausLike P` to `CompHausLike P'` is fully faithful. -/ def fullyFaithfulToCompHausLike : (toCompHausLike h).FullyFaithful := fullyFaithfulInducedFunctor _ diff --git a/Mathlib/Topology/Category/CompHausLike/Limits.lean b/Mathlib/Topology/Category/CompHausLike/Limits.lean index c3705bfeab520..845abc60f56e7 100644 --- a/Mathlib/Topology/Category/CompHausLike/Limits.lean +++ b/Mathlib/Topology/Category/CompHausLike/Limits.lean @@ -18,14 +18,14 @@ which may be useful due to their definitional properties. * `HasExplicitFiniteCoproducts`: A typeclass describing the property that forming all finite disjoint unions is stable under the property `P`. - Given this property, we deduce that `CompHausLike P` has finite coproducts and the inclusion - functors to other `CompHausLike P'` and to `TopCat` preserve them. + functors to other `CompHausLike P'` and to `TopCat` preserve them. * `HasExplicitPullbacks`: A typeclass describing the property that forming all "explicit pullbacks" is stable under the property `P`. Here, explicit pullbacks are defined as a subset of the product. - Given this property, we deduce that `CompHausLike P` has pullbacks and the inclusion - functors to other `CompHausLike P'` and to `TopCat` preserve them. + functors to other `CompHausLike P'` and to `TopCat` preserve them. - We also define a variant `HasExplicitPullbacksOfInclusions` which is says that explicit - pullbacks along inclusion maps into finite disjoint unions exist. `Stonean` has this property + pullbacks along inclusion maps into finite disjoint unions exist. `Stonean` has this property but not the stronger one. ## Main results @@ -127,7 +127,7 @@ class HasExplicitFiniteCoproducts : Prop where hasProp {α : Type w} [Finite α] (X : α → CompHausLike.{max u w} P) : HasExplicitFiniteCoproduct X /- -This linter complains that the universes `u` and `w` only occur together, but `w` appears by itself +This linter complains that the universes `u` and `w` only occur together, but `w` appears by itself in the indexing type of the coproduct. In almost all cases, `w` will be either `0` or `u`, but we want to allow both possibilities. -/ @@ -164,7 +164,7 @@ lemma Sigma.openEmbedding_ι (a : α) : change (Sigma.ι X a ≫ _) x = _ simp -/-- The functor to `TopCat` preserves finite coproducts if they exist. -/ +/-- The functor to `TopCat` preserves finite coproducts if they exist. -/ instance (P) [HasExplicitFiniteCoproducts.{0} P] : PreservesFiniteCoproducts (compHausLikeToTop P) := by refine ⟨fun J hJ ↦ ⟨fun {F} ↦ ?_⟩⟩ @@ -173,7 +173,7 @@ instance (P) [HasExplicitFiniteCoproducts.{0} P] : apply preservesColimitOfPreservesColimitCocone (CompHausLike.finiteCoproduct.isColimit _) exact TopCat.sigmaCofanIsColimit _ -/-- The functor to another `CompHausLike` preserves finite coproducts if they exist. -/ +/-- The functor to another `CompHausLike` preserves finite coproducts if they exist. -/ noncomputable instance {P' : TopCat.{u} → Prop} (h : ∀ (X : CompHausLike P), P X.toTop → P' X.toTop) : PreservesFiniteCoproducts (toCompHausLike h) := by @@ -275,18 +275,18 @@ def pullback.isLimit : Limits.IsLimit (pullback.cone f g) := instance : HasLimit (cospan f g) where exists_limit := ⟨⟨pullback.cone f g, pullback.isLimit f g⟩⟩ -/-- The functor to `TopCat` creates pullbacks if they exist. -/ +/-- The functor to `TopCat` creates pullbacks if they exist. -/ noncomputable instance : CreatesLimit (cospan f g) (compHausLikeToTop P) := by refine createsLimitOfFullyFaithfulOfIso (pullback f g) (((TopCat.pullbackConeIsLimit f g).conePointUniqueUpToIso (limit.isLimit _)) ≪≫ Limits.lim.mapIso (?_ ≪≫ (diagramIsoCospan _).symm)) exact Iso.refl _ -/-- The functor to `TopCat` preserves pullbacks. -/ +/-- The functor to `TopCat` preserves pullbacks. -/ noncomputable instance : PreservesLimit (cospan f g) (compHausLikeToTop P) := preservesLimitOfCreatesLimitAndHasLimit _ _ -/-- The functor to another `CompHausLike` preserves pullbacks. -/ +/-- The functor to another `CompHausLike` preserves pullbacks. -/ noncomputable instance {P' : TopCat → Prop} (h : ∀ (X : CompHausLike P), P X.toTop → P' X.toTop) : PreservesLimit (cospan f g) (toCompHausLike h) := by diff --git a/Mathlib/Topology/Category/CompactlyGenerated.lean b/Mathlib/Topology/Category/CompactlyGenerated.lean index 200b869bfa079..2563c6dffb796 100644 --- a/Mathlib/Topology/Category/CompactlyGenerated.lean +++ b/Mathlib/Topology/Category/CompactlyGenerated.lean @@ -9,7 +9,7 @@ import Mathlib.CategoryTheory.Elementwise # Compactly generated topological spaces -This file defines the category of compactly generated topological spaces. These are spaces `X` such +This file defines the category of compactly generated topological spaces. These are spaces `X` such that a map `f : X → Y` is continuous whenever the composition `S → X → Y` is continuous for all compact Hausdorff spaces `S` mapping continuously to `X`. diff --git a/Mathlib/Topology/Category/LightProfinite/AsLimit.lean b/Mathlib/Topology/Category/LightProfinite/AsLimit.lean index d5e2c6c5f4e62..48104258a6815 100644 --- a/Mathlib/Topology/Category/LightProfinite/AsLimit.lean +++ b/Mathlib/Topology/Category/LightProfinite/AsLimit.lean @@ -36,14 +36,14 @@ abbrev diagram : ℕᵒᵖ ⥤ LightProfinite := S.fintypeDiagram ⋙ FintypeCat /-- A cone over `S.diagram` whose cone point is isomorphic to `S`. -(Auxiliary definition, use `S.asLimitCone` instead.) +(Auxiliary definition, use `S.asLimitCone` instead.) -/ def asLimitConeAux : Cone S.diagram := let c : Cone (S.diagram ⋙ lightToProfinite) := S.toLightDiagram.cone let hc : IsLimit c := S.toLightDiagram.isLimit liftLimit hc -/-- An auxiliary isomorphism of cones used to prove that `S.asLimitConeAux` is a limit cone. -/ +/-- An auxiliary isomorphism of cones used to prove that `S.asLimitConeAux` is a limit cone. -/ def isoMapCone : lightToProfinite.mapCone S.asLimitConeAux ≅ S.toLightDiagram.cone := let c : Cone (S.diagram ⋙ lightToProfinite) := S.toLightDiagram.cone let hc : IsLimit c := S.toLightDiagram.isLimit @@ -51,7 +51,7 @@ def isoMapCone : lightToProfinite.mapCone S.asLimitConeAux ≅ S.toLightDiagram. /-- `S.asLimitConeAux` is indeed a limit cone. -(Auxiliary definition, use `S.asLimit` instead.) +(Auxiliary definition, use `S.asLimit` instead.) -/ def asLimitAux : IsLimit S.asLimitConeAux := let hc : IsLimit (lightToProfinite.mapCone S.asLimitConeAux) := diff --git a/Mathlib/Topology/Category/LightProfinite/Basic.lean b/Mathlib/Topology/Category/LightProfinite/Basic.lean index 097f5cc942104..cd2b31b51da75 100644 --- a/Mathlib/Topology/Category/LightProfinite/Basic.lean +++ b/Mathlib/Topology/Category/LightProfinite/Basic.lean @@ -17,7 +17,7 @@ implemented as totally disconnected second countable compact Hausdorff spaces. This file also defines the category `LightDiagram`, which consists of those spaces that can be written as a sequential limit (in `Profinite`) of finite sets. -We define an equivalence of categories `LightProfinite ≌ LightDiagram` and prove that these are +We define an equivalence of categories `LightProfinite ≌ LightDiagram` and prove that these are essentially small categories. -/ @@ -225,6 +225,9 @@ theorem epi_iff_surjective {X Y : LightProfinite.{u}} (f : X ⟶ Y) : · rw [← CategoryTheory.epi_iff_surjective] apply (forget LightProfinite).epi_of_epi_map +instance : lightToProfinite.PreservesEpimorphisms where + preserves f _ := (Profinite.epi_iff_surjective _).mpr ((epi_iff_surjective f).mp inferInstance) + end LightProfinite /-- A structure containing the data of sequential limit in `Profinite` of finite sets. -/ @@ -238,7 +241,7 @@ structure LightDiagram : Type (u+1) where namespace LightDiagram -/-- The underlying `Profinite` of a `LightDiagram`. -/ +/-- The underlying `Profinite` of a `LightDiagram`. -/ def toProfinite (S : LightDiagram) : Profinite := S.cone.pt @[simps!] diff --git a/Mathlib/Topology/Category/LightProfinite/Extend.lean b/Mathlib/Topology/Category/LightProfinite/Extend.lean new file mode 100644 index 0000000000000..55d6645661ad5 --- /dev/null +++ b/Mathlib/Topology/Category/LightProfinite/Extend.lean @@ -0,0 +1,198 @@ +/- +Copyright (c) 2024 Dagur Asgeirsson. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Dagur Asgeirsson +-/ +import Mathlib.Topology.Category.LightProfinite.AsLimit +import Mathlib.Topology.Category.Profinite.Extend + +/-! + +# Extending cones in `LightProfinite` + +Let `(Sₙ)_{n : ℕᵒᵖ}` be a sequential inverse system of finite sets and let `S` be +its limit in `Profinite`. Let `G` be a functor from `LightProfinite` to a category `C` and suppose +that `G` preserves the limit described above. Suppose further that the projection maps `S ⟶ Sₙ` are +epimorphic for all `n`. Then `G.obj S` is isomorphic to a limit indexed by +`StructuredArrow S toLightProfinite` (see `LightProfinite.Extend.isLimitCone`). + +We also provide the dual result for a functor of the form `G : LightProfiniteᵒᵖ ⥤ C`. + +We apply this to define `LightProfinite.diagram'`, `LightProfinite.asLimitCone'`, and +`LightProfinite.asLimit'`, analogues to their unprimed versions in +`Mathlib.Topology.Category.LightProfinite.AsLimit`, in which the +indexing category is `StructuredArrow S toLightProfinite` instead of `ℕᵒᵖ`. +-/ + +universe u + +open CategoryTheory Limits FintypeCat Functor + +attribute [local instance] FintypeCat.discreteTopology ConcreteCategory.instFunLike + +namespace LightProfinite + +variable {F : ℕᵒᵖ ⥤ FintypeCat.{u}} (c : Cone <| F ⋙ toLightProfinite) + +namespace Extend + +/-- +Given a sequential cone in `LightProfinite` consisting of finite sets, +we obtain a functor from the indexing category to `StructuredArrow c.pt toLightProfinite`. +-/ +@[simps] +def functor : ℕᵒᵖ ⥤ StructuredArrow c.pt toLightProfinite where + obj i := StructuredArrow.mk (c.π.app i) + map f := StructuredArrow.homMk (F.map f) (c.w f) + +-- We check that the original diagram factors through `LightProfinite.Extend.functor`. +example : functor c ⋙ StructuredArrow.proj c.pt toLightProfinite ≅ F := Iso.refl _ + +/-- +Given a sequential cone in `LightProfinite` consisting of finite sets, +we obtain a functor from the opposite of the indexing category to +`CostructuredArrow toProfinite.op ⟨c.pt⟩`. +-/ +@[simps! obj map] +def functorOp : ℕ ⥤ CostructuredArrow toLightProfinite.op ⟨c.pt⟩ := + (functor c).rightOp ⋙ StructuredArrow.toCostructuredArrow _ _ + +-- We check that the opposite of the original diagram factors through `Profinite.Extend.functorOp`. +example : functorOp c ⋙ CostructuredArrow.proj toLightProfinite.op ⟨c.pt⟩ ≅ F.rightOp := Iso.refl _ + +-- We check that `Profinite.Extend.functor` factors through `LightProfinite.Extend.functor`, +-- via the equivalence `StructuredArrow.post _ _ lightToProfinite`. +example : functor c ⋙ (StructuredArrow.post _ _ lightToProfinite) = + Profinite.Extend.functor (lightToProfinite.mapCone c) := rfl + +/-- +If the projection maps in the cone are epimorphic and the cone is limiting, then +`LightProfinite.Extend.functor` is initial. +-/ +theorem functor_initial (hc : IsLimit c) [∀ i, Epi (c.π.app i)] : Initial (functor c) := by + rw [initial_iff_comp_equivalence _ (StructuredArrow.post _ _ lightToProfinite)] + have : ∀ i, Epi ((lightToProfinite.mapCone c).π.app i) := + fun i ↦ inferInstanceAs (Epi (lightToProfinite.map (c.π.app i))) + exact Profinite.Extend.functor_initial _ (isLimitOfPreserves lightToProfinite hc) + +/-- +If the projection maps in the cone are epimorphic and the cone is limiting, then +`LightProfinite.Extend.functorOp` is final. +-/ +theorem functorOp_final (hc : IsLimit c) [∀ i, Epi (c.π.app i)] : Final (functorOp c) := by + have := functor_initial c hc + have : ((StructuredArrow.toCostructuredArrow toLightProfinite c.pt)).IsEquivalence := + (inferInstance : (structuredArrowOpEquivalence _ _).functor.IsEquivalence ) + have : (functor c).rightOp.Final := + inferInstanceAs ((opOpEquivalence ℕ).inverse ⋙ (functor c).op).Final + exact Functor.final_comp (functor c).rightOp _ + +section Limit + +variable {C : Type*} [Category C] (G : LightProfinite ⥤ C) + +/-- +Given a functor `G` from `LightProfinite` and `S : LightProfinite`, we obtain a cone on +`(StructuredArrow.proj S toLightProfinite ⋙ toLightProfinite ⋙ G)` with cone point `G.obj S`. + +Whiskering this cone with `LightProfinite.Extend.functor c` gives `G.mapCone c` as we check in the +example below. +-/ +def cone (S : LightProfinite) : + Cone (StructuredArrow.proj S toLightProfinite ⋙ toLightProfinite ⋙ G) where + pt := G.obj S + π := { + app := fun i ↦ G.map i.hom + naturality := fun _ _ f ↦ (by + have := f.w + simp only [const_obj_obj, StructuredArrow.left_eq_id, const_obj_map, Category.id_comp, + StructuredArrow.w] at this + simp only [const_obj_obj, comp_obj, StructuredArrow.proj_obj, const_obj_map, Category.id_comp, + Functor.comp_map, StructuredArrow.proj_map, ← map_comp, StructuredArrow.w]) } + +example : G.mapCone c = (cone G c.pt).whisker (functor c) := rfl + +/-- +If `c` and `G.mapCone c` are limit cones and the projection maps in `c` are epimorphic, +then `cone G c.pt` is a limit cone. +-/ +noncomputable +def isLimitCone (hc : IsLimit c) [∀ i, Epi (c.π.app i)] (hc' : IsLimit <| G.mapCone c) : + IsLimit (cone G c.pt) := (functor_initial c hc).isLimitWhiskerEquiv _ hc' + +end Limit + +section Colimit + +variable {C : Type*} [Category C] (G : LightProfiniteᵒᵖ ⥤ C) + +/-- +Given a functor `G` from `LightProfiniteᵒᵖ` and `S : LightProfinite`, we obtain a cocone on +`(CostructuredArrow.proj toLightProfinite.op ⟨S⟩ ⋙ toLightProfinite.op ⋙ G)` with cocone point +`G.obj ⟨S⟩`. + +Whiskering this cocone with `LightProfinite.Extend.functorOp c` gives `G.mapCocone c.op` as we +check in the example below. +-/ +@[simps] +def cocone (S : LightProfinite) : + Cocone (CostructuredArrow.proj toLightProfinite.op ⟨S⟩ ⋙ toLightProfinite.op ⋙ G) where + pt := G.obj ⟨S⟩ + ι := { + app := fun i ↦ G.map i.hom + naturality := fun _ _ f ↦ (by + have := f.w + simp only [op_obj, const_obj_obj, op_map, CostructuredArrow.right_eq_id, const_obj_map, + Category.comp_id] at this + simp only [comp_obj, CostructuredArrow.proj_obj, op_obj, const_obj_obj, Functor.comp_map, + CostructuredArrow.proj_map, op_map, ← map_comp, this, const_obj_map, Category.comp_id]) } + +example : G.mapCocone c.op = (cocone G c.pt).whisker + ((opOpEquivalence ℕ).functor ⋙ functorOp c) := rfl + +/-- +If `c` is a limit cone, `G.mapCocone c.op` is a colimit cone and the projection maps in `c` +are epimorphic, then `cocone G c.pt` is a colimit cone. +-/ +noncomputable +def isColimitCocone (hc : IsLimit c) [∀ i, Epi (c.π.app i)] (hc' : IsColimit <| G.mapCocone c.op) : + IsColimit (cocone G c.pt) := + haveI := functorOp_final c hc + (Functor.final_comp (opOpEquivalence ℕ).functor (functorOp c)).isColimitWhiskerEquiv _ hc' + +end Colimit + +end Extend + +open Extend + +section LightProfiniteAsLimit + +variable (S : LightProfinite.{u}) + +/-- +A functor `StructuredArrow S toLightProfinite ⥤ FintypeCat` whose limit in `LightProfinite` is +isomorphic to `S`. +-/ +abbrev fintypeDiagram' : StructuredArrow S toLightProfinite ⥤ FintypeCat := + StructuredArrow.proj S toLightProfinite + +/-- An abbreviation for `S.fintypeDiagram' ⋙ toLightProfinite`. -/ +abbrev diagram' : StructuredArrow S toLightProfinite ⥤ LightProfinite := + S.fintypeDiagram' ⋙ toLightProfinite + +/-- A cone over `S.diagram'` whose cone point is `S`. -/ +def asLimitCone' : Cone (S.diagram') := cone (𝟭 _) S + +instance (i : ℕᵒᵖ) : Epi (S.asLimitCone.π.app i) := + (epi_iff_surjective _).mpr (S.proj_surjective _) + +/-- `S.asLimitCone'` is a limit cone. -/ +noncomputable def asLimit' : IsLimit S.asLimitCone' := isLimitCone _ (𝟭 _) S.asLimit S.asLimit + +/-- A bundled version of `S.asLimitCone'` and `S.asLimit'`. -/ +noncomputable def lim' : LimitCone S.diagram' := ⟨S.asLimitCone', S.asLimit'⟩ + +end LightProfiniteAsLimit + +end LightProfinite diff --git a/Mathlib/Topology/Category/LightProfinite/Sequence.lean b/Mathlib/Topology/Category/LightProfinite/Sequence.lean index 17d3590bd8020..ae729f14b1979 100644 --- a/Mathlib/Topology/Category/LightProfinite/Sequence.lean +++ b/Mathlib/Topology/Category/LightProfinite/Sequence.lean @@ -17,7 +17,7 @@ open CategoryTheory TopologicalSpace OnePoint namespace LightProfinite -/-- The continuous map from `ℕ∪{∞}` to `ℝ` sending `n` to `1/(n+1)` and `∞` to `0`. -/ +/-- The continuous map from `ℕ∪{∞}` to `ℝ` sending `n` to `1/(n+1)` and `∞` to `0`. -/ noncomputable def natUnionInftyEmbedding : C(OnePoint ℕ, ℝ) where toFun | ∞ => 0 @@ -26,7 +26,7 @@ noncomputable def natUnionInftyEmbedding : C(OnePoint ℕ, ℝ) where tendsto_one_div_add_atTop_nhds_zero_nat /-- -The continuous map from `ℕ∪{∞}` to `ℝ` sending `n` to `1/(n+1)` and `∞` to `0` is a closed +The continuous map from `ℕ∪{∞}` to `ℝ` sending `n` to `1/(n+1)` and `∞` to `0` is a closed embedding. -/ lemma closedEmbedding_natUnionInftyEmbedding : ClosedEmbedding natUnionInftyEmbedding := by diff --git a/Mathlib/Topology/Category/Profinite/Basic.lean b/Mathlib/Topology/Category/Profinite/Basic.lean index 2fcfa55ea7cfa..8def32734be5c 100644 --- a/Mathlib/Topology/Category/Profinite/Basic.lean +++ b/Mathlib/Topology/Category/Profinite/Basic.lean @@ -46,7 +46,7 @@ abbrev Profinite := CompHausLike (fun X ↦ TotallyDisconnectedSpace X) namespace Profinite -instance (X : Type*) [TopologicalSpace X] +instance (X : Type*) [TopologicalSpace X] [TotallyDisconnectedSpace X] : HasProp (fun Y ↦ TotallyDisconnectedSpace Y) X := ⟨(inferInstance : TotallyDisconnectedSpace X)⟩ diff --git a/Mathlib/Topology/Category/Profinite/EffectiveEpi.lean b/Mathlib/Topology/Category/Profinite/EffectiveEpi.lean index 2777ca0f06433..251da0eb75003 100644 --- a/Mathlib/Topology/Category/Profinite/EffectiveEpi.lean +++ b/Mathlib/Topology/Category/Profinite/EffectiveEpi.lean @@ -54,7 +54,7 @@ instance : profiniteToCompHaus.ReflectsEffectiveEpis where ((Profinite.effectiveEpi_tfae f).out 0 2).mpr (((CompHaus.effectiveEpi_tfae _).out 0 2).mp h) /-- -An effective presentation of an `X : Profinite` with respect to the inclusion functor from `Stonean` +An effective presentation of an `X : Profinite` with respect to the inclusion functor from `Stonean` -/ noncomputable def profiniteToCompHausEffectivePresentation (X : CompHaus) : profiniteToCompHaus.EffectivePresentation X where diff --git a/Mathlib/Topology/Category/Profinite/Extend.lean b/Mathlib/Topology/Category/Profinite/Extend.lean new file mode 100644 index 0000000000000..1ac168134b484 --- /dev/null +++ b/Mathlib/Topology/Category/Profinite/Extend.lean @@ -0,0 +1,217 @@ +/- +Copyright (c) 2024 Dagur Asgeirsson. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Dagur Asgeirsson +-/ +import Mathlib.Topology.Category.Profinite.AsLimit +import Mathlib.Topology.Category.Profinite.CofilteredLimit +import Mathlib.CategoryTheory.Filtered.Final +/-! + +# Extending cones in `Profinite` + +Let `(Sᵢ)_{i : I}` be a family of finite sets indexed by a cofiltered category `I` and let `S` be +its limit in `Profinite`. Let `G` be a functor from `Profinite` to a category `C` and suppose that +`G` preserves the limit described above. Suppose further that the projection maps `S ⟶ Sᵢ` are +epimorphic for all `i`. Then `G.obj S` is isomorphic to a limit indexed by +`StructuredArrow S toProfinite` (see `Profinite.Extend.isLimitCone`). + +We also provide the dual result for a functor of the form `G : Profiniteᵒᵖ ⥤ C`. + +We apply this to define `Profinite.diagram'`, `Profinite.asLimitCone'`, and `Profinite.asLimit'`, +analogues to their unprimed versions in `Mathlib.Topology.Category.Profinite.AsLimit`, in which the +indexing category is `StructuredArrow S toProfinite` instead of `DiscreteQuotient S`. +-/ + +universe u w + +open CategoryTheory Limits FintypeCat Functor + +attribute [local instance] ConcreteCategory.instFunLike + +namespace Profinite + +variable {I : Type u} [SmallCategory I] [IsCofiltered I] + {F : I ⥤ FintypeCat.{max u w}} (c : Cone <| F ⋙ toProfinite) + +/-- +A continuous map from a profinite set to a finite set factors through one of the components of +the profinite set when written as a cofiltered limit of finite sets. +-/ +lemma exists_hom (hc : IsLimit c) {X : FintypeCat} (f : c.pt ⟶ toProfinite.obj X) : + ∃ (i : I) (g : F.obj i ⟶ X), f = c.π.app i ≫ toProfinite.map g := by + let _ : TopologicalSpace X := ⊥ + have : DiscreteTopology (toProfinite.obj X) := ⟨rfl⟩ + let f' : LocallyConstant c.pt (toProfinite.obj X) := + ⟨f, (IsLocallyConstant.iff_continuous _).mpr f.continuous⟩ + obtain ⟨i, g, h⟩ := exists_locallyConstant.{_, u} c hc f' + refine ⟨i, (g : _ → _), ?_⟩ + ext x + exact LocallyConstant.congr_fun h x + +namespace Extend + +/-- +Given a cone in `Profinite`, consisting of finite sets and indexed by a cofiltered category, +we obtain a functor from the indexing category to `StructuredArrow c.pt toProfinite`. +-/ +@[simps] +def functor : I ⥤ StructuredArrow c.pt toProfinite where + obj i := StructuredArrow.mk (c.π.app i) + map f := StructuredArrow.homMk (F.map f) (c.w f) + +-- We check that the original diagram factors through `Profinite.Extend.functor`. +example : functor c ⋙ StructuredArrow.proj c.pt toProfinite ≅ F := Iso.refl _ + +/-- +Given a cone in `Profinite`, consisting of finite sets and indexed by a cofiltered category, +we obtain a functor from the opposite of the indexing category to +`CostructuredArrow toProfinite.op ⟨c.pt⟩`. +-/ +@[simps! obj map] +def functorOp : Iᵒᵖ ⥤ CostructuredArrow toProfinite.op ⟨c.pt⟩ := + (functor c).op ⋙ StructuredArrow.toCostructuredArrow _ _ + +-- We check that the opposite of the original diagram factors through `Profinite.Extend.functorOp`. +example : functorOp c ⋙ CostructuredArrow.proj toProfinite.op ⟨c.pt⟩ ≅ F.op := Iso.refl _ + +/-- +If the projection maps in the cone are epimorphic and the cone is limiting, then +`Profinite.Extend.functor` is initial. + +TODO: investigate how to weaken the assumption `∀ i, Epi (c.π.app i)` to +`∀ i, ∃ j (_ : j ⟶ i), Epi (c.π.app j)`. +-/ +lemma functor_initial (hc : IsLimit c) [∀ i, Epi (c.π.app i)] : Initial (functor c) := by + let e : I ≌ ULiftHom.{w} (ULift.{w} I) := ULiftHomULiftCategory.equiv _ + suffices (e.inverse ⋙ functor c).Initial from initial_of_equivalence_comp e.inverse (functor c) + rw [initial_iff_of_isCofiltered (F := e.inverse ⋙ functor c)] + constructor + · intro ⟨_, X, (f : c.pt ⟶ _)⟩ + obtain ⟨i, g, h⟩ := exists_hom c hc f + refine ⟨⟨i⟩, ⟨StructuredArrow.homMk g h.symm⟩⟩ + · intro ⟨_, X, (f : c.pt ⟶ _)⟩ ⟨i⟩ ⟨_, (s : F.obj i ⟶ X), (w : f = c.π.app i ≫ _)⟩ + ⟨_, (s' : F.obj i ⟶ X), (w' : f = c.π.app i ≫ _)⟩ + simp only [functor_obj, functor_map, StructuredArrow.hom_eq_iff, StructuredArrow.mk_right, + StructuredArrow.comp_right, StructuredArrow.homMk_right] + refine ⟨⟨i⟩, 𝟙 _, ?_⟩ + simp only [CategoryTheory.Functor.map_id, Category.id_comp] + rw [w] at w' + exact toProfinite.map_injective <| Epi.left_cancellation _ _ w' + +/-- +If the projection maps in the cone are epimorphic and the cone is limiting, then +`Profinite.Extend.functorOp` is final. +-/ +lemma functorOp_final (hc : IsLimit c) [∀ i, Epi (c.π.app i)] : Final (functorOp c) := by + have := functor_initial c hc + have : ((StructuredArrow.toCostructuredArrow toProfinite c.pt)).IsEquivalence := + (inferInstance : (structuredArrowOpEquivalence _ _).functor.IsEquivalence ) + exact Functor.final_comp (functor c).op _ + +section Limit + +variable {C : Type*} [Category C] (G : Profinite ⥤ C) + +/-- +Given a functor `G` from `Profinite` and `S : Profinite`, we obtain a cone on +`(StructuredArrow.proj S toProfinite ⋙ toProfinite ⋙ G)` with cone point `G.obj S`. + +Whiskering this cone with `Profinite.Extend.functor c` gives `G.mapCone c` as we check in the +example below. +-/ +@[simps] +def cone (S : Profinite) : + Cone (StructuredArrow.proj S toProfinite ⋙ toProfinite ⋙ G) where + pt := G.obj S + π := { + app := fun i ↦ G.map i.hom + naturality := fun _ _ f ↦ (by + have := f.w + simp only [const_obj_obj, StructuredArrow.left_eq_id, const_obj_map, Category.id_comp, + StructuredArrow.w] at this + simp only [const_obj_obj, comp_obj, StructuredArrow.proj_obj, const_obj_map, Category.id_comp, + Functor.comp_map, StructuredArrow.proj_map, ← map_comp, StructuredArrow.w]) } + +example : G.mapCone c = (cone G c.pt).whisker (functor c) := rfl + +/-- +If `c` and `G.mapCone c` are limit cones and the projection maps in `c` are epimorphic, +then `cone G c.pt` is a limit cone. +-/ +noncomputable +def isLimitCone (hc : IsLimit c) [∀ i, Epi (c.π.app i)] (hc' : IsLimit <| G.mapCone c) : + IsLimit (cone G c.pt) := (functor_initial c hc).isLimitWhiskerEquiv _ hc' + +end Limit + +section Colimit + +variable {C : Type*} [Category C] (G : Profiniteᵒᵖ ⥤ C) + +/-- +Given a functor `G` from `Profiniteᵒᵖ` and `S : Profinite`, we obtain a cocone on +`(CostructuredArrow.proj toProfinite.op ⟨S⟩ ⋙ toProfinite.op ⋙ G)` with cocone point `G.obj ⟨S⟩`. + +Whiskering this cocone with `Profinite.Extend.functorOp c` gives `G.mapCocone c.op` as we check in +the example below. +-/ +@[simps] +def cocone (S : Profinite) : + Cocone (CostructuredArrow.proj toProfinite.op ⟨S⟩ ⋙ toProfinite.op ⋙ G) where + pt := G.obj ⟨S⟩ + ι := { + app := fun i ↦ G.map i.hom + naturality := fun _ _ f ↦ (by + have := f.w + simp only [op_obj, const_obj_obj, op_map, CostructuredArrow.right_eq_id, const_obj_map, + Category.comp_id] at this + simp only [comp_obj, CostructuredArrow.proj_obj, op_obj, const_obj_obj, Functor.comp_map, + CostructuredArrow.proj_map, op_map, ← map_comp, this, const_obj_map, Category.comp_id]) } + +example : G.mapCocone c.op = (cocone G c.pt).whisker (functorOp c) := rfl + +/-- +If `c` is a limit cone, `G.mapCocone c.op` is a colimit cone and the projection maps in `c` +are epimorphic, then `cocone G c.pt` is a colimit cone. +-/ +noncomputable +def isColimitCocone (hc : IsLimit c) [∀ i, Epi (c.π.app i)] (hc' : IsColimit <| G.mapCocone c.op) : + IsColimit (cocone G c.pt) := (functorOp_final c hc).isColimitWhiskerEquiv _ hc' + +end Colimit + +end Extend + +open Extend + +section ProfiniteAsLimit + +variable (S : Profinite.{u}) + +/-- +A functor `StructuredArrow S toProfinite ⥤ FintypeCat` whose limit in `Profinite` is isomorphic +to `S`. +-/ +abbrev fintypeDiagram' : StructuredArrow S toProfinite ⥤ FintypeCat := + StructuredArrow.proj S toProfinite + +/-- An abbreviation for `S.fintypeDiagram' ⋙ toProfinite`. -/ +abbrev diagram' : StructuredArrow S toProfinite ⥤ Profinite := + S.fintypeDiagram' ⋙ toProfinite + +/-- A cone over `S.diagram'` whose cone point is `S`. -/ +abbrev asLimitCone' : Cone (S.diagram') := cone (𝟭 _) S + +instance (i : DiscreteQuotient S) : Epi (S.asLimitCone.π.app i) := + (epi_iff_surjective _).mpr i.proj_surjective + +/-- `S.asLimitCone'` is a limit cone. -/ +noncomputable def asLimit' : IsLimit S.asLimitCone' := isLimitCone _ (𝟭 _) S.asLimit S.asLimit + +/-- A bundled version of `S.asLimitCone'` and `S.asLimit'`. -/ +noncomputable def lim' : LimitCone S.diagram' := ⟨S.asLimitCone', S.asLimit'⟩ + +end ProfiniteAsLimit + +end Profinite diff --git a/Mathlib/Topology/Category/Profinite/Nobeling.lean b/Mathlib/Topology/Category/Profinite/Nobeling.lean index 503c3e2b49016..b666e7f0d9593 100644 --- a/Mathlib/Topology/Category/Profinite/Nobeling.lean +++ b/Mathlib/Topology/Category/Profinite/Nobeling.lean @@ -18,16 +18,16 @@ This file proves Nöbeling's theorem. ## Main result * `LocallyConstant.freeOfProfinite`: Nöbeling's theorem. - For `S : Profinite`, the `ℤ`-module `LocallyConstant S ℤ` is free. + For `S : Profinite`, the `ℤ`-module `LocallyConstant S ℤ` is free. ## Proof idea We follow the proof of theorem 5.4 in [scholze2019condensed], in which the idea is to embed `S` in a product of `I` copies of `Bool` for some sufficiently large `I`, and then to choose a -well-ordering on `I` and use ordinal induction over that well-order. Here we can let `I` be -the set of clopen subsets of `S` since `S` is totally separated. +well-ordering on `I` and use ordinal induction over that well-order. Here we can let `I` be +the set of clopen subsets of `S` since `S` is totally separated. -The above means it suffices to prove the following statement: For a closed subset `C` of `I → Bool`, +The above means it suffices to prove the following statement: For a closed subset `C` of `I → Bool`, the `ℤ`-module `LocallyConstant C ℤ` is free. For `i : I`, let `e C i : LocallyConstant C ℤ` denote the map `fun f ↦ (if f.val i then 1 else 0)`. @@ -60,7 +60,7 @@ section Projections The purpose of this section is twofold. -Firstly, in the proof that the set `GoodProducts C` spans the whole module `LocallyConstant C ℤ`, +Firstly, in the proof that the set `GoodProducts C` spans the whole module `LocallyConstant C ℤ`, we need to project `C` down to finite discrete subsets and write `C` as a cofiltered limit of those. Secondly, in the inductive argument, we need to project `C` down to "smaller" sets satisfying the @@ -73,11 +73,11 @@ In this section we define the relevant projection maps and prove some compatibil * Let `J : I → Prop`. Then `Proj J : (I → Bool) → (I → Bool)` is the projection mapping everything that satisfies `J i` to itself, and everything else to `false`. -* The image of `C` under `Proj J` is denoted `π C J` and the corresponding map `C → π C J` is called - `ProjRestrict`. If `J` implies `K` we have a map `ProjRestricts : π C K → π C J`. +* The image of `C` under `Proj J` is denoted `π C J` and the corresponding map `C → π C J` is called + `ProjRestrict`. If `J` implies `K` we have a map `ProjRestricts : π C K → π C J`. * `spanCone_isLimit` establishes that when `C` is compact, it can be written as a limit of its - images under the maps `Proj (· ∈ s)` where `s : Finset I`. + images under the maps `Proj (· ∈ s)` where `s : Finset I`. -/ variable (J K L : I → Prop) [∀ i, Decidable (J i)] [∀ i, Decidable (K i)] [∀ i, Decidable (L i)] @@ -171,7 +171,7 @@ theorem projRestricts_comp_projRestrict (h : ∀ i, J i → K i) : variable (J) -/-- The objectwise map in the isomorphism `spanFunctor ≅ Profinite.indexFunctor`. -/ +/-- The objectwise map in the isomorphism `spanFunctor ≅ Profinite.indexFunctor`. -/ def iso_map : C(π C J, (IndexFunctor.obj C J)) := ⟨fun x ↦ ⟨fun i ↦ x.val i.val, by rcases x with ⟨x, y, hy, rfl⟩ @@ -264,7 +264,7 @@ of `e`. * `Products I` is the type of lists of decreasing elements of `I`, so a typical element is `[i₁, i₂,..., iᵣ]` with `i₁ > i₂ > ... > iᵣ`. -* `Products.eval C` is the `C`-evaluation of a list. It takes a term `[i₁, i₂,..., iᵣ] : Products I` +* `Products.eval C` is the `C`-evaluation of a list. It takes a term `[i₁, i₂,..., iᵣ] : Products I` and returns the actual product `e C i₁ ··· e C iᵣ : LocallyConstant C ℤ`. * `GoodProducts C` is the set of `Products I` such that their `C`-evaluation cannot be written as @@ -272,7 +272,7 @@ of `e`. ### Main results -* `Products.evalFacProp` and `Products.evalFacProps` establish the fact that `Products.eval`  +* `Products.evalFacProp` and `Products.evalFacProps` establish the fact that `Products.eval` interacts nicely with the projection maps from the previous section. * `GoodProducts.span_iff_products`: the good products span `LocallyConstant C ℤ` iff all the @@ -359,7 +359,7 @@ theorem injective : Function.Injective (eval C) := by · exfalso; apply ha; rw [h] exact Submodule.subset_span ⟨b, ⟨h',rfl⟩⟩ -/-- The image of the good products in the module `LocallyConstant C ℤ`. -/ +/-- The image of the good products in the module `LocallyConstant C ℤ`. -/ def range := Set.range (GoodProducts.eval C) /-- The type of good products is equivalent to its image. -/ @@ -667,7 +667,7 @@ theorem fin_comap_jointlySurjective (spanCone_isLimit hC.isCompact) f exact ⟨(Opposite.unop J), g, h⟩ -/-- The good products span all of `LocallyConstant C ℤ` if `C` is closed. -/ +/-- The good products span all of `LocallyConstant C ℤ` if `C` is closed. -/ theorem GoodProducts.span [IsWellOrder I (· < ·)] (hC : IsClosed C) : ⊤ ≤ Submodule.span ℤ (Set.range (eval C)) := by rw [span_iff_products] @@ -692,14 +692,14 @@ can be regarded as the set of all strictly smaller ordinals, allowing to apply o ### Main definitions -* `ord I i` is the term `i` of `I` regarded as an ordinal. +* `ord I i` is the term `i` of `I` regarded as an ordinal. -* `term I ho` is a sufficiently small ordinal regarded as a term of `I`. +* `term I ho` is a sufficiently small ordinal regarded as a term of `I`. -* `contained C o` is a predicate saying that `C` is "small" enough in relation to the ordinal `o` +* `contained C o` is a predicate saying that `C` is "small" enough in relation to the ordinal `o` to satisfy the inductive hypothesis. -* `P I` is the predicate on ordinals about linear independence of good products, which the rest of +* `P I` is the predicate on ordinals about linear independence of good products, which the rest of this file is spent on proving by induction. -/ @@ -732,13 +732,13 @@ theorem ord_term {o : Ordinal} (ho : o < Ordinal.type ((·<·) : I → I → Pro · subst h exact ord_term_aux ho -/-- A predicate saying that `C` is "small" enough to satisfy the inductive hypothesis. -/ +/-- A predicate saying that `C` is "small" enough to satisfy the inductive hypothesis. -/ def contained (o : Ordinal) : Prop := ∀ f, f ∈ C → ∀ (i : I), f i = true → ord I i < o variable (I) in /-- The predicate on ordinals which we prove by induction, see `GoodProducts.P0`, -`GoodProducts.Plimit` and `GoodProducts.linearIndependentAux` in the section `Induction` below +`GoodProducts.Plimit` and `GoodProducts.linearIndependentAux` in the section `Induction` below -/ def P (o : Ordinal) : Prop := o ≤ Ordinal.type (·<· : I → I → Prop) → @@ -762,7 +762,7 @@ section Zero ## The zero case of the induction -In this case, we have `contained C 0` which means that `C` is either empty or a singleton. +In this case, we have `contained C 0` which means that `C` is either empty or a singleton. -/ instance : Subsingleton (LocallyConstant (∅ : Set (I → Bool)) ℤ) := @@ -776,7 +776,7 @@ instance : IsEmpty { l // Products.isGood (∅ : Set (I → Bool)) l } := theorem GoodProducts.linearIndependentEmpty {I} [LinearOrder I] : LinearIndependent ℤ (eval (∅ : Set (I → Bool))) := linearIndependent_empty_type -/-- The empty list as a `Products` -/ +/-- The empty list as a `Products` -/ def Products.nil : Products I := ⟨[], by simp only [List.chain'_nil]⟩ theorem Products.lt_nil_empty {I} [LinearOrder I] : { m : Products I | m < Products.nil } = ∅ := by @@ -848,13 +848,13 @@ precomposition with the projections defined in the section `Projections`. ### Main definitions -* `πs` and `πs'` are the `ℤ`-linear maps corresponding to `ProjRestrict` and `ProjRestricts`  +* `πs` and `πs'` are the `ℤ`-linear maps corresponding to `ProjRestrict` and `ProjRestricts` respectively. ### Main result -* We prove that `πs` and `πs'` interact well with `Products.eval` and the main application is the - theorem `isGood_mono` which says that the property `isGood` is "monotone" on ordinals. +* We prove that `πs` and `πs'` interact well with `Products.eval` and the main application is the + theorem `isGood_mono` which says that the property `isGood` is "monotone" on ordinals. -/ theorem contained_eq_proj (o : Ordinal) (h : contained C o) : @@ -963,7 +963,7 @@ section Limit We relate linear independence in `LocallyConstant (π C (ord I · < o')) ℤ` with linear independence in `LocallyConstant C ℤ`, where `contained C o` and `o' < o`. -When `o` is a limit ordinal, we prove that the good products in `LocallyConstant C ℤ` are linearly +When `o` is a limit ordinal, we prove that the good products in `LocallyConstant C ℤ` are linearly independent if and only if a certain directed union is linearly independent. Each term in this directed union is in bijection with the good products w.r.t. `π C (ord I · < o')` for an ordinal `o' < o`, and these are linearly independent by the inductive hypothesis. @@ -972,13 +972,13 @@ directed union is in bijection with the good products w.r.t. `π C (ord I · < o * `GoodProducts.smaller` is the image of good products coming from a smaller ordinal. -* `GoodProducts.range_equiv`: The image of the `GoodProducts` in `C` is equivalent to the union of - `smaller C o'` over all ordinals `o' < o`. +* `GoodProducts.range_equiv`: The image of the `GoodProducts` in `C` is equivalent to the union of + `smaller C o'` over all ordinals `o' < o`. ### Main results * `Products.limitOrdinal`: for `o` a limit ordinal such that `contained C o`, a product `l` is good - w.r.t. `C` iff it there exists an ordinal `o' < o` such that `l` is good w.r.t. + w.r.t. `C` iff it there exists an ordinal `o' < o` such that `l` is good w.r.t. `π C (ord I · < o')`. * `GoodProducts.linearIndependent_iff_union_smaller` is the result mentioned above, that the good @@ -988,8 +988,8 @@ directed union is in bijection with the good products w.r.t. `π C (ord I · < o namespace GoodProducts /-- -The image of the `GoodProducts` for `π C (ord I · < o)` in `LocallyConstant C ℤ`. The name `smaller` -refers to the setting in which we will use this, when we are mapping in `GoodProducts` from a +The image of the `GoodProducts` for `π C (ord I · < o)` in `LocallyConstant C ℤ`. The name `smaller` +refers to the setting in which we will use this, when we are mapping in `GoodProducts` from a smaller set, i.e. when `o` is a smaller ordinal than the one `C` is "contained" in. -/ def smaller (o : Ordinal) : Set (LocallyConstant C ℤ) := @@ -1085,7 +1085,7 @@ theorem GoodProducts.union : range C = ⋃ (e : {o' // o' < o}), (smaller C e.va exact Products.isGood_mono C (le_of_lt h) hl /-- -The image of the `GoodProducts` in `C` is equivalent to the union of `smaller C o'` over all +The image of the `GoodProducts` in `C` is equivalent to the union of `smaller C o'` over all ordinals `o' < o`. -/ def GoodProducts.range_equiv : range C ≃ ⋃ (e : {o' // o' < o}), (smaller C e.val) := @@ -1108,8 +1108,8 @@ section Successor ## The successor case in the induction -Here we assume that `o` is an ordinal such that `contained C (o+1)` and `o < I`. The element in `I` -corresponding to `o` is called `term I ho`, but in this informal docstring we refer to it simply as +Here we assume that `o` is an ordinal such that `contained C (o+1)` and `o < I`. The element in `I` +corresponding to `o` is called `term I ho`, but in this informal docstring we refer to it simply as `o`. This section follows the proof in [scholze2019condensed] quite closely. A translation of the @@ -1140,32 +1140,32 @@ corresponds to the last paragraph in the proof in [scholze2019condensed]. The main definitions in the section `ExactSequence` are all just notation explained in the table above. -The main definitions in the section `GoodProducts` are as follows: +The main definitions in the section `GoodProducts` are as follows: * `MaxProducts`: the set of good products that contain the ordinal `o` (since we have `contained C (o+1)`, these all start with `o`). * `GoodProducts.sum_equiv`: the equivalence between `GoodProducts C` and the disjoint union of - `MaxProducts C` and `GoodProducts (π C (ord I · < o))`. + `MaxProducts C` and `GoodProducts (π C (ord I · < o))`. ### Main results -* The main results in the section `ExactSequence` are `succ_mono` and `succ_exact` which together - say that the sequence given by `πs` and `Linear_CC'` is left exact: +* The main results in the section `ExactSequence` are `succ_mono` and `succ_exact` which together + say that the sequence given by `πs` and `Linear_CC'` is left exact: ``` f g 0 --→ LocallyConstant (π C (ord I · < o)) ℤ --→ LocallyConstant C ℤ --→ LocallyConstant C' ℤ ``` - where `f` is `πs` and `g` is `Linear_CC'`. + where `f` is `πs` and `g` is `Linear_CC'`. -The main results in the section `GoodProducts` are as follows: +The main results in the section `GoodProducts` are as follows: * `Products.max_eq_eval` says that the linear map on the right in the exact sequence, i.e. - `Linear_CC'`, takes the evaluation of a term of `MaxProducts` to the evaluation of the + `Linear_CC'`, takes the evaluation of a term of `MaxProducts` to the evaluation of the corresponding list with the leading `o` removed. -* `GoodProducts.maxTail_isGood` says that removing the leading `o` from a term of `MaxProducts C`  - yields a list which `isGood` with respect to `C'`. +* `GoodProducts.maxTail_isGood` says that removing the leading `o` from a term of `MaxProducts C` + yields a list which `isGood` with respect to `C'`. -/ variable {o : Ordinal} (hC : IsClosed C) (hsC : contained C (Order.succ o)) @@ -1245,7 +1245,7 @@ theorem swapTrue_mem_C1 (f : π (C1 C ho) (ord I · < o)) : contrapose! hsC exact ⟨hsC, Order.succ_le_of_lt (h'.lt_of_ne' h)⟩ -/-- The first way to map `C'` into `C`. -/ +/-- The first way to map `C'` into `C`. -/ def CC'₀ : C' C ho → C := fun g ↦ ⟨g.val,g.prop.1.1⟩ /-- The second way to map `C'` into `C`. -/ @@ -1268,7 +1268,7 @@ noncomputable def Linear_CC'₁ : LocallyConstant C ℤ →ₗ[ℤ] LocallyConstant (C' C ho) ℤ := LocallyConstant.comapₗ ℤ ⟨(CC'₁ C hsC ho), (continuous_CC'₁ C hsC ho)⟩ -/-- The difference between `Linear_CC'₁` and `Linear_CC'₀`. -/ +/-- The difference between `Linear_CC'₁` and `Linear_CC'₀`. -/ noncomputable def Linear_CC' : LocallyConstant C ℤ →ₗ[ℤ] LocallyConstant (C' C ho) ℤ := Linear_CC'₁ C hsC ho - Linear_CC'₀ C ho @@ -1450,7 +1450,7 @@ theorem sum_equiv_comp_eval_eq_elim : eval C ∘ (sum_equiv C hsC ho).toFun = Then `SumEval C ho` is the map `u` in the diagram below. It is linearly independent if and only if `GoodProducts.eval C` is, see `linearIndependent_iff_sum`. The top row is the exact sequence given -by `succ_exact` and `succ_mono`. The left square commutes by `GoodProducts.square_commutes`. +by `succ_exact` and `succ_mono`. The left square commutes by `GoodProducts.square_commutes`. ``` 0 --→ N --→ M --→ P ↑ ↑ ↑ @@ -1609,20 +1609,20 @@ theorem good_lt_maxProducts (q : GoodProducts (π C (ord I · < o))) include hC hsC in /-- -Removing the leading `o` from a term of `MaxProducts C` yields a list which `isGood` with respect to +Removing the leading `o` from a term of `MaxProducts C` yields a list which `isGood` with respect to `C'`. -/ theorem maxTail_isGood (l : MaxProducts C ho) (h₁ : ⊤ ≤ Submodule.span ℤ (Set.range (eval (π C (ord I · < o))))) : l.val.Tail.isGood (C' C ho) := by have : Inhabited I := ⟨term I ho⟩ - -- Write `l.Tail` as a linear combination of smaller products: + -- Write `l.Tail` as a linear combination of smaller products: intro h rw [Finsupp.mem_span_image_iff_linearCombination, ← max_eq_eval C hsC ho] at h obtain ⟨m, ⟨hmmem, hmsum⟩⟩ := h rw [Finsupp.linearCombination_apply] at hmsum - -- Write the image of `l` under `Linear_CC'` as `Linear_CC'` applied to the linear combination + -- Write the image of `l` under `Linear_CC'` as `Linear_CC'` applied to the linear combination -- above, with leading `term I ho`'s added to each term: have : (Linear_CC' C hsC ho) (l.val.eval C) = (Linear_CC' C hsC ho) (Finsupp.sum m fun i a ↦ a • ((term I ho :: i.1).map (e C)).prod) := by @@ -1646,7 +1646,7 @@ theorem maxTail_isGood (l : MaxProducts C ho) rw [ShortComplex.moduleCat_exact_iff_range_eq_ker] at hse dsimp [ModuleCat.ofHom] at hse - -- Rewrite `this` using exact sequence manipulations to conclude that a term is in the range of + -- Rewrite `this` using exact sequence manipulations to conclude that a term is in the range of -- the linear map `πs`: rw [← LinearMap.sub_mem_ker_iff, ← hse] at this obtain ⟨(n : LocallyConstant (π C (ord I · < o)) ℤ), hn⟩ := this @@ -1722,16 +1722,16 @@ section Induction ## The induction -Here we put together the results of the sections `Zero`, `Limit` and `Successor` to prove the -predicate `P I o` holds for all ordinals `o`, and conclude with the main result: +Here we put together the results of the sections `Zero`, `Limit` and `Successor` to prove the +predicate `P I o` holds for all ordinals `o`, and conclude with the main result: -* `GoodProducts.linearIndependent` which says that `GoodProducts C` is linearly independent when `C` +* `GoodProducts.linearIndependent` which says that `GoodProducts C` is linearly independent when `C` is closed. We also define -* `GoodProducts.Basis` which uses `GoodProducts.linearIndependent` and `GoodProducts.span` to - define a basis for `LocallyConstant C ℤ`  +* `GoodProducts.Basis` which uses `GoodProducts.linearIndependent` and `GoodProducts.span` to + define a basis for `LocallyConstant C ℤ` -/ theorem GoodProducts.P0 : P I 0 := fun _ C _ hsC ↦ by @@ -1771,7 +1771,7 @@ theorem GoodProducts.linearIndependent (hC : IsClosed C) : GoodProducts.linearIndependentAux (Ordinal.type (·<· : I → I → Prop)) (le_refl _) C hC (fun _ _ _ _ ↦ Ordinal.typein_lt_type _ _) -/-- `GoodProducts C` as a `ℤ`-basis for `LocallyConstant C ℤ`. -/ +/-- `GoodProducts C` as a `ℤ`-basis for `LocallyConstant C ℤ`. -/ noncomputable def GoodProducts.Basis (hC : IsClosed C) : Basis (GoodProducts C) ℤ (LocallyConstant C ℤ) := @@ -1783,7 +1783,7 @@ variable {S : Profinite} {ι : S → I → Bool} (hι : ClosedEmbedding ι) include hι /-- -Given a profinite set `S` and a closed embedding `S → (I → Bool)`, the `ℤ`-module +Given a profinite set `S` and a closed embedding `S → (I → Bool)`, the `ℤ`-module `LocallyConstant C ℤ` is free. -/ theorem Nobeling_aux : Module.Free ℤ (LocallyConstant S ℤ) := Module.Free.of_equiv' @@ -1800,7 +1800,7 @@ noncomputable def Nobeling.ι : S → ({C : Set S // IsClopen C} → Bool) := fun s C => decide (s ∈ C.1) open scoped Classical in -/-- The map `Nobeling.ι` is a closed embedding. -/ +/-- The map `Nobeling.ι` is a closed embedding. -/ theorem Nobeling.embedding : ClosedEmbedding (Nobeling.ι S) := by apply Continuous.closedEmbedding · dsimp (config := { unfoldPartialApp := true }) [ι] @@ -1830,9 +1830,11 @@ end Profinite open Profinite NobelingProof -/-- Nöbeling's theorem: the `ℤ`-module `LocallyConstant S ℤ` is free for every `S : Profinite` -/ +/-- Nöbeling's theorem: the `ℤ`-module `LocallyConstant S ℤ` is free for every `S : Profinite` -/ instance LocallyConstant.freeOfProfinite (S : Profinite.{u}) : Module.Free ℤ (LocallyConstant S ℤ) := @Nobeling_aux {C : Set S // IsClopen C} (IsWellOrder.linearOrder WellOrderingRel) WellOrderingRel.isWellOrder S (Nobeling.ι S) (Nobeling.embedding S) + +set_option linter.style.longFile 2000 diff --git a/Mathlib/Topology/Category/Profinite/Product.lean b/Mathlib/Topology/Category/Profinite/Product.lean index 6760033fce6b9..0224264e33b98 100644 --- a/Mathlib/Topology/Category/Profinite/Product.lean +++ b/Mathlib/Topology/Category/Profinite/Product.lean @@ -13,7 +13,7 @@ Hausdorff spaces as a cofiltered limit in `Profinite` indexed by `Finset ι`. ## Main definitions -- `Profinite.indexFunctor` is the functor `(Finset ι)ᵒᵖ ⥤ Profinite` indexing the limit. It maps +- `Profinite.indexFunctor` is the functor `(Finset ι)ᵒᵖ ⥤ Profinite` indexing the limit. It maps `J` to the restriction of `C` to `J` - `Profinite.indexCone` is a cone on `Profinite.indexFunctor` with cone point `C` diff --git a/Mathlib/Topology/Category/Stonean/Adjunctions.lean b/Mathlib/Topology/Category/Stonean/Adjunctions.lean index d20e34fdfc9fb..dd99b65695aed 100644 --- a/Mathlib/Topology/Category/Stonean/Adjunctions.lean +++ b/Mathlib/Topology/Category/Stonean/Adjunctions.lean @@ -12,7 +12,7 @@ import Mathlib.Topology.StoneCech This file constructs the left adjoint `typeToStonean` to the forgetful functor from Stonean spaces to sets, using the Stone-Cech compactification. This allows to conclude that the monomorphisms in -`Stonean` are precisely the injective maps (see `Stonean.mono_iff_injective`). +`Stonean` are precisely the injective maps (see `Stonean.mono_iff_injective`). -/ universe u diff --git a/Mathlib/Topology/Category/Stonean/Basic.lean b/Mathlib/Topology/Category/Stonean/Basic.lean index 41c7eeabe0cde..2dd69040d6dce 100644 --- a/Mathlib/Topology/Category/Stonean/Basic.lean +++ b/Mathlib/Topology/Category/Stonean/Basic.lean @@ -83,7 +83,7 @@ abbrev fullyFaithfulToCompHaus : toCompHaus.FullyFaithful := open CompHausLike -instance (X : Type*) [TopologicalSpace X] +instance (X : Type*) [TopologicalSpace X] [ExtremallyDisconnected X] : HasProp (fun Y ↦ ExtremallyDisconnected Y) X := ⟨(inferInstance : ExtremallyDisconnected X)⟩ @@ -116,7 +116,7 @@ def mkFinite (X : Type*) [Finite X] [TopologicalSpace X] [DiscreteTopology X] : apply isOpen_discrete (closure U) /-- -A morphism in `Stonean` is an epi iff it is surjective. +A morphism in `Stonean` is an epi iff it is surjective. -/ lemma epi_iff_surjective {X Y : Stonean} (f : X ⟶ Y) : Epi f ↔ Function.Surjective f := by @@ -186,7 +186,7 @@ end Stonean namespace CompHaus /-- If `X` is compact Hausdorff, `presentation X` is a Stonean space equipped with an epimorphism - down to `X` (see `CompHaus.presentation.π` and `CompHaus.presentation.epi_π`). It is a + down to `X` (see `CompHaus.presentation.π` and `CompHaus.presentation.epi_π`). It is a "constructive" witness to the fact that `CompHaus` has enough projectives. -/ noncomputable def presentation (X : CompHaus) : Stonean where @@ -253,7 +253,7 @@ end CompHaus namespace Profinite /-- If `X` is profinite, `presentation X` is a Stonean space equipped with an epimorphism down to - `X` (see `Profinite.presentation.π` and `Profinite.presentation.epi_π`). -/ + `X` (see `Profinite.presentation.π` and `Profinite.presentation.epi_π`). -/ noncomputable def presentation (X : Profinite) : Stonean where toTop := (profiniteToCompHaus.obj X).projectivePresentation.p.toTop diff --git a/Mathlib/Topology/Category/Stonean/EffectiveEpi.lean b/Mathlib/Topology/Category/Stonean/EffectiveEpi.lean index 6f0dcd7b65055..ff4d234dae338 100644 --- a/Mathlib/Topology/Category/Stonean/EffectiveEpi.lean +++ b/Mathlib/Topology/Category/Stonean/EffectiveEpi.lean @@ -55,7 +55,7 @@ instance : Stonean.toCompHaus.ReflectsEffectiveEpis where (((CompHaus.effectiveEpi_tfae (Stonean.toCompHaus.map f)).out 0 2).mp h) /-- -An effective presentation of an `X : CompHaus` with respect to the inclusion functor from `Stonean` +An effective presentation of an `X : CompHaus` with respect to the inclusion functor from `Stonean` -/ noncomputable def stoneanToCompHausEffectivePresentation (X : CompHaus) : Stonean.toCompHaus.EffectivePresentation X where diff --git a/Mathlib/Topology/Category/TopCat/EffectiveEpi.lean b/Mathlib/Topology/Category/TopCat/EffectiveEpi.lean index 841f550bb606f..5510c9abcf4ae 100644 --- a/Mathlib/Topology/Category/TopCat/EffectiveEpi.lean +++ b/Mathlib/Topology/Category/TopCat/EffectiveEpi.lean @@ -11,7 +11,7 @@ import Mathlib.Topology.Category.TopCat.Limits.Pullbacks # Effective epimorphisms in `TopCat` This file proves the result `TopCat.effectiveEpi_iff_quotientMap`: -The effective epimorphisms in `TopCat` are precisely the quotient maps. +The effective epimorphisms in `TopCat` are precisely the quotient maps. -/ @@ -37,7 +37,7 @@ def effectiveEpiStructOfQuotientMap {B X : TopCat.{u}} (π : X ⟶ B) (hπ : Quo fac e h := (hπ.lift_comp e fun a b hab ↦ DFunLike.congr_fun (h ⟨fun _ ↦ a, continuous_const⟩ ⟨fun _ ↦ b, continuous_const⟩ (by ext; exact hab)) a) - /- Uniqueness follows from the fact that `QuotientMap.lift` is an equivalence (given by + /- Uniqueness follows from the fact that `QuotientMap.lift` is an equivalence (given by `QuotientMap.liftEquiv`). -/ uniq e h g hm := by suffices g = hπ.liftEquiv ⟨e, @@ -49,12 +49,12 @@ def effectiveEpiStructOfQuotientMap {B X : TopCat.{u}} (π : X ⟶ B) (hπ : Quo simp only [QuotientMap.liftEquiv_symm_apply_coe, ContinuousMap.comp_apply, ← hm] rfl -/-- The effective epimorphisms in `TopCat` are precisely the quotient maps. -/ +/-- The effective epimorphisms in `TopCat` are precisely the quotient maps. -/ theorem effectiveEpi_iff_quotientMap {B X : TopCat.{u}} (π : X ⟶ B) : EffectiveEpi π ↔ QuotientMap π := by /- The backward direction is given by `effectiveEpiStructOfQuotientMap` above. -/ refine ⟨fun _ ↦ ?_, fun hπ ↦ ⟨⟨effectiveEpiStructOfQuotientMap π hπ⟩⟩⟩ - /- Since `TopCat` has pullbacks, `π` is in fact a `RegularEpi`. This means that it exhibits `B` as + /- Since `TopCat` has pullbacks, `π` is in fact a `RegularEpi`. This means that it exhibits `B` as a coequalizer of two maps into `X`. It suffices to prove that `π` followed by the isomorphism to an arbitrary coequalizer is a quotient map. -/ have hπ : RegularEpi π := inferInstance @@ -63,7 +63,7 @@ theorem effectiveEpi_iff_quotientMap {B X : TopCat.{u}} (π : X ⟶ B) : suffices QuotientMap (homeoOfIso i ∘ π) by simpa [← Function.comp.assoc] using (homeoOfIso i).symm.quotientMap.comp this constructor - /- Effective epimorphisms are epimorphisms and epimorphisms in `TopCat` are surjective. -/ + /- Effective epimorphisms are epimorphisms and epimorphisms in `TopCat` are surjective. -/ · change Function.Surjective (π ≫ i.hom) rw [← epi_iff_surjective] infer_instance diff --git a/Mathlib/Topology/Category/TopCat/Limits/Products.lean b/Mathlib/Topology/Category/TopCat/Limits/Products.lean index 43cd610adcbfb..20ee2f8395a8d 100644 --- a/Mathlib/Topology/Category/TopCat/Limits/Products.lean +++ b/Mathlib/Topology/Category/TopCat/Limits/Products.lean @@ -58,7 +58,7 @@ equipped with the product topology. -/ def piIsoPi {ι : Type v} (α : ι → TopCat.{max v u}) : ∏ᶜ α ≅ TopCat.of (∀ i, α i) := (limit.isLimit _).conePointUniqueUpToIso (piFanIsLimit.{v, u} α) - -- Specifying the universes in `piFanIsLimit` wasn't necessary when we had `TopCatMax`  + -- Specifying the universes in `piFanIsLimit` wasn't necessary when we had `TopCatMax` @[reassoc (attr := simp)] theorem piIsoPi_inv_π {ι : Type v} (α : ι → TopCat.{max v u}) (i : ι) : @@ -106,7 +106,7 @@ def sigmaCofanIsColimit {ι : Type v} (β : ι → TopCat.{max v u}) : IsColimit -/ def sigmaIsoSigma {ι : Type v} (α : ι → TopCat.{max v u}) : ∐ α ≅ TopCat.of (Σi, α i) := (colimit.isColimit _).coconePointUniqueUpToIso (sigmaCofanIsColimit.{v, u} α) - -- Specifying the universes in `sigmaCofanIsColimit` wasn't necessary when we had `TopCatMax`  + -- Specifying the universes in `sigmaCofanIsColimit` wasn't necessary when we had `TopCatMax` @[reassoc (attr := simp)] theorem sigmaIsoSigma_hom_ι {ι : Type v} (α : ι → TopCat.{max v u}) (i : ι) : diff --git a/Mathlib/Topology/Category/TopCat/OpenNhds.lean b/Mathlib/Topology/Category/TopCat/OpenNhds.lean index c5465486c0688..a5c79d6b932bf 100644 --- a/Mathlib/Topology/Category/TopCat/OpenNhds.lean +++ b/Mathlib/Topology/Category/TopCat/OpenNhds.lean @@ -10,12 +10,12 @@ import Mathlib.Data.Set.Subsingleton # The category of open neighborhoods of a point Given an object `X` of the category `TopCat` of topological spaces and a point `x : X`, this file -builds the type `OpenNhds x` of open neighborhoods of `x` in `X` and endows it with the partial +builds the type `OpenNhds x` of open neighborhoods of `x` in `X` and endows it with the partial order given by inclusion and the corresponding category structure (as a full subcategory of the poset category `Set X`). This is used in `Topology.Sheaves.Stalks` to build the stalk of a sheaf at `x` as a limit over `OpenNhds x`. -## Main declarations +## Main declarations Besides `OpenNhds`, the main constructions here are: diff --git a/Mathlib/Topology/Category/TopCat/Yoneda.lean b/Mathlib/Topology/Category/TopCat/Yoneda.lean index 4875f93370077..65ed0d1e00d83 100644 --- a/Mathlib/Topology/Category/TopCat/Yoneda.lean +++ b/Mathlib/Topology/Category/TopCat/Yoneda.lean @@ -57,7 +57,7 @@ theorem piComparison_fac {α : Type} (X : α → TopCat) : Equiv.coe_fn_symm_mk, comp_assoc, sigmaMk_apply, ← opCoproductIsoProduct_inv_comp_ι] rfl -/-- The universe polymorphic Yoneda presheaf on `TopCat` preserves finite products. -/ +/-- The universe polymorphic Yoneda presheaf on `TopCat` preserves finite products. -/ noncomputable instance : PreservesFiniteProducts (yonedaPresheaf'.{w, w'} Y) where preserves J _ := { preservesLimit := fun {K} => diff --git a/Mathlib/Topology/Compactness/CompactlyGeneratedSpace.lean b/Mathlib/Topology/Compactness/CompactlyGeneratedSpace.lean index ebc17cc09ad5a..fbcd4585a405a 100644 --- a/Mathlib/Topology/Compactness/CompactlyGeneratedSpace.lean +++ b/Mathlib/Topology/Compactness/CompactlyGeneratedSpace.lean @@ -54,7 +54,7 @@ The compactly generated topology on a topological space `X`. This is the finest which makes all maps from compact Hausdorff spaces to `X`, which are continuous for the original topology, continuous. -Note: this definition should be used with an explicit universe parameter `u` for the size of the +Note: this definition should be used with an explicit universe parameter `u` for the size of the compact Hausdorff spaces mapping to `X`. -/ def TopologicalSpace.compactlyGenerated (X : Type w) [TopologicalSpace X] : TopologicalSpace X := diff --git a/Mathlib/Topology/Compactness/Lindelof.lean b/Mathlib/Topology/Compactness/Lindelof.lean index 4652fa61f3e11..6cbd814c5efbe 100644 --- a/Mathlib/Topology/Compactness/Lindelof.lean +++ b/Mathlib/Topology/Compactness/Lindelof.lean @@ -511,7 +511,7 @@ theorem IsClosed.isLindelof [LindelofSpace X] (h : IsClosed s) : IsLindelof s := theorem IsCompact.isLindelof (hs : IsCompact s) : IsLindelof s := by tauto -/-- A σ-compact set `s` is Lindelöf-/ +/-- A σ-compact set `s` is Lindelöf -/ theorem IsSigmaCompact.isLindelof (hs : IsSigmaCompact s) : IsLindelof s := by rw [IsSigmaCompact] at hs @@ -564,7 +564,7 @@ theorem Filter.coLindelof_neBot_iff : NeBot (Filter.coLindelof X) ↔ NonLindelo theorem not_LindelofSpace_iff : ¬LindelofSpace X ↔ NonLindelofSpace X := ⟨fun h₁ => ⟨fun h₂ => h₁ ⟨h₂⟩⟩, fun ⟨h₁⟩ ⟨h₂⟩ => h₁ h₂⟩ -/-- A compact space `X` is Lindelöf. -/ +/-- A compact space `X` is Lindelöf. -/ instance (priority := 100) [CompactSpace X] : LindelofSpace X := { isLindelof_univ := isCompact_univ.isLindelof} @@ -692,7 +692,7 @@ for open sets in the definition, and then conclude that this holds for all sets def IsHereditarilyLindelof (s : Set X) := ∀ t ⊆ s, IsLindelof t -/-- Type class for Hereditarily Lindelöf spaces. -/ +/-- Type class for Hereditarily Lindelöf spaces. -/ class HereditarilyLindelofSpace (X : Type*) [TopologicalSpace X] : Prop where /-- In a Hereditarily Lindelöf space, `Set.univ` is a Hereditarily Lindelöf set. -/ isHereditarilyLindelof_univ : IsHereditarilyLindelof (univ : Set X) diff --git a/Mathlib/Topology/Connected/PathConnected.lean b/Mathlib/Topology/Connected/PathConnected.lean index 07fea44bddd1e..8e9c395f62521 100644 --- a/Mathlib/Topology/Connected/PathConnected.lean +++ b/Mathlib/Topology/Connected/PathConnected.lean @@ -33,7 +33,7 @@ Then there are corresponding relative notions for `F : Set X`. * `LocPathConnectedSpace X` is a predicate class asserting that `X` is locally path-connected: each point has a basis of path-connected neighborhoods (we do *not* ask these to be open). -## Main theorems +## Main theorems * `Joined` and `JoinedIn F` are transitive relations. diff --git a/Mathlib/Topology/Connected/Separation.lean b/Mathlib/Topology/Connected/Separation.lean index 57db6948dc729..8ce21856914c0 100644 --- a/Mathlib/Topology/Connected/Separation.lean +++ b/Mathlib/Topology/Connected/Separation.lean @@ -11,7 +11,7 @@ import Mathlib.Topology.Separation This file provides an instance `T2Space X` given `TotallySeparatedSpace X`. ## TODO -* Move the last part of `Topology/Separation` to this file. +* Move the last part of `Topology/Separation` to this file. -/ diff --git a/Mathlib/Topology/Constructions.lean b/Mathlib/Topology/Constructions.lean index 9e9048b0dcb31..8e3db8e45a710 100644 --- a/Mathlib/Topology/Constructions.lean +++ b/Mathlib/Topology/Constructions.lean @@ -600,7 +600,7 @@ theorem prod_generateFrom_generateFrom_eq {X Y : Type*} {s : Set (Set X)} {t : S (hs : ⋃₀ s = univ) (ht : ⋃₀ t = univ) : @instTopologicalSpaceProd X Y (generateFrom s) (generateFrom t) = generateFrom (image2 (· ×ˢ ·) s t) := - let G := generateFrom (image2 (· ×ˢ ·) s t) + let G := generateFrom (image2 (· ×ˢ ·) s t) le_antisymm (le_generateFrom fun g ⟨u, hu, v, hv, g_eq⟩ => g_eq.symm ▸ @@ -1067,7 +1067,7 @@ theorem embedding_inclusion {s t : Set X} (h : s ⊆ t) : Embedding (inclusion h embedding_subtype_val.codRestrict _ _ /-- Let `s, t ⊆ X` be two subsets of a topological space `X`. If `t ⊆ s` and the topology induced -by `X`on `s` is discrete, then also the topology induces on `t` is discrete. -/ +by `X`on `s` is discrete, then also the topology induces on `t` is discrete. -/ theorem DiscreteTopology.of_subset {X : Type*} [TopologicalSpace X] {s t : Set X} (_ : DiscreteTopology s) (ts : t ⊆ s) : DiscreteTopology t := (embedding_inclusion ts).discreteTopology @@ -1608,3 +1608,5 @@ theorem Filter.Eventually.prod_nhdsSet {p : X × Y → Prop} {px : X → Prop} { nhdsSet_prod_le _ _ (mem_of_superset (prod_mem_prod hs ht) fun _ ⟨hx, hy⟩ ↦ hp hx hy) end NhdsSet + +set_option linter.style.longFile 1700 diff --git a/Mathlib/Topology/ContinuousFunction/Basic.lean b/Mathlib/Topology/ContinuousFunction/Basic.lean index b24e4f2ee999c..e77f01dabfc8e 100644 --- a/Mathlib/Topology/ContinuousFunction/Basic.lean +++ b/Mathlib/Topology/ContinuousFunction/Basic.lean @@ -68,7 +68,7 @@ instance : CoeTC F C(α, β) := ⟨toContinuousMap⟩ end ContinuousMapClass -/-! ### Continuous maps-/ +/-! ### Continuous maps -/ namespace ContinuousMap @@ -304,7 +304,7 @@ def sigma (f : ∀ i, C(X i, A)) : C((Σ i, X i), A) where variable (A X) in /-- Giving a continuous map out of a disjoint union is the same as giving a continuous map out of -each term. This is a version of `Equiv.piCurry` for continuous maps. +each term. This is a version of `Equiv.piCurry` for continuous maps. -/ @[simps] def sigmaEquiv : (∀ i, C(X i, A)) ≃ C((Σ i, X i), A) where @@ -494,7 +494,7 @@ noncomputable def lift : C(Y, Z) where continuous_toFun := Continuous.comp (continuous_quot_lift _ g.2) (Homeomorph.continuous _) /-- -The obvious triangle induced by `QuotientMap.lift` commutes: +The obvious triangle induced by `QuotientMap.lift` commutes: ``` g X --→ Z diff --git a/Mathlib/Topology/ContinuousFunction/Bounded.lean b/Mathlib/Topology/ContinuousFunction/Bounded.lean index 80e9caca4ffa6..3c61e9ba6a02d 100644 --- a/Mathlib/Topology/ContinuousFunction/Bounded.lean +++ b/Mathlib/Topology/ContinuousFunction/Bounded.lean @@ -1513,3 +1513,5 @@ lemma norm_sub_nonneg (f : α →ᵇ ℝ) : end end BoundedContinuousFunction + +set_option linter.style.longFile 1700 diff --git a/Mathlib/Topology/ContinuousFunction/Ordered.lean b/Mathlib/Topology/ContinuousFunction/Ordered.lean index 0b4780410756f..7e46c520e70b6 100644 --- a/Mathlib/Topology/ContinuousFunction/Ordered.lean +++ b/Mathlib/Topology/ContinuousFunction/Ordered.lean @@ -85,7 +85,7 @@ section Extend variable [LinearOrder α] [OrderTopology α] {a b : α} (h : a ≤ b) -/-- Extend a continuous function `f : C(Set.Icc a b, β)` to a function `f : C(α, β)`. -/ +/-- Extend a continuous function `f : C(Set.Icc a b, β)` to a function `f : C(α, β)`. -/ def IccExtend (f : C(Set.Icc a b, β)) : C(α, β) where toFun := Set.IccExtend h f diff --git a/Mathlib/Topology/DiscreteQuotient.lean b/Mathlib/Topology/DiscreteQuotient.lean index 6c041809ef504..a6413350f7c54 100644 --- a/Mathlib/Topology/DiscreteQuotient.lean +++ b/Mathlib/Topology/DiscreteQuotient.lean @@ -348,7 +348,7 @@ open Classical in If `X` is a compact space, then we associate to any discrete quotient on `X` a finite set of clopen subsets of `X`, given by the fibers of `proj`. -TODO: prove that these form a partition of `X`  +TODO: prove that these form a partition of `X` -/ noncomputable def finsetClopens [CompactSpace X] (d : DiscreteQuotient X) : Finset (Clopens X) := have : Fintype d := Fintype.ofFinite _ @@ -368,7 +368,7 @@ lemma comp_finsetClopens [CompactSpace X] : simpa [← h] using Quotient.mk_eq_iff_out (s := d.toSetoid) · exact fun ⟨y, h⟩ ↦ ⟨d.proj y, by ext; simp [h, proj]⟩ -/-- `finsetClopens X` is injective. -/ +/-- `finsetClopens X` is injective. -/ theorem finsetClopens_inj [CompactSpace X] : (finsetClopens X).Injective := by apply Function.Injective.of_comp (f := Set.image (fun (t : Clopens X) ↦ t.carrier) ∘ Finset.toSet) diff --git a/Mathlib/Topology/DiscreteSubset.lean b/Mathlib/Topology/DiscreteSubset.lean index 834b2a12022fc..5238fbf4e8e1e 100644 --- a/Mathlib/Topology/DiscreteSubset.lean +++ b/Mathlib/Topology/DiscreteSubset.lean @@ -97,7 +97,7 @@ theorem isClosed_and_discrete_iff {S : Set X} : simpa [disjoint_iff, nhdsWithin, inf_assoc, hx] using H /-- The filter of sets with no accumulation points inside a set `S : Set X`, implemented -as the supremum over all punctured neighborhoods within `S`. -/ +as the supremum over all punctured neighborhoods within `S`. -/ def Filter.codiscreteWithin (S : Set X) : Filter X := ⨆ x ∈ S, 𝓝[S \ {x}] x lemma mem_codiscreteWithin {S T : Set X} : diff --git a/Mathlib/Topology/EMetricSpace/Basic.lean b/Mathlib/Topology/EMetricSpace/Basic.lean index 79a2678c491d7..cf23aef640373 100644 --- a/Mathlib/Topology/EMetricSpace/Basic.lean +++ b/Mathlib/Topology/EMetricSpace/Basic.lean @@ -230,7 +230,7 @@ section Compact -- Porting note (#11215): TODO: generalize to metrizable spaces /-- A compact set in a pseudo emetric space is separable, i.e., it is a subset of the closure of a -countable set. -/ +countable set. -/ theorem subset_countable_closure_of_compact {s : Set α} (hs : IsCompact s) : ∃ t, t ⊆ s ∧ t.Countable ∧ s ⊆ closure t := by refine subset_countable_closure_of_almost_dense_set s fun ε hε => ?_ diff --git a/Mathlib/Topology/FiberBundle/Trivialization.lean b/Mathlib/Topology/FiberBundle/Trivialization.lean index c1e63718a72cd..74276221f3ee0 100644 --- a/Mathlib/Topology/FiberBundle/Trivialization.lean +++ b/Mathlib/Topology/FiberBundle/Trivialization.lean @@ -74,7 +74,7 @@ variable (e : Pretrivialization F proj) {x : Z} /-- Coercion of a pretrivialization to a function. We don't use `e.toFun` in the `CoeFun` instance because it is actually `e.toPartialEquiv.toFun`, so `simp` will apply lemmas about `toPartialEquiv`. While we may want to switch to this behavior later, doing it mid-port will break a -lot of proofs. -/ +lot of proofs. -/ @[coe] def toFun' : Z → (B × F) := e.toFun instance : CoeFun (Pretrivialization F proj) fun _ => Z → B × F := ⟨toFun'⟩ @@ -282,7 +282,7 @@ lemma ext' (e e' : Trivialization F proj) (h₁ : e.toPartialHomeomorph = e'.toP /-- Coercion of a trivialization to a function. We don't use `e.toFun` in the `CoeFun` instance because it is actually `e.toPartialEquiv.toFun`, so `simp` will apply lemmas about `toPartialEquiv`. While we may want to switch to this behavior later, doing it mid-port will break a -lot of proofs. -/ +lot of proofs. -/ @[coe] def toFun' : Z → (B × F) := e.toFun /-- Natural identification as a `Pretrivialization`. -/ @@ -465,7 +465,7 @@ theorem preimageSingletonHomeomorph_symm_apply {b : B} (hb : b ∈ e.baseSet) (p ⟨e.symm (b, p), by rw [mem_preimage, e.proj_symm_apply' hb, mem_singleton_iff]⟩ := rfl -/-- In the domain of a bundle trivialization, the projection is continuous-/ +/-- In the domain of a bundle trivialization, the projection is continuous -/ theorem continuousAt_proj (ex : x ∈ e.source) : ContinuousAt proj x := (e.map_proj_nhds ex).le diff --git a/Mathlib/Topology/Instances/ENNReal.lean b/Mathlib/Topology/Instances/ENNReal.lean index e91af73104939..3931f4671b99e 100644 --- a/Mathlib/Topology/Instances/ENNReal.lean +++ b/Mathlib/Topology/Instances/ENNReal.lean @@ -444,7 +444,7 @@ theorem iInf_mul_left' {ι} {f : ι → ℝ≥0∞} {a : ℝ≥0∞} (h : a = cases isEmpty_or_nonempty ι · rw [iInf_of_empty, iInf_of_empty, mul_top] exact mt h0 (not_nonempty_iff.2 ‹_›) - · exact (ENNReal.mul_left_mono.map_iInf_of_continuousAt' + · exact (ENNReal.mul_left_mono.map_ciInf_of_continuousAt (ENNReal.continuousAt_const_mul H)).symm theorem iInf_mul_left {ι} [Nonempty ι] {f : ι → ℝ≥0∞} {a : ℝ≥0∞} @@ -504,7 +504,7 @@ protected theorem tendsto_inv_nat_nhds_zero : Tendsto (fun n : ℕ => (n : ℝ ENNReal.inv_top ▸ ENNReal.tendsto_inv_iff.2 tendsto_nat_nhds_top theorem iSup_add {ι : Sort*} {s : ι → ℝ≥0∞} [Nonempty ι] : iSup s + a = ⨆ b, s b + a := - Monotone.map_iSup_of_continuousAt' (continuousAt_id.add continuousAt_const) <| + Monotone.map_ciSup_of_continuousAt (continuousAt_id.add continuousAt_const) <| monotone_id.add monotone_const theorem biSup_add' {ι : Sort*} {p : ι → Prop} (h : ∃ i, p i) {f : ι → ℝ≥0∞} : @@ -610,7 +610,7 @@ protected theorem tendsto_coe_sub {b : ℝ≥0∞} : theorem sub_iSup {ι : Sort*} [Nonempty ι] {b : ι → ℝ≥0∞} (hr : a < ∞) : (a - ⨆ i, b i) = ⨅ i, a - b i := - antitone_const_tsub.map_iSup_of_continuousAt' (continuous_sub_left hr.ne).continuousAt + antitone_const_tsub.map_ciSup_of_continuousAt (continuous_sub_left hr.ne).continuousAt theorem exists_countable_dense_no_zero_top : ∃ s : Set ℝ≥0∞, s.Countable ∧ Dense s ∧ 0 ∉ s ∧ ∞ ∉ s := by @@ -1523,3 +1523,5 @@ lemma limsup_toReal_eq {ι : Type*} {F : Filter ι} [NeBot F] {b : ℝ≥0∞} ( end LimsupLiminf end ENNReal -- namespace + +set_option linter.style.longFile 1700 diff --git a/Mathlib/Topology/Instances/NNReal.lean b/Mathlib/Topology/Instances/NNReal.lean index f7759c47f7eea..d6ef63c1b5f66 100644 --- a/Mathlib/Topology/Instances/NNReal.lean +++ b/Mathlib/Topology/Instances/NNReal.lean @@ -93,6 +93,11 @@ noncomputable def _root_.ContinuousMap.realToNNReal : C(ℝ, ℝ≥0) := theorem continuous_coe : Continuous ((↑) : ℝ≥0 → ℝ) := continuous_subtype_val +lemma _root_.ContinuousOn.ofReal_map_toNNReal {f : ℝ≥0 → ℝ≥0} {s : Set ℝ} {t : Set ℝ≥0} + (hf : ContinuousOn f t) (h : Set.MapsTo Real.toNNReal s t) : + ContinuousOn (fun x ↦ f x.toNNReal : ℝ → ℝ) s := + continuous_subtype_val.comp_continuousOn <| hf.comp continuous_real_toNNReal.continuousOn h + /-- Embedding of `ℝ≥0` to `ℝ` as a bundled continuous map. -/ @[simps (config := .asFn)] def _root_.ContinuousMap.coeNNRealReal : C(ℝ≥0, ℝ) := @@ -257,7 +262,7 @@ section Monotone /-- A monotone, bounded above sequence `f : ℕ → ℝ` has a finite limit. -/ theorem _root_.Real.tendsto_of_bddAbove_monotone {f : ℕ → ℝ} (h_bdd : BddAbove (Set.range f)) (h_mon : Monotone f) : ∃ r : ℝ, Tendsto f atTop (𝓝 r) := by - obtain ⟨B, hB⟩ := Real.exists_isLUB (Set.range_nonempty f) h_bdd + obtain ⟨B, hB⟩ := Real.exists_isLUB (Set.range_nonempty f) h_bdd exact ⟨B, tendsto_atTop_isLUB h_mon hB⟩ /-- An antitone, bounded below sequence `f : ℕ → ℝ` has a finite limit. -/ diff --git a/Mathlib/Topology/LocallyConstant/Algebra.lean b/Mathlib/Topology/LocallyConstant/Algebra.lean index 1e70ce1a80c57..986f83f29a8ac 100644 --- a/Mathlib/Topology/LocallyConstant/Algebra.lean +++ b/Mathlib/Topology/LocallyConstant/Algebra.lean @@ -186,7 +186,7 @@ instance [NonAssocSemiring Y] : NonAssocSemiring (LocallyConstant X Y) := Function.Injective.nonAssocSemiring DFunLike.coe DFunLike.coe_injective' rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl -/-- The constant-function embedding, as a ring hom. -/ +/-- The constant-function embedding, as a ring hom. -/ @[simps] def constRingHom [NonAssocSemiring Y] : Y →+* LocallyConstant X Y := { constMonoidHom, constAddMonoidHom with toFun := const X } @@ -347,7 +347,7 @@ lemma ker_comapₗ [Semiring R] [AddCommMonoid Z] [Module R Z] (f : C(X, Y)) LinearMap.ker (comapₗ R f : LocallyConstant Y Z →ₗ[R] LocallyConstant X Z) = ⊥ := LinearMap.ker_eq_bot_of_injective <| comap_injective _ hfs -/-- `LocallyConstant.congrLeft` as a linear equivalence. -/ +/-- `LocallyConstant.congrLeft` as a linear equivalence. -/ @[simps!] def congrLeftₗ (R : Type*) [Semiring R] [AddCommMonoid Z] [Module R Z] (e : X ≃ₜ Y) : LocallyConstant X Z ≃ₗ[R] LocallyConstant Y Z where @@ -362,7 +362,7 @@ def congrLeftRingEquiv [Semiring Z] (e : X ≃ₜ Y) : __ := comapMonoidHom ⟨_, e.symm.continuous⟩ __ := comapAddMonoidHom ⟨_, e.symm.continuous⟩ -/-- `LocallyConstant.congrLeft` as an `AlgEquiv`. -/ +/-- `LocallyConstant.congrLeft` as an `AlgEquiv`. -/ @[simps!] def congrLeftₐ (R : Type*) [CommSemiring R] [Semiring Z] [Algebra R Z] (e : X ≃ₜ Y) : LocallyConstant X Z ≃ₐ[R] LocallyConstant Y Z where @@ -406,7 +406,7 @@ def mapₐ (R : Type*) [CommSemiring R] [Semiring Y] [Algebra R Y] [Semiring Z] toRingHom := mapRingHom f commutes' _ := by aesop -/-- `LocallyConstant.congrRight` as a linear equivalence. -/ +/-- `LocallyConstant.congrRight` as a linear equivalence. -/ @[simps!] def congrRightₗ (R : Type*) [Semiring R] [AddCommMonoid Y] [Module R Y] [AddCommMonoid Z] [Module R Z] (e : Y ≃ₗ[R] Z) : @@ -422,7 +422,7 @@ def congrRightRingEquiv [Semiring Y] [Semiring Z] (e : Y ≃+* Z) : __ := mapMonoidHom e.toMonoidHom __ := mapAddMonoidHom e.toAddMonoidHom -/-- `LocallyConstant.congrRight` as an `AlgEquiv`. -/ +/-- `LocallyConstant.congrRight` as an `AlgEquiv`. -/ @[simps!] def congrRightₐ (R : Type*) [CommSemiring R] [Semiring Y] [Algebra R Y] [Semiring Z] [Algebra R Z] (e : Y ≃ₐ[R] Z) : LocallyConstant X Y ≃ₐ[R] LocallyConstant X Z where diff --git a/Mathlib/Topology/LocallyConstant/Basic.lean b/Mathlib/Topology/LocallyConstant/Basic.lean index 48f981df57cff..bc918bf4803b5 100644 --- a/Mathlib/Topology/LocallyConstant/Basic.lean +++ b/Mathlib/Topology/LocallyConstant/Basic.lean @@ -465,7 +465,7 @@ end Indicator section Equiv /-- -The equivalence between `LocallyConstant X Z` and `LocallyConstant Y Z` given a +The equivalence between `LocallyConstant X Z` and `LocallyConstant Y Z` given a homeomorphism `X ≃ₜ Y` -/ @[simps] @@ -480,7 +480,7 @@ def congrLeft [TopologicalSpace Y] (e : X ≃ₜ Y) : LocallyConstant X Z ≃ Lo simp [comap_comap] /-- -The equivalence between `LocallyConstant X Y` and `LocallyConstant X Z` given an +The equivalence between `LocallyConstant X Y` and `LocallyConstant X Z` given an equivalence `Y ≃ Z` -/ @[simps] @@ -556,7 +556,7 @@ lemma piecewise_apply_right {C₁ C₂ : Set X} (h₁ : IsClosed C₁) (h₂ : I · exact hfg x ⟨h, hx⟩ · rfl -/-- A variant of `LocallyConstant.piecewise` where the two closed sets cover a subset. +/-- A variant of `LocallyConstant.piecewise` where the two closed sets cover a subset. TODO: Generalise this construction to `ContinuousMap`. -/ def piecewise' {C₀ C₁ C₂ : Set X} (h₀ : C₀ ⊆ C₁ ∪ C₂) (h₁ : IsClosed C₁) diff --git a/Mathlib/Topology/MetricSpace/Cauchy.lean b/Mathlib/Topology/MetricSpace/Cauchy.lean index 7a51a0300765e..cec514c737140 100644 --- a/Mathlib/Topology/MetricSpace/Cauchy.lean +++ b/Mathlib/Topology/MetricSpace/Cauchy.lean @@ -88,7 +88,7 @@ theorem Metric.uniformCauchySeqOn_iff {γ : Type*} {F : β → γ → α} {s : S exact hab (hN b.fst hbl.ge b.snd hbr.ge x hx) /-- If the distance between `s n` and `s m`, `n ≤ m` is bounded above by `b n` -and `b` converges to zero, then `s` is a Cauchy sequence. -/ +and `b` converges to zero, then `s` is a Cauchy sequence. -/ theorem cauchySeq_of_le_tendsto_0' {s : β → α} (b : β → ℝ) (h : ∀ n m : β, n ≤ m → dist (s n) (s m) ≤ b n) (h₀ : Tendsto b atTop (𝓝 0)) : CauchySeq s := Metric.cauchySeq_iff'.2 fun ε ε0 => (h₀.eventually (gt_mem_nhds ε0)).exists.imp fun N hN n hn => @@ -97,7 +97,7 @@ theorem cauchySeq_of_le_tendsto_0' {s : β → α} (b : β → ℝ) _ < ε := hN /-- If the distance between `s n` and `s m`, `n, m ≥ N` is bounded above by `b N` -and `b` converges to zero, then `s` is a Cauchy sequence. -/ +and `b` converges to zero, then `s` is a Cauchy sequence. -/ theorem cauchySeq_of_le_tendsto_0 {s : β → α} (b : β → ℝ) (h : ∀ n m N : β, N ≤ n → N ≤ m → dist (s n) (s m) ≤ b N) (h₀ : Tendsto b atTop (𝓝 0)) : CauchySeq s := diff --git a/Mathlib/Topology/MetricSpace/Defs.lean b/Mathlib/Topology/MetricSpace/Defs.lean index 600bc7f10f03d..3ce13e989e61a 100644 --- a/Mathlib/Topology/MetricSpace/Defs.lean +++ b/Mathlib/Topology/MetricSpace/Defs.lean @@ -80,11 +80,11 @@ theorem dist_pos {x y : γ} : 0 < dist x y ↔ x ≠ y := by theorem eq_of_forall_dist_le {x y : γ} (h : ∀ ε > 0, dist x y ≤ ε) : x = y := eq_of_dist_eq_zero (eq_of_le_of_forall_le_of_dense dist_nonneg h) -/-- Deduce the equality of points from the vanishing of the nonnegative distance-/ +/-- Deduce the equality of points from the vanishing of the nonnegative distance -/ theorem eq_of_nndist_eq_zero {x y : γ} : nndist x y = 0 → x = y := by simp only [NNReal.eq_iff, ← dist_nndist, imp_self, NNReal.coe_zero, dist_eq_zero] -/-- Characterize the equality of points as the vanishing of the nonnegative distance-/ +/-- Characterize the equality of points as the vanishing of the nonnegative distance -/ @[simp] theorem nndist_eq_zero {x y : γ} : nndist x y = 0 ↔ x = y := by simp only [NNReal.eq_iff, ← dist_nndist, imp_self, NNReal.coe_zero, dist_eq_zero] diff --git a/Mathlib/Topology/MetricSpace/GromovHausdorff.lean b/Mathlib/Topology/MetricSpace/GromovHausdorff.lean index fbeb7156e42d0..263d76d921097 100644 --- a/Mathlib/Topology/MetricSpace/GromovHausdorff.lean +++ b/Mathlib/Topology/MetricSpace/GromovHausdorff.lean @@ -940,7 +940,7 @@ limit of the `Y n`, and finally let `Z` be the completion of `Z0`. The images `X2 n` of `X n` in `Z` are at Hausdorff distance `< 1/2^n` by construction, hence they form a Cauchy sequence for the Hausdorff distance. By completeness (of `Z`, and therefore of its set of nonempty compact subsets), they converge to a limit `L`. This is the nonempty -compact metric space we are looking for. -/ +compact metric space we are looking for. -/ variable (X : ℕ → Type) [∀ n, MetricSpace (X n)] [∀ n, CompactSpace (X n)] [∀ n, Nonempty (X n)] /-- Auxiliary structure used to glue metric spaces below, recording an isometric embedding diff --git a/Mathlib/Topology/MetricSpace/Isometry.lean b/Mathlib/Topology/MetricSpace/Isometry.lean index b2464d0e4b65a..fc48af3ac67e9 100644 --- a/Mathlib/Topology/MetricSpace/Isometry.lean +++ b/Mathlib/Topology/MetricSpace/Isometry.lean @@ -28,7 +28,7 @@ open Function Set open scoped Topology ENNReal /-- An isometry (also known as isometric embedding) is a map preserving the edistance -between pseudoemetric spaces, or equivalently the distance between pseudometric space. -/ +between pseudoemetric spaces, or equivalently the distance between pseudometric space. -/ def Isometry [PseudoEMetricSpace α] [PseudoEMetricSpace β] (f : α → β) : Prop := ∀ x1 x2 : α, edist (f x1) (f x2) = edist x1 x2 diff --git a/Mathlib/Topology/MetricSpace/Pseudo/Defs.lean b/Mathlib/Topology/MetricSpace/Pseudo/Defs.lean index 7a02659c96fe2..cfcb1f4eccec8 100644 --- a/Mathlib/Topology/MetricSpace/Pseudo/Defs.lean +++ b/Mathlib/Topology/MetricSpace/Pseudo/Defs.lean @@ -263,15 +263,15 @@ theorem edist_lt_coe {x y : α} {c : ℝ≥0} : edist x y < c ↔ nndist x y < c theorem edist_le_coe {x y : α} {c : ℝ≥0} : edist x y ≤ c ↔ nndist x y ≤ c := by rw [edist_nndist, ENNReal.coe_le_coe] -/-- In a pseudometric space, the extended distance is always finite-/ +/-- In a pseudometric space, the extended distance is always finite -/ theorem edist_lt_top {α : Type*} [PseudoMetricSpace α] (x y : α) : edist x y < ⊤ := (edist_dist x y).symm ▸ ENNReal.ofReal_lt_top -/-- In a pseudometric space, the extended distance is always finite-/ +/-- In a pseudometric space, the extended distance is always finite -/ theorem edist_ne_top (x y : α) : edist x y ≠ ⊤ := (edist_lt_top x y).ne -/-- `nndist x x` vanishes-/ +/-- `nndist x x` vanishes -/ @[simp] theorem nndist_self (a : α) : nndist a a = 0 := NNReal.coe_eq_zero.1 (dist_self a) -- Porting note: `dist_nndist` and `coe_nndist` moved up @@ -299,7 +299,7 @@ theorem nndist_dist (x y : α) : nndist x y = Real.toNNReal (dist x y) := by theorem nndist_comm (x y : α) : nndist x y = nndist y x := NNReal.eq <| dist_comm x y -/-- Triangle inequality for the nonnegative distance-/ +/-- Triangle inequality for the nonnegative distance -/ theorem nndist_triangle (x y z : α) : nndist x z ≤ nndist x y + nndist y z := dist_triangle _ _ _ @@ -1096,7 +1096,7 @@ variable {x y z : α} {ε ε₁ ε₂ : ℝ} {s : Set α} theorem ball_subset_interior_closedBall : ball x ε ⊆ interior (closedBall x ε) := interior_maximal ball_subset_closedBall isOpen_ball -/-- ε-characterization of the closure in pseudometric spaces-/ +/-- ε-characterization of the closure in pseudometric spaces -/ theorem mem_closure_iff {s : Set α} {a : α} : a ∈ closure s ↔ ∀ ε > 0, ∃ b ∈ s, dist a b < ε := (mem_closure_iff_nhds_basis nhds_basis_ball).trans <| by simp only [mem_ball, dist_comm] diff --git a/Mathlib/Topology/NhdsSet.lean b/Mathlib/Topology/NhdsSet.lean index 5580d18fa47ef..3a3f45b2eeff7 100644 --- a/Mathlib/Topology/NhdsSet.lean +++ b/Mathlib/Topology/NhdsSet.lean @@ -144,7 +144,7 @@ theorem nhdsSet_insert (x : X) (s : Set X) : 𝓝ˢ (insert x s) = 𝓝 x ⊔ rw [insert_eq, nhdsSet_union, nhdsSet_singleton] /-- Preimage of a set neighborhood of `t` under a continuous map `f` is a set neighborhood of `s` -provided that `f` maps `s` to `t`. -/ +provided that `f` maps `s` to `t`. -/ theorem Continuous.tendsto_nhdsSet {f : X → Y} {t : Set Y} (hf : Continuous f) (hst : MapsTo f s t) : Tendsto f (𝓝ˢ s) (𝓝ˢ t) := ((hasBasis_nhdsSet s).tendsto_iff (hasBasis_nhdsSet t)).mpr fun U hU => diff --git a/Mathlib/Topology/Order/Monotone.lean b/Mathlib/Topology/Order/Monotone.lean index e64473e08518c..0493d4d868c9c 100644 --- a/Mathlib/Topology/Order/Monotone.lean +++ b/Mathlib/Topology/Order/Monotone.lean @@ -28,66 +28,123 @@ variable [ConditionallyCompleteLinearOrder α] [TopologicalSpace α] [OrderTopol /-- A monotone function continuous at the supremum of a nonempty set sends this supremum to the supremum of the image of this set. -/ -theorem Monotone.map_sSup_of_continuousAt' {f : α → β} {A : Set α} (Cf : ContinuousAt f (sSup A)) - (Mf : Monotone f) (A_nonemp : A.Nonempty) (A_bdd : BddAbove A := by bddDefault) : +theorem MonotoneOn.map_csSup_of_continuousWithinAt {f : α → β} {A : Set α} + (Cf : ContinuousWithinAt f A (sSup A)) + (Mf : MonotoneOn f A) (A_nonemp : A.Nonempty) (A_bdd : BddAbove A := by bddDefault) : f (sSup A) = sSup (f '' A) := --This is a particular case of the more general `IsLUB.isLUB_of_tendsto` - .symm <| ((isLUB_csSup A_nonemp A_bdd).isLUB_of_tendsto (Mf.monotoneOn _) A_nonemp <| - Cf.mono_left inf_le_left).csSup_eq (A_nonemp.image f) + .symm <| ((isLUB_csSup A_nonemp A_bdd).isLUB_of_tendsto Mf A_nonemp <| + Cf.mono_left fun ⦃_⦄ a ↦ a).csSup_eq (A_nonemp.image f) + +/-- A monotone function continuous at the supremum of a nonempty set sends this supremum to +the supremum of the image of this set. -/ +theorem Monotone.map_csSup_of_continuousAt {f : α → β} {A : Set α} + (Cf : ContinuousAt f (sSup A)) (Mf : Monotone f) (A_nonemp : A.Nonempty) + (A_bdd : BddAbove A := by bddDefault) : f (sSup A) = sSup (f '' A) := + MonotoneOn.map_csSup_of_continuousWithinAt Cf.continuousWithinAt + (Mf.monotoneOn _) A_nonemp A_bdd + +@[deprecated (since := "2024-08-26")] alias Monotone.map_sSup_of_continuousAt' := + Monotone.map_csSup_of_continuousAt /-- A monotone function continuous at the indexed supremum over a nonempty `Sort` sends this indexed supremum to the indexed supremum of the composition. -/ -theorem Monotone.map_iSup_of_continuousAt' {ι : Sort*} [Nonempty ι] {f : α → β} {g : ι → α} +theorem Monotone.map_ciSup_of_continuousAt {ι : Sort*} [Nonempty ι] {f : α → β} {g : ι → α} (Cf : ContinuousAt f (iSup g)) (Mf : Monotone f) (bdd : BddAbove (range g) := by bddDefault) : f (⨆ i, g i) = ⨆ i, f (g i) := by - rw [iSup, Monotone.map_sSup_of_continuousAt' Cf Mf (range_nonempty g) bdd, ← range_comp, iSup] + rw [iSup, Monotone.map_csSup_of_continuousAt Cf Mf (range_nonempty g) bdd, ← range_comp, iSup] rfl +@[deprecated (since := "2024-08-26")] alias Monotone.map_iSup_of_continuousAt' := + Monotone.map_ciSup_of_continuousAt + /-- A monotone function continuous at the infimum of a nonempty set sends this infimum to the infimum of the image of this set. -/ -theorem Monotone.map_sInf_of_continuousAt' {f : α → β} {A : Set α} (Cf : ContinuousAt f (sInf A)) +theorem MonotoneOn.map_csInf_of_continuousWithinAt {f : α → β} {A : Set α} + (Cf : ContinuousWithinAt f A (sInf A)) + (Mf : MonotoneOn f A) (A_nonemp : A.Nonempty) (A_bdd : BddBelow A := by bddDefault) : + f (sInf A) = sInf (f '' A) := + MonotoneOn.map_csSup_of_continuousWithinAt (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual A_nonemp A_bdd + +/-- A monotone function continuous at the infimum of a nonempty set sends this infimum to +the infimum of the image of this set. -/ +theorem Monotone.map_csInf_of_continuousAt {f : α → β} {A : Set α} (Cf : ContinuousAt f (sInf A)) (Mf : Monotone f) (A_nonemp : A.Nonempty) (A_bdd : BddBelow A := by bddDefault) : f (sInf A) = sInf (f '' A) := - Monotone.map_sSup_of_continuousAt' (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual A_nonemp A_bdd + Monotone.map_csSup_of_continuousAt (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual A_nonemp A_bdd + +@[deprecated (since := "2024-08-26")] alias Monotone.map_sInf_of_continuousAt' := + Monotone.map_csInf_of_continuousAt /-- A monotone function continuous at the indexed infimum over a nonempty `Sort` sends this indexed infimum to the indexed infimum of the composition. -/ -theorem Monotone.map_iInf_of_continuousAt' {ι : Sort*} [Nonempty ι] {f : α → β} {g : ι → α} +theorem Monotone.map_ciInf_of_continuousAt {ι : Sort*} [Nonempty ι] {f : α → β} {g : ι → α} (Cf : ContinuousAt f (iInf g)) (Mf : Monotone f) (bdd : BddBelow (range g) := by bddDefault) : f (⨅ i, g i) = ⨅ i, f (g i) := by - rw [iInf, Monotone.map_sInf_of_continuousAt' Cf Mf (range_nonempty g) bdd, ← range_comp, iInf] + rw [iInf, Monotone.map_csInf_of_continuousAt Cf Mf (range_nonempty g) bdd, ← range_comp, iInf] rfl +@[deprecated (since := "2024-08-26")] alias Monotone.map_iInf_of_continuousAt' := + Monotone.map_ciInf_of_continuousAt + +/-- An antitone function continuous at the infimum of a nonempty set sends this infimum to +the supremum of the image of this set. -/ +theorem AntitoneOn.map_csInf_of_continuousWithinAt {f : α → β} {A : Set α} + (Cf : ContinuousWithinAt f A (sInf A)) + (Af : AntitoneOn f A) (A_nonemp : A.Nonempty) (A_bdd : BddBelow A := by bddDefault) : + f (sInf A) = sSup (f '' A) := + MonotoneOn.map_csInf_of_continuousWithinAt (β := βᵒᵈ) Cf Af.dual_right A_nonemp A_bdd + /-- An antitone function continuous at the infimum of a nonempty set sends this infimum to the supremum of the image of this set. -/ -theorem Antitone.map_sInf_of_continuousAt' {f : α → β} {A : Set α} (Cf : ContinuousAt f (sInf A)) +theorem Antitone.map_csInf_of_continuousAt {f : α → β} {A : Set α} (Cf : ContinuousAt f (sInf A)) (Af : Antitone f) (A_nonemp : A.Nonempty) (A_bdd : BddBelow A := by bddDefault) : f (sInf A) = sSup (f '' A) := - Monotone.map_sInf_of_continuousAt' (β := βᵒᵈ) Cf Af.dual_right A_nonemp A_bdd + Monotone.map_csInf_of_continuousAt (β := βᵒᵈ) Cf Af.dual_right A_nonemp A_bdd + +@[deprecated (since := "2024-08-26")] alias Antitone.map_sInf_of_continuousAt' := + Antitone.map_csInf_of_continuousAt /-- An antitone function continuous at the indexed infimum over a nonempty `Sort` sends this indexed infimum to the indexed supremum of the composition. -/ -theorem Antitone.map_iInf_of_continuousAt' {ι : Sort*} [Nonempty ι] {f : α → β} {g : ι → α} +theorem Antitone.map_ciInf_of_continuousAt {ι : Sort*} [Nonempty ι] {f : α → β} {g : ι → α} (Cf : ContinuousAt f (iInf g)) (Af : Antitone f) (bdd : BddBelow (range g) := by bddDefault) : f (⨅ i, g i) = ⨆ i, f (g i) := by - rw [iInf, Antitone.map_sInf_of_continuousAt' Cf Af (range_nonempty g) bdd, ← range_comp, iSup] + rw [iInf, Antitone.map_csInf_of_continuousAt Cf Af (range_nonempty g) bdd, ← range_comp, iSup] rfl +@[deprecated (since := "2024-08-26")] alias Antitone.map_iInf_of_continuousAt' := + Antitone.map_ciInf_of_continuousAt + +/-- An antitone function continuous at the supremum of a nonempty set sends this supremum to +the infimum of the image of this set. -/ +theorem AntitoneOn.map_csSup_of_continuousWithinAt {f : α → β} {A : Set α} + (Cf : ContinuousWithinAt f A (sSup A)) + (Af : AntitoneOn f A) (A_nonemp : A.Nonempty) (A_bdd : BddAbove A := by bddDefault) : + f (sSup A) = sInf (f '' A) := + MonotoneOn.map_csSup_of_continuousWithinAt (β := βᵒᵈ) Cf Af.dual_right A_nonemp A_bdd + /-- An antitone function continuous at the supremum of a nonempty set sends this supremum to the infimum of the image of this set. -/ -theorem Antitone.map_sSup_of_continuousAt' {f : α → β} {A : Set α} (Cf : ContinuousAt f (sSup A)) +theorem Antitone.map_csSup_of_continuousAt {f : α → β} {A : Set α} (Cf : ContinuousAt f (sSup A)) (Af : Antitone f) (A_nonemp : A.Nonempty) (A_bdd : BddAbove A := by bddDefault) : f (sSup A) = sInf (f '' A) := - Monotone.map_sSup_of_continuousAt' (β := βᵒᵈ) Cf Af.dual_right A_nonemp A_bdd + Monotone.map_csSup_of_continuousAt (β := βᵒᵈ) Cf Af.dual_right A_nonemp A_bdd + +@[deprecated (since := "2024-08-26")] alias Antitone.map_sSup_of_continuousAt' := + Antitone.map_csSup_of_continuousAt /-- An antitone function continuous at the indexed supremum over a nonempty `Sort` sends this indexed supremum to the indexed infimum of the composition. -/ -theorem Antitone.map_iSup_of_continuousAt' {ι : Sort*} [Nonempty ι] {f : α → β} {g : ι → α} +theorem Antitone.map_ciSup_of_continuousAt {ι : Sort*} [Nonempty ι] {f : α → β} {g : ι → α} (Cf : ContinuousAt f (iSup g)) (Af : Antitone f) (bdd : BddAbove (range g) := by bddDefault) : f (⨆ i, g i) = ⨅ i, f (g i) := by - rw [iSup, Antitone.map_sSup_of_continuousAt' Cf Af (range_nonempty g) bdd, ← range_comp, iInf] + rw [iSup, Antitone.map_csSup_of_continuousAt Cf Af (range_nonempty g) bdd, ← range_comp, iInf] rfl +@[deprecated (since := "2024-08-26")] alias Antitone.map_iSup_of_continuousAt' := + Antitone.map_ciSup_of_continuousAt + end ConditionallyCompleteLinearOrder section CompleteLinearOrder @@ -109,11 +166,18 @@ theorem IsClosed.sInf_mem {s : Set α} (hs : s.Nonempty) (hc : IsClosed s) : sIn /-- A monotone function `f` sending `bot` to `bot` and continuous at the supremum of a set sends this supremum to the supremum of the image of this set. -/ -theorem Monotone.map_sSup_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (sSup s)) - (Mf : Monotone f) (fbot : f ⊥ = ⊥) : f (sSup s) = sSup (f '' s) := by +theorem MonotoneOn.map_sSup_of_continuousWithinAt {f : α → β} {s : Set α} + (Cf : ContinuousWithinAt f s (sSup s)) + (Mf : MonotoneOn f s) (fbot : f ⊥ = ⊥) : f (sSup s) = sSup (f '' s) := by rcases s.eq_empty_or_nonempty with h | h · simp [h, fbot] - · exact Mf.map_sSup_of_continuousAt' Cf h + · exact Mf.map_csSup_of_continuousWithinAt Cf h + +/-- A monotone function `f` sending `bot` to `bot` and continuous at the supremum of a set sends +this supremum to the supremum of the image of this set. -/ +theorem Monotone.map_sSup_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (sSup s)) + (Mf : Monotone f) (fbot : f ⊥ = ⊥) : f (sSup s) = sSup (f '' s) := + MonotoneOn.map_sSup_of_continuousWithinAt Cf.continuousWithinAt (Mf.monotoneOn _) fbot /-- If a monotone function sending `bot` to `bot` is continuous at the indexed supremum over a `Sort`, then it sends this indexed supremum to the indexed supremum of the composition. -/ @@ -122,6 +186,13 @@ theorem Monotone.map_iSup_of_continuousAt {ι : Sort*} {f : α → β} {g : ι f (⨆ i, g i) = ⨆ i, f (g i) := by rw [iSup, Mf.map_sSup_of_continuousAt Cf fbot, ← range_comp, iSup]; rfl +/-- A monotone function `f` sending `top` to `top` and continuous at the infimum of a set sends +this infimum to the infimum of the image of this set. -/ +theorem MonotoneOn.map_sInf_of_continuousWithinAt {f : α → β} {s : Set α} + (Cf : ContinuousWithinAt f s (sInf s)) (Mf : MonotoneOn f s) (ftop : f ⊤ = ⊤) : + f (sInf s) = sInf (f '' s) := + MonotoneOn.map_sSup_of_continuousWithinAt (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual ftop + /-- A monotone function `f` sending `top` to `top` and continuous at the infimum of a set sends this infimum to the infimum of the image of this set. -/ theorem Monotone.map_sInf_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (sInf s)) @@ -134,6 +205,14 @@ theorem Monotone.map_iInf_of_continuousAt {ι : Sort*} {f : α → β} {g : ι (Cf : ContinuousAt f (iInf g)) (Mf : Monotone f) (ftop : f ⊤ = ⊤) : f (iInf g) = iInf (f ∘ g) := Monotone.map_iSup_of_continuousAt (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual ftop +/-- An antitone function `f` sending `bot` to `top` and continuous at the supremum of a set sends +this supremum to the infimum of the image of this set. -/ +theorem AntitoneOn.map_sSup_of_continuousWithinAt {f : α → β} {s : Set α} + (Cf : ContinuousWithinAt f s (sSup s)) (Af : AntitoneOn f s) (fbot : f ⊥ = ⊤) : + f (sSup s) = sInf (f '' s) := + MonotoneOn.map_sSup_of_continuousWithinAt + (show ContinuousWithinAt (OrderDual.toDual ∘ f) s (sSup s) from Cf) Af fbot + /-- An antitone function `f` sending `bot` to `top` and continuous at the supremum of a set sends this supremum to the infimum of the image of this set. -/ theorem Antitone.map_sSup_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (sSup s)) @@ -149,6 +228,14 @@ theorem Antitone.map_iSup_of_continuousAt {ι : Sort*} {f : α → β} {g : ι Monotone.map_iSup_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (iSup g) from Cf) Af fbot +/-- An antitone function `f` sending `top` to `bot` and continuous at the infimum of a set sends +this infimum to the supremum of the image of this set. -/ +theorem AntitoneOn.map_sInf_of_continuousWithinAt {f : α → β} {s : Set α} + (Cf : ContinuousWithinAt f s (sInf s)) (Af : AntitoneOn f s) (ftop : f ⊤ = ⊥) : + f (sInf s) = sSup (f '' s) := + MonotoneOn.map_sInf_of_continuousWithinAt + (show ContinuousWithinAt (OrderDual.toDual ∘ f) s (sInf s) from Cf) Af ftop + /-- An antitone function `f` sending `top` to `bot` and continuous at the infimum of a set sends this infimum to the supremum of the image of this set. -/ theorem Antitone.map_sInf_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (sInf s)) @@ -192,60 +279,6 @@ theorem IsClosed.isGreatest_csSup {s : Set α} (hc : IsClosed s) (hs : s.Nonempt IsGreatest s (sSup s) := IsClosed.isLeast_csInf (α := αᵒᵈ) hc hs B -/-- If a monotone function is continuous at the supremum of a nonempty bounded above set `s`, -then it sends this supremum to the supremum of the image of `s`. -/ -theorem Monotone.map_csSup_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (sSup s)) - (Mf : Monotone f) (ne : s.Nonempty) (H : BddAbove s) : f (sSup s) = sSup (f '' s) := by - refine ((isLUB_csSup (ne.image f) (Mf.map_bddAbove H)).unique ?_).symm - refine (isLUB_csSup ne H).isLUB_of_tendsto (fun x _ y _ xy => Mf xy) ne ?_ - exact Cf.mono_left inf_le_left - -/-- If a monotone function is continuous at the indexed supremum of a bounded function on -a nonempty `Sort`, then it sends this supremum to the supremum of the composition. -/ -theorem Monotone.map_ciSup_of_continuousAt {f : α → β} {g : γ → α} (Cf : ContinuousAt f (⨆ i, g i)) - (Mf : Monotone f) (H : BddAbove (range g)) : f (⨆ i, g i) = ⨆ i, f (g i) := by - rw [iSup, Mf.map_csSup_of_continuousAt Cf (range_nonempty _) H, ← range_comp, iSup]; rfl - -/-- If a monotone function is continuous at the infimum of a nonempty bounded below set `s`, -then it sends this infimum to the infimum of the image of `s`. -/ -theorem Monotone.map_csInf_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (sInf s)) - (Mf : Monotone f) (ne : s.Nonempty) (H : BddBelow s) : f (sInf s) = sInf (f '' s) := - Monotone.map_csSup_of_continuousAt (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual ne H - -/-- A continuous monotone function sends indexed infimum to indexed infimum in conditionally -complete linear order, under a boundedness assumption. -/ -theorem Monotone.map_ciInf_of_continuousAt {f : α → β} {g : γ → α} (Cf : ContinuousAt f (⨅ i, g i)) - (Mf : Monotone f) (H : BddBelow (range g)) : f (⨅ i, g i) = ⨅ i, f (g i) := - Monotone.map_ciSup_of_continuousAt (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual H - -/-- If an antitone function is continuous at the supremum of a nonempty bounded above set `s`, -then it sends this supremum to the infimum of the image of `s`. -/ -theorem Antitone.map_csSup_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (sSup s)) - (Af : Antitone f) (ne : s.Nonempty) (H : BddAbove s) : f (sSup s) = sInf (f '' s) := - Monotone.map_csSup_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (sSup s) from Cf) Af - ne H - -/-- If an antitone function is continuous at the indexed supremum of a bounded function on -a nonempty `Sort`, then it sends this supremum to the infimum of the composition. -/ -theorem Antitone.map_ciSup_of_continuousAt {f : α → β} {g : γ → α} (Cf : ContinuousAt f (⨆ i, g i)) - (Af : Antitone f) (H : BddAbove (range g)) : f (⨆ i, g i) = ⨅ i, f (g i) := - Monotone.map_ciSup_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (⨆ i, g i) from Cf) - Af H - -/-- If an antitone function is continuous at the infimum of a nonempty bounded below set `s`, -then it sends this infimum to the supremum of the image of `s`. -/ -theorem Antitone.map_csInf_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (sInf s)) - (Af : Antitone f) (ne : s.Nonempty) (H : BddBelow s) : f (sInf s) = sSup (f '' s) := - Monotone.map_csInf_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (sInf s) from Cf) Af - ne H - -/-- A continuous antitone function sends indexed infimum to indexed supremum in conditionally -complete linear order, under a boundedness assumption. -/ -theorem Antitone.map_ciInf_of_continuousAt {f : α → β} {g : γ → α} (Cf : ContinuousAt f (⨅ i, g i)) - (Af : Antitone f) (H : BddBelow (range g)) : f (⨅ i, g i) = ⨆ i, f (g i) := - Monotone.map_ciInf_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (⨅ i, g i) from Cf) - Af H - lemma MonotoneOn.tendsto_nhdsWithin_Ioo_left {α β : Type*} [LinearOrder α] [TopologicalSpace α] [OrderTopology α] [ConditionallyCompleteLinearOrder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} {x y : α} (h_nonempty : (Ioo y x).Nonempty) (Mf : MonotoneOn f (Ioo y x)) diff --git a/Mathlib/Topology/Order/UpperLowerSetTopology.lean b/Mathlib/Topology/Order/UpperLowerSetTopology.lean index ff3fc1e7a3de2..5aa350f222cbb 100644 --- a/Mathlib/Topology/Order/UpperLowerSetTopology.lean +++ b/Mathlib/Topology/Order/UpperLowerSetTopology.lean @@ -74,10 +74,10 @@ def WithUpperSet (α : Type*) := α namespace WithUpperSet -/-- `toUpperSet` is the identity function to the `WithUpperSet` of a type. -/ +/-- `toUpperSet` is the identity function to the `WithUpperSet` of a type. -/ @[match_pattern] def toUpperSet : α ≃ WithUpperSet α := Equiv.refl _ -/-- `ofUpperSet` is the identity function from the `WithUpperSet` of a type. -/ +/-- `ofUpperSet` is the identity function from the `WithUpperSet` of a type. -/ @[match_pattern] def ofUpperSet : WithUpperSet α ≃ α := Equiv.refl _ @[simp] lemma to_WithUpperSet_symm_eq : (@toUpperSet α).symm = ofUpperSet := rfl @@ -120,10 +120,10 @@ def WithLowerSet (α : Type*) := α namespace WithLowerSet -/-- `toLowerSet` is the identity function to the `WithLowerSet` of a type. -/ +/-- `toLowerSet` is the identity function to the `WithLowerSet` of a type. -/ @[match_pattern] def toLowerSet : α ≃ WithLowerSet α := Equiv.refl _ -/-- `ofLowerSet` is the identity function from the `WithLowerSet` of a type. -/ +/-- `ofLowerSet` is the identity function from the `WithLowerSet` of a type. -/ @[match_pattern] def ofLowerSet : WithLowerSet α ≃ α := Equiv.refl _ @[simp] lemma to_WithLowerSet_symm_eq : (@toLowerSet α).symm = ofLowerSet := rfl diff --git a/Mathlib/Topology/PartialHomeomorph.lean b/Mathlib/Topology/PartialHomeomorph.lean index 3c930a28e8556..75016e12aaea7 100644 --- a/Mathlib/Topology/PartialHomeomorph.lean +++ b/Mathlib/Topology/PartialHomeomorph.lean @@ -361,7 +361,7 @@ theorem eventually_nhdsWithin' {x : X} (p : X → Prop) {s : Set X} /-- This lemma is useful in the manifold library in the case that `e` is a chart. It states that locally around `e x` the set `e.symm ⁻¹' s` is the same as the set intersected with the target - of `e` and some other neighborhood of `f x` (which will be the source of a chart on `Z`). -/ + of `e` and some other neighborhood of `f x` (which will be the source of a chart on `Z`). -/ theorem preimage_eventuallyEq_target_inter_preimage_inter {e : PartialHomeomorph X Y} {s : Set X} {t : Set Z} {x : X} {f : X → Z} (hf : ContinuousWithinAt f s x) (hxe : x ∈ e.source) (ht : t ∈ 𝓝 (f x)) : @@ -1002,7 +1002,7 @@ theorem continuousOn_iff_continuousOn_comp_right {f : Y → Z} {s : Set Y} (h : /-- Continuity within a set at a point can be read under left composition with a local homeomorphism if a neighborhood of the initial point is sent to the source of the local -homeomorphism-/ +homeomorphism -/ theorem continuousWithinAt_iff_continuousWithinAt_comp_left {f : Z → X} {s : Set Z} {x : Z} (hx : f x ∈ e.source) (h : f ⁻¹' e.source ∈ 𝓝[s] x) : ContinuousWithinAt f s x ↔ ContinuousWithinAt (e ∘ f) s x := by @@ -1015,7 +1015,7 @@ theorem continuousWithinAt_iff_continuousWithinAt_comp_left {f : Z → X} {s : S exact this.congr (fun y hy => by simp [e.left_inv hy.2]) (by simp [e.left_inv hx]) /-- Continuity at a point can be read under left composition with a partial homeomorphism if a -neighborhood of the initial point is sent to the source of the partial homeomorphism-/ +neighborhood of the initial point is sent to the source of the partial homeomorphism -/ theorem continuousAt_iff_continuousAt_comp_left {f : Z → X} {x : Z} (h : f ⁻¹' e.source ∈ 𝓝 x) : ContinuousAt f x ↔ ContinuousAt (e ∘ f) x := by have hx : f x ∈ e.source := (mem_of_mem_nhds h : _) diff --git a/Mathlib/Topology/Separation.lean b/Mathlib/Topology/Separation.lean index 1cc16c0294650..b86c559b092ef 100644 --- a/Mathlib/Topology/Separation.lean +++ b/Mathlib/Topology/Separation.lean @@ -259,7 +259,7 @@ end SeparatedNhds /-- A T₀ space, also known as a Kolmogorov space, is a topological space such that for every pair `x ≠ y`, there is an open set containing one but not the other. We formulate the definition in terms -of the `Inseparable` relation. -/ +of the `Inseparable` relation. -/ class T0Space (X : Type u) [TopologicalSpace X] : Prop where /-- Two inseparable points in a T₀ space are equal. -/ t0 : ∀ ⦃x y : X⦄, Inseparable x y → x = y @@ -974,13 +974,13 @@ theorem Filter.HasBasis.exists_inter_eq_singleton_of_mem_discrete {ι : Type*} { exact ⟨i, hi, hix.antisymm <| singleton_subset_iff.2 ⟨mem_of_mem_nhds <| hb.mem_of_mem hi, hx⟩⟩ /-- A point `x` in a discrete subset `s` of a topological space admits a neighbourhood -that only meets `s` at `x`. -/ +that only meets `s` at `x`. -/ theorem nhds_inter_eq_singleton_of_mem_discrete {s : Set X} [DiscreteTopology s] {x : X} (hx : x ∈ s) : ∃ U ∈ 𝓝 x, U ∩ s = {x} := by simpa using (𝓝 x).basis_sets.exists_inter_eq_singleton_of_mem_discrete hx /-- Let `x` be a point in a discrete subset `s` of a topological space, then there exists an open -set that only meets `s` at `x`. -/ +set that only meets `s` at `x`. -/ theorem isOpen_inter_eq_singleton_of_mem_discrete {s : Set X} [DiscreteTopology s] {x : X} (hx : x ∈ s) : ∃ U : Set X, IsOpen U ∧ U ∩ s = {x} := by obtain ⟨U, hU_nhds, hU_inter⟩ := nhds_inter_eq_singleton_of_mem_discrete hx @@ -1103,7 +1103,7 @@ theorem exists_isCompact_superset_iff {s : Set X} : alias exists_compact_superset_iff := exists_isCompact_superset_iff /-- If `K` and `L` are disjoint compact sets in an R₁ topological space -and `L` is also closed, then `K` and `L` have disjoint neighborhoods. -/ +and `L` is also closed, then `K` and `L` have disjoint neighborhoods. -/ theorem SeparatedNhds.of_isCompact_isCompact_isClosed {K L : Set X} (hK : IsCompact K) (hL : IsCompact L) (h'L : IsClosed L) (hd : Disjoint K L) : SeparatedNhds K L := by simp_rw [separatedNhds_iff_disjoint, hK.disjoint_nhdsSet_left, hL.disjoint_nhdsSet_right, @@ -1880,7 +1880,7 @@ of filters `𝓝ˢ s` and `𝓝 a`. -/ @[mk_iff] class RegularSpace (X : Type u) [TopologicalSpace X] : Prop where /-- If `a` is a point that does not belong to a closed set `s`, then `a` and `s` admit disjoint - neighborhoods. -/ + neighborhoods. -/ regular : ∀ {s : Set X} {a}, IsClosed s → a ∉ s → Disjoint (𝓝ˢ s) (𝓝 a) theorem regularSpace_TFAE (X : Type u) [TopologicalSpace X] : @@ -2168,7 +2168,7 @@ end T25 section T3 /-- A T₃ space is a T₀ space which is a regular space. Any T₃ space is a T₁ space, a T₂ space, and -a T₂.₅ space. -/ +a T₂.₅ space. -/ class T3Space (X : Type u) [TopologicalSpace X] extends T0Space X, RegularSpace X : Prop instance (priority := 90) instT3Space [T0Space X] [RegularSpace X] : T3Space X := ⟨⟩ @@ -2565,7 +2565,7 @@ theorem isTopologicalBasis_isClopen : IsTopologicalBasis { s : Set X | IsClopen tauto /-- Every member of an open set in a compact Hausdorff totally disconnected space - is contained in a clopen set contained in the open set. -/ + is contained in a clopen set contained in the open set. -/ theorem compact_exists_isClopen_in_isOpen {x : X} {U : Set X} (is_open : IsOpen U) (memU : x ∈ U) : ∃ V : Set X, IsClopen V ∧ x ∈ V ∧ V ⊆ U := isTopologicalBasis_isClopen.mem_nhds_iff.1 (is_open.mem_nhds memU) @@ -2640,3 +2640,5 @@ instance ConnectedComponents.t2 [T2Space X] [CompactSpace X] : T2Space (Connecte rw [ConnectedComponents.quotientMap_coe.isClopen_preimage] at hU refine ⟨Vᶜ, V, hU.compl.isOpen, hU.isOpen, ?_, hb mem_connectedComponent, disjoint_compl_left⟩ exact fun h => flip Set.Nonempty.ne_empty ha ⟨a, mem_connectedComponent, h⟩ + +set_option linter.style.longFile 2800 diff --git a/Mathlib/Topology/Sheaves/Presheaf.lean b/Mathlib/Topology/Sheaves/Presheaf.lean index 77a9b775aec7d..1045f3e96ce28 100644 --- a/Mathlib/Topology/Sheaves/Presheaf.lean +++ b/Mathlib/Topology/Sheaves/Presheaf.lean @@ -154,7 +154,7 @@ def pushforward {X Y : TopCat.{w}} (f : X ⟶ Y) : X.Presheaf C ⥤ Y.Presheaf C (whiskeringLeft _ _ _).obj (Opens.map f).op set_option quotPrecheck false in -/-- push forward of a presheaf-/ +/-- push forward of a presheaf -/ notation f:80 " _* " P:81 => (pushforward _ f).obj P @[simp] @@ -291,7 +291,7 @@ def pullbackInvIsoPushforwardHom {X Y : TopCat.{v}} (H : X ≅ Y) : variable {C} -/-- If `f '' U` is open, then `f⁻¹ℱ U ≅ ℱ (f '' U)`. -/ +/-- If `f '' U` is open, then `f⁻¹ℱ U ≅ ℱ (f '' U)`. -/ def pullbackObjObjOfImageOpen {X Y : TopCat.{v}} (f : X ⟶ Y) (ℱ : Y.Presheaf C) (U : Opens X) (H : IsOpen (f '' SetLike.coe U)) : ((pullback C f).obj ℱ).obj (op U) ≅ ℱ.obj (op ⟨_, H⟩) := by let x : CostructuredArrow (Opens.map f).op (op U) := CostructuredArrow.mk diff --git a/Mathlib/Topology/Specialization.lean b/Mathlib/Topology/Specialization.lean index 53b1665a0beab..874083b9a9983 100644 --- a/Mathlib/Topology/Specialization.lean +++ b/Mathlib/Topology/Specialization.lean @@ -26,7 +26,7 @@ variable {α β γ : Type*} /-- `toEquiv` is the "identity" function to the `Specialization` of a type. -/ @[match_pattern] def toEquiv : α ≃ Specialization α := Equiv.refl _ -/-- `ofEquiv` is the identity function from the `Specialization` of a type. -/ +/-- `ofEquiv` is the identity function from the `Specialization` of a type. -/ @[match_pattern] def ofEquiv : Specialization α ≃ α := Equiv.refl _ @[simp] lemma toEquiv_symm : (@toEquiv α).symm = ofEquiv := rfl diff --git a/Mathlib/Topology/Spectral/Hom.lean b/Mathlib/Topology/Spectral/Hom.lean index 695abf50017b4..078b9875e0dbe 100644 --- a/Mathlib/Topology/Spectral/Hom.lean +++ b/Mathlib/Topology/Spectral/Hom.lean @@ -57,9 +57,9 @@ end Unbundled /-- The type of spectral maps from `α` to `β`. -/ structure SpectralMap (α β : Type*) [TopologicalSpace α] [TopologicalSpace β] where - /-- function between topological spaces-/ + /-- function between topological spaces -/ toFun : α → β - /-- proof that `toFun` is a spectral map-/ + /-- proof that `toFun` is a spectral map -/ spectral' : IsSpectralMap toFun section @@ -69,7 +69,7 @@ section You should extend this class when you extend `SpectralMap`. -/ class SpectralMapClass (F α β : Type*) [TopologicalSpace α] [TopologicalSpace β] [FunLike F α β] : Prop where - /-- statement that `F` is a type of spectral maps-/ + /-- statement that `F` is a type of spectral maps -/ map_spectral (f : F) : IsSpectralMap f end diff --git a/Mathlib/Topology/StoneCech.lean b/Mathlib/Topology/StoneCech.lean index 81b611c27866c..ba2b4232abec5 100644 --- a/Mathlib/Topology/StoneCech.lean +++ b/Mathlib/Topology/StoneCech.lean @@ -13,7 +13,7 @@ Construction of the Stone-Čech compactification using ultrafilters. For any topological space `α`, we build a compact Hausdorff space `StoneCech α` and a continuous map `stoneCechUnit : α → StoneCech α` which is minimal in the sense of the following universal property: for any compact Hausdorff space `β` and every map `f : α → β` such that -`hf : Continuous f`, there is a unique map `stoneCechExtend hf : StoneCech α → β` such that +`hf : Continuous f`, there is a unique map `stoneCechExtend hf : StoneCech α → β` such that `stoneCechExtend_extends : stoneCechExtend hf ∘ stoneCechUnit = f`. Continuity of this extension is asserted by `continuous_stoneCechExtend` and uniqueness by `stoneCech_hom_ext`. diff --git a/Mathlib/Topology/TietzeExtension.lean b/Mathlib/Topology/TietzeExtension.lean index 704a18651fd7e..b1e175559e9fd 100644 --- a/Mathlib/Topology/TietzeExtension.lean +++ b/Mathlib/Topology/TietzeExtension.lean @@ -306,7 +306,7 @@ theorem exists_extension_forall_mem_Icc_of_closedEmbedding (f : X →ᵇ ℝ) {a embedding. Let `e` be a closed embedding of a nonempty topological space `X` into a normal topological space `Y`. Let `f` be a bounded continuous real-valued function on `X`. Then there exists a bounded continuous function `g : Y →ᵇ ℝ` such that `g ∘ e = f` and each value `g y` belongs -to a closed interval `[f x₁, f x₂]` for some `x₁` and `x₂`. -/ +to a closed interval `[f x₁, f x₂]` for some `x₁` and `x₂`. -/ theorem exists_extension_forall_exists_le_ge_of_closedEmbedding [Nonempty X] (f : X →ᵇ ℝ) {e : X → Y} (he : ClosedEmbedding e) : ∃ g : Y →ᵇ ℝ, (∀ y, ∃ x₁ x₂, g y ∈ Icc (f x₁) (f x₂)) ∧ g ∘ e = f := by @@ -340,7 +340,7 @@ theorem exists_extension_forall_exists_le_ge_of_closedEmbedding [Nonempty X] (f · exact ⟨g, fun y => ⟨x, hg_mem _⟩, hgf⟩ /- Otherwise, `g ⁻¹' {a}` is disjoint with `range e ∪ g ⁻¹' (Ici c)`, hence there exists a function `dg : Y → ℝ` such that `dg ∘ e = 0`, `dg y = 0` whenever `c ≤ g y`, `dg y = c - a` - whenever `g y = a`, and `0 ≤ dg y ≤ c - a` for all `y`. -/ + whenever `g y = a`, and `0 ≤ dg y ≤ c - a` for all `y`. -/ have hd : Disjoint (range e ∪ g ⁻¹' Ici c) (g ⁻¹' {a}) := by refine disjoint_union_left.2 ⟨?_, Disjoint.preimage _ ?_⟩ · rw [Set.disjoint_left] diff --git a/Mathlib/Topology/UniformSpace/Basic.lean b/Mathlib/Topology/UniformSpace/Basic.lean index 5d50ef91ca453..0aedb9cd65b99 100644 --- a/Mathlib/Topology/UniformSpace/Basic.lean +++ b/Mathlib/Topology/UniformSpace/Basic.lean @@ -564,16 +564,16 @@ theorem comp_comp_symm_mem_uniformity_sets {s : Set (α × α)} (hs : s ∈ 𝓤 ### Balls in uniform spaces -/ +namespace UniformSpace + /-- The ball around `(x : β)` with respect to `(V : Set (β × β))`. Intended to be used for `V ∈ 𝓤 β`, but this is not needed for the definition. Recovers the -notions of metric space ball when `V = {p | dist p.1 p.2 < r }`. -/ -def UniformSpace.ball (x : β) (V : Set (β × β)) : Set β := - Prod.mk x ⁻¹' V +notions of metric space ball when `V = {p | dist p.1 p.2 < r }`. -/ +def ball (x : β) (V : Set (β × β)) : Set β := Prod.mk x ⁻¹' V open UniformSpace (ball) -theorem UniformSpace.mem_ball_self (x : α) {V : Set (α × α)} (hV : V ∈ 𝓤 α) : x ∈ ball x V := - refl_mem_uniformity hV +lemma mem_ball_self (x : α) {V : Set (α × α)} : V ∈ 𝓤 α → x ∈ ball x V := refl_mem_uniformity /-- The triangle inequality for `UniformSpace.ball` -/ theorem mem_ball_comp {V W : Set (β × β)} {x y z} (h : y ∈ ball x V) (h' : z ∈ ball y W) : @@ -612,11 +612,10 @@ theorem mem_comp_of_mem_ball {V W : Set (β × β)} {x y z : β} (hV : Symmetric rw [mem_ball_symmetry hV] at hx exact ⟨z, hx, hy⟩ -theorem UniformSpace.isOpen_ball (x : α) {V : Set (α × α)} (hV : IsOpen V) : IsOpen (ball x V) := +lemma isOpen_ball (x : α) {V : Set (α × α)} (hV : IsOpen V) : IsOpen (ball x V) := hV.preimage <| continuous_const.prod_mk continuous_id -theorem UniformSpace.isClosed_ball (x : α) {V : Set (α × α)} (hV : IsClosed V) : - IsClosed (ball x V) := +lemma isClosed_ball (x : α) {V : Set (α × α)} (hV : IsClosed V) : IsClosed (ball x V) := hV.preimage <| continuous_const.prod_mk continuous_id theorem mem_comp_comp {V W M : Set (β × β)} (hW' : SymmetricRel W) {p : β × β} : @@ -629,10 +628,14 @@ theorem mem_comp_comp {V W M : Set (β × β)} (hW' : SymmetricRel W) {p : β × rw [mem_ball_symmetry hW'] at z_in exact ⟨z, ⟨w, w_in, hwz⟩, z_in⟩ +end UniformSpace + /-! ### Neighborhoods in uniform spaces -/ +open UniformSpace + theorem mem_nhds_uniformity_iff_right {x : α} {s : Set α} : s ∈ 𝓝 x ↔ { p : α × α | p.1 = x → p.2 ∈ s } ∈ 𝓤 α := by simp only [nhds_eq_comap_uniformity, mem_comap_prod_mk] @@ -1793,3 +1796,5 @@ theorem Filter.Tendsto.congr_uniformity {α β} [UniformSpace β] {f g : α → theorem Uniform.tendsto_congr {α β} [UniformSpace β] {f g : α → β} {l : Filter α} {b : β} (hfg : Tendsto (fun x => (f x, g x)) l (𝓤 β)) : Tendsto f l (𝓝 b) ↔ Tendsto g l (𝓝 b) := ⟨fun h => h.congr_uniformity hfg, fun h => h.congr_uniformity hfg.uniformity_symm⟩ + +set_option linter.style.longFile 1900 diff --git a/Mathlib/Topology/UniformSpace/Compact.lean b/Mathlib/Topology/UniformSpace/Compact.lean index 6c6f0ab1644d7..3e8953b8f360d 100644 --- a/Mathlib/Topology/UniformSpace/Compact.lean +++ b/Mathlib/Topology/UniformSpace/Compact.lean @@ -141,7 +141,7 @@ def uniformSpaceOfCompactT2 [TopologicalSpace γ] [CompactSpace γ] [T2Space γ] simp [comap_const_of_not_mem (compl_singleton_mem_nhds hxy) (not_not_intro rfl)] /-! -### Heine-Cantor theorem +### Heine-Cantor theorem -/ diff --git a/Mathlib/Topology/UniformSpace/CompactConvergence.lean b/Mathlib/Topology/UniformSpace/CompactConvergence.lean index dabba67db0cd2..4a744f0a1c158 100644 --- a/Mathlib/Topology/UniformSpace/CompactConvergence.lean +++ b/Mathlib/Topology/UniformSpace/CompactConvergence.lean @@ -163,7 +163,7 @@ which defines topology of uniform convergence on compact sets. We use `ContinuousMap.tendsto_iff_forall_compact_tendstoUniformlyOn` to show that the induced topology agrees with the compact-open topology and replace the topology with `compactOpen` to avoid non-defeq diamonds, -see Note [forgetful inheritance]. -/ +see Note [forgetful inheritance]. -/ instance compactConvergenceUniformSpace : UniformSpace C(α, β) := .replaceTopology (.comap toUniformOnFunIsCompact inferInstance) <| by refine TopologicalSpace.ext_nhds fun f ↦ eq_of_forall_le_iff fun l ↦ ?_ diff --git a/Mathlib/Topology/UniformSpace/UniformEmbedding.lean b/Mathlib/Topology/UniformSpace/UniformEmbedding.lean index b674ec1daf22e..c871457f6115d 100644 --- a/Mathlib/Topology/UniformSpace/UniformEmbedding.lean +++ b/Mathlib/Topology/UniformSpace/UniformEmbedding.lean @@ -109,7 +109,7 @@ theorem UniformInducing.inducing {f : α → β} (h : UniformInducing f) : Induc theorem UniformInducing.prod {α' : Type*} {β' : Type*} [UniformSpace α'] [UniformSpace β'] {e₁ : α → α'} {e₂ : β → β'} (h₁ : UniformInducing e₁) (h₂ : UniformInducing e₂) : UniformInducing fun p : α × β => (e₁ p.1, e₂ p.2) := - ⟨by simp [(· ∘ ·), uniformity_prod, ← h₁.1, ← h₂.1, comap_inf, comap_comap]⟩ + ⟨by simp [(· ∘ ·), uniformity_prod, ← h₁.1, ← h₂.1, Filter.comap_inf, comap_comap]⟩ theorem UniformInducing.denseInducing {f : α → β} (h : UniformInducing f) (hd : DenseRange f) : DenseInducing f := @@ -238,9 +238,9 @@ theorem closure_image_mem_nhds_of_uniformInducing {s : Set (α × α)} {e : α ∃ U, (U ∈ 𝓤 β ∧ IsOpen U ∧ SymmetricRel U) ∧ Prod.map e e ⁻¹' U ⊆ s := by rwa [← he₁.comap_uniformity, (uniformity_hasBasis_open_symmetric.comap _).mem_iff] at hs rcases he₂.dense.mem_nhds (UniformSpace.ball_mem_nhds b hU) with ⟨a, ha⟩ - refine ⟨a, mem_of_superset ?_ (closure_mono <| image_subset _ <| ball_mono hs a)⟩ + refine ⟨a, mem_of_superset ?_ (closure_mono <| image_subset _ <| UniformSpace.ball_mono hs a)⟩ have ho : IsOpen (UniformSpace.ball (e a) U) := UniformSpace.isOpen_ball (e a) hUo - refine mem_of_superset (ho.mem_nhds <| (mem_ball_symmetry hsymm).2 ha) fun y hy => ?_ + refine mem_of_superset (ho.mem_nhds <| (UniformSpace.mem_ball_symmetry hsymm).2 ha) fun y hy => ?_ refine mem_closure_iff_nhds.2 fun V hV => ?_ rcases he₂.dense.mem_nhds (inter_mem hV (ho.mem_nhds hy)) with ⟨x, hxV, hxU⟩ exact ⟨e x, hxV, mem_image_of_mem e hxU⟩ diff --git a/Mathlib/Topology/VectorBundle/Basic.lean b/Mathlib/Topology/VectorBundle/Basic.lean index f7f9be5e65667..cf55b20054f31 100644 --- a/Mathlib/Topology/VectorBundle/Basic.lean +++ b/Mathlib/Topology/VectorBundle/Basic.lean @@ -538,7 +538,7 @@ theorem coordChange_linear_comp (i j k : ι) : @[nolint unusedArguments] -- Porting note(#5171): was `nolint has_nonempty_instance` def Index := ι -/-- The base space of a vector bundle core, as a convenience function for dot notation-/ +/-- The base space of a vector bundle core, as a convenience function for dot notation -/ @[nolint unusedArguments, reducible] def Base := B diff --git a/lake-manifest.json b/lake-manifest.json index ea1adab76b4db..07080820b6dab 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -5,7 +5,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "e6d3a32d66252a70fda1d56463e1da975b3b8f53", + "rev": "9c6c2d647e57b2b7a0b42dd8080c698bd33a1b6f", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "main", @@ -15,7 +15,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "d38fb94558af9957b8f479e350841ce65a1ec42c", + "rev": "9d0bdd07bdfe53383567509348b1fe917fc08de4", "name": "Qq", "manifestFile": "lake-manifest.json", "inputRev": "master", @@ -25,7 +25,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "f36af1a7011c102cdf3f5f6c31d2367de28da3a8", + "rev": "deb279eb7be16848d0bc8387f80d6e41bcdbe738", "name": "aesop", "manifestFile": "lake-manifest.json", "inputRev": "master", @@ -55,7 +55,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "fe36a37a5f1b3260331f54fc010c24bbf9fbcfeb", + "rev": "1ef0b288623337cb37edd1222b9c26b4b77c6620", "name": "importGraph", "manifestFile": "lake-manifest.json", "inputRev": "main", diff --git a/lean-toolchain b/lean-toolchain index e7a4f40b892b4..5a9c76dc98c08 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:v4.11.0-rc2 +leanprover/lean4:v4.11.0 diff --git a/scripts/get_tlabel.sh b/scripts/get_tlabel.sh new file mode 100755 index 0000000000000..1685f96172964 --- /dev/null +++ b/scripts/get_tlabel.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + + : <<'BASH_MODULE_DOCS' + +This script is used by the maintainer merge actions to extract +* either `t-xxx` if `t-xxx` is the unique `t-`label of the PR; +* or `generic` otherwise +and stores it in `tlabels`. + +In turn, the string `tlabels` extracted above is converted into the +topic name `maintainer merge: tlabels` for the post to the +`maintainer merge` stream. + +BASH_MODULE_DOCS + +PR="${1}" + +>&2 printf $'Using PR: \'%s\'\n' "${PR}" + +tlabels="$(gh api --jq '.labels.[].name' "${PR}" | grep -- '^t-' || printf 'generic')" +# print to error, since the stdout is captured into `GITHUB_OUTPUT +>&2 printf 't-labels:\n---\n%s\n---\n' "${tlabels}" +# if there isn't exactly 1 `t-xxx` label, use `generic` +if [[ "$(wc -l <<<"${tlabels}")" -ne 1 ]]; then + tlabels="generic" +fi +topicName="maintainer merge: ${tlabels}" +>&2 printf $'Post to topic: \'%s\'"\n' "${topicName}" +echo "topic=${topicName}" diff --git a/scripts/lint-style.lean b/scripts/lint-style.lean index ed4ac6ebf23b0..2db69b6d8db67 100644 --- a/scripts/lint-style.lean +++ b/scripts/lint-style.lean @@ -29,9 +29,12 @@ def lintStyleCli (args : Cli.Parsed) : IO UInt32 := do -- note: since we manually add "Batteries" to "Mathlib.lean", we remove it here manually allModules := allModules.erase "Batteries" let numberErrorFiles ← lintModules allModules mode (args.hasFlag "fix") - -- Make sure to return an exit code of at most 125, so this return value can be used further - -- in shell scripts. - return min numberErrorFiles 125 + -- If run with the `--update` or `--fix` argument, return a zero exit code. + -- Otherwise, make sure to return an exit code of at most 125, + -- so this return value can be used further in shell scripts. + if args.hasFlag "update" || args.hasFlag "fix" then + return 0 + else return min numberErrorFiles 125 /-- Setting up command line options and help text for `lake exe lint-style`. -/ -- so far, no help options or so: perhaps that is fine? diff --git a/scripts/lint-style.py b/scripts/lint-style.py index b8b0ed4779a5b..953790a5e4daf 100755 --- a/scripts/lint-style.py +++ b/scripts/lint-style.py @@ -59,9 +59,15 @@ for exline in f: filename, _, _, _, _, errno, *extra = exline.split() path = ROOT_DIR / filename - if errno == "ERR_MOD": - exceptions += [(ERR_MOD, path, None)] - elif errno in ["ERR_COP", "ERR_LIN", "ERR_ADN", "ERR_NUM_LIN"]: + map = { + "ERR_MOD": ERR_MOD, "ERR_IBY": ERR_IBY, "ERR_IWH": ERR_IWH, + "ERR_DOT": ERR_DOT, "ERR_SEM": ERR_SEM, "ERR_WIN": ERR_WIN, + "ERR_TWS": ERR_TWS, "ERR_CLN": ERR_CLN, "ERR_IND": ERR_IND, + "ERR_ARR": ERR_ARR, "ERR_NSP": ERR_NSP, + } + if errno in map: + exceptions += [(map[errno], path, None)] + elif errno in ["ERR_COP", "ERR_ADN"]: pass # maintained by the Lean style linter now else: print(f"Error: unexpected errno in style-exceptions.txt: {errno}") diff --git a/scripts/mk_all.lean b/scripts/mk_all.lean index c33a957e6149d..309a4bf49d2c4 100644 --- a/scripts/mk_all.lean +++ b/scripts/mk_all.lean @@ -64,7 +64,8 @@ def mkAllCLI (args : Parsed) : IO UInt32 := do updates := updates + 1 else if (← IO.FS.readFile fileName) != fileContent then if check then - IO.println s!"The file '{fileName}' is out of date: run `lake exe mk_all{if git then " --git" else ""}` to update it" + IO.println s!"The file '{fileName}' is out of date: \ + run `lake exe mk_all{if git then " --git" else ""}` to update it" else IO.println s!"Updating '{fileName}'" IO.FS.writeFile fileName fileContent diff --git a/scripts/nolints.json b/scripts/nolints.json index b2ed89639f44c..cd10aac529d97 100644 --- a/scripts/nolints.json +++ b/scripts/nolints.json @@ -30,8 +30,6 @@ ["docBlame", "WriterT"], ["docBlame", "Xor'"], ["docBlame", "Zero"], - ["docBlame", "bit0"], - ["docBlame", "bit1"], ["docBlame", "cancelDenominators"], ["docBlame", "cancelDenominatorsAt"], ["docBlame", "cancelDenominatorsTarget"], @@ -51,7 +49,6 @@ ["docBlame", "«term_≃ᵃⁱ[_]_»"], ["docBlame", "«term_≃ᵈ_»"], ["docBlame", "«term_≡_[SMOD_]»"], - ["docBlame", "termℤ"], ["docBlame", "«termℤ√_»"], ["docBlame", "«term∫_In_.._,_»"], ["docBlame", "«term∫_In_.._,_∂_»"], @@ -80,7 +77,6 @@ ["docBlame", "Bitraversable.bitraverse"], ["docBlame", "BoundedContinuousFunction.«term_→ᵇ_»"], ["docBlame", "BoundedRandom.randomR"], - ["docBlame", "BumpCovering.toFun"], ["docBlame", "ByteSlice.arr"], ["docBlame", "ByteSlice.len"], ["docBlame", "ByteSlice.off"], @@ -283,7 +279,6 @@ ["docBlame", "One.one"], ["docBlame", "OptionT.callCC"], ["docBlame", "OptionT.mkLabel"], - ["docBlame", "PartitionOfUnity.toFun"], ["docBlame", "PicardLindelof.C"], ["docBlame", "PicardLindelof.L"], ["docBlame", "PicardLindelof.R"], @@ -337,7 +332,6 @@ ["docBlame", "SchwartzMap.toFun"], ["docBlame", "SemiRingCat.forget_obj_eq_coe"], ["docBlame", "Semigrp.forget_obj_eq_coe"], - ["docBlame", "Set.«term{_|_}»"], ["docBlame", "Shrink.rec"], ["docBlame", "SlashAction.map"], ["docBlame", "SlashInvariantForm.toFun"], @@ -427,8 +421,6 @@ ["docBlame", "CategoryTheory.Comma.right"], ["docBlame", "CategoryTheory.CommaMorphism.left"], ["docBlame", "CategoryTheory.CommaMorphism.right"], - ["docBlame", "CategoryTheory.Comonad.δ'"], - ["docBlame", "CategoryTheory.Comonad.ε'"], ["docBlame", "CategoryTheory.EnrichedCategory.Hom"], ["docBlame", "CategoryTheory.EnrichedCategory.comp"], ["docBlame", "CategoryTheory.EnrichedCategory.id"], @@ -441,8 +433,6 @@ ["docBlame", "CategoryTheory.GlueData.t"], ["docBlame", "CategoryTheory.GlueData.t'"], ["docBlame", "CategoryTheory.GradedNatTrans.app"], - ["docBlame", - "CategoryTheory.GrothendieckTopology.sheafificationIsoPresheafToSheafCompSheafToPreasheaf"], ["docBlame", "CategoryTheory.HalfBraiding.β"], ["docBlame", "CategoryTheory.Mat_.X"], ["docBlame", "CategoryTheory.Mat_.ι"], @@ -451,8 +441,6 @@ ["docBlame", "CategoryTheory.Monad.PreservesColimitOfIsReflexivePair"], ["docBlame", "CategoryTheory.Monad.PreservesColimitOfIsSplitPair"], ["docBlame", "CategoryTheory.Monad.ReflectsColimitOfIsSplitPair"], - ["docBlame", "CategoryTheory.Monad.η'"], - ["docBlame", "CategoryTheory.Monad.μ'"], ["docBlame", "CategoryTheory.Presieve.yonedaFamilyOfElements_fromCocone"], ["docBlame", "CategoryTheory.Pretopology.coverings"], ["docBlame", "CategoryTheory.ProjectivePresentation.f"], @@ -489,7 +477,6 @@ ["docBlame", "GromovHausdorff.AuxGluingStruct.Space"], ["docBlame", "GromovHausdorff.AuxGluingStruct.embed"], ["docBlame", "GromovHausdorff.AuxGluingStruct.metric"], - ["docBlame", "HahnSeries.SummableFamily.toFun"], ["docBlame", "HomogeneousLocalization.NumDenSameDeg.deg"], ["docBlame", "HomogeneousLocalization.NumDenSameDeg.den"], ["docBlame", "HomogeneousLocalization.NumDenSameDeg.num"], @@ -497,7 +484,6 @@ ["docBlame", "Ideal.Filtration.N"], ["docBlame", "IntermediateField.delabAdjoinNotation.delabInsertArray"], ["docBlame", "IsDedekindDomain.HeightOneSpectrum.asIdeal"], - ["docBlame", "Lean.Attr.substAttr"], ["docBlame", "Lean.Export.Alloc"], ["docBlame", "Lean.Export.Entry"], ["docBlame", "Lean.Export.OfState"], @@ -515,10 +501,6 @@ ["docBlame", "Lean.Expr.modifyRevArg"], ["docBlame", "Lean.MVarId.casesType"], ["docBlame", "Lean.MVarId.congrCore!"], - ["docBlame", "Lean.Meta.checkTypeIsProp"], - ["docBlame", "Lean.Meta.mkSimpTheoremCore"], - ["docBlame", "Lean.Meta.preprocess"], - ["docBlame", "Lean.Meta.shouldPreprocess"], ["docBlame", "Lean.Name.isBlackListed"], ["docBlame", "Lean.PHashSet.toList"], ["docBlame", "LocallyFinite.Realizer.bas"], @@ -785,4 +767,4 @@ ["docBlame", "Mathlib.Meta.NormNum.evalAdd.core.ratArm"], ["docBlame", "Mathlib.Meta.NormNum.evalMul.core.intArm"], ["docBlame", "Mathlib.Meta.NormNum.evalMul.core.ratArm"], - ["unusedArguments", "Combinator.K"]] + ["unusedArguments", "Combinator.K"]] \ No newline at end of file diff --git a/scripts/style-exceptions.txt b/scripts/style-exceptions.txt index 9888c59074978..e69de29bb2d1d 100644 --- a/scripts/style-exceptions.txt +++ b/scripts/style-exceptions.txt @@ -1,68 +0,0 @@ -Mathlib/Algebra/BigOperators/Group/Finset.lean : line 1 : ERR_NUM_LIN : 2400 file contains 2245 lines, try to split it up -Mathlib/Algebra/Group/Subgroup/Basic.lean : line 1 : ERR_NUM_LIN : 3000 file contains 2893 lines, try to split it up -Mathlib/Algebra/MonoidAlgebra/Basic.lean : line 1 : ERR_NUM_LIN : 2100 file contains 1965 lines, try to split it up -Mathlib/Algebra/MvPolynomial/Basic.lean : line 1 : ERR_NUM_LIN : 1700 file contains 1544 lines, try to split it up -Mathlib/Algebra/Order/Floor.lean : line 1 : ERR_NUM_LIN : 1700 file contains 1593 lines, try to split it up -Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian.lean : line 1 : ERR_NUM_LIN : 1700 file contains 1511 lines, try to split it up -Mathlib/Analysis/Asymptotics/Asymptotics.lean : line 1 : ERR_NUM_LIN : 2100 file contains 1955 lines, try to split it up -Mathlib/Analysis/Calculus/ContDiff/Basic.lean : line 1 : ERR_NUM_LIN : 2100 file contains 1952 lines, try to split it up -Mathlib/Analysis/Calculus/ContDiff/Defs.lean : line 1 : ERR_NUM_LIN : 1700 file contains 1595 lines, try to split it up -Mathlib/Analysis/InnerProductSpace/Basic.lean : line 1 : ERR_NUM_LIN : 2500 file contains 2433 lines, try to split it up -Mathlib/CategoryTheory/Limits/Shapes/Biproducts.lean : line 1 : ERR_NUM_LIN : 2100 file contains 1998 lines, try to split it up -Mathlib/Computability/TMToPartrec.lean : line 1 : ERR_NUM_LIN : 2200 file contains 2071 lines, try to split it up -Mathlib/Computability/TuringMachine.lean : line 1 : ERR_NUM_LIN : 2700 file contains 2561 lines, try to split it up -Mathlib/Data/DFinsupp/Basic.lean : line 1 : ERR_NUM_LIN : 2200 file contains 2078 lines, try to split it up -Mathlib/Data/Fin/Basic.lean : line 1 : ERR_NUM_LIN : 1700 file contains 1524 lines, try to split it up -Mathlib/Data/Finset/Basic.lean : line 1 : ERR_NUM_LIN : 3200 file contains 3057 lines, try to split it up -Mathlib/Data/Finset/Lattice.lean : line 1 : ERR_NUM_LIN : 2100 file contains 1968 lines, try to split it up -Mathlib/Data/Finset/Pointwise/Basic.lean : line 1 : ERR_NUM_LIN : 2100 file contains 1997 lines, try to split it up -Mathlib/Data/Finsupp/Basic.lean : line 1 : ERR_NUM_LIN : 1900 file contains 1703 lines, try to split it up -Mathlib/Data/List/Basic.lean : line 1 : ERR_NUM_LIN : 2700 file contains 2598 lines, try to split it up -Mathlib/Data/Matrix/Basic.lean : line 1 : ERR_NUM_LIN : 2700 file contains 2519 lines, try to split it up -Mathlib/Data/Multiset/Basic.lean : line 1 : ERR_NUM_LIN : 2900 file contains 2725 lines, try to split it up -Mathlib/Data/Num/Lemmas.lean : line 1 : ERR_NUM_LIN : 1700 file contains 1576 lines, try to split it up -Mathlib/Data/Ordmap/Ordset.lean : line 1 : ERR_NUM_LIN : 1700 file contains 1580 lines, try to split it up -Mathlib/Data/Real/EReal.lean : line 1 : ERR_NUM_LIN : 1900 file contains 1778 lines, try to split it up -Mathlib/Data/Seq/WSeq.lean : line 1 : ERR_NUM_LIN : 1800 file contains 1622 lines, try to split it up -Mathlib/Data/Set/Basic.lean : line 1 : ERR_NUM_LIN : 2300 file contains 2170 lines, try to split it up -Mathlib/Data/Set/Finite.lean : line 1 : ERR_NUM_LIN : 1700 file contains 1535 lines, try to split it up -Mathlib/Data/Set/Function.lean : line 1 : ERR_NUM_LIN : 1900 file contains 1740 lines, try to split it up -Mathlib/Data/Set/Lattice.lean : line 1 : ERR_NUM_LIN : 2100 file contains 1932 lines, try to split it up -Mathlib/Data/ZMod/Basic.lean : line 1 : ERR_NUM_LIN : 1700 file contains 1533 lines, try to split it up -Mathlib/LinearAlgebra/AffineSpace/AffineSubspace.lean : line 1 : ERR_NUM_LIN : 1800 file contains 1693 lines, try to split it up -Mathlib/LinearAlgebra/Dual.lean : line 1 : ERR_NUM_LIN : 1900 file contains 1738 lines, try to split it up -Mathlib/LinearAlgebra/Multilinear/Basic.lean : line 1 : ERR_NUM_LIN : 1900 file contains 1775 lines, try to split it up -Mathlib/Logic/Equiv/Basic.lean : line 1 : ERR_NUM_LIN : 2000 file contains 1806 lines, try to split it up -Mathlib/MeasureTheory/Function/LpSpace.lean : line 1 : ERR_NUM_LIN : 2100 file contains 1978 lines, try to split it up -Mathlib/MeasureTheory/Function/StronglyMeasurable/Basic.lean : line 1 : ERR_NUM_LIN : 2000 file contains 1879 lines, try to split it up -Mathlib/MeasureTheory/Integral/Bochner.lean : line 1 : ERR_NUM_LIN : 2100 file contains 1947 lines, try to split it up -Mathlib/MeasureTheory/Integral/FundThmCalculus.lean : line 1 : ERR_NUM_LIN : 1800 file contains 1647 lines, try to split it up -Mathlib/MeasureTheory/Integral/Lebesgue.lean : line 1 : ERR_NUM_LIN : 2200 file contains 2051 lines, try to split it up -Mathlib/MeasureTheory/Integral/SetIntegral.lean : line 1 : ERR_NUM_LIN : 1700 file contains 1579 lines, try to split it up -Mathlib/MeasureTheory/Integral/SetToL1.lean : line 1 : ERR_NUM_LIN : 1800 file contains 1640 lines, try to split it up -Mathlib/MeasureTheory/Measure/MeasureSpace.lean : line 1 : ERR_NUM_LIN : 2200 file contains 2008 lines, try to split it up -Mathlib/MeasureTheory/Measure/Typeclasses.lean : line 1 : ERR_NUM_LIN : 1700 file contains 1531 lines, try to split it up -Mathlib/Order/CompleteLattice.lean : line 1 : ERR_NUM_LIN : 1900 file contains 1709 lines, try to split it up -Mathlib/Order/ConditionallyCompleteLattice/Basic.lean : line 1 : ERR_NUM_LIN : 1700 file contains 1549 lines, try to split it up -Mathlib/Order/Filter/AtTopBot.lean : line 1 : ERR_NUM_LIN : 2000 file contains 1828 lines, try to split it up -Mathlib/Order/Filter/Basic.lean : line 1 : ERR_NUM_LIN : 3000 file contains 2898 lines, try to split it up -Mathlib/Order/Hom/Lattice.lean : line 1 : ERR_NUM_LIN : 1800 file contains 1661 lines, try to split it up -Mathlib/Order/Interval/Set/Basic.lean : line 1 : ERR_NUM_LIN : 1800 file contains 1652 lines, try to split it up -Mathlib/Order/LiminfLimsup.lean : line 1 : ERR_NUM_LIN : 1900 file contains 1791 lines, try to split it up -Mathlib/Order/UpperLower/Basic.lean : line 1 : ERR_NUM_LIN : 1900 file contains 1795 lines, try to split it up -Mathlib/RingTheory/UniqueFactorizationDomain.lean : line 1 : ERR_NUM_LIN : 2100 file contains 1982 lines, try to split it up -Mathlib/SetTheory/Cardinal/Basic.lean : line 1 : ERR_NUM_LIN : 2200 file contains 2004 lines, try to split it up -Mathlib/SetTheory/Game/PGame.lean : line 1 : ERR_NUM_LIN : 1900 file contains 1753 lines, try to split it up -Mathlib/SetTheory/Ordinal/Arithmetic.lean : line 1 : ERR_NUM_LIN : 2400 file contains 2269 lines, try to split it up -Mathlib/SetTheory/ZFC/Basic.lean : line 1 : ERR_NUM_LIN : 1700 file contains 1549 lines, try to split it up -Mathlib/Tactic/CC/Addition.lean : line 1 : ERR_NUM_LIN : 2300 file contains 2100 lines, try to split it up -Mathlib/Tactic/ToAdditive/Frontend.lean : line 1 : ERR_NUM_LIN : 1700 file contains 1502 lines, try to split it up -Mathlib/Topology/Algebra/Group/Basic.lean : line 1 : ERR_NUM_LIN : 2100 file contains 1932 lines, try to split it up -Mathlib/Topology/Algebra/Module/Basic.lean : line 1 : ERR_NUM_LIN : 2600 file contains 2405 lines, try to split it up -Mathlib/Topology/Basic.lean : line 1 : ERR_NUM_LIN : 1900 file contains 1731 lines, try to split it up -Mathlib/Topology/Category/Profinite/Nobeling.lean : line 1 : ERR_NUM_LIN : 2000 file contains 1806 lines, try to split it up -Mathlib/Topology/Constructions.lean : line 1 : ERR_NUM_LIN : 1700 file contains 1591 lines, try to split it up -Mathlib/Topology/ContinuousFunction/Bounded.lean : line 1 : ERR_NUM_LIN : 1800 file contains 1682 lines, try to split it up -Mathlib/Topology/Instances/ENNReal.lean : line 1 : ERR_NUM_LIN : 1700 file contains 1513 lines, try to split it up -Mathlib/Topology/Separation.lean : line 1 : ERR_NUM_LIN : 2900 file contains 2716 lines, try to split it up -Mathlib/Topology/UniformSpace/Basic.lean : line 1 : ERR_NUM_LIN : 1900 file contains 1768 lines, try to split it up diff --git a/scripts/technical-debt-metrics.sh b/scripts/technical-debt-metrics.sh index cd49fd69bfaa1..2eab5e3d43193 100755 --- a/scripts/technical-debt-metrics.sh +++ b/scripts/technical-debt-metrics.sh @@ -54,7 +54,9 @@ for i in ${!titlesAndRegexes[@]}; do done printf '%s|%s\n' "$(grep -c 'docBlame' scripts/nolints.json)" "documentation nolint entries" -printf '%s|%s\n' "$(grep -c 'ERR_NUM_LIN' scripts/style-exceptions.txt)" "large files" +# the exceptions for files exceeding the 1500 line limit are split between the `longFile` and +# the text-based linters. +printf '%s|%s\n' "$(grep -c '^set_option linter.style.longFile [0-9]*' $(git ls-files '*.lean'))" "large files" printf '%s|%s\n' "$(git grep "^open .*Classical" | grep -v " in$" -c)" "bare open (scoped) Classical" # We print the number of files, not the number of matches --- hence, the nested grep. printf '%s|%s\n' "$(git grep -c 'autoImplicit true' | grep -c -v 'test')" "non-test files with autoImplicit true" diff --git a/scripts/update_nolints_CI.sh b/scripts/update_nolints_CI.sh index 42c50b9c2074e..dd798bc21e78e 100755 --- a/scripts/update_nolints_CI.sh +++ b/scripts/update_nolints_CI.sh @@ -12,7 +12,7 @@ branch_name=nolints owner_name=leanprover-community # Exit if the branch already exists -git fetch "$remote_name" +git fetch --quiet "$remote_name" git rev-parse --verify --quiet "refs/remotes/${remote_name}/${branch_name}" && exit 0 # Exit if there are no changes relative to master @@ -34,7 +34,7 @@ gh_api() { git push "${remote_name}" "HEAD:$branch_name" -pr_id=$(gh_api "repos/${owner_name}/mathlib/pulls" -X POST -d @- <:1:3: Stacks tags must be exactly 4 characters -/ #guard_exceptions in Mathlib.Stacks.stacksTagFn "A05" diff --git a/test/StringDiagram.lean b/test/StringDiagram.lean index ec654cf09ce73..1933c6add2017 100644 --- a/test/StringDiagram.lean +++ b/test/StringDiagram.lean @@ -24,7 +24,7 @@ lemma left_triangle {X Y : C} (η : 𝟙_ _ ⟶ X ⊗ Y) (ε : Y ⊗ X ⟶ 𝟙_ /- Place the cursor here and shift-click the 2-morphisms in the tactic state. -/ exact w.elim -/- Instead of writing `with_panel_widgets` everywhere, you can also use this command. -/ +/- Instead of writing `with_panel_widgets` everywhere, you can also use this command. -/ show_panel_widgets [local StringDiagram, local SelectionPanel] lemma yang_baxter {V₁ V₂ V₃ : C} (R : ∀ V₁ V₂ : C, V₁ ⊗ V₂ ⟶ V₂ ⊗ V₁) (w : False) : diff --git a/test/UnusedTactic.lean b/test/UnusedTactic.lean index 5dd2b6a81221b..e12d30af91f30 100644 --- a/test/UnusedTactic.lean +++ b/test/UnusedTactic.lean @@ -4,7 +4,7 @@ import Mathlib.Tactic.AdaptationNote def why2 : True → True := (by refine ·) example : True := by - #adaptation_note /--hi-/ + #adaptation_note /-- hi -/ exact .intro -- both `;` and `<;>` are unseen by the linter diff --git a/test/Zify.lean b/test/Zify.lean index 0ff0f60de8ab5..a61537de310b2 100644 --- a/test/Zify.lean +++ b/test/Zify.lean @@ -29,11 +29,11 @@ example (a b : ℕ) (h : (a : ℤ) ≤ b) : a ≤ b := by guard_target = (a : ℤ) ≤ b exact h -/-example (a b : ℕ) (h : a = b ∧ b < a) : False := by +/- example (a b : ℕ) (h : a = b ∧ b < a) : False := by zify at h rcases h with ⟨ha, hb⟩ -- Preorder for `ℤ` is missing - exact ne_of_lt hb ha-/ + exact ne_of_lt hb ha -/ example (a b c : ℕ) (h : a - b < c) (hab : b ≤ a) : True := by zify [hab] at h diff --git a/test/finsupp_notation.lean b/test/finsupp_notation.lean index e713fedca935a..e042b67a8903f 100644 --- a/test/finsupp_notation.lean +++ b/test/finsupp_notation.lean @@ -21,7 +21,7 @@ info: reprStr (Finsupp.mk {1, 2} (fun | 1 | 2 => 3 | _ => 0) (fun x => by aesop)) = "fun₀ | 1 => 3 | 2 => 3" -/-! ## (computable) number theory examples-/ +/-! ## (computable) number theory examples -/ /-- info: fun₀ | 2 => 2 | 7 => 1 -/ #guard_msgs in diff --git a/test/fun_prop_dev.lean b/test/fun_prop_dev.lean index 7ce645666bfaa..b2059309039f4 100644 --- a/test/fun_prop_dev.lean +++ b/test/fun_prop_dev.lean @@ -6,6 +6,7 @@ Authors: Tomáš Skřivan import Mathlib.Tactic.FunProp import Mathlib.Logic.Function.Basic import Mathlib.Data.FunLike.Basic +import Aesop /-! # Tests for the `fun_prop` tactic @@ -465,3 +466,26 @@ Issues: -/ #guard_msgs in example : Con (fun x : α => f3 x) := by fun_prop (config:={maxTransitionDepth:=0}) + + +@[fun_prop] opaque Dif (𝕜:Type) [Add 𝕜] {α β} (f : α → β) : Prop + +variable {𝕜 : Type} +@[fun_prop] theorem Dif_id [Add 𝕜] : Dif 𝕜 (id : α → α) := silentSorry +@[fun_prop] theorem Dif_const [Add 𝕜] (y : β) : Dif 𝕜 (fun x : α => y) := silentSorry +@[fun_prop] theorem Dif_apply [Add 𝕜] (x : α) : Dif 𝕜 (fun f : α → β => f x) := silentSorry +@[fun_prop] theorem Dif_applyDep [Add 𝕜] (x : α) : Dif 𝕜 (fun f : (x' : α) → E x' => f x) := silentSorry +@[fun_prop] theorem Dif_comp [Add 𝕜] (f : β → γ) (g : α → β) (hf : Dif 𝕜 f) (hg : Dif 𝕜 g) : Dif 𝕜 (fun x => f (g x)) := silentSorry +@[fun_prop] theorem Dif_pi [Add 𝕜] (f : β → (i : α) → (E i)) (hf : ∀ i, Dif 𝕜 (fun x => f x i)) : Dif 𝕜 (fun x i => f x i) := silentSorry + +@[fun_prop] +theorem Dif_Con [Add 𝕜] (f : α → β) (hf : Dif 𝕜 f) : Con f := silentSorry + +def f4 (a : α) := a + +example (hf : Dif Nat (f4 : α → α)) : Con (f4 : α → α) := by fun_prop (disch:=trace_state; aesop) + +@[fun_prop] +theorem f4_dif : Dif Nat (f4 : α → α) := silentSorry + +example (hf : Dif Nat (f4 : α → α)) : Con (f4 : α → α) := by fun_prop (disch:=aesop) diff --git a/test/instance_diamonds.lean b/test/instance_diamonds.lean index 7b746593fdb05..f26a6b719c7ff 100644 --- a/test/instance_diamonds.lean +++ b/test/instance_diamonds.lean @@ -141,7 +141,7 @@ example : @Monoid.toMulOneClass (Multiplicative ℕ) CommMonoid.toMonoid = end Multiplicative -/-! ## `Finsupp` instances-/ +/-! ## `Finsupp` instances -/ section Finsupp diff --git a/test/polyrith.lean b/test/polyrith.lean index a0bd8b137e1f3..69b2dad906d48 100644 --- a/test/polyrith.lean +++ b/test/polyrith.lean @@ -183,7 +183,7 @@ A full test suite is provided at the bottom of the file. -- "(((((2 * var0) - 3) + (9 * var1)) + (3 * var2)) - (((8 - var3) + (3 * var2)) - (3 * var0)))"] -- "linear_combination 2 * h1 - h2 + 3 * h3 - 3 * h4" --- /-! ### Case with ambiguous identifiers-/ +-- /-! ### Case with ambiguous identifiers -/ -- example («def evil» y : ℤ) (h1 : 3*«def evil» + 2*y = 10) : -- 3*«def evil» + 2*y = 10 := @@ -481,7 +481,7 @@ example (a b c d : ℚ) (h1 : a = 4) (h2 : 3 = b) (h3 : c*3 = d) (h4 : -d = a) : 2*a - 3 + 9*c + 3*d = 8 - b + 3*d - 3*a := by polyrith -/-! ### Case with ambiguous identifiers-/ +/-! ### Case with ambiguous identifiers -/ -- set_option trace.Meta.Tactic.polyrith true example («def evil» y : ℤ) (h1 : 3*«def evil» + 2*y = 10) : 3*«def evil» + 2*y = 10 := by @@ -631,7 +631,7 @@ example (a b c d : ℚ) (h1 : a = 4) (h2 : 3 = b) (h3 : c*3 = d) (h4 : -d = a) : 2*a - 3 + 9*c + 3*d = 8 - b + 3*d - 3*a := by create_polyrith_test -/-! ### Case with ambiguous identifiers-/ +/-! ### Case with ambiguous identifiers -/ example («def evil» y : ℤ) (h1 : 3*«def evil» + 2*y = 10) : 3*«def evil» + 2*y = 10 := by diff --git a/test/recover.lean b/test/recover.lean index 1803fcb328b8a..72d81332f21b0 100644 --- a/test/recover.lean +++ b/test/recover.lean @@ -6,7 +6,7 @@ set_option linter.unusedTactic false elab "this" "is" "a" "problem" : tactic => Lean.Elab.Tactic.setGoals [] -/- The main test-/ +/- The main test -/ example : 1 = 1 := by recover this is a problem rfl diff --git a/test/set_like.lean b/test/set_like.lean index 284818ca75cd9..2847a594eb156 100644 --- a/test/set_like.lean +++ b/test/set_like.lean @@ -51,7 +51,7 @@ example [Monoid M] (x y z : M) (S₁ S₂ : Submonoid M) (h : S₁ ≤ S₂) (hx x * y * z ∈ S₁ ⊔ S₂ := by aesop -example [Monoid M] (x y z : M) (S : Submonoid M) (hxy : x * y ∈ S) (hz : z ∈ S) : +example [Monoid M] (x y z : M) (S : Submonoid M) (hxy : x * y ∈ S) (hz : z ∈ S) : z * (x * y) ∈ S := by aesop