Binary Recursion
Total Page:16
File Type:pdf, Size:1020Kb
Binary recursion 1 Unate functions ! Theorem If a cover C(f) is unate in xj, then f is unate in xj. ! Theorem If f is unate in xj, then every prime implicant of f is unate in xj. 2 1 Why are unate functions so special? ! Special Boolean algorithms for unate functions are not only fast, but also give the guaranteed minimum result. ! The algorithms presented perform the Boolean operations and simplify the result in the same time. ! In practice, many functions are partially unate. The divide and conquer strategy aimed at unateness produces very shallow recursions; algorithms are fast in practice. 3 Unate recursive paradigm works for: ! Complementation ! Irredundant cover ! Reduce ! Essential primes = + ! Example f x 1 x 2 x 2 x 3 is unate 4 2 Important facts about unate functions Proposition 1. A logic function f is monotone increasing (decreasing) in x j if and only if no prime implicant of f has a 0 (1) in the j-th position. Proof: (if) If no prime implicant has a 0 in the jth position, any prime cover C(f) is unate in x j . So f is unate in x j. (only if) Let c i is a prime with 0 at jth position -> the cube c~i obtained by replacing 0 in jth position with a 1 contains at least one vector in f . For the input v corresponding to that vertex, f(v)=0. If we change x j from 1 to 0 in v, the value of f changes from 0 to 1, so f is not monotone increasing. 5 Proposition 2. A unate cover is a tautology if and only if it contains a row of all 2s (it contains a universal cube). Proposition 3. Let C be a unate cover, S any subset of the cubes of C and c a cube in C. Then c ⊆ S if and only if c ⊆ s for some s ∈ S . (Only if) Let C be a positive unate cover. Since C is positive, unate, every cube in C contains the vertex (1,1,…1) and so c ∩ s ≠ 0 ∀s∈ S ⊆ ≡ Now, suppose c S . This implies that S c 1 but a unate cover is a tautology if and only if it contains a row of all 2s. So there exists s ∈ S Which generated this row. Thus c ⊆ s from this s ∈ S . The if part is trivially true. 6 3 Proposition 4. Every prime of a unate function is essential. Proposition 5. Let C be a unate cover and P be a set of all primes of b(C), the logical function specified by C. Then P ⊆ C . If in addition, C is minimal with respect to single cube containment, then P=C, and C is unique minimum cover. ( C minimal with respect to containment ≡ any c is contained in some p) From proposition 5, it follows that we can find the minimum cardinality prime cover of a unate function starting from any cover and (a) expand each cube to a prime (b) remove any cube which is contained in any other cube of the cover. 7 The following propositions are helpful in constructing an efficient algorithm for finding the complement of a function: • If a logic function f is monotone increasing in x j , then the complement of f, f is monotone increasing in x j . • The complement of a unate function is unate. •The cofactors of a unate function f with respect to x j and x j are unate. 8 4 How to simplify a unate function? Example: f = abc + abc + abc + abc + abc f is monotone increasing in a, decreasing in b and c. c b a f = ab/c + abc/ + abc + a/bc/ + a/bc = ac + ab + abc + b + bc (unate cover) f = b + ac (set of all primes = global unate cover) 9 Proposition. Let f = x f + x j f be the Shannon expansion of a j x j x j completely specified logic function f. Then f=1 (tautology) if and only if f ≡ 1 and f ≡ 1 . x j x j Proof (If) If f ≡1 ∧ f ≡1⇒ f = x + x ≡1. x j x j j j (only if) f f Suppose that x j is not a tautology -> exists an input of x j say y , such that the output of f x is 0. Since f x j j j = is independent of x j , an input combination with x j 1 can be selected so that the output of x f is 0. j x j For this input combination, the output of f = x f + x j f j x j x j corresponding to y j must be 0, -> f is not a tautology. 10 5 General recursive paradigm Applies to: intersection complementation tautology 1. Apply the operation to the 2 cofactors. 2. Merge the results. Operate( f , g) = merge(x operate( f , g ), j x j x j x joperate( f , g )) x j x j 11 Recursion tree Each node merges the results of its 2 children trees. For tautology checking - merging is simple, both trees must be tautologies. Complementation and reduction are more complicated. h h = x h + x jh (for function) j x j x j h0 h1 H = x H + x j H j x j x j (for covers) 12 6 Binary recursion tree ! The recursive Shannon expansion corresponds to a binary recursion tree = + = + + + f xf x x f x x(yf xy y f x y ) x(yf xy y f xy ) x1 f x f 1 0 0 1 f f x P(v) = x2 x c x1x2 x3 0 y 0 y 0 1 P(v) 1 1 f f f x y xy f y x y x P(v) x3 0 Path P(v) to node v corresponds to cube c 1 v 13 Binary recursion tree ! The root represents the original function f ! Each node v corresponds to f cP (v ) ! f If ever c P ( v ) =1 or 0 we can terminate the tree and replace v by 1 or 0. Such a node is a leaf. ! Example: f = ab + a’c splitting variable 1 a 0 1 a 0 c b 1 b 0 b 1 0 1 0 1 0 c c 0 1 0 1 0 1 1 1 0 0 1 0 1 0 14 7 Implicit enumeration - branch and bound ! Checking for tautology and many other theoretically intractable problems (co-NP complete) can be effectively solved using implicit enumeration. n ! Use recursive Shannon expansion to explore B n ! in (hopefully) large subspaces of B , prune the binary recursion tree by f ! exploiting properties of the node function cP (v ) ! exploiting heuristic bounding techniques n ! even though in the worst case the recursion tree may have 2 nodes, in practice we typically encounter a linear number of nodes ! thus we say that the 2 n min-terms of f have been implicitly enumerated ! BDD’s are alternate representations in which implicit enumeration is performed statically, and nodes with identical path cofactors are identified. 15 Unate recursive paradigm ! In the ESPRESSO program, the key pruning technique is based on exploiting the properties of unate functions. ! The splitting variable is chosen so that the functions at lower nodes of the recursion tree become unate. ! Unate covers F have many good properties: ! If a cover F is minimal with respect to single cube containment, all of its cubes are essential primes. ! In this case F is the unique minimum cube representation of its logic function. ! A unate cover represents the tautology iff it contains a cube with no literals. ! This type of implicit enumeration applies to many subproblems (prime generation, complementation, reduction). 16 8 Recursion tree ! Each node merges results of its 2 children trees. ! For tautology checking - merging is simple, both subtrees must be tautologies. ! Complementation and reduction are more complicated. ! h0 and h1 are the logic functions corresponding to the trees below a node h of a tree. h h=xj’h0+xjh1 ! We work with covers and their matrix h0 h1 representations: H = xj’H0 + xjH1 17 How to keep results compact? ! If H0 and H1 are prime and irredundant, we would like to have the same property at the next stage, i.e. H which is prime and irredundant. ! IDEA: Make all the cubes in H prime: pick one cube of H at a time and make it as large as possible, provided that it does not contain vertex not in H.Then remove redundant covers. ! HERE: H0 and H1 are prime and irredundant and in a form of Shannon expansion, so to enlarge a cube, one has to change a 0 or a 1 in the input cube to 2, or change 3 in the output to 4. ! The only possibility is to change 1 or 0 to 2 at the j-th position. ! “Rising” cubes and checking redundancy is expensive. Fast heuristics are needed. 18 9 Unate complementation ! Proposition The complement of a unate cover F can be expressed as j F = x F + F x j x j (a) if F is monotone increasing in xj, or as (b) j j F = x F + F x x j Proof. If F is monotone increasing in xj, every cube of F has either ⊆ a 1 or a 2 in the j-th position. Hence F F j and F can be x j x written as = j + = j + F x F j F (x F )F j x x j x j x j F = x F x j + F x j 19 Computing a complement of a unate cover ! Compute x j F x j , this involves complementation of a reduced # of cubes (assuming F depended on xj ) | F |<| F | F and one less variable xj, since x j and x j contains a column of 2s in the j-th position.