Record Class EvaluableFunctionImpl

java.lang.Object
java.lang.Record
fr.inria.rules.integraal.model.logicalElements.impl.functionalTerms.EvaluableFunctionImpl
Record Components:
function_name - the name of the represented function
invoker - the invoker used to evaluate the function
sub_terms - the function arguments
All Implemented Interfaces:
fr.inria.rules.dlgpemodel.api.elems.IFunctionalTerm, fr.inria.rules.dlgpemodel.api.elems.ITerm, fr.inria.rules.dlgpemodel.api.sentences.IPrintable, Standardizable, Evaluable<Term>, EvaluableFunction, Substitutable<Term>, Term, TermCompound, TermSequenceCompound

public record EvaluableFunctionImpl(String function_name, Invoker invoker, List<Term> sub_terms) extends Record implements EvaluableFunction
Default implementation of FunctionalTerm
Author:
Florent Tornil, Federico Ulliana
  • Constructor Details

    • EvaluableFunctionImpl

      public EvaluableFunctionImpl(String function_name, Invoker invoker, List<Term> sub_terms)
      Creates an evaluable function and validates its required components.
  • Method Details

    • setFunctionParameters

      public EvaluableFunctionImpl setFunctionParameters(Substitution s)
      Description copied from interface: EvaluableFunction
      Applies a substitution to this function arguments without evaluating this function.
      Specified by:
      setFunctionParameters in interface EvaluableFunction
      Parameters:
      s - substitution
      Returns:
      a new function where some variables have been replaced by other terms, as defined by the substitution s
    • getInvoker

      public Invoker getInvoker()
      Description copied from interface: EvaluableFunction
      Returns the invoker used to evaluate this function.
      Specified by:
      getInvoker in interface EvaluableFunction
      Returns:
      the invoker backing this evaluable function
    • getFunctionName

      public String getFunctionName()
      Description copied from interface: EvaluableFunction
      Returns the function name used by this evaluable term.
      Specified by:
      getFunctionName in interface EvaluableFunction
      Specified by:
      getFunctionName in interface fr.inria.rules.dlgpemodel.api.elems.IFunctionalTerm
      Returns:
      a string representing the function name
    • getTermSequence

      public List<Term> getTermSequence()
      Description copied from interface: TermSequenceCompound
      Returns the direct term sequence of this compound.
      Specified by:
      getTermSequence in interface fr.inria.rules.dlgpemodel.api.elems.IFunctionalTerm
      Specified by:
      getTermSequence in interface TermSequenceCompound
      Returns:
      the sequence of first level terms (i.e., all terms that are not themselves in a compound term) For instance, for p(a,g(b)), it returns a and g(b) but not b.
    • eval

      public Term eval(Substitution s)
      Description copied from interface: EvaluableFunction
      (1) applies the substitution to the term (2) evaluate the function associated with the term

      Precondition : a functional term is evaluable IFF all of its arguments -- after applying the substitution -- are literals

      Specified by:
      eval in interface Evaluable<Term>
      Specified by:
      eval in interface EvaluableFunction
      Parameters:
      s - a substitution
      Returns:
      the resulting term of the evaluation
    • getMandatoryParameters

      public Set<Variable> getMandatoryParameters()
      Description copied from interface: Evaluable
      Get the variables that must be sent to something to evaluate the object
      Specified by:
      getMandatoryParameters in interface Evaluable<Term>
      Returns:
      a set of variables containing the variables that must be substituted
    • evaluateNestedFunctions

      public EvaluableFunction evaluateNestedFunctions(Substitution s)
      Description copied from interface: EvaluableFunction
      Evaluates nested functions that become ground after substitution.
      Specified by:
      evaluateNestedFunctions in interface EvaluableFunction
      Parameters:
      s - substitution
      Returns:
      a new evaluable function where some variables have been replaced by other terms, as defined by the substitution, and where all evaluable nested functions that are already evaluable have been evaluated
    • isEvaluableFunction

      public boolean isEvaluableFunction()
      Description copied from interface: Term
      Indicates whether this term denotes an evaluable function.
      Specified by:
      isEvaluableFunction in interface Term
      Returns:
      true when this term is an evaluable function
    • hashCode

      public int hashCode()
      //////////////////////////////////////////////
      Specified by:
      hashCode in class Record
    • label

      public String label()
      Description copied from interface: Term
      Returns the textual representation of this term.
      Specified by:
      label in interface Term
      Returns:
      a string representation of this object
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • equals

      public boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • applySubstitution

      public Term applySubstitution(Substitution substitution, boolean evaluate)
      Description copied from interface: Term
      Applies a substitution to this term.
      Specified by:
      applySubstitution in interface Substitutable<Term>
      Specified by:
      applySubstitution in interface Term
      Parameters:
      substitution - the substitution to apply
      evaluate - whether nested evaluable functions should be evaluated
      Returns:
      the substituted term
    • function_name

      public String function_name()
      Returns the value of the function_name record component.
      Returns:
      the value of the function_name record component
    • invoker

      public Invoker invoker()
      Returns the value of the invoker record component.
      Returns:
      the value of the invoker record component
    • sub_terms

      public List<Term> sub_terms()
      Returns the value of the sub_terms record component.
      Returns:
      the value of the sub_terms record component