rreduce {cna}R Documentation

Eliminate redundancies from a disjunctive normal form (DNF)

Description

rreduce eliminate 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), 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 truthTab or data.frame; can be either crisp-set or multi-value.

full

Logical; if TRUE (the default), redundancies are eliminated relative to full.ct(x), otherwise relative to x.

simplify2constant

Logical; if TRUE (the default), a tautologous or contradictory cond is reduced to a constant "1" or "0", respectively. If FALSE, a minimal tautology or contradiction, i.e. "A+a" or "A*a", will result.

verbose

Logical; if TRUE, the reduction process will be traced in the console.

maxiter

Maximal number of iterations.

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 there are more than one redundancy-free forms of cond, rreduce only returns a randomly chosen one.

Value

Redundancy-free disjunctive normal form (DNF).

See Also

full.ct.

Examples

# Logical redundancies.
cond1 <- "A*b + a*B + A*C + B*C"
rreduce(cond1)
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

[Package cna version 3.2.0 Index]