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.
翻译:暂无翻译