limit(Id,Year,Limit) <- course(Id,Year,Inst,Room,Limit). course(cs322,1999,david,cicsr208,120). course(cs322,1998,craig,cicsr208,100). course(cs327,1999,jim,cicsr202,50).
prop(cs322_1999,identifier,cs322). prop(cs322_1999,year,1999). prop(cs322_1999,instructor,david). prop(cs322_1999,room,cicsr208). prop(cs322_1999,limit,120). prop(cs322_1998,identifier,cs322). prop(cs322_1998,year,1999). prop(cs322_1998,instructor,craig). prop(cs322_1998,room,cicsr208). prop(cs322_1998,limit,100). prop(cs327_1999,identifier,cs327). prop(cs327_1999,year,1999). prop(cs327_1999,instructor,jim). prop(cs327_1999,room,cicsr202). prop(cs327_1999,limit,50).
limit(Id,Year,Limit) <- prop(Obj,intentifier,Id) & prop(Obj,year,Year) & prop(Obj,limit,Limit).
For example, given the knowledge base:
Then ceval(cs322,if(fun,if(easy,99,80),if(confusing,55,70)),Val) should return Val=80.prop(cs322,fun,true). prop(cs322,easy,false). prop(cs322,interesting,true). prop(cs322,confusing,true).
ceval(Obj,V,V) <- value(V). ceval(Obj, if(Att,Then,Else), V) <- prop(Obj, Att, true) & ceval(Obj, Then, V). ceval(Obj, if(Att,Then,Else), V) <- prop(Obj, Att, false) & ceval(Obj, Else, V). value(N) <- number(N). value(true). value(false).