-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
killer(butch). | ||
married(mia, marsellus). | ||
dead(zed). | ||
kills(marsellus,X):-footmassage(X,mia). | ||
loves(mia,X):-gooddancer(X). | ||
eats(jules,X):-nutritious(X); tasty(X). | ||
|
||
/** | ||
* a. i. I built up the representations so that the nouns were consistently the | ||
* arguments (butch,mia,marsellus), and if a variable was required then | ||
* I would use X as a simple variable. The relational adjectives and verbs | ||
* were used as functors (married, kills, killer, eats). From there it was a | ||
* simple matter of determining which functors in regard to which arguments | ||
* implied which other functors in regard to which other arguments. | ||
*/ | ||
|
||
wizard(ron). | ||
hasWand(harry). | ||
quidditchPlayer(harry). | ||
wizard(X):- hasBroom(X), hasWand(X). | ||
hasBroom(X):- quidditchPlayer(X). | ||
|
||
/** | ||
* a. ii. | ||
* 1. wizard(ron). This returns true, since ron is defined as a wizard; but if a semicolon | ||
* is pressed, it returns false, since hasBroom(ron). and hasWand(ron). are not stated. | ||
* 2. witch(ron). This returns ERROR: Undefined procedure: witch/1 (DWIM could not correct | ||
* goal), since the functor witch is not defined. | ||
* 3. wizard(hermione). This returns false, because wizard(hermione). is not stated, and | ||
* neither are hasBroom(hermione). and hasWand(hermione). | ||
* 4. witch(hermione). This returns ERROR: Undefined procedure: witch/1 (DWIM could not | ||
* correct goal), since the functor witch is not defined. | ||
* 5. wizard(harry). This returns true; while wizard(harry). is not expressly stated, | ||
* hasBroom(harry). and hasWand(harry). are, which through modus ponens Prolog can use | ||
* to conclude wizard(harry). | ||
* 6. wizard(Y). This returns Y = ron, and if a semicolon is typed it returns Y = harry. | ||
* Y = ron is returned because wizard(ron). is expressly stated, and Y = harry is returned | ||
* for the same reason wizard(harry). returned true in the previous query. | ||
* 7. witch(Y). This returns ERROR: Undefined procedure: witch/1 (DWIM could not | ||
* correct goal), since the functor witch is not defined. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* a. i. | ||
* 1. bread = bread -> true. No instantiation occurs because there are no | ||
* variables involved. | ||
* 2. ’Bread’ = bread -> false. No instantiation occurs because there are | ||
* no variables involved. | ||
* 8. food(X) = food(bread) -> X = bread. X is instantiated to bread. | ||
* 9. food(bread,X) = food(Y,sausage) -> X = sausage, Y = bread. X is | ||
* instantiated to sausage, Y is instantiated to bread. | ||
* 14. meal(food(bread),X) = meal(X,drink(beer)) -> false. If X is | ||
* instantiated to drink(beer) then | ||
* meal(food(bread),drink(beer)) != meal(drink(beer),drink(beer)). If X is | ||
* instantiated to food(bread), then | ||
* meal(food(bread),food(bread)) != meal(food(bread),drink(beer)). | ||
*/ | ||
|
||
wizard(tom). | ||
house_elf(dobby). | ||
witch(hermione). | ||
witch('McGonagall'). | ||
witch(rita_skeeter). | ||
magic(X):-house_elf(X). | ||
magic(X):-wizard(X). | ||
magic(X):-witch(X). | ||
|
||
/* Swi-prolog doesn't allow us to query using functors that haven't been previously defined. In short, | ||
it doesn't allow us to unify variables with functors that haven't been used before. | ||
For instance: | ||
magic(house_elf). | ||
wizard(harry). | ||
magic(wizard). | ||
all return me variations on this error: Undefined procedure: wizard/1..... | ||
wizard/1 has not been used, so it cannot be queried (wizard(harry). and magic(wizard).) and it additionally | ||
prevents magic/1 being used on other functors, since magic/1 depends on wizard/1 | ||
However, if I add to the knowledge base the line | ||
wizard(tom). | ||
(or any other random atomic that has no relevance to the rest of the knowledge base, not necessarily tom) | ||
then all three return actual values (false, in each case), because the functor has now been defined and used. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
weighsduck(lady). | ||
floats(X):-weighsduck(X). | ||
wood(X):-floats(X). | ||
burn(X):-wood(X). | ||
witch(X):-burn(X). | ||
|
||
/* witch(lady). returns true */ |