File tree Expand file tree Collapse file tree 2 files changed +16
-12
lines changed
Expand file tree Collapse file tree 2 files changed +16
-12
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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+
518531elab_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
You can’t perform that action at this time.
0 commit comments