<s>
Prolog	B-Language
is	O
a	O
logic	B-Language
programming	I-Language
language	I-Language
associated	O
with	O
artificial	B-Application
intelligence	I-Application
and	O
computational	O
linguistics	O
.	O
</s>
<s>
Prolog	B-Language
has	O
its	O
roots	O
in	O
first-order	O
logic	B-Language
,	O
a	O
formal	O
logic	B-Language
,	O
and	O
unlike	O
many	O
other	O
programming	O
languages	O
,	O
Prolog	B-Language
is	O
intended	O
primarily	O
as	O
a	O
declarative	B-Language
programming	I-Language
language	I-Language
:	O
the	O
program	O
logic	B-Language
is	O
expressed	O
in	O
terms	O
of	O
relations	B-Algorithm
,	O
represented	O
as	O
facts	O
and	O
rules	O
.	O
</s>
<s>
A	O
computation	O
is	O
initiated	O
by	O
running	O
a	O
query	O
over	O
these	O
relations	B-Algorithm
.	O
</s>
<s>
The	O
language	O
was	O
developed	O
and	O
implemented	O
in	O
Marseille	O
,	O
France	O
,	O
in	O
1972	O
by	O
Alain	O
Colmerauer	O
with	O
Philippe	O
Roussel	O
,	O
based	O
on	O
Robert	O
Kowalski	O
's	O
procedural	O
interpretation	O
of	O
Horn	B-Application
clauses	I-Application
at	O
University	O
of	O
Edinburgh	O
.	O
</s>
<s>
Prolog	B-Language
was	O
one	O
of	O
the	O
first	O
logic	B-Language
programming	I-Language
languages	I-Language
and	O
remains	O
the	O
most	O
popular	O
such	O
language	O
today	O
,	O
with	O
several	O
free	O
and	O
commercial	O
implementations	O
available	O
.	O
</s>
<s>
The	O
language	O
has	O
been	O
used	O
for	O
theorem	B-Application
proving	I-Application
,	O
expert	B-Application
systems	I-Application
,	O
term	O
rewriting	O
,	O
type	O
systems	O
,	O
and	O
automated	B-Application
planning	I-Application
,	O
as	O
well	O
as	O
its	O
original	O
intended	O
field	O
of	O
use	O
,	O
natural	B-Language
language	I-Language
processing	I-Language
.	O
</s>
<s>
Modern	O
Prolog	B-Language
environments	O
support	O
the	O
creation	O
of	O
graphical	B-Application
user	I-Application
interfaces	I-Application
,	O
as	O
well	O
as	O
administrative	O
and	O
networked	O
applications	O
.	O
</s>
<s>
Prolog	B-Language
is	O
well-suited	O
for	O
specific	O
tasks	O
that	O
benefit	O
from	O
rule-based	B-Language
logical	O
queries	O
such	O
as	O
searching	O
databases	O
,	O
voice	B-Application
control	I-Application
systems	O
,	O
and	O
filling	O
templates	O
.	O
</s>
<s>
In	O
Prolog	B-Language
,	O
program	O
logic	B-Language
is	O
expressed	O
in	O
terms	O
of	O
relations	B-Algorithm
,	O
and	O
a	O
computation	O
is	O
initiated	O
by	O
running	O
a	O
query	O
over	O
these	O
relations	B-Algorithm
.	O
</s>
<s>
Relations	B-Algorithm
and	O
queries	O
are	O
constructed	O
using	O
Prolog	B-Language
's	O
single	O
data	O
type	O
,	O
the	O
term	O
.	O
</s>
<s>
Relations	B-Algorithm
are	O
defined	O
by	O
clauses	O
.	O
</s>
<s>
Given	O
a	O
query	O
,	O
the	O
Prolog	B-Language
engine	O
attempts	O
to	O
find	O
a	O
resolution	O
refutation	O
of	O
the	O
negated	O
query	O
.	O
</s>
<s>
This	O
makes	O
Prolog	B-Language
(	O
and	O
other	O
logic	B-Language
programming	I-Language
languages	I-Language
)	O
particularly	O
useful	O
for	O
database	O
,	O
symbolic	B-Algorithm
mathematics	I-Algorithm
,	O
and	O
language	O
parsing	O
applications	O
.	O
</s>
<s>
Because	O
Prolog	B-Language
allows	O
impure	O
predicates	B-Algorithm
,	O
checking	O
the	O
truth	O
value	O
of	O
certain	O
special	O
predicates	B-Algorithm
may	O
have	O
some	O
deliberate	O
side	O
effect	O
,	O
such	O
as	O
printing	O
a	O
value	O
to	O
the	O
screen	O
.	O
</s>
<s>
Because	O
of	O
this	O
,	O
the	O
programmer	O
is	O
permitted	O
to	O
use	O
some	O
amount	O
of	O
conventional	O
imperative	B-Application
programming	I-Application
when	O
the	O
logical	O
paradigm	O
is	O
inconvenient	O
.	O
</s>
<s>
It	O
has	O
a	O
purely	O
logical	O
subset	O
,	O
called	O
"	O
pure	O
Prolog	B-Language
"	O
,	O
as	O
well	O
as	O
a	O
number	O
of	O
extralogical	O
features	O
.	O
</s>
<s>
Prolog	B-Language
's	O
single	O
data	O
type	O
is	O
the	O
term	O
.	O
</s>
<s>
Numbers	O
can	O
be	O
floats	B-Algorithm
or	O
integers	O
.	O
</s>
<s>
ISO	O
standard	O
compatible	O
Prolog	B-Language
systems	O
can	O
check	O
the	O
Prolog	B-Language
flag	O
"	O
bounded	O
"	O
.	O
</s>
<s>
Most	O
of	O
the	O
major	O
Prolog	B-Language
systems	O
support	O
arbitrary	O
length	O
integer	O
numbers	O
.	O
</s>
<s>
Variables	O
closely	O
resemble	O
variables	O
in	O
logic	B-Language
in	O
that	O
they	O
are	O
placeholders	O
for	O
arbitrary	O
terms	O
.	O
</s>
<s>
Strings	O
:	O
A	O
sequence	O
of	O
characters	O
surrounded	O
by	O
quotes	O
is	O
equivalent	O
to	O
either	O
a	O
list	O
of	O
(	O
numeric	B-Algorithm
)	O
character	O
codes	O
,	O
a	O
list	O
of	O
characters	O
(	O
atoms	O
of	O
length	O
1	O
)	O
,	O
or	O
an	O
atom	O
depending	O
on	O
the	O
value	O
of	O
the	O
Prolog	B-Language
flag	O
double_quotes	O
.	O
</s>
<s>
ISO	O
Prolog	B-Language
provides	O
the	O
atom/1	O
,	O
number/1	O
,	O
integer/1	O
,	O
and	O
float/1	O
predicates	B-Algorithm
for	O
type-checking	O
.	O
</s>
<s>
Prolog	B-Language
programs	O
describe	O
relations	B-Algorithm
,	O
defined	O
by	O
means	O
of	O
clauses	O
.	O
</s>
<s>
Pure	O
Prolog	B-Language
is	O
restricted	O
to	O
Horn	B-Application
clauses	I-Application
.	O
</s>
<s>
A	O
rule	O
's	O
body	O
consists	O
of	O
calls	O
to	O
predicates	B-Algorithm
,	O
which	O
are	O
called	O
the	O
rule	O
's	O
goals	O
.	O
</s>
<s>
The	O
built-in	O
predicate	B-Algorithm
true/0	O
is	O
always	O
true	O
.	O
</s>
<s>
Due	O
to	O
the	O
relational	O
nature	O
of	O
many	O
built-in	O
predicates	B-Algorithm
,	O
they	O
can	O
typically	O
be	O
used	O
in	O
several	O
directions	O
.	O
</s>
<s>
For	O
this	O
reason	O
,	O
a	O
comparatively	O
small	O
set	O
of	O
library	O
predicates	B-Algorithm
suffices	O
for	O
many	O
Prolog	B-Language
programs	O
.	O
</s>
<s>
As	O
a	O
general	O
purpose	O
language	O
,	O
Prolog	B-Language
also	O
provides	O
various	O
built-in	O
predicates	B-Algorithm
to	O
perform	O
routine	O
activities	O
like	O
input/output	B-General_Concept
,	O
using	O
graphics	O
and	O
otherwise	O
communicating	O
with	O
the	O
operating	B-General_Concept
system	I-General_Concept
.	O
</s>
<s>
These	O
predicates	B-Algorithm
are	O
not	O
given	O
a	O
relational	O
meaning	O
and	O
are	O
only	O
useful	O
for	O
the	O
side-effects	O
they	O
exhibit	O
on	O
the	O
system	O
.	O
</s>
<s>
For	O
example	O
,	O
the	O
predicate	B-Algorithm
write/1	O
displays	O
a	O
term	O
on	O
the	O
screen	O
.	O
</s>
<s>
Execution	O
of	O
a	O
Prolog	B-Language
program	O
is	O
initiated	O
by	O
the	O
user	O
's	O
posting	O
of	O
a	O
single	O
goal	O
,	O
called	O
the	O
query	O
.	O
</s>
<s>
Logically	O
,	O
the	O
Prolog	B-Language
engine	O
tries	O
to	O
find	O
a	O
resolution	O
refutation	O
of	O
the	O
negated	O
query	O
.	O
</s>
<s>
The	O
resolution	O
method	O
used	O
by	O
Prolog	B-Language
is	O
called	O
SLD	B-Application
resolution	I-Application
.	O
</s>
<s>
Operationally	O
,	O
Prolog	B-Language
's	O
execution	O
strategy	O
can	O
be	O
thought	O
of	O
as	O
a	O
generalization	O
of	O
function	O
calls	O
in	O
other	O
languages	O
,	O
one	O
difference	O
being	O
that	O
multiple	O
clause	O
heads	O
can	O
match	O
a	O
given	O
call	O
.	O
</s>
<s>
In	O
that	O
case	O
,	O
the	O
system	O
creates	O
a	O
choice-point	O
,	O
unifies	B-Algorithm
the	O
goal	O
with	O
the	O
clause	O
head	O
of	O
the	O
first	O
alternative	O
,	O
and	O
continues	O
with	O
the	O
goals	O
of	O
that	O
first	O
alternative	O
.	O
</s>
<s>
This	O
execution	O
strategy	O
is	O
called	O
chronological	O
backtracking	B-Algorithm
.	O
</s>
<s>
enumerates	O
all	O
valid	O
answers	O
on	O
backtracking	B-Algorithm
.	O
</s>
<s>
Iterative	O
algorithms	O
can	O
be	O
implemented	O
by	O
means	O
of	O
recursive	O
predicates	B-Algorithm
.	O
</s>
<s>
The	O
built-in	O
Prolog	B-Language
predicate	B-Algorithm
\+/1	O
provides	O
negation	B-Application
as	I-Application
failure	I-Application
,	O
which	O
allows	O
for	O
non-monotonic	O
reasoning	O
.	O
</s>
<s>
is	O
evaluated	O
as	O
follows	O
:	O
Prolog	B-Language
attempts	O
to	O
prove	O
illegal(X )	O
.	O
</s>
<s>
In	O
Prolog	B-Language
,	O
loading	O
code	O
is	O
referred	O
to	O
as	O
consulting	O
.	O
</s>
<s>
Prolog	B-Language
can	O
be	O
used	O
interactively	O
by	O
entering	O
queries	O
at	O
the	O
Prolog	B-Language
prompt	O
?	O
-	O
.	O
</s>
<s>
If	O
there	O
is	O
no	O
solution	O
,	O
Prolog	B-Language
writes	O
no	O
.	O
</s>
<s>
Here	O
follow	O
some	O
example	O
programs	O
written	O
in	O
Prolog	B-Language
.	O
</s>
<s>
As	O
an	O
example	O
,	O
an	O
optimizing	B-Application
compiler	I-Application
with	O
three	O
optimization	O
passes	O
could	O
be	O
implemented	O
as	O
a	O
relation	O
between	O
an	O
initial	O
program	O
and	O
its	O
optimized	O
form	O
:	O
</s>
<s>
or	O
equivalently	O
using	O
DCG	B-Application
notation	O
:	O
</s>
<s>
The	O
quicksort	B-Algorithm
sorting	O
algorithm	O
,	O
relating	O
a	O
list	O
to	O
its	O
sorted	O
version	O
:	O
</s>
<s>
Some	O
design	O
patterns	O
in	O
Prolog	B-Language
are	O
skeletons	O
,	O
techniques	O
,	O
cliches	O
,	O
program	O
schemata	O
,	O
logic	B-Language
description	O
schemata	O
,	O
and	O
higher	B-Application
order	I-Application
programming	I-Application
.	O
</s>
<s>
A	O
higher-order	B-Algorithm
predicate	I-Algorithm
is	O
a	O
predicate	B-Algorithm
that	O
takes	O
one	O
or	O
more	O
other	O
predicates	B-Algorithm
as	O
arguments	O
.	O
</s>
<s>
Although	O
support	O
for	O
higher-order	B-Application
programming	I-Application
takes	O
Prolog	B-Language
outside	O
the	O
domain	O
of	O
first-order	O
logic	B-Language
,	O
which	O
does	O
not	O
allow	O
quantification	O
over	O
predicates	B-Algorithm
,	O
ISO	O
Prolog	B-Language
now	O
has	O
some	O
built-in	O
higher-order	B-Algorithm
predicates	I-Algorithm
such	O
as	O
call/1	O
,	O
call/2	O
,	O
call/3	O
,	O
findall/3	O
,	O
setof/3	O
,	O
and	O
bagof/3	O
.	O
</s>
<s>
Furthermore	O
,	O
since	O
arbitrary	O
Prolog	B-Language
goals	O
can	O
be	O
constructed	O
and	O
evaluated	O
at	O
run-time	O
,	O
it	O
is	O
easy	O
to	O
write	O
higher-order	B-Algorithm
predicates	I-Algorithm
like	O
maplist/2	O
,	O
which	O
applies	O
an	O
arbitrary	O
predicate	B-Algorithm
to	O
each	O
member	O
of	O
a	O
given	O
list	O
,	O
and	O
sublist/3	O
,	O
which	O
filters	O
elements	O
that	O
satisfy	O
a	O
given	O
predicate	B-Algorithm
,	O
also	O
allowing	O
for	O
currying	B-Application
.	O
</s>
<s>
To	O
convert	O
solutions	O
from	O
temporal	O
representation	O
(	O
answer	O
substitutions	O
on	O
backtracking	B-Algorithm
)	O
to	O
spatial	O
representation	O
(	O
terms	O
)	O
,	O
Prolog	B-Language
has	O
various	O
all-solutions	O
predicates	B-Algorithm
that	O
collect	O
all	O
answer	O
substitutions	O
of	O
a	O
given	O
query	O
in	O
a	O
list	O
.	O
</s>
<s>
This	O
can	O
be	O
used	O
for	O
list	B-Language
comprehension	I-Language
.	O
</s>
<s>
As	O
another	O
example	O
,	O
the	O
predicate	B-Algorithm
maplist	O
applies	O
a	O
predicate	B-Algorithm
P	O
to	O
all	O
corresponding	O
positions	O
in	O
a	O
pair	O
of	O
lists	O
:	O
</s>
<s>
When	O
P	O
is	O
a	O
predicate	B-Algorithm
that	O
for	O
all	O
X	O
,	O
P(X,Y )	O
unifies	B-Algorithm
Y	O
with	O
a	O
single	O
unique	O
value	O
,	O
maplist(P, Xs, Ys )	O
is	O
equivalent	O
to	O
applying	O
the	O
map	O
function	O
in	O
functional	B-Language
programming	I-Language
as	O
Ys	O
=	O
map(Function, Xs )	O
.	O
</s>
<s>
Higher-order	B-Application
programming	I-Application
style	O
in	O
Prolog	B-Language
was	O
pioneered	O
in	O
HiLog	B-Language
and	O
λProlog	B-Language
.	O
</s>
<s>
For	O
programming	O
in	O
the	O
large	O
,	O
Prolog	B-Language
provides	O
a	O
module	B-Architecture
system	I-Architecture
.	O
</s>
<s>
The	O
module	B-Architecture
system	I-Architecture
is	O
standardised	O
by	O
ISO	O
.	O
</s>
<s>
However	O
,	O
not	O
all	O
Prolog	B-Language
compilers	O
support	O
modules	B-Architecture
,	O
and	O
there	O
are	O
compatibility	O
problems	O
between	O
the	O
module	B-Architecture
systems	I-Architecture
of	O
the	O
major	O
Prolog	B-Language
compilers	O
.	O
</s>
<s>
Consequently	O
,	O
modules	B-Architecture
written	O
on	O
one	O
Prolog	B-Language
compiler	O
will	O
not	O
necessarily	O
work	O
on	O
others	O
.	O
</s>
<s>
There	O
is	O
a	O
special	O
notation	O
called	O
definite	B-Application
clause	I-Application
grammars	I-Application
(	O
DCGs	O
)	O
.	O
</s>
<s>
A	O
rule	O
defined	O
via	O
-->/	O
2	O
instead	O
of	O
:-/2	O
is	O
expanded	O
by	O
the	O
preprocessor	O
(	O
expand_term/2	O
,	O
a	O
facility	O
analogous	O
to	O
macros	O
in	O
other	O
languages	O
)	O
according	O
to	O
a	O
few	O
straightforward	O
rewriting	O
rules	O
,	O
resulting	O
in	O
ordinary	O
Prolog	B-Language
clauses	O
.	O
</s>
<s>
Most	O
notably	O
,	O
the	O
rewriting	O
equips	O
the	O
predicate	B-Algorithm
with	O
two	O
additional	O
arguments	O
,	O
which	O
can	O
be	O
used	O
to	O
implicitly	O
thread	O
state	O
around	O
,	O
analogous	O
to	O
monads	O
in	O
other	O
languages	O
.	O
</s>
<s>
Prolog	B-Language
is	O
a	O
homoiconic	O
language	O
and	O
provides	O
many	O
facilities	O
for	O
reflection	B-Language
.	O
</s>
<s>
Its	O
implicit	O
execution	O
strategy	O
makes	O
it	O
possible	O
to	O
write	O
a	O
concise	O
meta-circular	B-Application
evaluator	I-Application
(	O
also	O
called	O
meta-interpreter	O
)	O
for	O
pure	O
Prolog	B-Language
code	O
:	O
</s>
<s>
where	O
true	O
represents	O
an	O
empty	O
conjunction	O
,	O
and	O
clause(Head, Body )	O
unifies	B-Algorithm
with	O
clauses	O
in	O
the	O
database	O
of	O
the	O
form	O
Head	O
:	O
-	O
Body	O
.	O
</s>
<s>
Since	O
Prolog	B-Language
programs	O
are	O
themselves	O
sequences	O
of	O
Prolog	B-Language
terms	O
(	O
:	O
-/2	O
is	O
an	O
infix	O
operator	O
)	O
that	O
are	O
easily	O
read	O
and	O
inspected	O
using	O
built-in	O
mechanisms	O
(	O
like	O
read/1	O
)	O
,	O
it	O
is	O
possible	O
to	O
write	O
customized	O
interpreters	O
that	O
augment	O
Prolog	B-Language
with	O
domain-specific	O
features	O
.	O
</s>
<s>
Pure	O
Prolog	B-Language
is	O
based	O
on	O
a	O
subset	O
of	O
first-order	O
predicate	B-Algorithm
logic	B-Language
,	O
Horn	B-Application
clauses	I-Application
,	O
which	O
is	O
Turing-complete	B-Algorithm
.	O
</s>
<s>
Turing	B-Algorithm
completeness	I-Algorithm
of	O
Prolog	B-Language
can	O
be	O
shown	O
by	O
using	O
it	O
to	O
simulate	O
a	O
Turing	O
machine	O
:	O
</s>
<s>
This	O
illustrates	O
how	O
any	O
computation	O
can	O
be	O
expressed	O
declaratively	O
as	O
a	O
sequence	O
of	O
state	O
transitions	O
,	O
implemented	O
in	O
Prolog	B-Language
as	O
a	O
relation	O
between	O
successive	O
states	O
of	O
interest	O
.	O
</s>
<s>
The	O
ISO	O
Prolog	B-Language
standard	O
consists	O
of	O
two	O
parts	O
.	O
</s>
<s>
ISO/IEC	B-Language
13211-1	I-Language
,	O
published	O
in	O
1995	O
,	O
aims	O
to	O
standardize	O
the	O
existing	O
practices	O
of	O
the	O
many	O
implementations	O
of	O
the	O
core	O
elements	O
of	O
Prolog	B-Language
.	O
</s>
<s>
ISO/IEC	B-Language
13211-2	I-Language
,	O
published	O
in	O
2000	O
,	O
adds	O
support	O
for	O
modules	B-Architecture
to	O
the	O
standard	O
.	O
</s>
<s>
For	O
efficiency	O
,	O
Prolog	B-Language
code	O
is	O
typically	O
compiled	O
to	O
abstract	O
machine	O
code	O
,	O
often	O
influenced	O
by	O
the	O
register-based	O
Warren	B-Application
Abstract	I-Application
Machine	I-Application
(	O
WAM	O
)	O
instruction	O
set	O
.	O
</s>
<s>
Some	O
implementations	O
employ	O
abstract	O
interpretation	O
to	O
derive	O
type	O
and	O
mode	O
information	O
of	O
predicates	B-Algorithm
at	O
compile	O
time	O
,	O
or	O
compile	O
to	O
real	O
machine	O
code	O
for	O
high	O
performance	O
.	O
</s>
<s>
Devising	O
efficient	O
implementation	O
methods	O
for	O
Prolog	B-Language
code	O
is	O
a	O
field	O
of	O
active	O
research	O
in	O
the	O
logic	B-Language
programming	I-Language
community	O
,	O
and	O
various	O
other	O
execution	O
methods	O
are	O
employed	O
in	O
some	O
implementations	O
.	O
</s>
<s>
These	O
include	O
clause	O
binarization	O
and	O
stack-based	B-Application
virtual	I-Application
machines	I-Application
.	O
</s>
<s>
Prolog	B-Language
systems	O
typically	O
implement	O
a	O
well-known	O
optimization	O
method	O
called	O
tail	B-Language
call	I-Language
optimization	I-Language
(	O
TCO	O
)	O
for	O
deterministic	O
predicates	B-Algorithm
exhibiting	O
tail	B-Language
recursion	I-Language
or	O
,	O
more	O
generally	O
,	O
tail	B-Language
calls	I-Language
:	O
A	O
clause	O
's	O
stack	O
frame	O
is	O
discarded	O
before	O
performing	O
a	O
call	O
in	O
a	O
tail	O
position	O
.	O
</s>
<s>
Therefore	O
,	O
deterministic	O
tail-recursive	B-Language
predicates	B-Algorithm
are	O
executed	O
with	O
constant	O
stack	O
space	O
,	O
like	O
loops	O
in	O
other	O
languages	O
.	O
</s>
<s>
Term	B-Application
indexing	I-Application
uses	O
a	O
data	B-General_Concept
structure	I-General_Concept
that	O
enables	O
sub-linear-time	O
lookups	O
.	O
</s>
<s>
Most	O
Prologs	B-Language
only	O
use	O
indexing	O
on	O
the	O
first	O
term	O
,	O
as	O
indexing	O
on	O
all	O
terms	O
is	O
expensive	O
,	O
but	O
techniques	O
based	O
on	O
field-encoded	O
words	O
or	O
superimposed	B-General_Concept
codewords	O
provide	O
fast	O
indexing	O
across	O
the	O
full	O
query	O
and	O
head	O
.	O
</s>
<s>
Some	O
Prolog	B-Language
systems	O
,	O
such	O
as	O
WIN-PROLOG	O
and	O
SWI-Prolog	B-Application
,	O
now	O
implement	O
hashing	O
to	O
help	O
handle	O
large	O
datasets	O
more	O
efficiently	O
.	O
</s>
<s>
This	O
tends	O
to	O
yield	O
very	O
large	O
performance	O
gains	O
when	O
working	O
with	O
large	O
corpora	O
such	O
as	O
WordNet	B-General_Concept
.	O
</s>
<s>
Some	O
Prolog	B-Language
systems	O
,	O
(	O
B-Prolog	B-Language
,	O
XSB	B-Language
,	O
SWI-Prolog	B-Application
,	O
YAP	B-Application
,	O
and	O
Ciao	B-Application
)	O
,	O
implement	O
a	O
memoization	O
method	O
called	O
tabling	O
,	O
which	O
frees	O
the	O
user	O
from	O
manually	O
storing	O
intermediate	O
results	O
.	O
</s>
<s>
It	O
can	O
support	O
recursive	O
predicates	B-Algorithm
through	O
SLG-resolution	O
or	O
linear	O
tabling	O
.	O
</s>
<s>
In	O
a	O
multi-threaded	O
Prolog	B-Language
system	O
tabling	O
results	O
could	O
be	O
kept	O
private	O
to	O
a	O
thread	O
or	O
shared	O
among	O
all	O
threads	O
.	O
</s>
<s>
During	O
the	O
Fifth	B-Device
Generation	I-Device
Computer	I-Device
Systems	I-Device
project	I-Device
,	O
there	O
were	O
attempts	O
to	O
implement	O
Prolog	B-Language
in	O
hardware	O
with	O
the	O
aim	O
of	O
achieving	O
faster	O
execution	O
with	O
dedicated	O
architectures	O
.	O
</s>
<s>
Furthermore	O
,	O
Prolog	B-Language
has	O
a	O
number	O
of	O
properties	O
that	O
may	O
allow	O
speed-up	O
through	O
parallel	O
execution	O
.	O
</s>
<s>
A	O
more	O
recent	O
approach	O
has	O
been	O
to	O
compile	O
restricted	O
Prolog	B-Language
programs	O
to	O
a	O
field	B-Architecture
programmable	I-Architecture
gate	I-Architecture
array	I-Architecture
.	O
</s>
<s>
Sega	O
implemented	O
Prolog	B-Language
for	O
use	O
with	O
the	O
Sega	O
AI	B-Application
Computer	O
,	O
released	O
for	O
the	O
Japanese	O
market	O
in	O
1986	O
.	O
</s>
<s>
Prolog	B-Language
was	O
used	O
for	O
reading	O
natural	O
language	O
inputs	O
,	O
in	O
the	O
Japanese	O
language	O
,	O
via	O
a	O
touch	O
pad	O
.	O
</s>
<s>
Although	O
Prolog	B-Language
is	O
widely	O
used	O
in	O
research	O
and	O
education	O
,	O
Prolog	B-Language
and	O
other	O
logic	B-Language
programming	I-Language
languages	I-Language
have	O
not	O
had	O
a	O
significant	O
impact	O
on	O
the	O
computer	O
industry	O
in	O
general	O
.	O
</s>
<s>
Programming	O
in	O
the	O
large	O
is	O
considered	O
to	O
be	O
complicated	O
because	O
not	O
all	O
Prolog	B-Language
compilers	O
support	O
modules	B-Architecture
,	O
and	O
there	O
are	O
compatibility	O
problems	O
between	O
the	O
module	B-Architecture
systems	I-Architecture
of	O
the	O
major	O
Prolog	B-Language
compilers	O
.	O
</s>
<s>
Portability	O
of	O
Prolog	B-Language
code	O
across	O
implementations	O
has	O
also	O
been	O
a	O
problem	O
,	O
but	O
developments	O
since	O
2007	O
have	O
meant	O
:	O
"	O
the	O
portability	O
within	O
the	O
family	O
of	O
Edinburgh/Quintus	O
derived	O
Prolog	B-Language
implementations	O
is	O
good	O
enough	O
to	O
allow	O
for	O
maintaining	O
portable	O
real-world	O
applications.	O
"	O
</s>
<s>
Software	O
developed	O
in	O
Prolog	B-Language
has	O
been	O
criticised	O
for	O
having	O
a	O
high	O
performance	O
penalty	O
compared	O
to	O
conventional	O
programming	O
languages	O
.	O
</s>
<s>
In	O
particular	O
,	O
Prolog	B-Language
's	O
non-deterministic	O
evaluation	O
strategy	O
can	O
be	O
problematic	O
when	O
programming	O
deterministic	O
computations	O
,	O
or	O
when	O
even	O
using	O
"	O
do	O
n't	O
care	O
non-determinism	O
"	O
(	O
where	O
a	O
single	O
choice	O
is	O
made	O
instead	O
of	O
backtracking	B-Algorithm
over	O
all	O
possibilities	O
)	O
.	O
</s>
<s>
Cuts	O
and	O
other	O
language	O
constructs	O
may	O
have	O
to	O
be	O
used	O
to	O
achieve	O
desirable	O
performance	O
,	O
destroying	O
one	O
of	O
Prolog	B-Language
's	O
main	O
attractions	O
,	O
the	O
ability	O
to	O
run	O
programs	O
"	O
backwards	O
and	O
forwards	O
"	O
.	O
</s>
<s>
Prolog	B-Language
is	O
not	O
purely	O
declarative	B-Language
:	O
because	O
of	O
constructs	O
like	O
the	O
cut	B-Application
operator	I-Application
,	O
a	O
procedural	O
reading	O
of	O
a	O
Prolog	B-Language
program	O
is	O
needed	O
to	O
understand	O
it	O
.	O
</s>
<s>
The	O
order	O
of	O
clauses	O
in	O
a	O
Prolog	B-Language
program	O
is	O
significant	O
,	O
as	O
the	O
execution	O
strategy	O
of	O
the	O
language	O
depends	O
on	O
it	O
.	O
</s>
<s>
Other	O
logic	B-Language
programming	I-Language
languages	I-Language
,	O
such	O
as	O
Datalog	B-Language
,	O
are	O
truly	O
declarative	B-Language
but	O
restrict	O
the	O
language	O
.	O
</s>
<s>
As	O
a	O
result	O
,	O
many	O
practical	O
Prolog	B-Language
programs	O
are	O
written	O
to	O
conform	O
to	O
Prolog	B-Language
's	O
depth-first	B-Algorithm
search	I-Algorithm
order	O
,	O
rather	O
than	O
as	O
purely	O
declarative	B-Language
logic	B-Language
programs	I-Language
.	O
</s>
<s>
Various	O
implementations	O
have	O
been	O
developed	O
from	O
Prolog	B-Language
to	O
extend	O
logic	B-Language
programming	I-Language
capabilities	O
in	O
numerous	O
directions	O
.	O
</s>
<s>
These	O
include	O
types	O
,	O
modes	O
,	O
constraint	B-Application
logic	I-Application
programming	I-Application
(	O
CLP	O
)	O
,	O
object-oriented	B-Language
logic	B-Language
programming	I-Language
(	O
OOLP	O
)	O
,	O
concurrency	O
,	O
linear	O
logic	B-Language
(	O
LLP	O
)	O
,	O
functional	O
and	O
higher-order	B-Algorithm
logic	I-Algorithm
programming	I-Language
capabilities	O
,	O
plus	O
interoperability	O
with	O
knowledge	O
bases	O
:	O
</s>
<s>
Prolog	B-Language
is	O
an	O
untyped	O
language	O
.	O
</s>
<s>
Attempts	O
to	O
introduce	O
types	O
date	O
back	O
to	O
the	O
1980s	O
,	O
and	O
as	O
of	O
2008	O
there	O
are	O
still	O
attempts	O
to	O
extend	O
Prolog	B-Language
with	O
types	O
.	O
</s>
<s>
Type	O
information	O
is	O
useful	O
not	O
only	O
for	O
type	B-Language
safety	I-Language
but	O
also	O
for	O
reasoning	O
about	O
Prolog	B-Language
programs	O
.	O
</s>
<s>
The	O
syntax	O
of	O
Prolog	B-Language
does	O
not	O
specify	O
which	O
arguments	O
of	O
a	O
predicate	B-Algorithm
are	O
inputs	O
and	O
which	O
are	O
outputs	O
.	O
</s>
<s>
Modes	O
provide	O
valuable	O
information	O
when	O
reasoning	O
about	O
Prolog	B-Language
programs	O
and	O
can	O
also	O
be	O
used	O
to	O
accelerate	O
execution	O
.	O
</s>
<s>
Constraint	B-Application
logic	I-Application
programming	I-Application
extends	O
Prolog	B-Language
to	O
include	O
concepts	O
from	O
constraint	B-Application
satisfaction	I-Application
.	O
</s>
<s>
A	O
constraint	O
logic	B-Language
program	I-Language
allows	O
constraints	O
in	O
the	O
body	O
of	O
clauses	O
,	O
such	O
as	O
:	O
A(X,Y )	O
:	O
-	O
X+	O
Y>0	O
.	O
</s>
<s>
It	O
is	O
suited	O
to	O
large-scale	O
combinatorial	O
optimisation	O
problems	O
and	O
is	O
thus	O
useful	O
for	O
applications	O
in	O
industrial	O
settings	O
,	O
such	O
as	O
automated	O
time-tabling	O
and	O
production	B-Application
scheduling	I-Application
.	O
</s>
<s>
Most	O
Prolog	B-Language
systems	O
ship	O
with	O
at	O
least	O
one	O
constraint	O
solver	O
for	O
finite	O
domains	O
,	O
and	O
often	O
also	O
with	O
solvers	O
for	O
other	O
domains	O
like	O
rational	O
numbers	O
.	O
</s>
<s>
Flora-2	B-Language
is	O
an	O
object-oriented	B-Language
knowledge	O
representation	O
and	O
reasoning	O
system	O
based	O
on	O
F-logic	B-Language
and	O
incorporates	O
HiLog	B-Language
,	O
Transaction	B-Language
logic	I-Language
,	O
and	O
defeasible	O
reasoning	O
.	O
</s>
<s>
Logtalk	B-Language
is	O
an	O
object-oriented	B-Language
logic	B-Language
programming	I-Language
language	I-Language
that	O
can	O
use	O
most	O
Prolog	B-Language
implementations	O
as	O
a	O
back-end	O
compiler	O
.	O
</s>
<s>
Oblog	O
is	O
a	O
small	O
,	O
portable	O
,	O
object-oriented	B-Language
extension	O
to	O
Prolog	B-Language
by	O
Margaret	O
McDougall	O
of	O
EdCAAD	O
,	O
University	O
of	O
Edinburgh	O
.	O
</s>
<s>
Objlog	B-Language
was	O
a	O
frame-based	O
language	O
combining	O
objects	O
and	O
Prolog	B-Language
II	I-Language
from	O
CNRS	O
,	O
Marseille	O
,	O
France	O
.	O
</s>
<s>
Prolog++	B-Language
was	O
developed	O
by	O
Logic	B-Language
Programming	I-Language
Associates	O
and	O
first	O
released	O
in	O
1989	O
for	O
MS-DOS	O
PCs	O
.	O
</s>
<s>
A	O
book	O
about	O
Prolog++	B-Language
by	O
Chris	O
Moss	O
was	O
published	O
by	O
Addison-Wesley	O
in	O
1994	O
.	O
</s>
<s>
Visual	B-Application
Prolog	I-Application
is	O
a	O
multi-paradigm	O
language	O
with	O
interfaces	O
,	O
classes	O
,	O
implementations	O
and	O
object	O
expressions	O
.	O
</s>
<s>
Prolog	B-Language
systems	O
that	O
provide	O
a	O
graphics	B-Library
library	I-Library
are	O
SWI-Prolog	B-Application
,	O
Visual	B-Application
Prolog	I-Application
,	O
WIN-PROLOG	O
,	O
and	O
B-Prolog	B-Language
.	O
</s>
<s>
Prolog-MPI	O
is	O
an	O
open-source	O
SWI-Prolog	B-Application
extension	O
for	O
distributed	O
computing	O
over	O
the	O
Message	B-Application
Passing	I-Application
Interface	I-Application
.	O
</s>
<s>
Also	O
there	O
are	O
various	O
concurrent	O
Prolog	B-Language
programming	I-Language
languages	I-Language
.	O
</s>
<s>
Some	O
Prolog	B-Language
implementations	O
,	O
notably	O
Visual	B-Application
Prolog	I-Application
,	O
SWI-Prolog	B-Application
and	O
Ciao	B-Application
,	O
support	O
server-side	B-Application
web	O
programming	O
with	O
support	O
for	O
web	O
protocols	O
,	O
HTML	B-Language
and	O
XML	B-Protocol
.	O
</s>
<s>
There	O
are	O
also	O
extensions	O
to	O
support	O
semantic	O
web	O
formats	O
such	O
as	O
RDF	O
and	O
OWL	B-Language
.	O
</s>
<s>
Prolog	B-Language
has	O
also	O
been	O
suggested	O
as	O
a	O
client-side	B-Operating_System
language	O
.	O
</s>
<s>
In	O
addition	O
Visual	B-Application
Prolog	I-Application
supports	O
JSON-RPC	B-General_Concept
and	O
Websockets	B-Protocol
.	O
</s>
<s>
is	O
a	O
free	O
and	O
basic	O
Prolog	B-Language
interpreter	O
.	O
</s>
<s>
This	O
provides	O
a	O
new	O
platform	O
to	O
programming	O
in	O
Prolog	B-Language
through	O
ActionScript	B-Operating_System
.	O
</s>
<s>
F-logic	B-Language
extends	O
Prolog	B-Language
with	O
frames/objects	O
for	O
knowledge	O
representation	O
.	O
</s>
<s>
Transaction	B-Language
logic	I-Language
extends	O
Prolog	B-Language
with	O
a	O
logical	O
theory	O
of	O
state-changing	O
update	O
operators	O
.	O
</s>
<s>
OW	O
Prolog	B-Language
has	O
been	O
created	O
in	O
order	O
to	O
answer	O
Prolog	B-Language
's	O
lack	O
of	O
graphics	O
and	O
interface	O
.	O
</s>
<s>
Frameworks	O
exist	O
which	O
can	O
bridge	O
between	O
Prolog	B-Language
and	O
other	O
languages	O
:	O
</s>
<s>
The	O
allows	O
the	O
embedding	O
of	O
within	O
C	O
,	O
C#	O
,	O
C++	O
,	O
Java	B-Device
,	O
VB	O
,	O
Delphi	O
,	O
.Net	O
,	O
Lua	O
,	O
Python	O
and	O
other	O
languages	O
.	O
</s>
<s>
The	O
Logic	B-Language
Server	O
API	O
allows	O
both	O
the	O
extension	O
and	O
embedding	O
of	O
Prolog	B-Language
in	O
C	O
,	O
C++	O
,	O
Java	B-Device
,	O
VB	O
,	O
Delphi	O
,	O
.NET	O
and	O
any	O
language/environment	O
which	O
can	O
call	O
a	O
.dll	O
or	O
.so	O
.	O
</s>
<s>
Prolog	B-Language
but	O
the	O
API	O
specification	O
can	O
be	O
made	O
available	O
for	O
any	O
implementation	O
.	O
</s>
<s>
is	O
a	O
bi-directional	O
Java	B-Device
Prolog	B-Language
bridge	O
which	O
ships	O
with	O
SWI-Prolog	B-Application
by	O
default	O
,	O
allowing	O
Java	B-Device
and	O
Prolog	B-Language
to	O
call	O
each	O
other	O
(	O
recursively	O
)	O
.	O
</s>
<s>
,	O
a	O
programming	O
library	O
bridge	O
between	O
Java	B-Device
and	O
Prolog	B-Language
,	O
implementing	O
bi-directional	O
predicate/method	O
calling	O
between	O
both	O
languages	O
.	O
</s>
<s>
Java	B-Device
objects	O
can	O
be	O
mapped	O
into	O
Prolog	B-Language
terms	O
and	O
vice	O
versa	O
.	O
</s>
<s>
Allows	O
the	O
development	O
of	O
GUIs	B-Application
and	O
other	O
functionality	O
in	O
Java	B-Device
while	O
leaving	O
logic	B-Language
processing	O
in	O
the	O
Prolog	B-Language
layer	O
.	O
</s>
<s>
Supports	O
XSB	B-Language
,	O
with	O
support	O
for	O
SWI-Prolog	B-Application
and	O
YAP	B-Application
planned	O
for	O
2013	O
.	O
</s>
<s>
Prova	B-Language
provides	O
native	O
syntax	O
integration	O
with	O
Java	B-Device
,	O
agent	O
messaging	O
and	O
reaction	O
rules	O
.	O
</s>
<s>
Prova	B-Language
positions	O
itself	O
as	O
a	O
rule-based	B-Language
scripting	O
(	O
RBS	O
)	O
system	O
for	O
middleware	O
.	O
</s>
<s>
The	O
language	O
breaks	O
new	O
ground	O
in	O
combining	O
imperative	B-Application
and	O
declarative	B-Language
programming	I-Language
.	O
</s>
<s>
An	O
embeddable	O
Prolog	B-Language
engine	O
for	O
Java	B-Device
.	O
</s>
<s>
Ciao	B-Application
provides	O
interfaces	O
to	O
C	O
,	O
C++	O
,	O
Java	B-Device
,	O
and	O
relational	O
databases	O
.	O
</s>
<s>
is	O
a	O
Prolog	B-Language
interpreter	O
written	O
in	O
(	O
managed	O
)	O
C#	O
.	O
</s>
<s>
Characteristics	O
:	O
reliable	O
and	O
fairly	O
fast	O
interpreter	O
,	O
command	O
line	O
interface	O
,	O
Windows-interface	O
,	O
builtin	O
DCG	B-Application
,	O
XML-predicates	O
,	O
SQL-predicates	O
,	O
extendible	O
.	O
</s>
<s>
A	O
Prolog	B-Language
compiler	O
and	O
interpreter	O
in	O
PHP	O
5.3	O
.	O
</s>
<s>
is	O
a	O
light-weight	O
Prolog	B-Language
system	O
for	O
distributed	O
applications	O
and	O
infrastructures	O
,	O
intentionally	O
designed	O
around	O
a	O
minimal	O
core	O
,	O
to	O
be	O
either	O
statically	O
or	O
dynamically	O
configured	O
by	O
loading/unloading	O
libraries	O
of	O
predicates	B-Algorithm
.	O
</s>
<s>
tuProlog	O
natively	O
supports	O
multi-paradigm	O
programming	O
,	O
providing	O
a	O
clean	O
,	O
seamless	O
integration	O
model	O
between	O
Prolog	B-Language
and	O
mainstream	O
object-oriented	B-Language
languages	I-Language
—	O
namely	O
Java	B-Device
,	O
for	O
tuProlog	O
Java	B-Device
version	O
,	O
and	O
any	O
.NET-based	O
language	O
(	O
C#	O
,	O
F#	O
..	O
)	O
,	O
for	O
tuProlog	O
.NET	O
version	O
.	O
</s>
<s>
The	O
name	O
Prolog	B-Language
was	O
chosen	O
by	O
Philippe	O
Roussel	O
as	O
an	O
abbreviation	O
for	O
(	O
French	O
for	O
programming	O
in	O
logic	B-Language
)	O
.	O
</s>
<s>
It	O
was	O
created	O
around	O
1972	O
by	O
Alain	O
Colmerauer	O
with	O
Philippe	O
Roussel	O
,	O
based	O
on	O
Robert	O
Kowalski	O
's	O
procedural	O
interpretation	O
of	O
Horn	B-Application
clauses	I-Application
.	O
</s>
<s>
It	O
was	O
motivated	O
in	O
part	O
by	O
the	O
desire	O
to	O
reconcile	O
the	O
use	O
of	O
logic	B-Language
as	O
a	O
declarative	B-Language
knowledge	O
representation	O
language	O
with	O
the	O
procedural	O
representation	O
of	O
knowledge	O
that	O
was	O
popular	O
in	O
North	O
America	O
in	O
the	O
late	O
1960s	O
and	O
early	O
1970s	O
.	O
</s>
<s>
According	O
to	O
Robert	O
Kowalski	O
,	O
the	O
first	O
Prolog	B-Language
system	O
was	O
developed	O
in	O
1972	O
by	O
Colmerauer	O
and	O
Phillipe	O
Roussel	O
.	O
</s>
<s>
The	O
first	O
implementation	O
of	O
Prolog	B-Language
was	O
an	O
interpreter	O
written	O
in	O
Fortran	O
by	O
Gerard	O
Battani	O
and	O
Henri	O
Meloni	O
.	O
</s>
<s>
David	O
H	O
.	O
D	O
.	O
Warren	O
took	O
this	O
interpreter	O
to	O
University	O
of	O
Edinburgh	O
,	O
and	O
there	O
implemented	O
an	O
alternative	O
front-end	O
,	O
which	O
came	O
to	O
define	O
the	O
“	O
Edinburgh	O
Prolog	B-Language
”	O
syntax	O
used	O
by	O
most	O
modern	O
implementations	O
.	O
</s>
<s>
Warren	O
also	O
implemented	O
the	O
first	O
compiler	O
for	O
Prolog	B-Language
,	O
creating	O
the	O
influential	O
DEC-10	O
Prolog	B-Language
in	O
collaboration	O
with	O
Fernando	O
Pereira	O
.	O
</s>
<s>
Warren	O
later	O
generalised	O
the	O
ideas	O
behind	O
DEC-10	O
Prolog	B-Language
,	O
to	O
create	O
the	O
Warren	B-Application
Abstract	I-Application
Machine	I-Application
.	O
</s>
<s>
European	O
AI	B-Application
researchers	O
favored	O
Prolog	B-Language
while	O
Americans	O
favored	O
Lisp	B-Language
,	O
reportedly	O
causing	O
many	O
nationalistic	O
debates	O
on	O
the	O
merits	O
of	O
the	O
languages	O
.	O
</s>
<s>
Much	O
of	O
the	O
modern	O
development	O
of	O
Prolog	B-Language
came	O
from	O
the	O
impetus	O
of	O
the	O
Fifth	B-Device
Generation	I-Device
Computer	I-Device
Systems	I-Device
project	I-Device
(	O
FGCS	O
)	O
,	O
which	O
developed	O
a	O
variant	O
of	O
Prolog	B-Language
named	O
Kernel	B-Language
Language	I-Language
for	O
its	O
first	O
operating	B-General_Concept
system	I-General_Concept
.	O
</s>
<s>
Pure	O
Prolog	B-Language
was	O
originally	O
restricted	O
to	O
the	O
use	O
of	O
a	O
resolution	O
theorem	O
prover	O
with	O
Horn	B-Application
clauses	I-Application
of	O
the	O
form	O
:	O
</s>
<s>
The	O
application	O
of	O
the	O
theorem-prover	B-Application
treats	O
such	O
clauses	O
as	O
procedures	O
:	O
</s>
<s>
Pure	O
Prolog	B-Language
was	O
soon	O
extended	O
,	O
however	O
,	O
to	O
include	O
negation	B-Application
as	I-Application
failure	I-Application
,	O
in	O
which	O
negative	O
conditions	O
of	O
the	O
form	O
not(Bi )	O
are	O
shown	O
by	O
trying	O
and	O
failing	O
to	O
solve	O
the	O
corresponding	O
positive	O
conditions	O
Bi	O
.	O
</s>
<s>
Subsequent	O
extensions	O
of	O
Prolog	B-Language
by	O
the	O
original	O
team	O
introduced	O
constraint	B-Application
logic	I-Application
programming	I-Application
abilities	O
into	O
the	O
implementations	O
.	O
</s>
<s>
Prolog	B-Language
has	O
been	O
used	O
in	O
Watson	B-Application
.	O
</s>
<s>
Watson	B-Application
uses	O
IBM	O
's	O
DeepQA	B-Application
software	O
and	O
the	O
Apache	O
UIMA	B-Application
(	O
Unstructured	O
Information	O
Management	O
Architecture	O
)	O
framework	O
.	O
</s>
<s>
The	O
system	O
was	O
written	O
in	O
various	O
languages	O
,	O
including	O
Java	B-Device
,	O
C++	O
,	O
and	O
Prolog	B-Language
,	O
and	O
runs	O
on	O
the	O
SUSE	O
Linux	O
Enterprise	O
Server	O
11	O
operating	B-General_Concept
system	I-General_Concept
using	O
Apache	B-Application
Hadoop	I-Application
framework	O
to	O
provide	O
distributed	O
computing	O
.	O
</s>
<s>
Prolog	B-Language
is	O
used	O
for	O
pattern	B-Language
matching	I-Language
over	O
natural	O
language	O
parse	O
trees	O
.	O
</s>
<s>
The	O
developers	O
have	O
stated	O
:	O
"	O
We	O
required	O
a	O
language	O
in	O
which	O
we	O
could	O
conveniently	O
express	O
pattern	B-Language
matching	I-Language
rules	O
over	O
the	O
parse	O
trees	O
and	O
other	O
annotations	O
(	O
such	O
as	O
named	O
entity	O
recognition	O
results	O
)	O
,	O
and	O
a	O
technology	O
that	O
could	O
execute	O
these	O
rules	O
very	O
efficiently	O
.	O
</s>
<s>
We	O
found	O
that	O
Prolog	B-Language
was	O
the	O
ideal	O
choice	O
for	O
the	O
language	O
due	O
to	O
its	O
simplicity	O
and	O
expressiveness.	O
"	O
</s>
<s>
Prolog	B-Language
is	O
being	O
used	O
in	O
the	O
Low-Code	O
Development	O
Platform	O
GeneXus	B-Application
,	O
which	O
is	O
focused	O
around	O
AI	B-Application
.	O
</s>
<s>
Open	O
source	O
graph	B-Application
database	I-Application
TerminusDB	B-Application
is	O
implemented	O
in	O
prolog	B-Language
.	O
</s>
<s>
TerminusDB	B-Application
is	O
designed	O
for	O
collaboratively	O
building	O
and	O
curating	O
knowledge	B-Application
graphs	I-Application
.	O
</s>
