-
Notifications
You must be signed in to change notification settings - Fork 1
/
homewwork05.txt
58 lines (48 loc) · 2.26 KB
/
homewwork05.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
First-Order Logic — Homework 5
1. Do exercise 7.2 in the text. Do your work on paper and then speculate on whether you could program the solution in
Prolog (easily)? Explain why or why not?
ANSWER:
Rules.
isMythical => isImmortal
!isMythical => !isImmortal && isMammal
isImmortal || isMammal => isHorned
isHorned => isMagical
-- Inference --
!isMythical => !isImmortal && isMammal = (!isMythical => !isImmortal) && (!isMythical => isMammal)
-> Since !isMythical => !isImmortal (which is equivalent to isImmortal => isMythical),
and isMythical => isImmortal are true, isMythical = isImmortal
-> Since isMythical = isisImmortal and (!isMythical => isMammal) = (!isImmortal => isMammal) = (isImmortal || isMammal)
-> Since isImmortal || isMammal is true, isHorned is also true.
-> Since isHorned is true, isMagical is also true.
So, the unicorn is horned and magical.
---- Speculation about prolog:
I don't think we can easily solve the problem in prolog. Prolog proves statements by using modus ponens and searching
its knowledge base for facts or for other rules that eventually resolve to facts. However, the unicorn problem's
knowledge base does not have any facts. So, prolog won't be able to find a solution for it. (At least, it can't find
a solution with enumerating the truth table.)
Do LPN! exercise 2.4 (i.e., the crossword problem).
ANSWER: this is probably the laziest response...
word(astante, a,s,t,a,n,t,e).
word(astoria, a,s,t,o,r,i,a).
word(baratto, b,a,r,a,t,t,o).
word(cobalto, c,o,b,a,l,t,o).
word(pistola, p,i,s,t,o,l,a).
word(statale, s,t,a,t,a,l,e).
crossword(W1, W2, W3, W4, W5, W6) :-
/*get the characters that will be at the intersections.*/
word(W1, _,W1P2,_,W1P4,_,W1P6,_),
word(W2, _,W2P2,_,W2P4,_,W2P6,_),
word(W3, _,W3P2,_,W3P4,_,W3P6,_),
word(W4, _,W4P2,_,W4P4,_,W4P6,_),
word(W5, _,W5P2,_,W5P4,_,W5P6,_),
word(W6, _,W6P2,_,W6P4,_,W6P6,_),
/*make sure characters at the intersections match.*/
W1P2 = W4P2,
W1P4 = W5P2,
W1P6 = W6P2,
W2P2 = W4P4,
W2P4 = W5P4,
W2P6 = W6P4,
W3P2 = W4P6,
W3P4 = W5P6,
W3P6 = W6P6.