Skip to content

Commit

Permalink
chore: compatibility with Lean incrementality branch (#12796)
Browse files Browse the repository at this point in the history
Backward-compatible fixes for leanprover/lean4#3940. In particular, gets rid of two `open private` (out of six in all of Mathlib) which in my opinion really were not necessary and just invited breakage.

Somehow the unused variables and unnecessary `have` linters became *more* complete, which might be due to earlier mvar instantiation in `Elab.MutualDef` but I haven't investigated deeply.
  • Loading branch information
Kha authored and apnelson1 committed May 12, 2024
1 parent 858568d commit 38b54e1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Mathlib/Algebra/CharZero/Lemmas.lean
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ section RingHom

variable {R S : Type*} [NonAssocSemiring R] [NonAssocSemiring S]

theorem RingHom.charZero (ϕ : R →+* S) [hS : CharZero S] : CharZero R :=
theorem RingHom.charZero (ϕ : R →+* S) [CharZero S] : CharZero R :=
fun a b h => CharZero.cast_injective (by rw [← map_natCast ϕ, ← map_natCast ϕ, h])⟩
#align ring_hom.char_zero RingHom.charZero

Expand Down
1 change: 0 additions & 1 deletion Mathlib/LinearAlgebra/Semisimple.lean
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ theorem IsSemisimple.minpoly_squarefree : Squarefree (minpoly K f) :=
protected theorem IsSemisimple.aeval (p : K[X]) : (aeval f p).IsSemisimple :=
let R := K[X] ⧸ Ideal.span {minpoly K f}
have : Finite K R := (AdjoinRoot.powerBasis' <| minpoly.monic <| isIntegral f).finite
have : IsArtinianRing R := .of_finite K R
have : IsReduced R := (Ideal.isRadical_iff_quotient_reduced _).mp <|
span_minpoly_eq_annihilator K f ▸ hf.annihilator_isRadical
isSemisimple_of_squarefree_aeval_eq_zero ((minpoly.isRadical K _).squarefree <|
Expand Down
7 changes: 6 additions & 1 deletion Mathlib/Tactic/Cases.lean
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ Prefer `cases` or `rcases` when possible, because these tactics promote structur
namespace Mathlib.Tactic
open Lean Meta Elab Elab.Tactic

open private getAltNumFields in evalCases ElimApp.evalAlts.go in
private def getAltNumFields (elimInfo : ElimInfo) (altName : Name) : TermElabM Nat := do
for altInfo in elimInfo.altsInfo do
if altInfo.name == altName then
return altInfo.numFields
throwError "unknown alternative name '{altName}'"

def ElimApp.evalNames (elimInfo : ElimInfo) (alts : Array ElimApp.Alt) (withArg : Syntax)
(numEqs := 0) (generalized : Array FVarId := #[]) (toClear : Array FVarId := #[])
(toTag : Array (Ident × FVarId) := #[]) :
Expand Down
26 changes: 16 additions & 10 deletions Mathlib/Tactic/Recall.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Copyright (c) 2023 Mac Malone. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mac Malone, Kyle Miller
-/
import Lean.Elab.MutualDef
import Batteries.Tactic.OpenPrivate
import Lean.Elab.Command
import Lean.Elab.DeclUtil

/-!
# `recall` command
Expand Down Expand Up @@ -35,7 +35,6 @@ recall Nat.add_comm {n m : Nat} : n + m = m + n
syntax (name := recall) "recall " ident ppIndent(optDeclSig) (declVal)? : command

open Lean Meta Elab Command Term
open private elabHeaders from Lean.Elab.MutualDef

elab_rules : command
| `(recall $id $sig:optDeclSig $[$val?]?) => withoutModifyingEnv do
Expand Down Expand Up @@ -63,10 +62,17 @@ elab_rules : command
throwErrorAt val err
else
let (binders, type?) := expandOptDeclSig sig
let views := #[{
declId := newId, binders, type?, value := .missing,
ref := ← getRef, kind := default, modifiers := {} : DefView}]
liftTermElabM do
let elabView := (← elabHeaders views)[0]!
unless (← isDefEq info.type elabView.type) do
throwTypeMismatchError none info.type elabView.type declConst
if let some type := type? then
runTermElabM fun vars => do
withAutoBoundImplicit do
elabBinders binders.getArgs fun xs => do
let xs ← addAutoBoundImplicits xs
let type ← elabType type
Term.synthesizeSyntheticMVarsNoPostponing
let type ← mkForallFVars xs type
let type ← mkForallFVars vars type (usedOnly := true)
unless (← isDefEq info.type type) do
throwTypeMismatchError none info.type type declConst
else
unless binders.getNumArgs == 0 do
throwError "expected type after ':'"
2 changes: 1 addition & 1 deletion Mathlib/Tactic/Says.lean
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def evalTacticCapturingMessages (tac : TSyntax `tactic) (only : Message → Bool
try
evalTactic tac
let (capture, leave) := (← getThe Core.State).messages.msgs.toList.partition only
msgs := leave.foldl (fun m => m.push) msgs.msgs⟩
msgs := leave.foldl (·.add) msgs
return capture
catch e =>
msgs := msgs ++ (← getThe Core.State).messages
Expand Down

0 comments on commit 38b54e1

Please sign in to comment.