3 - 2 - Lecture 2.2 Computational Boolean Algebra- Boolean Difference (15-51)

download 3 - 2 - Lecture 2.2 Computational Boolean Algebra- Boolean Difference (15-51)

of 8

Transcript of 3 - 2 - Lecture 2.2 Computational Boolean Algebra- Boolean Difference (15-51)

  • 7/29/2019 3 - 2 - Lecture 2.2 Computational Boolean Algebra- Boolean Difference (15-51)

    1/8

    [music] So, here we are in Lecture 2.2,Computational Boolean Algebra.What we did in the last lecture was weintroduced the Shannon cofactors and theShannon Expansion theorem.We showed how you can take a complicatedBoolean object apart into smaller, simplerpieces and manipulate it.What we want to start talking about now isthe fact that the cofactors are incrediblyuseful objects.And even when we're not rebuilding theoriginal Boolean equation, they take on aninteresting life of their own.And, in fact, important combinations ofthese cofactors have famous names andfamous uses in the chip design business.And so, we're going to start talking aboutthe first one of these, which is calledthe Boolean difference.So, here's our first question what elsecan you do with cofactors?So, for example, from a hardware sort of a

    view, suppose I've got 2 functions F andG, different functions of, say, variablesx1 to xn.And I make a new function, for example, Iinvert function F and I call that H, orI[UNKNOWN] the functions together or themor something.And it's, it's worth just, you know,reminding ourselves that you know, it'skind of a hardware thing, right?So, here's function F, and here's all theX's going in and, and here's function G,and you know, it really is.

    It's the same set of X's, you know, goinginto those things and here's F of X comingout and here's G of X coming out and whatI've really, really said here is, okay,I've gotta put them into an and gate andI'm going to make a new function H.Here's the new question I'd like to starttalking about.Can I tell anything about H's cofactors ifI know something about the cofactors of Fand G?So you know, good question, and the bottomis what is the positive X cofactor of H,

    which is the positive cofactor of this newfunction F and G, you know, what can we,what can we say about that?And the wonderful news is that pretty muchthe cofactors tell you everything you needto know and they also give you somewonderful practical tricks for calculatingstuff.So, for example suppose I take F and Icomplement it and then I would like to do

  • 7/29/2019 3 - 2 - Lecture 2.2 Computational Boolean Algebra- Boolean Difference (15-51)

    2/8

    the positive cofactor operation, you know,what is that?And it turns out that the other thing thatI could do is I could take X and I couldcofactor it first and then I could invertit, or depending on how you like to writethis, I take F and I cofactor it first,and then I compliment the whole thing,right?And in English, I'm writing it underneaththe cofactor of the compliment is thecompliment of the cofactor, right?So, it doesn't matter what order I do itin, I get to do it in whichever ordermakes the calculation easier.And similarly, for basically all binaryBoolean operators, it works like that.The cofactor of the AND is the AND of thecofactors, the cofactor of the OR is theOR of the cofactors.The cofactor of the exclusive OR, EXOR,right, that's this gate, remember is theEXOR of the cofactors.This is really very useful because this

    can often help in getting cofactors ofcomplex formulas and, in fact, we're goingto see that in, in this particular slidedeck.So now, let's consider some operations onthe cofactors, themselves.Suppose I have F of X and I told you aboutthe Shannon cofactor, which is one way ofutilizing them, what if I just take thepositive and negative cofactors and I juststart putting them together in differentways?What happens if I exclusive OR them?

    What happens if I AND them?What happens if I OR them?It turns out that all of those things areuseful.In fact, they are so useful, they allactually have names.Each of the 3 things above, has a famousname and it's a famous thing.So, let's go look at them and the firstone is we're going to look at this one.We're going to look at the exclusive OR.And surprisingly enough, I'm going to takeyou back to Calculus and derivatives,

    alright?So, remember way back when, whenever youlearned you know, introductory Calculusand basic derivatives and we said, okay,you have a function, y is f of x and wedefine the derivative as the slope of thecurve, right, was this thing right here.And the way we defined that was, we said,alright, look, we're going to take x andthen we're going to change x just a little

  • 7/29/2019 3 - 2 - Lecture 2.2 Computational Boolean Algebra- Boolean Difference (15-51)

    3/8

    bit by delta.And then, we're going to look and see howmuch the value of the function changesbetween f of x and f of x plus delta.And we're going to take the ratio of thosetwo things and we're going to let delta goto 0, and when we're done, we're going toget this really interesting mathematicalobject called the derivative.So, here's a, maybe an unusual questionfor you.Do Boolean functions have derivatives?And amazingly enough, yes.And they're useful.And they have a name.The trick is, how do you define them,alright?So, the basic idea for real valuedfunctions was that DFDX, the derivativetells you how F changes when X changes.And that's the thing to, to hang on to,conceptually.How does the output change when the inputchanges?

    For a 0,1 value Boolean function, wecannot change X by some small delta.The only thing you can do is you canchange it by, you know, 0 to 1 or 1 to 0,but you can still ask, ask how X changes.And it turns out there's actually a verynice definition for, for something like aBoolean derivative it looks like this.We take the positive cofactor and weexclusive OR it with the negativecofactor.And that's, the, the, the definition ofthis interesting kind of a derivative.

    The way you can think about that is thatit compares the value of F when X is zero,against the value of X when it's 1.And this mathematical object is a 1, justif these 2 things are different.And the, the one thing that I'll remindyou of again, alright, is that theexclusive OR operation, the thing we are,we're drawing like that if we say aexclusive OR b, right, that's equal to a bbar plus a bar b, right?And this thing is equal to 1, if and onlyif a is not equal to b, right?

    So, this object down here is a 1 just ifthese 2 things are different.Now, we seen those pieces before, right?You know, the derivative is just theexclusive OR of the Shannon cofactors, thepositive and the negative cofactors.But I will note that it's not writtenDFDX.It's written del F del X.That's just a historical thing.

  • 7/29/2019 3 - 2 - Lecture 2.2 Computational Boolean Algebra- Boolean Difference (15-51)

    4/8

    And it's got a slightly different namesince it's not a derivative in thecontinuous value sense.It's called the Boolean difference, justto be sort of clear about that.And the thing that's interesting is thatit kind of behaves like Calculus, so, youknow, for example you can do derivativesdifferences with, with respect to morethan one variable.You can do del f, del x, and then del y.And it doesn't matter if you do x first ory first.The order doesn't matter.That's, that's just like Calculus.And the derivative of the EXOR is the EXORof the derivatives.That's interesting.That's kind of like addition, right, inregular Calculus, so that's interesting.And if the function f is actually aconstant, which means it's always 1 oralways 0, then its Boolean difference is 0all the time and that, that's also like

    Calculus which is, you know, kind ofinteresting.And one of the reasons why people findthis you know, this stuff interesting andwhy we use this notation.Now, it would be great if this stuffactually behaved like Calculus but itdoesn't.And so, here's some scary stuff.If you take the derivatives of the AND off and g or the OR of f and g, it doesn'twork the same.You get these really very complicated,

    complicated, complicated Booleanexpressions.And the reason is that AND, and OR,despite the fact that we like to kind ofwrite them like multiplication and writethem like addition, they do not alwaysbehave like real numbers and so, you know,ultimately, it comes back and somethingdifferent happens.Here's a little interesting example thatI'm going to walk you through to try togive you some sense of what the Booleandifference actually does.

    So, let's just calculate the Booleandifference del f del x for all four ofthese very trivial gates.And we're going to see an interestingpattern, right?So, here's a function which is just f is xbar.And so, remember, the, the Boolean do, youknow, the Boolean difference here is fxexclusive ORed fx bar, alright?

  • 7/29/2019 3 - 2 - Lecture 2.2 Computational Boolean Algebra- Boolean Difference (15-51)

    5/8

    So, what's fx here?Well, we take x and we make it a 1, and sowe're going to get a 0 and if we take fxbar, right, we take a 1.We're going to get is a 1, right?And so the derivative with respect to x isgoing to be 0 exclusive OR 1, which isjust one and it's not at all clear,there's a pattern yet, but there is.We have to do a little more work.So, here is f is xy, it's a simple ANDgate, right?F of x, the positive cofactor, is 1 and y,so that's just a y.And f of x bar, the negative cofactor, wetake x and make it a 0, and you just get a0, right?So, the derivative, the difference of delf del f is y exclusive OR 0 and that'sjust y.And so, let me ask you a, a kind of aquestion there.Supposed that I do whatever it takes tomake this Boolean derivative, this Boolean

    difference equal to a 1, alright, so then,that, what that would mean is that I'dhave to put a 1 on that input.Oh, here's something interesting thathappens.If you make this input a 1, any time youmake a change on x, I guarantee you, itwill make a change on the output.This is actually the pattern we're goingto, we're going to discover if you makethe Boolean difference a 1, it guaranteesfor those values of, of other inputs thatif you wiggle x, f will change.

    So, let's try that again with an OR gate,convince ourselves that that's thepattern, x plus y, x plus y.F of x is going to be 1 plus y, which isgoing to be 1.F of x bar is 0 plus y and so, it's goingto be y and so the difference del f del xis going to be 1 exclusive ORr y and ifyou do the Boolean Algebra on that one,you'll discover that that's just y bar andI sort of said this same thing.What does it take to make this thing a 1?What it takes to make this thing a 1 is

    that you make y a 0, alright?That's what it takes to make the Booleanderivative a 1.So, if you make this thing as 0, oh, look,if you change, if you put a 0 on the otherOR gate, any time you change x, Iguarantee, you'll change f.That's cool.So, evaluate the Boolean difference,figure out how to make it a 1.

  • 7/29/2019 3 - 2 - Lecture 2.2 Computational Boolean Algebra- Boolean Difference (15-51)

    6/8

    If you put that pattern of inputs on thegate when you change x, f will change,alright?What about an exclusive OR?So, this is x exclusive OR y, del f del,I'm sorry, f of x is equal to 1 exclusiveOR y.So, that's y bar.F of x bar is equal to 0 exclusive OR y,so that's y.Del F, del x is equal to y exclusive OR ybar do th Boolean Algebra, and youdiscover that's a 1.That's that makes sense.What does it take to make that Booleanderivative a 1?And the answer is, everything makes it a1, either you can't not make it a 1.And so, that means it does not matter whatvalue you put on a y.If you put a wiggle on a x, if you changex, the output will always, always, alwayschange.And now, if we go back to the inverter, we

    can see the pattern.X will always change the output no matterwhat you do, x will always change theoutput, that's why the Boolean differenceevaluates to a 1.And for all of these others, the meaningis that when del f del f is 1, then fchanges if x changes.And that's a, a wonderful thing becausewith just some math, we were able to dosome sensitivity studies on a, on aninteresting piece of logic.So you know, we could sort of expand that

    to a, you know, a much bigger thing.Here's a big blob of logic, right?And I'm trying to ask the question whendoes an input change on x turn into aninput, turn, turn into an output change?And the answer is that, what I should godo, is I should go evaluate del f del x,and I should figure out what values ofthese variables here make it a 1.And if I can put those values of thevariables on all of those other inputs, ifI can make del f del fx which, recall, isa function of everything up at the top but

    not x, if I can make this function a 1,okay, then I garuantee that if I put thatpattern on the input, right, the outputwill change.That's very useful thing.Here's just another um,you know, littlekind of an example.So, here's a one bit adder, very simplelittle object.It's got a sum and it's got a carry we're

  • 7/29/2019 3 - 2 - Lecture 2.2 Computational Boolean Algebra- Boolean Difference (15-51)

    7/8

    basically going, right now we're goinglook at just the, just the carry out.So, the carry out is ab, the two bitsbeing added plus a plus b Cin.So, a simple equation.What's the Boolean difference of the carryout with respect to the carry in?Or, or kind of in English, when does thechange in the carry in make a change inthe carry out?Okay, well, we can go do the math.The notation is a little, a little weird.Carry out sub carry in, right, is what youget when you take the carry in and make ita 1.So, if you look at the equation, I get abplus a plus b, okay?And that's just a plus b, alright?And then I do carry out sub carry in barand that's what happens when I make thecarry in as 0 and obviously, I'm justgoing to get ab because the second term isjust going to drop out, okay?And if i want to do the carry out with

    respect to the carry in, del carry in I'mgoing to get a plus b exclusive OR ab,alright?And so that's a plus b, bar ab plus a plusb ab bar.The Boolean Algebra is a little tedious.I'll just kind of let you do it.It turns out you get a exclusive OR b,which makes total sense, alright?What does it take to make the Booleandifference of the carry out with respectto the carry in 1?A has to be different than b, right?

    If a is not equal to b, right, then, ifyou change the carry in, you will changethe carry out.That makes sense because, you know, if ais equal to b and they both are 0, I don'tcare what you do with the carry in, youare not going to make a carry out.You just can't do it.And, you know, if a and b are both 1, theymake a carry out all by itself, and againI don't care what you do with the carryin, it doesn't matter.But if a and b are not the same, then I

    guarantee you a change in the carry inwill change the carry out.So arithmetically, this all makes sense,but the thing that's really nice and veryelegant about this is that I can do all ofthis entirely in the Boolean domain.So, a couple of quick things to rememberabout the Boolean difference.It's not like the physical interpretationof Calculus derivative, there's no slope

  • 7/29/2019 3 - 2 - Lecture 2.2 Computational Boolean Algebra- Boolean Difference (15-51)

    8/8

    of the curve stuff, but it explains how aninput change can cause, can cause anoutput change for a Boolean function.The Boolean difference, del f del x, is aBoolean function, but it does not dependon x.That's a big one.And if I don't tell you that 5 more times,you'll forget it.Because, you know, in Calculus land, whenyou differentiated something with respectto x, the x did not always go away, but inBoolean land it does.Look, it can't have an x in it.It's made out of cofactors and cofactorsdon't have x's in them, they got replacedby constants.And this is really surprisingly useful.We're going to see this in a bunch oflater places.