Thats exactly where old Prolog ideas have left out, land in
a computer museum, and new Prolog ideas such as λ-Prolog
start, not only the work by @stassa.p but also the Prolog^2
work by James Trewern. While old Prolog ideas have invested
incredible amount of work into this thingy here which waits
for an individual value V, i.e. a value V e D from a first
order theory domain D to arrive:
https://softwarepreservation.computerhistory.org/prolog/#BNR
Delay is only a operational varying interpretation, but its still
a first order interpretation. What 2nd order learning for goals
and clauses basically somehow demands would be:

Where V^2 is a 2nd order variable, with values V^2 e D^2
from a second order domain D^2 so to speak. Here are
some examples, following @stassa.p I drop ^2, you can
identify second order variables by their predicate position:
/* first order */
freeze(X, X > 3)
/* second order */
freeze(Q, Q(3))
Loosly speaking a 2nd order logic can do 2nd order freeze,
since a logic definition itself has no operational definition. It
usually talks about “what” is , and not “how” it is.
But for 2nd order logic MIL, to make it fly, we can either do what
@stassa.p did, look at CONSTRUCT and find that inside the
CONSTRUCT box there is a SLD search. Or we can ask what
is the box itself? What inference rules guard the box itself?
BTW: About the ^2 notation. 2nd order logic uses two sorts
of variables, first order variables V and second order variables V^2.
They belong to two different ontological commitments.
Sometimes it makes it extremly hard to talk about second
order logic, since these ontological commitments are in the
way, for example for the first order natural numbers n e N, that
are countably infinite many, then the predicates P(n) are
uncountably infinite many. But @stassa.p work and others
work doesn’t go that far, its anyways 2nd order quantifier
elimination, turning V^2 variables into V variables somehow.
But who knows, maybe this work will also attract dust, and
land in a computer museum, like λ-Prolog itself. But somehow
I believe a Prolog to Prolog^2 transition is currently in full bloom.

