160 likes | 415 Views
PROLOG. www.MrsBillinghurst.net. The Prolog Language. Prolog allows us to make use of Facts and Rules in order to establish the relationships between objects in a system. What’s the point??!
E N D
PROLOG www.MrsBillinghurst.net
The Prolog Language • Prolog allows us to make use of Facts and Rules in order to establish the relationships between objects in a system. • What’s the point??! • Prolog is predominantly used in AI, however there have also been incidents of Prolog being used to prototype logic, and forming the basis of insurance companies calculating risk and ultimately premiums to be paid. www.MrsBillinghurst.net
Our Family Tree Rules mother(M,X) :- female(M), parent(M,X). father(F,X) :- male(F), parent(F,X). husband(H,X) :- male(H), spouse(H,X). wife(W,X) :- female(W), spouse(X,W). illegitimate(X) :- mother(M,X), father(F,X), not(wife(M,F)). snow(X) :- illegitimate(X). www.MrsBillinghurst.net
Are You A Lannister? Facts lannister(tywin). lannister(jaime). lannister(cersai). lannister(tyrion). Rules alwayspaysdebts(x) :- lannister(x). male(tywin). male(jaime). female(cersai). male(tyrion). www.MrsBillinghurst.net
Are You A Lannister? Facts parent(tywin, cersai). parent (tywin, jaime). parent(tywin, tyrion). parent(jaime, joffrey). parent(jaime, myrcella). parent(jaime, tommen). parent(cersai, joffrey). parent(cersai, myrcella). parent(cersai, tommen). spouse(tyrion, sansa). www.MrsBillinghurst.net
Are You A Baratheon? male(robert). male (stannis). male(renly). male(joffrey). female(myrcella). male(tommen). female(shireen). Facts baratheon(robert). baratheon (stannis). baratheon(renly). baratheon(joffrey). baratheon(myrcella). baratheon(tommen). baratheon(shireen). www.MrsBillinghurst.net
Are You A Baratheon? Facts parent(stannis, shireen). parent(selyse, shireen). spouse(stannis,shireen). spouse(robert, cersai). spouse(renly, margaery). spouse(joffrey, margaery). www.MrsBillinghurst.net
Are You A Stark? Facts stark(rickard). stark(eddard). stark(robb). stark(brandon). stark(lyanna). stark(benjen). stark(jon). stark(sansa). stark(arya). stark(bran). stark(rickon). www.MrsBillinghurst.net
Are You A Stark? Facts male(rickard). male(eddard). male(robb). male(brandon). female(lyanna). male(benjen). male(jon). female(sansa). female(arya). male(bran). male(rickon). www.MrsBillinghurst.net
Are You A Stark? Facts parent(eddard,robb). parent(eddard,jon). parent(eddard,sansa). parent(eddard,arya). parent(eddard, bran). parent(eddard, rickon). parent(caitlyn, robb). parent(caitlyn,sansa). parent(caitlyn,arya). parent(caitlyn, bran). parent(caitlyn, rickon). spouse(eddard, caitlyn). www.MrsBillinghurst.net
Are You A Targaryan? male(aerys). male(viserys). female(daenrys). male(drogo). Facts targaryan(aerys). targaryan(viserys). targaryan(daenrys). dragon(drogon). dragon(rhaegal). dragon(viserion). dothraki(drogo). www.MrsBillinghurst.net
Are You A Targaryan? Facts parent(daenrys, drogon). parent(daenrys, rhaegal). parent(daenrys, viserion). spouse(drogo, daenrys). Rules wife(x,drogo) :- kalisi(x). Inthevault(x) : dragon(x). www.MrsBillinghurst.net
Anything Else? Facts handoftheking(tywin). handoftheking(jon_arryn). handoftheking(eddard). handoftheking(tyrion). kingofthenorth(robb). kingofthenorth(rickard). www.MrsBillinghurst.net
Anything Else? dead(aerys). dead(viserys). dead(drogo) Facts dead(rickard). dead(lyanna). dead(robert). dead(eddard). dead(renly). dead(joffrey). dead(benjen). dead(caitlyn). dead(robb). likelytodiewithoutwarning(X):- (male(X) ; female(X)), not(dead(X)). www.MrsBillinghurst.net