Skip to content

Commit

Permalink
fix: wlog: don't supply let vars to mkAppN (#5362)
Browse files Browse the repository at this point in the history
`wlog` was erroneously supplying all reverted fvars to `mkAppN`, instead of just supplying the ones which weren't ldecls. This fixes #5348.
  • Loading branch information
thorimur committed Jun 28, 2023
1 parent e703ae8 commit ddf819c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Mathlib/Tactic/WLOG.lean
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ def _root_.Lean.MVarId.wlog (goal : MVarId) (h : Option Name) (P : Expr)
let (⟨easyGoal, hyp⟩, ⟨reductionGoal, negHyp⟩) ←
reductionGoal.byCases P <| if inaccessible then `_ else h
easyGoal.withContext do
-- Exclude ldecls from the `mkAppN` arguments
let HArgFVarIds ← revertedFVars.filterM (notM ·.isLetVar)
let HApp ← instantiateMVars <|
mkAppN (.fvar HFVarId) (revertedFVars.map .fvar) |>.app (.fvar hyp)
mkAppN (.fvar HFVarId) (HArgFVarIds.map .fvar) |>.app (.fvar hyp)
ensureHasNoMVars HApp
easyGoal.assign HApp
return ⟨reductionGoal, (HFVarId, negHyp), hGoal, hFVar, revertedFVars⟩
Expand Down
7 changes: 7 additions & 0 deletions test/wlog.lean
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,10 @@ example {x y : ℕ} : True := by
guard_hyp h : x ≤ y
guard_target =ₛ True
trivial

-- Handle ldecls properly:
example (x y : ℕ) : True := by
let z := 0
wlog hxy' : z ≤ y with H
· trivial
· trivial

0 comments on commit ddf819c

Please sign in to comment.