2017-11-12 3 views
0

外部の任意の外部者が有効なID証明なしにキャンパスに入ることを許可するセキュリティー者は、 となります。有効な身分証明書を持たない一部の外部者は、 内にあります。これらのすべての部外者は、私はこのようなアプローチ上記の質問について 前方および後方連鎖のプロローグの例

(a) From the above statements, construct a knowledge base. 
(b) Implement forward and backward chaining. 
(c) Using the forward chaining and backward chaining, prove that 
“Mr. X must be suspended”. 
(d) Compare the efficiency of forward chaining and backward chain- 
ing algorithms with respect to the number of irrelevant clauses 
generated. 

氏X.

という名前 セキュリティ担当者がキャンパスに入ることを許可されました。

securityPerson(mrx). 
outsider(P). 
securityAllows(mrx,P). 
suspended(Z) :- securityPerson(Z),outsider(P),securityAllows(Z,P). 

クエリ:?

?- suspended(mrx). 
true. 
?- suspended(mrxa). 
false. 
?- trace. 
true. 
[trace] ?- suspended(mrx). 
Call: (7) suspended(mrx) ? creep 
Call: (8) securityPerson(mrx) ? creep 
Exit: (8) securityPerson(mrx) ? creep 
Call: (8) outsider(_G1937) ? creep 
Exit: (8) outsider(_G1937) ? creep 
Call: (8) securityAllows(mrx, _G1938) ? creep 
Exit: (8) securityAllows(mrx, _G1938) ? creep 
Exit: (7) suspended(mrx) ? creep 
true. 

+0

質問はしていません。 – Enigmativity

+0

あなたは[ask]を読むべきです。 – Enigmativity

答えて

0

を助けてくださいされていない場合それは何が正しいとは思えない、それは正しくありません。あなたは「キャンパス内」をコーディングしていません。また、あなたのルールはX氏が部外者であることを暗示しているようです。あなたは、outsider/1節に(n個の暗黙的に普遍的に定量化された)変数を持つ代わりに、いくつかの人を作り上げるべきです。

関連する問題