BOOLE   : Boolean Algebra - truth table                              -1- 

Title   : BOOLE
Version : 4.2
Date    : Feb 06,2000
Author  : J.R. Ferguson, Amsterdam, The Netherlands
Usage   : DOS (BOOLE.EXE) and Windows (BOOLEW.EXE) application
Download: Author's Internet site http://hello.to/ferguson
E-mail  : j.r.ferguson@iname.com

This program, its sources and description may be used and copied  freely
without  charge, but only for non-commercial purposes. The author is not
responsible for any damage or loss of data that may be caused  by  using
it.

BOOLE  verifies  if  a  Boolean  expression is true, or displays a truth
table for a Boolean expression.

The program opens with the following main menu:

  <H>elp  <E>xpression  <L>ist  E<x>it :

You can choose an option by pressing the key displayed in the < > sign.

-- Help
   By pressing the H key you get a short description  on  screen.  After
   you  have  read this text, press the RETURN key to redisplay the main
   menu. 

-- Expression
   When key E is pressed a prompt "S : " is displayed and you  can  type
   in  a  boolean  expression.  End the expression input by pressing the
   RETURN key. The truth table for this expression, or an error message,
   will be displayed, followed by  a new  prompt "S : ".  You  can  then
   enter a new expression.
   By pressing the RETURN key right after the "S : " prompt (entering an
   empty expression), you can return to the main menu.

-- List
   Pressing the L key from the main menu will result in the display of a
   submenu with print options. This submenu looks like this:

      <P>rinter  <F>ile  <O>ff  <M>enu :

   ++ Printer
      The Boolean expression and the truth tables are not only displayed
      on screen, but also sent to the printer.
      Remark: this option can be suppressed with a simple change in  the
      program.  Read  the  technical  information later in this text for
      instructions.

   ++ File
      You can enter the name of a outputfile for the Boolean expressions
      and   thruth   tables.   If  another  output  file  was  specified
      previously, that file will be closed first.

   ++ Off
      The  printer  or output file echo will be turned off. If an output
      fuile was specified previously, that file will be closed.

   ++ Menu
      Back to the main menu.

-- Exit
   Press 'X' to end the program.
BOOLE   : Boolean Algebra - truth table                              -2-

Expression syntax
-----------------

After  the  "S : " prompt you can enter the Boolean expression for which
you want a truth table displayed. All uper case letters  are  translated
to lower case. Spaces may be used freely, they do not change the meaning
of the expression.

For constants you use the values 0 and 1.

For variables you may use any letter of the alphabet (a-z).

The basic operators are:

  + : inclusive "or"          * or . or nothing : logical "and" 
  @ : exclusive "or"          ' or `            : logical "not"

The priority for these operators is the usual one, so "not" comes first,
followed by "and" and then by "or". The two "or" variants (inclusive and
exclusive) have the same priority. You may use parenthesis (  and  )  to
explicitly specify the order of evaluation.

  Examples:
  S : (a + b)'. (a'b + c)
  S : xy.(x`+wx)`

You may also use the following relational operators:

  =  is equal to                 >  implicates
  #  is not equal to             <  is implied by

If you add a question mark at the end of  the  expression,  the  program
will  check  if  the expression always yields the value true. If this is
the case, the word 'true' is displayed. Otherwise, the word  'false'  is
displayed, followed by a truth table for the expression, so you can  see
for  what combinations of the specified variables the assertion does not
hold.

  Examples:
  S : (x'y'z')' = x+y+z ?
  S : a+b > a ?
BOOLE   : Boolean Algebra - truth table                              -3-

A complete list af  all  operators  follows.  The  number  on  the  left
specifies the priority of the operator (0 = highest priority).

 0    '      "not"
 0    `      same

 1    *      "and"
 1    .      same
 1  <empty>  same

 2    +      "inclusive or"
 2    @      "exclusive or"

 3    =      is equal to
 3    #      is not equal to
 3    >      implicates
 3    <      is implied by

The truth tables for the various operators are:

  S : a'       S : ab        S : a+b       S : a@b
                                                  
  a|S          ab|S          ab|S          ab|S   
  -+-          --+-          --+-          --+-   
  0|1          00|0          00|0          00|0   
  1|0          01|0          01|1          01|1   
               10|0          10|1          10|1   
               11|1          11|1          11|0   
                                           
                                           
  S : a=b      S : a#b       S : a>b       S : a<b 
                                                   
  ab|S         ab|S          ab|S          ab|S    
  --+-         --+-          --+-          --+-    
  00|1         00|0          00|1          00|1    
  01|0         01|1          01|0          01|1    
  10|0         10|1          10|1          10|0    
  11|1         11|0          11|1          11|1    

Remark: The operators @ (exclusive or) and # (is not equal to) have  the
same truth table, but not the same priority.
BOOLE   : Boolean Algebra - truth table                              -4-

De exact syntax rules are:

<command>       ::= <assertion> <command suffix>
<assertion>     ::= <expression> |
                    <expression> <rel operator> <expression>
<expression>    ::= <term> { <or operator> <term> }
<term>          ::= <factor> { <and operator> <factor> }
<factor>        ::= <constant> | <variabele> | "(" <expression> ")" |
                    <factor> <not operator>
<command suffix>::= "?" | <empty>
<rel operator>  ::= "=" | "#" | ">" | "<"
<or operator>   ::= "+" | "@"
<and operator>  ::= "*" | "." | <empty>
<not operator>  ::= "'" | "`"
<constant>      ::= "0" | "1"
<variabele>     ::= "a"|"b"|"c"|"d"|"e"|"f"|"g"|"h"|"i"|"j"|"k"|"l"|"m"|
                    "n"|"o"|"p"|"q"|"r"|"s"|"t"|"u"|"v"|"w"|"x"|"y"|"z"



Technical information
---------------------

The program is split up into the followinf source files:

  BOOLE.PAS   : incluse directives and main program
  BOOLE.1     : declarations
  BOOLE.2     : general routines
  BOOLE.3     : system dependant procedures and functions
  BOOLE.4     : input and output
  BOOLE.5     : command processing
  BOOLE.6     : menu

There are two compiled versions of the program:

  BOOLE.EXE   : DOS program
  BOOLEW.EXE  : Windows 3.1 program

A description is provided in English and in Dutch:

  BOOLEE.TXT  : English description
  BOOLEN.TXT  : Dutch description


The  program was written for the Borland Turbo Pascal compiler for a DOS
or  Windows  operating  environment.  In  order  to  reach  an   optimal
portability,  all  system  dependant  procedures  and functions are kept
together in BOOLE3.PAS. In BOOLE.PAS, conditional compilation directives
({$IFDEF  WINDOWS}") are used to enable compilation for both a DOS and a
Windows version with Borland Pascal version 7.0. You may have to  change
BOOLE.PAS  and  BOOLE3.PAS  to  adapt the program to another compiler or
operating system. All other source files use strictly standard Pascal.

Debug code is included between {[ and ]} comment signs. You can activate
the debug code by changing {[  into  {[}  and  ]}  into  {]}  for  every
occurrence  in  the  sourcefiles  and  setting  the  value of the global
constant "test" to true. When you run the  program  with  the  debugging
code  activated,  a  question "Debug? (Y/N) : " is asked at the start of
the program. By answering "Y" or "y"  you  activate  trace  output  that
enables  you to see what actions the program performs when an expression
is evaluated. This may be a helpful feature if you modify the program.

The  global  constant  printavail  can  be  set  to false if you want no
printer support. In that  case,  the  option  P  for  "printer"  is  not
displayed in the main menu.
