2
$\begingroup$

How to generate the truth table to show that $p \implies (q \vee r)$ is equivalent to $(p \wedge \neg q ) \implies r$ ? Can I use BooleanTable?

$\endgroup$
  • 5
    $\begingroup$ BooleanTable[Implies[p, q || r], {p, q, r}] == BooleanTable[Implies[p && Not[q], r], {p, q, r}] $\endgroup$ – Dr. belisarius Dec 20 '13 at 0:48
  • 4
    $\begingroup$ Alternatively, Reduce[Equivalent[Implies[p, q || r], Implies[p && Not[q], r]]] $\endgroup$ – Daniel Lichtblau Dec 20 '13 at 0:57
4
$\begingroup$

(from the comments of belisarius & Daniel Lichtblau)

Equal[
  BooleanTable[Implies[p, q || r], {p, q, r}],
  BooleanTable[Implies[p && Not[q], r], {p, q, r}]
]

(* ==> True *)

Or without truth tables:

Reduce[Equivalent[Implies[p, q || r], Implies[p && Not[q], r]]]

(* ==> True *)
$\endgroup$
3
$\begingroup$

Here is a Rube Goldberg Machine that handles sequences of formulae.

truthTableFormattor[rawData_] := Insert[Insert[
Grid[rawData /. {0 -> 0, 
   1 -> Item[1, Background -> Lighter[Magenta]]}, 
 FrameStyle -> Gray, 
 Frame -> All], {Background -> {None, {GrayLevel[0.7], {White}}}, 
 Dividers -> {Black, {2 -> Black}}, Frame -> True, 
 Spacings -> {2, {2, {0.7}, 2}}}, 2], {Dividers -> All, 
Spacings -> .7 {1, 1}}, 2];


truthTable[f__] :=  Module[{}, atoms = Cases[Most[{f}],
 (a_ /;Length[a] == 0 \[And] Not[StringQ[a]])];heads = 
 ToString[TraditionalForm@#] & /@ {f};
  rawData = Transpose@Boole[BooleanTable[#, atoms] & /@ {f}];
  If[Last[{f}] === 1, 
   Transpose@Boole[BooleanTable[#, atoms] & /@ Most[{f}]], 
    If[Last[{f}] === "rev", 
    truthTableFormattor[{ToString[
       TraditionalForm@#] & /@ (Most@{f})}~Join~
      Transpose[(Reverse /@ 
      Boole[BooleanTable[#, atoms] & /@ (Most@{f})])]], 
     truthTableFormattor[{heads}~Join~rawData]]]];


truthTable[p, q, r, p \[Implies] (q \[Or] r), (p \[And] \[Not] q) \[Implies] r]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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