Solutions

advertisement
SCL exam solutions, UNL 20/02/06
Exercise #1:
This is the simplest solution (I think) but others are possible:
(1) function symbols: {0\0, f\2, s\1}
Hydra ::= 0 | f(Hydra, N)
N ::= 0 | s(N)
(2) rewriting rules:
(i) f(X,0) -> X
(ii) f(X,s(Y)) -> f(f(X,Y),Y)
(iii) f(X,s(s(Y))) -> f(f(X,Y),Y)
(3) polynomial ordering:
f(X,Y) --> X+Y
s(X) --> 3*X
0 --> 1
then, check the rules:
(i) X+1 > X
(ii) X+3*Y > X+2*Y
(iii) X+9*Y > X+2*Y
(4) the normal forms are:
nf ::= 0 | s(nf) | f(nf,f(nf))
The only nf that is a Hydra is 0, and it's the dead hydra.
Claim: All Hydras can reduce to 0.
Proof: by checking syntax of Hydras according to (1)
(a) 0 ok, is a Hydra
(b) f(X,0) -> X ok, remains a Hydra
(c) f(X,s(Y)) -> f(f(X,Y),Y) ok, remains a Hydra
(d) f(X,s(s(Y))) -> f(f(X,Y),Y) ok, remains a Hydra
Æ so any Hydra reduces in one step to another hydra,
since the system is terminating and 0 is the only Hydra normal form,
all Hydra's must die eventually
(5) there is one critical pair between the 2nd and 3rd rule,
it can be joined like this:
[n] -> [n-1,n-1] ->2 [n-1,n-1,n-1,n-1] ->4 [n-2,n-2,n-2,n-2] ->? [n-2,n-2]
||
\/
[n-2,n-2]
Æ termination + all critical pairs are joinable = confluency
Exercise #2:
part 1:
(Å)
take some n
(*)assume that P(m) for all m<n implies P(n).
There are two cases:
n=0: Then P(0) holds trivially (**)
n>0: Let P'(n) = P(0) /\ P(1) /\ ... /\ P(n)
by (*) P'(n) implies P'(n+1)\\
By (**) P'(0) also holds
Then (by the first principle) P'(n) for all n.
Then (by def. of P') P(n) holds for all n.
(Æ)
the second principle subsumes the first
part 2:
Let P(X):= (AY) even(X) /\ even(Y) -> even(X+Y)
P(0) holds iff (AY) even(0) /\ even(Y) -> even(0+Y)
iff (AY) TRUE /\ even(Y) -> even(0+Y) (by axiom 3)
iff (AY) even(Y) -> even(Y) (by axiom 1)
iff TRUE (obviously)
P(s(0)) holds iff (AY) even(s(0)) /\ even(Y) -> even(s(0)+Y)
iff (AY) FALSE /\ even(Y) -> even(s(0)+Y) (by axiom 4)
iff TRUE (obviously)
(AX) P(X) -> P(s(s(X)) holds
iff (AX) [(AY) even(X) /\ even(Y) -> even(X+Y)] -> [(AY) even(s(s(X))) /\ even(Y) -> even(s(s(X))+Y)]
iff (AX) [(AY) even(X) /\ even(Y) -> even(X+Y)] -> [(AY) even(X) /\ even(Y) -> even(s(s(X))+Y)] (by
ax 5) iff (AX) [(AY) even(X) /\ even(Y) -> even(X+Y)] -> [(AY) even(X) /\ even(Y) -> even(s(s(X)+Y))]
(by ax 2) iff (AX) [(AY) even(X) /\ even(Y) -> even(X+Y)] -> [(AY) even(X) /\ even(Y) ->
even(s(s(X+Y)))] (by ax 2) iff (AX) [(AY) even(X) /\ even(Y) -> even(X+Y)] -> [(AY) even(X) /\
even(Y) -> even(X+Y)] (by ax 5) iff TRUE (obviously)
Then by the induction principle (AX) P(X) follows, which is what we wanted to prove.
Exercise #3:
F = { if <-> ch \/ ck, ck <-> gc \/ cf}
F_A = { ch, gc, cf}
I = \emptyset
-------------------------------------------F_<- = {if <- ch, if <- ck, ck <- gc, ck <- cf}
F_-> = { if -> ch \/ ck, ck -> gc \/ cf }
--------------------------------------------model generation: consider {if} UNION F_-> :
minimal models:
{if, ck, gc} \intersection F_A = {gc}
{if, ck, cf} \intersection F_A = {cf}
{if, ch} \intersection F_A = {ch}
---------------------------------------------SDL tree for F_<-:
<- if
/\
/ \
/
<- ch
\
<- ck
/\
/ \
/
\
<- gc
<- cf
explanation: ch \/ gc \/ cf
-------------------------------------------------\
Exercise #4:
part 1:
It is not required the students provide a full featured proof here, just to give a sketch as follows:
Since extenxions are deductively closed the following holds for all extensions F, and all formulas
A,B:
claim:
-A \notin F and -B \notin F
iff
-(A/\B) \notin F
proof:
by showing the contrapositive: -A \in F or -B \in F iff -(A/\B) \in F which follows from F being
deductively closed.
Now we can show that, F is an extension of <F_D,F_W> iff it is an extension of <F_D',F_W> by
following theorem 11.7:
F = UNION(i>=0) F_i. We will show that all F_i are the same no matter for which knowledge base
we check.
F_0 = F_W (this step is equivalent for both knowledge bases)
Let's assume that F_i is the same for both knowledge bases.
Then F_i+1 = T(F_i) UNION X_i+1
such that H \in X_i+1 iff
there is x,y such that p(x,y) \in F_n and
NOT ( s(x) AND NOT(r(y)) ) \notin F (*) (for <F_D,F_W>)
by the above claim, this step (*) is equivalent with checking (**)
NOT s(x) \notin F and NOT NOT r(y) \notin F (**) (for <F_D',F_W>)
Therefore F_i+1 is the same for both knowledge bases.
Therefore F is the same for both knowledge bases.
part 2:
Ext1=T({q(a,b),p(a,b)})
Ext2=T({q(a,b),p(a,b),r(a)})
part 3:
add p(a,b) Æ -s(a), this excludes the second extension
other solutions are possible
Download