Multi-agent separability, weighted distances, and entanglement measures
Definitionmarkov_entanglement_multiStatement
Definitions. For agents with local state-action spaces , write the joint space as . A joint transition is separable when
with each a transition matrix. Given a distribution , the -norm is , the -weighted total variation distance replaces the maximum over rows of the usual distance by a -average, and the -weighted agent-wise total variation distance compares the joint transition marginalised onto agent with a candidate local transition. The measure of Markov entanglement is the distance from to the nearest separable transition,
for a distance left abstract, and is its agent-wise counterpart. Further definitions cover product-form transitions, a shared global coordinate, the measure of reward entanglement , and the span of the transition matrices.
Notes
These are the objects the mission's theorems are stated against. Three design points are worth flagging for anyone reusing them.
The measure of entanglement is parameterised by the distance rather than fixed to one choice. The source defines it that way — "where is some distance measure" — and keeping it abstract means the total variation, agent-wise, and -weighted variants are all instances of one definition instead of three near-duplicates.
The generic pieces are reused, not restated: transition matrices, positive distributions, stationarity, the Bellman fixed point and the plain total variation distance come from the already-published two-agent definitions module, which states them over an arbitrary finite index type. Only the genuinely -agent layer is new here.
Reward entanglement is defined in exact parallel to Markov entanglement — a distance from an object to the set of decomposable ones — so the two error terms in the cooperative bound have the same shape.
Search terms: separable transition kernel, tensor product of stochastic matrices, agent-wise total variation distance, occupancy-weighted norm, measure of entanglement, value decomposition.
import Definitions.Def_markov_entanglement
open scoped BigOperators
namespace MarkovEntanglement
/-! ## Multi-agent vocabulary
The two-agent file this imports already states `IsTransitionMatrix`,
`IsPositiveDist`, `IsStationary`, `IsBellmanQ` and `tvDist` over an arbitrary
finite index type, so they are reused verbatim here rather than restated. What
follows is the `N`-agent layer plus the weighted distances, kept generic in the
same spirit: agents carry their own state-action spaces `S i`, and the measure of
entanglement is parameterised by an abstract distance, exactly as the source
leaves `d(·,·)` abstract. -/
variable {N : ℕ} {S : Fin N → Type*} [∀ i, Fintype (S i)] [∀ i, DecidableEq (S i)]
/-- The joint state-action space of `N` agents: a choice of local state-action pair
for each agent. -/
abbrev Joint (S : Fin N → Type*) : Type _ := ∀ i, S i
/-- The `N`-fold tensor product of local transition matrices: agents move
independently, so the joint probability is the product of the local ones. -/
def tensorProdN (P : ∀ i, Matrix (S i) (S i) ℝ) : Matrix (Joint S) (Joint S) ℝ :=
fun p q => ∏ i, P i (p i) (q i)
/-- A joint transition is **separable** when it is a finite affine combination of
tensor products of local transitions; otherwise the agents are **entangled**. -/
def IsSeparableN (P : Matrix (Joint S) (Joint S) ℝ) : Prop :=
∃ (K : ℕ) (x : Fin K → ℝ) (Pj : Fin K → ∀ i, Matrix (S i) (S i) ℝ),
(∀ k i, IsTransitionMatrix (Pj k i)) ∧ (∑ k, x k = 1) ∧
P = ∑ k, x k • tensorProdN (Pj k)
/-- The **`μ`-norm** of a vector: the `μ`-weighted average of its absolute values.
A norm when `μ` is strictly positive, a seminorm in general. -/
def muNorm {ι : Type*} [Fintype ι] (μ x : ι → ℝ) : ℝ := ∑ i, μ i * |x i|
/-- The **`μ`-weighted total variation distance** between transition matrices:
the total variation distance of corresponding rows, averaged with weights `μ`
instead of maximised. -/
noncomputable def muTVDist {ι : Type*} [Fintype ι] (μ : ι → ℝ) (P Q : Matrix ι ι ℝ) : ℝ :=
∑ i, μ i * ((1 / 2) * ∑ j, |P i j - Q i j|)
/-- The transition probability that agent `i` moves to local state-action `t`,
obtained by marginalising the joint transition over every other agent. -/
def marginalN (i : Fin N) (P : Matrix (Joint S) (Joint S) ℝ)
(p : Joint S) (t : S i) : ℝ :=
∑ q : Joint S, if q i = t then P p q else 0
/-- The marginal of the occupancy measure `μ` onto agent `i`'s coordinate. -/
def marginalDist (i : Fin N) (μ : Joint S → ℝ) (s : S i) : ℝ :=
∑ q : Joint S, if q i = s then μ q else 0
/-- `Pi` is agent `i`'s **local (marginalised) transition** induced by the joint
transition `P` under the occupancy measure `μ`, the `N`-agent form of Eq. (2).
Both sides are scaled by the marginal of `μ`, so that no division by a marginal
that could vanish off its support is needed. This is the right notion to use in
place of demanding that the joint marginal depend on the joint state only through
agent `i`'s coordinate, which would already force agent-wise separability. -/
def IsLocalTransitionN (i : Fin N) (P : Matrix (Joint S) (Joint S) ℝ)
(μ : Joint S → ℝ) (Pi : Matrix (S i) (S i) ℝ) : Prop :=
∀ s t : S i, marginalDist i μ s * Pi s t
= ∑ p : Joint S, (if p i = s then μ p else 0) * marginalN i P p t
/-- The **`μ`-weighted agent-wise total variation distance** for agent `i`:
how far the joint transition, marginalised onto agent `i`, sits from a candidate
local transition, averaged over joint state-action pairs with weights `μ`. -/
noncomputable def muAgentTVDistN (i : Fin N) (μ : Joint S → ℝ)
(P : Matrix (Joint S) (Joint S) ℝ) (Pi : Matrix (S i) (S i) ℝ) : ℝ :=
∑ p : Joint S, μ p * ((1 / 2) * ∑ t : S i, |marginalN i P p t - Pi (p i) t|)
/-- The **measure of Markov entanglement** with respect to an arbitrary distance
`d`, following the source, which defines it as the distance from the joint
transition to the nearest separable one and leaves `d` abstract. Instantiate `d`
with the total variation distance, the agent-wise variant, or their `μ`-weighted
counterparts. -/
noncomputable def entanglementWith
(d : Matrix (Joint S) (Joint S) ℝ → Matrix (Joint S) (Joint S) ℝ → ℝ)
(P : Matrix (Joint S) (Joint S) ℝ) : ℝ :=
sInf {r : ℝ | ∃ Q : Matrix (Joint S) (Joint S) ℝ, IsSeparableN Q ∧ r = d P Q}
/-- The **agent-wise measure of Markov entanglement** for agent `i`: how far the
joint transition sits from being generated by a single local transition for `i`,
in `μ`-weighted agent-wise total variation distance. -/
noncomputable def entanglementN (i : Fin N) (μ : Joint S → ℝ)
(P : Matrix (Joint S) (Joint S) ℝ) : ℝ :=
sInf {r : ℝ | ∃ Pi : Matrix (S i) (S i) ℝ,
IsTransitionMatrix Pi ∧ r = muAgentTVDistN i μ P Pi}
/-- `Q` decomposes as a sum of local values: `Q(s,a) = Σ_i Q_i(s_i, a_i)`. -/
def IsValueDecomposition (Q : Joint S → ℝ) (Qi : ∀ i, S i → ℝ) : Prop :=
∀ p : Joint S, Q p = ∑ i, Qi i (p i)
/-! ## Weakly-coupled systems, shared global state, and reward entanglement -/
/-- A joint transition is **product-form**: the agents' local kernels are independent,
`P(s' | s) = ∏ i, P i (s' i | s i)`. This is the transition half of a weakly-coupled
MDP; the coupling in such a model lives entirely in the action constraints. -/
def IsProductTransition (P : Matrix (Joint S) (Joint S) ℝ)
(Pl : ∀ i, Matrix (S i) (S i) ℝ) : Prop :=
P = tensorProdN Pl
/-- The joint state-action space of `N` agents together with a shared global
coordinate, used for systems where the agents also observe a common state. -/
abbrev JointZ (S : Fin N → Type*) (Z : Type*) : Type _ := (∀ i, S i) × Z
/-- Agent `i`'s marginal of a joint transition on a system with a shared global
coordinate: the probability of moving to local state-action `t` with global state `z`. -/
def marginalZ {Z : Type*} [Fintype Z] [DecidableEq Z] (i : Fin N)
(P : Matrix (JointZ S Z) (JointZ S Z) ℝ) (p : JointZ S Z) (t : S i × Z) : ℝ :=
∑ q : JointZ S Z, if q.1 i = t.1 ∧ q.2 = t.2 then P p q else 0
/-- A reward on the joint space **decomposes** when it is a sum of local rewards. -/
def IsDecomposableReward (r : Joint S → ℝ) : Prop :=
∃ rl : ∀ i, S i → ℝ, ∀ p, r p = ∑ i, rl i (p i)
/-- The **measure of reward entanglement**: how far a joint reward is, in `μ`-norm,
from being a sum of local rewards. Zero exactly when the reward decomposes, and the
direct analogue for rewards of the measure of Markov entanglement for transitions. -/
noncomputable def rewardEntanglement (μ : Joint S → ℝ) (r : Joint S → ℝ) : ℝ :=
sInf {c : ℝ | ∃ rl : ∀ i, S i → ℝ, c = muNorm μ (fun p => r p - ∑ i, rl i (p i))}
/-- The linear span of the transition matrices on a finite index type. -/
noncomputable def transitionSpan (ι : Type*) [Fintype ι] [DecidableEq ι] :
Submodule ℝ (Matrix ι ι ℝ) :=
Submodule.span ℝ {P : Matrix ι ι ℝ | IsTransitionMatrix P}
end MarkovEntanglement
Read-back
What the Lean code literally says, in plain math · claude-opus-5
Read-back — markov_entanglement_multi.lean
All declarations live in the namespace MarkovEntanglement and are definitions only: the file contains no theorem, no lemma, and no proof. Nothing below is asserted to hold; each item merely introduces a name for a term or for a predicate. Doc-comments in the source (e.g. claims that a quantity "is a norm", "is zero exactly when the reward decomposes", or that a construction "is the right notion") are prose annotations and carry no formal content; they are not part of what the code asserts and are not reproduced as claims here.
Standing context
The file is developed under the ambient variables
- — the number of agents, indexed by ;
- — a family of local state–action types, one per agent;
- the typeclass assumptions is a finite type for every and has decidable equality for every .
These are implicit (respectively instance) arguments of every declaration below whose statement mentions ; they are not arguments of muNorm, muTVDist or transitionSpan, which carry their own index-type assumptions. No declaration assumes that , that any is nonempty, or that any is inhabited.
The only object imported from the two-agent file and actually used here is
i.e. a square real matrix over a finite index type with nonnegative entries whose every row sums to . (The imported file also supplies IsPositiveDist, IsStationary, IsBellmanQ, tvDist, marginalA/marginalB, IsLocalTransitionA/B, tensorProd, IsSeparable, agentTVDistA/B, entanglementA/B; none of these are referenced in this file.) Throughout, "matrix over " means a function ; no finiteness or stochasticity of a matrix is ever assumed unless IsTransitionMatrix is explicitly invoked. Real-valued infima are taken with Mathlib's on , which returns the junk value when the set is empty or is not bounded below.
1. Joint
Assumptions: (implicit); explicit; the two family-wide typeclass assumptions on .
is an abbreviation for the dependent product type
i.e. the type of functions assigning to each agent a local state–action pair . It is a plain type abbreviation and asserts nothing.
Degenerate cases. If the product is over the empty index set, so is a one-element type (the empty function), not empty. If some is empty, is empty, and then every function out of it is the unique empty function and every sum indexed by it is .
2. tensorProdN
Assumptions: , implicit; finite with decidable equality for each . Input: a family where is a matrix over — with no hypothesis that any is a transition matrix.
The definition produces the matrix over
Degenerate cases. For the product is empty and equals , so the result is the matrix with entry on the singleton , regardless of . Entries may be negative or exceed , since the are arbitrary real matrices.
3. IsSeparableN
Assumptions: , implicit; finite with decidable equality for each . Input: a matrix over , arbitrary (not assumed stochastic, nonnegative, or anything else).
is separable means: there exist a natural number , real coefficients , and for each a family of matrices over , such that
- every is a transition matrix: for all and for all ;
- ;
- exact matrix equality
The coefficients are only required to sum to ; they may be negative and are not required to lie in , so this is an affine (not convex) combination. The word "entangled" appears only in the doc-comment; no separate predicate for it is defined.
Degenerate cases. ranges over all of including , but forces , so any witness has . If , is a singleton and the condition reduces to ; so the predicate holds precisely for the matrix . If some is empty, then is empty, every matrix over it is the unique empty matrix, condition 1 is vacuous for that , and the predicate holds for the unique (take , ).
4. muNorm
Assumptions: an arbitrary type with the assumption that is finite; no decidability assumption; , play no role. Inputs: two functions .
Degenerate cases. is an arbitrary real function: it is not assumed nonnegative, nor normalized to sum to . If some the value can be negative and the quantity is neither a norm nor a seminorm. If is empty the value is for all inputs.
5. muTVDist
Assumptions: an arbitrary finite type ; no decidability assumption. Inputs: and two matrices over , neither assumed stochastic.
This is a -weighted sum over rows of the row-wise total variation distance, in contrast to the imported tvDist, which takes a supremum over rows.
Degenerate cases. is unconstrained (may be negative, may not sum to ), so the value can be negative and can fail symmetry-independent properties of a metric such as nonnegativity; it is symmetric in and vanishes when regardless of . Empty gives . This definition is not used by any other declaration in the file.
6. marginalN
Assumptions: , implicit; finite (needed to sum over ) and decidably equal (needed for the test ). Inputs: an agent index , a matrix over (arbitrary), a joint point , and .
Degenerate cases. No stochasticity is required of , so this can be any real number. If is empty (some empty) the value is . If the index cannot be supplied, so the definition is vacuous in that case.
7. marginalDist
Assumptions: as in item 6. Inputs: an agent index , a function (arbitrary — not assumed nonnegative or normalized), and .
Degenerate cases. May be negative or zero for arbitrary ; equals when is empty.
8. IsLocalTransitionN
Assumptions: , implicit; finite with decidable equality. Inputs: an agent index ; a matrix over ; a function ; a matrix over . None of , , is assumed stochastic, nonnegative, or normalized.
The predicate holds iff for all ,
i.e. the -marginal weight at times the candidate local entry equals the -weighted marginal flow from the fibre into the fibre . It is stated multiplicatively; no division occurs.
Degenerate cases. For any with vanishing marginal , the left side is for every candidate value of , so the row is completely unconstrained by the predicate at that (while the right side is then forced to be , a condition on and alone that may be unsatisfiable, making the predicate hold for no at all). If the predicate reduces to requiring the right-hand side to vanish identically, again leaving arbitrary. If is empty the predicate is vacuously true. If is empty both sides are and the predicate is true for every .
9. muAgentTVDistN
Assumptions: , implicit; finite with decidable equality. Inputs: an agent index ; (arbitrary); a matrix over (arbitrary); a matrix over (arbitrary).
That is, at each joint point one compares the marginal row of onto agent 's coordinate with the row of indexed by , takes half the discrepancy, and averages these with weights (a weighted sum, not a maximum).
Degenerate cases. With arbitrary the value can be negative. If or is empty the value is .
10. entanglementWith
Assumptions: , implicit; finite with decidable equality. Inputs: a completely arbitrary function taking two matrices over to a real number — it is not assumed symmetric, nonnegative, or to satisfy any metric axiom — and a matrix over .
the infimum of the values as ranges over separable joint transitions, with in the first argument of .
Degenerate cases. The infimum is the real-number , which returns the junk value whenever the set is empty or unbounded below. Since is arbitrary, the set is in general not bounded below, so the value can be by convention rather than by any minimization. When the only separable matrix is on the singleton joint space, so the value is . When some is empty, and are both the unique empty matrix and the value is .
11. entanglementN
Assumptions: , implicit; finite with decidable equality. Inputs: an agent index ; (arbitrary, not assumed a distribution); a matrix over (arbitrary).
with as spelled out in item 9. Note the ranging object is required to be a genuine transition matrix, whereas and are unconstrained.
Degenerate cases. Again the real with the junk-value- convention on empty or unbounded-below sets. If is empty the set is and the value is . If is empty, the unique matrix over is vacuously a transition matrix, so the infimum is over a single point. The definition takes an infimum over a set of reals rather than an indexed infimum over the subtype of transition matrices (unlike the imported two-agent entanglementA/entanglementB, which use the latter).
12. IsValueDecomposition
Assumptions: , implicit; finite with decidable equality. Inputs: and a family — the local functions are given, not existentially quantified.
The predicate holds iff
Degenerate cases. If the right-hand sum is empty, so the predicate says on the singleton joint space. If is empty the predicate is vacuously true for all and all .
13. IsProductTransition
Assumptions: , implicit; finite with decidable equality. Inputs: a matrix over and a given family of matrices over (existentially quantified nowhere; and not assumed to be transition matrices).
The predicate holds iff equals the tensor product of item 2, i.e.
Degenerate cases. With this says . With empty it is vacuously true. Since no stochasticity is required of , this is exact equality of arbitrary real matrices with an entrywise product formula. Nothing in the definition mentions actions, action constraints, or coupling, despite the doc-comment.
14. JointZ
Assumptions: implicit; and explicit; the family typeclass assumptions on (no assumption on at this declaration).
An abbreviation for the product type
pairs consisting of a joint local configuration and one extra "global" coordinate in . It is a type abbreviation and asserts nothing.
15. marginalZ
Assumptions: , implicit with finite and decidably equal; additionally implicit with finite and decidably equal. Inputs: an agent index ; a matrix over (arbitrary); a point ; and a target pair .
i.e. the total mass that assigns from to all joint successors whose agent- local coordinate is and whose global coordinate is , marginalizing over all other agents' coordinates.
Degenerate cases. Arbitrary sign and magnitude, since is unconstrained; equals if or some is empty. This definition is not used by any other declaration in the file, and no shared-global-coordinate analogue of separability, local transition, or entanglement is defined.
16. IsDecomposableReward
Assumptions: , implicit; finite with decidable equality. Input: .
The predicate holds iff there exists a family of local functions such that
(The same shape as item 12, but with the local pieces existentially quantified rather than supplied.)
Degenerate cases. With it says on the singleton joint space. With empty it is vacuously true for every .
17. rewardEntanglement
Assumptions: , implicit; finite with decidable equality. Inputs: (arbitrary — no nonnegativity, no normalization) and .
using of item 4 applied to the residual . The local pieces range over all real-valued functions, with no boundedness or sign constraint.
Degenerate cases. The set is nonempty (take ), but with a having any negative value the set is in general unbounded below, in which case the real returns its junk value ; the same junk value is returned in the genuinely-zero cases, so the two are indistinguishable from the definition alone. If is empty the value is . If the residual is and the value is .
18. transitionSpan
Assumptions: an arbitrary type assumed finite and decidably equal; this declaration does not mention or .
the -linear span (as a submodule of the space of all real matrices) of the set of transition matrices. Arbitrary real coefficients are allowed — no constraint that they sum to , unlike the affine condition in item 3.
Degenerate cases. If is empty, the ambient matrix space is the zero module and the span is the whole (trivial) space. If is nonempty, the set spanned is nonempty. This declaration is not used by any other declaration in the file.
Confirmed by the mission captain (proposal self-audit).