This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
teaching:is:ind-solutions [2020/06/24 10:12] Franconi Enrico created |
teaching:is:ind-solutions [2020/06/24 17:11] (current) Franconi Enrico [12.9] |
||
---|---|---|---|
Line 2: | Line 2: | ||
===== 12.3 ===== | ===== 12.3 ===== | ||
+ | < | ||
+ | C={r(a), | ||
+ | C ∪ {q(a)} by rule 2 with X/a,Y/b | ||
+ | |||
+ | C ∪ {p(a)} by rule 1 with X/a | ||
+ | |||
+ | C ∪ {q(d)} by rule 2 with X/d,Y/b | ||
+ | |||
+ | C ∪ {q(e)} by rule 2 with X/e,Y/d | ||
+ | |||
+ | C ∪ {p(e)} by rule 1 with X/e | ||
+ | |||
+ | </ | ||
===== 12.4 ===== | ===== 12.4 ===== | ||
+ | |||
+ | yes(R) ⇐ two_doors_east(R, | ||
+ | | ||
+ | imm_east(E1, | ||
+ | | ||
+ | yes(R) ⇐ imm_east(R, | ||
+ | | ||
+ | | ||
+ | | ||
+ | yes(R) ⇐ imm_west(M1, | ||
+ | | ||
+ | | ||
+ | | ||
+ | yes(r111) ⇐ imm_east(r107, | ||
+ | | ||
+ | | ||
+ | yes(r111) ⇐ imm_west(r107, | ||
+ | no substitution available | ||
+ | | ||
+ | until imm_west(r107, | ||
===== 12.5 ===== | ===== 12.5 ===== | ||
+ | By selecting the rightmost conjunct, there would be only one choice: | ||
+ | |||
+ | yes(R) ⇐ two_doors_east(R, | ||
+ | | ||
+ | imm_east(E1, | ||
+ | | ||
+ | yes(R) ⇐ imm_east(R, | ||
+ | | ||
+ | | ||
+ | | ||
+ | yes(R) ⇐ imm_east(R, | ||
+ | | ||
+ | | ||
+ | | ||
+ | yes(R) ⇐ imm_east(R, | ||
+ | | ||
+ | | ||
+ | yes(R) ⇐ imm_west(r109, | ||
+ | | ||
+ | | ||
+ | yes(r111) ⇐ | ||
+ | | ||
+ | It is optimal because the query had a constant in its second argument, therefore instantiating the variable W of the two_doors_east predicate. But it would not be optimal for queries like: | ||
+ | |||
+ | ask two_doors_east(r107, | ||
===== 12.6 ===== | ===== 12.6 ===== | ||
+ | (a) | ||
+ | yes(R) ⇐ two_doors_east(r107, | ||
+ | | ||
+ | imm_east(E1, | ||
+ | | ||
+ | yes(R) ⇐ imm_east(r017, | ||
+ | | ||
+ | | ||
+ | | ||
+ | yes(R) ⇐ imm_west(M1, | ||
+ | | ||
+ | | ||
+ | | ||
+ | yes(R) ⇐ imm_east(r105, | ||
+ | | ||
+ | | ||
+ | yes(R) ⇐ imm_west(R, | ||
+ | | ||
+ | | ||
+ | yes(r103) ⇐ | ||
+ | | ||
+ | (b) | ||
+ | | ||
+ | yes(R) ⇐ next_door(R, | ||
+ | | ||
+ | | ||
+ | yes(R) ⇐ imm_east(R, | ||
+ | | ||
+ | | ||
+ | yes(R) ⇐ imm_west(r107, | ||
+ | | ||
+ | | ||
+ | yes(r109) ⇐ | ||
+ | | ||
+ | Another derivation by backtracking to (*) and selecting another clause to resolve against: | ||
+ | |||
+ | yes(R) ⇐ next_door(R, | ||
+ | | ||
+ | | ||
+ | yes(R) ⇐ imm_west(R, | ||
+ | | ||
+ | | ||
+ | yes(r105) ⇐ | ||
+ | |||
+ | |||
+ | < | ||
+ | |||
+ | ...similar to (d)... | ||
+ | |||
+ | (d) | ||
+ | |||
+ | yes(R) ⇐ west(r107, | ||
+ | | ||
+ | | ||
+ | yes(R) ⇐ imm_west(r107, | ||
+ | | ||
+ | | ||
+ | yes(r109) ⇐ | ||
+ | |||
+ | Another derivation by backtracking to (*) and selecting another clause to resolve against: | ||
+ | |||
+ | yes(R) ⇐ west(r107, | ||
+ | | ||
+ | imm_west(W1, | ||
+ | west(M1, | ||
+ | | ||
+ | yes(R) ⇐ imm_west(r107, | ||
+ | | ||
+ | | ||
+ | | ||
+ | yes(R) ⇐ west(r109, | ||
+ | resolve with west(W2,E2) ⇐ imm_west(W2, | ||
+ | | ||
+ | yes(R) ⇐ imm_west(r109, | ||
+ | | ||
+ | | ||
+ | yes(r111) ⇐ | ||
===== 12.8 ===== | ===== 12.8 ===== | ||
+ | |||
+ | (a) | ||
+ | f(X, | ||
+ | |||
+ | |||
+ | (b) | ||
+ | yes(c(l, | ||
+ | |||
+ | |||
+ | < | ||
+ | |||
+ | append(c(l, | ||
+ | | ||
===== 12.9 ===== | ===== 12.9 ===== | ||
+ | |||
+ | (a) | ||
+ | {Z/ | ||
+ | |||
+ | (b) | ||
+ | {W/ | ||
+ | |||
+ | < | ||
+ | |||
+ | {P/ | ||
===== 12.14 ===== | ===== 12.14 ===== | ||
+ | (a) Here is a top-down derivation: | ||
+ | |||
+ | yes(Y) ⇐ adj(b, | ||
+ | choose clause 3, with { A/ | ||
+ | | ||
+ | yes(Y) ⇐ ap(F1, | ||
+ | choose clause 2, under | ||
+ | { F1/ | ||
+ | | ||
+ | yes(Y) ⇐ ap(T2, | ||
+ | choose clause 1 under { T2/ | ||
+ | | ||
+ | yes(b) ⇐ | ||
+ | |||
+ | (b) Yes, there is one more answer . | ||
+ | at (*) | ||
+ | choose clause 2 under | ||
+ | { T2/ | ||
+ | | ||
+ | yes(Y) <- ap(T3, | ||
+ | choose clause 1 under { T3/ | ||
+ | | ||
+ | yes(a) <- |