Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Equal[
- BooleanTable[Implies[p, q || r], {p, q, r}],
- BooleanTable[Implies[p && Not[q], r], {p, q, r}]
- ]
- (* ==> True *)
- Reduce[Equivalent[Implies[p, q || r], Implies[p && Not[q], r]]]
- (* ==> True *)
- tableFormattor[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]
Add Comment
Please, Sign In to add comment