MathGroup Archive 2012

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

Search the Archive

Re: Evaluation of boolean functions in Mathematica 8

> g[True,True,True]
> But the above statement does not evaluate g at the data-point given,...

Hi.  Just some additional ideas.  Here's what you have:



Notice that the equation has p,q,r assigned to it.
Therefore, just assign a value to the variables.



Slightly better might be:


As a side note, notice that using x,y,z will not work as the function is expecting p,q,r.

< does not work >

Using your equation, we see that there is only 1 output with True, and the rest are False.
What generated the True condition?    All False, All True, or something in-between?
Here's a general idea you may find interesting.
I've includes "steps" so as to see intermediate steps one may want to look at leading up to the final solution.

v = BooleanVariables[equ];


Here's your example.  It appears the output is true when all inputs are true.
(I know... this example was easy)

( 	p	q	r	p&&q&&r
1	True	True	True	True
2	True	True	False False
3	True	False True False
4	True	False False False
5	False True True False
6	False True False False
7	False False True False
8	False False False False

This example is also easy, but suppose one didn't know the intermediate steps.
If one didn't know what the final NOT did, you could look at the inside part prior to the final NOT.


// additional things one may want to look at:

steps = {And[x,y],  Or[And[x,y],z]};

(         x	y	z	x&&y	(x&&y)||z	!((x&&y)||z)
1	True	True	True	True	True	False
2	True	True	False True True False


As a side note, does anyone know of a simple way to keep the input equation as And[p,q,r] ?

This gets simplified to p&&q&&r.
I've been trying to find a way (without typing it as string) to keep the original version of And[p,q,r]   in the heading row.

= = = = = = = = = = 
HTH  :>)
Dana DeLouis
Mac & Math 8
= = = = = = = = = = 

On Aug 1, 4:57 am, lalwani.ak... at wrote:
> Hello,
> I want to evaluate a Boolean function by substituting True and False values for its variables, to get a True or False value at the output. Example,
> g = BooleanConvert[And[p, q, r], "BFF"]
> g[True,True,True]
> But the above statement does not evaluate g at the data-point given, but instead returns the statement,
> BooleanFunction[<3>][p,q,r][True,True,True]
> Can anybody please suggest how to proceed?
> Thanks a lot.

  • Prev by Date: Re: Ordering an algebraic expression in Mathematica
  • Next by Date: Re: ListContourPlot
  • Previous by thread: Re: Evaluation of boolean functions in Mathematica 8
  • Next by thread: Re: Evaluation of boolean functions in Mathematica 8