Computer science: truth table. Truth Table Building

Today weโ€™ll talk about a subject called computer science. The truth table, varieties of functions, the order of their execution are our main questions, to which we will try to find answers in the article.

computer science table

Usually this course is taught back in high school, but a large number of students are the cause of a misunderstanding of some features. And if you are going to devote your life to this, then you just can not do without passing a single state exam in computer science. The truth table, the conversion of complex expressions, the solution of logical problems - all this can be found on the ticket. Now we will consider this topic in more detail and help you gain more points on the exam.

The subject of logic

What is this subject - computer science? Truth table - how to build it? Why do we need science logic? We will answer all these questions with you now.

Computer science is a rather fascinating subject. It cannot cause difficulties in modern society, because everything that surrounds us, one way or another, relates to the computer.

The basics of the science of logic are given by high school teachers in computer science lessons. Truth tables, functions, simplification of expressions - all this should be explained by computer science teachers. This science is simply necessary in our life. Take a closer look, everything obeys any laws. You threw the ball, it flew up, but after that fell back to the ground, this was due to the laws of physics and the force of gravity. Mom cooks soup and adds salt. Why when we eat it, we do not come across grains? It's simple, the salt dissolved in water, obeying the laws of chemistry.

make a truth table

Now pay attention to how you are talking.

  • "If I take my cat to the veterinary clinic, they will get a vaccination."
  • โ€œToday was a very difficult day because the check was coming.โ€
  • โ€œI do not want to go to university, because today there will be a colloquiumโ€ and so on.

Everything you say is subject to the laws of logic. This applies to both business and friendly conversation. It is for this reason that it is necessary to understand the laws of logic in order not to act at random, but to be sure of the outcome of events.

Functions

In order to compile a truth table for the task proposed to you, you need to know the logical functions. What it is? A logical function has some variables that are statements (true or false), and the very meaning of the function should give us the answer to the question: โ€œIs the expression true or false?โ€.

All expressions take the following values:

  • True or false.
  • And or L.
  • 1 or 0.
  • Plus or minus.

Here, give preference to the method that is more convenient for you. In order to compile a truth table, we need to list all combinations of variables. Their number is calculated by the formula: 2 to the power of n. The result of the calculation is the number of possible combinations, the variable n in this formula denotes the number of variables in the condition. If the expression has many variables, then you can use the calculator or make a small table for yourself with the raising of two to a power.

In total, seven functions or relations connecting expressions are distinguished in logic:

  • Multiplication (conjunction).
  • Addition (disjunction).
  • Consequence (implication).
  • Equivalence.
  • Inversion.
  • Schaeffer stroke.
  • Arrow pierce.

The first operation presented in the list is called "logical multiplication". It can be graphically marked as an inverted checkmark, with the signs & or *. The second operation on our list is logical addition, graphically indicated as a check mark, +. The implication is called a logical consequence, is indicated in the form of an arrow indicating the condition for the consequence. Equivalence is indicated by a two-way arrow, the function has a true value only in those cases, when the code both values โ€‹โ€‹take the value "1" or "0". Inversion is called logical negation. Schaefferโ€™s bar is called a function that negates the conjunction, and Pierceโ€™s arrow is called a function that negates the disjunction.

Basic binary functions

The logical truth table helps to find the answer in the problem, but for this it is necessary to remember the tables of binary functions. In this section they will be provided.

truth table for 4 variables

Conjunction (multiplication). If two expressions are true, then as a result we get the truth, in all other cases we get a lie.

+

+

+

+

-

-

-

+

-

-

-

-

What the table looks like, you learned, then there is no need to bring it to all formulas. In the picture above you can see in which cases the result is equal to one.

The result is a lie with logical addition we have only in the case of two false input data.

A logical consequence has a false result only when the condition is true and the effect is false. Here you can give an example from life: โ€œI wanted to buy sugar, but the store was closed,โ€ therefore, sugar was never bought.

Equivalence is true only in cases of identical values โ€‹โ€‹of the input data. That is, in pairs: โ€œ0; 0โ€ or โ€œ1; 1โ€.

truth table informatics examples

In the case of inversion, everything is elementary, if there is a true expression at the input, then it will be converted to false, and vice versa. The picture shows how it is indicated graphically.

The Schiffer stroke will have a false result only if there are two true expressions.

In the case of the Pierce arrow, the function will be true only if we have only false expressions at the input.

In what order do logical operations

Please note that building truth tables and simplifying expressions is only possible with the correct sequence of operations. Remember in what sequence they need to be carried out, it is very important for receiving the correct result.

  • logical negation;
  • multiplication;
  • addition;
  • consequence;
  • Equivalence
  • denial of multiplication (Schaeffer stroke);
  • denial of addition (pierce arrow).

Example No. 1

Now we propose to consider an example of constructing a truth table for 4 variables. It is necessary to find out in what cases F = 0 for the equation: not A + B + C * D

A

IN

WITH

D

not a

C * D

F

-

-

-

-

+

-

+

-

-

-

+

+

-

+

-

-

+

-

+

-

+

-

-

+

+

+

+

+

-

+

-

-

+

-

+

-

+

-

+

+

-

+

-

+

+

-

+

-

+

-

+

+

+

+

+

+

+

-

-

-

-

-

-

+

-

-

+

-

-

-

+

-

+

-

-

-

-

+

-

+

+

-

+

+

+

+

-

-

-

-

+

+

+

-

+

-

-

+

+

+

+

-

-

-

+

+

+

+

+

-

+

+

The answer to this task will be to list the following combinations: โ€œ1; 0; 0; 0โ€, โ€œ1; 0; 0; 1โ€ and โ€œ1; 0; 1; 0โ€. As you can see, compiling a truth table is quite simple. Once again, I want to draw your attention to the order of the actions. In a specific case, it was as follows:

  1. Inverse of the first simple expression.
  2. The conjunction of the third and fourth expression.
  3. Disjunction of the second expression with the results of previous calculations.

Example No. 2

logical truth table

Now we will consider another task that requires the construction of a truth table. Computer science (examples were taken from the school course) can also have logical tasks as a task. We briefly consider one of them. Is Vanya guilty of stealing the ball if the following is known:

  • If Vanya did not steal or Petya stole, then Seryozha took part in the theft.
  • If Vanya is not guilty, then Seryozha did not steal the ball.

We introduce the notation: And - Vanya stole the ball; P - Petya stole; S - Serezha stole.

Under this condition, we can compose the equation: F = ((unI + P) implication C) * (unI implication notC). We need those options where the function takes the true value. Next, you need to create a table, since this function has as many as 7 actions, then we omit them. We will enter only the input data and the result.

AND

P

WITH

F

-

-

-

-

-

-

+

-

-

+

-

-

-

+

+

-

+

-

-

+

+

-

+

+

+

+

-

-

+

+

+

+

Pay attention to the fact that in this problem we used plus and minus instead of the signs โ€œ0โ€ and โ€œ1โ€. This is also acceptable. We are interested in combinations, where F = +. After analyzing them, we can draw the following conclusion: Vanya participated in the theft of the ball, since in all cases where F takes the value +, And has a positive value.

Example No. 3

truth tables

Now we suggest you find the number of combinations when F = 1. The equation has the following form: F = notA + B * A + notB. We compose a truth table:

A

IN

not a

neV

B * A

F

L

L

AND

AND

L

AND

L

AND

AND

L

L

AND

AND

L

L

AND

L

AND

AND

AND

L

L

AND

AND

Answer: 4 combinations.


All Articles