人工智能

 

domains 
    name=symbol. 
predicates 
    mother(name,name). 
    father(name,name). 
    grandfather(name,name). 
    grandmother(name,name). 
    sister(name,name). 
    aunt(name,name). 
goal 
    grandmother(a,X),write("X=",X),nl, 
    father(b,Y),write("Y=",Y),nl, 
    sister(d,Z),write("Z=",Z),nl, 
    aunt(d,T),write("T=",T). 
clauses 
    mother(a,c). 
    mother(a,d). 
    mother(c,g). 
    mother(c,f). 
    father(b,c). 
    father(b,d). 
    father(e,g). 
    father(e,f). 
    grandfather(X,Z):-father(X,Z),father(Y,Z). 
    grandmother(X,Z):-mother(X,Y),mother(Y,Z). 
    sister(X,Y):-mother(Z,X),mother(Z,Y). 
    aunt(X,Y):-mother(Z,Y),sister(Z,X). 

 

上一篇:设计原则看这篇就够了


下一篇:软件设计模式六大原则之依赖倒置原则(PHP语言实现)