The simplest logical operations in computer science
Everyone who begins to study computer science is taughtbinary system of calculus. It is used to calculate logical operations. Let's consider below all the most elementary logical operations in computer science. After all, if you think about it, they are used when creating the logic of computers and devices.
Before we start to consider in detail specific examples, we list the main logical operations in computer science:
Also, before beginning to study logical operations, it is worthwhile to say that in computer science lie is designated "0", and the truth is "1".
For each action, as in ordinary mathematics, the following signs of logical operations in informatics are used: ¬, v, &, ->.
Each action can be described either by 1/0 digits, or simply by logical expressions. Let's start with 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, the result of the inversion will be true.
When writing this expression, the following notation is used: "¬A".
Here is a truth table - a diagram that shows all possible results of an operation for any input data.Truth table for inversion
That is, if our original expression is true (1), then its negation will be false (0). And if the original expression is false (0), then its negation is true (1).
The remaining operations require two variables. We denote one expression -And the second - V. Logical operations in informatics, which denote the addition (or disjunction), are indicated by either the word "or" or the "v" sign. Let's write down the possible data options and the results of the calculations.
- E = 1, H = 1, then E v H = 1. If both expressions are true, then their disjunction is also true.
- E = 0, H = 1, then E v H = 1. E = 1, H = 0, then E v H = 1. If at least one of the expressions is true, then the result of their addition will be true.
- 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
|E v H||x||x||x||about|
Having dealt with the operation of addition, go tomultiplication (conjunction). We use the same notation as above for addition. When writing, logical multiplication is indicated by the symbol "&" or the letter "AND".
- E = 1, H = 1, then E & H = 1. If both expressions are true, then their conjunction is true.
- If at least one of the expressions is false, then the result of logical multiplication will also be a lie.
- E = 1, H = 0, and therefore E & H = 0.
- E = 0, H = 1, then E & H = 0.
- E = 0, H = 0, the result of E & H = 0.
|E & H||x||0||0||0|
The logical sequencing operation (implication) is one of the simplest in mathematical logic. It is based on a single axiom - the truth can not be followed by a lie.
- E = 1, H =, therefore E -> H = 1. If the couple is in love, then they can kiss - the truth.
- E = 0, H = 1, then E -> H = 1. If the couple is not in love, then they can kiss - it can also be true.
- 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.
- E = 1, H = 0, the result is E -> H = 0. If the couple is in love, then they do not kiss - it's a lie.
To facilitate the implementation of mathematical actions, we also give a truth table.Implication
|E -> H||x||about||x||x|
The last operation considered will belogical identity or equivalence. In the text, it can be designated as "... if and only if ...". Proceeding from this formulation, we will write examples for all the initial variants.
- A = 1, B = 1, then A≡B = 1. A person drinks tablets only if he is ill. (true)
- A = 0, B = 0, in the end A≡B = 1. A person does not drink tablets if and only if he does not get sick. (true)
- A = 1, B = 0, so A≡B = 0. A person drinks tablets only if he does not get sick. (False)
- A = 0, B = 1, then A≡B = 0. A person does not drink tablets if and only if he is sick. (False)
So, after considering the simplest logical operations ininformatics, we can begin to study some of their properties. Like in mathematics, logical operations have their own processing order. In large logical expressions, operations in brackets are performed first. After them, first of all, we calculate all the values of negation in the example. The next step is to calculate the conjunction, and then disjunction. Only after this we perform the operation of the investigation and, finally, the equivalence. Consider a small example for clarity.
A v B & ¬ B -> B ≡ A
The order of the action is as follows.
- B & (¬ B)
- A v (B & (B))
- (A v (B & (B)))) → B
- ((A v (B & (¬ B))) -> B) ≡ A
In order to solve this example, weyou will need to build an extended truth table. When you create it, remember that it's better to place the columns in the same order in which the actions will be performed.Sample solution
B & (¬ B)
A v (B & (B))
(A v (B & (B)))) → B
((A v (B & (¬ B))) -> B) ≡ A
As we see, the last column will result in the solution of the example. The truth table helped solve the problem with any possible initial data.
In this article, some concepts have been consideredmathematical logic, such as informatics, the properties of logical operations, and also - what are logical operations in themselves. Some simple examples were given for solving mathematical logic problems and truth tables necessary to simplify this process.