Closed MartyO256 closed 3 months ago
The way Beluga deals with with out-of-scope metavariables is kind of weird. It doesn't immediately produce an error, because there's one situation where free metavariables are actually important, and that's in type signatures where they are automatically abstracted. So internally, what one has to do is explicitly to forbid free variables by scanning the term to see if there are any.
So the reason you get a recursive call not structurally smaller error is that internally [|- Q]
is a free variable and you're using it in the first argument of a recursive call, which must be unifiable with one of the generated valid recursive calls. The free variable won't unify with anything, so Beluga just thinks you tried a bogus recursive call.
I think that to resolve this, one needs to explicitly forbid free metavariables in any box embedded in a Beluga expression.
Closed by #266. The free meta-variable Q
is disallowed.
Theorem: trans
intros <- split x (case leq_s) <- split x1 (case leq_s)
Meta-context:
X : ( |- nat)
X1 : ( |- nat)
X4 : ( |- nat)
X2 : ( |- leq X X1)
X5 : ( |- leq X1 X4)
Computational context:
x : [ |- leq (s X) (s X1)]
x1 : [ |- leq (s X1) (s X4)]
--------------------------------------------------------------------------------
[ |- leq (s X) (s X4)]
> by trans [ |- Q] [ |- X5] as L unboxed
File "<prompt>", line 1, column 15
Error: This free meta-variable is illegal.
Load the following signature:
There is no meta-variable
Q
in the the remaining subgoal's context. Usingby trans [ |- Q] [ |- X5] as L unboxed
results in a "Recursive call not structurally smaller" error as opposed to an "Unbound meta-level identifier: Q" error.