Directed type theory, with a twist
Fernando Rafael Chu Rivera, Paige Randall North
cs.LO
Feb 19, 2026 · v2
TL;DR
All results are formalized, with AI assistance, in a fork of Lean 4 extended with rewrite rules, building on Mathlib, as statements about category models.
Abstract
In recent years, Homotopy Type Theory (HoTT) has had great success both as a foundation of mathematics and as an internal language to reason about $\infty$-groupoids (a.k.a. spaces). However, in many areas of mathematics and computer science, it is often the case that it is categories, not groupoids, which are the more important structures to consider. For this reason, multiple directed type theories have been proposed, i.e., theories whose semantics are based on categories. In this paper, we present a new directed type theory, Twisted Type Theory (TTT). It features a novel "twisting" operation on types: given a type $B$ that depends on a variable $a : A^\mathsf{op}$, its twist $\mathsf{Tw}_a(B)$ is a new kind of type that depends on $a : A$ instead, but without contravariance or covariance. To provide the semantics of this operation, we introduce dependent 2-sided fibrations (D2SFibs), which generalize Street's 2-sided fibrations. We develop the basic theory of D2SFibs and characterize them through a straightening-unstraightening theorem. With these results in hand, we give new introduction, elimination and computation rules for $\mathsf{Hom}$-types, whose semantics closely mirror those of $\mathsf{Id}$-types in Hofmann and Streicher's groupoid model. As a result, TTT allows reasoning about categories in a style similar to that of Homotopy Type Theory. We end the paper by exemplifying this, using TTT to prove a weak form of the Yoneda lemma. All results are formalized in a fork of Lean extended with rewrite rules.
Problem
Homotopy Type Theory reasons synthetically about ∞-groupoids, but many areas need categories instead. Existing directed type theories lack Hom-type rules that closely mirror Id-types in the groupoid model.
Approach
Twisted Type Theory (TTT) introduces a twisting operation that turns a type depending on a : A^op into one depending on a : A. Its semantics uses dependent 2-sided fibrations (D2SFibs), generalizing Street's 2-sided fibrations, which are characterized by a straightening-unstraightening theorem. New Hom-type intro, elimination and computation rules are validated in category models. All results are formalized in a Lean fork with global and local rewrite rules on top of Mathlib, as statements about the models rather than a deep embedding. Claude carried out the formalization under the authors' supervision.
Results
Category models validate the TTT rules. Directed univalence, an internalization of natural transformations and a weak Yoneda lemma are proved, all machine-checked in Lean.