Kirk Rader  1.0-SNAPSHOT
Public Member Functions | Private Attributes | List of all members
us.rader.tt.formula.Predicate Class Reference

A predicate, i.e. More...

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

Public Member Functions

 Predicate (final String symbol, final Expression factor)
 
void printDigraph (final PrintStream stream, final int indent)
 
Expression replaceVariable (final Variable boundVariable, final Expression newFactor)
 
String toString ()
 
- Public Member Functions inherited from us.rader.tt.formula.SymbolicNode
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...
 

Private Attributes

final Expression factor
 The factor to which this predicate is applied. 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...
 
- Protected Member Functions inherited from us.rader.tt.formula.SymbolicNode
 SymbolicNode (final String symbol)
 Initialize symbol. More...
 
- Protected Member Functions inherited from us.rader.tt.formula.Expression
 Expression ()
 Initialize nodeName. 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...
 
- Protected Attributes inherited from us.rader.tt.formula.SymbolicNode
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...
 
- Static Package Functions inherited from us.rader.tt.formula.Expression
 [static initializer]
 

Detailed Description

A predicate, i.e.

an upper-case letter immediately followed by a lower-case letter.

Definition at line 25 of file Predicate.java.

Constructor & Destructor Documentation

◆ Predicate()

us.rader.tt.formula.Predicate.Predicate ( final String  symbol,
final Expression  factor 
)
Parameters
symbolSymbol for SymbolicNode#SymbolicNode.
factorThe Expression denoting the object to which this Predicate is applied

Definition at line 40 of file Predicate.java.

References us.rader.tt.formula.Predicate.factor.

Referenced by us.rader.tt.formula.Predicate.replaceVariable().

40  {
41 
42  super(symbol);
43  this.factor = factor;
44 
45  }
final Expression factor
The factor to which this predicate is applied.
Definition: Predicate.java:30
String symbol
The symbol for this primitive term.

Member Function Documentation

◆ printDigraph()

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

Implements us.rader.tt.formula.Graphable.

Definition at line 51 of file Predicate.java.

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

51  {
52 
53  super.printDigraph(stream, indent);
54  factor.printDigraph(stream, indent);
55  printIndentation(stream, indent);
56  stream.print(nodeName);
57  stream.print(" -> ");
58  stream.println(factor.nodeName);
59 
60  }
void printDigraph(PrintStream stream, int indent)
Print the Graphviz nodes and edges for this object to the given stream.
String nodeName
Graphviz digraph node name.
Definition: Expression.java:90
final Expression factor
The factor to which this predicate is applied.
Definition: Predicate.java:30
static void printIndentation(final PrintStream stream, final int indent)
Print the specified number of spaces to the given stream.

◆ replaceVariable()

Expression us.rader.tt.formula.Predicate.replaceVariable ( final Variable  boundVariable,
final Expression  newFactor 
)
See also
Expression::replaceVariable

Definition at line 66 of file Predicate.java.

References us.rader.tt.formula.Expression.equals(), us.rader.tt.formula.Predicate.factor, us.rader.tt.formula.Predicate.Predicate(), and us.rader.tt.formula.SymbolicNode.symbol.

66  {
67 
68  final Expression expression = factor.equals(boundVariable) ? newFactor : factor;
69  return new Predicate(symbol, expression);
70 
71  }
Expression()
Initialize nodeName.
final boolean equals(final Object obj)
Base equality on the string representation of a formula.
final Expression factor
The factor to which this predicate is applied.
Definition: Predicate.java:30
String symbol
The symbol for this primitive term.
Predicate(final String symbol, final Expression factor)
Definition: Predicate.java:40

◆ toString()

String us.rader.tt.formula.Predicate.toString ( )
Returns
Symbol immediately followed by variable.

Definition at line 77 of file Predicate.java.

77  {
78 
79  return super.toString() + factor.toString();
80 
81  }
final Expression factor
The factor to which this predicate is applied.
Definition: Predicate.java:30

Member Data Documentation

◆ factor

final Expression us.rader.tt.formula.Predicate.factor
private

The factor to which this predicate is applied.

Definition at line 30 of file Predicate.java.

Referenced by us.rader.tt.formula.Predicate.Predicate(), and us.rader.tt.formula.Predicate.replaceVariable().


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