Skip to content

Commit

Permalink
Merge branch 'tmp' into lean-pr-testing-2778
Browse files Browse the repository at this point in the history
This folds in the changes from #8291
  • Loading branch information
eric-wieser committed Nov 9, 2023
2 parents 7569392 + ca50860 commit 9af36fb
Show file tree
Hide file tree
Showing 83 changed files with 2,037 additions and 1,213 deletions.
4 changes: 2 additions & 2 deletions Mathlib.lean
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,6 @@ import Mathlib.Algebra.Order.Kleene
import Mathlib.Algebra.Order.LatticeGroup
import Mathlib.Algebra.Order.Module
import Mathlib.Algebra.Order.Monoid.Basic
import Mathlib.Algebra.Order.Monoid.Cancel.Basic
import Mathlib.Algebra.Order.Monoid.Cancel.Defs
import Mathlib.Algebra.Order.Monoid.Canonical.Defs
import Mathlib.Algebra.Order.Monoid.Defs
import Mathlib.Algebra.Order.Monoid.Lemmas
Expand Down Expand Up @@ -1917,6 +1915,7 @@ import Mathlib.Data.String.Lemmas
import Mathlib.Data.Subtype
import Mathlib.Data.Sum.Basic
import Mathlib.Data.Sum.Interval
import Mathlib.Data.Sum.Lattice
import Mathlib.Data.Sum.Order
import Mathlib.Data.Sym.Basic
import Mathlib.Data.Sym.Card
Expand Down Expand Up @@ -2469,6 +2468,7 @@ import Mathlib.MeasureTheory.Decomposition.Jordan
import Mathlib.MeasureTheory.Decomposition.Lebesgue
import Mathlib.MeasureTheory.Decomposition.RadonNikodym
import Mathlib.MeasureTheory.Decomposition.SignedHahn
import Mathlib.MeasureTheory.Decomposition.SignedLebesgue
import Mathlib.MeasureTheory.Decomposition.UnsignedHahn
import Mathlib.MeasureTheory.Function.AEEqFun
import Mathlib.MeasureTheory.Function.AEEqFun.DomAct
Expand Down
8 changes: 8 additions & 0 deletions Mathlib/Algebra/Algebra/Hom.lean
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,14 @@ theorem ofId_apply (r) : ofId R A r = algebraMap R A r :=
rfl
#align algebra.of_id_apply Algebra.ofId_apply

/-- This is a special case of a more general instance that we define in a later file. -/
instance subsingleton_id : Subsingleton (R →ₐ[R] A) :=
fun f g => AlgHom.ext fun _ => (f.commutes _).trans (g.commutes _).symm⟩

/-- This ext lemma closes trivial subgoals create when chaining heterobasic ext lemmas. -/
@[ext high]
theorem ext_id (f g : R →ₐ[R] A) : f = g := Subsingleton.elim _ _

end Algebra

namespace MulSemiringAction
Expand Down
24 changes: 19 additions & 5 deletions Mathlib/Algebra/BigOperators/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Multiset.Powerset
import Mathlib.Data.Set.Pairwise.Basic

#align_import algebra.big_operators.basic from "leanprover-community/mathlib"@"fa2309577c7009ea243cffdf990cd6c84f0ad497"
#align_import algebra.big_operators.basic from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83"

/-!
# Big operators
Expand Down Expand Up @@ -187,6 +187,12 @@ theorem prod_eq_multiset_prod [CommMonoid β] (s : Finset α) (f : α → β) :
#align finset.prod_eq_multiset_prod Finset.prod_eq_multiset_prod
#align finset.sum_eq_multiset_sum Finset.sum_eq_multiset_sum

@[to_additive (attr := simp)]
lemma prod_map_val [CommMonoid β] (s : Finset α) (f : α → β) : (s.1.map f).prod = ∏ a in s, f a :=
rfl
#align finset.prod_map_val Finset.prod_map_val
#align finset.sum_map_val Finset.sum_map_val

@[to_additive]
theorem prod_eq_fold [CommMonoid β] (s : Finset α) (f : α → β) :
∏ x in s, f x = s.fold ((· * ·) : β → β → β) 1 f :=
Expand Down Expand Up @@ -1775,11 +1781,19 @@ theorem sum_const_nat {m : ℕ} {f : α → ℕ} (h₁ : ∀ x ∈ s, f x = m) :
apply sum_congr rfl h₁
#align finset.sum_const_nat Finset.sum_const_nat

lemma natCast_card_filter [AddCommMonoidWithOne β] (p) [DecidablePred p] (s : Finset α) :
((filter p s).card : β) = ∑ a in s, if p a then (1 : β) else 0 := by
rw [sum_ite, sum_const_zero, add_zero, sum_const, nsmul_one]
#align finset.nat_cast_card_filter Finset.natCast_card_filter

lemma card_filter (p) [DecidablePred p] (s : Finset α) :
(filter p s).card = ∑ a in s, ite (p a) 1 0 := natCast_card_filter _ _
#align finset.card_filter Finset.card_filter

@[simp]
theorem sum_boole {s : Finset α} {p : α → Prop} [NonAssocSemiring β] {hp : DecidablePred p} :
(∑ x in s, if p x then (1 : β) else (0 : β)) = (s.filter p).card := by
simp only [add_zero, mul_one, Finset.sum_const, nsmul_eq_mul, eq_self_iff_true,
Finset.sum_const_zero, Finset.sum_ite, mul_zero]
lemma sum_boole {s : Finset α} {p : α → Prop} [AddCommMonoidWithOne β] [DecidablePred p] :
(∑ x in s, if p x then 1 else 0 : β) = (s.filter p).card :=
(natCast_card_filter _ _).symm
#align finset.sum_boole Finset.sum_boole

theorem _root_.Commute.sum_right [NonUnitalNonAssocSemiring β] (s : Finset α) (f : α → β) (b : β)
Expand Down
12 changes: 10 additions & 2 deletions Mathlib/Algebra/BigOperators/Order.lean
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Mathlib.Algebra.BigOperators.Basic
import Mathlib.Data.Fintype.Card
import Mathlib.Tactic.GCongr.Core

#align_import algebra.big_operators.order from "leanprover-community/mathlib"@"824f9ae93a4f5174d2ea948e2d75843dd83447bb"
#align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83"

/-!
# Results about big operators with values in an ordered algebraic structure.
Expand Down Expand Up @@ -208,13 +208,21 @@ theorem single_le_prod' (hf : ∀ i ∈ s, 1 ≤ f i) {a} (h : a ∈ s) : f a
#align finset.single_le_prod' Finset.single_le_prod'
#align finset.single_le_sum Finset.single_le_sum

@[to_additive]
lemma mul_le_prod {i j : ι} (hf : ∀ i ∈ s, 1 ≤ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i ≠ j) :
f i * f j ≤ ∏ k in s, f k :=
calc
f i * f j = ∏ k in .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton]
_ ≤ ∏ k in s, f k := by
refine prod_le_prod_of_subset_of_one_le' ?_ fun k hk _ ↦ hf k hk
simp [cons_subset, *]

@[to_additive sum_le_card_nsmul]
theorem prod_le_pow_card (s : Finset ι) (f : ι → N) (n : N) (h : ∀ x ∈ s, f x ≤ n) :
s.prod f ≤ n ^ s.card := by
refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _
· simpa using h
· simp
rfl
#align finset.prod_le_pow_card Finset.prod_le_pow_card
#align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul

Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Algebra/Order/Group/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Copyright (c) 2016 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Leonardo de Moura, Mario Carneiro, Johannes Hölzl
-/
import Mathlib.Algebra.Order.Monoid.Cancel.Defs
import Mathlib.Algebra.Order.Monoid.Defs
import Mathlib.Algebra.Order.Sub.Defs
import Mathlib.Order.Hom.Basic

Expand Down
27 changes: 27 additions & 0 deletions Mathlib/Algebra/Order/Monoid/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,33 @@ def Function.Injective.linearOrderedCommMonoid [LinearOrderedCommMonoid α] {β
#align function.injective.linear_ordered_comm_monoid Function.Injective.linearOrderedCommMonoid
#align function.injective.linear_ordered_add_comm_monoid Function.Injective.linearOrderedAddCommMonoid

/-- Pullback an `OrderedCancelCommMonoid` under an injective map.
See note [reducible non-instances]. -/
@[to_additive (attr := reducible) Function.Injective.orderedCancelAddCommMonoid
"Pullback an `OrderedCancelAddCommMonoid` under an injective map."]
def Function.Injective.orderedCancelCommMonoid [OrderedCancelCommMonoid α] [One β] [Mul β] [Pow β ℕ]
(f : β → α) (hf : Injective f) (one : f 1 = 1) (mul : ∀ x y, f (x * y) = f x * f y)
(npow : ∀ (x) (n : ℕ), f (x ^ n) = f x ^ n) : OrderedCancelCommMonoid β :=
{ hf.orderedCommMonoid f one mul npow with
le_of_mul_le_mul_left := fun a b c (bc : f (a * b) ≤ f (a * c)) ↦
(mul_le_mul_iff_left (f a)).mp (by rwa [← mul, ← mul]) }
#align function.injective.ordered_cancel_comm_monoid Function.Injective.orderedCancelCommMonoid
#align function.injective.ordered_cancel_add_comm_monoid Function.Injective.orderedCancelAddCommMonoid

/-- Pullback a `LinearOrderedCancelCommMonoid` under an injective map.
See note [reducible non-instances]. -/
@[to_additive (attr := reducible) Function.Injective.linearOrderedCancelAddCommMonoid
"Pullback a `LinearOrderedCancelAddCommMonoid` under an injective map."]
def Function.Injective.linearOrderedCancelCommMonoid [LinearOrderedCancelCommMonoid α] [One β]
[Mul β] [Pow β ℕ] [Sup β] [Inf β] (f : β → α) (hf : Injective f) (one : f 1 = 1)
(mul : ∀ x y, f (x * y) = f x * f y) (npow : ∀ (x) (n : ℕ), f (x ^ n) = f x ^ n)
(hsup : ∀ x y, f (x ⊔ y) = max (f x) (f y)) (hinf : ∀ x y, f (x ⊓ y) = min (f x) (f y)) :
LinearOrderedCancelCommMonoid β :=
{ hf.linearOrderedCommMonoid f one mul npow hsup hinf,
hf.orderedCancelCommMonoid f one mul npow with }
#align function.injective.linear_ordered_cancel_comm_monoid Function.Injective.linearOrderedCancelCommMonoid
#align function.injective.linear_ordered_cancel_add_comm_monoid Function.Injective.linearOrderedCancelAddCommMonoid

-- TODO find a better home for the next two constructions.
/-- The order embedding sending `b` to `a * b`, for some fixed `a`.
See also `OrderIso.mulLeft` when working in an ordered group. -/
Expand Down
61 changes: 0 additions & 61 deletions Mathlib/Algebra/Order/Monoid/Cancel/Basic.lean

This file was deleted.

115 changes: 0 additions & 115 deletions Mathlib/Algebra/Order/Monoid/Cancel/Defs.lean

This file was deleted.

Loading

0 comments on commit 9af36fb

Please sign in to comment.