Zulip Chat Archive

Stream: general

Topic: calling a tactic "by name"?


Scott Morrison (Sep 19 2019 at 06:48):

I'd like to tell one of my tactics to try calling norm_num, but not have to import norm_num myself.

Scott Morrison (Sep 19 2019 at 06:48):

In particular, I'd like my call to norm_num to just fail if norm_num hasn't actually been imported by the time I invoke it.

Scott Morrison (Sep 19 2019 at 06:48):

Is there some trickery with pre-expressions that will let me do this?

Keeley Hoek (Sep 19 2019 at 06:49):

Definitely.

Keeley Hoek (Sep 19 2019 at 06:49):

You want to eval_expr an expr which corresponds to the norm_num tactic, which you build only if you can resolve the name in tactic.interactive.

Keeley Hoek (Sep 19 2019 at 06:50):

Then you can just execute it.

Scott Morrison (Sep 19 2019 at 06:52):

Oh.. tidy.lean actually contains name_to_tactic

Scott Morrison (Sep 19 2019 at 06:52):

which maybe does exactly this

Mario Carneiro (Sep 19 2019 at 06:52):

You can more reliably test existence using resolve_name

Scott Morrison (Sep 19 2019 at 06:52):

I should git blame that line and see if I wrote it ...

Mario Carneiro (Sep 19 2019 at 06:53):

If you just eval_expr it then you won't be able to tell whether it failed because norm_num failed or norm_num doesn't exist

Scott Morrison (Sep 19 2019 at 06:53):

In this use case, I actually don't care much. :-)

Keeley Hoek (Sep 19 2019 at 07:20):

Yeah sorry to be clear, I meant to check for existence before you build the expr. But ok.

Keeley Hoek (Sep 19 2019 at 07:24):

By the way, that function name_to_tactic looks broken to me. I'm going to push a fix. (If I recall =ₐ means equals-ignoring-binders, which is just wrong.) Nope, it's equals ignoring binder names! This does nothing in this case, but I suppose makes more sense.


Last updated: Dec 20 2023 at 11:08 UTC