[comp.sys.handhelds] Forming boolean expressions

d0evert@dtek.chalmers.se (Mats Olsson) (09/22/90)

Hi there!

It seems to be impossible to use HP48/28`s built-in colecter
and expander to manipulate boolean expression, such like
(A OR B) AND NOT A.

Thats`s because I wonder if someone of YOU have written any
little program to make such manipulations. What I really mean
is a program which makes use of De Morgans Theorem to "solve"
and make such expressions easier.

Example: NOT (A OR B) <=> NOT (A) AND NOT (B)
              
         A AND NOT A = 0

                                     
         etc, etc

The expressions can, of cause, be much more complicated than theese exaples.
That`s because I Need the program!!

Please let me know how to use the HP for this, if anyone know something
about it (which I bet at least ONE of you out there do!)

Thanks a lot

Mats
 

pedz@halley.UUCP (09/25/90)

>Example: NOT (A OR B) <=> NOT (A) AND NOT (B)
>              
>         A AND NOT A = 0

This looks like a good place to use ^match and Vmatch.  I've used this
only once of twice but it can definately do what you want.  e.g.

<< { '&a AND NOT &a' '0' } ^MATCH >>

Would be the second example.

But I don't have much insight as to when to use ^MATCH as oppose to
VMATCH.  I understand (sorta) how they differ but don't understand
when to use one or the other.  Anyone care to comment?

pedz

bson@rice-chex.ai.mit.edu (Jan Brittenson) (09/25/90)

In article <996@halley.UUCP> pedz@halley.UUCP writes:

 > I don't have much insight as to when to use ^MATCH as oppose to
 > VMATCH.  I understand (sorta) how they differ but don't understand
 > when to use one or the other.

Assume you want to make the (very reasonable) reduction of

'&A+(&B+&C)' to '&A+&B+&C'.

With the simple algebraic '1+(2+3)' everything will be just fine,
you'll end up with '1+2+3' either way.

But try it with '1+(2+(3+4))', and you'll end up with 

	vMATCH  ==> '1+2+(3+4)'
	^MATCH  ==> '1+(2+3+4)'

Why is this? Well, ^MATCH looks at the innermost subexpression first
(the bottommost, if you regard the expression as a tree), so the
matching order will be (with the algebraic '1+(2+(3+4))'):


	&A+(&B+&C) vs. '3+4'		(no match)
	  - "" -   vs. '2+(3+4)'	-> '2+3+4'
	  - "" -   vs. '1+(2+3+4)'	(no match)

	==> '1+(2+3+4)'

vMATCH attempts to substitute the topmost level first, so the order
with vMATCH will be:

	&A+(&B+&C) vs. '1+(2+(3+4))'	-> '1+2+(3+4)'
	  - "" -   vs.  '3+4'		(no match)

	==> '1+2+(3+4)'