Zulip Chat Archive

Stream: general

Topic: unexpected local in quotation expression


Scott Morrison (Mar 02 2019 at 23:14):

Simple expr question: how do I turn a nat into an expression?

Scott Morrison (Mar 02 2019 at 23:14):

I'm writing a tactic, I have an explicit nat argument, and I want to assertv some lemma, applied to that particular nat.

Scott Morrison (Mar 02 2019 at 23:14):

e.g. if n : expr, and a : nat, I tried writing to_expr `(trichotomy %%n a), but I get a "unexpected local in quotation expression" error at the a.

Scott Morrison (Mar 02 2019 at 23:14):

Curiously, the only search result for that error is that line in the source code.

Chris Hughes (Mar 02 2019 at 23:25):

This works for me.

meta def f (n : ) (e : expr): expr :=
`(nat.add %%e %%`(n))

def g :  := by tactic.exact (f 5 `(1))

#eval g

Scott Morrison (Mar 02 2019 at 23:37):

Thanks!

Scott Morrison (Mar 03 2019 at 03:09):

Documented at https://github.com/leanprover-community/mathlib/pull/786


Last updated: Dec 20 2023 at 11:08 UTC