rreduce {cna} | R Documentation |
Eliminate redundancies from a disjunctive normal form (DNF)
Description
rreduce
eliminates redundancies from disjunctive normal forms (DNF), i.e. disjunctions of conjunctions of literals. If there are several minimal DNF, rreduce
selects one at random.
Usage
rreduce(cond, x = full.ct(cond), niter = 1, full = !missing(x), verbose = FALSE,
maxiter = 1000, simplify2constant = TRUE)
Arguments
cond |
A character string specifying a disjunctive normal form; can be either crisp-set or multi-value. |
x |
A
|
niter |
An integer value |
full |
Logical; if |
simplify2constant |
Logical; if |
verbose |
Logical; if TRUE, the reduction process will be traced in the console. |
maxiter |
Maximal number of iterations. This is a parameter of internal nature, usually not set by the user. |
Details
rreduce
successively eliminates conjuncts and disjuncts from a DNF cond
as long as the result of condition(cond, x)
remains the same. The only required argument is cond
. If x
is not provided, redundancies are eliminated relative to full.ct(cond)
. If x
is provided and full = TRUE
, redundancies are eliminated relative to full.ct(x)
. If x
is provided and full = FALSE
, redundancies are eliminated relative to x
.
If cond
has more than one redundancy-free form, rreduce
only returns a randomly chosen one in the default setting of niter = 1
. By increasing niter
to a value >1
, cond
is (randomly) minimized niter
times. All resulting redundancy-free forms are collected and returned. This provides some insight about the amount of redundancy-free forms that cond
has.
Value
Redundancy-free disjunctive normal form (DNF).
See Also
Examples
# Logical redundancies.
cond1 <- "A*b + a*B + A*C + B*C"
rreduce(cond1)
rreduce(cond1, niter = 10)
cond2 <- "A*b + a*B + A*B + a*b"
rreduce(cond2, simplify2constant = FALSE)
# Any Boolean expressions.
cond <- "!(A*B*C)*!(a*b*c)" # or "A + B*!(D + e) <-> C"
x <- selectCases(cond)
cond <- getCond(x) # Returns a DNF equivalent to cond, but with many redundancies.
rreduce(cond) # Repeated execution results in different outputs.
rreduce(cond, verbose = TRUE)
rreduce(cond, niter = 20) # 20 iterations yield 5 minimal forms.