I have this situation:
val term = ...
val app_term = term $ t1 $ t2
term contains schematic type variables. Is there a function that constructs app_term with instantiated schematic type variables?
The instantiation should use the types of t1 and t2 accordingly.
Hmm, I think maybe you want type inference. Don't know all that much about it though to be honest. Maybe search for "schematic" in the Isabelle cookbook.
(inb4 have fun with flex-flex pairs :D)
there should'nt be any flex-flex pairs since there is only one schematic type variable that only occurs in term :fingers_crossed:
if "term" is something whose type you know, I would just compute the type
e.g. if "term" where addition, you should write an ML function mk_add : typ -> term
that does something like mk_add T = Const (@{const_name "Groups.add"}, T --> T --> T)
.
That's the way it's done in the library.
I'd only use actual type inference with schematic variables and whatever if you absolutely have to
Depends a bit where this "term" thing comes from, I guess.
Ok, I'll try to do it without type inference, thanks for the hint.
one common pattern is also to specify the type of the function as dummyT
and then do a Syntax.check_term
to let type inference fill in the type
that doesn't seem to work in the presence of schematic variables though and I never really understood why
I think you have to tag them somehow to tell type inference that it is allowed to fill them in
Manuel Eberl said:
one common pattern is also to specify the type of the function as
dummyT
and then do aSyntax.check_term
to let type inference fill in the type
Cool, I am using that now.
Last updated: Dec 21 2024 at 12:33 UTC