Prolog?? PowerPoint???????????????????????????. - PowerPoint PPT Presentation

About This Presentation
Title:

Prolog?? PowerPoint???????????????????????????.

Description:

Title: PowerPoint Presentation Created Date: 1/1/1601 12:00:00 AM Document presentation format: Other titles: Times New Roman MS P ... – PowerPoint PPT presentation

Number of Views:129
Avg rating:3.0/5.0
Slides: 25
Provided by: nuisAcJp
Category:

less

Transcript and Presenter's Notes

Title: Prolog?? PowerPoint???????????????????????????.


1
Prolog??PowerPoint???????????????????????????.
  • 2002??????????????????(???????A)??????????????????
    ???.
  • ???? (t-nakada_at_jaist.ac.jp)

2
??? (?????) (1)
  • ????????????.
  • ???,a, a0, coffee?????????(????)????.
  • ???,X,_a,_??????????,???,_(??)????.
  • ???,???????.?????????????????????.??????????.
  • ????????
  • ????????
  • ????????

3
??? (?????) (2)
  • ????????,??????.
  • grandchild(X,Z)- parent(Z,Y), parent(Y,X).
  • ancestor(X,Y)- parent(X,Y).
  • (ancestor(Y,X)- parent(Y,X).?,????)
  • ???,??????.????????????????????.????,????????.
  • ????????,??????????.

4
grandchild ?? (???)
grandchild(X,??).
parent(??,???). parent(??,???). parent(??
,???). parent(?,???). parent(?,???). pa
rent(?,???). parent(???,???). parent(???
,???). grandchild(GC,GF)- parent(GF,FA),paren
t(FA,GC).
GCX, GF??
X???
parent(??,FA),parent(FA,X).
FA???
FA???
X???
FA???
parent(??,???).
parent(???,X).
?- grandchild(X,??). X ???
X???
X???
parent(???,???).
5
grandchild ?? (???)
grandchild(X,???).
parent(??,???). parent(??,???). parent(??
,???). parent(?,???). parent(?,???). pa
rent(?,???). parent(???,???). parent(???
,???). grandchild(GC,GF)- parent(GF,FA),paren
t(FA,GC).
GCX, GF???
???????
??
parent(???,FA),parent(FA,X).
FA???
FA???
FA???
??
???????
parent(???,???).
parent(???,X).
?- grandchild(X,???). no
6
Prolog???????????2???? (1)
  • ??????
  • ???,???????????????,??/?????????.
  • ??/????,???????????????.
  • ??/????,??????????????????????????????.
  • grandchild(GC,GF) - parent(GF,FA),parent(FA,GC)

7
Prolog???????????2???? (2)
  • ???????
  • ???????,????????????????.
  • ???,??,???????????,???????????????.
  • ????,????????Prolog??????????????????,????????????
    .????,?????????????.

8
ancestor??
ancestor(X,???).
parent(??,???). parent(??,???). parent(??
,???). parent(?,???). parent(?,???). pa
rent(?,???). parent(???,???). parent(???
,???). ancestor(X,Z)-parent(X,Z). ancestor(X,Z
)-parent(X,Y), ancestor(Y,Z).
parent(X,???). XX,Z???
parent(???,???). X???
parent(???,???). X???
parent(X,Y),ancestor(Y,???). XX,Z???
parent(??,???),ancestor(???,???).
X??,Y???
?- ancestor(X,???). X ??? ? X ??? ?
X ?? ?
parent(??,???), parent(???,???).
X???,Z???
9
????????
  • fact(??)?rule??????.
  • ----- fact --------------------------------------
    --------------
  • parent(??,???). ???????????
  • parent(?,???). ??????????
  • ----- rule --------------------------------------
    --------------
  • X?Z?????,X?Z??????.
  • ancestor(X,Z)- parent(X,Z).
  • X?Y???,??,Y?Z??????,X?Z??????.
  • ancestor(X,Z)- parent(X,Y), ancestor(Y,Z).

10
???
  • 1,a,b,coffee,X ??????,?????????????.
  • ???????????????????.
  • 1,a,10,c
  • ??,???????????.
  • ?????????????????(??)???(?????????).
  • XY 1,2,3 (X1, Y2,3)
  • XY 1 (X1, Y).
  • XY no

11
member?? (???)
member(X,X_). member(X,_Y)- member(X,Y).
member(a, x,y,a).
?- member(a, x,y,a). yes
12
member?? (???)
member(X,X_). member(X,_Y)- member(X,Y).
member(a, x,y).
?- member(a, x,y). no
13
?????????
  • XY,Y1.
  • X1,Y1.
  • parent(X)parent(taro).
  • Xtaro.
  • parent(X)grandchild(taro).
  • no
  • XY a,b,c,d.
  • Xa, Yb,c,d.
  • X1.
  • X1.
  • X 1.
  • X1.

14
???????
  • ???????????????????,????????.
  • Prolog?????,?????????????????,?????????,??????????
    ?????.
  • ?????????????,Prolog?????,?????????????????.
  • 1??????????,??????????? (?????)?????,???????????
    ???????????.

15
???,????
  • grandchild(GC,GF) - parent(GF,FA) ,
    parent(FA,GC).
  • GF????FA???,??,FA????GC???,GC?GF?????. (???)
  • parent(PA,C) - father(PA,C) mother(PA,C).
  • PA?C???,???,PA?C??????,PA?C?????.
  • parent(PA,C)-father(PA,C).
    parent(PA,C)-mother(PA,C). ???
  • man(X) -gt father(X,Y) mother(X,Y).
  • man(X)??????,father(X,Y)?????.?????,mother(X,Y)???
    ??.

16
????
  • ?????????????????????????.
  • member(X,_Y)- member(X,Y).
  • ??????????????????,??,????(?????)?,n???n1????????
    ?????????.
  • ???? member(X,X_).
  • n,n1????? member(X,_Y)-
    member(X,Y).

17
??
  • Prolog????,?????????,???????????.
  • parent(??,???). (?????)
  • ???,?????????,?????
  • \ parent(??,???). (Prolog???)
  • ???,????????,????????

18
unmarried_man??
unmarried_man(X)- \ married(X),
man(X). man(bill). married(joe).
unmarried_man(bill).
?- unmarried_man(bill). yes ?-
unmarried_man(taro). no
unmarried_man(taro).
19
???
  • ??????????
  • married(X,Y)- married(Y,X).
  • ???????,
  • Control????????C?????.
  • Prolog interruption???????,a??????,?????????.

20
???? (????????????)
  • X 23.
  • X23.
  • X is 23.
  • X5.
  • X 23, Y is X.
  • X23, Y5.
  • X 23, Y X.
  • X23, Y23.

21
?????????? (1)
child(taro). adult(jiro). members(jiro). fee(X,100
0)- child(X),members(X). fee(X,2000)-
adult(X),members(X).
fee(taro,X).
?- fee(taro,X). no
22
?????????? (2)
fee(taro,X).
child(taro). adult(jiro). members(jiro). fee(X,100
0)- child(X),!,members(X). fee(X,2000)-
adult(X),!,members(X).
fee(bill,X).
?- fee(taro,X). no ?- fee(bill,X). no
23
?????????? (3)
  • C - a,b. C - d,e.
  • a,b?????????,d,e?????.
  • C - !,a,b. C - d,e.
  • a,b?????????,d,e??????????.
  • C - a,!,b. C - d,e.
  • a?????????,d,e??????,b?????????,d,e??????.
  • C - a,b,!. C - d,e.
  • a,b?????????,d,e?????.?????a,b??????,d,e??????????
    ?.

24
???
Write a Comment
User Comments (0)
About PowerShow.com