Zulip Chat Archive
Stream: Is there code for X?
Topic: metavariable
Frédéric Le Roux (Dec 16 2020 at 22:22):
Is there a tactic that check if the target contains a metavariable?
Rob Lewis (Dec 16 2020 at 22:26):
In interactive mode or for metaprogramming?
Rob Lewis (Dec 16 2020 at 22:26):
expr.has_meta_var <$> tactic.target
for the latter.
Frédéric Le Roux (Dec 16 2020 at 22:26):
It would be better for me in interactive mode...
Rob Lewis (Dec 16 2020 at 22:27):
With what behavior? Failing if there is a metavariable?
Frédéric Le Roux (Dec 16 2020 at 22:27):
Yes, that would be perfect
(I want to combine this with any tactic, to avoid using a tactic if it leads to metavariables in the target)
Rob Lewis (Dec 16 2020 at 22:30):
I don't think it's in the library but
meta def tactic.interactive.no_meta_vars : tactic unit :=
mwhen (expr.has_meta_var <$> tactic.target) $ tactic.fail "target contains metavars"
example : ∃ x : ℕ, x = 0 :=
begin
existsi _,
no_meta_vars
end
Frédéric Le Roux (Dec 16 2020 at 22:31):
Great, many thanks!
Rob Lewis (Dec 16 2020 at 22:34):
Better:
meta def tactic.interactive.no_meta_vars : tactic unit :=
mwhen (expr.has_meta_var <$> (tactic.target >>= tactic.instantiate_mvars)) $ tactic.fail "target contains metavars"
Last updated: Dec 20 2023 at 11:08 UTC