10 logical values \u200b\u200bof the expression operation. Boolean values, operations, expressions. (Grade 10). Pascal branch operator

Compiled by: E.P. Antonova 2008

Slide 2

Boolean values

Boolean values: concepts expressed by words: TRUE, FALSE (true, false). Consequently, the truth of statements is expressed through logical values. Boolean constant: TRUE or FALSE Boolean variable: a symbolic Boolean value. If A, B, X, Y, etc. are variable logical values, then this means that they can only take on the values \u200b\u200bTRUE or FALSE. A logical expression is a simple or complex statement. A complex statement is built from simple ones using logical operations (connectives).

Slide 3

Logical operations. Conjunction

Conjunction (logical multiplication). In Russian, it is expressed by the union I. In mathematical logic, the signs & or / \\ are used. Conjunction - double operation; written in the form: A / \\ B. The value of such an expression will be FALSE if at least the value of one of the operands is false.

Slide 4

Logical operations. Disjunction

Disjunction (logical addition). In Russian, this conjunction corresponds to the union OR. In mathematical logic, it is denoted by the sign v. Disjunction - double operation; written as: A vB. The value of such an expression will be TRUE if the value of at least one of the operands is true.

Slide 5

Logical operations. Negation

Negation. In Russian, this bundle corresponds to the particle NOT (in some statements, the phrase "it is not true that ..." is used). Negation is a unary (one-place) operation; written in the form: ¬A

Slide 7

Example

Consider a complex statement: "The number 6 is divisible by 2, and the number 6 is divisible by 3." Present this statement as a logical formula. Let us denote by A the simple statement “the number 6 is divisible by 2”, and by B the simple statement “the number 6 is divisible by 3”. Then the corresponding logical formula is: A & B. Obviously, its value is TRUE.

Slide 8

Rules for performing logical operations

  • Slide 9

    Problem 1

    Formulate statements in ordinary language for the following logical expressions: 1) (X \u003d 12) and (Y \u003d 12) and (Z \u003d 12); 2) (X 0) or (Y 0); 3) (X x Y 0); 4) (X x Y x Z 0).

    Slide 10

    Problem 2

    Determine the value of the logical expression: not (X\u003e Z) and not (X \u003d Y), if: 1) X \u003d 3, Y \u003d 5, Z \u003d 2; 2) X \u003d 0, Y \u003d 1, Z \u003d 19; 3) X \u003d 5, Y \u003d 0, Z \u003d -8; 4) X \u003d 9, Y \u003d -9, Z \u003d 9.

    Slide 11

    Problem 3

    Determine the values \u200b\u200bof the logical variables a, b c, d if: 1) a and (Mars is a planet) is a true statement; 2) b and (Mars - planet) is a false statement; 3) with or (the Sun is a satellite of the Earth) - a true statement; 4) d or (the Sun is a satellite of the Earth) is a false statement.

    A discipline called mathematical logic is directly related to programming. The basis of mathematical logic is the algebra of logic, or propositional calculus. A statement is understood as any statement in relation to which it is possible to say unambiguously whether it is true or false. For example, "The moon is a satellite of the Earth" is true; "5\u003e 3" is true; “Moscow is the capital of China” is false; "1 \u003d 0" is false. True or false are logical values. The logical meanings of the above statements are uniquely defined; in other words, their values \u200b\u200bare logical constants.

    Boolean value of inequality x< 0, где х - переменная, является переменной величиной. В зависимости от значения х оно может быть либо истиной, либо ложью. В связи с этим возникает понятие логической переменной.

    He created the foundations of the formal apparatus of mathematical logic in the middle of the 19th century. English mathematician George Boole. In his honor, the propositional calculus is called Boolean algebra, and logical values \u200b\u200bare called Boolean.

    Single statements can be combined into compound logical formulas using logical operations.

    There are three main logical operations: negation, conjunction (logical multiplication) and disjunction (logical addition).

    Negation operation denoted in mathematical logic by the symbol ¬ and is read as a particle not. This is a single operation.

    For example, ¬ (x \u003d y) reads "not (x equals y)". The result is true if x is not equal to y, and false if x is equal to y. Negation reverses the Boolean value.

    The conjunction operation is denoted by & and is read as a particle and ... This is a two-bed operation. For example, (x\u003e 0) & (x< 1) читается «х больше 0 и х меньше 1». Данная логическая формула примет значение истина, если х (0,1), и ложь - в противном случае. Следовательно, результат конъюнкции - истина, если истинны оба операнда. Disjunction operation sign v read as a particle or. For example, (x \u003d 0) v (x \u003d 1) reads "x is 0 or x is 1". The formula is true if x is a binary digit (0 or 1). Therefore, disjunction results in true if at least one operand is true.

    In Pascal, boolean values \u200b\u200bare denoted by the service words false and true, and the boolean type identifier is boolean.

    In addition to values \u200b\u200b(constants and variables) of type boolean, the boolean values \u200b\u200bfalse, true accept the results of relation operations.

    Relation operations (Figure 18) compare two operands and determine whether the corresponding relationship between them is true or false.

    Logical operations are performed on Boolean operands. There are four logical operations: Not - negation; And - logical multiplication (conjunction); Or - logical addition (disjunction).In addition to these three mandatory operations, Turbo Pascal has another operation - exclusive OR ... Its sign is the service word Xor. It is a two-place operation that evaluates to true if both operands have different logical values.

    Relationship operations have the lowest priority. Therefore, if the operands of a logical operation are relations, then they should be enclosed in parentheses. For example, the following logical expression corresponds to the mathematical inequality 1 ≤ х ≤ 50:

    (1<=X) And (X<=50)

    A logical expression is a logical formula written in a programming language. A Boolean expression consists of Boolean operands linked by Boolean operations and parentheses. The logical expression evaluates to a Boolean value (false or true). Logical operands can be boolean constants, variables, functions, relation operations. One separate boolean operand is the simplest form of boolean expression.

    Examples of logical expressions (here d, b, c are boolean variables; x, y are real variables; k is an integer variable):

    If d \u003d true; b \u003d false; c \u003d true; x \u003d 3.0; y \u003d 0.5; k \u003d 5, then the calculation results will be as follows:

    The example uses the logical function odd (k). This is a function of the integer argument k, which evaluates to true if k is odd and false if k is even.

    The logical assignment operator has the structure shown in Fig. nineteen.

    Utterance (judgment) is a declarative sentence in which something is affirmed or denied. Any statement can be said to be true or false.

    Boolean values: concepts expressed by words: TRUE (true), FALSE (false).

    Boolean constant: TRUE (true), FALSE (false).

    Boolean variable: a symbolically designated boolean value. Therefore, if it is known that A, B, X, Y, etc. are logical values, then this means that they can only take on the values \u200b\u200bTRUE or FALSE.

    Boolean expression: a simple or complex statement. Complex statements are built from simple ones using logical operations (connectives).

    Logical operations

    Conjunction (logical multiplication). In Russian, it is expressed by the union of I.

    In mathematical logic, signs & are used. Conjunction is a two-place operation, written as A ^ B (A, B are operands). The value of such an expression will be FALSE if at least one of the operands is false.

    Disjunction (logical addition). In Russian, it is expressed by the union OR.

    In mathematical logic, signs are used Disjunction - a two-place operation, written in the form AB. The value of such an expression will be TRUE if at least one of the operands is true.

    Negation. In Russian, it is expressed by the union NOT (in some statements, a turnover is used - it is not true that ...).

    In mathematical logic, the signs are used Negation - a unary (unary) operation, written as A or.

    Logical formula (logical expression) - a formula containing only logical values \u200b\u200band signs of logical operations. The logical formula evaluates to TRUE or FALSE. In logical formulas, TRUE is often represented as 1, FALSE as 0.

    The rules for performing logical operations are reflected in the truth table.

    Truth table

    The sequence of execution of logical operations in logical formulas is determined by the precedence of the operations. The oldest operation is negation (it is performed earlier than others), then comes the conjunction (s), and then the disjunction (or).

    Logic

    Logical circuits are a convenient way to represent logical expressions. This is how the three main logical operations are depicted in such diagrams.

    This table uses the following conventions:

    1 - true, 0 - false, and, or, non-logical operations.

    Example 1: Draw a circuit for a boolean expression 1 or 0 and 1. Then evaluate the value of the boolean expression.

    Solution: Scheme - Calculation:

    Example 2: Given a logic diagram. Build a boolean expression. Then evaluate the value of the boolean expression.

    Solution: Given a scheme -

    Let's compose the formula - (1 or 0) and 1. Let's calculate the value according to the scheme 1 or 0 \u003d 1,

    then 1 and 1 \u003d 1. So (1 or 0) and 1 \u003d 1.

    Logical information and the basics of logic

    A discipline called mathematical logic is directly related to programming. The basis of mathematical logic is the algebra of logic, or propositional calculus. A statement is understood as any statement in relation to which it is possible to say unambiguously whether it is true or false. For example, "The moon is a satellite of the Earth" is true; "5\u003e 3" is true; “Moscow is the capital of China” is false; "1 \u003d 0" is false. True or false are logical values. The logical meanings of the above statements are uniquely defined; in other words, their values \u200b\u200bare logical constants.

    Boolean value of inequality x< 0, где х - переменная, является переменной величиной. В зависимости от значения х оно может быть либо истиной, либо ложью. В связи с этим возникает понятие логической переменной.

    He created the foundations of the formal apparatus of mathematical logic in the middle of the 19th century. English mathematician George Boole. In his honor, the propositional calculus is called Boolean algebra, and logical values \u200b\u200bare called Boolean.

    Single statements can be combined into compound logical formulas using logical operations.

    There are three main logical operations: negation, conjunction (logical multiplication) and disjunction (logical addition).

    Negation operation denoted in mathematical logic by the symbol ¬ and is read as a particle not. This is a single operation.

    For example, ¬ (x \u003d y) reads "not (x equals y)". The result is true if x is not equal to y, and false if x is equal to y. Negation reverses the Boolean value.

    The conjunction operation is denoted by & and is read as a particle and ... This is a two-bed operation. For example, (x\u003e 0) & (x< 1) читается «х больше 0 и х меньше 1». Данная логическая формула примет значение истина, если х (0,1), и ложь - в противном случае. Следовательно, результат конъюнкции - истина, если истинны оба операнда. Disjunction operation sign v read as a particle or. For example, (x \u003d 0) v (x \u003d 1) reads "x is 0 or x is 1". The formula is true if x is a binary digit (0 or 1). Therefore, disjunction results in true if at least one operand is true.

    In Pascal, boolean values \u200b\u200bare denoted by the service words false and true, and the boolean type identifier is boolean.

    In addition to values \u200b\u200b(constants and variables) of type boolean, the boolean values \u200b\u200bfalse, true accept the results of relation operations.

    Relation operations (Figure 18) compare two operands and determine whether the corresponding relationship between them is true or false.

    Logical operations are performed on Boolean operands. There are four logical operations: Not - negation; And - logical multiplication (conjunction); Or - logical addition (disjunction).In addition to these three mandatory operations, Turbo Pascal has another operation - exclusive OR ... Its sign is the service word Xor. It is a two-place operation that evaluates to true if both operands have different logical values.

    Relationship operations have the lowest priority. Therefore, if the operands of a logical operation are relations, then they should be enclosed in parentheses. For example, the following logical expression corresponds to the mathematical inequality 1 ≤ х ≤ 50:

    (1<=X) And (X<=50)

    A logical expression is a logical formula written in a programming language. A Boolean expression consists of Boolean operands linked by Boolean operations and parentheses. The logical expression evaluates to a Boolean value (false or true). Logical operands can be boolean constants, variables, functions, relation operations. One separate boolean operand is the simplest form of boolean expression.

    Examples of logical expressions (here d, b, c are boolean variables; x, y are real variables; k is an integer variable):

    If d \u003d true; b \u003d false; c \u003d true; x \u003d 3.0; y \u003d 0.5; k \u003d 5, then the calculation results will be as follows:

    The example uses the logical function odd (k). This is a function of the integer argument k, which evaluates to true if k is odd and false if k is even.

    The logical assignment operator has the structure shown in Fig. nineteen.