Main Page   Class Hierarchy   Compound List   File List   Compound Members  

LogicTree Class Reference

Inheritance diagram for LogicTree::

BinaryTree Failure UnaryTree Unit And Iff Implies Or Not False True Var List of all members.

Public Methods

String toString ()
abstract void toStringBuffer (String indentation, StringBuffer buffer)
boolean isFailure ()

Static Public Methods

LogicTree iff (LogicTree leftSubtree, LogicTree rightSubtree)
LogicTree implies (LogicTree leftSubtree, LogicTree rightSubtree)
LogicTree or (LogicTree leftSubtree, LogicTree rightSubtree)
LogicTree and (LogicTree leftSubtree, LogicTree rightSubtree)
LogicTree not (LogicTree subtree)
LogicTree var (char name)
LogicTree failure (String cause)
void main (String arg[])

Static Private Attributes

LogicTree C0 = new False()
LogicTree C1 = new True()
String additionalIndentation = " "

Detailed Description

A LogicTree represents the syntax of a propositional logic expression.

Definition at line 9 of file LogicTree.java.


Member Function Documentation

LogicTree LogicTree::and ( LogicTree leftSubtree,
LogicTree rightSubtree ) [inline, static]
 

pseudo-constructor for an "and" tree

Definition at line 97 of file LogicTree.java.

Referenced by main().

00098   {
00099   return new And(leftSubtree, rightSubtree);
00100   }

LogicTree LogicTree::failure ( String cause ) [inline, static]
 

pseudo-constructor for a failure

Definition at line 127 of file LogicTree.java.

00128   {
00129   return new Failure(cause);
00130   }

LogicTree LogicTree::iff ( LogicTree leftSubtree,
LogicTree rightSubtree ) [inline, static]
 

pseudo-constructor for an "iff" tree

Definition at line 67 of file LogicTree.java.

Referenced by main().

00068   {
00069   return new Iff(leftSubtree, rightSubtree);
00070   }

LogicTree LogicTree::implies ( LogicTree leftSubtree,
LogicTree rightSubtree ) [inline, static]
 

pseudo-constructor for an "implies" tree

Definition at line 77 of file LogicTree.java.

Referenced by main().

00078   {
00079   return new Implies(leftSubtree, rightSubtree);
00080   }

boolean LogicTree::isFailure ( ) [inline]
 

Tell whether this tree is a failure.

Definition at line 57 of file LogicTree.java.

00058   {
00059   return this instanceof Failure;
00060   }

void LogicTree::main ( String arg[] ) [inline, static]
 

test program that constructs several trees and displays them

Definition at line 137 of file LogicTree.java.

00138   {
00139   System.out.println("Tree for: (a+b)' = a'*b'");
00140   System.out.println(
00141     iff(
00142         not(or(var('a'), var('b'))),
00143         and(not(var('a')), not(var('b')))
00144        ) );
00145 
00146   System.out.println("Tree for: c > 1");
00147   System.out.println(
00148     implies(var('c'), C1)
00149        );
00150 
00151   System.out.println("Tree for: 0 > d");
00152   System.out.println(
00153     implies(C0, var('d'))
00154        );
00155 
00156   System.out.println("Tree for: a + a'*b = a + b");
00157   System.out.println(
00158     iff(
00159         or(var('a'), and(not(var('a')), var('b'))), 
00160         or(var('a'), var('b')))
00161        );
00162   }

LogicTree LogicTree::not ( LogicTree subtree ) [inline, static]
 

pseudo-constructor for a "not" tree

Definition at line 107 of file LogicTree.java.

Referenced by main().

00108   {
00109   return new Not(subtree);
00110   }

LogicTree LogicTree::or ( LogicTree leftSubtree,
LogicTree rightSubtree ) [inline, static]
 

pseudo-constructor for an "or" tree

Definition at line 87 of file LogicTree.java.

Referenced by main().

00088   {
00089   return new Or(leftSubtree, rightSubtree);
00090   }

String LogicTree::toString ( ) [inline]
 

Convert the tree to a String representation.

Definition at line 37 of file LogicTree.java.

00038   {
00039   StringBuffer buffer = new StringBuffer();  
00040   toStringBuffer("", buffer);
00041   return buffer.toString();
00042   }

abstract void LogicTree::toStringBuffer ( String indentation,
StringBuffer buffer ) [pure virtual]
 

Put the tree's representation into a StringBuffer.

Reimplemented in BinaryTree, UnaryTree, Unit, and Failure.

Referenced by toString(), UnaryTree::toStringBuffer(), and BinaryTree::toStringBuffer().

LogicTree LogicTree::var ( char name ) [inline, static]
 

pseudo-constructor for a logical variable

Definition at line 117 of file LogicTree.java.

Referenced by main().

00118   {
00119   return new Var(name);
00120   }


Member Data Documentation

LogicTree LogicTree::C0 = new False() [static, private]
 

C0 is a tree for the constant 0 (false).

Definition at line 15 of file LogicTree.java.

LogicTree LogicTree::C1 = new True() [static, private]
 

C1 is a tree for the constant 1 (true).

Definition at line 22 of file LogicTree.java.

String LogicTree::additionalIndentation = " " [static, private]
 

additionalIndentation determines how much additional Indentation there is at each level of the tree when it is converted to a String.

Definition at line 30 of file LogicTree.java.


The documentation for this class was generated from the following file:
Generated at Wed Mar 26 13:57:26 2003 for LogicParserSupportFiles by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001