-3

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.

stefanobaghino
  • 11,253
  • 4
  • 35
  • 63
Solanki Vaibhav
  • 449
  • 6
  • 10
  • Rephrase: *There's fire **if** there is smoke*. Btw, the title of your question makes no sense to me. – lurker Jan 22 '18 at 11:58

3 Answers3

2

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.

Florian H
  • 3,052
  • 2
  • 14
  • 25
  • *Both are possible because one could argue that there cant be smoke without fire and there cant be fire without smoke.* Yes, actually, there can be smoke without fire. Common in fact. – lurker Jan 22 '18 at 13:03
  • 1
    Yes but this is not a physics task, but logic. So to simplify the problem one could argue like that. But that is actualy not the point because a machine does not have the common sense of a human to argue. it follows the rules given. So only smoke=condition and fire=conclusion is true in that case – Florian H Jan 22 '18 at 13:14
0

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.

G_V
  • 2,396
  • 29
  • 44
  • Can you give a query for your program that terminates? E.g. I would like to receive ```false.``` when calling ```fire(asbestos)```. But also the query ```fire(a)``` needs to be aborted, enumerating solutions by entering ```;``` will repeat ```true``` without ever ending. – lambda.xy.x Jan 29 '18 at 17:06
  • @lambda.xy.x The program assumes you are asking about known facts, so if you ask about is something fire or smoke, and there's no fact? Infinite recursion. You could write separate predicates that don't imply each other which allow you to check for the same thing but with unknowns. `isFire(X) :- fire(X);smoke(X). isSmoke(X) :- smoke(X);fire(X).` – G_V Jan 30 '18 at 08:31
0

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

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