Skip to content

[Merged by Bors] - feat(Logic/Basic): forall_and_index#27737

Closed
ChrisHughes24 wants to merge 8 commits intoleanprover-community:masterfrom
ChrisHughes24:forall_and_left
Closed

[Merged by Bors] - feat(Logic/Basic): forall_and_index#27737
ChrisHughes24 wants to merge 8 commits intoleanprover-community:masterfrom
ChrisHughes24:forall_and_left

Conversation

@ChrisHughes24
Copy link
Copy Markdown
Member


A generalization of and_imp. It may cause a linter error because of the simp attribute. I wasn't that sure about the name.

Open in Gitpod

@ChrisHughes24 ChrisHughes24 changed the title feat(logic/basic): forall_prop_and_right feat(logic/basic): forall_prop_and_left Jul 31, 2025
@github-actions github-actions bot added the t-logic Logic (model theory, etc) label Jul 31, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 31, 2025

PR summary c776b599a9

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ forall_and_index
+ forall_and_index'

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

Copy link
Copy Markdown
Contributor

@grunweg grunweg left a comment

Choose a reason for hiding this comment

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

Thanks!
maintainer delegate

@grunweg grunweg changed the title feat(logic/basic): forall_prop_and_left feat(Logic/Basic): forall_prop_and_left Jul 31, 2025
@github-actions
Copy link
Copy Markdown

🚀 Pull request has been placed on the maintainer queue by grunweg.

@ghost ghost added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Jul 31, 2025
@plp127
Copy link
Copy Markdown
Contributor

plp127 commented Jul 31, 2025

Can you also add a backwards version
(∀ h : p ∧ q, r h.1 h.2) ↔ (∀ (hp : p) (hq : q), r hp hq)
It's useful when rewriting sometimes to have both of them.

@bryangingechen bryangingechen added the awaiting-author A reviewer has asked the author a question or requested changes. label Aug 1, 2025
@ChrisHughes24
Copy link
Copy Markdown
Member Author

Can you also add a backwards version (∀ h : p ∧ q, r h.1 h.2) ↔ (∀ (hp : p) (hq : q), r hp hq) It's useful when rewriting sometimes to have both of them.

I'm not sure about this. It would be very rarely used in the other direction, and more lemmas isn't always a good thing.

@ChrisHughes24
Copy link
Copy Markdown
Member Author

-awaiting-author

@github-actions github-actions bot removed the awaiting-author A reviewer has asked the author a question or requested changes. label Aug 1, 2025
@plp127
Copy link
Copy Markdown
Contributor

plp127 commented Aug 1, 2025

Can you also add a backwards version (∀ h : p ∧ q, r h.1 h.2) ↔ (∀ (hp : p) (hq : q), r hp hq) It's useful when rewriting sometimes to have both of them.

I'm not sure about this. It would be very rarely used in the other direction, and more lemmas isn't always a good thing.

I asked for this because we have both Finset.sum_product and Finset.sum_product', and we also have Finset.sum_product_right and Finset.sum_product_right', so to me this looks like it's doing the same thing but with forall instead of sum and and instead of product. So if it was a good idea for the finset sums I think it should also be a good idea for the foralls.

@plp127
Copy link
Copy Markdown
Contributor

plp127 commented Aug 1, 2025

I counted the uses of Finset.sum_product' with a script

import Mathlib

/-
MultilinearMap.domCoprod_alternization._simp_1_5
MonoidAlgebra.mul_apply_mul_eq_mul_of_uniqueMul._simp_1_1
AlgebraicTopology.AlternatingFaceMapComplex.d_squared._simp_1_1
Finset.expect_product'
PowerBasis.repr_mul_isIntegral
Finset.sum_smul_sum_eq_sum_perm
ArithmeticFunction.IsMultiplicative.mul
Matrix.induction_on'
Choose.choose_modEq_choose_mod_mul_choose_div
Fintype.sum_prod_type'
QuadraticMap.toQuadraticMap_toBilin._simp_1_1
Matrix.det_fromBlocks_zero₂₁._simp_1_1
Matrix.frobenius_nnnorm_diagonal._simp_1_1
-/
#eval do
  let env ← Lean.getEnv
  for i in env.constants do
    if i.2.isUnsafe then continue
    let some val := i.2.value? | continue
    if val.containsConst (· == ``Finset.sum_product') then
      Lean.logInfo (Lean.MessageData.ofConstName i.1)

so it's at least seeing some use in mathlib.

@ChrisHughes24
Copy link
Copy Markdown
Member Author

Can you also add a backwards version (∀ h : p ∧ q, r h.1 h.2) ↔ (∀ (hp : p) (hq : q), r hp hq) It's useful when rewriting sometimes to have both of them.

I'm not sure about this. It would be very rarely used in the other direction, and more lemmas isn't always a good thing.

I asked for this because we have both Finset.sum_product and Finset.sum_product', and we also have Finset.sum_product_right and Finset.sum_product_right', so to me this looks like it's doing the same thing but with forall instead of sum and and instead of product. So if it was a good idea for the finset sums I think it should also be a good idea for the foralls.

I've added the other version

@j-loreaux
Copy link
Copy Markdown
Contributor

Thanks!

bors merge

@ghost ghost added ready-to-merge This PR has been sent to bors. and removed maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. labels Aug 13, 2025
@j-loreaux
Copy link
Copy Markdown
Contributor

bors r-

@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Aug 13, 2025

Canceled.

@ghost ghost removed the ready-to-merge This PR has been sent to bors. label Aug 13, 2025
@j-loreaux
Copy link
Copy Markdown
Contributor

I'm not sure quite what went wrong when I hit merge. Can you merge master and make sure it builds?

bors d+

@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Aug 13, 2025

✌️ ChrisHughes24 can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@ghost ghost added the delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). label Aug 13, 2025
@ChrisHughes24
Copy link
Copy Markdown
Member Author

bors d-

@ChrisHughes24
Copy link
Copy Markdown
Member Author

I'm undelegating this, because one of the tests broke, so it should probably be checked again by somebody who understood what that test is for.

@ChrisHughes24
Copy link
Copy Markdown
Member Author

-delegated

@plp127
Copy link
Copy Markdown
Contributor

plp127 commented Aug 14, 2025

cc @JovanGerb

@JovanGerb
Copy link
Copy Markdown
Contributor

Oh, don't worry about that test too much. The test simply looks for all lemmas of a certain shape, and your new lemma now matches that shape, so it needs to be added.

@JovanGerb
Copy link
Copy Markdown
Contributor

Though I'm having trouble understanding what is "left" about forall_prop_and_left

@JovanGerb
Copy link
Copy Markdown
Contributor

Maybe it can be called forall_and_index, akin to forall_exists_index? Although that is a bit of a strange name too.

Also I think this should be labelled @[simp] instead of and_imp, but unfortunately we can't globally disable a core simp lemma.

@ChrisHughes24 ChrisHughes24 changed the title feat(Logic/Basic): forall_prop_and_left feat(Logic/Basic): forall_and_index Aug 16, 2025
@ChrisHughes24
Copy link
Copy Markdown
Member Author

bors r+

mathlib-bors bot pushed a commit that referenced this pull request Aug 16, 2025
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Aug 16, 2025

Build failed:

@bryangingechen
Copy link
Copy Markdown
Contributor

Failure looks like a temporary network issue?
bors r+

@ghost ghost added the ready-to-merge This PR has been sent to bors. label Aug 16, 2025
mathlib-bors bot pushed a commit that referenced this pull request Aug 16, 2025
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Aug 16, 2025

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat(Logic/Basic): forall_and_index [Merged by Bors] - feat(Logic/Basic): forall_and_index Aug 16, 2025
@mathlib-bors mathlib-bors bot closed this Aug 16, 2025
Julian added a commit to Aaron1011/mathlib4 that referenced this pull request Aug 16, 2025
* origin/master: (508 commits)
  feat(Logic/Basic): forall_and_index (leanprover-community#27737)
  feat(Algebra/intNorm): `x` divides `intNorm x` (leanprover-community#28021)
  feat(RingTheory/MvPolynomial/MonomialOrder): some lemmas about degree (leanprover-community#26000)
  chore: more elementary Motzkin polynomial proof (leanprover-community#28482)
  feat: e-seminormed monoid (leanprover-community#27385)
  feat(RingTheory): ` (⊥ : Ideal R) ^ n = ⊥` (leanprover-community#28171)
  fix(LinearAlgebra/Dimension/ErdosKaplansky): authorship (leanprover-community#28513)
  chore: golf entire `X_pow_eq_monomial` (leanprover-community#28504)
  feat(RingTheory): invertible modules and Picard group (leanprover-community#25337)
  chore: use delta `deriving` for leanprover-community#380 (leanprover-community#28498)
  feat: add bilinear maps for vector/matrix products (leanprover-community#28130)
  feat(Counterexamples): topologists' sine curve (leanprover-community#25833)
  feat(Analysis/Convex): doubly stochastic matrices have operator norm at most one (leanprover-community#28453)
  chore(Topology/Compactification): deprecate duplicate `ultrafilter_pure_injective` (leanprover-community#28436)
  feat: add `@[simp]` to `Multiset.cons_le_cons` and `Finset.insert_subset_insert` (leanprover-community#28285)
  feat: make `ring` work for semifields (leanprover-community#28494)
  feat: filtering lists and bounded quantifiers are primitive recursive (leanprover-community#26295)
  chore(Analysis/Analytic): split `Analytic.Basic` (leanprover-community#26270)
  refactor: tidy `mulVec` and `vecMul` lemmas about `•` (leanprover-community#28450)
  feat(Order/WellFounded): Acc and infinite descending chain (leanprover-community#28120)
  feat(NumberTheory/Padics): {Int,Rat}.padicValuation (leanprover-community#27667)
  chore(*): address a few timeout-related porting notes (leanprover-community#28483)
  feat(Algebra): toAlgebra_algebraMap (leanprover-community#28238)
  feat(Shrink): `IsCancelMul` instance (leanprover-community#28407)
  chore(Geometry): golf entire `chart_eq'` and `orthogonalProjection_orthogonalProjection` (leanprover-community#28485)
  feat: shifted geometric series and a `ProbabilityMeasure` version of `measure_iUnion_le` (leanprover-community#28087)
  chore(LinearAlgebra/PiTensorProduct): `rw` away use of `erw` in `lifts_zero` (leanprover-community#27554)
  feat(RingTheory): faithfully flat ring maps (leanprover-community#24530)
  chore(Geometry/RingedSpace): remove use of `erw` in `stalkSpecializes_stalkMap` (leanprover-community#27656)
  chore: add the Brownian motion project to downstream_repos.yml (leanprover-community#28459)
  feat(CategoryTheory/Sites/SheafOfTypes): composition of a sheaf with uliftFunctor is still a sheaf (leanprover-community#27816)
  feat(Valuation/DiscreteValuationRel): val relations with compatible valuations to Zm0 are IsDiscrete (leanprover-community#27213)
  chore(*): process a bunch of `aesop`-related porting notes (leanprover-community#28402)
  feat(CategoryTheory): abstract argument for the stability under transfinite compositions (leanprover-community#26030)
  chore: bump toolchain to v4.23.0-rc2 (leanprover-community#28454)
  chore(FieldTheory/Finite): fermat's little theorem in Nat form (leanprover-community#27962)
  feat(Combinatorics/SimpleGraph/Paths): add theorem `SimpleGraph.Walk.IsPath.concat` (leanprover-community#27582)
  feat(Slope): slope_pos_iff_of_le and related lemmas (leanprover-community#28039)
  feat: tactic analysis framework (leanprover-community#26683)
  chore(Data/EReal): deprecate `add_pos_of_nonneg_of_pos` and `add_ne_top_iff_of_ne_bot` (duplicates) (leanprover-community#28424)
  feat(MathlibTest/FieldSimp): add a few more tests (leanprover-community#28413)
  chore(RingTheory/HahnSeries): deprecate duplicate `orderTop_add_orderTop_le_orderTop_mul` (leanprover-community#28231)
  chore(AlgebraicGeometry/IdealSheaf): deprecate duplicate `AlgebraicGeometry.Scheme.IdealSheafData.Scheme.zeroLocus_radical` (leanprover-community#28202)
  feat(Algebra/Order): ArchimedeanClass ball (leanprover-community#27885)
  chore(Geometry/RingedSpace): remove use of `erw` in `isUnit_of_isUnit_germ` (leanprover-community#27660)
  feat(SkewMonoidAlgebra): coeff_mul lemmas (leanprover-community#27255)
  chore(LinearAlgebra): golf entire `isUnit_det` (leanprover-community#28438)
  chore(FieldTheory/IntermediateField): golf entire `coe_sum` and `coe_prod` (leanprover-community#28431)
  feat: separate linter error message for empty doc-strings (leanprover-community#27895)
  feat(RingTheory/PowerSeries/Binomial): add basic lemmas, golf (leanprover-community#27497)
  ...
Paul-Lez pushed a commit to Paul-Lez/mathlib4 that referenced this pull request Aug 23, 2025
pechersky pushed a commit to pechersky/mathlib4 that referenced this pull request Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). ready-to-merge This PR has been sent to bors. t-logic Logic (model theory, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants