Zulip Chat Archive

Stream: metaprogramming / tactics

Topic: Metavariables in types of local hypotheses


Eric Wieser (Jul 11 2023 at 13:25):

Is this expected behavior?

example :  (y : ), y  37  true :=
begin
  refine λ y hy, _,
  do {
    [y, hy]  tactic.local_context,
    t  infer_type hy,
    tactic.trace t.is_mvar },
  trivial
end

This traces tt, which foils attempts at matching on t syntactically

Eric Wieser (Jul 11 2023 at 13:27):

This isn't hypothetical: the following code fails because interval_cases expects infer_type not to contain metavariables:

import tactic.interval_cases

example :  y, y  37  true :=
begin
  refine λ y hy, _,  -- replace with `intros y hy` and it works
  interval_cases y,
  all_goals { trivial },
end

Jannis Limperg (Jul 11 2023 at 13:30):

Probably needs an instantiate_mvars. As a general rule, it's safer to assume that mvars are never fully instantiated except directly after instantiate_mvars.

Eric Wieser (Jul 11 2023 at 14:19):

So in general, matching against an expression without a instantiate_mvars is pretty much always a bug?

Jannis Limperg (Jul 11 2023 at 14:27):

Syntactic matching yes, very likely.

Eric Wieser (Jul 11 2023 at 14:29):

Another failure:

example :  (y : ), y  37  y < 40 :=
begin
  refine λ y hy, _,    -- replace with `intros y hy` and it works
  linarith
end

Eric Wieser (Jul 11 2023 at 22:24):

Fixed in !3#19232 and !3#19233

Eric Wieser (Jul 11 2023 at 22:25):

These won't need forward-porting, but for anyone still working on downstream projects in Lean 3 I think they're worth merging

Eric Wieser (Jul 12 2023 at 14:06):

Just found this old thread


Last updated: Dec 20 2023 at 11:08 UTC