Class NLPProgram
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<NLPRule>,Collection<NLPRule>,Set<NLPRule>,BeliefBase,LogicProgram<FolFormula,FolFormula, NLPRule>
The `NLPProgram` class extends `RuleSet` with rules of type `NLPRule` and implements the `LogicProgram` interface for first-order logic (FOL) formulas. It provides methods to manage facts, retrieve the minimal signature, and perform substitutions and exchanges on terms within the program.
- Author:
- Tim Janus
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFact(FolFormula fact) Adds a fact to the nested logic program.voidaddFacts(FolFormula... facts) Adds multiple facts to the nested logic program.Exchanges two terms in all rules of the nested logic program.getFacts()Retrieves a set of facts from the nested logic program.Retrieves the minimal signature of the nested logic program.substitute(Map<? extends Term<?>, ? extends Term<?>> map) Substitutes multiple terms in all rules of the nested logic program according to the provided map.substitute(Term<?> t, Term<?> v) Substitutes a term in all rules of the nested logic program.Methods inherited from class org.tweetyproject.commons.util.rules.RuleSet
getConclusions, getPremises, getRulesWithConclusion, getSyntacticModuleMethods inherited from class java.util.HashSet
add, clear, clone, contains, isEmpty, iterator, newHashSet, remove, size, spliterator, toArray, toArrayMethods inherited from class java.util.AbstractSet
equals, hashCode, removeAllMethods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toStringMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface org.tweetyproject.logics.commons.syntax.interfaces.LogicProgram
toString
-
Constructor Details
-
NLPProgram
public NLPProgram()
-
-
Method Details
-
getFacts
Retrieves a set of facts from the nested logic program.This method iterates through all the rules in the program and collects those that are identified as facts. A fact is a rule with an empty premise, and its conclusion is considered a fact in first-order logic.
- Returns:
- a `Set` of `FolFormula` objects representing the facts in the program.
-
addFact
Adds a fact to the nested logic program.This method creates a new `NLPRule` with the given fact.
- Specified by:
addFactin interfaceLogicProgram<FolFormula,FolFormula, NLPRule> - Parameters:
fact- a `FolFormula` representing the fact to be added to the program.
-
addFacts
Adds multiple facts to the nested logic program.This method accepts multiple facts as an array of `FolFormula` objects and adds each one to the program by calling the `addFact` method for each fact.
- Specified by:
addFactsin interfaceLogicProgram<FolFormula,FolFormula, NLPRule> - Parameters:
facts- an array of `FolFormula` objects representing the facts to be added.
-
getMinimalSignature
Retrieves the minimal signature of the nested logic program.- Specified by:
getMinimalSignaturein interfaceBeliefBase- Specified by:
getMinimalSignaturein interfaceLogicProgram<FolFormula,FolFormula, NLPRule> - Returns:
- a `FolSignature` object representing the minimal signature of the program.
-
substitute
Substitutes a term in all rules of the nested logic program.This method creates a new `NLPProgram` in which all occurrences of a specific term (`t`) in the program are replaced with another term (`v`). Each rule in the program is processed, and a substituted version of the rule is added to the new program.
- Specified by:
substitutein interfaceLogicProgram<FolFormula,FolFormula, NLPRule> - Parameters:
t- the term to be replaced.v- the term to replace with.- Returns:
- a new `NLPProgram` with the substitution applied.
-
substitute
public NLPProgram substitute(Map<? extends Term<?>, ? extends Term<?>> map) throws IllegalArgumentExceptionSubstitutes multiple terms in all rules of the nested logic program according to the provided map.- Specified by:
substitutein interfaceLogicProgram<FolFormula,FolFormula, NLPRule> - Parameters:
map- a map where the keys are the terms to be replaced and the values are the replacement terms.- Returns:
- a new `NLPProgram` with the substitutions applied.
- Throws:
IllegalArgumentException- if an invalid substitution is encountered.
-
exchange
Exchanges two terms in all rules of the nested logic program.This method creates a new `NLPProgram` in which two terms (`v` and `t`) are exchanged in all rules of the program.
- Specified by:
exchangein interfaceLogicProgram<FolFormula,FolFormula, NLPRule> - Parameters:
v- the first term involved in the exchange.t- the second term involved in the exchange.- Returns:
- a new `NLPProgram` with the terms exchanged.
- Throws:
IllegalArgumentException- if an invalid exchange is attempted.
-