Kirk Rader  1.0-SNAPSHOT
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
us.rader.tt.formula.SymbolicNode Class Referenceabstract

A sentence or predicate. More...

Inheritance diagram for us.rader.tt.formula.SymbolicNode:
Inheritance graph

Public Member Functions

final boolean evaluate (final Map< Expression, Boolean > values)
 
final Set< ExpressiongetNodes ()
 
final Set< ExpressiongetTerminalNodes ()
 
void printDigraph (final PrintStream stream, final int indent)
 
final void toLaTeX (final PrintStream stream)
 
String toString ()
 
- Public Member Functions inherited from us.rader.tt.formula.Formula
abstract boolean evaluate (Map< Expression, Boolean > values)
 Evaluate this formula according to its truth table assuming the given values for its primitive terms. More...
 
final String toDigraph (final int indent) throws IOException
 
final void toDigraph (final PrintStream stream, final int indent)
 Write this formula's syntax tree as a Graphviz digraph. More...
 
final String toTruthTable (final int indent) throws IOException
 
final void toTruthTable (final PrintStream stream, final int indent) throws IOException
 Print this formula's truth table in LaTeX format to the given output stream. More...
 
- Public Member Functions inherited from us.rader.tt.formula.Expression
final boolean equals (final Object obj)
 Base equality on the string representation of a formula. More...
 
abstract Set< ExpressiongetNodes ()
 
abstract Set< ExpressiongetTerminalNodes ()
 
final int hashCode ()
 Base the hash code on the string representation of a formula. More...
 
abstract Expression replaceVariable (Variable boundVariable, Expression factor)
 Replace boundVariable with factor everywhere in this Expression. More...
 
final String toLaTeX () throws IOException
 
abstract void toLaTeX (PrintStream stream)
 Print the LaTeX representation of this object to the given stream. More...
 

Protected Member Functions

 SymbolicNode (final String symbol)
 Initialize symbol. More...
 
- Protected Member Functions inherited from us.rader.tt.formula.Expression
 Expression ()
 Initialize nodeName. More...
 

Protected Attributes

String symbol
 The symbol for this primitive term. More...
 
- Protected Attributes inherited from us.rader.tt.formula.Expression
String nodeName
 Graphviz digraph node name. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from us.rader.tt.formula.Formula
static Formula parseFormula (final BufferedReader reader) throws IOException
 Parse the next Formula from the given buffered input stream. More...
 
static Formula parseFormula (final InputStream stream) throws IOException
 Parse the next Formula from the given input stream. More...
 
static Formula parseFormula (final String formula) throws IOException
 Parse the the given term. More...
 
- Static Public Member Functions inherited from us.rader.tt.formula.Expression
static Expression parseFactor (final BufferedReader reader) throws IOException
 Parse the next Expression from the given buffered input stream. More...
 
static Expression parseFactor (final InputStream stream) throws IOException
 Parse the next Expression from the given buffered input stream. More...
 
static Expression parseFactor (final String factor) throws IOException
 Parse the next Expression from the given buffered input stream. More...
 
- Static Protected Member Functions inherited from us.rader.tt.formula.Expression
static Expression parseVariableBindingOperator (final BufferedReader reader, final Class<? extends VariableBindingOperator > type, final char terminator) throws IOException
 Parse the next VariableBindingOperator or Description from the given buffered input stream. More...
 
static void printIndentation (final PrintStream stream, final int indent)
 Print the specified number of spaces to the given stream. More...
 
static int skipWhitespace (final BufferedReader reader) throws IOException
 Discard white space from the given buffered input stream. More...
 
- Static Package Functions inherited from us.rader.tt.formula.Expression
 [static initializer]
 

Detailed Description

A sentence or predicate.

Definition at line 27 of file SymbolicNode.java.

Constructor & Destructor Documentation

◆ SymbolicNode()

us.rader.tt.formula.SymbolicNode.SymbolicNode ( final String  symbol)
protected

Initialize symbol.

Parameters
symbolsymbol

Definition at line 40 of file SymbolicNode.java.

References us.rader.tt.formula.SymbolicNode.symbol.

40  {
41 
42  this.symbol = symbol;
43 
44  }
String symbol
The symbol for this primitive term.

Member Function Documentation

◆ evaluate()

final boolean us.rader.tt.formula.SymbolicNode.evaluate ( final Map< Expression, Boolean >  values)
See also
Formula::evaluate

Definition at line 50 of file SymbolicNode.java.

References us.rader.tt.formula.SymbolicNode.toString().

50  {
51 
52  final Boolean value = values.get(this);
53 
54  if (value == null) {
55 
56  throw new IllegalArgumentException(String.format("no value specified for %s", toString()));
57 
58  }
59 
60  return value.booleanValue();
61 
62  }

◆ getNodes()

final Set<Expression> us.rader.tt.formula.SymbolicNode.getNodes ( )
See also
Formula::getNodes

Definition at line 68 of file SymbolicNode.java.

References us.rader.tt.formula.SymbolicNode.getTerminalNodes().

68  {
69 
70  return getTerminalNodes();
71 
72  }
final Set< Expression > getTerminalNodes()

◆ getTerminalNodes()

final Set<Expression> us.rader.tt.formula.SymbolicNode.getTerminalNodes ( )
See also
Formula::getTerminalNodes

Definition at line 78 of file SymbolicNode.java.

Referenced by us.rader.tt.formula.SymbolicNode.getNodes().

78  {
79 
80  final Set<Expression> terms = new HashSet<>();
81  terms.add(this);
82  return terms;
83 
84  }

◆ printDigraph()

void us.rader.tt.formula.SymbolicNode.printDigraph ( final PrintStream  stream,
final int  indent 
)
See also
Graphable::printDigraph

Implements us.rader.tt.formula.Graphable.

Definition at line 90 of file SymbolicNode.java.

References us.rader.tt.formula.Expression.nodeName, and us.rader.tt.formula.Expression.printIndentation().

90  {
91 
92  printIndentation(stream, indent);
93  stream.println(nodeName + " [ label=\"" + symbol + "\" ]");
94 
95  }
String nodeName
Graphviz digraph node name.
Definition: Expression.java:90
String symbol
The symbol for this primitive term.
static void printIndentation(final PrintStream stream, final int indent)
Print the specified number of spaces to the given stream.

◆ toLaTeX()

final void us.rader.tt.formula.SymbolicNode.toLaTeX ( final PrintStream  stream)
See also
Formula::toLaTeX

Definition at line 101 of file SymbolicNode.java.

References us.rader.tt.formula.SymbolicNode.toString().

101  {
102 
103  stream.print(toString());
104 
105  }

◆ toString()

String us.rader.tt.formula.SymbolicNode.toString ( )
Returns
symbol

Definition at line 111 of file SymbolicNode.java.

References us.rader.tt.formula.SymbolicNode.symbol.

Referenced by us.rader.tt.formula.SymbolicNode.evaluate(), and us.rader.tt.formula.SymbolicNode.toLaTeX().

111  {
112 
113  return symbol;
114 
115  }
String symbol
The symbol for this primitive term.

Member Data Documentation

◆ symbol

String us.rader.tt.formula.SymbolicNode.symbol
protected

The documentation for this class was generated from the following file: