[PYTHON] Is there a contradiction between the party that protects the people from NHK and the party that protects NHK from the people?

What are you talking about

Please read this article first.

In this article, we will implement in Python the "algorithm that determines whether the world is inconsistent when given a political party name," which was asked in the original article.

Mathematically formulate

If NHK is 0 and the people are 1, the "party that protects the people from NHK" can be expressed as the "party that protects the people from 0 to 1."

If we omit it further and use the list [0, 1], all parties can be represented by a list of length 2.

For example, "the party that protects the people from the party that protects NHK from the people" is expressed by [[1, 0], 1]. "The party that protects the people from NHK to the party that protects NHK from the people" can be simply expressed as [[[0,1], [1,0]], 0]. I will.

And all possible political parties (including contradictory ones) can be written this way.

Axiom of friendship

In general, it is expected that the following holds when the political party [x, y] exists.

  1. Political parties [x, y] are friendly with y (because the former defends the latter). --The party [x, y] is not friendly with x (because the former is trying to protect something from the latter).

The original article also assumes the following axioms.

--If x and y are friendly and y and z are friendly, then x and z are also friendly (allies are allies).

Now, if you write x ~ y that" x and y are friendly ", The above axiom can be rephrased as "relationship~is transitive".

Also, since it is considered that the reflex law (I am friendly with myself) and the symmetric law (if x and y are friendly, y and x are also friendly) are also considered to hold, ** relation~Has an equivalence relation **.

Therefore, we can see that all political parties are equivalence class and are divided without duplication.

Is there a third force?

Now, it turns out that all political parties are neatly divided into some camp, How many camps can exist? Is there a "third force" that neither NHK nor the people have?

Now, from Axiom 1, [x, y] ~ y holds for any political party[x, y], It is clear that the latter has fewer "number of parentheses used for notation" than the former.

In other words, you can find a friendly party (or NHK or citizens) with less parentheses for any party.

And as I continued to find a friendly party with fewer parentheses than myself, Eventually, you will find that the parentheses are 0, that is, NHK or the people.

Therefore, any political party [x, y] is always friendly with either NHK or the public. You can see that there is no third power because it is included in either equivalence class.

Conflicting manifest

According to Axiom 2, [x, y]! ~ X holds for any political party[x, y], This means that x belongs to a camp to which[x, y]does not belong, as all parties belong to the NHK or national camp according to the above discussion.

At this time, if [x, y] belongs to both camps, x does not belong to either camp, which is a contradiction.

Therefore, there can be no political party on the side of both NHK and the people in a consistent world. Also, if there is any political party, ** NHK and the people must be hostile **.

To put it the other way around, in a world where NHK and the people are friendly, there is no need for political parties.

When political parties contradict

If x and y are in the same camp, from Axiom 1, [x, y] belongs to the camp of y (the camp of x), and according to Axiom 2, it does not belong to the camp of x. It will be a contradiction.

In order to make the logic equivalent to this easier to handle in the program Consider a world where it is okay to have political parties belonging to both camps.

A friendly world

Consider the next axiom 2', which once weakened axiom 2.

[x, y]If x is the NHK camp, it belongs to the national camp, and if x is the national camp, it belongs to the NHK camp.

When Axiom 2 holds, then Axiom 2'also holds (under Axiom 1), The opposite is not true.

Also, under Axiom 2', there is no contradiction even if there are political parties that are on the side of both NHK and the people. Because even if a political party belongs to some camp, there is no way to tell that it does not belong to any camp, and no contradiction can occur.

For example, "The Party to Protect NHK from NHK" belongs to the NHK camp from Axiom 1 It is a contradiction because it does not belong to the NHK camp from Axiom 2. If this is Axiom 2', it can only be said that it belongs to the non-NHK camp and the national camp. There is no contradiction. It's just a matter of saying good friends.

In this friendly world, I think it is clear that the parties that are good friends with both camps are contradictory parties in the original world.

Therefore, if you examine the camp in the friendly world, you can determine the contradiction of the original world.

Faction function

A function that assigns the camp to which it belongs to any political party in a friendly world

T(x): x \mapsto \{ \{0\}, \{1\}, \{0, 1\} \}

Can be defined.

At this time, for any political party [x, y]

T(x) \cap T(y) \neq \varnothing \Rightarrow T([x, y]) = \{0, 1\} \\
T(x) \cap T(y) = \varnothing \Rightarrow T([x, y]) = T(y) 

You can see that holds true.

In other words, whether or not the political party [x, y] is inconsistent in the original world can be determined by recursively examining the camp in the friendly world.

Judge with Python

The contents of the previous section are used as they are in the program.

def T(party):
  if party in [0, 1]:
    return [party]
  else:
    p = T(party[0])
    q = T(party[1])
    if len(set(p) & set(q)) != 0:
      return [0, 1]
    else:       
      return q

Is there a contradiction between the party that protects the people from NHK and the party that protects NHK from the people?

print(T([[[0,1],[1,0]],0])) # => [0, 1]

Since they belong to both camps, it turned out to be inconsistent.

that's all. Please let me know if you make a mistake.

Addendum A: How many political parties are consistent?

Now define the political party rank R (x) as follows:

R(0) = R(1) = 0, \\  
R(x, y) = max(R(x), R(y)) + 1

For example, $ R ([1, 1]) = max (0, 0) + 1 = 1 $.

There are only two ranks, NHK and the public, and neither is inconsistent (apart from the actual situation).

There are four rank 1 political parties, [0, 0], [0, 1], [1, 0], [1, 1], of which two are consistent.

Rank 2 parties are obtained as a combination of each of the 6 groups of rank 1 and below, so we can see that there are 6 * 6 = 36. In addition, there are two NHK camps and two national camps among the consistent political parties of rank 1 or lower, and only when combined with the enemy camp, a consistent party can be created. You can see that there are 4 * 2 = 8 consistent parties of rank 2.

Similarly, it turns out that there are (2 + 4 + 36) ^ 2 = 1764 political parties of rank 3, of which only 12 * 6 = 72 are consistent.

This difference widens as the rank increases, so it can be said that ** almost all political parties in the world are inconsistent **.

In general, when the number of political parties of rank n is p_n and the number of consistent parties is c_n, they are

p_0 = 2, \\
p_n = (\Sigma_{k=1}^{n-1} p_k)^2 \\

When

c_0 = 2, \\
c_n = \frac{1}{2} (\Sigma_{k=1}^{n-1} c_k)^2

It is calculated by the recurrence formula of.

[End of Addendum]

Recommended Posts

Is there a contradiction between the party that protects the people from NHK and the party that protects NHK from the people?
What is the difference between a symbolic link and a hard link?
Is there a bias in the numbers that appear in the Fibonacci numbers?
[Free study] Is there a connection between Wikipedia updates and trends?
[Introduction to Python] What is the difference between a list and a tuple?
DJango memo: From the beginning (editing the management screen) There is a mystery
What is the difference between `pip` and` conda`?
The answer of "1/2" is different between python2 and 3
About the difference between "==" and "is" in python
What is the difference between Unix and Linux?
There is a pattern that the program did not stop when using Python threading
Checks if there is a specific character string for all files under the directory that is Python and outputs the target line
What is the difference between usleep, nanosleep and clock_nanosleep?
Find the part that is 575 from Wikipedia in Python
A library that monitors the life and death of other machines by pinging from Python
A program that just presses and releases the Esc key
A rough summary of the differences between Windows and Linux
Is there a secret to the frequency of pi numbers?
I made a Line bot that guesses the gender and age of a person from an image
A story that verified whether the number of coronas is really increasing rapidly among young people
[Python] Comprehension notation. Write a for statement simply. (A collection is the difference between an iterator and an iterator)