Skip to content

IIT 4.0

iitx.measures.iit4

IIT 4.0: system-level integrated information (Albantakis et al. 2023).

The system level of the 4.0 pipeline: condition the candidate system on its background (effect side: background clamped at the current state; cause side: causal marginalization conditional on the current state, Eq. 4), find the maximal cause-effect state the system specifies (max intrinsic information, Eqs. 5-13), then find the minimum partition over the directional system partitions (Eqs. 14-23): phi_s is the intrinsic information about the maximal states lost under that partition, minimized across the cause and effect sides.

Everything here is pure tensor algebra plus min/max reductions — no linear programs — so system_phi composes with jit, vmap (batching over systems and states), and grad (differentiable almost everywhere, with exact subgradients at ties).

Conventions inherited from the oracle rather than the paper are recorded in docs/notes/oracle-findings.md; the load-bearing ones here: the reported φ is clamped by the paper's |·|₊ while selection runs on signed values (signed_phi is kept, not least for gradients); the partition normalization is 1 / (number of distinct severed connections); a partition with φ ≤ 0 short-circuits the search; and ties of the specified state resolve by maximal φ_s, then the oracle's state-iteration order.

PRECISION = 1e-13 module-attribute

Quantization applied to values before any comparison (PyPhi's 4.0 PRECISION).

CauseEffectState dataclass

The maximal cause-effect state a system specifies (Eqs. 12-13).

Attributes:

Name Type Description
cause_state Array

The past state the system specifies most, shape (n,). Units outside the candidate system carry no information; their entries are the first-occurrence tie convention, not a specification.

effect_state Array

The future state the system specifies most, shape (n,).

phi_cause Array

Intrinsic cause information ii_c of the cause state, in ibits.

phi_effect Array

Intrinsic effect information ii_e of the effect state, in ibits.

Source code in src/iitx/measures/iit4.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
@jax.tree_util.register_dataclass
@dataclasses.dataclass(frozen=True)
class CauseEffectState:
	"""The maximal cause-effect state a system specifies (Eqs. 12-13).

	Attributes:
		cause_state: The past state the system specifies most, shape ``(n,)``. Units
			outside the candidate system carry no information; their entries are the
			first-occurrence tie convention, not a specification.
		effect_state: The future state the system specifies most, shape ``(n,)``.
		phi_cause: Intrinsic cause information ``ii_c`` of the cause state, in ibits.
		phi_effect: Intrinsic effect information ``ii_e`` of the effect state, in ibits.

	"""

	cause_state: jax.Array
	effect_state: jax.Array
	phi_cause: jax.Array
	phi_effect: jax.Array

SystemPhi dataclass

System integrated information and its minimum partition (Eqs. 19-23).

Attributes:

Name Type Description
phi Array

System integrated information phi_s = min(phi_cause, phi_effect) at the minimum partition, clamped at zero by the paper's |·|₊ (as the primary oracle does), unnormalized, in ibits. Zero means reducible.

signed_phi Array

The unclamped value — negative when a partition increases the specified probabilities. Selection uses signed values; keep this for gradients, which the clamp would zero out in the reducible region.

normalized_phi Array

Clamped phi divided by the number of connections the minimum partition severs (normalization is used only to select the partition).

phi_cause Array

Cause-side φ at the minimum partition (signed).

phi_effect Array

Effect-side φ at the minimum partition (signed).

cut_index Array

Index of the minimum partition in the canonical cut table (:func:iitx.enumeration.system_cuts for this candidate).

cause_effect_state CauseEffectState

The maximal cause-effect state the φ values refer to.

Source code in src/iitx/measures/iit4.py
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
@jax.tree_util.register_dataclass
@dataclasses.dataclass(frozen=True)
class SystemPhi:
	"""System integrated information and its minimum partition (Eqs. 19-23).

	Attributes:
		phi: System integrated information ``phi_s = min(phi_cause, phi_effect)`` at the
			minimum partition, clamped at zero by the paper's ``|·|₊`` (as the primary
			oracle does), unnormalized, in ibits. Zero means reducible.
		signed_phi: The unclamped value — negative when a partition *increases* the
			specified probabilities. Selection uses signed values; keep this for
			gradients, which the clamp would zero out in the reducible region.
		normalized_phi: Clamped ``phi`` divided by the number of connections the minimum
			partition severs (normalization is used only to select the partition).
		phi_cause: Cause-side φ at the minimum partition (signed).
		phi_effect: Effect-side φ at the minimum partition (signed).
		cut_index: Index of the minimum partition in the canonical cut table
			(:func:`iitx.enumeration.system_cuts` for this candidate).
		cause_effect_state: The maximal cause-effect state the φ values refer to.

	"""

	phi: jax.Array
	signed_phi: jax.Array
	normalized_phi: jax.Array
	phi_cause: jax.Array
	phi_effect: jax.Array
	cut_index: jax.Array
	cause_effect_state: CauseEffectState

PartitionPhis dataclass

Per-partition signed φ values at the resolved specified states.

The raw material behind the minimum-partition selection, exposed for relaxations and landscape analysis (:mod:iitx.relax).

Attributes:

Name Type Description
phi Array

Signed min(phi_cause, phi_effect) of every partition, shape (P,).

phi_cause Array

Cause-side signed φ per partition, shape (P,).

phi_effect Array

Effect-side signed φ per partition, shape (P,).

severed Array

Connections severed by each partition (the normalization), shape (P,).

cause_effect_state CauseEffectState

The resolved maximal cause-effect state.

Source code in src/iitx/measures/iit4.py
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
@jax.tree_util.register_dataclass
@dataclasses.dataclass(frozen=True)
class PartitionPhis:
	"""Per-partition signed φ values at the resolved specified states.

	The raw material behind the minimum-partition selection, exposed for relaxations
	and landscape analysis (:mod:`iitx.relax`).

	Attributes:
		phi: Signed ``min(phi_cause, phi_effect)`` of every partition, shape ``(P,)``.
		phi_cause: Cause-side signed φ per partition, shape ``(P,)``.
		phi_effect: Effect-side signed φ per partition, shape ``(P,)``.
		severed: Connections severed by each partition (the normalization), shape
			``(P,)``.
		cause_effect_state: The resolved maximal cause-effect state.

	"""

	phi: jax.Array
	phi_cause: jax.Array
	phi_effect: jax.Array
	severed: jax.Array
	cause_effect_state: CauseEffectState

Distinctions dataclass

The causal distinctions of a candidate system (Eqs. 27-48), as stacked arrays.

Row k describes the mechanism whose mask is row k of iitx.enumeration.subsets(n, nonempty=True) restricted to the candidate; rows for mechanisms not contained in the candidate, and mechanisms that specify no congruent irreducible cause-effect, have exists false and zeros elsewhere.

Attributes:

Name Type Description
exists Array

Which mechanisms are distinctions (φ_d > 0 and congruent), shape (D,).

phi Array

Distinction integrated information phi_d = min(phi_cause, phi_effect), shape (D,).

mechanism Array

Mechanism masks, shape (D, n).

cause_purview Array

Maximally irreducible cause purview masks, shape (D, n).

effect_purview Array

Maximally irreducible effect purview masks, shape (D, n).

cause_state Array

Specified cause states (values outside the purview are conventions, not specifications), shape (D, n).

effect_state Array

Specified effect states, shape (D, n).

phi_cause Array

Cause-side φ maxima, shape (D,).

phi_effect Array

Effect-side φ maxima, shape (D,).

Source code in src/iitx/measures/iit4.py
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
@jax.tree_util.register_dataclass
@dataclasses.dataclass(frozen=True)
class Distinctions:
	"""The causal distinctions of a candidate system (Eqs. 27-48), as stacked arrays.

	Row ``k`` describes the mechanism whose mask is row ``k`` of
	``iitx.enumeration.subsets(n, nonempty=True)`` restricted to the candidate; rows for
	mechanisms not contained in the candidate, and mechanisms that specify no congruent
	irreducible cause-effect, have ``exists`` false and zeros elsewhere.

	Attributes:
		exists: Which mechanisms are distinctions (φ_d > 0 and congruent), shape ``(D,)``.
		phi: Distinction integrated information ``phi_d = min(phi_cause, phi_effect)``,
			shape ``(D,)``.
		mechanism: Mechanism masks, shape ``(D, n)``.
		cause_purview: Maximally irreducible cause purview masks, shape ``(D, n)``.
		effect_purview: Maximally irreducible effect purview masks, shape ``(D, n)``.
		cause_state: Specified cause states (values outside the purview are conventions,
			not specifications), shape ``(D, n)``.
		effect_state: Specified effect states, shape ``(D, n)``.
		phi_cause: Cause-side φ maxima, shape ``(D,)``.
		phi_effect: Effect-side φ maxima, shape ``(D,)``.

	"""

	exists: jax.Array
	phi: jax.Array
	mechanism: jax.Array
	cause_purview: jax.Array
	effect_purview: jax.Array
	cause_state: jax.Array
	effect_state: jax.Array
	phi_cause: jax.Array
	phi_effect: jax.Array

Relations dataclass

The causal relations of a distinction set, in aggregate (Eqs. 49-56).

Relations are never enumerated — their number is doubly exponential — but their total φ and count have closed forms (S3 Text of Albantakis et al. 2023), which is all that Φ needs.

Attributes:

Name Type Description
sum_phi Array

sum(phi_r) over all relations, in ibits.

count Array

Number of relations (including self-relations with φ_r > 0).

Source code in src/iitx/measures/iit4.py
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
@jax.tree_util.register_dataclass
@dataclasses.dataclass(frozen=True)
class Relations:
	"""The causal relations of a distinction set, in aggregate (Eqs. 49-56).

	Relations are never enumerated — their number is doubly exponential — but their
	total φ and count have closed forms (S3 Text of Albantakis et al. 2023), which is
	all that Φ needs.

	Attributes:
		sum_phi: ``sum(phi_r)`` over all relations, in ibits.
		count: Number of relations (including self-relations with φ_r > 0).

	"""

	sum_phi: jax.Array
	count: jax.Array

PhiStructure dataclass

The Φ-structure of a candidate system: distinctions, relations, and Φ (Eqs. 57-59).

Attributes:

Name Type Description
system SystemPhi

The system-level irreducibility analysis (φ_s and its partition).

distinctions Distinctions

The congruent causal distinctions.

relations Relations

The relations, in aggregate.

big_phi Array

Structure integrated information Φ = sum(phi_d) + sum(phi_r).

Source code in src/iitx/measures/iit4.py
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
@jax.tree_util.register_dataclass
@dataclasses.dataclass(frozen=True)
class PhiStructure:
	"""The Φ-structure of a candidate system: distinctions, relations, and Φ (Eqs. 57-59).

	Attributes:
		system: The system-level irreducibility analysis (φ_s and its partition).
		distinctions: The congruent causal distinctions.
		relations: The relations, in aggregate.
		big_phi: Structure integrated information ``Φ = sum(phi_d) + sum(phi_r)``.

	"""

	system: SystemPhi
	distinctions: Distinctions
	relations: Relations
	big_phi: jax.Array

Complex dataclass

One complex of a condensed system.

Attributes:

Name Type Description
units tuple[int, ...]

The complex's units.

analysis SystemPhi

Its system φ analysis.

Source code in src/iitx/measures/iit4.py
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
@dataclasses.dataclass(frozen=True)
class Complex:
	"""One complex of a condensed system.

	Attributes:
		units: The complex's units.
		analysis: Its system φ analysis.

	"""

	units: tuple[int, ...]
	analysis: SystemPhi

cause_effect_state(system, state, candidate=None)

Find the maximal cause-effect state a candidate system specifies.

The intrinsic information of each candidate past/future state is its selectivity times its informativeness (Eqs. 5-9); the specified state maximizes it, with ties broken by first occurrence in canonical (little-endian) state order.

Parameters:

Name Type Description Default
system System

The system.

required
state Array

Current state of the whole system, shape (n,).

required
candidate Array | None

Mask of the candidate system's units; None means all units.

None

Returns:

Type Description
CauseEffectState

The maximal cause-effect state with its intrinsic information on both sides.

Source code in src/iitx/measures/iit4.py
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
def cause_effect_state(
	system: System,
	state: jax.Array,
	candidate: jax.Array | None = None,
) -> CauseEffectState:
	"""Find the maximal cause-effect state a candidate system specifies.

	The intrinsic information of each candidate past/future state is its selectivity
	times its informativeness (Eqs. 5-9); the specified state maximizes it, with ties
	broken by first occurrence in canonical (little-endian) state order.

	Args:
		system: The system.
		state: Current state of the whole system, shape ``(n,)``.
		candidate: Mask of the candidate system's units; ``None`` means all units.

	Returns:
		The maximal cause-effect state with its intrinsic information on both sides.

	"""
	if candidate is None:
		candidate = jnp.ones(system.n, dtype=bool)
	factors = node_tpms(system, check_independence=False)
	effect_factors = condition(factors, state, candidate)
	cause_factors = _backward_factors(factors, state, candidate)

	effect_state, phi_effect = _specify(
		_effect_information(effect_factors, state, candidate), system.shape
	)
	cause_state, phi_cause = _specify(
		_cause_information(cause_factors, state, candidate), system.shape
	)
	return CauseEffectState(
		cause_state=cause_state,
		effect_state=effect_state,
		phi_cause=phi_cause,
		phi_effect=phi_effect,
	)

system_phi(system, state, candidate=None, version='2023')

Compute the system integrated information φ_s of a candidate system.

Evaluates every directional system partition (the canonical SET_UNI/BI scheme): for each, the φ lost about the maximal cause-effect state on each side (Eqs. 19-20, without clipping, per the oracle), minimized across sides (Eq. 21); the minimum partition is selected by quantized (normalized φ, -φ) with first occurrence winning ties (Eqs. 22-23). A partition with φ ≤ 0 proves the system reducible, and — matching the oracle's short-circuit — the first such partition in enumeration order is reported as the minimum partition, with its (possibly negative) φ.

Parameters:

Name Type Description Default
system System

The system.

required
state Array

Current state of the whole system, shape (n,).

required
candidate tuple[int, ...] | None

Units of the candidate system (static, since it fixes the partition table); None means all units.

None
version str

"2023" (Albantakis et al. 2023, canonical) or "2026" (Mayner et al. 2026): the 2026 formalism selects the same minimum partition on the same uncapped values, then caps phi_s = min(phi_c, phi_e, ii(s)), where ii(s) is the least, over both directions, of the rectified intrinsic information of the specified state and its rectified surprisal. Static.

'2023'

Returns:

Type Description
SystemPhi

The system φ analysis at the minimum partition.

Source code in src/iitx/measures/iit4.py
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
def system_phi(
	system: System,
	state: jax.Array,
	candidate: tuple[int, ...] | None = None,
	version: str = "2023",
) -> SystemPhi:
	"""Compute the system integrated information φ_s of a candidate system.

	Evaluates every directional system partition (the canonical ``SET_UNI/BI`` scheme):
	for each, the φ lost about the maximal cause-effect state on each side (Eqs. 19-20,
	without clipping, per the oracle), minimized across sides (Eq. 21); the minimum
	partition is selected by quantized ``(normalized φ, -φ)`` with first occurrence
	winning ties (Eqs. 22-23). A partition with φ ≤ 0 proves the system reducible, and —
	matching the oracle's short-circuit — the first such partition in enumeration order
	is reported as the minimum partition, with its (possibly negative) φ.

	Args:
		system: The system.
		state: Current state of the whole system, shape ``(n,)``.
		candidate: Units of the candidate system (static, since it fixes the partition
			table); ``None`` means all units.
		version: ``"2023"`` (Albantakis et al. 2023, canonical) or ``"2026"`` (Mayner et
			al. 2026): the 2026 formalism selects the same minimum partition on the same
			uncapped values, then caps ``phi_s = min(phi_c, phi_e, ii(s))``, where
			``ii(s)`` is the least, over both directions, of the rectified intrinsic
			information of the specified state and its rectified surprisal. Static.

	Returns:
		The system φ analysis at the minimum partition.

	"""
	if version not in ("2023", "2026"):
		msg = f'version must be "2023" or "2026", got {version!r}'
		raise ValueError(msg)
	units = tuple(range(system.n)) if candidate is None else tuple(sorted(candidate))
	(
		pair_phi,
		phi_cause_z,
		phi_effect_z,
		severed,
		cut_choice,
		cause_index,
		effect_index,
		ces,
		strong,
	) = _system_tables(system, state, candidate, version)

	index = cut_choice[cause_index, effect_index]
	phi = pair_phi[index, cause_index, effect_index]
	phi_cause = phi_cause_z[index, cause_index]
	phi_effect = phi_effect_z[index, effect_index]

	if version == "2026":
		# The Eq. 23 cap: the MIP is chosen on the uncapped values above, then
		# phi_s = min(phi_c, phi_e, ii(s)) with ii(s) from the specified states'
		# rectified intrinsic information and surprisal.
		factors = node_tpms(system, check_independence=False)
		candidate_mask = jnp.asarray(_static_mask(system.n, units))
		effect_factors = condition(factors, state, candidate_mask)
		cause_factors = _backward_factors(factors, state, candidate_mask)
		probability_effect = _at(
			purview_distribution(
				repertoire(effect_factors, state, candidate_mask, candidate_mask, Direction.EFFECT),
				candidate_mask,
			),
			ces.effect_state,
			system.shape,
		)
		probability_cause = _at(
			purview_distribution(
				repertoire(cause_factors, state, candidate_mask, candidate_mask, Direction.CAUSE),
				candidate_mask,
			),
			ces.cause_state,
			system.shape,
		)
		surprisals = [
			jnp.where(p > 0.0, -jnp.log2(jnp.where(p > 0.0, p, 1.0)), jnp.inf)
			for p in (probability_cause, probability_effect)
		]
		intrinsic = jnp.minimum(
			jnp.minimum(jnp.maximum(ces.phi_cause, 0.0), jnp.maximum(ces.phi_effect, 0.0)),
			jnp.minimum(jnp.maximum(surprisals[0], 0.0), jnp.maximum(surprisals[1], 0.0)),
		)
		phi = jnp.minimum(phi, intrinsic)

	normalized = phi / severed[index]
	signed = jnp.where(strong, phi, 0.0)
	return SystemPhi(
		phi=jnp.maximum(signed, 0.0),
		signed_phi=signed,
		normalized_phi=jnp.maximum(jnp.where(strong, normalized, 0.0), 0.0),
		phi_cause=jnp.where(strong, phi_cause, 0.0),
		phi_effect=jnp.where(strong, phi_effect, 0.0),
		cut_index=index,
		cause_effect_state=ces,
	)

partition_phis(system, state, candidate=None)

Evaluate every system partition at the resolved specified states.

The partitions are the canonical table of :func:iitx.enumeration.system_cuts for this candidate; the specified states are resolved exactly as in :func:system_phi (ii-maximal, then φ-maximal, then oracle order).

Parameters:

Name Type Description Default
system System

The system.

required
state Array

Current state of the whole system, shape (n,).

required
candidate tuple[int, ...] | None

Units of the candidate system (static); None means all units.

None

Returns:

Type Description
PartitionPhis

The per-partition signed φ values, sides, and normalizations.

Source code in src/iitx/measures/iit4.py
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
def partition_phis(
	system: System,
	state: jax.Array,
	candidate: tuple[int, ...] | None = None,
) -> PartitionPhis:
	"""Evaluate every system partition at the resolved specified states.

	The partitions are the canonical table of :func:`iitx.enumeration.system_cuts` for
	this candidate; the specified states are resolved exactly as in
	:func:`system_phi` (ii-maximal, then φ-maximal, then oracle order).

	Args:
		system: The system.
		state: Current state of the whole system, shape ``(n,)``.
		candidate: Units of the candidate system (static); ``None`` means all units.

	Returns:
		The per-partition signed φ values, sides, and normalizations.

	"""
	(
		pair_phi,
		phi_cause_z,
		phi_effect_z,
		severed,
		_cut_choice,
		cause_index,
		effect_index,
		ces,
		_strong,
	) = _system_tables(system, state, candidate)
	return PartitionPhis(
		phi=pair_phi[:, cause_index, effect_index],
		phi_cause=phi_cause_z[:, cause_index],
		phi_effect=phi_effect_z[:, effect_index],
		severed=severed,
		cause_effect_state=ces,
	)

distinctions(system, state, candidate=None, specification=None)

Unfold the causal distinctions of a candidate system.

For every mechanism, on each side: the intrinsic information of every purview state selects candidate specified states (Eqs. 34-37); φ over the disintegrating partitions Θ(M, Z) (Eqs. 38-44, minimum by quantized normalized φ with the oracle's φ ≤ 0 short-circuit) evaluates each purview; the maximally irreducible purview wins (Eqs. 45-46). Ties are searched for a representative congruent with the system's maximal cause-effect state (Eq. 48): among φ-tied states the congruent one is preferred, then among φ-tied purviews the one whose state is congruent; a mechanism with no congruent representative on either side is not a distinction.

Parameters:

Name Type Description Default
system System

The system.

required
state Array

Current state of the whole system, shape (n,).

required
candidate tuple[int, ...] | None

Units of the candidate system (static); None means all units.

None
specification CauseEffectState | None

The system's maximal cause-effect state to be congruent with. None computes the ii-level specification; pass the φ-resolved one from :func:system_phi (as :func:phi_structure does) for oracle-exact congruence when the specification is tied.

None

Returns:

Type Description
Distinctions

The distinctions, stacked over the nonempty mechanisms of the candidate.

Source code in src/iitx/measures/iit4.py
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
def distinctions(
	system: System,
	state: jax.Array,
	candidate: tuple[int, ...] | None = None,
	specification: CauseEffectState | None = None,
) -> Distinctions:
	"""Unfold the causal distinctions of a candidate system.

	For every mechanism, on each side: the intrinsic information of every purview state
	selects candidate specified states (Eqs. 34-37); φ over the disintegrating partitions
	Θ(M, Z) (Eqs. 38-44, minimum by quantized normalized φ with the oracle's φ ≤ 0
	short-circuit) evaluates each purview; the maximally irreducible purview wins
	(Eqs. 45-46). Ties are searched for a representative congruent with the system's
	maximal cause-effect state (Eq. 48): among φ-tied states the congruent one is
	preferred, then among φ-tied purviews the one whose state is congruent; a mechanism
	with no congruent representative on either side is not a distinction.

	Args:
		system: The system.
		state: Current state of the whole system, shape ``(n,)``.
		candidate: Units of the candidate system (static); ``None`` means all units.
		specification: The system's maximal cause-effect state to be congruent with.
			``None`` computes the ii-level specification; pass the φ-resolved one from
			:func:`system_phi` (as :func:`phi_structure` does) for oracle-exact
			congruence when the specification is tied.

	Returns:
		The distinctions, stacked over the nonempty mechanisms of the candidate.

	"""
	units = tuple(range(system.n)) if candidate is None else tuple(sorted(candidate))
	n, shape = system.n, system.shape
	static_candidate = _static_mask(n, units)
	candidate_mask = jnp.asarray(static_candidate)

	factors = node_tpms(system, check_independence=False)
	effect_factors = condition(factors, state, candidate_mask)
	cause_factors = _backward_factors(factors, state, candidate_mask)
	ces = (
		specification
		if specification is not None
		else cause_effect_state(system, state, candidate_mask)
	)

	# Master tables over co-part bitmasks (axis 1 ordered by bitmask value).
	bits = np.asarray([[bool(mask >> i & 1) for i in range(n)] for mask in range(2**n)], dtype=bool)
	smear_tables = tuple(
		jax.vmap(lambda keep, factor=factor: _smear_axes(factor, keep))(jnp.asarray(bits))
		for factor in effect_factors
	)
	conditional_tables = tuple(
		jax.vmap(lambda table_row: _at_prev(table_row, state, shape))(table)
		for table in smear_tables
	)
	likelihoods = tuple(
		jnp.take(factor, state[u], axis=-1) for u, factor in enumerate(cause_factors)
	)
	marginal_tables = jnp.stack(
		[
			jax.vmap(lambda keep, like=like: _smear_axes(like, keep))(jnp.asarray(bits))
			for like in likelihoods
		]
	)

	mechanism_table = subsets(n, nonempty=True)
	purview_table = subsets(n, nonempty=True)

	# One compiled body per mechanism-size class: mechanisms of equal size share their
	# partition-table shapes exactly, so a lax.scan over the class members reuses one
	# trace where a Python loop would unroll 2**n - 1 bodies.
	row_of = {tuple(row.tolist()): index for index, row in enumerate(mechanism_table)}
	results: list[tuple[jax.Array, ...] | None] = [None] * len(mechanism_table)
	inside = jnp.asarray(np.all(~purview_table | static_candidate, axis=1))
	purviews = jnp.asarray(purview_table)
	for size in range(1, n + 1):
		members = [
			row
			for row in mechanism_table
			if row.sum() == size and bool(np.all(~row | static_candidate))
		]
		if not members:
			continue

		stacked_masks = np.stack(members)
		stacked_bitmasks = (stacked_masks @ (1 << np.arange(n))).astype(np.int32)
		co_mechanism_class = []
		co_purview_class = []
		severed_class = []
		valid_class = []
		for member in members:
			mechanism_units = tuple(int(u) for u in np.flatnonzero(member))
			tables = [
				mechanism_partitions(
					mechanism_units, tuple(int(u) for u in np.flatnonzero(purview_row)), n
				)
				for purview_row in purview_table
			]
			max_partitions = max(len(entry[2]) for entry in tables)
			co_mechanism = np.zeros((len(purview_table), max_partitions, n), dtype=np.int32)
			co_purview = np.zeros_like(co_mechanism)
			severed = np.ones((len(purview_table), max_partitions), dtype=np.int32)
			valid = np.zeros((len(purview_table), max_partitions), dtype=bool)
			for k, (a, b, cut_count) in enumerate(tables):
				co_mechanism[k, : len(cut_count)] = a
				co_purview[k, : len(cut_count)] = b
				severed[k, : len(cut_count)] = cut_count
				valid[k, : len(cut_count)] = True
			co_mechanism_class.append(co_mechanism)
			co_purview_class.append(co_purview)
			severed_class.append(severed)
			valid_class.append(valid)

		def member_row(
			mechanism_row: jax.Array,
			mechanism_bitmask: jax.Array,
			co_mechanism: jax.Array,
			co_purview: jax.Array,
			severed: jax.Array,
			valid: jax.Array,
		) -> tuple[jax.Array, ...]:
			side = {}
			for direction in Direction:
				specified = ces.cause_state if direction is Direction.CAUSE else ces.effect_state

				def evaluate_purview(
					purview: jax.Array,
					co_m: jax.Array,
					co_p: jax.Array,
					ncc: jax.Array,
					ok: jax.Array,
					direction: Direction = direction,
					mechanism_row: jax.Array = mechanism_row,
					mechanism_bitmask: jax.Array = mechanism_bitmask,
					specified: jax.Array = specified,
				) -> tuple[jax.Array, jax.Array, jax.Array]:
					return _purview_phi(
						direction,
						mechanism_row,
						mechanism_bitmask,
						purview,
						co_m,
						co_p,
						ncc,
						ok,
						conditional_tables,
						marginal_tables,
						smear_tables,
						specified,
						shape,
					)

				phi_z, congruent, chosen_state = jax.vmap(
					evaluate_purview, in_axes=(0, 0, 0, 0, 0)
				)(purviews, co_mechanism, co_purview, severed, valid)
				phi_z = jnp.where(inside, phi_z, -jnp.inf)
				best = _q(phi_z) >= _q(phi_z).max()
				preferred = best & congruent
				purview_index = jnp.where(preferred.any(), jnp.argmax(preferred), jnp.argmax(best))
				side[direction] = (
					phi_z[purview_index],
					purviews[purview_index],
					chosen_state[purview_index],
					preferred.any(),
				)

			phi_cause, cause_purview, cause_state_row, cause_congruent = side[Direction.CAUSE]
			phi_effect, effect_purview, effect_state_row, effect_congruent = side[Direction.EFFECT]
			phi_d = jnp.minimum(phi_cause, phi_effect)
			exists = (_q(phi_d) > 0.0) & cause_congruent & effect_congruent
			return (
				exists,
				jnp.where(exists, phi_d, 0.0),
				mechanism_row,
				cause_purview,
				effect_purview,
				cause_state_row,
				effect_state_row,
				phi_cause,
				phi_effect,
			)

		def body(carry: None, xs: tuple[jax.Array, ...]) -> tuple[None, tuple[jax.Array, ...]]:
			return carry, member_row(*xs)

		_, outputs = jax.lax.scan(
			body,
			None,
			(
				jnp.asarray(stacked_masks),
				jnp.asarray(stacked_bitmasks),
				jnp.asarray(np.stack(co_mechanism_class)),
				jnp.asarray(np.stack(co_purview_class)),
				jnp.asarray(np.stack(severed_class)),
				jnp.asarray(np.stack(valid_class)),
			),
		)
		for position, member in enumerate(members):
			results[row_of[tuple(member.tolist())]] = tuple(leaf[position] for leaf in outputs)

	def zeros_row() -> tuple[jax.Array, ...]:
		return (
			jnp.asarray(False),
			jnp.asarray(0.0, dtype=system.tpm.dtype),
			jnp.zeros(n, dtype=bool),
			jnp.zeros(n, dtype=bool),
			jnp.zeros(n, dtype=bool),
			jnp.zeros(n, dtype=jnp.asarray(state).dtype),
			jnp.zeros(n, dtype=jnp.asarray(state).dtype),
			jnp.asarray(0.0, dtype=system.tpm.dtype),
			jnp.asarray(0.0, dtype=system.tpm.dtype),
		)

	strong = strongly_connected(connectivity(system), candidate_mask)
	rows = [row if row is not None else zeros_row() for row in results]
	stacked = [jnp.stack(column) for column in zip(*rows, strict=True)]
	return Distinctions(
		exists=stacked[0] & strong,
		phi=stacked[1],
		mechanism=stacked[2],
		cause_purview=stacked[3],
		effect_purview=stacked[4],
		cause_state=stacked[5],
		effect_state=stacked[6],
		phi_cause=stacked[7],
		phi_effect=stacked[8],
	)

relations(found, ces, shape)

Aggregate the relations among a set of distinctions, analytically.

A relation binds distinctions whose cause/effect purviews overlap congruently — over the same units in the same specified states. Since every distinction is congruent with the system's cause-effect state, the overlap arithmetic reduces to sets of unit-state atoms: one atom per unit and side, merged when the system's cause and effect states agree on the unit.

sum(phi_r) uses the S3 Text sort identity (per atom, sort member distinctions by φ density and weight by the number of subsets whose minimum they are); the count uses inclusion-exclusion over atom subsets. Self-relations (a single distinction whose own cause and effect overlap) are added individually.

Parameters:

Name Type Description Default
found Distinctions

The distinctions (with existence mask).

required
ces CauseEffectState

The system's maximal cause-effect state (for the atom merging).

required
shape tuple[int, ...]

Per-unit alphabet sizes.

required

Returns:

Type Description
Relations

The total relation φ and the relation count.

Source code in src/iitx/measures/iit4.py
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
def relations(found: Distinctions, ces: CauseEffectState, shape: tuple[int, ...]) -> Relations:
	"""Aggregate the relations among a set of distinctions, analytically.

	A relation binds distinctions whose cause/effect purviews overlap *congruently* —
	over the same units in the same specified states. Since every distinction is
	congruent with the system's cause-effect state, the overlap arithmetic reduces to
	sets of unit-state atoms: one atom per unit and side, merged when the system's cause
	and effect states agree on the unit.

	``sum(phi_r)`` uses the S3 Text sort identity (per atom, sort member distinctions by
	φ density and weight by the number of subsets whose minimum they are); the count
	uses inclusion-exclusion over atom subsets. Self-relations (a single distinction
	whose own cause and effect overlap) are added individually.

	Args:
		found: The distinctions (with existence mask).
		ces: The system's maximal cause-effect state (for the atom merging).
		shape: Per-unit alphabet sizes.

	Returns:
		The total relation φ and the relation count.

	"""
	n = len(shape)
	merged = ces.cause_state == ces.effect_state

	# Atom membership: slots 0..n-1 are cause-side atoms, n..2n-1 effect-side atoms;
	# when the system states agree on a unit its effect atom folds into its cause atom.
	cause_atoms = found.cause_purview | (merged[None] & found.effect_purview)
	effect_atoms = ~merged[None] & found.effect_purview
	atoms = jnp.concatenate([cause_atoms, effect_atoms], axis=1) & found.exists[:, None]

	size = atoms.sum(axis=1)
	density = jnp.where(size > 0, found.phi / jnp.where(size > 0, size, 1), 0.0)

	# Relations of two or more distinctions: per atom, sort members by density.
	member = atoms & found.exists[:, None]
	keys = jnp.where(member, density[:, None], jnp.inf)
	order = jnp.argsort(keys, axis=0, stable=True)
	sorted_density = jnp.take_along_axis(keys, order, axis=0)
	counts = member.sum(axis=0)
	ranks = jnp.arange(found.exists.shape[0])[:, None] + 1
	weights = jnp.where(ranks <= counts[None], 2.0 ** (counts[None] - ranks) - 1.0, 0.0)
	sum_higher = jnp.sum(jnp.where(weights > 0, sorted_density * weights, 0.0))

	# Count of relations with two or more distinctions: inclusion-exclusion over atom
	# subsets with nonempty common overlap.
	atom_subsets = jnp.asarray(subsets(2 * n, nonempty=True))
	missing = (~atoms).astype(jnp.int32) @ atom_subsets.T.astype(jnp.int32)
	contains = (missing == 0) & found.exists[:, None]
	num_containing = contains.sum(axis=0)
	sign = jnp.where(atom_subsets.sum(axis=1) % 2 == 1, 1.0, -1.0)
	count_higher = jnp.sum(sign * (2.0**num_containing - num_containing - 1.0)).astype(jnp.int64)

	# Self-relations: a distinction related to itself through the overlap of its own
	# cause and effect purviews (nonempty only over merged atoms).
	self_overlap = (merged[None] & found.cause_purview & found.effect_purview).sum(axis=1)
	self_phi = jnp.where(found.exists & (self_overlap > 0), self_overlap * density, 0.0)
	sum_self = self_phi.sum()
	count_self = jnp.sum(found.exists & (self_overlap > 0)).astype(jnp.int64)

	return Relations(sum_phi=sum_higher + sum_self, count=count_higher + count_self)

phi_structure(system, state, candidate=None, version='2023')

Unfold the Φ-structure of a candidate system.

Composes the system-level analysis, the distinctions, and the relations; Φ = sum(phi_d) + sum(phi_r) (Eq. 59) — a sum over what exists, not a partitioned distance.

Parameters:

Name Type Description Default
system System

The system.

required
state Array

Current state of the whole system, shape (n,).

required
candidate tuple[int, ...] | None

Units of the candidate system (static); None means all units.

None
version str

Theory version, "2023" or "2026" (see :func:system_phi); the cap affects only the system-level φ, not the distinctions or relations.

'2023'

Returns:

Type Description
PhiStructure

The Φ-structure.

Source code in src/iitx/measures/iit4.py
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
def phi_structure(
	system: System,
	state: jax.Array,
	candidate: tuple[int, ...] | None = None,
	version: str = "2023",
) -> PhiStructure:
	"""Unfold the Φ-structure of a candidate system.

	Composes the system-level analysis, the distinctions, and the relations;
	``Φ = sum(phi_d) + sum(phi_r)`` (Eq. 59) — a sum over what exists, not a partitioned
	distance.

	Args:
		system: The system.
		state: Current state of the whole system, shape ``(n,)``.
		candidate: Units of the candidate system (static); ``None`` means all units.
		version: Theory version, ``"2023"`` or ``"2026"`` (see :func:`system_phi`); the
			cap affects only the system-level φ, not the distinctions or relations.

	Returns:
		The Φ-structure.

	"""
	analysis = system_phi(system, state, candidate, version=version)
	found = distinctions(system, state, candidate, specification=analysis.cause_effect_state)
	related = relations(found, analysis.cause_effect_state, system.shape)
	return PhiStructure(
		system=analysis,
		distinctions=found,
		relations=related,
		big_phi=jnp.where(found.exists, found.phi, 0.0).sum() + related.sum_phi,
	)

complexes(system, state)

Condense a system into its complexes (recursive exclusion, Eqs. 24-26).

Among all candidate systems, the one with maximal φ_s is a complex (the first complex is the maximal substrate); its units are removed and the search recurses on the remainder until no candidate has positive φ_s. Excluded units remain background conditions throughout. A Python driver by design (the recursion is data-dependent); each candidate's analysis is the jitted :func:system_phi.

Ties among overlapping candidates resolve by first occurrence in powerset order (the S1 Text's Φ-comparison cascade for exact ties is deferred with the deeper tie machinery; the residual divergence is recorded in docs/notes/oracle-findings.md).

Parameters:

Name Type Description Default
system System

The system.

required
state Array

Current state of the whole system, shape (n,).

required

Returns:

Type Description
list[Complex]

The complexes, in order of discovery (decreasing φ_s across rounds).

Source code in src/iitx/measures/iit4.py
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
def complexes(system: System, state: jax.Array) -> list[Complex]:
	"""Condense a system into its complexes (recursive exclusion, Eqs. 24-26).

	Among all candidate systems, the one with maximal φ_s is a complex (the first
	complex is the maximal substrate); its units are removed and the search recurses on
	the remainder until no candidate has positive φ_s. Excluded units remain background
	conditions throughout. A Python driver by design (the recursion is data-dependent);
	each candidate's analysis is the jitted :func:`system_phi`.

	Ties among overlapping candidates resolve by first occurrence in powerset order
	(the S1 Text's Φ-comparison cascade for exact ties is deferred with the deeper tie
	machinery; the residual divergence is recorded in ``docs/notes/oracle-findings.md``).

	Args:
		system: The system.
		state: Current state of the whole system, shape ``(n,)``.

	Returns:
		The complexes, in order of discovery (decreasing φ_s across rounds).

	"""
	remaining = list(range(system.n))
	found: list[Complex] = []
	while remaining:
		best: Complex | None = None
		for size in range(1, len(remaining) + 1):
			for units in combinations(remaining, size):
				if not is_strongly_connected(system, units):
					continue
				analysis = system_phi(system, state, units)
				if float(analysis.phi) > 0.0 and (
					best is None or float(analysis.phi) > float(best.analysis.phi)
				):
					best = Complex(units=units, analysis=analysis)
		if best is None:
			break
		found.append(best)
		remaining = [u for u in remaining if u not in best.units]
	return found