Bool49 v2.0 by Steen S. Schmidt

March 5, 2001

 

 

 

Contents

Contents. 1

Disclaimer & Copyright 1

Credits. 1

Requirements & Installation. 1

Bool49. 2

TruthTable. 2

OneTerms. 3

SofP.. 4

PofS.. 4

BView.. 4

BEQ?. 5

NAND.. 5

NOR.. 5

XNOR.. 6

Revision History. 6

Disclaimer & Copyright

This program is freeware, so no registration or licensing fees are necessary. You are free to distribute this program to anyone, as long as this document is included.

I cannot take responsibility for any damage or data loss caused by this program – it is written in 100% SysRPL and there could be bugs in it. This also means that it will not run on the HP48 series.

If you have any suggestions, additions or find any bugs in the code, you’re welcome to contact me per email at SSchmidt@nospam.dk.

Credits

The library is coded and compiled directly on the HP49G, which has proven to be a great tool for this too. A thanks goes to ACO for making this possible – including these programming tools on the calculator itself has made the job a lot easier.

Requirements & Installation

You need to copy the library (library #1127) to the calculator (with HPComm for example) and store it in a port (any port should do).

To store it in port 2 for example, you will need to recall the library to the stack, type 2 and STO.

 

 

Hold down ON and press F3, release both keys and the calc should warm boot (warning: you’ll loose all stack contents, but calc memory will remain intact). When this is done, your port 2 should contain the entry for the library (press left shift APPS to enter the Filer):

 

  à 

 

Running BYTES on the library on the stack should yield #D924h and 4377 bytes.

 

  à 

 

This document is showing stack syntax for RPN mode, but the library will work in algebraic mode too.

Bool49

This is a library containing a couple of tools for manipulating Boolean expressions. Such expressions shouldn’t contain operators other than AND, OR and NOT. I’m still planning to include a Boolean simplification routine, but I’ll make no promises of updates.

 

TruthTable

Truth Table command:

This command calculates a truth table for a Boolean algebraic expression.

 


Level 1

à

Level 1

symbolic

à

grob

 

NB: For correct result with Boolean equations, use ==, not =.

 

The command will return a graphics object representing the truth table to the stack. This grob is also displayed on the screen. Press F6, ON or ENTER to exit the scrollable graphic.

The maximum number of variables that can be present in an expression is 10 due to memory and time restrictions. The grob of a truth table consisting of more than 10 variables would occupy >150kB of RAM.

 

  à    à 

 

To view the returned grob again, execute the built-in SCROLL command, or press VIEW in the TOOL menu.

 

The performance of this command is much better than the previously released truth table generator for the HP49G.

 

In the comparison below, TT49FS is Frederic Saverots truth table generator for the HP49G, and TTSS is the truth table generator of this library:

 

EQ1:                                 (two variable expression w/ many combinations)

EQ2:                    (many variable expression w/ few combinations)

 

 

TT49FS

TTSS

EQ1

15.3 s.

0.7 s.

EQ2

246.6 s.

10.8 s.

 

OneTerms

List of One Terms command:

This command calculates all one terms of a Boolean algebraic expression.

 


Level 1

à

Level 2

Level 1

symbolic

à

[ vars ]

{ T1 T2  … Tn }

 

NB: For correct result with Boolean equations, use ==, not =.

 

The command will return a list containing all the combinations that’ll make the input expression yield TRUE. Stack level 2 contains a vector of the variables, in which order the combinations should be read.

 

An example:

 

  à 

 

The example above shows that the only combination that yields a TRUE output of the expression  is 7. This result must be seen in conjunction with the variable vector in level 2. The vector shows that there were three variables, X, Y & Z, in the expression, which makes room for combinations. These combinations go from 0 (X=0, Y=0, Z=0, binary #000b) to 7 (X=1, Y=1, Z=1, binary #111b). The result from the example, 7, means that all three variables has to be 1 for the expression to be 1. This is why the variable order is important.

 

Another example:

 

  à 

 

This means that 6 of the 8 combinations yield TRUE. These are 0 (X=0, Y=0, Z=0, binary #000b), 1 (X=0, Y=0, Z=1, binary #001b), 3 (X=0, Y=1, Z=1, binary #011b), 5 (X=1, Y=0, Z=1, binary #101b), 6 (X=1, Y=1, Z=0, binary #110b) and 7 (X=1, Y=1, Z=1, binary #111b).

 

The maximum number of variables that can be present in an expression is 15 – this is due to time restrictions, as a truth table consisting of more than 15 variables would take more than 2 hours to compute.

 

As with the TruthTable command, the performance of this command is much better than previously released truth table generators for the HP4x series.

In the comparison below, TTD is the ‘T.T.M’ command of the Digitician v0.9.1 for the HP48, and TTSS is the OneTerm command of this library. The reason for these two commands to be compared, is that TTD also returns a list of one terms:

 

EQ1:                                 (two variable expression w/ many combinations)

EQ2:                    (many variable expression w/ few combinations)

 

 

TTD

TTSS

EQ1

4.7 s.

0.5 s.

EQ2

32.4 s.

6.3 s.

 

This list of one terms can be difficult to decipher for large tables, but it is a bit faster than creating a truth table, and it takes considerably less memory.

 

SofP

Sum-of-Products command:

This command converts a Boolean algebraic expression to its sum-of-products representation.

 


Level 1

à

Level 1

symbolic

à

symbolic

 

  à 

 

A conversion can always take place, since multiplication is always distributable. No simplification will take place other than obvious simplifications like , and so on.

 

PofS

Product-of-Sums command:

This command converts a Boolean algebraic expression to its product-of-sums representation.

 


Level 1

à

Level 1

symbolic

à

symbolic

 

  à 

 

A complete conversion can’t always take place, since an expression may not always factor completely. No simplification will take place other than obvious simplifications like , and so on.

 

BView

Boolean View command:

This command displays a Boolean algebraic expression on the screen.

 


Level 1

à

Level 1

symbolic

à

symbolic

 

The symbolic is left untouched on the stack for further use, and the shown algebraic will have “+” for “OR”, “·” for “AND”, “‛” for “NOT” and “Å” for “XOR”.

 

  à 

 

  à 

 

Often a Boolean expression is much easier to understand when seen in this short form.

 

BEQ?

Boolean Equivalence command:

This command checks if two Boolean algebraic expressions are equivalent.

 

Level 2


Level 1

à

Level 1

symbolic

symbolic

à

0. or 1.

 

Equivalent expression can look totally different from each other, and they can even have different number of variables:

 

  à 

 

The calculation can be lengthy, since this command uses a variant of OneTerm to decide. This also means that the number of different variables in the two expressions combined is not allowed to exceed 15.

 

NAND

NOT AND command:

This command executes a logical NAND on a Boolean algebraic expression.

 


Level 1

à

Level 1

symbolic

à

symbolic

 

Since the HP49G does not have a way of representing NAND internally, the command simply executes the two built-in commands AND and NOT.

 

NOR

NOT OR command:

This command executes a logical NOR on a Boolean algebraic expression.

 


Level 1

à

Level 1

symbolic

à

symbolic

 

Since the HP49G does not have a way of representing NOR internally, the command simply executes the two built-in commands OR and NOT.

 

XNOR

NOT XOR command:

This command executes a logical XNOR on a Boolean algebraic expression.

 


Level 1

à

Level 1

symbolic

à

symbolic

 

Since the HP49G does not have a way of representing XNOR internally, the command simply executes the two built-in commands XOR and NOT.

Revision History

v1.0:  Initial public release.

 

v2.0:  Added commands OneTerm, SofP, PofS, BView, BEQ?, NAND, NOR and XNOR.