 In today's lecture we will be discussing Boolean functions we have already discussed in previous lectures Boolean algebras but still to start with I will recall the definition of a Boolean algebra we know that a Boolean algebra is a lattice which is complemented distributive having at least two elements and also having a least element and the greatest element apart from that it has three basic operations one called disjunction or or or plus and the other being the conjunction the and or product and the complementation operation now the probably this simplest Boolean algebra consists of the set 0 1 with the operations defined as this one which is the or disjunction or simply we may call it plus and then another operation which is called and or conjunction which is denoted usually by a simply a dot or by juxtaposition of two elements which is defined as this and complementation which is simply this usually denoted by a prime and 0 prime is 1 and 1 prime is 0 sometimes it is also called not now as we have seen before that a Boolean function this Boolean algebra consisting of only 0 1 can be extended to b to the power n which is the Cartesian product of n copies of b the operations disjunction conjunction and complementation or or and not are defined as this or or plus consider two elements x bar and y bar inside bn therefore x bar x bar is of this type x 1 x 2 dot dot dot xn belonging to bn and y bar is y 1 y 2 dot dot dot yn belonging to bn x bar plus y bar is x 1 plus y 1, and so on up to xn plus yn now this plus operation is same as the plus operation that we have defined before over b similarly I can define and or just the dot as x bar and y bar equal to x 1 dot y 1 and so on up to xn yn not that is the complementation denoted by the simple symbol prime is x bar prime equal to x 1 up to xn prime which is again x 1 prime dot dot dot xn prime it is fairly easy to check that bn along with the operations just defined which are induced from the operations defined on b is a Boolean algebra for any positive integer value of n. So if we are very strict about that then we can write the Boolean algebraic system involving bn as bn then this plus the dot the prime and of course the least element which is the all 0 vector having n terms and the greatest element which is the all 1 vector having n terms combining all these things we have the Boolean algebra bn in the beginning it seems that this is a very restricted class of Boolean algebras but we can show that any finite Boolean algebra is essentially same as bn we are not going into a theoretical proof of that or a theoretical definition of what is called isomorphism of Boolean algebras. But we shall write the statement over here that any finite Boolean algebra is essentially same as bn for some positive integer value n we want to define functions over Boolean algebras the first type of functions that we define and which are called Boolean functions are functions from bn to b a function from bn to b is said to be Boolean function that is what we are going to study today now let us start with examples of Boolean functions to start with Boolean functions are very simple. So let us consider possibly one of the most simple examples of Boolean functions here we consider n to be equal to 2 then we can enumerate very easily all the points of bn that is b2 those are 0 0 0 1 1 0 and 1 1 we can list them in a table and since we are interested in a function from b2 to b we can write a rightmost column in the table some values from b so it can be just 1 0 1 0. So suppose this column I am designating by the function f which is essentially the function that we are defining from b2 to b we can say that this function takes the value 1 when the input is 0 0 it takes the value 0 when the input is 0 1 it takes the value 1 when the input is 1 0 and it takes the value 0 when the input is 1 1 at this point we define something else we define what we call a Boolean variable so a symbol x is called a Boolean variable if it can take the values 0 or 1 so we are essentially defining variables what they said b a symbol x is said to be a Boolean variable if x can take values from b which is essentially the set containing 0 and 1 now we look again at the table that we have already discussed in the context of the function f the each coordinate point of b2 can be assigned to a Boolean variable so we write the same table like this we assign the Boolean variable x1 to the leftmost coordinate and x2 to the rightmost coordinate so we get the values like this 0 0 0 1 1 0 and 1 1 and now the function f can be thought of as a function on x1 and x2 and its values are 0 1 1 0 a table like this for a Boolean function is said to be its truth table it is of course obvious that if we have a function from b to the power n to b for any positive integer value of n then we will be able to write the truth table of that function at this point it is worthwhile to check the ordering in which we write the values of the vectors of bn so we look at b3 suppose x1 x2 x3 are the Boolean variable corresponding to the coordinates in b3 then we will write the values in this order first we will write the all 0 vector then we will write 0 0 1 then we will write 0 1 0 and lastly we will write 0 1 1 and then we will write 1 0 0 then 1 0 1 then 1 1 0 1 1 1 in what follows we will always write the table in this order this has a very useful connection to decimal numbers what we can do is that we can say that each of these vectors or strings or elements can be related to a number which is given by x1 plus 2 times x2 plus 2 square times x3 now let us evaluate each and every point when it is 0 then of course the result is 0 when it is only 1 the result is 1 but when it is 0 1 0 then it is 2 when it is 0 1 1 now let us check when x3 is 0 so that is 2 square into 0 then x2 is 1 that is 2 x1 plus x1 is 1 that is 1 so this gives me 3 this is 3 the next one is 2 square into 1 plus 2 into 0 plus 0 which is equal to 4 continuing in this way we will see that the rest of the elements correspond to the decimal numbers 5 6 and 7 so this is something that we will be calling a decimal code now of course we can extend this and go to a situation when there are n Boolean variables so bn is typically the set consisting of x1 and so on up to xn where xi belongs to b for all i belonging to 1 2 so on up to n now we will be writing the elements of bn in the order which is exactly the extension of what we have seen before so the first one will be all 0 so the decimal coding will be 0 then it will be all 0 and 1 so the decimal coding will be 1 then it will be all 0 and 1 0 so the decimal code will be 2 and then all 0 and 1 1 so the decimal code will be 3 it will go on in this way and eventually we will have the pattern which consists of only all 1 and this is in decimal code it will be 2 to the power n-1 and if we see carefully this will give us all the positive integers from 0 1 2 2 to the power n-1 we will be using this ordering always in this in these lectures and otherwise also in the theory of Boolean functions and Boolean algebra this ordering is predominantly used now what we realize coming to this point is that we can talk about something called Boolean expressions a Boolean expression is any formula that we can build up by using Boolean variables plus dot and complement that is a Boolean variables or and and complement or conjunction disjunction and complementation so for example we can suppose we fix the number of Boolean variables to be 3 so we are considering here x 1 x 2 and x 3 only we can build up any expression let us call one expression like this as g x 1 x 2 x 3 which is equal to possibly x 1 x 2 complement plus x 3 well plus x 2 now what we can do is that we can put as inputs the values of x 1 x 2 x 3 from the Boolean algebra b 3 and see what happens let us try that now so I write x 1 then x 2 and x 3 I put 0 0 0 then the next entry is 0 0 1 the next is 0 1 0 the fourth one is 0 1 1 fifth one is 1 0 0 and 1 0 1 then 1 1 0 and then 1 1 1 so I have got all the 8 entries over here and I will put the inputs in G according to that the first one is 0 0 0 0 0 so here x 1 is 0 x 2 is 0 complement so 1 plus x 3 is 0 and x 2 is 0 so it is 0 so I will write it over here so I am designating the right hand column as the function g then let us consider g of now x 1 is 1 rest are 0s now x 1 is 1 and see here x 2 is 0 so 0 complement is 1 therefore I have 1 over here plus x 3 is 0 and x 2 is 0 now this gives me 1 so I write 1 over here in the third one is 0 1 0 here x 1 is 0 then x 2 complement is also 0 then x 3 is 0 and x 2 in this case x 2 is 1 therefore again I will get 1 so I write 1 over here now we come to the fourth one that is 0 1 1 remember that we are starting from this way onwards x 1 is 0 x 2 is 1 complement so it is 0 then x 3 is 1 then x 2 is 1 so I again get 1 I write 1 over here then I have 1 0 0 so x 1 remembering that I am x 1 to x 3 is in this direction so x 1 is 1 x 2 is 0 complement so it is 1 then x 3 and x 2 both are 0 so I get 1 I write over here then see g 1 0 1 so it is x 1 is 1 x 2 complement is 1 then x 3 is 1 x 2 is 0 this also is 1 and then g 1 1 0 is x 1 is 1 x 2 complement is 0 then x 3 is 0 then x 2 is 1 this is again 1 and g 1 1 1 we get x 1 is 1 x 2 complement is 0 x 3 is 1 and x 2 is 1 so again I have got 1 so I get a pattern like the one I have got in the right hand side but this is a truth table of a Boolean function therefore what we have seen is that if we have a Boolean expression then we have a Boolean function if we have a Boolean expression consisting of n Boolean variables then it corresponds to Boolean function from bn to b and of course this function is unique so we see that a Boolean expression corresponds to a Boolean function now the question is the other way round if we have a Boolean function can we construct a Boolean expression the answer is yes and we will see an example how it works so we now consider our small Boolean algebra b2 so not bn but just b2 and we write down an arbitrary truth table involving b2 suppose x1 is again the less most variable and x2 is the next variable so the input values are 0 0 0 1 1 0 and 1 1 and let us consider the function 0 1 0 1 let us call it f our goal is to find out a Boolean expression corresponding to this function so I write here our goal is to find out a Boolean expression corresponding to f what we do here is a very standard trick we extend the table a little bit here again I have got x1 and x2 I write the input values and this is my function f so this is 0 1 0 1 I write some so called sub functions maybe yeah so these are f1 and f2 so what I have done over here is that for each one in the truth table of the function f I have constructed a function so for this one I have a function f1 for the next one I have a function f2 and if we take f1 plus f2 then we will see that we will arrive at the function f because f1 plus f2 the first row is 0 the second one is 1 then 0 and then 1 it is of course clear to us that f is equal to f1 plus f2 now the question is that can we find out an expression for f1 and f2 if we can do that then we have a an expression for f to do that we concentrate on the function f1 we see that f1 is a function which is 1 at only this input point and otherwise it is 0 the question is that how can we do that and a simple observation shows that f1 is nothing but x1 and x2 complement what I am doing over here is that I am checking the point at which f1 is 1 at that point I am checking the corresponding Boolean variables we see that corresponding to x1 the component value is 1 therefore x1 is kept as it is I see that corresponding to x0 the component value is 0 therefore I take x2 complement now if I give the input 0 1 to this function say f1 I put x1 equal to 0 I am sorry I put here x1 equal to 1 so I have got x1 equal to 1 and x2 equal to 0 this gives me 1.0 complement that is 1.1 this is equal to 1 so at least I know that this expression that I have written this expression evaluates to 1 at the point x1 equal to 1 and x2 equal to 0 now if we scan all the other points we will see that this pattern will never match therefore in other places either x1 will be 0 in that case f1 will be 0 or x2 will be 1 in that case x2 complement will be 0 for example if I evaluate the same function f1 at let us say x1 equal to 0 and x2 equal to 1 this will evaluate to 0.1 complement which is 0.0 which gives me 0 we can check that this is going to happen in all the other input points now so what is the rule of getting these functions these functions which we may call component functions of f or at this point or whatever these functions are one only in one input points and 0 in all the other input points so check that pattern and wherever the Boolean variable corresponding Boolean variable values are 1 keep the variables intact corresponding to the other entries just take the complement of those variables take the product of them and get a essentially a product term of some Boolean variables and their complements now in the same way we can get the expression for f2 which is f2 x1 x2 now please see that f2 is 1 only at the input point 1 1 and so all the Boolean variables are 1 over here so I will simply write this is x1 x2 and as we have seen if we take or or plus of these two columns we get back our function f so we can write f1 x1 x2 equal to x1 x2 complement x1 plus x1 x2 we do not write the one here because this is the whole function f so we see that f is x1 x2 complement plus x1 x2 we can evaluate this function here and check that it is indeed so so let us take the first point when both are 0's then x1 equal to 0 x2 equal to 1 and x1 0 so I get 0 then when x1 equal to 1 and x2 equal to 0 then this is 1 and this is 1 so I get 1 over here when x2 equal to 1 and x1 equal to 0 then this is evaluated to 0 and this is also evaluated to 0 so I get 0 over here and when both are 1 then this is 1 therefore I will get 1 over here so we see that the expression that we have got matches with the Boolean function this example more or less convinces us that we can get a Boolean expression for any Boolean function on any number of variables the basic rule is same just decompose the function into functions having one at only one place and correspondingly write the product terms and add them up at the end here what we see is that we are getting the Boolean expression in the form which can be expressed as sum of products indeed we sometimes call these these expressions as sum of products we also see a salient point over here that is each product term contains all the variables so we come to a definition which is called mean term a product term which contains each variable in their complemented or uncomplimented form is called a mean term similarly we define something called max terms which we will be discussing shortly so I will define them in the same go a max term is a sum term which contains each variable in their complemented uncomplimented form is called a max term what we have seen just now is that the function f x1 x2 is x1 x2 complement plus x1 x2 here the salient point of this expression is that this is to salient point of this expression is that it is sum of mean terms this function f is from b2 to b so only two variables are involved and among these two variables both the variables are involved in all the product terms whose sums we are taking so these are mean terms and we are summing the mean terms to get the expression of the function and if such is the case then this expression is called a conjunctive normal form I am sorry a disjunctive normal form so this is called a disjunctive normal form or in terms DNF I repeat again if a Boolean expression is written as sum of mean terms then it is said to be a disjunctive normal form of the corresponding Boolean function now we will soon see that we can write a function as product of some terms that is product of max terms in particular and that will be called conjunctive normal form or CNF to do that we will take up again the same function that we have discussed just before and try to find its conjunctive normal form or in other words try to write a Boolean expression which is product of max terms so we look at the truth table again and we have 0 1 0 1 0 1 0 1 now what we do is that we now try to locate the zeros so we have now a function g 1 which is 0 in the first place and 1 in all the other places and a function g 2 which is 0 in the third place and 1 in all the other places we will show that g 1 and g 2 can be written as sum of the Boolean variables which are involved in this Boolean algebra and if we take the product of g 1 and g 2 that is and of g 1 and g 2 then we will get 0 1 0 and 1 which is nothing but our original function f now the question is how to get that so our rule is as follows we have g 1 we write x 1 x 2 we want it to be 0 when the input is 0 0 in order to do that I will just write x 1 plus x 2 because this expression is 0 when both x 1 x 2 are 0 but if anything else happens and it is not 0 and it is in fact 1 similarly we concentrate on this input vector which is gives me value this so it is g 2 x 1 x 2 and this g 2 x 1 x 2 is going to be 0 if I put well as x 1 intact because anyway x 1 value is 0 over here and instead of x 2 I put x 2 complement please check that these two are the functions that we need and the rule is very clear that we have only in one input value that we have to consider check each component if the component value is 0 just write the corresponding Boolean variable in the sum if it is 1 write its complement if you do that you will get exactly the function you need and then f x 1 x 2 is g 1 x 1 x 2 dot g 2 x 1 x 2 that is equal to x 1 plus x 2 dot x 1 plus x 2 complement and this is what is called the conjunctive normal form of the function f conjunctive in saw in short CNF of the Boolean function thus we have seen two very important normal forms of Boolean functions now we will move on to another useful form which is of course very difficult to write when the function is large but when the function is not on a very large space we can write that and this relates to the decimal codes that we have discussed before we will check this way of representation by an example so we have an example on a function from v3 to be let me write down all the all the points of b3 along with the decimal coding now we write the variables as x 1 x 2 and x 3 as before so I write 0 0 0 0 0 0 1 0 1 0 0 0 1 1 1 0 0 1 0 1 0 1 1 1 1 0 and 1 1 1 and now I write the decimal code which is 0 1 2 3 4 5 6 and 7 and suppose my Boolean function f is something like this 0 1 0 1 1 1 0 0 what I can do is that I can simply write this function with a summation notation and put within bracket all the points at which the function is 1 so it is 1 at 1 so I write 1 over here and then it is 1 at 3 so I write 3 over here 1 at 4 I write 4 over here 1 at 5 I write 5 over here of course this representation may not be convenient if the Boolean function is on a large number of variables but for a small number of variables it is going to be convenient and a very common problem is to write the CNF or the DNF of a function which is given in this way and this is what I would like to propose as an exercise to you so in this lecture we have discussed one Boolean functions truth table then we have discussed Boolean variables and Boolean expressions we have discussed decimal coding and representation of Boolean functions and finally the most important fact of Boolean functions is DNF and CNF that is disjunctive normal forms and conjunctive normal forms and their interrelations this is for today thank you