Class Proposition

java.lang.Object
edu.uky.cs.nil.tt.world.Proposition
All Implemented Interfaces:
Expression, Logical, Predicate<State>

public class Proposition extends Object implements Predicate<State>, Expression
A proposition is a logical expression that can be either true or false. A proposition is an operator applied to zero or more other expressions, called its arguments.
Author:
Stephen G. Ware
  • Field Details

    • TRUE

      public static final Proposition TRUE
      A proposition that is always true
    • FALSE

      public static final Proposition FALSE
      A proposition that is always false
    • operator

      public final Proposition.Operator operator
      An operator defines the type and behavior of a proposition
  • Constructor Details

    • Proposition

      public Proposition(Proposition.Operator operator, Expression... arguments)
      Constructs a new proposition from an operator and arguments.
      Parameters:
      operator - the operator which defines the type and behavior of the proposition
      arguments - the arguments which will be evaluate by the operator in a given state
  • Method Details

    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • test

      public boolean test(State state)
      Specified by:
      test in interface Predicate<State>
    • substitute

      public Proposition substitute(Function<Object,Object> substitution)
      Description copied from interface: Logical
      Returns a logical object identical to this one, except that its logical elements have been replaced according to the given substitution. A substitution defines how some logical formula (the input to the function) should be replaced with a different formula (the output of the function).
      Specified by:
      substitute in interface Expression
      Specified by:
      substitute in interface Logical
      Parameters:
      substitution - a function which maps logical formula that should be replaced to the formula they should be replaced with
      Returns:
      an identical object, except that its logical formula have been replaced according to the substitution
    • evaluate

      public Value evaluate(State state)
      Returns the value of this logical expression in the given state.

      A proposition always returns either true or false when evaluated.

      Specified by:
      evaluate in interface Expression
      Parameters:
      state - a mapping of values to all of a story world's variables
      Returns:
      the value of the expression in the given state
    • getArguments

      public List<Expression> getArguments()
      Returns an unmodifiable list of this proposition's arguments, the other expressions that make up this proposition and which are considered when evaluating the truth value of this proposition.
      Returns:
      an unmodifiable list of arguments