Solanki Vaibhav
Solanki Vaibhav

Reputation: 494

Creating implications in Prolog, where A implies B and B implies A, through generic rules

No smoke without fire, no fire without smoke.

Identify the conclusion and condition from above statement with a Prolog program. In the answer, the conclusion must be that if there is fire, there is smoke and if there is smoke, there must be fire.

How do I do this?

Please explain the answer.

Upvotes: -2

Views: 466

Answers (3)

MIRZA USAMA BAIG
MIRZA USAMA BAIG

Reputation: 1

I assume you want to write predicate rule for: If there is smoke there is fine.

Answer: smell(smoke, if) ^ reaction(fire)

Upvotes: 0

G_V
G_V

Reputation: 2434

I'm assuming this question is about how to create sensible rules which imply facts are true based on other facts known about certain atoms. If location 'a' is smoking, there must be fire at location 'a', therefore 'a' has fire.

smoke(a).
smoke(b).
fire(c).

fire(X) :- smoke(X).
smoke(X) :- fire(X).

?- fire(a).
true

?- fire(b).
true

?- fire(c).
true

?- smoke(c).
true

In case you want to specifically check whether something is on fire or smoking:

isFire(X) :- fire(X);smoke(X).
isSmoke(X) :- smoke(X);fire(X).

Example:

?- isFire(asbestos), smoke(asbestos).
false <- the first statement is never true so the second never gets called

The ; symbol means OR, so if either fire or smoke is true for a given fact, it will return true.

Upvotes: 0

Florian H
Florian H

Reputation: 3082

Both are possible because one could argue that there cant be smoke without fire and there cant be fire without smoke.

But given the sentence without prior knowledge about fire and smoke you can only conclude that there can only be smoke if there is a fire. So smoke is the condition because "if you see smoke (condition)" you "know there is a fire (conclusion)". But given only the sentence if you know there is fire you cant be sure there is smoke.

Upvotes: 2

Related Questions