2

If I have a subset of logic programming which contains only one function symbol, am I able to do everything?

I think that I cannot but I am not sure at all. A programming language can do anything user wants if it is a Turing-complete language. I was taught that this means it has to be able to execute if..then..else commands, recursion and that natural numbers should be defined.

Any help and opinions would be appreciated!

Blacklight Shining
  • 1,468
  • 2
  • 11
  • 28
Nanc
  • 464
  • 5
  • 15
  • http://en.wikipedia.org/wiki/Functional_completeness: if you have nand or nor as a binary function, you should be able to compute any Turing computable function. – user1666959 Jul 22 '14 at 18:10
  • So in your opinion, if this function symbol is about nand or nor, my subset is a Turing complete language? – Nanc Jul 22 '14 at 18:16
  • @user1666959: It's a big stretch from being able to express any Boolean function to being Turing complete. The article you link says nothing about Turing completeness of nand (or nor). – hardmath Jul 22 '14 at 21:12
  • @Nancy: Logic programming is about predicates, at least in "pure" Prolog. It's not clear how function symbols enter into the language except as extensions. For example, the arithmetic operators require `is/2` to force evaluation; otherwise they are simply functors. – hardmath Jul 22 '14 at 21:14
  • @Nancy: I also have a similar concern as that expressed by hardmath - IIRC first order predicate logic introduces 'functions' from N arguments to truth value - we call those 'functors' in Prolog, and we can't have just one, as they carry identity. – CapelliC Jul 22 '14 at 22:09
  • @hardmath: So would it be correct to assume that the Herbrand universe of this subset is limited because the functors are limited (in my case only one)? I suppose it would, wouldn't it? – Nanc Jul 23 '14 at 09:39
  • @Nancy and anyone else interested: I created [a chat room](http://chat.stackoverflow.com/rooms/57827/logic-programming-w-one-function-symbol) for this topic to clarify what exactly is meant, and I upvoted Nancy's Q since I suspect 20 reputation are required to post in chat. – hardmath Jul 23 '14 at 11:29
  • @Nancy: If you visit chat.stackoverflow.com, then I think I can give you write access to the chat. I've already given you read access. – hardmath Jul 23 '14 at 11:34
  • @user1666959 the functional completeness of nand/xor means, that givin this as an operator for propositional logic, you can express every function over the booleans. This is not the same as restricting the language in first-order logic. The semantic of the logical operators (and/or/not) is fixed, only the interpretation of additional predicate/function symbol is variable. – lambda.xy.x Jul 23 '14 at 17:50

1 Answers1

5

In classical predicate logic, there is a distinction between the formula level and the term level. Since an n-ary function can be represented as an (n+1)-ary predicate, restricting only the number of function symbols does not lessen the expressivity.

In prolog, there is no difference between the formula and the term level. You might pick an n-ary symbol p and try to encode turing machines or an equivalent notion(e.g. recursive functions) via nestings of p.

From my intution I would assume this is not possible: you can basically describe n-ary trees with variables as leaves, but then you can always unify these trees. This means that every rule head will match during recursive derivations and therefore you are unable to express any case distinction. Still, this is just an informal argument, not a proof.

P.S. you might also be interested in monadic logic, where only unary predicates are allowed. This fragment of first-order logic is decidable.

lambda.xy.x
  • 4,918
  • 24
  • 35
  • Thank you for your answer. I haven't thought about trees and I think you have a point. – Nanc Jul 24 '14 at 10:12
  • 2
    Just as an addition: this is some kind of implicit reasoning on the Herbrand universe - in the case of one symbol, the label of each node in the term tree is just the same. – lambda.xy.x Jul 25 '14 at 10:00