Class FunctionalTerm
- java.lang.Object
-
- net.sf.tweety.logics.commons.syntax.TermAdapter<Pair<Functor,java.util.List<Term<?>>>>
-
- net.sf.tweety.logics.commons.syntax.FunctionalTerm
-
- All Implemented Interfaces:
LogicStructure
,Term<Pair<Functor,java.util.List<Term<?>>>>
public class FunctionalTerm extends TermAdapter<Pair<Functor,java.util.List<Term<?>>>>
A functional term in a logic language, i.e. a functor and a list of argument terms.- Author:
- Matthias Thimm,, Tim Janus
-
-
Constructor Summary
Constructors Constructor Description FunctionalTerm(FunctionalTerm other)
FunctionalTerm(Functor functor)
Creates a new functional term with the given functor.FunctionalTerm(Functor functor, java.util.List<Term<?>> arguments)
Creates a new functional term with the given functor and the given list of arguments.FunctionalTerm(Functor functor, Term<?>... terms)
-
Method Summary
Modifier and Type Method Description FunctionalTerm
addArgument(Term<?> term)
Appends the given argument to this term's arguments and returns itself.FunctionalTerm
clone()
Creates a deep copy of the termjava.util.List<Term<?>>
getArguments()
Functor
getFunctor()
java.util.Set<Term<?>>
getTerms()
<C extends Term<?>>
java.util.Set<C>getTerms(java.lang.Class<C> cls)
Processes the set containing all terms of type C.boolean
isComplete()
Checks whether this term is complete, i.e.Term<?>
substitute(Term<?> v, Term<?> t)
Substitutes all occurrences of term "v" in this term by term "t" and returns the new term.java.lang.String
toString()
-
Methods inherited from class net.sf.tweety.logics.commons.syntax.TermAdapter
containsTermsOfType, equals, get, getSort, hashCode, set
-
-
-
-
Constructor Detail
-
FunctionalTerm
public FunctionalTerm(Functor functor, java.util.List<Term<?>> arguments)
Creates a new functional term with the given functor and the given list of arguments.- Parameters:
functor
- the functor of this termarguments
- the list of arguments of this functional term
-
FunctionalTerm
public FunctionalTerm(FunctionalTerm other)
-
FunctionalTerm
public FunctionalTerm(Functor functor)
Creates a new functional term with the given functor.- Parameters:
functor
- a functor
-
-
Method Detail
-
getFunctor
public Functor getFunctor()
-
getArguments
public java.util.List<Term<?>> getArguments()
-
isComplete
public boolean isComplete()
Checks whether this term is complete, i.e. whether every argument is set.- Returns:
- "true" if the term is complete.
-
addArgument
public FunctionalTerm addArgument(Term<?> term) throws java.lang.IllegalArgumentException
Appends the given argument to this term's arguments and returns itself.- Parameters:
term
- an argument to be added- Returns:
- the term itself.
- Throws:
java.lang.IllegalArgumentException
- if the given term does not correspond to the expected sort or the argument list is complete.
-
getTerms
public java.util.Set<Term<?>> getTerms()
- Specified by:
getTerms
in interfaceLogicStructure
- Overrides:
getTerms
in classTermAdapter<Pair<Functor,java.util.List<Term<?>>>>
- Returns:
- a set containing all terms of this logical structure
-
getTerms
public <C extends Term<?>> java.util.Set<C> getTerms(java.lang.Class<C> cls)
Description copied from interface:LogicStructure
Processes the set containing all terms of type C. This method uses the equals method of the given Class and therefore does not add terms which are sub classes of type C to the set.- Specified by:
getTerms
in interfaceLogicStructure
- Overrides:
getTerms
in classTermAdapter<Pair<Functor,java.util.List<Term<?>>>>
- Type Parameters:
C
- the type of terms- Parameters:
cls
- The Class structure containing type information about the searched term- Returns:
- A set containing all terms of type C of this logical structure
-
substitute
public Term<?> substitute(Term<?> v, Term<?> t) throws java.lang.IllegalArgumentException
Description copied from interface:Term
Substitutes all occurrences of term "v" in this term by term "t" and returns the new term.- Specified by:
substitute
in interfaceTerm<Pair<Functor,java.util.List<Term<?>>>>
- Overrides:
substitute
in classTermAdapter<Pair<Functor,java.util.List<Term<?>>>>
- Parameters:
v
- the term to be substituted.t
- the term to substitute.- Returns:
- a term where every occurrence of "v" is replaced by "t".
- Throws:
java.lang.IllegalArgumentException
- if "v" and "t" are of different sorts (NOTE: this exception is only thrown when "v" actually appears in this formula)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classTermAdapter<Pair<Functor,java.util.List<Term<?>>>>
-
-