15.08.2013 Views

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

tationally loaded). We just assume the contrary, i.e. that there is a minimal polynomial p that<br />

contains a non-prime-implicant monomial Mk, then we can decrease the cost of the of p while still<br />

inducing the given function f. So p was not minimal which shows the assertion.<br />

Prime Implicants and Costs<br />

Theorem 283 Given a Boolean function f = λx.F and a Boolean polynomial fp ≡ f with<br />

minimal cost, i.e., there is no other polynomial p ′ ≡ p such that C(p ′ ) < C(p). Then, p<br />

solely consists of prime implicants of f.<br />

Proof: The theorem obviously holds for f = λx.T.<br />

P.1 For other f, we have f ≡ fp where p := n<br />

i=1 Mi for some n ≥ 1 monomials Mi.<br />

P.2 Nos, suppose that Mi is not a prime implicant of f, i.e., M ′ ≻ f for some M ′ ⊂ Mk<br />

with k < i.<br />

P.3 Let us substitute Mk by M ′ : p ′ := k−1<br />

i=1 Mi + M ′ + n<br />

i=k+1 Mi<br />

P.4 We have C(M ′ ) < C(Mk) and thus C(p ′ ) < C(p) (def of sub-monomial)<br />

P.5 Furthermore Mk ≤ M ′ and hence that p ≤ p ′ by Lemma 281.<br />

P.6 In addition, M ′ ≤ p as M ′ ≻ f and f = p.<br />

P.7 similarly: Mi ≤ p for all Mi. Hence, p ′ ≤ p.<br />

P.8 So p ′ ≡ p and fp ≡ f. Therefore, p is not a minimal polynomial.<br />

c○: Michael Kohlhase 157<br />

This theorem directly suggests a simple generate-and-test algorithm to construct minimal polynomials.<br />

We will however improve on this using an idea by Quine and McCluskey. There are of<br />

course better algorithms nowadays, but this one serves as a nice example of how to get from a<br />

theoretical insight to a practical algorithm.<br />

The Quine/McCluskey Algorithm (Idea)<br />

Idea: use this theorem to search for minimal-cost polynomials<br />

Determine all prime implicants (sub-algorithm QMC 1)<br />

choose the minimal subset that covers f (sub-algorithm QMC 2)<br />

Idea: To obtain prime implicants,<br />

start with the DNF monomials (they are implicants by construction)<br />

find submonomials that are still implicants of f.<br />

Idea: Look at polynomials of the form p := mxi + m xi<br />

c○: Michael Kohlhase 158<br />

(note: p ≡ m)<br />

Armed with the knowledge that minimal polynomials must consist entirely of prime implicants,<br />

we can build a practical algorithm for computing minimal polynomials: In a first step we compute<br />

the set of prime implicants of a given function, and later we see whether we actually need all of<br />

them.<br />

For the first step we use an important observation: for a given monomial m, the polynomials<br />

m x + m x are equivalent, and in particular, we can obtain an equivalent polynomial by replace the<br />

latter (the partners) by the former (the resolvent). That gives the main idea behind the first part<br />

of the Quine-McCluskey algorithm. Given a Boolean function f, we start with a polynomial for f:<br />

83

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!