-
Lean/Elab/Tactic/Simp.lean:
"simp " (config)? (discharger)? ("only ")? ("[" simpLemma,* "]")? (location)?@[builtinTactic Lean.Parser.Tactic.simp] def evalSimp : Tactic := fun stx => do let { ctx, fvarIdToLemmaId, dischargeWrapper } ← withMainContext <| mkSimpContext stx (eraseLocal := false)
-- trace[Meta.debug] "Lemmas {← toMessageData ctx.simpLemmas.post}"
let loc := expandOptLocation stx[5]
match loc with
| Location.targets hUserNames simplifyTarget =><| mkSimpContext stx (eraseLocal := false)
-- trace[Meta.debug] "Lemmas {← toMessageData ctx.simpLemmas.post}"
let loc := expandOptLocation stx[5]
match loc with
| Location.targets hUserNames simplifyTarget => withMainContext do<| mkSimpContext stx (eraseLocal := false)
-- trace[Meta.debug] "Lemmas {← toMessageData ctx.simpLemmas.post}"
let loc := expandOptLocation stx[5]
match loc with
| Location.targets hUserNames simplifyTarget => let fvarIds ← hUserNames.mapM fun hUserName => return (← getLocalDeclFromUserName hUserName).fvarId<| mkSimpContext stx (eraseLocal := false)
-- trace[Meta.debug] "Lemmas {← toMessageData ctx.simpLemmas.post}"
let loc := expandOptLocation stx[5]
match loc with
| Location.targets hUserNames simplifyTarget => go ctx dischargeWrapper fvarIds simplifyTarget fvarIdToLemmaId<| mkSimpContext stx (eraseLocal := false)
-- trace[Meta.debug] "Lemmas {← toMessageData ctx.simpLemmas.post}"
let loc := expandOptLocation stx[5]
match loc with
| Location.targets hUserNames simplifyTarget => | Location.wildcard =><| mkSimpContext stx (eraseLocal := false)
-- trace[Meta.debug] "Lemmas {← toMessageData ctx.simpLemmas.post}"
let loc := expandOptLocation stx[5]
match loc with
| Location.targets hUserNames simplifyTarget => withMainContext do<| mkSimpContext stx (eraseLocal := false)
-- trace[Meta.debug] "Lemmas {← toMessageData ctx.simpLemmas.post}"
let loc := expandOptLocation stx[5]
match loc with
| Location.targets hUserNames simplifyTarget => go ctx dischargeWrapper (← getNondepPropHyps (← getMainGoal)) (simplifyTarget := true) fvarIdToLemmaId<| mkSimpContext stx (eraseLocal := false)
-- trace[Meta.debug] "Lemmas {← toMessageData ctx.simpLemmas.post}"
let loc := expandOptLocation stx[5]
match loc with
| Location.targets hUserNames simplifyTarget =>where<| mkSimpContext stx (eraseLocal := false)
-- trace[Meta.debug] "Lemmas {← toMessageData ctx.simpLemmas.post}"
let loc := expandOptLocation stx[5]
match loc with
| Location.targets hUserNames simplifyTarget => go (ctx : Simp.Context) (dischargeWrapper : Simp.DischargeWrapper) (fvarIdsToSimp : Array FVarId) (simplifyTarget : Bool) (fvarIdToLemmaId : FVarIdToLemmaId) : TacticM Unit := do<| mkSimpContext stx (eraseLocal := false)
-- trace[Meta.debug] "Lemmas {← toMessageData ctx.simpLemmas.post}"
let loc := expandOptLocation stx[5]
match loc with
| Location.targets hUserNames simplifyTarget => let mvarId ← getMainGoal<| mkSimpContext stx (eraseLocal := false)
-- trace[Meta.debug] "Lemmas {← toMessageData ctx.simpLemmas.post}"
let loc := expandOptLocation stx[5]
match loc with
| Location.targets hUserNames simplifyTarget => let result? ← dischargeWrapper.with fun discharge? => return (← simpGoal mvarId ctx (simplifyTarget := simplifyTarget) (discharge? := discharge?) (fvarIdsToSimp := fvarIdsToSimp) (fvarIdToLemmaId := fvarIdToLemmaId)).map (·.2)<| mkSimpContext stx (eraseLocal := false)
-- trace[Meta.debug] "Lemmas {← toMessageData ctx.simpLemmas.post}"
let loc := expandOptLocation stx[5]
match loc with
| Location.targets hUserNames simplifyTarget => match result? with<| mkSimpContext stx (eraseLocal := false)
-- trace[Meta.debug] "Lemmas {← toMessageData ctx.simpLemmas.post}"
let loc := expandOptLocation stx[5]
match loc with
| Location.targets hUserNames simplifyTarget => | none => replaceMainGoal []<| mkSimpContext stx (eraseLocal := false)
-- trace[Meta.debug] "Lemmas {← toMessageData ctx.simpLemmas.post}"
let loc := expandOptLocation stx[5]
match loc with
| Location.targets hUserNames simplifyTarget => | some mvarId => replaceMainGoal [mvarId]