Class AssociativeFolFormula
java.lang.Object
org.tweetyproject.logics.commons.syntax.RelationalFormula
org.tweetyproject.logics.fol.syntax.FolFormula
org.tweetyproject.logics.fol.syntax.AssociativeFolFormula
- All Implemented Interfaces:
Iterable<RelationalFormula>
,Collection<RelationalFormula>
,List<RelationalFormula>
,SequencedCollection<RelationalFormula>
,Formula
,AssociativeFormulaSupport.AssociativeSupportBridge
,AssociativeFormula<RelationalFormula>
,ClassicalFormula
,ComplexLogicalFormula
,Conjunctable
,Disjunctable
,Invertable
,LogicStructure
,ProbabilityAware
,QuantifiedFormula
,SimpleLogicalFormula
- Direct Known Subclasses:
Conjunction
,Disjunction
,ExclusiveDisjunction
public abstract class AssociativeFolFormula
extends FolFormula
implements AssociativeFormula<RelationalFormula>, AssociativeFormulaSupport.AssociativeSupportBridge
This class captures the common functionalities first order associative formulas like conjunction,
disjunction, etc.
- Author:
- Matthias Thimm, Tim Janus
-
Constructor Summary
ConstructorDescriptionCreates a new (empty) associative formula.AssociativeFolFormula
(Collection<? extends RelationalFormula> formulas) Creates a new associative formula with the given inner formulas.AssociativeFolFormula
(RelationalFormula first, RelationalFormula second) Creates a new associative formula with the two given formulae -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int index, RelationalFormula element) boolean
boolean
add
(FolFormula... formulas) Adds the specified elements to the end of this collection (optional operation).boolean
addAll
(int index, Collection<? extends RelationalFormula> c) boolean
addAll
(Collection<? extends RelationalFormula> c) void
clear()
boolean
boolean
containsAll
(Collection<?> c) boolean
Checks whether this formula contains any quantification.boolean
get
(int index) getAtoms()
Processes the set of all atoms which appear in this formula<C extends SimpleLogicalFormula>
Set<C> getFormulas
(Class<C> cls) Process the formulas of type C that are children of this associative formulaProcesses the set of all predicates which appear in this formulagetTerms()
Processes the set containing all terms of type C.int
hashCode()
int
boolean
isClosed()
Checks whether this formula is closed, i.e.boolean
Checks whether this formula is closed, i.e.boolean
isEmpty()
boolean
boolean
Checks whether this formula is well-bound, i.e.boolean
isWellBound
(Set<Variable> boundVariables) Checks whether this formula is well-bound, i.e.iterator()
int
listIterator
(int index) remove
(int index) boolean
boolean
removeAll
(Collection<?> c) boolean
retainAll
(Collection<?> c) set
(int index, RelationalFormula element) int
size()
subList
(int fromIndex, int toIndex) substitute
(Map<? extends Term<?>, ? extends Term<?>> termMap) Substitutes all occurrences of all terms "v" in map.keyset() in this formula by map.get(v) and returns the new formula.
NOTE: variables bound to quantifiers are not substituted in their inner formulas even if they appear in the map.substitute
(Term<?> v, Term<?> t) Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.Object[]
toArray()
<T> T[]
toArray
(T[] a) toString()
Methods inherited from class org.tweetyproject.logics.fol.syntax.FolFormula
clone, collapseAssociativeFormulas, combineWithAnd, combineWithOr, complement, getSignature, getUniformProbability, isDnf, toDnf, toNnf
Methods inherited from class org.tweetyproject.logics.commons.syntax.RelationalFormula
allGroundInstances, allSubstitutions, containsTermsOfType, exchange, getFormula, getPredicateCls, getSatisfactionRatio, isGround, isWellFormed
Methods inherited from interface org.tweetyproject.logics.commons.syntax.AssociativeFormulaSupport.AssociativeSupportBridge
createEmptyFormula, getEmptySymbol, getOperatorSymbol
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface org.tweetyproject.commons.Formula
getSignature
Methods inherited from interface java.util.List
addFirst, addLast, getFirst, getLast, removeFirst, removeLast, replaceAll, reversed, sort, spliterator
Methods inherited from interface org.tweetyproject.logics.commons.syntax.interfaces.SimpleLogicalFormula
getPredicateCls
-
Constructor Details
-
AssociativeFolFormula
public AssociativeFolFormula()Creates a new (empty) associative formula. -
AssociativeFolFormula
Creates a new associative formula with the two given formulae- Parameters:
first
- a relational formula.second
- a relational formula.
-
AssociativeFolFormula
Creates a new associative formula with the given inner formulas.- Parameters:
formulas
- a collection of formulas.
-
-
Method Details
-
createEmptySignature
- Specified by:
createEmptySignature
in interfaceAssociativeFormulaSupport.AssociativeSupportBridge
- Returns:
- An empty signature of the language of the AssociativeFormula implementation
-
getFunctors
- Specified by:
getFunctors
in classRelationalFormula
- Returns:
- all functors that appear in this formula.
-
containsQuantifier
public boolean containsQuantifier()Description copied from interface:QuantifiedFormula
Checks whether this formula contains any quantification.- Specified by:
containsQuantifier
in interfaceQuantifiedFormula
- Returns:
- "true" if this formula contains a quantification.
-
getUnboundVariables
- Specified by:
getUnboundVariables
in interfaceQuantifiedFormula
- Returns:
- a set of of unbound variables
-
isClosed
public boolean isClosed()Description copied from interface:QuantifiedFormula
Checks whether this formula is closed, i.e. whether every variables occurring in the formula is bound by a quantifier.- Specified by:
isClosed
in interfaceQuantifiedFormula
- Returns:
- "true" if this formula is closed, "false" otherwise.
-
isClosed
Description copied from interface:QuantifiedFormula
Checks whether this formula is closed, i.e. whether every variables occurring in the formula is bound by a quantifier. Every variable in "boundVariables" is already assumed to be bound.- Specified by:
isClosed
in interfaceQuantifiedFormula
- Parameters:
boundVariables
- the variables assumed to be bound.- Returns:
- "true" if this formula is closed wrt. "boundVariables", "false" otherwise.
-
isWellBound
public boolean isWellBound()Description copied from interface:QuantifiedFormula
Checks whether this formula is well-bound, i.e. whether no variable bound by a quantifier is again bound by another quantifier within the first quantifier's range.- Specified by:
isWellBound
in interfaceQuantifiedFormula
- Returns:
- "true" if this formula is well-bound, "false" otherwise.
-
isWellBound
Description copied from interface:QuantifiedFormula
Checks whether this formula is well-bound, i.e. whether no variable bound by a quantifier is again bound by another quantifier within the first quantifier range. Every variable in "boundVariables" is assumed to be bound already.- Specified by:
isWellBound
in interfaceQuantifiedFormula
- Parameters:
boundVariables
- the variables assumed to be bound.- Returns:
- "true" if this formula is well-bound, "false" otherwise.
-
isLiteral
public boolean isLiteral()- Specified by:
isLiteral
in interfaceSimpleLogicalFormula
- Returns:
- true if the formula represents a literal in the language or false otherwise
-
getQuantifierVariables
- Specified by:
getQuantifierVariables
in interfaceQuantifiedFormula
- Overrides:
getQuantifierVariables
in classFolFormula
- Returns:
- a set containing all quantified variables
-
getFormulas
- Specified by:
getFormulas
in interfaceAssociativeFormula<RelationalFormula>
- Returns:
- all the formulas saved as childs in the associative formula
-
getFormulas
Description copied from interface:AssociativeFormula
Process the formulas of type C that are children of this associative formula- Specified by:
getFormulas
in interfaceAssociativeFormula<RelationalFormula>
- Type Parameters:
C
- the type of formulas- Parameters:
cls
- the class structure defining the type of formulas which are searched.- Returns:
- A set of formulas of type C which are members of the associative formula
-
getAtoms
Description copied from interface:SimpleLogicalFormula
Processes the set of all atoms which appear in this formula- Specified by:
getAtoms
in interfaceSimpleLogicalFormula
- Specified by:
getAtoms
in classRelationalFormula
- Returns:
- all atoms that appear in this formula.
-
getTerms
- Specified by:
getTerms
in interfaceLogicStructure
- Returns:
- a set containing all terms of this logical structure
-
getTerms
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
- 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
-
getPredicates
Description copied from interface:SimpleLogicalFormula
Processes the set of all predicates which appear in this formula- Specified by:
getPredicates
in interfaceSimpleLogicalFormula
- Returns:
- all predicates that appear in this formula
-
substitute
Description copied from class:RelationalFormula
Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula. NOTE: if "v" is a variable and bound to a quantifier then "v" is not substituted in that quantifiers inner formula.- Specified by:
substitute
in interfaceComplexLogicalFormula
- Specified by:
substitute
in classFolFormula
- Parameters:
v
- the term to be substituted.t
- the term to substitute.- Returns:
- a formula where every occurrence of "v" is replaced by "t".
-
substitute
Description copied from class:RelationalFormula
Substitutes all occurrences of all terms "v" in map.keyset() in this formula by map.get(v) and returns the new formula.
NOTE: variables bound to quantifiers are not substituted in their inner formulas even if they appear in the map.- Specified by:
substitute
in interfaceComplexLogicalFormula
- Overrides:
substitute
in classRelationalFormula
- Parameters:
termMap
- a mapping defining which terms to be substituted.- Returns:
- a formula where every term in map.keyset() has been replaced by map.get(v).
-
toString
- Specified by:
toString
in classRelationalFormula
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceCollection<RelationalFormula>
- Specified by:
hashCode
in interfaceList<RelationalFormula>
- Specified by:
hashCode
in interfaceSimpleLogicalFormula
- Overrides:
hashCode
in classObject
-
equals
- Specified by:
equals
in interfaceCollection<RelationalFormula>
- Specified by:
equals
in interfaceList<RelationalFormula>
- Specified by:
equals
in interfaceSimpleLogicalFormula
- Overrides:
equals
in classObject
-
add
- Specified by:
add
in interfaceCollection<RelationalFormula>
- Specified by:
add
in interfaceList<RelationalFormula>
-
add
Adds the specified elements to the end of this collection (optional operation).- Parameters:
formulas
- to be appended to collection- Returns:
- true if all elements were added, false otherwise
-
addAll
- Specified by:
addAll
in interfaceCollection<RelationalFormula>
- Specified by:
addAll
in interfaceList<RelationalFormula>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<RelationalFormula>
- Specified by:
clear
in interfaceList<RelationalFormula>
-
contains
- Specified by:
contains
in interfaceCollection<RelationalFormula>
- Specified by:
contains
in interfaceList<RelationalFormula>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<RelationalFormula>
- Specified by:
containsAll
in interfaceList<RelationalFormula>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<RelationalFormula>
- Specified by:
isEmpty
in interfaceList<RelationalFormula>
-
iterator
- Specified by:
iterator
in interfaceCollection<RelationalFormula>
- Specified by:
iterator
in interfaceIterable<RelationalFormula>
- Specified by:
iterator
in interfaceList<RelationalFormula>
-
remove
- Specified by:
remove
in interfaceCollection<RelationalFormula>
- Specified by:
remove
in interfaceList<RelationalFormula>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<RelationalFormula>
- Specified by:
removeAll
in interfaceList<RelationalFormula>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<RelationalFormula>
- Specified by:
retainAll
in interfaceList<RelationalFormula>
-
size
public int size()- Specified by:
size
in interfaceCollection<RelationalFormula>
- Specified by:
size
in interfaceList<RelationalFormula>
-
toArray
- Specified by:
toArray
in interfaceCollection<RelationalFormula>
- Specified by:
toArray
in interfaceList<RelationalFormula>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArray
in interfaceCollection<RelationalFormula>
- Specified by:
toArray
in interfaceList<RelationalFormula>
-
add
- Specified by:
add
in interfaceList<RelationalFormula>
-
addAll
- Specified by:
addAll
in interfaceList<RelationalFormula>
-
get
- Specified by:
get
in interfaceList<RelationalFormula>
-
indexOf
- Specified by:
indexOf
in interfaceList<RelationalFormula>
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceList<RelationalFormula>
-
listIterator
- Specified by:
listIterator
in interfaceList<RelationalFormula>
-
listIterator
- Specified by:
listIterator
in interfaceList<RelationalFormula>
-
remove
- Specified by:
remove
in interfaceList<RelationalFormula>
-
set
- Specified by:
set
in interfaceList<RelationalFormula>
-
subList
- Specified by:
subList
in interfaceList<RelationalFormula>
-