first go to the folder that the database is located (the *.pl files) to load the database use [*] where star is the name of the database ############################################################################################################################### #from here on it's Jamies code# ############################################################################################################################### #this is only applicable using the database that Jamie has used during his lecture. in this case its lecture 16 [l16] database# ############################################################################################################################### wet(water). #returns true wet(milk). #returns true wet(bycicle_lubricant). #returns false #prolog has a database in memory and searches the database for assertions that user inputs# wet(X). #prolog searches the database for possible instanciations of X which would provide "true" output #everything starting with a capital letter is a variable #everything starting with a lowercase letter is a constant wet(x). #would output "water". it will find the first hit in the database #if the user presses "y" then prolog assumes that the instanciation is correct and comes to a halt. #if the user presses "n" then prolog will produce next possible instanciation and wait for input unless its the last item in the database. #as long as "n" keeps being pressed during the instanciations, the program will run. mother(X, ann). #returns betty mother(delia, Y). #returns betty (again) father(X,Y). #returns instanciations of X and Y which would provide true for both #X = chris, Y = ann; (first time, press "n") #X = eric, Y = betty; (no other possibilities, program comes to a stop) #not possible to input only 1 variable mother(betty, _). #instructs prolog to search the database for anything containing "betty" as first input and returns true if such exists. mother(X, _). #returns instanciation of X where X would be a mother of a child (does not require child input) mother(_, _). #corresponds to "is someone a mother of someone" #would require the "n" or "y" input from user if there is more than one possibility #would return only true if exists #if it doesnt exist, then returns and error of "Undefined procedure" parent(betty, jane). #returns true, because betty is mother of jane parent(X,Y). #returns all possible instanciations of both mother(X,Y) and parent(X,Y). parent(chris, ann). #returns true (this particular function was used to explain how parent function works (watch the lecture video for explanation at 40:00))