AI For DIY

Saturday, October 1, 2022

Logical operations

1. About logical operations

Before explaining logical operations, in simple terms, logic is a system that consists of only two elements: true and false. It has been in existence since ancient Greece and continues to be a study of argumentation, and George Boole devised Boolean algebra and settled as a system capable of operations on logic.
  For example, in electricity, let the logic when voltage is applied to be true and the logic when no voltage is applied to be false. Then, in Boolean logarithm, it becomes ‘1’ when there is voltage and ‘0’ when there is no voltage. And in the computer, the bit is ‘1’ when there is voltage and ‘0’ when there is no voltage, so Boolean logarithm can be applied in binary as it is.
  An operation method performed in such a logical system is called a logical operation. Let’s learn the operators and rules for this logical operation.

 

2. Types of logical operators

Logical operators used in Boolean algebra are easy to think of similarly to operators that indicate the type of set, so here we approach the logical operators by bringing the concept of a set. In addition, since the operation result of each logical operator is always fixed, it is necessary to know together with the operator what is called a truth table, which can be easily grasped by listing the operands and results in a table.
  First, as the concept of the complementarity of the set A, it is the remainder of true or the remainder of false. Since the element is ‘1’ or ‘0’, it can be said that they are in a negative(inverted) relation as a remainder relation. The operator that causes the inversion of the operand in this way is called the NOT operator. It is expressed as A’ in the formula.

 

Operand

NOT

A

A’

0

1

1

0

 

Next, with the concept of the intersection of sets A and B, the result is called true only when both sets are true. That is, it is only applicable when A is ‘1’ and B is ‘1’, and if it contains ‘0’, it is false. If there is even one ‘0’, it becomes ‘0’. It is called the logical product(AND) operator. It is expressed as A∙B in formulas, and it is sometimes written by abbreviating AB like in arithmetic operations.

 

Operands

AND

A

B

ABAB

0

0

0

0

1

0

1

0

0

1

1

1

 

Operands

AND

A

B

C

ABCABC

0

0

0

0

0

0

1

0

0

1

0

0

0

1

1

0

1

0

0

0

1

0

1

0

1

1

0

0

1

1

1

1

 

Then, as the concept of the union of sets A and B, if either set is true, the result is called true. In other words, if A is ‘1’ or B is ‘1’, both are true, and it is false only when both are ‘0’. If there is even one ‘1’, it becomes ‘1’, and it is called an logical sum(OR) operator. (It is assumed that there is no concept of rounding in logic.) It is expressed as A+B in the formula.

 

Operands

OR

A

B

A+B

0

0

0

0

1

1

1

0

1

1

1

1

 

Operands

OR

A

B

C

A+B+C

0

0

0

0

0

0

1

1

0

1

0

1

0

1

1

1

1

0

0

1

1

0

1

1

1

1

0

1

1

1

1

1

 

Next, the concept of the union of the mutual difference between sets A and B, if only one of them is true, the result is called true. That is, it corresponds to the case where only A is ‘1’ and the case where only B is ‘1’, and if both are ‘0’ or ‘1’, it is false. The property of excluding only the same cases from logical sum is called an exclusive logical sum(XOR : eXclusive OR) operator. In formulas, it is expressed as AB, and is sometimes written as AB+AB in the form of logical product and sum. However, this result is only applicable when there are two operands. Considering three or more operands, remember it as an operator that is ‘True when the number of true(‘1’) is odd(even parity)’.

 

Operands

XOR

A

B

AB

0

0

0

0

1

1

1

0

1

1

1

0

 

Operands

XOR

A

B

C

ABC

0

0

0

0

0

0

1

1

0

1

0

1

0

1

1

0

1

0

0

1

1

0

1

0

1

1

0

0

1

1

1

1

 

In addition, the NOT result of logical product is negative logical product (NAND : Not AND), the NOT result of logical sum is negative logical sum(NOR: Not OR), and the NOT result of exclusive logical sum is exclusive negative logical sum(XNOR: eXclusive NOR). If each operator is expressed as a formula, it becomes (AB)’, (A+B)’, (AB)’, and their truth table is as follows. It is expressed as AB only for the exclusive negative logical sum, and it is also written as A’B’+AB in the form of logical product and sum.

 

Operands

NAND

A

B

(AB)’

0

0

1

0

1

1

1

0

1

1

1

0

 

Operands

NOR

A

B

(A+B)’

0

0

1

0

1

0

1

0

0

1

1

0

 

Operands

XNOR

A

B

(AB)AB

0

0

1

0

1

0

1

0

0

1

1

1

 

Comparing the three primitive operations with the three additions of NOT operations, it can be seen that ‘1’ and ‘0’ are reversed. That is, it is the same as inverting the original result. Know the above 7 logical operators as a basis and apply them to the following logical expressions.

 

3. Law of logical operation

As a characteristic of logical operations used in Boolean algebra, it is considered as a modification of logical expressions that always holds true. The rules below have names, but the names themselves are not very important.

 

Law(Rule)

AND based

OR Based

Involution

(A’)’A

Null

A11

A00

Compliment

AA’1

AA’0

Identity

A0A

A1A

Idempotent

AAA

AAA

Absorption

A(AB)A

A(AB)A

Common identity

A(A’B)A+B

A(A’B)AB

Unity

(AB)(AB’)A

(AB)(AB’)A

Commutation

ABBA

ABBA

Association

(AB)CA(BC)

(AB)CA(BC)

Distribution

A(BC)(AB)(AC)

A(BC)(AB)(AC)

De Morgan’s

(AB)’A’B’, (ABC)’A’B’C’

(AB)’A’B’, (ABC)’A’B’C’

Consensus

(AB)(BC)(CA’)(AB)(CA’)

(AB)(BC)(CA’)(AB)(CA)’

 

As a rule that always holds for each operator, instead of trying to memorize them all, find them whenever you need them and apply them to the operation of logical expressions.
  Among these, the de Morgan law, which was proved by Augustus De Morgan, is particularly considered. According to this law, the negation of the logical sum becomes the logical product of individual negation operations(NOR
NOTNOT), and the negation of the logical product becomes the logical OR of the individual negation operations(NANDNOTNOT). In summary, logical product and logical sum can be substituted for each other. This means that all logical expressions can be expressed with only negative logical sum or only negative logical product.

In addition, some appear in the table, but in the order of operation of logical expressions, parentheses take precedence, followed by negation operators, then logical product and logical sum. Except for negation operators, think of arithmetic operations in the same order as parentheses, multiplication, and addition.

 

4. Conclusion

Unlike arithmetic operations, logical operations are based on false ('0') or not ('1'), so you may not be familiar with them. However, it is necessary to know the basics of logic operation, so that it is necessary for the logic circuit that follows.

No comments:

Post a Comment