【Consideration】Toward a Category Theory Foundation for Civil Law (1)
Author Note: The ideas presented here are preliminary and non-rigorous. The goal is to propose a direction of inquiry, not to establish formal results. We invite critique from both legal scholars and mathematicians. AI tools were adopted in the creation of this article.
1. The Starting Observation
Civil law is, at its core, a science of relations. Not things, not acts, but the structured connections between legal subjects — the debt that runs from debtor to creditor, the ownership that connects a person to a piece of land, the guardianship that links an adult to a child. This is not a novel observation. But it raises a question that has not, to our knowledge, been seriously pursued: if civil law is fundamentally about relations and their transformations, and if category theory is the mathematical language of pure relational structure, might category theory offer a natural foundation for civil law analysis?
2. The Closure of the Legal System
There is a structural parallel between Derrida’s il n’y a pas de hors-texte and the way civil law operates. A social fact only generates rights and duties if the law recognises it. Cohabitation is a social fact. Two people living together is real. But under current Chinese judicial interpretation, cohabitation as such generates no civil legal relationship, no rights of status, no duties of identity. The law is both the medium and the boundary of legally cognisable reality.
This closure is precisely what makes category theory a natural fit. A category is a closed formal system: objects are defined entirely by their morphisms, morphisms compose within the system, and the system specifies its own valid transformations. Civil law has exactly this character.
3. The Category $\mathcal{R}$ of Legal Relations
We propose reading the civil law system as a category $\mathcal{R}$:
- Objects are civil law subjects — natural persons, legal persons, unincorporated organisations.
- Morphisms $r \in \mathrm{Hom}(A, B)$ are civil legal relations directed from subject $A$ to subject $B$.
- Identity $\mathrm{id}_A$ is bare legal existence: subject $A$ bearing no relation and no obligation.
- Composition represents derived relations — chains of legal connection such as subrogation or successive assignment.
A first correction this framing delivers concerns the obligatory relation (债权). An earlier draft of our analytical framework labelled it an “object–object” relation because its performance often involves a physical thing. The categorical reading is precise: the debt $r \in \mathrm{Hom}(B, A)$ runs from debtor $B$ to creditor $A$. The thing to be delivered is the content of the morphism, not its endpoints.
Not every pair of composable morphisms yields a legally valid composition. Legal constraints restrict $\mathcal{R}$ to a proper subcategory $\mathcal{R}^{\mathsf{Law}} \hookrightarrow \mathcal{R}$, where admissibility is governed by conditions on capacity, form, content, and the basic principles of civil law.
4. CRUD Operations as Categorical Structures
The operational framework for civil legal relations identifies three fundamental operations: creation (1.1), extinction (1.2), and modification (1.3). Each maps onto a categorical structure of increasing expressiveness.
Creation as extension embedding. Forming a new legal relation means adding a morphism to $\mathcal{R}$. Formation is a functor $\iota : \mathcal{R} \hookrightarrow \mathcal{R}’$, the identity on objects but strictly extending the morphism sets. The obstacles to creation — defects in capacity, cognitive state, procedural form, or violations of public order — define a filter on candidate morphisms. In particular, the principle of 公序良俗 (public order and good morals, Article 8 of the Civil Code) acts as a terminal filter: a morphism that passes all other conditions is still expelled from $\mathcal{R}^{\mathsf{Law}}$ if its content violates Article 153(2). This reflects $\mathcal{R}^{\mathsf{Law}}$ being a full subcategory of legally recognised structures.
Extinction as deletion functor. When a legal relation is extinguished, its morphism collapses to the identity. The deletion functor $D_r$ maps $r \mapsto \mathrm{id}_B$ and leaves all other structure intact. This gives a precise reading of prescription (诉讼时效). When the three-year period expires, what is deleted is not the debt morphism $r$ itself — the substantive right persists — but a secondary morphism $\sigma_r$ representing the creditor’s right to enforce through litigation. This is why a debtor who voluntarily repays after prescription cannot recover the payment as unjust enrichment: the morphism $r$ was always there; only $\sigma_r$ was deleted.
Modification as natural transformation. When a contract is modified, we have two endofunctors — $F$ (original obligations) and $G$ (modified obligations) — and the modification agreement is a natural transformation $\eta : F \Rightarrow G$. The naturality condition, expressed as a commutative square for each morphism $r \in \mathrm{Hom}(A, B)$,
$$\begin{array}{ccc} F(A) & \xrightarrow{\eta_A} & G(A) \ \downarrow_{F(r)} & & \downarrow_{G(r)} \ F(B) & \xrightarrow{\eta_B} & G(B) \end{array}$$
captures the legal requirement of coherence: a change to one end of a relational chain must propagate consistently to the other. Debt assignment (债权让与) is codomain-reassignment — the same morphism content, rerouted from creditor $A$ to assignee $A’$. Statutory notice to the debtor (Article 546) is the commutativity witness, ensuring the debtor updates its internal representation of the endpoint. The change-of-circumstances doctrine (情势变更, Article 533) is modelled as a court-supplied canonical $\eta^{\ast}$ that makes the diagram commute at minimum displacement from the original obligations when the parties’ own renegotiation fails.
5. Competition Among Rights as Limits
A fundamental clarification in the framework is that relations do not conflict; rights and duties conflict, and only when they converge on a shared object. The categorical statement is: conflict is detected by the existence of a non-trivial co-cone over a diagram of convergent morphisms, and resolved by the choice of a preferred limit construction mandated by positive law.
Vertical competition (包括式竞合) — where one relation nests inside another — is functor composition. The guarantee functor $F_{\mathrm{guar}}$ acts on the output of the primary obligation functor $F_{\mathrm{main}}$. The rule that extinction of the primary obligation extinguishes the guarantee (Articles 388, 682) is a commutativity condition on deletion functors:
$$F_{\mathrm{guar}} \circ D_r ;=; D_r \circ F_{\mathrm{guar}}$$
Analysis proceeds bottom-up: verify the primary obligation first; if invalid, the guarantee collapses (subject to apparent authority doctrines); if valid, the guarantee follows the fate of the primary debt.
Horizontal competition (共存式竞合) — where multiple independent relations converge on the same object $Z$ — is a limit problem. When $r_1 \in \mathrm{Hom}(X_1, Z)$ and $r_2 \in \mathrm{Hom}(X_2, Z)$ both terminate at the contested asset, the priority rules of civil law specify which limiting construction is chosen. Different priority regimes correspond to different limit constructions. The categorical framework clarifies the form of the choice without determining its content, which remains the province of positive law.
The priority ordering on morphism tiers — real rights above secured obligations above unsecured obligations, with lateral insertions for lease-surviving-sale (Article 725) and pre-registered notices (Article 221) — is a partial order on the morphisms of $\mathcal{R}$ that the law imposes when a shared object cannot satisfy all claims simultaneously.
6. The Monad of Civil Law
At the highest level of abstraction, the civil law system as a whole has the structure of a monad $(T, \eta, \mu)$ on $\mathcal{R}$, where $T : \mathcal{R} \to \mathcal{R}$ is the “legally interpreted” version of the relational system, the unit $\eta_A : A \to T(A)$ embeds a bare social fact into the legally cognisable system (法律事实的认定), and the multiplication $\mu_A : T(T(A)) \to T(A)$ collapses sequential legal acts into a single net legal result.
The monad laws carry jurisprudential content. Associativity expresses that the order of evaluating nested legal acts does not affect the final relational state. The unit laws express that recognising an already-legal relation does not change it, and that applying the law to a bare fact and immediately evaluating gives the same result as the legal relation directly.
The principle of 公序良俗 acts as a submonad constraint. The valid civil relations form a proper submonad $T^{\mathsf{Law}} \hookrightarrow T$, and the “legally void” sector — social-fact-shaped structures that cannot be embedded into $T^{\mathsf{Law}}$ — is the complement, excluded by Articles 8 and 153(2).
7. Time Enrichment
The static category $\mathcal{R}$ has no temporal structure, but civil law is saturated with it: prescription periods, age thresholds for capacity, time-of-registration priority. The appropriate enrichment is the functor category $[\mathcal{T}, \mathcal{R}]$, where $\mathcal{T} = (\mathbb{R}_{\geq 0}, \leq)$ is the time-ordered poset viewed as a category. In $[\mathcal{T}, \mathcal{R}]$, morphisms are functions of time. Civil capacity becomes a time-varying object attribute with discontinuous jumps at the statutory thresholds of 8 and 18 years. The litigation morphism $\sigma_r$ is defined only on the interval $[t_0,, t_0 + 3,\text{years}]$, giving an intrinsic categorical account of prescription.
8. Limitations
Three honest limitations must be acknowledged. First, $\mathcal{R}$ may not have all limits: priority rules have gaps and hard cases where courts exercise discretion. The framework requires either weak limits or a supplementary judicial functor supplying missing constructions. Second, not every morphism chain is legally meaningful: subrogation and similar derived relations require specific statutory conditions that naive categorical composition does not enforce; a partial category or restricted composition law is needed. Third, judicial discretion — adjusting unconscionable penalty clauses, filling gaps by good faith — is not a deterministic functorial operation and would require a probabilistic or Kleisli-categorical extension to model adequately.
These are open problems, not objections to the framework. We present this perspective as a starting point for a more rigorous programme.
This post is part of a larger project constructing a unified analytical framework for civil law. A more formal development, including commutative diagrams and proofs of the principal propositions, is contained in the accompanying working paper.