public abstract class QBF extends Object
QBF
is an immutable data structure, representing quantified boolean
formula trees containing the following connectives:
Modifier and Type | Class and Description |
---|---|
static class |
QBF.And
A conjunction.
|
static class |
QBF.Exists
An existential quantifier.
|
static class |
QBF.False
The boolean constant
false . |
static class |
QBF.ForAll
A universal quantifier.
|
static class |
QBF.MultiaryOperator
Base class for multiary (n-ary) operators.
|
static class |
QBF.Not
A negation.
|
static class |
QBF.Or
A disjunction.
|
static class |
QBF.Quantifier
Base class for quantifier nodes.
|
static class |
QBF.Terminal
A terminal node in the QBF tree.
|
static class |
QBF.Traverse
Tree traversal order.
|
static class |
QBF.True
The boolean constant
true . |
static class |
QBF.UnaryOperator
Base class for unary operators.
|
static class |
QBF.Variable
A variable.
|
Modifier and Type | Field and Description |
---|---|
static QBF |
False
Singleton instance of the boolean constant
false . |
static Predicate<QBF> |
isAnd
Tests if the given instance is a
conjunction . |
static Predicate<QBF> |
isCNF
Tests if the given instance is in conjunctive normal form.
|
static Predicate<QBF> |
isConstant
Tests if the given instance is a boolean constant.
|
static Predicate<QBF> |
isExists
Tests if the given instance is a
existential quantifier . |
static Predicate<QBF> |
isForAll
Tests if the given instance is a
universal quantifier . |
static Predicate<QBF> |
isLiteral
Tests if the given instance is a literal.
|
static Predicate<QBF> |
isNegation
Tests if the given instance is a
negation . |
static Predicate<QBF> |
isOr
Tests if the given instance is a
disjunction . |
static Predicate<QBF> |
isQuantifier
Tests if the given instance is a quantifier.
|
static Predicate<QBF> |
isVariable
Tests if the given instance is a
variable . |
static QBF |
True
Singleton instance of the boolean constant
true . |
Modifier and Type | Method and Description |
---|---|
void |
accept(Consumer<QBF.ForAll> forall,
Consumer<QBF.Exists> exists)
Applies a given
Consumer to a quantifier. |
abstract void |
accept(Consumer<QBF.True> t,
Consumer<QBF.False> f,
Consumer<QBF.Variable> var,
Consumer<QBF.Not> not,
Consumer<QBF.And> and,
Consumer<QBF.Or> or,
Consumer<QBF.ForAll> forall,
Consumer<QBF.Exists> exists)
Applies a given
Consumer to the underlying concrete type. |
<T> T |
apply(Function<QBF.ForAll,T> forall,
Function<QBF.Exists,T> exists)
Applies a given
Function to a quantifier. |
abstract <T> T |
apply(Function<QBF.True,T> t,
Function<QBF.False,T> f,
Function<QBF.Variable,T> var,
Function<QBF.Not,T> not,
Function<QBF.And,T> and,
Function<QBF.Or,T> or,
Function<QBF.ForAll,T> forall,
Function<QBF.Exists,T> exists)
Applies a given
Function to the underlying concrete type. |
QBF |
cleanse()
Produces a cleansed formula.
|
boolean |
equals(Object o) |
static List<QBF> |
getCriticalPaths(List<QBF> qpaths)
Gets a list of critical q-paths.
|
List<QBF> |
getQPaths()
Gets a list of this formula's q-paths.
|
QBF |
getSkeleton()
Gets the propositional skeleton of this formula.
|
protected int |
hash() |
int |
hashCode() |
boolean |
isAnd()
Tests if this is a
conjunction . |
boolean |
isCNF()
Tests if this formula is in conjunctive normal form.
|
boolean |
isConstant()
Tests if this is a boolean constant.
|
boolean |
isExists()
Tests if this is a
existential quantifier . |
boolean |
isForAll()
Tests if this is a
universal quantifier . |
boolean |
isLiteral()
Tests if this is a literal.
|
boolean |
isNegation()
Tests if this is a
negation . |
boolean |
isOr()
Tests if this is a
disjunction . |
boolean |
isQuantifier()
Tests if this is a quantifier.
|
boolean |
isVariable()
Tests if this is a
variable . |
QBF |
negate()
Negates the current formula.
|
String |
prefixToString()
Gets a String representation of this formula's prefix.
|
static String |
quantifierToString(QBF.Quantifier q)
Gets a String representation of the given quantifier.
|
QBF |
rename(Map<String,String> variables)
Renames this formula's variables.
|
Stream<QBF> |
stream(QBF.Traverse traversal)
Streams the formula's nodes in a depth-first search manner.
|
Stream<String> |
streamBoundVariables()
Streams all bound variables in this formula.
|
Stream<String> |
streamFreeVariables()
Streams all free variables in this formula.
|
Stream<QBF.Quantifier> |
streamPrefix()
Streams this formula's prefix.
|
Stream<QBF> |
streamQPaths()
Streams this formula's q-paths.
|
Stream<String> |
streamVariables()
Streams all variables in this formula.
|
QBF |
toNNF()
Transforms this formula into negated normal form.
|
QBF |
toPCNF(PrenexingStrategy strategy,
CNFEncoder encoder)
Transforms this formula into prenex conjunctive normal form.
|
QBF |
toPNF(PrenexingStrategy strategy)
Transforms this formula into prenex normal form.
|
String |
toString() |
QBF |
unifyPrefix()
Deprecated.
|
public static final Predicate<QBF> isConstant
public static final Predicate<QBF> isQuantifier
public static final Predicate<QBF> isForAll
universal quantifier
.public static final Predicate<QBF> isExists
existential quantifier
.public static final Predicate<QBF> isAnd
conjunction
.public static final Predicate<QBF> isOr
disjunction
.public abstract void accept(Consumer<QBF.True> t, Consumer<QBF.False> f, Consumer<QBF.Variable> var, Consumer<QBF.Not> not, Consumer<QBF.And> and, Consumer<QBF.Or> or, Consumer<QBF.ForAll> forall, Consumer<QBF.Exists> exists)
Consumer
to the underlying concrete type.t
- Consumer
accepting the boolean constant true
f
- Consumer
accepting the boolean constant false
var
- Consumer
accepting variables
not
- Consumer
accepting negations
and
- Consumer
accepting conjunctions
or
- Consumer
accepting disjunctions
forall
- Consumer
accepting universal quantifiers
exists
- Consumer
accepting existential quantifiers
public void accept(Consumer<QBF.ForAll> forall, Consumer<QBF.Exists> exists)
Consumer
to a quantifier.forall
- Consumer
accepting universal quantifiers
exists
- Consumer
accepting existential quantifiers
IllegalArgumentException
- if this is not a quantifierpublic abstract <T> T apply(Function<QBF.True,T> t, Function<QBF.False,T> f, Function<QBF.Variable,T> var, Function<QBF.Not,T> not, Function<QBF.And,T> and, Function<QBF.Or,T> or, Function<QBF.ForAll,T> forall, Function<QBF.Exists,T> exists)
Function
to the underlying concrete type.T
- return typet
- Function
accepting the boolean constant true
f
- Function
accepting the boolean constant false
var
- Function
accepting variables
not
- Function
accepting negations
and
- Function
accepting conjunctions
or
- Function
accepting disjunctions
forall
- Function
accepting universal quantifiers
exists
- Function
accepting existential quantifiers
Function
applicationpublic <T> T apply(Function<QBF.ForAll,T> forall, Function<QBF.Exists,T> exists)
Function
to a quantifier.T
- return typeforall
- Function
accepting universal quantifiers
exists
- Function
accepting existential quantifiers
Function
applicationIllegalArgumentException
- if this is not a quantifierpublic boolean isConstant()
public boolean isQuantifier()
true
if this is either QBF.ForAll
or QBF.Exists
public boolean isForAll()
universal quantifier
.true
if this is a universal quantifier
public boolean isExists()
existential quantifier
.true
if this is a existential quantifier
public boolean isVariable()
variable
.true
if this is a variable
public boolean isLiteral()
true
if this is a literal.public boolean isNegation()
negation
.true
if this is a negation
public boolean isAnd()
conjunction
.true
if this is a conjunction
public boolean isOr()
disjunction
.true
if this is a disjunction
public boolean isCNF()
true
if this is in conjunctive normal formprotected int hash()
public Stream<QBF> stream(QBF.Traverse traversal)
traversal
- pre- or post-orderpublic Stream<String> streamVariables()
public Stream<String> streamFreeVariables()
public Stream<String> streamBoundVariables()
public Stream<QBF.Quantifier> streamPrefix()
public Stream<QBF> streamQPaths()
The set of q-paths of Φ, qpaths(Φ)
, is defined inductively as
follows:
Φ
is a variable, QBF.True
or QBF.False
, then
qpaths(Φ) = {}
.
Φ = ¬Φ1
, then
qpaths(Φ) = {Q̄1 p1 ... Q̄k pk | Q1 p1 ... Qk pk ∈ qpaths(Φ1)}
.
Φ = Φ1 ◦ Φ 2 (◦ ∈ {∧, ∨})
, then
qpaths(Φ) = qpaths(Φ1) ∪ qpaths(Φ2)
.
Φ = Φ1 → Φ2
, then
qpaths(Φ) = qpaths(¬Φ1 ∨ Φ2)
.
Φ = Qp Φ1 (Q ∈ {∀, ∃})
, then
qpaths(Φ) = {Q ps | s ∈ qpaths(Φ1)}
.
Note: only the q-path's head node is returned, use
streamPrefix()
to get the full path.
public List<QBF> getQPaths()
The set of q-paths of Φ, qpaths(Φ)
, is defined inductively as
follows:
Φ
is a variable, QBF.True
or QBF.False
, then
qpaths(Φ) = {}
.
Φ = ¬Φ1
, then
qpaths(Φ) = {Q̄1 p1 ... Q̄k pk | Q1 p1 ... Qk pk ∈ qpaths(Φ1)}
.
Φ = Φ1 ◦ Φ 2 (◦ ∈ {∧, ∨})
, then
qpaths(Φ) = qpaths(Φ1) ∪ qpaths(Φ2)
.
Φ = Φ1 → Φ2
, then
qpaths(Φ) = qpaths(¬Φ1 ∨ Φ2)
.
Φ = Qp Φ1 (Q ∈ {∀, ∃})
, then
qpaths(Φ) = {Q ps | s ∈ qpaths(Φ1)}
.
Note: only the q-path's head node is returned, use
streamPrefix()
to get the full path.
public static List<QBF> getCriticalPaths(List<QBF> qpaths)
A critical path is defined by having the largest number of quantifier alterations.
qpaths
- a list of q-pathspublic QBF getSkeleton()
The propositional skeleton of a QBF Φ is given by deleting all quantifiers in Φ.
@Deprecated public QBF unifyPrefix()
∀x: ∀y: ϕ → ∀x,y: ϕ
QBF
with purely alternating prefixpublic QBF rename(Map<String,String> variables)
variables
- a map of old to new variable namesQBF
with renamed variablespublic QBF cleanse()
[1, #bound]
]#bound, #variables]
QBF
public QBF toNNF()
QBF
in negated normal formpublic QBF toPNF(PrenexingStrategy strategy)
strategy
- prenexing strategyQBF
in prenex normal formpublic QBF toPCNF(PrenexingStrategy strategy, CNFEncoder encoder)
strategy
- prenexing strategyencoder
- CNF encoderQBF
in prenex conjunctive normal formpublic static String quantifierToString(QBF.Quantifier q)
q
- a quantifierpublic String prefixToString()