import numpy as np
A = np.array([[3, 0], [3, 1]])
B = np.array([[3, 3], [0, 1]])

# Verify that first row is weakly dominated by second row
all(A[0,:] <= A[1,:]) and any(A[0,:] < A[1,:])

# Verify that first column is weakly dominated by second column
all(B[:,0] <= B[:,1]) and any(B[:,0] < B[:,1])

"""
Explanation: Rationalisation

Definition of a strictly dominated strategy
Video
In a two player game $(A, B)\in\mathbb{{R^{m \times n}}^2}$ a strategy $s$ is dominated by strategy $\bar s$ if for all strategies of the other player $t$:
$$
u(s, t) < u(\bar s, t)
$$

For example if we consider the Prisoner's Dilemma:
$$
A =
\begin{pmatrix}
    3 & 0\
    5 & 1
\end{pmatrix}\qquad
B =
\begin{pmatrix}
    3 & 5\
    0 & 1
\end{pmatrix}
$$

we see that $A_{2j} > A_{1j}$ for all $j$, so we can say that the row players' first strategy is dominated by its second strategy.
we see that $B_{i2} > B_{i1}$ for all $i$, so we can say that the column players' first strategy is dominated by its second strategy.


Definition of a weakly dominated strategy
Video
In a two player game $(A, B)\in\mathbb{{R^{m \times n}}^2}$ a strategy $s$ is weakly dominated by strategy $\bar s$ if for all strategies of the other player $t$:
$$
u(s, t) \leq u(\bar s, t)
$$
and there exists a $t'$ such that:
$$
u(s, t') < u(\bar s, t')
$$

For example if we consider the modified version of the previous game:
$$
A =
\begin{pmatrix}
    3 & 0\
    3 & 1
\end{pmatrix}\qquad
B =
\begin{pmatrix}
    3 & 3\
    0 & 1
\end{pmatrix}
$$

we see that $A_{2j} \geq A_{1j}$ for all $j$ and $A_{22} > A_{12}$, so we can say that the row players' first strategy is weakly dominated by its second strategy.
we see that $B_{i2} \geq B_{i1}$ for all $i$ and $B_{22} > B_{21}$, so we can say that the column players' first strategy is weakly dominated by its second strategy.

We can use numpy to verify if a strategy is weakly/strictly dominated:
End of explanation
"""


A = np.array([[10, 5, 1], [10, 5, 4]])
B = np.array([[1, 1, -2], [1, 0, 2]])
all(A[0,:] <= A[1,:]) and any(A[0,:] < A[1,:])

"""
Explanation: Definition  of common knowledge of rationality
Video
An important aspect of Game Theory and the tool that we have in fact been using so far is to assume that players are rational. However we can (and need) to go further:

The players are rational;
The players all know that the other players are rational;
The players all know that the other players know that they are rationals;
...

This chain of assumptions is called Common Knowledge of Rationality (CKR). By applying the CKR assumption we can attempt to predict rational behaviour through the iterated elimination of weakly dominated strategies. This process is called rationalisation.
Let us consider the following game:
$$
A =
\begin{pmatrix}
    10 & 5 & 1\
    10 & 5 & 4
\end{pmatrix}\qquad
B =
\begin{pmatrix}
    1 & 1 & -2\
    1 & 0 & 2
\end{pmatrix}
$$
We see that the rows players' first strategy is weakly dominated by its second.
End of explanation
"""


