-
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
2 changed files
with
90 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,58 @@ | ||
/** | ||
* Exercise 13.1 | ||
* a. | ||
* i. Exercise 3.2 | ||
*/ | ||
|
||
directlyIn(katarina,olga). | ||
directlyIn(olga,natasha). | ||
directlyIn(natasha,irina). | ||
in(X,Y) :- directlyIn(X,Y). | ||
in(X,Y) :- directlyIn(Z,Y), in(X,Z). | ||
|
||
/** | ||
* in(katarina,natasha). => true. | ||
* in(olga, katarina). => false. | ||
* | ||
* ii. Exercise 4.5 | ||
*/ | ||
|
||
tran(eins,one). | ||
tran(zwei,two). | ||
tran(drei,three). | ||
tran(vier,four). | ||
tran(fuenf,five). | ||
tran(sechs,six). | ||
tran(sieben,seven). | ||
tran(acht,eight). | ||
tran(neun,nine). | ||
|
||
listtran([],[]). | ||
listtran([G|TG],[E|TE]) :- tran(G,E), listtran(TG,TE). | ||
|
||
/** | ||
* listtran([eins,neun,zwei],X). | ||
* X = [one, nine, two]. | ||
* | ||
* listtran(X,[one,seven,six,two]). | ||
* X = [eins, sieben, sechs, zwei]. | ||
*/ | ||
|
||
/** | ||
* b. | ||
* Prolog does implement at least a partial version of generalized modus ponens. | ||
* While universal instantiation is not explicitly stated, it is implied; with a | ||
* statement like the one below (fun(X).), universal instantiation will make it so | ||
* the query fun(<any parameter>). will return true. | ||
* Prolog does not have existential instantiation and cannot be given existential | ||
* instantiation. This is because while Prolog deals with positive, clear statements | ||
* well, such as a universal instantiation which makes an affirmative statement about | ||
* all, it doesn't deal well with uncertainty. And with an existential instantiation, | ||
* uncertainty is assigned to every variable; at least one has to have the assigned | ||
* quality, but it's not clear which one. | ||
*/ | ||
|
||
fun(X). | ||
|
||
|
||
|
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,32 @@ | ||
Exercise 13.2 | ||
on(a,b) | ||
on(b,c) | ||
supports(table,c) | ||
AxAy supports(x,y) => on(y,x) | ||
AxAy on(x,y) => above(x,y) | ||
AxAyAz above(x,y) ^ above(y,z) => above(x,z) | ||
|
||
Suppose: | ||
1. !above(a,table) ^ on(a,b) ^ on(b,c) ^ supports(table,c) | ||
|
||
Through (AxAy supports(x,y) => on(y,x)) | ||
^ supports(table,c) | ||
|
||
2. !above(a,table) ^ on(a,b) ^ on(b,c) ^ on(c,table) | ||
|
||
Through (AxAy on(x,y) => above(x,y)) | ||
^ on(a,b) ^ on(b,c) ^ on(c,table) | ||
|
||
3. !above(a,table) ^ above(a,b) ^ above(b,c) ^ above(c,table) | ||
|
||
Through (AxAyAz above(x,y) ^ above(y,z) => above(x,z)) | ||
^ above(b,c) ^ above(c,table) | ||
|
||
4. !above(a,table) ^ above(a,b) ^ above(b,table) | ||
|
||
Through AxAyAz (above(x,y) ^ above(y,z) => above(x,z)) | ||
^ above(a,b) ^ above(b,table) | ||
|
||
5. !above(a,table) ^ above(a,table) | ||
|
||
Contradiction. Therefore, above(a,table) must be true. |