<s>
A	O
definite	B-Application
clause	I-Application
grammar	I-Application
(	O
DCG	O
)	O
is	O
a	O
way	O
of	O
expressing	O
grammar	O
,	O
either	O
for	O
natural	O
or	O
formal	O
languages	O
,	O
in	O
a	O
logic	O
programming	O
language	O
such	O
as	O
Prolog	B-Language
.	O
</s>
<s>
It	O
is	O
closely	O
related	O
to	O
the	O
concept	O
of	O
attribute	B-Application
grammars	I-Application
/	O
affix	O
grammars	O
from	O
which	O
Prolog	B-Language
was	O
originally	O
developed	O
.	O
</s>
<s>
DCGs	O
are	O
usually	O
associated	O
with	O
Prolog	B-Language
,	O
but	O
similar	O
languages	O
such	O
as	O
Mercury	B-Operating_System
also	O
include	O
DCGs	O
.	O
</s>
<s>
They	O
are	O
called	O
definite	B-Application
clause	I-Application
grammars	I-Application
because	O
they	O
represent	O
a	O
grammar	O
as	O
a	O
set	O
of	O
definite	B-Application
clauses	I-Application
in	O
first-order	O
logic	O
.	O
</s>
<s>
The	O
term	O
DCG	O
refers	O
to	O
the	O
specific	O
type	O
of	O
expression	O
in	O
Prolog	B-Language
and	O
other	O
similar	O
languages	O
;	O
not	O
all	O
ways	O
of	O
expressing	O
grammars	O
using	O
definite	B-Application
clauses	I-Application
are	O
considered	O
DCGs	O
.	O
</s>
<s>
However	O
,	O
all	O
of	O
the	O
capabilities	O
or	O
properties	O
of	O
DCGs	O
will	O
be	O
the	O
same	O
for	O
any	O
grammar	O
that	O
is	O
represented	O
with	O
definite	B-Application
clauses	I-Application
in	O
essentially	O
the	O
same	O
way	O
as	O
in	O
Prolog	B-Language
.	O
</s>
<s>
The	O
definite	B-Application
clauses	I-Application
of	O
a	O
DCG	O
can	O
be	O
considered	O
a	O
set	O
of	O
axioms	O
where	O
the	O
validity	O
of	O
a	O
sentence	O
,	O
and	O
the	O
fact	O
that	O
it	O
has	O
a	O
certain	O
parse	O
tree	O
can	O
be	O
considered	O
theorems	O
that	O
follow	O
from	O
these	O
axioms	O
.	O
</s>
<s>
The	O
history	O
of	O
DCGs	O
is	O
closely	O
tied	O
to	O
the	O
history	O
of	O
Prolog	B-Language
,	O
and	O
the	O
history	O
of	O
Prolog	B-Language
revolves	O
around	O
several	O
researchers	O
in	O
both	O
Marseille	O
,	O
France	O
,	O
and	O
Edinburgh	O
,	O
Scotland	O
.	O
</s>
<s>
According	O
to	O
Robert	O
Kowalski	O
,	O
an	O
early	O
developer	O
of	O
Prolog	B-Language
,	O
the	O
first	O
Prolog	B-Language
system	O
was	O
developed	O
in	O
1972	O
by	O
Alain	O
Colmerauer	O
and	O
Phillipe	O
Roussel	O
.	O
</s>
<s>
The	O
first	O
program	O
written	O
in	O
the	O
language	O
was	O
a	O
large	O
natural-language	B-Language
processing	I-Language
system	O
.	O
</s>
<s>
Fernando	O
Pereira	O
and	O
David	O
Warren	O
at	O
the	O
University	O
of	O
Edinburgh	O
were	O
also	O
involved	O
in	O
the	O
early	O
development	O
of	O
Prolog	B-Language
.	O
</s>
<s>
In	O
1978	O
,	O
Colmerauer	O
wrote	O
a	O
paper	O
about	O
a	O
way	O
of	O
representing	O
grammars	O
called	O
metamorphosis	O
grammars	O
which	O
were	O
part	O
of	O
the	O
early	O
version	O
of	O
Prolog	B-Language
called	O
Marseille	O
Prolog	B-Language
.	O
</s>
<s>
Fernando	O
Pereira	O
and	O
David	O
Warren	O
,	O
two	O
other	O
early	O
architects	O
of	O
Prolog	B-Language
,	O
coined	O
the	O
term	O
"	O
definite	B-Application
clause	I-Application
grammar	I-Application
"	O
and	O
created	O
the	O
notation	O
for	O
DCGs	O
that	O
is	O
used	O
in	O
Prolog	B-Language
today	O
.	O
</s>
<s>
They	O
introduced	O
the	O
idea	O
in	O
an	O
article	O
called	O
"	O
Definite	B-Application
Clause	I-Application
Grammars	I-Application
for	O
Language	O
Analysis	O
"	O
,	O
where	O
they	O
describe	O
DCGs	O
as	O
a	O
"	O
formalism	O
...	O
in	O
which	O
grammars	O
are	O
expressed	O
clauses	O
of	O
first-order	O
predicate	O
logic	O
"	O
that	O
"	O
constitute	O
effective	O
programs	O
of	O
the	O
programming	O
language	O
Prolog	B-Language
"	O
.	O
</s>
<s>
Pereira	O
,	O
Warren	O
,	O
and	O
other	O
pioneers	O
of	O
Prolog	B-Language
later	O
wrote	O
about	O
several	O
other	O
aspects	O
of	O
DCGs	O
.	O
</s>
<s>
Pereira	O
also	O
collaborated	O
with	O
Stuart	O
M	O
.	O
Shieber	O
on	O
a	O
book	O
called	O
"	O
Prolog	B-Language
and	O
Natural	O
Language	O
Analysis	O
"	O
,	O
that	O
was	O
intended	O
as	O
a	O
general	O
introduction	O
to	O
computational	O
linguistics	O
using	O
logic	O
programming	O
.	O
</s>
<s>
One	O
can	O
generate	O
all	O
of	O
the	O
valid	O
expressions	O
in	O
the	O
language	O
generated	O
by	O
this	O
grammar	O
at	O
a	O
Prolog	B-Language
interpreter	O
by	O
typing	O
sentence( X	O
,	O
 [  ] 	O
)	O
.	O
</s>
<s>
DCG	O
notation	O
is	O
just	O
syntactic	O
sugar	O
for	O
normal	O
definite	B-Application
clauses	I-Application
in	O
Prolog	B-Language
.	O
</s>
<s>
The	O
arguments	O
to	O
each	O
functor	O
,	O
such	O
as	O
(	O
A	O
,	O
B	O
)	O
and	O
(	O
B	O
,	O
Z	O
)	O
are	O
difference	B-Data_Structure
lists	I-Data_Structure
;	O
difference	B-Data_Structure
lists	I-Data_Structure
are	O
a	O
way	O
of	O
representing	O
a	O
prefix	O
of	O
a	O
list	O
as	O
the	O
difference	O
between	O
its	O
two	O
suffixes	O
(	O
the	O
bigger	O
including	O
the	O
smaller	O
one	O
)	O
.	O
</s>
<s>
Using	O
Prolog	B-Language
's	O
notation	O
for	O
lists	O
,	O
a	O
singleton	O
list	O
prefix	O
P	O
=	O
 [ H ] 	O
can	O
be	O
seen	O
as	O
the	O
difference	O
between	O
 [ H|X ] 	O
and	O
X	O
,	O
and	O
thus	O
represented	O
with	O
the	O
pair	O
( [	O
H|X ]	O
,	O
X	O
)	O
,	O
for	O
instance	O
.	O
</s>
<s>
Difference	B-Data_Structure
lists	I-Data_Structure
are	O
used	O
to	O
represent	O
lists	O
with	O
DCGs	O
for	O
reasons	O
of	O
efficiency	O
.	O
</s>
<s>
In	O
pure	O
Prolog	B-Language
,	O
normal	O
DCG	O
rules	O
with	O
no	O
extra	O
arguments	O
on	O
the	O
functors	O
,	O
such	O
as	O
the	O
previous	O
example	O
,	O
can	O
only	O
express	O
context-free	O
grammars	O
;	O
there	O
is	O
only	O
one	O
argument	O
on	O
the	O
left	O
side	O
of	O
the	O
production	O
.	O
</s>
<s>
In	O
the	O
declaratively	O
pure	O
programming	O
language	O
Mercury	B-Operating_System
I/O	O
must	O
be	O
represented	O
by	O
a	O
pair	O
of	O
io.state	O
arguments	O
.	O
</s>
<s>
DCG	O
notation	O
is	O
also	O
used	O
for	O
parsing	O
and	O
similar	O
things	O
in	O
Mercury	B-Operating_System
as	O
it	O
is	O
in	O
Prolog	B-Language
.	O
</s>
<s>
Another	O
,	O
more	O
recent	O
,	O
extension	O
was	O
made	O
by	O
researchers	O
at	O
NEC	O
Corporation	O
called	O
Multi-Modal	O
Definite	B-Application
Clause	I-Application
Grammars	I-Application
(	O
MM-DCGs	O
)	O
in	O
1995	O
.	O
</s>
<s>
Another	O
extension	O
,	O
called	O
definite	B-Application
clause	I-Application
translation	O
grammars	O
(	O
DCTGs	O
)	O
was	O
described	O
by	O
Harvey	O
Abramson	O
in	O
1984	O
.	O
</s>
<s>
The	O
translation	O
of	O
DCTGs	O
into	O
normal	O
Prolog	B-Language
clauses	O
is	O
like	O
that	O
of	O
DCGs	O
,	O
but	O
3	O
arguments	O
are	O
added	O
instead	O
of	O
2	O
.	O
</s>
