# In logic programming, what would a language with second-order model theory gain?

HiLog is described as a logic programming language with higher-order syntax, but first-order model theory.

For example, it allows you to define a map over lists:

maplist(F)([],[]).
maplist(F)([X|R],[Y|Z]) <- F(X,Y), maplist(F)(R,Z).


On the second line, F is a predicate, because it's used in F(X, Y), and ∀F is implied, because F is capitalized.

I'm trying to develop an intuition for what's missing here. What would an actual second-order logic programming language let me do that HiLog does not?

It's worth noting that the limitations of first-order logic do not necessarily apply to first-order logic programming languages. For example, Prolog can trivially express the ancestor relation, while the standard first-order logic cannot.

This question is about the limitations of HiLog, as a programming language.

• the easiest way to see the difference between Second Order logic and First Order logic (like set theory) is that in the SO the second sort is semantically required to be really subsets of the first sort, and all of them; where in FO that is not true. E.g. in FO there is no way to define the set of natural numbers N, as there are always nonstandard models. In SO, it is easy to define N and the minimal inductive set. In FO this doesn't hold since the second sort might be interpreted to in nonstandard ways. Mar 30 at 17:54
• @Kaveh It's my understanding that ZFC axioms are FO. If you add them, this lets you express all (or almost all?) of mathematics (Not really my area of expertise)
– MWB
Mar 31 at 15:24
• ZFC has nonstandard models, the set of natural numbers N is not definable in ZFC. Any formula you use to define natural numbers in ZFC will have models which contains nonstandard members that are not in N. You even have countable models for ZFC. In SO because the quantifier for the second order must be the actual power set of N, you can define N. Mar 31 at 18:47
• @Kaveh: Some people "require" SO semantics to be a certain thing, but SO kicks & screams and wants to be freed. Henkin understood that, and so do categorical logicians. Mar 31 at 21:57

An actual second-order logic programming language would allow you to use second-order quantifiers in a computationally meaningful way. Second-order logic without quantifiers ranging over second-order symbols is conservative over first-order logic (if I remember correctly, someone please correct me if I am wrong).

HiLog seems to be an old language, which to me it just looks like a precursor of λ-prolog, a modern way of adding higher-order features to prolog. I wouldn't spend too much time worrying about what someone thought about its semantics in 1989.

• Logic programming is not really logic: math.stackexchange.com/questions/3894192 . This is why I find appeals to properties of various logics rather unconvincing (and, but this is my fault, occasionally incomprehensible, as I never studied SOL). I'm hoping to see answers that illustrate what's missing in HiLog, from the programming language perspective.
– MWB
Apr 1 at 20:44
• Haskell/Lisp/Scheme/ML let you define a map function over singly-linked lists. Is maplist in the question more limited in any way, and if so, how? Is there anything else that's conveniently done in functional programming languages, but cannot be done in HiLog?
– MWB
Apr 1 at 20:53
• You have never studied second-order logic, and you're asking about it on a forum that is meant to be for research-level questions? I think your question is better suited for cs.stackexchange.com. Apr 3 at 23:33
• "a precursor of λ-prolog" λ-prolog predates HiLog by 2 years.
– MWB
Apr 4 at 6:46
• "allow you to use second-order quantifiers in a computationally meaningful way." But HiLog allows you to use second-order quantifiers, and it's computationally meaningful (no other way to define maplist in pure Prolog)
– MWB
Apr 4 at 16:23