---
title: Indexed Graded Monads
url: https://www.emergentmind.com/topics/indexed-graded-monads
type: topic
---

# Indexed Graded Monads

Indexed graded monads are a categorical structure generalizing graded monads and indexed monads, developed to provide semantics for effect systems and refinement type systems with *dependent effects*—effects whose quantitative or qualitative characteristics depend on parameters or predicates drawn from the typing context. They unify several strands in the theory of computational effects, supporting value-dependent resource analysis, probabilistic reasoning, and temporal safety properties. As ordinary graded monads model effect systems by grading by a monoid, and indexed monads provide families of monads parameterized over a base category, indexed graded monads internalize graded monads to fibers of a fibration, with the grading varying over the base category. This yields a structural framework capturing both global and context-dependent effect tracking in programming language semantics [2601.14846][2001.10274][1401.5391][2511.22419][1904.08083].

## 1. Foundational Structures: Graded, Indexed, and Indexed Graded Monads

Classical *graded monads* are defined by a monoidal grading set $M$ acting on a base category $\mathcal{C}$, with a functor $T: M \times \mathcal{C} \to \mathcal{C}$, together with unit and multiplication operations indexed by $M$ and satisfying graded coherence laws [2001.10274][1401.5391][1904.08083]. Ordinary *indexed monads* involve an indexing category $B$, forming a functor $\mathscr{T} : B \times \mathcal{C} \to \mathcal{C}$ such that for each $b \in B$, $T_b$ is a monad and the assignment is functorial in $b$ [1401.5391][1904.08083].

*Indexed graded monads* combine these axes. Formally, let $p: \mathcal{E} \to \mathcal{B}$ be a fibration, and let $M_{-}: \mathcal{B}^{op} \to \mathrm{PreMon}$ be a $\mathcal{B}$-indexed family of preordered monoids. An *indexed $M_{-}$-graded monad* is a family of graded monads $(T_I, \eta_I, \mu_I)$ on each fiber $\mathcal{E}_I$, such that for every $u: I \to J$ in $\mathcal{B}$, the reindexing $(u^* : M_J \to M_I,~u^* : \mathcal{E}_J \to \mathcal{E}_I)$ is a morphism of graded monads, i.e.,

$$u^*(T_J^m X) = T_I^{u^*(m)}(u^* X),$$

with preservation of units and multiplications [2601.14846][1904.08083]. If $\mathcal{B} = 1$, this collapses to an ordinary graded monad.

This framework subsumes the main generalizations:

| Structure                | Indexing      | Grading           | Generalizes               |
|--------------------------|--------------|-------------------|---------------------------|
| Monad                    | constant     | none              | Classical effect semantics|
| Graded Monad             | none         | monoid $M$        | Effect systems            |
| Indexed Monad            | category $B$ | none              | Program logics            |
| Indexed Graded Monad     | category $B$ | $M_{-}$ varying   | Dependent effect systems  |

## 2. Indexed Graded Monads and Dependent Effect Tracking

The principal motivation for indexed graded monads arises from the need to express *dependent effects*: effect annotations in type systems that may vary with parameters in the context, rather than being chosen uniformly. For example, cost bounds or probabilistic guarantees dependent on program inputs are not expressible using classical graded monads, which grade by a fixed monoid $M$ [2601.14846].

In a refinement-type setting, a dependent effect system allows effect terms $E$ to contain variables from the current typing context. For instance, a type $T_{{\max\{0, n-x\}}}A$ describes computations whose cost is determined by program values $n$ and $x$. The semantics requires fibers for each context and a family of monoids $M_I$ on each fiber, together with compatible monad structures and monoidal functors reflecting the base context structure [2601.14846].

Indexed graded monads provide the semantics for such systems: for each context $I$, the fiber $\mathcal{E}_I$ models value and computation types, and each $M_I$ is a preordered monoid of effects over $I$. The monad's grade can thus depend on $I$, allowing precise effect tracking and relational reasoning in context-sensitive analyses such as resource bounds, security assertions, and temporal properties [2601.14846][2511.22419].

## 3. Categorical Semantics and Coherence Laws

Formally, the structure of an indexed graded monad is captured as a monad internal to the 2-category of fibrations, with extra compatibility with the fibered premonoidal structure [2601.14846][1904.08083]. The categorical coherence requires that for every morphism $u: I \to J$ in $\mathcal{B}$,

- $u^*$ maps effects compatibly: $u^*: M_J \to M_I$ preserves the monoid and preorder,
- $u^*$ maps objects in fibers: $u^*: \mathcal{E}_J \to \mathcal{E}_I$,
- The monad structure is preserved: $u^*$ commutes with units and multiplications.

The underlying graded monad structure on each fiber consists of

- A unit $\eta_X: X \to T^{1} X$,
- Multiplications $\mu_{m_1,m_2, X}: T^{m_1}(T^{m_2} X) \to T^{m_1 m_2} X$,
- Reindexing functoriality linking context changes to effect grading.

Typical coherence diagrams—unit laws, associativity, and compatibility with reindexing—must commute across the fibers [2601.14846][1904.08083].

## 4. Examples and Instances

Several concrete semantics instantiate indexed graded monads:

- **Cost analysis:** The base category $\mathcal{B}$ is contexts (predicates) on a category $C$ (e.g., $\mathrm{Set}$ or $\omega\mathbf{CPO}$), and $M_I$ assigns to each context $I$ the set of functions $I \to \mathbb{N}_{\infty}$, ordered pointwise. The monad acts as $T_I(f, X_i) = (X_i \times \{n \leq f(i)\})_{i \in I}$ [2601.14846, Sec. 6.1].
- **Expectation bounds:** For probabilistic reasoning, $M_I$ assigns value-dependent expectation shift bounds, with the fiberwise monad acting on subspaces of distributions with bounded expectation [2601.14846, Sec. 6.2].
- **Temporal safety:** The fiberwise graded monad encodes trace languages parameterized by predicates, supporting semantic soundness for temporal contracts [2601.14846, App. D.3].
- **Resource-tracking quantum circuits:** The monad $M$ on $\mathcal{M}^{op} \times \mathcal{M} \times \mathrm{Set} \to \mathrm{Set}$, $M(m_1, m_2; X) = X \times \mathcal{M}(m_1, m_2)$, is refined using a circuit algebra $E$ to become an $E$-graded monad on $\mathrm{Set}$, modeling resource-aware circuit generation with effect typing [2511.22419].

These examples demonstrate that indexed graded monads subsume both ordinary effect and resource analysis as well as advanced dependent analyses.

## 5. Typing Discipline and Denotational Semantics

Effect typing with indexed graded monads decorates terms and types with effect annotations dependent on context. Typing judgments take the form

$$\Gamma \vdash M : A~[E],$$

where $E$ is a (possibly dependent) effect annotation in $M_{\llbracket \Gamma \rrbracket}$. Denotationally, the semantics assigns

$$\llbracket M \rrbracket : \llbracket \Gamma \rrbracket \to T^{E}_{\llbracket \Gamma \rrbracket} \llbracket A \rrbracket$$

for each term $M$. This subsumes conventional monadic semantics ($M$-graded or otherwise), enabling dependent subeffecting, composition, and refined effect polymorphism [1401.5391][2601.14846][2511.22419]. The soundness theorem asserts that syntactically well-typed programs have semantics respecting all effect and resource invariants imposed by the indexings [2601.14846, Thm 5.8][2511.22419].

Effect typing rules follow the graded monad's structure (e.g., sequencing via $\mu$ for `let`, subeffecting by morphisms in $M_I$, and preservation under context reindexing). For circuit generation, the typing tracks abstract resource usage (e.g., gate count, width) compositionaly, as determined by the base circuit algebra and abstraction functor [2511.22419].

## 6. 2-Categorical and Lax Functorial Perspectives

Indexed graded monads admit characterization as monads in appropriate 2-categories. Fujii [1904.08083] formalizes this by considering monads internal to certain 2-categories of fibrations, functors, and natural transformations, equipped with grading and indexing structures. Graded and indexed monads are monads in different 2-categorical environments; indexed graded monads combine these, requiring a composite structure with units and multiplications in both grade and index directions, and reindexing/regrading compatibility.

In particular, the composite functor $M \times B \times \mathcal{C} \to \mathcal{C}$, equipped with the four requisite structure families, is a monad in the relevant double 2-category, with Eilenberg–Moore and Kleisli constructions generalizing those for ordinary and graded monads [1904.08083, Prop. B.1]. This perspective clarifies the relation of indexed graded monads to parameterized and category-graded monads [2001.10274].

## 7. Applications and Impact

Indexed graded monads provide modular semantics for a wide range of advanced type-and-effect systems, notably enabling

- Resource and cost analysis in dependently-typed calculi,
- Formal verification of value-bound probabilities, expectations, and temporal properties,
- Effect typing for program logics and circuit description languages, including the Proto-Quipper family [2511.22419],
- Sound and adequate denotational models for dependent effect systems, supporting proof principles such as induction on contexts and effect annotations [2601.14846].

Soundness and adequacy theorems guarantee that effect annotations in types precisely control the operational cost, probability, or resource usage of program executions, even in the presence of dependent or parametric variation. This leads to verified quantitative properties, compositional reasoning, and supports compiler optimizations and resource-dependent program synthesis [2601.14846][2511.22419][1401.5391].

A plausible implication is that indexed graded monads will become a standard tool in the semantics of effectful, resource-sensitive, and dependently-typed programming languages, with ongoing impact on automated verification, cost analysis, and certified compilation.

Source: https://www.emergentmind.com/topics/indexed-graded-monads