Guest User

Untitled

a guest
Dec 18th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. Equal[
  2. BooleanTable[Implies[p, q || r], {p, q, r}],
  3. BooleanTable[Implies[p && Not[q], r], {p, q, r}]
  4. ]
  5.  
  6. (* ==> True *)
  7.  
  8. Reduce[Equivalent[Implies[p, q || r], Implies[p && Not[q], r]]]
  9.  
  10. (* ==> True *)
  11.  
  12. tableFormattor[rawData_] := Insert[Insert[
  13. Grid[rawData /. {0 -> 0,
  14. 1 -> Item[1, Background -> Lighter[Magenta]]},
  15. FrameStyle -> Gray,
  16. Frame -> All], {Background -> {None, {GrayLevel[0.7], {White}}},
  17. Dividers -> {Black, {2 -> Black}}, Frame -> True,
  18. Spacings -> {2, {2, {0.7}, 2}}}, 2], {Dividers -> All,
  19. Spacings -> .7 {1, 1}}, 2];
  20.  
  21.  
  22. truthTable[f__] := Module[{}, atoms = Cases[Most[{f}],
  23. (a_ /;Length[a] == 0 [And] Not[StringQ[a]])];heads =
  24. ToString[TraditionalForm@#] & /@ {f};
  25. rawData = Transpose@Boole[BooleanTable[#, atoms] & /@ {f}];
  26. If[Last[{f}] === 1,
  27. Transpose@Boole[BooleanTable[#, atoms] & /@ Most[{f}]],
  28. If[Last[{f}] === "rev",
  29. truthTableFormattor[{ToString[
  30. TraditionalForm@#] & /@ (Most@{f})}~Join~
  31. Transpose[(Reverse /@
  32. Boole[BooleanTable[#, atoms] & /@ (Most@{f})])]],
  33. truthTableFormattor[{heads}~Join~rawData]]]];
  34.  
  35.  
  36. truthTable[p, q, r, p [Implies] (q [Or] r), (p [And] [Not] q) [Implies] r]
Add Comment
Please, Sign In to add comment