.


:




:

































 

 

 

 


1 ()

:

. , , . , .

 

1:

1.1) , .

:

/* :

baseball -

person -

activity -

swimming - */

goal

likes(bill, baseball)

domains

person, activity = symbol

predicates

likes(person,activity)

clauses

likes(ellen,tennis).

likes(john,football).

likes(tom,baseball).

likes(eric,swimming).

likes(mark,tennis).

likes(bill,X_var) if likes(tom,X_var).

 

:

domains ()

/*... domain... */

predicates ()

/*... ... */

goal ()

/*... _1, _2, ..*/

clauses ()

/*... ( )..*/

 

, () , , .

X_var .

: 1stattempt, second, 'disaster.

 

, , (relations) (objects).

, likes(tom,baseball), = likes, = tom, baseball.

, (, , ).

- , .

(relation) 1, 2 .

-:

likes(ellen, reading)

likes(john, computers)

likes(enc, swimming)

likes(marybeth, X) if likes (john, X)

likes(gina,X) if likes (enc, X)

- , , .

,

domains

person, activity = symbol

predicates

likes (person,activity)

likes , .

: likes (12, X), : type error, .. 12 , .. 12 .

, likes (bill, tom, baseball) , .. likes 2 (. predicates).

 

 

- :

- domains /*() - */;

- database /* */;

- predicates /* */;

- goal /* */;

- clauses /* - */.

predicates clauses.

, .

, .

, .

(clauses):

likes(ellen, tennis).

likes(john, football).

likes(tom, baseball).

likes(eric, swimming).

likes(mark, tennis).

 

, : likes (bill, baseball), .. . , (goal) : likes (bill, baseball), : likes (bill, X) if likes (tom, X).

 

1.2) , . , likes (bill, baseball), likes (bill, tennis).

pro.

Goal: .

 

, - : True, like (bill, X) if likes(tom, X) likes(tom, baseball) likes (bill, baseball).

likes (bill, tennis) No solutions, likes(bill,tennis) , .

 

2: .

2.1) .

 

:

/* :

car -

brand -

color -

age -

price -

mileage -

body - */

goal

car(Make,Odometer,Years_on_road,Body,25000)

domains

brand, color = symbol

age, price = integer

mileage = real

predicates

car(brand,mileage,age,color,price)

/* <== ... */

goal

car(Renault,13,3,5,red,12000).

/* 2200 type error: .

3.5 .

age .

. */

/*... ==> */

clauses

car(chrysler,130000,3,red,12000).

car(ford,90000,4,gray,25000).

car(datsun,8000,1,red,30000).

 

2.2) . .

car , age price, . mileage .

 

: car (Make, Odometer, Years_on_road, Body, 25000), .. , 25000$.

- : Make= ford, Odometer= 90000, Years_on_road=4, Body=gray. 1 Solution.

 

:

car (renault,13,3,5, red,12000).

car (ford,90000, gray,4,25000).

car (1,red,30000,80000,datsun).

.

 

2.3) .

25000$. : car(Make,Odometer,Year_on_road,Body,Cost) and Cost<25000.

- 2 :

1) car(Make,Odometer,Year_on_road,Body,Cost);

2) Cost<25000.

 

2.4) .

() , . (_).

, .

, , owns(_, shirt) /*everyone owns a shirt ( )*/.

 

: car(_,_,Age,_,Cost) and Cost>12700.

-:

Age= 3, Cost= 32000

Age= 4, Cost= 25000

2 Solutions

 

3: .

, , - 9 . : pupil (Person1, 9) and pupil (Person2, 9) and Person1<>Person2. .

:

/* :

child -

age -

pupil -

person - */

domains

child = symbol

age = integer

predicates

pupil(child,age)

clauses

pupil(peter,9).

pupil(paul,10).

pupil(chris,9).

pupil(susan,9).

 

4: not .

.

:

/* :

person -

male -

smoker -

date - ,

vegetarian -

possible - */

domains

person = symbol

predicates

male(person)

smoker(person)

vegetarian(person)

sophie_could_date(person)

goal

sophie_could_date(X) and

write("a possible date for sophie is ",X) and nl.

clauses

male(joshua).

male(bill).

male(tom).

smoker(guiseppe).

smoker(tom).

vegetarian(joshua).

vegetarian(tom).

sophie_could_date(X) if male(X) and not(smoker(X)).

sophie_could_date(X) if male(X) and vegetarian(X).

 

- : a possible date for sophie is joshua.

, -.

 

, , , male(X) smoker(X), X .

, : sophie_could_date(X) if not(smoker(X)) and male(X) , .. smoker(X), , .

 

5: .

, .

:

1) alan ivan?

2) marilyn?

3) fay?

4) marilyn beverly, ?

 

: (.EXE) .

 

, , , .

:

/* :

father -

parent -

uncle -

brother -

grandfather -

male -

female -

sister -

mother -

is - , */

domains

person = symbol

predicates

male(person)

female(person)

father(person,person)

mother(person,person)

sister(person,person)

parent(person,person)

brother(person,person)

uncle(person,person)

grandfather(person,person)

clauses

male(alan).

male(charles).

male(bob).

male(ivan).

female(beverly).

female(fay).

female(marilyn).

female(sally).

mother(marilyn,beverly).

mother(alan,sally).

father(alan,bob).

father(beverly,charles).

father(fay,bob).

father(marilyn,alan).

parent(X,Y) if mother(X,Y).

parent(X,Y) if father(X,Y).

brother(X,Y) if /* Y, */

male(Y) and /*Y */

parent(X,P) and /* */

parent(Y,P) and /* Y */

X <> Y. /* X Y */

sister(X,Y) if /* Y */

female(Y) and /*Y - */

parent(X,P) and /* X P */

parent(Y,P) and /* Y P */

X <> Y. /*X Y */

uncle(X,U) if /* X U */

mother(X,P) and /* X P */

brother(P,U). /* P U. */

uncle(X,U) if /* X U */

father(X,P) and /* X P */

brother(P,U). /* P U */

grandfather(X,G) if /* X G */

father(P,G) and /* P G */

mother(X,P). /* X P. */

grandfather(X,G) if /* X G */

father(X,P) and /* X P */

father(P,G). /* P G */

 

 

:

1) brother(ivan,alan) - ; ;

2) grandfather(marilyn,Gf),write(Gf) - : charles; : bob;

3) sister(fay,Sis),write(Sis) - ;

4) sister(marilyn,beverly) and write("marilyn is beverly's sister") or mother(marilyn,beverly) and write("marilyn is beverly's mother") - : marilyn is beverly's mother.

 



<== | ==>
2; ZnO; H2SiO3; NaNO3; MgCl2; NaClO; Ca(NO3)2; CO; | ,
:


: 2016-09-03; !; : 390 |


:

:

, , .
==> ...

1325 - | 1243 -


© 2015-2024 lektsii.org - -

: 0.043 .