Package owl.logic.propositional
Class PropositionalFormula<T>
- java.lang.Object
-
- owl.logic.propositional.PropositionalFormula<T>
-
- Type Parameters:
T
- the variable type.
- Direct Known Subclasses:
PropositionalFormula.Biconditional
,PropositionalFormula.Conjunction
,PropositionalFormula.Disjunction
,PropositionalFormula.Negation
,PropositionalFormula.Variable
public abstract class PropositionalFormula<T> extends Object
A propositional formula. JDK16: This class is going to be sealed and migrated to records once JDK16 is adopted.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PropositionalFormula.Biconditional<T>
static class
PropositionalFormula.Conjunction<T>
static class
PropositionalFormula.Disjunction<T>
static class
PropositionalFormula.Negation<T>
static class
PropositionalFormula.Polarity
static class
PropositionalFormula.Variable<T>
-
Constructor Summary
Constructors Constructor Description PropositionalFormula()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static <T> List<PropositionalFormula<T>>
conjuncts(List<? extends PropositionalFormula<T>> formulas)
static <T> List<PropositionalFormula<T>>
conjuncts(PropositionalFormula<T> formula)
static <V> PropositionalFormula<V>
constant(boolean constant)
abstract boolean
containsVariable(T variable)
Map<T,Integer>
countVariables()
protected abstract void
countVariables(Map<T,Integer> occurrences)
protected <S> PropositionalFormula<S>
deduplicate(PropositionalFormula<S> newObject)
static <T> List<PropositionalFormula<T>>
disjuncts(List<? extends PropositionalFormula<T>> formulas)
static <T> List<PropositionalFormula<T>>
disjuncts(PropositionalFormula<T> formula)
abstract boolean
evaluate(Set<? extends T> assignment)
static <V> PropositionalFormula<V>
falseConstant()
abstract int
height()
boolean
isFalse()
boolean
isTrue()
abstract <R> PropositionalFormula<R>
map(Function<? super T,R> mapper)
PropositionalFormula<T>
nnf()
Construct an equivalent expression in negation normal form.protected abstract PropositionalFormula<T>
nnf(boolean negated)
abstract Map<T,PropositionalFormula.Polarity>
polarity()
abstract Optional<T>
smallestVariable()
Returns the smallest variable using the naturalOrder.abstract <S> PropositionalFormula<S>
substitute(Function<? super T,? extends PropositionalFormula<S>> substitution)
static <V> PropositionalFormula<V>
trueConstant()
Set<T>
variables()
-
-
-
Method Detail
-
nnf
public final PropositionalFormula<T> nnf()
Construct an equivalent expression in negation normal form.- Returns:
- A new expression
-
substitute
public abstract <S> PropositionalFormula<S> substitute(Function<? super T,? extends PropositionalFormula<S>> substitution)
-
nnf
protected abstract PropositionalFormula<T> nnf(boolean negated)
-
constant
public static <V> PropositionalFormula<V> constant(boolean constant)
-
trueConstant
public static <V> PropositionalFormula<V> trueConstant()
-
falseConstant
public static <V> PropositionalFormula<V> falseConstant()
-
height
public abstract int height()
-
isFalse
public boolean isFalse()
-
isTrue
public boolean isTrue()
-
containsVariable
public abstract boolean containsVariable(T variable)
-
smallestVariable
public abstract Optional<T> smallestVariable()
Returns the smallest variable using the naturalOrder.- Returns:
- the smallest variable.
-
polarity
public abstract Map<T,PropositionalFormula.Polarity> polarity()
-
map
public abstract <R> PropositionalFormula<R> map(Function<? super T,R> mapper)
-
deduplicate
protected <S> PropositionalFormula<S> deduplicate(PropositionalFormula<S> newObject)
-
conjuncts
public static <T> List<PropositionalFormula<T>> conjuncts(PropositionalFormula<T> formula)
-
conjuncts
public static <T> List<PropositionalFormula<T>> conjuncts(List<? extends PropositionalFormula<T>> formulas)
-
disjuncts
public static <T> List<PropositionalFormula<T>> disjuncts(PropositionalFormula<T> formula)
-
disjuncts
public static <T> List<PropositionalFormula<T>> disjuncts(List<? extends PropositionalFormula<T>> formulas)
-
-