Skip to content

Commit 89ce8bf

Browse files
committed
feat(Tactic): convert discharges side goals reducibly (#39928)
This PR implements the main behaviour change from #39039: `convert` now discharges side goals at reducible transparency. `convert!`, which we previously switched all calls inside Mathlib to, keeps the old behaviour of working at default transparency. (Everything discussed in this PR holds analogously for the other tactics in the family: `convert_to` and `ac_change`). The main trick in this PR is in allowing `convert!` to have different configuration options than `convert`, but still allow the user to override those options too. So `convert! (postTransparency := .instances)` will have transparency set to `.instances`, not `.default`. We achieve this by having two new structures that copy `Congr!.Config` but set different default values, and choosing between the corresponding elaborators for those configs based on the presence of an `!`. I got this trick from Jovan's #38071 which also changes settings in `Convert.Config`. This PR should be mostly compatible with #38071 and I'd like to get both this one and #38071 in before wrapping up #39039 by replacing unnecessary calls to `convert!` with `convert`. Co-authored-by: Anne C.A. Baanen <vierkantor@vierkantor.com>
1 parent 01cc327 commit 89ce8bf

47 files changed

Lines changed: 173 additions & 63 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Counterexamples/Phillips.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ theorem exists_discrete_support_nonpos (f : BoundedAdditiveMeasure α) :
283283
have I1 : ∀ n, ε / 2 ≤ f (↑(s (n + 1)) \ ↑(s n)) := by
284284
intro n
285285
rw [div_le_iff₀' (show (0 : ℝ) < 2 by simp), hε]
286-
convert hF (s n) u using 2
286+
convert! hF (s n) u using 2
287287
· ext x
288288
simp only [u, not_exists, mem_iUnion, mem_diff]
289289
tauto

Mathlib/Algebra/Lie/Weights/Chain.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ lemma exists_forall_mem_corootSpace_smul_add_eq_zero
239239
subst a b N
240240
erw [LinearMap.trace_eq_sum_trace_restrict_of_eq_biSup _ h₁ h₂ (genWeightSpaceChain M α χ p q) h₃]
241241
simp_rw [LieSubmodule.toEnd_restrict_eq_toEnd]
242-
convert_to _ =
242+
convert_to! _ =
243243
∑ k ∈ Finset.Ioo p q, (LinearMap.trace R { x // x ∈ (genWeightSpace M (k • α + χ)) })
244244
((toEnd R { x // x ∈ H } { x // x ∈ genWeightSpace M (k • α + χ) }) x)
245245
simp_rw [trace_toEnd_genWeightSpace, Pi.add_apply, Pi.smul_apply, smul_add,

Mathlib/Algebra/Lie/Weights/Killing.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ lemma finrank_rootSpace_eq_one (α : Weight K H L) (hα : α.IsNonZero) :
608608
finrank K (rootSpace H α) = 1 := by
609609
suffices ¬ 1 < finrank K (rootSpace H α) by
610610
have h₀ : finrank K (rootSpace H α) ≠ 0 := by
611-
convert_to finrank K (rootSpace H α).toSubmodule ≠ 0
611+
convert_to! finrank K (rootSpace H α).toSubmodule ≠ 0
612612
simpa using! α.genWeightSpace_ne_bot
613613
lia
614614
intro contra

Mathlib/Algebra/SkewPolynomial/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ lemma coeff_X_of_ne_one {n : ℕ} (hn : n ≠ 1) : coeff (X : SkewPolynomial R)
360360
rw [coeff_X, if_neg hn.symm]
361361

362362
lemma coeff_C : coeff (C a) n = ite (n = 0) a 0 := by
363-
convert coeff_monomial using 2; simp [eq_comm]
363+
convert! coeff_monomial using 2; simp [eq_comm]
364364

365365
@[simp] lemma coeff_C_zero : coeff (C a) 0 = a := coeff_monomial
366366

Mathlib/AlgebraicGeometry/Cover/Open.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ lemma OpenCover.pullbackCoverAffineRefinementObjIso_inv_pullbackHom
193193
simp only [Cover.pullbackHom, pullbackCoverAffineRefinementObjIso, Iso.trans_inv, asIso_inv,
194194
Iso.symm_inv, Category.assoc, pullbackSymmetry_inv_comp_snd, IsIso.inv_comp_eq, limit.lift_π,
195195
PullbackCone.mk_π_app, Category.comp_id]
196-
convert pullbackSymmetry_inv_comp_fst ((𝒰.X i.1).affineCover.f i.2) (pullback.fst _ _)
196+
convert! pullbackSymmetry_inv_comp_fst ((𝒰.X i.1).affineCover.f i.2) (pullback.fst _ _)
197197
exact pullbackRightPullbackFstIso_hom_fst _ _ _
198198

199199
/-- A family of elements spanning the unit ideal of `R` gives an affine open cover of `Spec R`. -/

Mathlib/AlgebraicGeometry/Morphisms/UniversallyOpen.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ nonrec instance (priority := low) [IsIntegral Y] [Subsingleton Y] :
167167
obtain ⟨ψ, rfl⟩ := Spec.map_surjective g
168168
algebraize [φ.hom, ψ.hom]
169169
refine (MorphismProperty.cancel_left_of_respectsIso _ (pullbackSpecIso K R S).inv _).mp ?_
170-
convert_to topologically _ (Spec.map <| CommRingCat.ofHom (algebraMap R (TensorProduct K R S)))
170+
convert_to! topologically _ (Spec.map <| CommRingCat.ofHom (algebraMap R (TensorProduct K R S)))
171171
· exact pullbackSpecIso_inv_fst ..
172172
let := hK.toField
173173
exact PrimeSpectrum.isOpenMap_comap_algebraMap_tensorProduct_of_field

Mathlib/AlgebraicGeometry/Normalization.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ instance [IsIntegralHom f] : IsIso f.toNormalization := by
290290
rw [← MorphismProperty.cancel_left_of_respectsIso (.isomorphisms _)
291291
(e ≪≫ (U.2.preimage f).isoSpec).inv]
292292
letI := (f.app U.1).hom.toAlgebra
293-
convert_to IsIso (Spec.map (CommRingCat.ofHom
293+
convert_to! IsIso (Spec.map (CommRingCat.ofHom
294294
(integralClosure Γ(Y, U.1) Γ(X, f ⁻¹ᵁ U.1)).val.toRingHom))
295295
· rw [← cancel_mono (f.normalizationOpenCover.f U), ← cancel_epi (U.2.preimage f).isoSpec.hom]
296296
simp [e, -Iso.cancel_iso_hom_left, IsAffineOpen.isoSpec_hom,

Mathlib/AlgebraicGeometry/OpenImmersion.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ theorem _root_.AlgebraicGeometry.isIso_iff_isIso_stalkMap {X Y : Scheme.{u}} (f
468468
IsOpenImmersion.iff_isIso_stalkMap, and_comm, ← and_assoc]
469469
refine and_congr ⟨?_, ?_⟩ Iff.rfl
470470
· rintro ⟨h₁, h₂⟩
471-
convert_to
471+
convert_to!
472472
IsIso
473473
(TopCat.isoOfHomeo
474474
(Equiv.toHomeomorphOfContinuousOpen

Mathlib/AlgebraicGeometry/PointsPi.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ lemma isIso_of_comp_eq_sigmaSpec {V : Scheme}
8888
infer_instance
8989
obtain ⟨I, e, rfl⟩ := IsClosedImmersion.Spec_iff.mp this
9090
obtain rfl := eq_bot_of_comp_quotientMk_eq_sigmaSpec R I (f ≫ e.hom) (by rwa [Category.assoc])
91-
convert_to IsIso (e.hom ≫ Spec.map (RingEquiv.quotientBot _).toCommRingCatIso.inv)
91+
convert_to! IsIso (e.hom ≫ Spec.map (RingEquiv.quotientBot _).toCommRingCatIso.inv)
9292
infer_instance
9393

9494
variable (X : Scheme)

Mathlib/AlgebraicGeometry/StructureSheaf.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ theorem comapₗ_eq_localRingHom (f : R →+* S) (U : Opens (PrimeSpectrum.Top R
10791079
induction m using LocalizedModule.induction_on with | h m s =>
10801080
trans LocalizedModule.mk (f m) ⟨f ↑s, s.2
10811081
· simp
1082-
convert_to Localization.mk _ _ = Localization.localRingHom _ _ _ _ (Localization.mk _ _)
1082+
convert_to! Localization.mk _ _ = Localization.localRingHom _ _ _ _ (Localization.mk _ _)
10831083
simp [Localization.mk_eq_mk']
10841084

10851085
/-- For a ring homomorphism `f : R →+* S` and open sets `U` and `V` of the prime spectra of `R` and
@@ -1124,7 +1124,7 @@ theorem comap_const (f : R →+* S) (U : Opens (PrimeSpectrum.Top R))
11241124
const (f a) (f b) V fun p hpV => hb (PrimeSpectrum.comap f p) (hUV hpV) :=
11251125
Subtype.ext <| funext fun p => by
11261126
rw [comap_apply, const_apply, const_apply]
1127-
convert_to Localization.localRingHom _ _ _ _ (Localization.mk _ _) = Localization.mk _ _
1127+
convert_to! Localization.localRingHom _ _ _ _ (Localization.mk _ _) = Localization.mk _ _
11281128
simp [Localization.mk_eq_mk']
11291129

11301130
/-- For an inclusion `i : V ⟶ U` between open sets of the prime spectrum of `R`, the comap of the

0 commit comments

Comments
 (0)