@@ -220,17 +220,19 @@ Finally, `borelize α β γ` runs `borelize α; borelize β; borelize γ`.
220
220
-/
221
221
syntax "borelize" (ppSpace colGt term:max)* : tactic
222
222
223
- /-- Add instances `borel $t : MeasurableSpace $t` and `⟨rfl⟩ : BorelSpace $t`. -/
224
- def addBorelInstance (t : Term) : TacticM Unit := do
223
+ /-- Add instances `borel e : MeasurableSpace e` and `⟨rfl⟩ : BorelSpace e`. -/
224
+ def addBorelInstance (e : Expr) : TacticM Unit := do
225
+ let t ← Lean.Elab.Term.exprToSyntax e
225
226
evalTactic <| ← `(tactic|
226
227
refine_lift
227
228
letI : MeasurableSpace $t := borel $t
228
229
haveI : BorelSpace $t := ⟨rfl⟩
229
230
?_)
230
231
231
- /-- Given a type `$t`, an assumption `i : MeasurableSpace $t`, and an instance `[BorelSpace $t]`,
232
- replace `i` with `borel $t`. -/
233
- def borelToRefl (t : Term) (i : FVarId) : TacticM Unit := do
232
+ /-- Given a type `e`, an assumption `i : MeasurableSpace e`, and an instance `[BorelSpace e]`,
233
+ replace `i` with `borel e`. -/
234
+ def borelToRefl (e : Expr) (i : FVarId) : TacticM Unit := do
235
+ let t ← Lean.Elab.Term.exprToSyntax e
234
236
evalTactic <| ← `(tactic|
235
237
have := @BorelSpace.measurable_eq $t _ _ _)
236
238
liftMetaTactic fun m => return [← subst m i]
@@ -242,11 +244,11 @@ def borelToRefl (t : Term) (i : FVarId) : TacticM Unit := do
242
244
/-- Given a type `$t`, if there is an assumption `[i : MeasurableSpace $t]`, then try to prove
243
245
`[BorelSpace $t]` and replace `i` with `borel $t`. Otherwise, add instances
244
246
`borel $t : MeasurableSpace $t` and `⟨rfl⟩ : BorelSpace $t`. -/
245
- def borelize (t : Term) : TacticM Unit := do
247
+ def borelize (t : Term) : TacticM Unit := withMainContext <| do
246
248
let u ← mkFreshLevelMVar
247
- let e ← Tactic.elabTermEnsuringType t (mkSort (mkLevelSucc u))
249
+ let e ← withoutRecover <| Tactic.elabTermEnsuringType t (mkSort (mkLevelSucc u))
248
250
let i? ← findLocalDeclWithType? (← mkAppOptM ``MeasurableSpace #[e])
249
- i?.elim (addBorelInstance t ) (borelToRefl t )
251
+ i?.elim (addBorelInstance e ) (borelToRefl e )
250
252
251
253
elab_rules : tactic
252
254
| `(tactic| borelize $[$t:term]*) => t.forM borelize
0 commit comments