MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Logic and Truth Tables with Mathematica?


ShowTruthTable[logicF_] :=
  Module[{TT = Outer[logicF, {False, True}, {False, True}]},
    TT = Map[ToString, TT, {2}];
    GridBox[{{ToString@logicF, "False", "True"}, {"False"}~Join~
            TT[[1]], {"True"}~Join~TT[[2]]},
        ColumnLines -> {True, False},
        RowLines -> {True, False}] // DisplayForm]

The argument is the logical function you want to study. If you don't want to
create a table, but just want the truth table in matrix form, just use the
Outer[...] expression.
Orestis

<heathw at in-tch.com> wrote in message news:9iji4d$ris$1 at smc.vnet.net...
> Hi,
> Can Mathematica, given a relation such as P->Q generate the truth table?
> Is there a book available that talks about Mathematica and logic?
> Thanks,
> Heath
>




  • Prev by Date: Re: about ConstrainedMin
  • Next by Date: Re: Clearing cache
  • Previous by thread: Re: Logic and Truth Tables with Mathematica?
  • Next by thread: Re: Logic and Truth Tables with Mathematica?