EducationSecondary education and schools

How to compile a truth table for a complex boolean expression

Today we will try to explain how to make a truth table for a logical expression. Note that Boolean algebra occurs in at least three tasks of the unified state exam. If you read this article, then, for sure, get more points in the exam in computer science.

Operations

Before making a truth table, we suggest to get acquainted with the operations of Boolean algebra.

Let's start our acquaintance with the function of negation. It is also called inversion. Let's give an example: the expression "I'm going to the movies today." We apply an inversion to it, as a result we have: "I am NOT going to the cinema today."

Now let's talk about the functions of multiplication and addition, in Boolean algebra they have names - a conjunction and a disjunction, respectively. Suppose we are told: "you will go to the cinema, if you learn the lessons and take out the trash." In this proposal, the "I" union performs the function of conjunction, and "IF" - the disjunction.

A logical consequence is another complicated operation of logic, which contains two expressions: the condition and the effect. If you interpret it in Russian, the sentence is structured roughly like this: "if I have time to learn literature, then I'll go to the cinema." The part of the sentence before the comma is a condition, and after the comma is an effect.

Now briefly about the function of equivalence or equivalence. To draw a parallel with the Russian language in this case is quite difficult. For equivalence, remember that if two input expressions are either false or true, then the result is positive, that is, one.

Algorithm

Now we will talk about how to compile a truth table on informatics, or rather, discuss the algorithm of our actions.

To compile a table, you first need to determine the number of cells, columns, and rows. We will do everything step by step.

  • Determine the number of rows. For this, it is necessary to calculate how many variables are included in the expression, and to construct a deuce in this number. For example, how to compile a truth table, or more precisely to find the number of rows for an expression with three variables? Two we raise to the third power and get eight. Without the cap, we need eight lines.
  • In order to determine the number of columns, we need to count and number the operations in this expression. For example, in the expression notA * C + B, there are only three operations. The first is negation, the second is multiplication, the third is addition. So we need three columns to fill the values of the operations. But, it is worth considering that our expression consists of three variables, and we need to fill in their possible combinations, add three more columns. Total is obtained 6.
  • Next, we proceed to enumerate possible combinations of variables and fill the table. Be sure to consider the priority of operations.

The first example (three variables)

We suggest you solve the following problem: calculate how many combinations satisfy the condition F = 1 of the expression: (notA + B) * notC + A. And now about how to make a truth table for the solution of the problem. We resort to the help of the compiled algorithm of actions.

  1. The number of lines = 9 (eight combinations of variables + one line - the table header).
  2. Priority of functions: 1-inversion, 2-addition in brackets, 3-inversion C, 4-multiplication, 5-addition.
  3. Number of columns = 8.
  4. Drawing up the table and filling.

Expression A

Expression B

Expression C

Operation # 1

Operation number 2

Operation # 3

Operation # 4

Operation # 5

-

-

-

+

+

+

+

AND

-

-

+

+

+

-

-

L

-

+

-

+

+

+

+

AND

-

+

+

+

+

-

-

L

+

-

-

-

-

+

-

AND

+

-

+

-

-

-

-

AND

+

+

-

-

-

+

-

AND

+

+

+

-

-

-

-

AND

  1. Finding the answer to the question.
  2. Record the answer. Answer: 6. Note that the job condition asks how many combinations are satisfied, but does not ask for them to be listed.

The second example (4 variables)

We suggest you consider the question: how to make a truth table for the formula: A * B * not C + D? Which number of combinations corresponds to: F = 0.

We act on the same algorithm. The number of rows in our case is increased to 17, and the number of columns is increased to 8. Priority of operations:

  1. A * B;
  2. NotC;
  3. Multiplying the results of the first and second operations;
  4. Addition of the result of the third operation and the value of the variable D.

We suggest you try to create and fill the table yourself, and then check the results in this section of the article.

Variable A

Variable B

Variable C

Variable D

Multiplication (1)

Inversion (2)

Multiplication (3)

Addition (4)

-

-

-

-

-

+

-

-

-

-

-

+

-

+

-

+

-

-

+

-

-

-

-

-

-

-

+

+

-

-

-

+

-

+

-

-

-

+

-

-

-

+

-

+

-

+

-

+

-

+

+

-

-

-

-

-

-

+

+

+

-

-

-

+

+

-

-

-

-

+

-

-

+

-

-

+

-

+

-

+

+

-

+

-

-

-

-

-

+

-

+

+

-

-

-

+

+

+

-

-

+

+

+

+

+

+

-

+

+

+

+

+

+

+

+

-

+

-

-

-

+

+

+

+

+

-

-

+

From the resulting table, we conclude: this condition is satisfied by 7 different combinations of variables.

Similar articles

 

 

 

 

Trending Now

 

 

 

 

Newest

Copyright © 2018 en.atomiyme.com. Theme powered by WordPress.