Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into PieterCuijpers_Quantales_H…
Browse files Browse the repository at this point in the history
…omomorphism
  • Loading branch information
PieterCuijpers committed Nov 23, 2024
2 parents 7e23b01 + 0b15a0d commit 5189bc2
Show file tree
Hide file tree
Showing 209 changed files with 2,361 additions and 1,014 deletions.
1 change: 1 addition & 0 deletions .github/workflows/PR_summary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:

jobs:
build:
name: "post-or-update-summary-comment"
runs-on: ubuntu-latest

steps:
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/discover-lean-pr-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
push:
branches:
- nightly-testing
paths:
- lean-toolchain

jobs:
discover-lean-pr-testing:
Expand Down Expand Up @@ -69,16 +67,19 @@ jobs:
# Output the PRs
echo "$PRS"
echo "prs=$PRS" >> "$GITHUB_OUTPUT"
printf "prs<<EOF\n%s\nEOF" "$PRS" >> "$GITHUB_OUTPUT"
- name: Use merged PRs information
id: find-branches
run: |
# Use the PRs from the previous step
PRS="${{ steps.get-prs.outputs.prs }}"
echo "$PRS"
echo "===================="
echo "$PRS" | tr ' ' '\n' > prs.txt
MATCHING_BRANCHES=$(git branch -r | grep -f prs.txt)
echo "$MATCHING_BRANCHES"
echo "===================="
# Initialize an empty variable to store branches with relevant diffs
RELEVANT_BRANCHES=""
Expand All @@ -91,25 +92,25 @@ jobs:
# Check if the diff contains files other than the specified ones
if echo "$DIFF_FILES" | grep -v -e 'lake-manifest.json' -e 'lakefile.lean' -e 'lean-toolchain'; then
# If it does, add the branch to RELEVANT_BRANCHES
RELEVANT_BRANCHES="$RELEVANT_BRANCHES $BRANCH"
RELEVANT_BRANCHES="$RELEVANT_BRANCHES\n- $BRANCH"
fi
done
# Output the relevant branches
echo "'$RELEVANT_BRANCHES'"
echo "branches=$RELEVANT_BRANCHES" >> "$GITHUB_OUTPUT"
printf "branches<<EOF\n%s\nEOF" "$RELEVANT_BRANCHES" >> "$GITHUB_OUTPUT"
- name: Check if there are relevant branches
id: check-branches
run: |
if [ -z "${{ steps.find-branches.outputs.branches }}" ]; then
echo "no_branches=true" >> "$GITHUB_ENV"
echo "branches_exist=false" >> "$GITHUB_ENV"
else
echo "no_branches=false" >> "$GITHUB_ENV"
echo "branches_exist=true" >> "$GITHUB_ENV"
fi
- name: Send message on Zulip
if: env.no_branches == 'false'
if: env.branches_exist == 'true'
uses: zulip/github-actions-zulip/send-message@v1
with:
api-key: ${{ secrets.ZULIP_API_KEY }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/sync_closed_tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:

jobs:
build:
name: "Cross off linked issues"
runs-on: ubuntu-latest
steps:
- name: Cross off any linked issue and PR references
Expand Down
16 changes: 13 additions & 3 deletions Mathlib.lean
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ import Mathlib.Algebra.CharP.ExpChar
import Mathlib.Algebra.CharP.IntermediateField
import Mathlib.Algebra.CharP.Invertible
import Mathlib.Algebra.CharP.Lemmas
import Mathlib.Algebra.CharP.LinearMaps
import Mathlib.Algebra.CharP.LocalRing
import Mathlib.Algebra.CharP.MixedCharZero
import Mathlib.Algebra.CharP.Pi
Expand Down Expand Up @@ -222,6 +223,7 @@ import Mathlib.Algebra.Field.Subfield.Defs
import Mathlib.Algebra.Field.ULift
import Mathlib.Algebra.Free
import Mathlib.Algebra.FreeAlgebra
import Mathlib.Algebra.FreeAlgebra.Cardinality
import Mathlib.Algebra.FreeMonoid.Basic
import Mathlib.Algebra.FreeMonoid.Count
import Mathlib.Algebra.FreeMonoid.Symbols
Expand Down Expand Up @@ -280,7 +282,10 @@ import Mathlib.Algebra.Group.Int
import Mathlib.Algebra.Group.Invertible.Basic
import Mathlib.Algebra.Group.Invertible.Defs
import Mathlib.Algebra.Group.MinimalAxioms
import Mathlib.Algebra.Group.Nat
import Mathlib.Algebra.Group.Nat.Basic
import Mathlib.Algebra.Group.Nat.Even
import Mathlib.Algebra.Group.Nat.TypeTags
import Mathlib.Algebra.Group.Nat.Units
import Mathlib.Algebra.Group.NatPowAssoc
import Mathlib.Algebra.Group.Opposite
import Mathlib.Algebra.Group.PNatPowAssoc
Expand Down Expand Up @@ -321,7 +326,9 @@ import Mathlib.Algebra.Group.Subsemigroup.Membership
import Mathlib.Algebra.Group.Subsemigroup.Operations
import Mathlib.Algebra.Group.Support
import Mathlib.Algebra.Group.Translate
import Mathlib.Algebra.Group.TypeTags
import Mathlib.Algebra.Group.TypeTags.Basic
import Mathlib.Algebra.Group.TypeTags.Finite
import Mathlib.Algebra.Group.TypeTags.Hom
import Mathlib.Algebra.Group.ULift
import Mathlib.Algebra.Group.UniqueProds.Basic
import Mathlib.Algebra.Group.UniqueProds.VectorSpace
Expand Down Expand Up @@ -2501,7 +2508,6 @@ import Mathlib.Data.Int.Sqrt
import Mathlib.Data.Int.Star
import Mathlib.Data.Int.SuccPred
import Mathlib.Data.Int.WithZero
import Mathlib.Data.LazyList.Basic
import Mathlib.Data.List.AList
import Mathlib.Data.List.Basic
import Mathlib.Data.List.Chain
Expand Down Expand Up @@ -2886,6 +2892,7 @@ import Mathlib.Deprecated.Combinator
import Mathlib.Deprecated.Equiv
import Mathlib.Deprecated.Group
import Mathlib.Deprecated.HashMap
import Mathlib.Deprecated.LazyList
import Mathlib.Deprecated.Logic
import Mathlib.Deprecated.MinMax
import Mathlib.Deprecated.NatLemmas
Expand Down Expand Up @@ -2945,6 +2952,8 @@ import Mathlib.FieldTheory.IsAlgClosed.Classification
import Mathlib.FieldTheory.IsAlgClosed.Spectrum
import Mathlib.FieldTheory.IsPerfectClosure
import Mathlib.FieldTheory.IsSepClosed
import Mathlib.FieldTheory.Isaacs
import Mathlib.FieldTheory.JacobsonNoether
import Mathlib.FieldTheory.KrullTopology
import Mathlib.FieldTheory.KummerExtension
import Mathlib.FieldTheory.Laurent
Expand Down Expand Up @@ -3771,6 +3780,7 @@ import Mathlib.NumberTheory.LSeries.Linearity
import Mathlib.NumberTheory.LSeries.MellinEqDirichlet
import Mathlib.NumberTheory.LSeries.Nonvanishing
import Mathlib.NumberTheory.LSeries.Positivity
import Mathlib.NumberTheory.LSeries.PrimesInAP
import Mathlib.NumberTheory.LSeries.RiemannZeta
import Mathlib.NumberTheory.LSeries.ZMod
import Mathlib.NumberTheory.LegendreSymbol.AddCharacter
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Algebra/AddConstMap/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ variable {G : Type*} [AddMonoid G] {a : G}
as a monoid homomorphism from `Multiplicative G` to `G →+c[a, a] G`. -/
@[simps! (config := .asFn)]
def addLeftHom : Multiplicative G →* (G →+c[a, a] G) where
toFun c := Multiplicative.toAdd c +ᵥ .id
toFun c := c.toAdd +ᵥ .id
map_one' := by ext; apply zero_add
map_mul' _ _ := by ext; apply add_assoc

Expand Down
12 changes: 9 additions & 3 deletions Mathlib/Algebra/AddTorsor.lean
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ theorem constVAdd_add (v₁ v₂ : G) : constVAdd P (v₁ + v₂) = constVAdd P

/-- `Equiv.constVAdd` as a homomorphism from `Multiplicative G` to `Equiv.perm P` -/
def constVAddHom : Multiplicative G →* Equiv.Perm P where
toFun v := constVAdd P (Multiplicative.toAdd v)
toFun v := constVAdd P (v.toAdd)
map_one' := constVAdd_zero G P
map_mul' := constVAdd_add P

Expand Down Expand Up @@ -404,20 +404,26 @@ theorem pointReflection_involutive (x : P) : Involutive (pointReflection x : P

/-- `x` is the only fixed point of `pointReflection x`. This lemma requires
`x + x = y + y ↔ x = y`. There is no typeclass to use here, so we add it as an explicit argument. -/
theorem pointReflection_fixed_iff_of_injective_bit0 {x y : P} (h : Injective (2 • · : G → G)) :
theorem pointReflection_fixed_iff_of_injective_two_nsmul {x y : P} (h : Injective (2 • · : G → G)) :
pointReflection x y = y ↔ y = x := by
rw [pointReflection_apply, eq_comm, eq_vadd_iff_vsub_eq, ← neg_vsub_eq_vsub_rev,
neg_eq_iff_add_eq_zero, ← two_nsmul, ← nsmul_zero 2, h.eq_iff, vsub_eq_zero_iff_eq, eq_comm]

@[deprecated (since := "2024-11-18")] alias pointReflection_fixed_iff_of_injective_bit0 :=
pointReflection_fixed_iff_of_injective_two_nsmul

-- Porting note: need this to calm down CI
theorem injective_pointReflection_left_of_injective_bit0 {G P : Type*} [AddCommGroup G]
theorem injective_pointReflection_left_of_injective_two_nsmul {G P : Type*} [AddCommGroup G]
[AddTorsor G P] (h : Injective (2 • · : G → G)) (y : P) :
Injective fun x : P => pointReflection x y :=
fun x₁ x₂ (hy : pointReflection x₁ y = pointReflection x₂ y) => by
rwa [pointReflection_apply, pointReflection_apply, vadd_eq_vadd_iff_sub_eq_vsub,
vsub_sub_vsub_cancel_right, ← neg_vsub_eq_vsub_rev, neg_eq_iff_add_eq_zero,
← two_nsmul, ← nsmul_zero 2, h.eq_iff, vsub_eq_zero_iff_eq] at hy

@[deprecated (since := "2024-11-18")] alias injective_pointReflection_left_of_injective_bit0 :=
injective_pointReflection_left_of_injective_two_nsmul

end Equiv

theorem AddTorsor.subsingleton_iff (G P : Type*) [AddGroup G] [AddTorsor G P] :
Expand Down
14 changes: 10 additions & 4 deletions Mathlib/Algebra/Algebra/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,24 @@ end CommSemiring

section Ring

variable [CommRing R]
variable (R)

/-- A `Semiring` that is an `Algebra` over a commutative ring carries a natural `Ring` structure.
See note [reducible non-instances]. -/
abbrev semiringToRing [Semiring A] [Algebra R A] : Ring A :=
abbrev semiringToRing (R : Type*) [CommRing R] [Semiring A] [Algebra R A] : Ring A :=
{ __ := (inferInstance : Semiring A)
__ := Module.addCommMonoidToAddCommGroup R
intCast := fun z => algebraMap R A z
intCast_ofNat := fun z => by simp only [Int.cast_natCast, map_natCast]
intCast_negSucc := fun z => by simp }

instance {R : Type*} [Ring R] : Algebra (Subring.center R) R where
toFun := Subtype.val
map_one' := rfl
map_mul' _ _ := rfl
map_zero' := rfl
map_add' _ _ := rfl
commutes' r x := (Subring.mem_center_iff.1 r.2 x).symm
smul_def' _ _ := rfl

end Ring

end Algebra
Expand Down
43 changes: 43 additions & 0 deletions Mathlib/Algebra/Algebra/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,19 @@ def RingHom.toAlgebra' {R S} [CommSemiring R] [Semiring S] (i : R →+* S)
smul_def' _ _ := rfl
toRingHom := i

-- just simple lemmas for a declaration that is itself primed, no need for docstrings
set_option linter.docPrime false in
theorem RingHom.smul_toAlgebra' {R S} [CommSemiring R] [Semiring S] (i : R →+* S)
(h : ∀ c x, i c * x = x * i c) (r : R) (s : S) :
let _ := RingHom.toAlgebra' i h
r • s = i r * s := rfl

set_option linter.docPrime false in
theorem RingHom.algebraMap_toAlgebra' {R S} [CommSemiring R] [Semiring S] (i : R →+* S)
(h : ∀ c x, i c * x = x * i c) :
@algebraMap R S _ _ (i.toAlgebra' h) = i :=
rfl

/-- Creating an algebra from a morphism to a commutative semiring. -/
def RingHom.toAlgebra {R S} [CommSemiring R] [CommSemiring S] (i : R →+* S) : Algebra R S :=
i.toAlgebra' fun _ => mul_comm _
Expand Down Expand Up @@ -311,6 +324,36 @@ section

end

section compHom

variable (A) (f : S →+* R)

/--
Compose an `Algebra` with a `RingHom`, with action `f s • m`.
This is the algebra version of `Module.compHom`.
-/
abbrev compHom : Algebra S A where
smul s a := f s • a
toRingHom := (algebraMap R A).comp f
commutes' _ _ := Algebra.commutes _ _
smul_def' _ _ := Algebra.smul_def _ _

theorem compHom_smul_def (s : S) (x : A) :
letI := compHom A f
s • x = f s • x := rfl

theorem compHom_algebraMap_eq :
letI := compHom A f
algebraMap S A = (algebraMap R A).comp f := rfl

theorem compHom_algebraMap_apply (s : S) :
letI := compHom A f
algebraMap S A s = (algebraMap R A) (f s) := rfl

end compHom


variable (R A)

/-- The canonical ring homomorphism `algebraMap R A : R →+* A` for any `R`-algebra `A`,
Expand Down
3 changes: 1 addition & 2 deletions Mathlib/Algebra/Algebra/Unitization.lean
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,7 @@ def starLift : (A →⋆ₙₐ[R] C) ≃ (Unitization R A →⋆ₐ[R] C) :=
right_inv := fun φ => Unitization.algHom_ext'' <| by
simp }

-- Note (#6057) : tagging simpNF because linter complains
@[simp high, nolint simpNF]
@[simp high]
theorem starLift_symm_apply_apply (φ : Unitization R A →⋆ₐ[R] C) (a : A) :
Unitization.starLift.symm φ a = φ a :=
rfl
Expand Down
14 changes: 5 additions & 9 deletions Mathlib/Algebra/BigOperators/Finsupp.lean
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,17 @@ theorem prod_ite_eq [DecidableEq α] (f : α →₀ M) (a : α) (b : α → M
dsimp [Finsupp.prod]
rw [f.support.prod_ite_eq]

/- Porting note: simpnf linter, added aux lemma below
Left-hand side simplifies from
Finsupp.sum f fun x v => if a = x then v else 0
to
if ↑f a = 0 then 0 else ↑f a
-/
-- @[simp]
theorem sum_ite_self_eq [DecidableEq α] {N : Type*} [AddCommMonoid N] (f : α →₀ N) (a : α) :
(f.sum fun x v => ite (a = x) v 0) = f a := by
classical
convert f.sum_ite_eq a fun _ => id
simp [ite_eq_right_iff.2 Eq.symm]

-- Porting note: Added this thm to replace the simp in the previous one. Need to add [DecidableEq N]
/--
The left hand side of `sum_ite_self_eq` simplifies; this is the variant that is useful for `simp`.
-/
@[simp]
theorem sum_ite_self_eq_aux [DecidableEq α] {N : Type*} [AddCommMonoid N] (f : α →₀ N) (a : α) :
theorem if_mem_support [DecidableEq α] {N : Type*} [AddCommMonoid N] (f : α →₀ N) (a : α) :
(if a ∈ f.support then f a else 0) = f a := by
simp only [mem_support_iff, ne_eq, ite_eq_left_iff, not_not]
exact fun h ↦ h.symm
Expand All @@ -113,6 +108,7 @@ theorem prod_ite_eq' [DecidableEq α] (f : α →₀ M) (a : α) (b : α → M
dsimp [Finsupp.prod]
rw [f.support.prod_ite_eq']

/-- A restatement of `sum_ite_self_eq` with the equality test reversed. -/
theorem sum_ite_self_eq' [DecidableEq α] {N : Type*} [AddCommMonoid N] (f : α →₀ N) (a : α) :
(f.sum fun x v => ite (x = a) v 0) = f a := by
classical
Expand Down
12 changes: 6 additions & 6 deletions Mathlib/Algebra/BigOperators/Group/Finset.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2197,7 +2197,7 @@ variable [Monoid α]
theorem ofMul_list_prod (s : List α) : ofMul s.prod = (s.map ofMul).sum := by simp [ofMul]; rfl

@[simp]
theorem toMul_list_sum (s : List (Additive α)) : toMul s.sum = (s.map toMul).prod := by
theorem toMul_list_sum (s : List (Additive α)) : s.sum.toMul = (s.map toMul).prod := by
simp [toMul, ofMul]; rfl

end Monoid
Expand All @@ -2210,7 +2210,7 @@ variable [AddMonoid α]
theorem ofAdd_list_prod (s : List α) : ofAdd s.sum = (s.map ofAdd).prod := by simp [ofAdd]; rfl

@[simp]
theorem toAdd_list_sum (s : List (Multiplicative α)) : toAdd s.prod = (s.map toAdd).sum := by
theorem toAdd_list_sum (s : List (Multiplicative α)) : s.prod.toAdd = (s.map toAdd).sum := by
simp [toAdd, ofAdd]; rfl

end AddMonoid
Expand All @@ -2224,7 +2224,7 @@ theorem ofMul_multiset_prod (s : Multiset α) : ofMul s.prod = (s.map ofMul).sum
simp [ofMul]; rfl

@[simp]
theorem toMul_multiset_sum (s : Multiset (Additive α)) : toMul s.sum = (s.map toMul).prod := by
theorem toMul_multiset_sum (s : Multiset (Additive α)) : s.sum.toMul = (s.map toMul).prod := by
simp [toMul, ofMul]; rfl

@[simp]
Expand All @@ -2233,7 +2233,7 @@ theorem ofMul_prod (s : Finset ι) (f : ι → α) : ofMul (∏ i ∈ s, f i) =

@[simp]
theorem toMul_sum (s : Finset ι) (f : ι → Additive α) :
toMul (∑ i ∈ s, f i) = ∏ i ∈ s, toMul (f i) :=
(∑ i ∈ s, f i).toMul = ∏ i ∈ s, (f i).toMul :=
rfl

end CommMonoid
Expand All @@ -2248,7 +2248,7 @@ theorem ofAdd_multiset_prod (s : Multiset α) : ofAdd s.sum = (s.map ofAdd).prod

@[simp]
theorem toAdd_multiset_sum (s : Multiset (Multiplicative α)) :
toAdd s.prod = (s.map toAdd).sum := by
s.prod.toAdd = (s.map toAdd).sum := by
simp [toAdd, ofAdd]; rfl

@[simp]
Expand All @@ -2257,7 +2257,7 @@ theorem ofAdd_sum (s : Finset ι) (f : ι → α) : ofAdd (∑ i ∈ s, f i) =

@[simp]
theorem toAdd_prod (s : Finset ι) (f : ι → Multiplicative α) :
toAdd (∏ i ∈ s, f i) = ∑ i ∈ s, toAdd (f i) :=
(∏ i ∈ s, f i).toAdd = ∑ i ∈ s, (f i).toAdd :=
rfl

end AddCommMonoid
Expand Down
3 changes: 2 additions & 1 deletion Mathlib/Algebra/BigOperators/Group/List.lean
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,8 @@ theorem ranges_nodup {l s : List ℕ} (hs : s ∈ ranges l) : s.Nodup :=

/-- Any entry of any member of `l.ranges` is strictly smaller than `l.sum`. -/
lemma mem_mem_ranges_iff_lt_sum (l : List ℕ) {n : ℕ} :
(∃ s ∈ l.ranges, n ∈ s) ↔ n < l.sum := by simp [mem_mem_ranges_iff_lt_natSum]
(∃ s ∈ l.ranges, n ∈ s) ↔ n < l.sum := by
rw [← mem_range, ← ranges_flatten, mem_flatten]

@[simp]
theorem length_flatMap (l : List α) (f : α → List β) :
Expand Down
1 change: 1 addition & 0 deletions Mathlib/Algebra/Category/Grp/FiniteGrp.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Copyright (c) 2024 Jujian Zhang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jujian Zhang, Nailin Guan, Yuyang Zhao
-/
import Mathlib.Data.Finite.Defs
import Mathlib.Algebra.Category.Grp.Basic

/-!
Expand Down
Loading

0 comments on commit 5189bc2

Please sign in to comment.