Zulip Chat Archive
Stream: lean4
Topic: Elaborate ‹...›
Marcus Rossel (Jan 03 2024 at 13:32):
How does one correctly elaborate a term of the form ‹...›
. The following example doesn't work:
import Lean
open Lean Meta Elab Term
elab "test" t:term : tactic => do
let ex ← elabTerm t none
let ty ← inferType ex
IO.println (← ppExpr ex)
IO.println (← ppExpr ty)
example (h : ∀ x : Nat, x = x) : True := by
test ‹∀ _, _›
-- ?m.1242
-- (x : ?m.1237) → ?m.1241 x
Also, adding instantiateMVars
didn't help.
Yaël Dillies (Jan 03 2024 at 13:33):
Does ‹∀ _ : ℕ, _›
work?
Marcus Rossel (Jan 03 2024 at 13:33):
Nope
Yaël Dillies (Jan 03 2024 at 13:34):
and ‹∀ _ : ℕ, _ = _›
?
Yaël Dillies (Jan 03 2024 at 13:35):
I think you're just hitting the limitations of higher order unification.
Marcus Rossel (Jan 03 2024 at 13:35):
Also nope. Even going full ‹∀ x : Nat, x = x›
doesn't work.
But writing something like have g := ‹_›
figures out that g
is h
, so I don't think unification is the problem here.
Alex J. Best (Jan 03 2024 at 13:50):
You code is using Term.elabTerm
, if you use Tactic.elabTerm
instead it works
Marcus Rossel (Jan 03 2024 at 13:54):
Thanks! What can Tactic.elabTerm
do that Term.elabTerm
can't? I.e. when should one use one over the other?
Mario Carneiro (Jan 03 2024 at 14:00):
Tactic.elabTerm
wraps Term.elabTerm
in withSynthesize
, which synthesizes delayed metavariables. ‹T›
is syntax for (by assumption : T)
and by
always creates a delayed metavariable, so you have to call withSynthesize
or synthesizeSyntheticMVarsNoPostponing
to actually get it to resolve
Last updated: May 02 2025 at 03:31 UTC