Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

How can we make a comprehensive statement, which will correspond to the truth table of xor (A, B, C) (means that only true if exactly one of A,B,C is true) by combining logical operators AND (&), OR (|), XOR (xor) and NOT (!)?

share|improve this question

closed as unclear what you're asking by belisarius, m_goldberg, Yves Klett, Michael E2, Kuba Apr 8 at 12:57

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Markus, welcome to mathematica.stackexchange.com. Could you please show us what you have tried already yourself? –  Jacob Akkerboom Apr 8 at 11:04
3  
And just to make sure, is this a question about the software Mathematica (and not math in general)? –  Yves Klett Apr 8 at 11:05
1  
The built-in (Mathematica) function Xor does what is required btw. –  Jacob Akkerboom Apr 8 at 11:07
2  
@JacobAkkerboom Plus LogicalExpand... –  Michael E2 Apr 8 at 12:16
    
oneTrue[a_, b_, c_] := Xor[a, b, c] && Not[a && b] && Not[a && c] && Not[b && c] –  Daniel Lichtblau Apr 8 at 14:40

2 Answers 2

For illustrative purposes:

tup = Tuples[{False, True}, 3];
g[x_, y_] := And[Or[x, y], Not[And[x, y]]]
h[x_, y_] := And[Or[x, y], Or[Not[x], Not[y]]]
g[x_, y__] := Fold[g, x, {y}];
h[x_, y__] := Fold[h, x, {y}];
TableForm[{##, Style[Xor[##], Red], Style[g[##], Blue], 
    Style[h[##], Purple]} & @@@ tup, 
 TableHeadings -> {None, {"", "", "", Xor, g, h}}]

enter image description here

share|improve this answer

Your definition of Xor is off, but going on what the OP said you want the result to be (only true if exactly one of the three arguments is true):

bc = BooleanCountingFunction[{1}, 3][a, b, c];

BooleanConvert[bc]

Transpose[{Tuples[{True, False}, {3}], BooleanTable[bc]}]

(*

(a && ! b && ! c) || (! a && b && ! c) || (! a && ! b && c)

{{{True, True, True}, False}, {{True, True, False}, False}, 
 {{True, False, True}, False}, {{True, False, False},True}, 
 {{False, True, True}, False}, {{False, True, False},True}, 
 {{False, False, True}, True}, {{False, False, False}, False}}

*)
share|improve this answer
    
sorry me... deleted comments –  ubpdqn Apr 8 at 11:50
    
@ubpdqn: No worries, I just wanted to be sure I had not blundered. :-) –  rasher Apr 8 at 11:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.