The simplest logical operations in computer science

Everyone who begins to study computer science is taught the binary system of calculus. It is she who is used to calculate logical operations. Consider below all the most elementary logical operations in computer science. After all, if you think about it, they are used to create the logic of computers and devices.

Negation

Before you begin to consider in detail specific examples, we list the main logical operations in computer science:

logical operations in computer science

  • negation;
  • addition;
  • multiplication;
  • following;
  • equality.

Also, before starting the study of logical operations, it is worth saying that in computer science a lie is designated "0", and the truth is "1".

For each action, as in ordinary mathematics, the following signs of logical operations in computer science are used: ¬, v, &, ->.

Each action can be described either by digits 1/0, or simply by logical expressions. We begin our consideration of mathematical logic with a simple operation that uses only one variable.

Logical negation is an inversion operation. The bottom line is that if the original expression is true, then the result of the inversion is false. Conversely, if the original expression is false, then the result of the inversion will be - true.

The following notation "¬A" is used to record this expression.

Here is the truth table - a diagram that shows all the possible results of the operation for any source data.

Truth table for inversion
Axabout
¬Aaboutx

That is, if our initial expression is truth (1), then its negation will be false (0). And if the original expression is false (0), then its negation is true (1).

Addition

The remaining operations require two variables. Denote one expression -

informatics properties of logical operations
A, the second - B. Logical operations in computer science, denoting the action of addition (or disjunction), when written are indicated by either the word "or" or the symbol "v". We will describe the possible data options and the calculation results.

  1. E = 1, H = 1, then E v H = 1. If both expressions are true, then their disjunction is also true.
  2. = 0, = 1, as a result v = 1. = 1, = 0, then v = 1. If at least one of the expressions is true, then the result of their addition will be true.
  3. E = 0, H = 0, the result is E v H = 0. If both expressions are false, then their sum is also false.

For brevity, create a truth table.

Disjunction
Exxaboutabout
Nxaboutxabout
E v Nxxxabout

Multiplication

Having dealt with the addition operation, we pass to the multiplication (conjunction). We use the same notation that was given above for addition. When writing, logical multiplication is indicated by the "&" symbol, or by the letter "AND".

  1. E = 1, H = 1, then E & H = 1. If both expressions are true, then their conjunction is true.
  2. If at least one of the expressions is a lie, then the result of logical multiplication will also be a lie.
  • E = 1, H = 0, therefore E & H = 0.
  • E = 0, H = 1, then E & H = 0.
  • E = 0, H = 0, the result is E & H = 0.
Conjunction
Exx00
Nx0x0
E & Hx000

Consequence

A logical follow-up operation (implication) is one of the simplest in mathematical logic. It is based on a single axiom - a lie cannot follow from the truth.

  1. E = 1, H =, therefore E -> H = 1. If a couple is in love, then they can kiss - true.
  2. E = 0, H = 1, then E -> H = 1. If the couple is not in love, then they can kiss - it can also be true.
  3. E = 0, H = 0, from this E -> H = 1. If the couple is not in love, then they do not kiss - it’s also true.
  4. E = 1, H = 0, the result will be E -> H = 0. If the couple is in love, then they do not kiss - a lie.

To facilitate the implementation of mathematical operations, we also give a truth table.

Implication
Exxaboutabout
Nxaboutx0
E -> Hxaboutxx

Equality

The last operation considered will be logical identity equality or equivalence. In the text, it can be designated as "... if and only if ...". Based on this formulation, we will write examples for all the original options.

basic logical operations in computer science

  1. A = 1, B = 1, then A≡B = 1. A person drinks pills if and only if he is sick. (true)
  2. A = 0, B = 0, in the end A≡B = 1. A person does not drink pills if and only if he is not sick. (true)
  3. A = 1, B = 0, therefore A≡B = 0. A person drinks pills if and only if he is not sick. (False)
  4. A = 0, B = 1, then A≡B = 0. A person does not drink pills if and only if he is sick. (False)
Equivalence
Axaboutxabout
INxabout0x
A≡Bxxaboutabout

The properties

So, having considered the simplest logical operations in computer science, we can begin to study some of their properties. As in mathematics, logical operations have their own processing order. In large logical expressions, operations in parentheses are performed first. After them, first of all, we calculate all the negation values ​​in the example. The next step is to calculate the conjunction, and then the disjunction. Only after this we carry out the operation of consequence and, finally, equivalence. Let's consider a small example for illustrative purposes.

A v B & ¬B -> B ≡ A

The sequence of actions is as follows.

  1. ¬
  2. B & (¬B)
  3. A v (B & (¬ B))
  4. (A v (B & (¬B))) -> B
  5. (( v ( & (¬))) -> ) ≡

In order to solve this example, we need to build an extended truth table. When creating it, remember that it is better to arrange the columns in the same order in which the actions will be performed.

Example solution
AIN

¬

B & (¬B)

A v (B & (¬ B))

(A v (B & (¬B))) -> B

(( v ( & (¬))) -> ) ≡

xaboutxaboutxxx
xxaboutaboutxxx
aboutaboutxaboutaboutxabout
aboutxaboutaboutaboutxabout

As we can see, the result of solving the example will be the last column. The truth table helped solve the problem with any possible source data.

signs of logical operations in computer science

Conclusion

This article examined some concepts of mathematical logic, such as computer science, the properties of logical operations, and also what are logical operations in themselves. Some simple examples were given for solving problems in mathematical logic and truth tables needed to simplify this process.

Source: https://habr.com/ru/post/C24654/


All Articles