C++/C does not need higher order interpretation. Inheritance and
overriding are simply modelled in first order. The modelling
can be derived from John McCarthy's circumscription.
It has not yet much transpired that Prolog can be also used in
a higher order fashion. But the most easiest way to do
higher order programming is by way of the call/n predicates. Here
you find a definition of a map predicate:
% map(+Function,+List,-List)
map(_,[],[]).
map(F,[X|Y],[Z|T]) :- call(F,X,Z), map(F,Y,T).
In the above example call/3 is used to add two additional arguments
to the closure F and then invoke the resulting term. Yes F can
be closure and not only a function symbol. In the simple case a
non-function symbol is a compound that carries additional data:
% plus(+Number,+Number,-Number)
plus(X,Y,Z) :- Z is X+Y.
We can then do the following:
?- map(plus(4),[1,2,3],X).
X = [5, 6, 7]
?- map(plus(4.56),[1,2,3],X).
X = [5.56, 6.56, 7.56]
call/n are not yet part of the ISO core standard, but they might become in the near future [1]. A lot of Prolog systems already support them. The call/n is already quite
old, it must have been invented around 1984 [2]. The closure can also be used to allow
lambda abstraction.
There are a couple of proposals for lambda abstraction. We find the one from Ulrich Neumerkel which mainly uses a new operator +/2 [3], or as part of Logtalk
Paulo Moura uses a syntax based on the operator >>/2 [4].
I started using the operator ^/2 in Jekejeke Prolog [5] with a slight different
semantic than the one from Ulrich and Paulo, namely local variables need explicit quantification. On the other hand global variables are then automatically determined.
With the ^/2 operator we do not need to define closure predicates. In the above example we do not need to define plus/3 and can directly do:
?- map(A^B^(B is A+4),[1,2,3],X).
X = [5, 6, 7]
?- map(A^B^(B is A+4.56),[1,2,3],X).
X = [5.56, 6.56, 7.56]
The most closest logical interpretation is probably predicate abstraction and not function abstraction. Predicate abstraction is related to the comprehension axiom
in set theory. But it can be also done with the lambda notation. An original source
is for example [6].
Best Regards
[1]
Draft Technical Corrigendum 2
http://www.complang.tuwien.ac.at/ulrich/iso-prolog/dtc2#call
[2]
Mycroft, O'Keefe A polymorphic type system for Prolog, AI Journal, August 1984
[3]
http://www.complang.tuwien.ac.at/ulrich/Prolog-inedit/ISO-Hiord.html
[4]
http://blog.logtalk.org/2009/12/lambda-expressions-in-logtalk/
[5]
http://www.jekejeke.ch/idatab/doclet/prod/en/docs/05_run/10_docu/05_frequent/07_theories/03_standard/01_apply.html
[6]
Dag Prawitz (1965), Natural Deduction, A Proof-Theoretical Study
See section V: Ramified 2nd Order Logic