Help with propositional formulas

Graham Klyne GK@ninebynine.org
Sun, 20 Jul 2003 10:39:41 +0100


There's a 'powerset' thread on this list [1][2] starting 4th June which I 
think contains some of the answers you seek.  Read and you shall learn!

#g
--

[1] List archive: http://www.haskell.org/pipermail/haskell-cafe/

[2] Powerset thread 
starts:  http://www.haskell.org/pipermail/haskell-cafe/2003-June/004463.html
(Read into the thread, because there are some problems with the code that 
appears earlier in the thread.)


At 22:55 19/07/03 -0300, Douglas O. Matoso wrote:
>Hi,
>
>I have an school assignment that asks to implement an truth table of
>propositional formulas. I'm having difficulties in the following part:
>
>data Prop = Var Char | Not Prop | And Prop Prop | Or Prop Prop
>type Subst = [(Char,Bool)]
>
>- Define a function
>bools :: Int -> [[Bool]]
>that calculates all possible lists of logical values of a specific length.
>For
>example, bools 2 should give the following list:
>[[False,False],
>[False,True ],
>[True ,False],
>[True ,True ]]
>
>- Define a function
>substs :: Prop -> [Subst]
>that calculates all possible substitutions for the variables of a
>proposition.
>
>For example, substs p2 should give the following list:
>[[('A',False),('B',False)],
>[('A',False),('B',True) ],
>[('A',True) ,('B',False)],
>[('A',True) ,('B',True) ]]
>
>
>I would be thankful for any help.
>
>Douglas Matoso
>
>
>**************************************************************************************************
>** Este email foi scaneado contra virus e conteudo malicioso **
>**************************************************************************************************
>
>_______________________________________________
>Haskell-Cafe mailing list
>Haskell-Cafe@haskell.org
>http://www.haskell.org/mailman/listinfo/haskell-cafe

-------------------
Graham Klyne
<GK@NineByNine.org>
PGP: 0FAA 69FF C083 000B A2E9  A131 01B9 1C7A DBCA CB5E