
    phV                         S r SSKrSSKrSSKJr  SSKJr  SSKJ	r	  SSK
Jr  \R                  rS$S jrS	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S r"S r#S r$S\"4-  u  r%r&r'r(\r)S  r*S! r+S" r,S# r-g)%zE
Example networks and subsystems to go along with the documentation.
    N   )
Transition)Network)	Subsystem)
all_statesc                     [         R                  " / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      nU SL a   [         R                  " / SQ/ SQ/ SQ/5      n OSn [        X[        SUR                  S	    S
9$ )a  A 3-node network of logic gates.

Diagram::

            +~~~~~~~~+
      +~~~~>|   A    |<~~~~+
      |     |  (OR)  +~~~+ |
      |     +~~~~~~~~+   | |
      |                  | |
      |                  v |
    +~+~~~~~~+       +~~~~~+~+
    |   B    |<~~~~~~+   C   |
    | (COPY) +~~~~~~>| (XOR) |
    +~~~~~~~~+       +~~~~~~~+

TPM:

+----------------+---------------+
| Previous state | Current state |
+----------------+---------------+
|    A, B, C     |    A, B, C    |
+================+===============+
|    0, 0, 0     |    0, 0, 0    |
+----------------+---------------+
|    1, 0, 0     |    0, 0, 1    |
+----------------+---------------+
|    0, 1, 0     |    1, 0, 1    |
+----------------+---------------+
|    1, 1, 0     |    1, 0, 0    |
+----------------+---------------+
|    0, 0, 1     |    1, 1, 0    |
+----------------+---------------+
|    1, 0, 1     |    1, 1, 1    |
+----------------+---------------+
|    0, 1, 1     |    1, 1, 1    |
+----------------+---------------+
|    1, 1, 1     |    1, 1, 0    |
+----------------+---------------+

Connectivity matrix:

+---+---+---+---+
| . | A | B | C |
+---+---+---+---+
| A | 0 | 0 | 1 |
+---+---+---+---+
| B | 1 | 0 | 1 |
+---+---+---+---+
| C | 1 | 1 | 0 |
+---+---+---+---+

.. note::
    |CM[i][j] = 1| means that there is a directed edge |(i,j)| from node
    |i| to node |j| and |CM[i][j] = 0| means there is no edge from |i| to
    |j|.
r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   FNr   cmnode_labelsnparrayr   LABELSshape)r   tpms     H/home/james-whalen/.local/lib/python3.13/site-packages/pyphi/examples.pybasic_networkr      sx    r ((	 	C 
U{XX
  36-399Q<+@AA    c                      g)z<The state of nodes in :func:`~pyphi.examples.basic_network`.r    r   r   r   basic_stater   f   s    r   c                  @    [        5       n [        5       n[        X5      $ )zSA subsystem containing all the nodes of the
:func:`~pyphi.examples.basic_network`.
)r   r   r   netstates     r   basic_subsystemr"   k   s     /CMES  r   c                      [         R                  " / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n [         R                  " / SQ/ SQ/ SQ/5      n[        XS	9$ )
a  Based on the basic_network, but with added selfloops and noisy edges.

Nodes perform deterministic functions of their inputs, but those inputs
may be flipped (i.e. what should be a 0 becomes a 1, and vice versa) with
probability epsilon (eps = 0.1 here).

Diagram::

               +~~+
               |  v
            +~~~~~~~~+
      +~~~~>|   A    |<~~~~+
      |     |  (OR)  +~~~+ |
      |     +~~~~~~~~+   | |
      |                  | |
      |                  v |
    +~+~~~~~~+       +~~~~~+~+
    |   B    |<~~~~~~+   C   |
  +>| (COPY) +~~~~~~>| (XOR) |<+
  | +~~~~~~~~+       +~~~~~~~+ |
  |   |                    |   |
  +~~~+                    +~~~+

)gMbX?RQ?Zd;?) rh?r$   x&1?)r&   Q?r'   )ʡE?r(   r%   )r)   Gz?r%   )g+?r*   r'   r   r   )r   r   r   r   r   r   s     r   basic_noisy_selfloop_networkr-   t   sZ    2 ((	 	C 
 
B 3r   c                  @    [        5       n [        5       n[        X5      $ )zbA subsystem containing all the nodes of the
:func:`~pyphi.examples.basic_noisy_selfloop_network`.
)r-   r   r   r   s     r   basic_noisy_selfloop_subsystemr/      s     '
(CMES  r   c                  ^   [         R                  " [        S5       V Vs/ s H@  n [        U 5      SS R	                  S5      SSS2    Vs/ s H  n[        U5      PM     snPMB     snn 5      nSU[         R                  " [         R                  " USS2SS24   S5      S:H  5      S4'   SU[         R                  " [         R                  " USS2S	S24   S5      S:H  5      S4'   SU[         R                  " [         R                  " USS2SS24   S5      S:  5      S4'   SU[         R                  " [         R                  " USS2S	S24   S5      S:  5      S4'   [         R                  " S
5      nSUSS2S4'   SUS	S2S4'   [        X#[        SUR                  S    S9$ s  snf s  snn f )a  The network for the residue example.

Current and previous state are all nodes OFF.

Diagram::

            +~~~~~~~+         +~~~~~~~+
            |   A   |         |   B   |
        +~~>| (AND) |         | (AND) |<~~+
        |   +~~~~~~~+         +~~~~~~~+   |
        |        ^               ^        |
        |        |               |        |
        |        +~~~~~+   +~~~~~+        |
        |              |   |              |
    +~~~+~~~+        +~+~~~+~+        +~~~+~~~+
    |   C   |        |   D   |        |   E   |
    |       |        |       |        |       |
    +~~~~~~~+        +~~~~~~~+        +~~~~~~~+

Connectivity matrix:

+---+---+---+---+---+---+
| . | A | B | C | D | E |
+---+---+---+---+---+---+
| A | 0 | 0 | 0 | 0 | 0 |
+---+---+---+---+---+---+
| B | 0 | 0 | 0 | 0 | 0 |
+---+---+---+---+---+---+
| C | 1 | 0 | 0 | 0 | 0 |
+---+---+---+---+---+---+
| D | 1 | 1 | 0 | 0 | 0 |
+---+---+---+---+---+---+
| E | 0 | 1 | 0 | 0 | 0 |
+---+---+---+---+---+---+
       N   r   r         )r3   r3   r   )r   r   rangebinzfillintwheresumzerosr   r   r   )xsr   r   s       r   residue_networkr@      s   H ((=B2Y=FQ))!,TrT232AQ23Y C 67CAB!Ga(A-.1256CAB!Ga(A-.1245CAB!Ga(1,-q0145CAB!Ga(1,-q01	&	BBqsAvJBqr1uI36-399Q<+@AA 	4s   +F)

F$F)
$F)
c                  0    [        5       n Sn[        X5      $ )zWThe subsystem containing all the nodes of the
:func:`~pyphi.examples.residue_network`.
r   r   r   r   r   )r@   r   r   s     r   residue_subsystemrC      s     
CES  r   c                      [         R                  " / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n [         R                  " / SQ/ SQ/ SQ/5      n[        X[        SU R                  S    S9$ )a5  A fully connected system of three XOR gates. In the state ``(0, 0, 0)``,
none of the elementary mechanisms exist.

Diagram::

    +~~~~~~~+       +~~~~~~~+
    |   A   +<~~~~~~+   B   |
    | (XOR) +~~~~~~>| (XOR) |
    +~+~~~~~+       +~~~~~+~+
      | ^               ^ |
      | |   +~~~~~~~+   | |
      | +~~~+   C   +~~~+ |
      +~~~~>| (XOR) +<~~~~+
            +~~~~~~~+

Connectivity matrix:

+---+---+---+---+
| . | A | B | C |
+---+---+---+---+
| A | 0 | 1 | 1 |
+---+---+---+---+
| B | 1 | 0 | 1 |
+---+---+---+---+
| C | 1 | 1 | 0 |
+---+---+---+---+
r	   r   r   r   r   r   Nr   r   r   r,   s     r   xor_networkrF      sk    8 ((	 	C 
 
B
 36-399Q<+@AAr   c                  0    [        5       n Sn[        X5      $ )zSThe subsystem containing all the nodes of the
:func:`~pyphi.examples.xor_network`.
r	   )rF   r   r   s     r   xor_subsystemrH     s     -CES  r   c                  J    [         R                  " / SQ/ SQ/ SQ/ SQ/5      n U $ )a;  A system of two general logic gates A and B such if they are in the same
state they stay the same, but if they are in different states, they flip
with probability 50%.

Diagram::

    +~~~~~+         +~~~~~+
    |  A  |<~~~~~~~~+  B  |
    |     +~~~~~~~~>|     |
    +~~~~~+         +~~~~~+

TPM:

+------+------+------+------+------+
|      |(0, 0)|(1, 0)|(0, 1)|(1, 1)|
+------+------+------+------+------+
|(0, 0)| 1.0  | 0.0  | 0.0  | 0.0  |
+------+------+------+------+------+
|(1, 0)| 0.0  | 0.5  | 0.5  | 0.0  |
+------+------+------+------+------+
|(0, 1)| 0.0  | 0.5  | 0.5  | 0.0  |
+------+------+------+------+------+
|(1, 1)| 0.0  | 0.0  | 0.0  | 1.0  |
+------+------+------+------+------+

Connectivity matrix:

+---+---+---+
| . | A | B |
+---+---+---+
| A | 0 | 1 |
+---+---+---+
| B | 1 | 0 |
+---+---+---+
)      ?        rK   rK   )rK         ?rL   rK   )rK   rK   rK   rJ   r   r   r   s    r   cond_depend_tpmrO     s+    H ((	 C Jr   c                  b    [         R                  " / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n U $ )a	  A system of three general logic gates A, B and C such that: if A and B
are in the same state then they stay the same; if they are in different
states, they flip if C is ON and stay the same if C is OFF; and C is ON 50%
of the time, independent of the previous state.

Diagram::

    +~~~~~+         +~~~~~+
    |  A  +~~~~~~~~>|  B  |
    |     |<~~~~~~~~+     |
    +~+~~~+         +~~~+~+
      | ^             ^ |
      | |   +~~~~~+   | |
      | ~~~~+  C  +~~~+ |
      +~~~~>|     |<~~~~+
            +~~~~~+

TPM:

+---------+---------+---------+---------+---------+---------+---------+---------+---------+
|         |(0, 0, 0)|(1, 0, 0)|(0, 1, 0)|(1, 1, 0)|(0, 0, 1)|(1, 0, 1)|(0, 1, 1)|(1, 1, 1)|
+---------+---------+---------+---------+---------+---------+---------+---------+---------+
|(0, 0, 0)|   0.5   |   0.0   |   0.0   |   0.0   |   0.5   |   0.0   |   0.0   |   0.0   |
+---------+---------+---------+---------+---------+---------+---------+---------+---------+
|(1, 0, 0)|   0.0   |   0.5   |   0.0   |   0.0   |   0.0   |   0.5   |   0.0   |   0.0   |
+---------+---------+---------+---------+---------+---------+---------+---------+---------+
|(0, 1, 0)|   0.0   |   0.0   |   0.5   |   0.0   |   0.0   |   0.0   |   0.5   |   0.0   |
+---------+---------+---------+---------+---------+---------+---------+---------+---------+
|(1, 1, 0)|   0.0   |   0.0   |   0.0   |   0.5   |   0.0   |   0.0   |   0.0   |   0.5   |
+---------+---------+---------+---------+---------+---------+---------+---------+---------+
|(0, 0, 1)|   0.5   |   0.0   |   0.0   |   0.0   |   0.5   |   0.0   |   0.0   |   0.0   |
+---------+---------+---------+---------+---------+---------+---------+---------+---------+
|(1, 0, 1)|   0.0   |   0.0   |   0.5   |   0.0   |   0.0   |   0.0   |   0.5   |   0.0   |
+---------+---------+---------+---------+---------+---------+---------+---------+---------+
|(0, 1, 1)|   0.0   |   0.5   |   0.0   |   0.0   |   0.0   |   0.5   |   0.0   |   0.0   |
+---------+---------+---------+---------+---------+---------+---------+---------+---------+
|(1, 1, 1)|   0.0   |   0.0   |   0.0   |   0.5   |   0.0   |   0.0   |   0.0   |   0.5   |
+---------+---------+---------+---------+---------+---------+---------+---------+---------+

Connectivity matrix:

+---+---+---+---+
| . | A | B | C |
+---+---+---+---+
| A | 0 | 1 | 0 |
+---+---+---+---+
| B | 1 | 0 | 0 |
+---+---+---+---+
| C | 1 | 1 | 0 |
+---+---+---+---+
)rL   rK   rK   rK   rL   rK   rK   rK   )rK   rL   rK   rK   rK   rL   rK   rK   )rK   rK   rL   rK   rK   rK   rL   rK   )rK   rK   rK   rL   rK   rK   rK   rL   rM   rN   s    r   cond_independ_tpmrQ   J  s7    h ((00000000	 	C Jr   c                  p   Sn SU -  n[         R                  " X45      n[        [        U 5      5       H  u  p4[	        U 5       Vs/ s H  nSPM     nnUS   S:X  d	  US   S:X  a  SUS'   US   S:X  a
  SUS'   SUS'   US   S:X  a
  SUS'   SUS'   US   SUS	   -  s=:X  a  S:X  a  O  OSUS'   US   S:X  a  US   S:X  a  SUS
'   US
   S:X  a
  SUS	'   SUS'   XbUSS24'   M     [         R
                  " / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/	5      n[        X'[        SUR                  S    S9$ s  snf )a  A version of the primary example from the IIT 3.0 paper with
deterministic COPY gates on each connection. These copy gates essentially
function as propagation delays on the signal between OR, AND and XOR gates
from the original system.

The current and previous states of the network are also selected to mimic
the corresponding states from the IIT 3.0 paper.

Diagram::

                               +----------+
            +------------------+ C (COPY) +<----------------+
            v                  +----------+                 |
    +-------+-+                                           +-+-------+
    |         |                +----------+               |         |
    | A (OR)  +--------------->+ B (COPY) +-------------->+ D (XOR) |
    |         |                +----------+               |         |
    +-+-----+-+                                           +-+-----+-+
      |     ^                                               ^     |
      |     |                                               |     |
      |     |   +----------+                 +----------+   |     |
      |     +---+ H (COPY) +<----+     +---->+ F (COPY) +---+     |
      |         +----------+     |     |     +----------+         |
      |                          |     |                          |
      |                        +-+-----+-+                        |
      |         +----------+   |         |   +----------+         |
      +-------->+ I (COPY) +-->| G (AND) |<--+ E (COPY) +<--------+
                +----------+   |         |   +----------+
                               +---------+

Connectivity matrix:

+---+---+---+---+---+---+---+---+---+---+
| . | A | B | C | D | E | F | G | H | I |
+---+---+---+---+---+---+---+---+---+---+
| A | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
+---+---+---+---+---+---+---+---+---+---+
| B | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
+---+---+---+---+---+---+---+---+---+---+
| C | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
+---+---+---+---+---+---+---+---+---+---+
| D | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 |
+---+---+---+---+---+---+---+---+---+---+
| E | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
+---+---+---+---+---+---+---+---+---+---+
| F | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
+---+---+---+---+---+---+---+---+---+---+
| G | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 |
+---+---+---+---+---+---+---+---+---+---+
| H | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
+---+---+---+---+---+---+---+---+---+---+
| I | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
+---+---+---+---+---+---+---+---+---+---+

States:

In the IIT 3.0 paper example, the previous state of the system has only the
XOR gate ON. For the propagation delay network, this corresponds to a state
of
``(0, 0, 0, 1, 0, 0, 0, 0, 0)``.

The current state of the IIT 3.0 example has only the OR gate ON. By
advancing the propagation delay system two time steps, the current state
``(1, 0, 0, 0, 0, 0, 0, 0, 0)`` is achieved, with corresponding previous
state ``(0, 0, 1, 0, 1, 0, 0, 0, 0)``.
	   r2   r   r         r6   r5   r3      N)	r   r   r   r   r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   r   	r   r=   	enumerater   r7   r   r   r   r   )	num_nodes
num_statesr   previous_state_indexpreviousicurrent_stater   s           r   propagation_delay_networkr_     s~   F IiJ
((J*
+C*3Jy4I*J&$))$45$4q$45A;!x{a/ M!A;! M! M!A;! M! M!A;!hqk/.Q. M!A;!q 0 M!A;! M! M!'4 !#$# +K& 
.........0 
1B 36-399Q<+@AA9 6s   D3c                      [         R                  " / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n [        U [        SU R                  S    S9$ )zmA network of micro elements which has greater integrated information
after coarse graining to a macro scale.
)333333?ra   ra   ra   )ra   ra   rJ   rJ   )rJ   rJ   ra   ra   )rJ   rJ   rJ   rJ   Nr   r   r   rN   s    r   macro_networkrc     se     ((((((((((((((((((* +C  3F=CIIaL$9::r   c                  0    [        5       n Sn[        X5      $ )zOA subsystem containing all the nodes of
:func:`~pyphi.examples.macro_network`.
r   r   r   r   )rc   r   r   s     r   macro_subsystemrf   
  s     /CES  r   c            	         Sn SU -  n[         R                  " X45      n[        [        U 5      5       H}  u  p4[	        U 5       Vs/ s H  nSPM     nnUS   S:X  a
  SUS'   SUS'   US   S:X  a  US   (       a  SUS'   US   S:X  a
  SUS'   SUS'   US   S:X  a  US   S:X  a  SUS'   XbUSS24'   M     [         R
                  " / S	Q/ S	Q/ S
Q/ SQ/ SQ/ SQ/5      n[        X'[        SUR                  S    S9$ s  snf )a^  A micro-network to demonstrate blackboxing.

Diagram::

                            +----------+
      +-------------------->+ A (COPY) + <---------------+
      |                     +----------+                 |
      |                 +----------+                     |
      |     +-----------+ B (COPY) + <-------------+     |
      v     v           +----------+               |     |
    +-+-----+-+                                  +-+-----+-+
    |         |                                  |         |
    | C (AND) |                                  | F (AND) |
    |         |                                  |         |
    +-+-----+-+                                  +-+-----+-+
      |     |                                      ^     ^
      |     |           +----------+               |     |
      |     +---------> + D (COPY) +---------------+     |
      |                 +----------+                     |
      |                     +----------+                 |
      +-------------------> + E (COPY) +-----------------+
                            +----------+

Connectivity Matrix:

+---+---+---+---+---+---+---+
| . | A | B | C | D | E | F |
+---+---+---+---+---+---+---+
| A | 0 | 0 | 1 | 0 | 0 | 0 |
+---+---+---+---+---+---+---+
| B | 0 | 0 | 1 | 0 | 0 | 0 |
+---+---+---+---+---+---+---+
| C | 0 | 0 | 0 | 1 | 1 | 0 |
+---+---+---+---+---+---+---+
| D | 0 | 0 | 0 | 0 | 0 | 1 |
+---+---+---+---+---+---+---+
| E | 0 | 0 | 0 | 0 | 0 | 1 |
+---+---+---+---+---+---+---+
| F | 1 | 1 | 0 | 0 | 0 | 0 |
+---+---+---+---+---+---+---+


In the documentation example, the state is (0, 0, 0, 0, 0, 0).
rV   r2   r   r3   r   r6   r5   Nr   r   r   r   r   r   )r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   rb   rW   )rY   rZ   r   indexprevious_stater]   r^   r   s           r   blackbox_networkrl     s/   Z IiJ
((J*
+C!*:i+@!A$))$45$4q$45!! M! M!!!nQ&7 M!!! M! M!!!nQ&71&< M!%E1H "B 
 
B 3}		!(=>>- 6s   C:c                      [         R                  " / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n [        U [        SU R                  S    S9$ )	zA network of three elements which follows the logic of the Rule 110
cellular automaton with current and previous state (0, 0, 0).
r	   r   r   r   rE   Nr   rb   r   rN   s    r   rule110_networkrn   ^  sL     ((I  C 3F=CIIaL$9::r   c                     [         R                  " / / SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ S	QP/ S
QP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ S QP5      n [         R                  " / SQ/ SQ/ SQ/ SQ/ SQ/5      n[        X[        S!U R                  S"    S#9$ )$zXA network of three elements which follows the logic of the Rule 154
cellular automaton.
rB   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   Nr   r   r   r,   s     r   rule154_networkrp   m  s    (( !!! 	! 		!
 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!  	!!" 	#!$ 	%!& 	'!( 	)!* 	+!, 	-!. 	/!0 	1!2 	3!4 	5!6 	7!8 	9!: 	;!< 	=!> 	?!@ 	A! !CD 
 
B 36-399Q<+@AAr   c            	         [         R                  " / / SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP5      n [         R                  " / S	Q/ SQ/ S
Q/ SQ/ SQ/ SQ/5      n[        X[        SU R                  S    S9$ )z9The network shown in Figure 1A of the 2014 IIT 3.0 paper.)r   r   r   r   r   r   rh   )r   r   r   r   r   r   )r   r   r   r   r   r   )r   r   r   r   r   r   )r   r   r   r   r   r   )r   r   r   r   r   r   )r   r   r   r   r   r   )r   r   r   r   r   r   ri   Nr   r   r   r,   s     r   fig1arr     s[   
(( AAA 	A 		A
 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A  	!A" 	#A$ 	%A& 	'A( 	)A* 	+A, 	-A. 	/A0 	1A2 	3A4 	5A6 	7A8 	9A: 	;A< 	=A> 	?A@ 	AAB 	CAD 	EAF 	GAH 	IAJ 	KAL 	MAN 	OAP 	QAR 	SAT 	UAV 	WAX 	YAZ 	[A\ 	]A^ 	_A` 	aAb 	cAd 	eAf 	gAh 	iAj 	kAl 	mAn 	oAp 	qAr 	sAt 	uAv 	wAx 	yAz 	{A| 	}A~ 	A@ 	AA ACD 
 
B 36-399Q<+@AAr   c                     [         R                  " / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n [         R                  " / SQ/ SQ/ SQ/ SQ/5      n[        X[        SU R                  S    S9$ )z9The network shown in Figure 3A of the 2014 IIT 3.0 paper.)rL   r   r   r   re   r   r   r   r   Nr   r   r   r,   s     r   fig3aru     s    
((! C$ 
	 
B 36-399Q<+@AAr   c                     [         R                  " / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n [         R                  " / SQ/ SQ/ SQ/ SQ/5      n[        X[        SU R                  S    S9$ )z9The network shown in Figure 3B of the 2014 IIT 3.0 paper.re   rt   Nr   r   r   r,   s     r   fig3brw   	  s    
((! C$ 
	 
B 36-399Q<+@AAr   c                      [         R                  " / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n [         R                  " / SQ/ SQ/ SQ/5      n[        X[        SU R                  S	    S
9$ )a`  The network shown in Figure 4 of the 2014 IIT 3.0 paper.

Diagram::

            +~~~~~~~+
      +~~~~>|   A   |<~~~~+
      | +~~~+ (OR)  +~~~+ |
      | |   +~~~~~~~+   | |
      | |               | |
      | v               v |
    +~+~~~~~+       +~~~~~+~+
    |   B   |<~~~~~~+   C   |
    | (AND) +~~~~~~>| (XOR) |
    +~~~~~~~+       +~~~~~~~+

r	   r
   r   r   r   r   rE   Nr   r   r   r,   s     r   fig4ry   &  sk    " ((	 	C 
 
B
 36-399Q<+@AAr   c                      [         R                  " / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n [         R                  " / SQ/ SQ/ SQ/5      n[        X[        SU R                  S    S	9$ )
aR  The network shown in Figure 5A of the 2014 IIT 3.0 paper.

Diagram::

             +~~~~~~~+
       +~~~~>|   A   |<~~~~+
       |     | (AND) |     |
       |     +~~~~~~~+     |
       |                   |
    +~~+~~~~~+       +~~~~~+~~+
    |    B   |<~~~~~~+   C    |
    | (COPY) +~~~~~~>| (COPY) |
    +~~~~~~~~+       +~~~~~~~~+

r	   r
   r   r   r   r   r   r   Nr   r   r   r,   s     r   fig5ar|   I  k      ((	 	C 
 
B
 36-399Q<+@AAr   c                      [         R                  " / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n [         R                  " / SQ/ SQ/ SQ/5      n[        X[        SU R                  S	    S
9$ )aN  The network shown in Figure 5B of the 2014 IIT 3.0 paper.

Diagram::

             +~~~~~~~+
        +~~~~+   A   +~~~~+
        |    | (AND) |    |
        |    +~~~~~~~+    |
        v                 v
    +~~~~~~~~+       +~~~~~~~~+
    |    B   |<~~~~~~+   C    |
    | (COPY) +~~~~~~>| (COPY) |
    +~~~~~~~~+       +~~~~~~~~+

r   r   r   r   rE   r
   r{   Nr   r   r   r,   s     r   fig5br   k  r}   r   r5   c            
         [         R                  " / / SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ S	QP/ S
QP/ S
QP/ SQP/ S	QP/ SQP/ SQP/ SQP/ S	QP/ S
QP/ S
QP/ S	QP/ S	QP/ S
QP/ SQP/ SQP/ S	QP/ S
QP/ S
QP/ SQP/ S	QP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ SQP/ S QP/ S!QP/ S"QP/ S"QP/ S#QP/ S!QP/ S$QP/ SQP/ S QP/ S!QP/ S"QP/ S"QP/ S!QP/ S!QP/ S"QP/ SQP/ S QP/ S!QP/ S"QP/ S"QP/ S#QP/ S!QP/ S$QP5      n [         R                  " / S%Q/ SQ/ S&Q/ S'Q/ SQ/ SQ/ SQ/5      n[        X[        S(U R                  S)    S*9$ )+z9The network shown in Figure 5B of the 2014 IIT 3.0 paper.)r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   Nr   r   r   r,   s     r   fig16r     s   
(( AAA 	A 		A
 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A  	!A" 	#A$ 	%A& 	'A( 	)A* 	+A, 	-A. 	/A0 	1A2 	3A4 	5A6 	7A8 	9A: 	;A< 	=A> 	?A@ 	AAB 	CAD 	EAF 	GAH 	IAJ 	KAL 	MAN 	OAP 	QAR 	SAT 	UAV 	WAX 	YAZ 	[A\ 	]A^ 	_A` 	aAb 	cAd 	eAf 	gAh 	iAj 	kAl 	mAn 	oAp 	qAr 	sAt 	uAv 	wAx 	yAz 	{A| 	}A~ 	A@ 	AAB 	CAD 	EAF 	GAH 	IAJ 	KAL 	MAN 	OAP 	QAR 	SAT 	UAV 	WAX 	YAZ 	[A\ 	]A^ 	_A` 	aAb 	cAd 	eAf 	gAh 	iAj 	kAl 	mAn 	oAp 	qAr 	sAt 	uAv 	wAx 	yAz 	{A| 	}A~ 	A@ 	AAB 	CAD 	EAF 	GAH 	IAJ 	KAL 	MAN 	OAP 	QAR 	SAT 	UAV 	WAX 	YAZ 	[A\ 	]A^ 	_A` 	aAb 	cAd 	eAf 	gAh 	iAj 	kAl 	mAn 	oAp 	qAr 	sAt 	uAv 	wAx 	yAz 	{A| 	}A~ 	A@ 	AA ACD 
 
B 36-399Q<+@AAr   c                      [         R                  " / SQ/ SQ/ SQ/ SQ/5      n [         R                  " SS/SS//5      n[        XSS9$ )z`The actual causation example network, consisting of an ``OR`` and
``AND`` gate with self-loops.
rt   )r   r   r   r   r   r   r   r   r   )ORANDrb   r+   r,   s     r   actual_causationr   '  sU     ((	 C 
	
A	
A 
B 366r   c                     [         R                  " / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n [         R                  " / SQ/ SQ/ SQ/ SQ/5      n[        X[        SU R                  S    S9$ )zThe disjunction-conjunction example from Actual Causation Figure 7.

A network of four elements, one output ``D`` with three inputs ``A B C``.
The output turns ON if ``A`` AND ``B`` are ON or if ``C`` is ON.
re   r   Nr   rb   r   r,   s     r   disjunction_conjunction_networkr   8  s     ((! C$ 
	 
B 3}		!(=>>r   c                      [         R                  " / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/5      n [         R                  " / SQ/ SQ/ SQ/5      n[        X/ SQS9nSnSn[        X#USS	5      $ )
zMThe |Transition| for the prevention example from Actual Causation
Figure 5D.
)rL   rL   r   )rL   rL   r   r
   r	   )ABFrb   r   )r   r   )r2   )r   r   r   r   )r   r   networkx_statey_states        r   
preventionr   Y  sv     ((	 	C 
 
B
 c?;GGGg>>r   )F).__doc__stringnumpyr   actualr   r   r   	subsystemr   utilsr   ascii_uppercaser   r   r   r"   r-   r/   r@   rC   rF   rH   rO   rQ   r_   rc   rf   rl   rn   rp   rr   ru   rw   ry   r|   r   fig6fig8fig9fig10fig14r   r   r   r   r   r   r   <module>r      s   
       			KB\
!*Z!0Bf!+B\!*Z>BeBP;.!H?V;-B`LB^B:B: BFBDBF tg+ dD% 	MBf7"?B?r   