rreduce: Eliminate redundancies from a disjunctive normal form (DNF)

View source: R/rreduce.R

rreduceR 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 configTable or data.frame; can be either crisp-set or multi-value.

niter

An integer value >=1 specifying the number of iterated minimization attempts. The minimal DNFs produced in each iteration are collected and returned.

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. 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

full.ct.

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.

cna documentation built on Aug. 11, 2023, 1:09 a.m.