0% found this document useful (0 votes)
9 views10 pages

Boolean Operators & Functions Guide

The document discusses Boolean algebra and presents examples of: 1) Representing Boolean functions using basic operators like AND, OR, and NOT. True and false values are shown for different combinations. 2) Converting between disjunctive normal form and conjunctive normal form for Boolean expressions. Duals of expressions are also calculated. 3) Representing circuit diagrams with gates as Boolean expressions using the basic operators. Circuits with multiple gates are converted into single Boolean expressions.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views10 pages

Boolean Operators & Functions Guide

The document discusses Boolean algebra and presents examples of: 1) Representing Boolean functions using basic operators like AND, OR, and NOT. True and false values are shown for different combinations. 2) Converting between disjunctive normal form and conjunctive normal form for Boolean expressions. Duals of expressions are also calculated. 3) Representing circuit diagrams with gates as Boolean expressions using the basic operators. Circuits with multiple gates are converted into single Boolean expressions.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PRACTICAL - 6

basic operators && (AND), || (OR), ! (NOT)

In[1]:= True || false


Out[1]= True

In[2]:= True || True


Out[2]= True

In[4]:= False || True


Out[4]= True

In[5]:= False || False


Out[5]= False

In[6]:= True && True


Out[6]= True

In[7]:= True && False


Out[7]= False

In[8]:= False && True


Out[8]= False

In[9]:= False && False


Out[9]= False

In[10]:= ! True
Out[10]=
False

In[11]:= ! False
Out[11]=
True

In[12]:= ! True && False


Out[12]=

False

In[13]:= ! True || False


Out[13]=

False
2

In[14]:= True && ! True


Out[14]=

False

In[15]:= True ∧ False


Out[15]=

False

In[16]:= True ∨ False


Out[16]=

True

In[17]:= ¬ True
Out[17]=

False

REPRESENTING BOOLEAN FUNCTIONS

1. f (x, y, z) = xy + yz + zx

In[18]:= f[x_ , y _, z_] := (x ∧ y) ∨ (y ∧ z) ∨ (z ∧ x);

In[19]:= f[p, q, r]
Out[19]=

(p && q) || (q && r) || (r && p)

In[20]:= f[True, False, True]


Out[20]=

True

In[21]:= f[True, q, r]
Out[21]=

q || (q && r) || r

In[22]:= f[True, q, r] // Simplify


Out[22]=

q || r

2. g (x, y) = ! (! x + y) x + ! ! ! y + xy + x ! y

In[23]:= g[x_ , y _] := ! ((! (x ∨ y) ∧ x) ∨ ! ! ! y) ∨ (x ∧ y) ∨ (x ∧ ! y)


3

In[24]:= g[False, False]


Out[24]=

False

In[25]:= g[False, True]


Out[25]=

True

In[26]:= gTrue, False


Out[26]=
True

In[27]:= g[True, True]


Out[27]=
True

3. h (x, y, z) = x (! (y + z)) + (xy + ! z) x

In[28]:= h[x_ , y _, z_] := (x ∧ (! (y ∨ z))) ∨ ((x ∧ y) ∨ ! z) ∧ x;

In[29]:= h[0, 0, 0] // Simplify


Out[29]=

False

In[30]:= h[1, 0, 0] // Simplify


Out[30]=
True

In[31]:= h[0, 1, 0] // Simplify


Out[31]=
False

In[32]:= h[0, 0, 1] // Simplify


Out[32]=
False

In[33]:= h[1, 1, 0] // Simplify


Out[33]=

True

In[34]:= h[1, 0, 1] // Simplify


Out[34]=

False
4

In[35]:= h[1, 1, 1] // Simplify


Out[35]=

True

TABLE FORM
1. FOR BOOLEAN POLYNOMIAL FUNCTION f :

In[37]:= BooleanTable[{p, q, r, f[p, q, r]}, {p, q, r}] // TableForm


Out[37]//TableForm=
True True True True
True True False True
True False True True
True False False False
False True True True
False True False False
False False True False
False False False False

In[38]:= Boole[BooleanTable[{p, q, r, f[p, q, r]}, {p, q, r}]] // TableForm


Out[38]//TableForm=
1 1 1 1
1 1 0 1
1 0 1 1
1 0 0 0
0 1 1 1
0 1 0 0
0 0 1 0
0 0 0 0

In[39]:= TableForm[Boole[BooleanTable[{p, q, r, f[p, q, r]}, {p, q, r}]],


TableHeadings → {None, {p, q, r, f}}]
Out[39]//TableForm=
p q r f
1 1 1 1
1 1 0 1
1 0 1 1
1 0 0 0
0 1 1 1
0 1 0 0
0 0 1 0
0 0 0 0

2. FOR BOOLEAN POLYNOMIAL FUNCTION g :


5

In[40]:= TableForm[Boole[BooleanTable[{p, q, g[p, q]}, {p, q}]],


TableHeadings → {None, {p, q, g}}]
Out[40]//TableForm=
p q g
1 1 1
1 0 1
0 1 1
0 0 0

3. FOR BOOLEAN POLYNOMIAL FUNCTION h :


In[41]:= TableForm[Boole[BooleanTable[{p, q, r, h[p, q, r]}, {p, q, r}]],
TableHeadings → {None, {p, q, r, h}}]
Out[41]//TableForm=
p q r h
1 1 1 1
1 1 0 1
1 0 1 0
1 0 0 1
0 1 1 0
0 1 0 0
0 0 1 0
0 0 0 0

PRACTICAL - 7
1. DUAL OF A GIVEN BOOLEAN POLYNOMIAL / EXPRESSION.
In[1]:= dual[expr_] := expr /. {And → Or, Or → And, False → True, True → False}

In[2]:= dual1 = dual[(x && ! y) || (y && ! z) || (! x && z)]


Out[2]= (x || ! y) && (y || ! z) && (! x || z)

In[3]:= dual2 = dual[(! x && y) || (! y && z) || (x && ! z)]


Out[3]= (! x || y) && (! y || z) && (x || ! z)

2. WHETHER OR NOT TWO BOOLEAN


POLYNOMIALS ARE EQUIVALENT.
In[4]:= distributiveL = x && (y || z);
distributiveR = (x && y) || (x && z);
6

In[6]:= TautologyQ[Equivalent[distributiveL, distributiveL, distributiveR], x, y, z]


Out[6]= True

In[7]:= TautologyQ[Equivalent[x || (x && y), y], {x, y}]


Out[7]= False

In[8]:= f1[x_ , y _] := ! (x && y);

f2[x_ , y _] := ! x || ! y;

In[10]:= TautologyQ[Equivalent[f1[x, y], f2[x, y]], {x, y}]


Out[10]=

True

3. DISJUNCTIVE NORMAL
FORM CONJUNCTIVE NORMAL FORM
FROM A GIVEN BOOLEAN EXPRESSION.
In[11]:= example3 = (x || y) && ! z
Out[11]=

(x || y) && ! z

In[12]:= BooleanConvert[example3, "DNF"]


Out[12]=

(x && ! z) || (y && ! z)

In[13]:= BooleanConvert[example3]
Out[13]=

(x && ! z) || (y && ! z)

In[14]:= BooleanConvert[example3, "CNF"]


Out[14]=

(x || y) && ! z

4. DISJUNCTIVE NORMAL FORM


CONJUNCTIVE NORMAL FORM WHEN THE GIVEN BOOLEAN

FUNCTION IS EXPRESSED BY A TABLE OF VALUES.


7

In[15]:= BFexample = BooleanFunction[{{1, 1, 1} → 0, {1, 1, 0} → 1, {1, 0, 1} → 0,


{1, 0, 0} → 1, {0, 1, 1} → 0, {0, 1, 0} → 0, {0, 0, 1} → 1, {0, 0, 0} → 0}]
Out[15]=

Number of variables: 3
BooleanFunction 
Function index: 82

In[16]:= BFexample[True, False, True]


Out[16]=
False

In[29]:= BooleanFunction[{{1, 1, 1} → 0, {1, 1, 0} → 1, {1, 0, 1} → 0,


{1, 0, 0} → 1, {0, 1, 1} → 0, {0, 1, 0} → 1, {0, 0, 1} → 1, {0, 0, 0} → 0}, {x, y, z}]
Out[29]=

(x && ! z) || (! x && ! y && z) || (y && ! z)

In[30]:= BooleanFunction[{{1, 1, 1} → 0, {1, 1, 0} → 1, {1, 0, 1} → 0, {1, 0, 0} → 1,


{0, 1, 1} → 0, {0, 1, 0} → 1, {0, 0, 1} → 1, {0, 0, 0} → 0}, {x, y, z}, "CNF"]
Out[30]=

(! x || ! z) && (x || y || z) && (! y || ! z)

In[19]:= BooleanTable[{x, y}, {x, y}] // TableForm


Out[19]//TableForm=
True True
True False
False True
False False

In[28]:= BooleanFunction[{0, 1, 0, 1, 0, 1, 1, 0}, {x, y, z}]


Out[28]=
(x && ! z) || (! x && ! y && z) || (y && ! z)

PRACTICAL - 8
8

Representing a given circuit diagram


expressed using gates in the form of boolean expression :

1.

In[1]:= G4 = ¬ a;

In[2]:= G5 = ¬ c;

In[3]:= G3 = G4 ∧ G5 ∧ c;

In[4]:= G2 = a ∧ b;

In[5]:= G1 = G2 ∨ G3;

In[6]:= G1
Out[6]= (a && b) || (! a && ! c && c)

In[8]:= G2 = A ∧ B ∧ C;

In[9]:= G4 = ¬ C;

In[10]:= G3 = A ∧ B ∧ G4;

In[11]:= G5 = ¬ A;
9

In[12]:= G6 = ¬ C;

In[13]:= G7 = G5 ∧ B ∧ G6;

In[14]:= G1 = G2 ∨ G3 ∨ G7;

In[15]:= G1
Out[15]=

(A && B && C) || (A && B && ! C) || (! A && B && ! C)

In[27]:= G1 = ¬ x;

In[28]:= G2 = G1 ∧ x;

In[29]:= G3 = ¬ G2;

In[50]:= G4 = G3 ∨ G3;

In[40]:= G5 = ¬ w;

In[41]:= G6 = y ∧ G5;

In[42]:= G7 = y ∧ w;

In[43]:= G8 = ¬ z;

G9 = G7 ∨ G8;

In[35]:= G10 = G6 ∨ G9;

In[45]:= G11 = G4 ∨ G10;

In[46]:= G11
Out[46]=

! (! x && x) || ! (! x && x) || (y && ! w) || (y && w) || ! z


10

PRACTICAL - 9

In[47]:= BooleanMinimize[(a ∧ b) ∨ (! a ∧ b ∧ ! c)]


Out[47]=

(a && b) || (b && ! c)

In[48]:= BooleanMinimize[(a ∧ b) ∨ (! a ∧ b ∧ ! c), "CNF"]


Out[48]=

(a || ! c) && b

In[49]:= Simplify[(a ∧ b) ∨ (! a ∧ b ∧ ! c)]


Out[49]=

(a || ! c) && b

Common questions

Powered by AI

Table forms are significant for representing boolean functions as they succinctly display the output results for all possible input combinations. This visualization aids in analyzing the function's behavior and verifying its correctness. For example, a boolean table can show truth values of 'f'(p, q, r) for various (p, q, r) combinations, such as (True, True, False) yielding True . It's a practical tool that provides a complete overview of how a function resolves.

Boolean tables are instrumental in simplifying boolean polynomial functions by providing a clear, structured overview of input-output correlations across all scenarios. They enable identification of simplifying patterns and redundancies. For example, a table representing function 'g(p, q)' illustrates patterns where simplifications like '(x && !z) || (!x && !y && z)' arise from table results, optimizing computation . Such utility in visualizing and analyzing results efficiently supports the reduction and practical implementation of functions.

Disjunctive Normal Form (DNF) is a standardized format where a boolean expression is a disjunction of conjunctions. It can be derived using the 'BooleanConvert' function, which transforms expressions into DNF. For example, '(x || y) && !z' is converted to '(x && !z) || (y && !z)' . Conjunctive Normal Form (CNF) is the conjunction of disjunctions and can be derived similarly; for the same expression, it remains '(x || y) && !z' when converted to CNF . These forms are used to simplify the evaluation and manipulation of boolean functions.

Logical operators determine the result of boolean expressions by combining or modifying boolean values. The AND operator (&&) returns true only if both operands are true. For example, 'True && True' evaluates to true, while 'True && False' evaluates to false . The OR operator (||) returns true if at least one operand is true, such as 'True || False' which evaluates to true . The NOT operator (!) inverts the boolean value of its operand; '!True' evaluates to false . These operators are foundational in constructing more complex boolean expressions and functions.

Boolean functions can be represented using logical gates in circuit diagrams, where each gate performs a fundamental operation like AND, OR, or NOT. For example, a circuit with gates 'G1' and 'G2' performing AND operations can be represented as '(a && b) || (!a && !c && c)' . Simplifying such circuits involves minimizing redundancy and combining gates to reduce complexity, such as using 'BooleanMinimize' to reduce '(a ∧b) ∨(! a ∧b ∧! c)' to '(a || !c) && b' . This process is crucial in designing efficient and smaller digital circuits.

Boolean function equivalence checks if two expressions yield identical output for all possible input combinations. Verification involves evaluating if their logical equivalence is a tautology, using `TautologyQ`. For instance, expressions 'f1(x, y) = !(x && y)' and 'f2(x, y) = !x || !y' are equivalent because '! (x && y) = !x || !y' is always true . This method is fundamental in determining the interchangeability of expressions in logical reasoning.

Transforming boolean expressions into their dual forms aids in logical reasoning by offering alternative perspectives and solving problems symmetrically. This transformation exchanges AND with OR and vice versa, alongside swapping truth values. For instance, the dual of '(x && !y) || (y && !z) || (!x && z)' is '(x || !y) && (y || !z) && (!x || z)' . Such transformations exemplify fundamental principles of duality in boolean logic, enhancing comprehension and flexible problem-solving.

The dual of a boolean polynomial is obtained by interchanging AND with OR and OR with AND, and swapping True and False values. For example, the dual of '(x && !y) || (y && !z) || (!x && z)' is '(x || !y) && (y || !z) && (!x || z)' . This transformation is crucial for understanding the symmetry and dual properties inherent in boolean algebra.

Simplification plays a critical role in making boolean functions computationally efficient by reducing complexity. This is achieved by minimizing terms and eliminating redundancies. Techniques like 'BooleanMinimize' and 'Simplify' reduce expressions such as '(a && b) ∨ (!a && b && !c)' to more efficient forms like '(a || !c) && b' . Efficient simplifications lower processing time and resource usage, essential for optimizing algorithms in various computer science applications.

Circuit diagrams use graphical symbols to depict boolean functions, mapping logical operations through gates for visual clarity. Gates like AND, OR, and NOT in circuits, e.g., '(a && b) || (! a && ! c && c)', functionally represent and compute expressions . These diagrams simplify understanding by presenting logical operations relationally, making comprehensive analyses and reasoning of complex operations accessible and intuitive, especially useful in educational and engineering contexts.

You might also like