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:
- 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 inversionA | x | about |
¬A | about | x |
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 -
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.
- E = 1, H = 1, then E v H = 1. If both expressions are true, then their disjunction is also true.
- = 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.
- 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.
DisjunctionE | x | x | about | about |
N | x | about | x | about |
E v N | x | x | x | about |
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".
- 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 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.
ConjunctionE | x | x | 0 | 0 |
N | x | 0 | x | 0 |
E & H | x | 0 | 0 | 0 |
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.
- E = 1, H =, therefore E -> H = 1. If a couple is in love, then they can kiss - true.
- 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 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.
ImplicationE | x | x | about | about |
N | x | about | x | 0 |
E -> H | x | about | x | x |
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.
- A = 1, B = 1, then A≡B = 1. A person drinks pills if and only if he is sick. (true)
- 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)
- A = 1, B = 0, therefore A≡B = 0. A person drinks pills if and only if he is not sick. (False)
- A = 0, B = 1, then A≡B = 0. A person does not drink pills if and only if he is sick. (False)
EquivalenceA | x | about | x | about |
IN | x | about | 0 | x |
A≡B | x | x | about | about |
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.
- ¬
- B & (¬B)
- A v (B & (¬ B))
- (A v (B & (¬B))) -> B
- (( 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 solutionA | IN | ¬ | B & (¬B) | A v (B & (¬ B)) | (A v (B & (¬B))) -> B | (( v ( & (¬))) -> ) ≡ |
x | about | x | about | x | x | x |
x | x | about | about | x | x | x |
about | about | x | about | about | x | about |
about | x | about | about | about | x | about |
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.
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.