Skip to content

Commit fc5f646

Browse files
committed
fix
1 parent bf20145 commit fc5f646

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

Mathlib/Data/Fin/VecNotation.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ open Lean Qq
145145
146146
`let ⟨xs, tailn, tail⟩ ← matchVecConsPrefix n e` decomposes `e : Fin n → _` in the form
147147
`vecCons x₀ <| ... <| vecCons xₙ <| tail` where `tail : Fin tailn → _`. -/
148-
meta def matchVecConsPrefix (n : Q(Nat)) (e : Expr) : MetaM <| List Expr × Q(Nat) × Expr := do
148+
meta partial def matchVecConsPrefix (n : Q(Nat)) (e : Expr) :
149+
MetaM <| List Expr × Q(Nat) × Expr := do
149150
match_expr ← Meta.whnfR e with
150151
| Matrix.vecCons _ n x xs => do
151152
let (elems, n', tail) ← matchVecConsPrefix n xs

Mathlib/Tactic/Linarith/Frontend.lean

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,19 @@ elab_rules : tactic
515515
let cfg := (← elabLinarithConfig cfg).updateReducibility bang.isSome
516516
commitIfNoEx do liftMetaFinishingTactic <| Linarith.linarith o.isSome args.toList cfg
517517

518+
private meta partial def minimize (cfg : Linarith.LinarithConfig) (st : Tactic.SavedState)
519+
(hs : List Expr) (i : Nat) : TacticM (List Expr) := do
520+
let g ← getMainGoal
521+
if _h : i < hs.length then
522+
let rest := hs.eraseIdx i
523+
st.restore
524+
try
525+
let _ ← Linarith.linarith true rest cfg g
526+
minimize cfg st rest i
527+
catch _ => minimize cfg st hs (i+1)
528+
else
529+
return hs
530+
518531
elab_rules : tactic
519532
| `(tactic| linarith?%$tk $[!%$bang]? $cfg:optConfig $[only%$o]? $[[$args,*]]?) =>
520533
withMainContext do
@@ -530,17 +543,7 @@ elab_rules : tactic
530543
throwError "linarith? currently only supports named hypothesis, not terms"
531544
let used ←
532545
if cfg.minimize then
533-
let rec minimize (hs : List Expr) (i : Nat) : TacticM (List Expr) := do
534-
if _h : i < hs.length then
535-
let rest := hs.eraseIdx i
536-
st.restore
537-
try
538-
let _ ← Linarith.linarith true rest cfg g
539-
minimize rest i
540-
catch _ => minimize hs (i+1)
541-
else
542-
return hs
543-
minimize used₀ 0
546+
minimize cfg st used₀ 0
544547
else
545548
pure used₀
546549
st.restore

0 commit comments

Comments
 (0)