📜 ⬆️ ⬇️

Cynical solution of logical problems



Recently I came across an article about the so-called most complex logical problem in Wikipedia. The article shocked me either with its provocativeness, or with logical illiteracy, especially with regard to the author’s explanations of its conditions and the possible course of the decision.

The task


There are three gods: A, B, and C, one of which is the god of truth, the other is lies, and the third is chance. The god of truth always tells the truth, the god of lies always deceives, the god of chance can speak the truth and lie. It is required to identify the gods by asking 3 questions that can be answered with “yes” or “no”. Each question is asked only by one god. The gods understand the language, but they answer in their own language, in which there are 2 words “da” and “ja”, and it is not known which word means “yes” and which “no”.

First we analyze the solution to this problem in a cynical way. Briefly, the method is characterized by two theses:
  1. The task should be reduced to a system of logical equations and inequalities (SLUN);
  2. Restrictions on the values ​​of input variables are written in relational tables. The solution of SLUN is performed by executing a SQL query. The constructed relational table contains 0 or more solutions to a logical problem. Each row of the table is one of the solutions to a logical problem.

')
We illustrate our theses by solving the most complex logical problem.

Let us denote A.STATUS, V.STATUS, and S.STATUS variables SLEEN, which we will now compile. Possible variable values ​​are the string values ​​TRUE, FALSE, and CASE. For their designation below we will use the identifiers TRUE, FALSE and CASE.

The study of the conditions of the problem allows you to create one logical equation:

(A.STATUS <> B.STATUS AND A.STATUS <> C.STATUS AND B.STATUS <> C.STATUS AND) EQV TRUE is a formal record of the first condition of the problem.

The SQL query for solving the equation is:

SELECT * FROM , ,  WHERE (.<>B. AND . <> . AND . <> .) EQV TRUE; 


The solutions of the equation (there are 6 of them) and one of the tables with restrictions on the values ​​of the input variables is shown in the figure below:


Any of the six solutions to the equation is the answer to the problem question. This answer was received without talking to the gods .

To support a “deductive” dialogue in order to obtain a single answer, let us ask each of the gods one question, for example:

God A: "Is not God a god of chance?" God B: "Is not God a God of lies?" God C: “Isn't he the god of chance?” Formally, these questions can be written as a system of 6 logical inequalities, the solution of which will be the only answer: A is the god of truth, B is the god of lies, and C is the god of chance. Note that the answers of the gods - “da” or “ja” are not needed to solve the problem .

The system of inequalities is:



Complement conjunctively the WHERE clause of our SQL query with this formula and get an answer to the question of the problem in the form of a relational table with one row.

Addressing our questions to the gods in a different order, for example, the first question to God B, and the second to God A, you can get any other answer from among the possible solutions of the logical equation given in the first figure.

The application of the thesis on the formalization of a logical problem by a system (or several systems) of logical equations and inequalities allows you to clearly fix the conditions of the problem. In the formulation of the most complex logical problem, only one equation is given. For a single answer, the author of the problem implicitly offers to supplement her condition, which we did by formulating 6 triples of questions. The thesis of the formalization of logical problems SLUN makes it understand without equivocation.

Turning SLUN into a SQL query is easy to automate. For some varieties of SLUN and SQL dialects, this has already been done (see the solution to other problems, additional information and materials here ). Of particular interest are systems of logical equations, which are solved by performing recursive SQL queries.

UPDATE:
I will try to answer most of the Comments.
To solve the problem on the basis of SLUNA from its wording it is necessary to extract
  1. The question of the problem.
  2. Variables, their possible values ​​from which sets of values ​​of variables will be built. These kits are answers to the problem question.
  3. Given causal relationships, written in the form of logical inequalities (“If A is B”) or equations (“If A is B” and “If B is A”, that is, A and B are equivalent).

Anything else is garbage or entrapment.
From the formulation of the most complex logical problem, we extracted one equation. Having solved it, we got 6 possible solutions. Any of them is the answer to the problem question.
The words that the god of truth always speaks the truth, the god of lies always lies, etc. these are “pieces” (in our case, the premise) of possible logical inequalities. With our questions we have added these inequalities. There are two inequalities behind each question, i.e. we succumbed to the provocation of the author of the problem and supplemented its condition.
Let us comment, for example, the first question to God A: “Is not God with the God of chance?”
Two inequalities are derived from this question. In Russian, the first inequality is: "If God A is the god of truth, then God C is the god of chance." The second inequality is “If A is the god of lies, then God is not the god of chance.”
Of course, it would be necessary to analyze what God answered - yes or no. I didn’t want to mess around with “da” and “ja” spells. We will encode the answers of the gods with the logical constants TRUE and FALSE.
The question of the form of a system of inequalities is:

Since the implication with the identically false premise is identical, and the identical factor in the conjunction is irrelevant, this formula is equivalent to the following formula:

To extract the third inequality for the variant, when god A is the god of chance, we did not, since this inequality is the identical true formula and does not impose any restrictions on the possible values ​​of variables.
The situation is similar with the remaining two questions (see the second formula in the article). Note that these questions are formulated on the motives of one of the tasks of R. Smillian from the series “Princess or Tiger” (Smallian R. Princess or Tiger? .. - M .: Mir, 1985. - 221 p.).
The phenomenon of the magic of questions is explained very simply. We do not need questions. We need a system of logical equations and inequalities. And this is a logical formula. We have three string variables, each of which can take one of three values. Thus, we will search for permissible combinations of their values ​​in the set of 27 elements. The equation and all 6 inequalities are satisfied by one set of variable values, corresponding to the case when A is the god of truth, B is the god of lies, and C is the god of chance.

Source: https://habr.com/ru/post/237099/


All Articles