Math If-then vs. Implies

I am new to Mathematica (v8) and use it to program sentence logic.

I am wondering what is the difference between If and Implies . For example, photographs both If[p,q] and Implies[p,q] return q for p=True (as expected).

But when I try to get SatisfiabilityInstances, I get the following:

 SatisfiabilityInstances[If[p, q], {p, q}] (* {{True, True}} *) 

if I donโ€™t ask about it anymore:

 SatisfiabilityInstances[If[p, q], {p, q}, All] 

Satisfactory conditions :: boolv: "If [p, q] is not a Boolean value in {False, True}.

But:

 SatisfiabilityInstances[Implies[p, q], {p, q}, All] 

returns expected from:

 (* {{True, True}, {False, True}, {False, False}} *) 

What causes this difference in output?

+7
source share
2 answers

This is what he said - If not logical, i.e. returns not only true or false. Try If[False,True] and you will not see the result. If[a,b,c,d] can return any b, c and d, not only logical, for example, If[True,2] returns 2. Thus, If intended for branching (even being functional), while Implies is a normal boolean function.

PS Ah, Implies can also come back 2 . Therefore, the difference is that If[False,True] returns nothing, so the SatisfiabilityInstances function cannot find the true area.

PPS More precisely, if the first argument of If[] is False , then it returns the third argument. When it is absent, it returns nothing.

+4
source

You can try:

 SatisfiabilityInstances[If[p, q, Not[q]], {p, q}, All] 
+3
source

All Articles