.


:




:

































 

 

 

 


21. 51 3





iiioh(Lisll. Ri 1): ittp(Listl, Listl),

[ I.isti. Rut).

Step

v.Ji.lu...... *:--------------------

I

Rt

LiiU

Listl

. 21.1.

, : (Listl, Rest) , (Listl, List2) (List2, Resc). 8, , , cone.

, DCG Prolog. DCG Prolog . , DCG :

--> nl, 2 . i .

nl, 2,..., , :

n[ Listl, Rest):-nl (Listl, List2}, n2 (List2, List3},

nn(Listri, Rest).

- nl, n2 .................. nn
( DCG ), .
,
. DCG:
n->nl, [ t2], , [ t4].

nl , a t2 t4 . :

ni Listl, Rest):-

.1 (Listl, [t2 | List3]), n3 (List3, [t4 | Rest] I.

. DCG .

sentence -> noun_phrase, verb_phrase. verb_phrase --> verb, nounjbrase. norai_phrase -> determiner, noun.



II. Prolog


determiner - -> f a]. determiner- --> [ the]. noun -> [ cat], noun --> [ mouse. verb --> [ scares], verb --> [ hates].

, .

the, cat, scares, a, mouse] I

the, mouse, hates, the, cat] %

the, mouse, scares, the, mouse] %

, [ the, mice, hate, the, cats] ( ) ;

noun ->
noun ->
verb -->
verb >

mice].

scare]. hate].

, , . , , , , , , , : [ the, mouse, hate, the cat] %

, : sentence --> noun_phrase, verb_phrase.

, . . , . (context dependency). , . BNF, DCG , DCG, BNF, , . , (Number) : noun_phrase (Number) verb phrase{ dumber)

, , , . sentence < Number) --> noun phrase(Number), verb phrase(Number). verb phrase(Number) --> verb(Number), noun phrase(Numberl). nou:n phrase (Number) - > determiner! Number), noun { Number). noun _ singular) --> [ mouse). % noun(plural) --> [ mice]. I

Prolog1 DCG Prolog , . ,

sentence(Number) --> noun_phrase(Number), verb_phrase(Numbet), : sentence(Number, Listl, Rest): -

ncun_phrase(Number, Listl, Llst2),

verb_phrase(Humber, List2, Rest).

21, 515


 

Prolog, , .

?- sentence(plural, [ the, mice, hate, the, cats), []}. yes

?- sentence! plural, [ the, mice, hates, the, cats], [)). no

?- sentence! plural, [ the, mouse, hates, the, cat], []). no

?- sentence! Kumber, [ the, mouse, hates, the, cat], []). Number - singular

?- sentence! singular, [ the, What, hates, the, cat], []}. What = cat; What - mouse; no

23.1. Prolog DCG: s - > [], s, [].

21.1. Prolog translate! DCGrule, PrologClause)

DCG Prolog.

21.3. DCG , ,
:

move --> step, move.

move > move, step.

, , , . Prolog . , . ? :?- move [ [up, lef t], []).





:


: 2015-10-01; !; : 583 |


:

:

.
==> ...

1402 - | 1375 -


© 2015-2024 lektsii.org - -

: 0.013 .