4

What does ?- mean in Prolog?

for example:

?- consult(solve)
false
  • 10,264
  • 13
  • 101
  • 209
hpn
  • 2,222
  • 2
  • 16
  • 23
  • You can check the link [here](http://en.wikipedia.org/wiki/Prolog#Rules_and_facts) Good luck! – Kds23 Jan 06 '13 at 18:14

2 Answers2

4

?- is typically the prompt of the top level loop or top level shell — which is the place where you can ask queries and enter commands. It has similar functionality as the read-eval-print loop in other languages.

In some systems this prompt is or used to be | ?- which is the more traditional prompt. This prompt comes from one of the earlier Prolog systems of ~1978, DECsystem 10 Prolog. The OS prompt for input was | and the user had to type ?- X is 1+1. to enter a query.

false
  • 10,264
  • 13
  • 101
  • 209
2

Within a prolog interpreter you can request data (that's basically running prolog scripts), the system replies with a yes or no. The interpreter signals with ?-, that he awaits a request.

Example:

?- male(adam).
yes.
?- male(eve).
no.

Read more in the wikipedia article for it

Bjoern
  • 15,934
  • 4
  • 43
  • 48
  • I see this in a script. I want to know why programmer has written `?-` before the command. why doesn't he write `consult(solve)` without "?-" ? – hpn Jan 06 '13 at 18:25
  • My first thought would be he wants to demonstrate the execution of his script. Without seeing it though hard to guess. – Bjoern Jan 06 '13 at 18:35