Menu
Log in

Computer Engineering Concepts

3.2 Logical Operators

Like mathematical operators which act on numbers to produce a numerical results, logical operators act on propositions to produce different logical results. Logical operators can act on a single proposition or on multiple propositions, just like mathematical operators that can act on a single number or on multiple numbers. There are many such logical operators, but the focus here will be on three commonly used operators, NOT, AND, and OR.


Negation - NOT

Negation can be thought of as the logical operator that creates the opposite logical result of a proposition. This idea is used in the English language with the word NOT. The function of negation or NOT can be summarized using the following definition.

Definition:   The NOT logical operator changes the truth values of propositions to its opposite. All true statements become false, and all false statements become true.     

Example I:        “It is warmer in the summer than in winter”                    T        1

                             “It is not warmer in the summer than in winter”             F       0

From this example it can be seen that the logical operator NOT changes the truth value of the proposition. As outlined in the definition in this case a true statement becomes false.

Example II:       6 + 3 < 5                             F            0

                              6 + 3 not< 5                      T            1

In this example it can be seen that a false statement becomes true with the use of the NOT operator.

From the above two examples it can be seen that the effect of using the NOT function is the same regardless of the proposition’s subject matter. The logical operator affects the truth value of the proposition and is independent of the subject matter. Winter and summer in example I and the numbers (6, 3, and 5) in example II have no impact on how the logical operator works. The results of the logical operators are not dependent on the subject of the proposition. Thus to simplify the study of logic, symbols can be used to express logical ideas without considering the subject matter. Therefore, a proposition can be represented using a letter, for example (p), instead of the whole statement. From our definition of a proposition as either true (1) or false (0), p can have values of 1 or 0. This idea can be represented in a table as shown below.


This method of representation is called a truth table.

Now that symbols can be used to represent the ideas, the analysis could be represented in symbolic form. The outcomes of Examples I and II could be represented by creating a table, and using symbols to represent the logic. Using truth tables, the logical operator NOT can be represented as shown below.

Table 3.1 The NOT logical operation.

This truth table shows the workings of the logical operator NOT. From the truth table it can be seen that the truth values are switched around. With the use of the NOT operator, the true (1) proposition (p) becomes false (0) and the false (0) proposition (p) becomes true (1). Truth tables are a quick and easy way of representing the function of logical operators.


Conjunction - AND

Unlike the negation operator which act on a single proposition, the conjunction operator (AND) joins two separate propositions together to form a single proposition.

Definition: The AND logical operator joins two different propositions together, and is true when both propositions are true. In all other cases it is false.         

Example I:        Determine if the statement “Today is Friday and it is raining outside” is a proposition.

Solution:          This statement is a proposition because the statement as a whole could be either true or false, but it is made up of two separate propositions that are joined together using AND. The first proposition is “Today is Friday”, and the second proposition is “It is raining outside”. The two propositions together with the logical operator AND form the complex proposition. The truth value of the complex proposition is dependent on the truth value of the two propositions. The combinations are represented in the following truth table.

From the above table it can be seen that the proposition is true only when both the simpler propositions are true. In all other cases it is false. If the two basic propositions in the above example are represented using (p) and (q), that is (p) represents “Today is Friday” and (q) represents “It is raining outside”, then there are four possible combinations of true and false to consider (shown in the previous example). These combinations are represented in the following truth table.

Table 3.2 The AND logical operation.

Disjunction - OR

Like the AND logical operator the OR operator joins two propositions to form a single proposition, but it produces a different logical outcome.

Definition:  The OR logical operator joins two different propositions together, and is false when both propositions are false. In all other cases it is true.          

Example I:        Determine if the mathematical statement x > 4 OR y > 6 is a proposition, if x and y are integers (positive whole numbers)

Solution:          This mathematical statement as a whole is a proposition because it can be either true or false, but it must be noted that it is made up of two propositions (x>4) and (y>6) which in themselves can be true or false. The two propositions joined together form a complex proposition, and the truth value of the complex proposition is dependent on the truth value of the two propositions.


If the two basic propositions in the above example are represented using (p) and (q), (p) represents the proposition (x > 4) and (q) represents the proposition (y >6), then there are four possible combinations of true and false that can be represented as a truth table.

Table 3.3 The OR logical operation.

Symbols

The various logical operators are represented symbolically to facilitate the analysis of logical statements and expressions. These symbols are also useful in reducing the space needed to represent an expression.  Since logic is used in different areas of study, the symbol sets also vary from one area to another. The following table shows the symbols that are commonly used in the study of computer engineering.

Table 3.4 Logical operator symbols.

The last four operators, XOR, NAND, NOR, and XNOR, are similar to the AND and OR in that they operate on two propositions. The XOR called the exclusive-OR is also sometimes represented as EOR. The XOR operator produces a true result only when one of propositions is true. The NAND, NOR and XNOR are operators that produce results that are negations (or opposite) of the AND, OR, and XOR results. For example, the NAND operator produces a false result when both propositions are true, and in all other cases it produces a true result, which is the opposite of AND.

Instead of using character based descriptions like AND, OR, and NOT, we can represent the ideas of logic using symbols; for example, [pANDq] NAND [pXORq] could be expressed as (p q) ↑ (p q) symbolically. The symbolic form is more compact in form, and later in chapter 6 we will see how it can be used to simplify logical expressions.


3.2 Practice Questions

1.    Determine the truth value of the following propositions if x=3 and y=1

        a. (x+1) > 5 and x < 6                    b. not(x=y)

        c. (y+1) < 7 or (x+2) > 3                d. (y-1) > 3 and (x+4) = 7

        e. (x-y) > 2 and (3-x) < 5               f. (x+3) = 2 or (x+5) < 7

2.     Express the following logic expressions symbolically.

        a. [pANDq]ORq                             b. [pXORr]ANDr

        c. [rNORq]XORq              d. pNAND[NOTr]

        e. [pORr]XNOR[NOTp]    f. [pNANDr]OR[pXORr]

3.     Determine the logical result for the expressions in question 2, if the truth values for p, q, and r are 1, 1, and 0.





GlobalEduTech Solutions

Powered by Wild Apricot Membership Software