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
?
2 Answers
$\begingroup$
$\endgroup$
(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 *)
$\begingroup$
$\endgroup$
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]
BooleanTable[Implies[p, q || r], {p, q, r}] == BooleanTable[Implies[p && Not[q], r], {p, q, r}]
$\endgroup$Reduce[Equivalent[Implies[p, q || r], Implies[p && Not[q], r]]]
$\endgroup$