version 3.22

Factorize Boolean expressions

Description

This function finds all combinations of common factors in a Boolean expression written in SOP - Sum Of Products form.

Usage

factorize(input, snames = "", noflevels, pos = FALSE, ...)

Arguments

input A string containing the SOP expression, or an object of class "qca".
snames A string containing the sets' names, separated by commas.
noflevels Numerical vector containing the number of levels for each set.
pos Logical, if possible factorize using product(s) of sums.
... Other arguments (mainly for backwards compatibility).

Details

Factorization is a process of finding common factors in a Boolean expression, written in a SOP - sum of products (or DNF - disjunctive normal form). Whenever possible, the factorization can also be performed in a POS - product of sums form.

Conjunctions should preferably be indicated with a star * sign, but this is not necessary when conditions have single letters or when the expression is expressed in multi-value notation.

The number of levels in noflevels is needed only when negating multivalue conditions, and it should complement the snames argument.

If input is an object of class "qca" (the result of the minimize() function), a factorization is performed for each of the minimized solutions.

Value

A named list, each component containing all possible factorizations of the input expression(s), found in the name(s).

References

Ragin, C.C. (1987) The Comparative Method. Moving beyond qualitative and quantitative strategies, Berkeley: University of California Press

Examples

# typical example with redundant conditions factorize("a~b~cd + a~bc~d + a~bcd + abc~d")
F1: a(~bd + c~d) F2: a~b(c + d) + abc~d F3: a~b~cd + ac(~b + ~d) F4: a~bd + ac~d F5: a(~b~cd + bc~d) + a~bc
# results presented in alphabetical order factorize("~one*two*~four + ~one*three + three*~four")
F1: ~four*(three + ~one*two) + ~one*three F2: ~four*three + ~one*(three + ~four*two) F3: ~four*~one*two + three*(~four + ~one)
# to preserve a certain order of the set names factorize("~one*two*~four + ~one*three + three*~four", snames = "one, two, three, four")
F1: ~one*(three + two*~four) + three*~four F2: ~one*two*~four + three*(~one + ~four) F3: ~four*(three + ~one*two) + ~one*three
# using pos - products of sums factorize("~a~c + ~ad + ~b~c + ~bd", pos = TRUE)
F1: (~a + ~b)(~c + d)
# using an object of class "qca" produced with minimize() pCVF <- minimize(CVF, outcome = "PROTEST", incl.cut = 0.8, include = "?", use.letters = TRUE) factorize(pCVF)
M1: ~E + ~A*B*D + A*B*C + A*C*D F1: ~E + ~A*B*D + A*C*(B + D) F2: ~E + A*C*D + B*(~A*D + A*C) F3: ~E + A*B*C + D*(~A*B + A*C) M2: ~E + ~A*B*D + A*B*~D + A*C*D F1: ~E + ~A*B*D + A*(B*~D + C*D) F2: ~E + A*C*D + B*(~A*D + A*~D) F3: ~E + A*B*~D + D*(~A*B + A*C) M3: ~E + A*B*C + A*C*D + B*C*D F1: ~E + B*C*D + A*C*(B + D) F2: ~E + A*C*D + B*C*(A + D) F3: ~E + C*(A*B + A*D + B*D) F4: ~E + A*B*C + C*D*(A + B) M4: ~E + A*B*~D + A*C*D + B*C*D F1: ~E + B*C*D + A*(B*~D + C*D) F2: ~E + A*C*D + B*(A*~D + C*D) F3: ~E + A*B*~D + C*D*(A + B)
# using an object of class "deMorgan" produced with negate() factorize(negate(pCVF))
M1: ~A~BE + ~A~DE + A~CE + ~B~DE F1: E(~A~B + ~A~D + A~C + ~B~D) F2: ~AE(~B + ~D) + E(A~C + ~B~D) F3: ~BE(~A + ~D) + E(~A~D + A~C) F4: ~DE(~A + ~B) + E(~A~B + A~C) M2: ~A~BE + ~A~DE + ~B~DE + A~CDE F1: E(~A~B + ~A~D + ~B~D + A~CD) F2: ~AE(~B + ~D) + E(~B~D + A~CD) F3: ~BE(~A + ~D) + E(~A~D + A~CD) F4: ~DE(~A + ~B) + E(~A~B + A~CD) M3: ~CE + ~A~BE + ~A~DE + ~B~DE F1: E(~C + ~A~B + ~A~D + ~B~D) F2: ~AE(~B + ~D) + E(~C + ~B~D) F3: ~BE(~A + ~D) + E(~C + ~A~D) F4: ~DE(~A + ~B) + E(~C + ~A~B) M4: ~A~BE + ~A~DE + ~B~DE + ~CDE F1: E(~A~B + ~A~D + ~B~D + ~CD) F2: ~AE(~B + ~D) + E(~B~D + ~CD) F3: ~BE(~A + ~D) + E(~A~D + ~CD) F4: ~DE(~A + ~B) + E(~A~B + ~CD)

Author

Adrian Dusa