((In conclusion)


It was hard to choose which answer to accept. I decided for the one which addressed most of the various aspects of the question.


)


(Later addon)


I now decided to put a bounty on this, and want to put particular accent on one aspect of the question that puzzles me most.


As discussed in greater length below, at the first sight from the point of view of Homotopy Type Theory (HoTT) the situation seems next to trivial: if we view $f:X\to Y$ as a family $X\_y:=f^{-1}(y)$ of spaces continuously varying over $Y$ then, if $Y$ is connected, HoTT squeezes water out of it and leaves the plain fact "all $y$ are equal to each other". This then implies that all $X\_y$ are equal to each other.


But on the other hand, the above argument completely ignores the fact that the fibration associated to $f$ might be nontrivial, i.e. one might be unable to uniformly pick simultaneous equalities $X\_y=X\_{y'}$ for all pairs $y$, $y'$. So, on top of having this next to trivial description of homotopy fibers, seemingly HoTT must also possess techniques to detect nontriviality of the fibration, etc. What are they?


End(Later addon)


One of the most basic constructions in homotopy theory assigns to a map $f:X\to Y$ another map $\pi\_f:P\_f\to Y$ such that $P\_f$ is equivalent to $X$ and (under connectedness assumption for $Y$) all $\pi\_f^{-1}(y)$ are equivalent to each other. $P\_f$ is the space of all pairs $(x,\gamma)$ where $x\in X$ and $\gamma$ is a path in $Y$ with $\gamma(0)=x$.


I would like to view this construction from a familial perspective. Namely, I want to view $f$ as a family $X\_y:=f^{-1}(y)$ of spaces continuously varying over $Y$. Then, we are constructing another family $\check X\_y$ from it, with$$
\check X\_y=\bigcup\_{y'}\operatorname{paths}(y,y')\times X\_{y'}.
$$That spaces in this family are pairwise equivalent is ensured by the fact that any path between $y\_1$ and $y\_2$ produces equivalences between $\operatorname{paths}(y\_1,y')$ and $\operatorname{paths}(y\_2,y')$ for all $y'$.


From this point of view, the equivalence of total spaces is clear from $$\bigcup\_{y,y'}\operatorname{paths}(y,y')\times X\_{y'}=\bigcup\_{y'}\left(\bigcup\_y\operatorname{paths}(y,y')\right)\times X\_{y'},$$as the spaces in parentheses are contractible.


Now this way of formulating it suggests that there must be many other situations where a similar construction is present. 


The most likely area is of course Homotopy Type Theory. I am pretty sure that something like this is used very frequently there. Could I have a specific reference - how is it called there and what does it mean conceptually from the type-theoretic/logical point of view?


It also looks like some sort of generalization for the associated bundle <-> principal bundle business. Is a generalization along these lines known?


I am especially interested in the context of moduli spaces in algebraic geometry. Some moduli spaces (like projective spaces or, more generally, Grassmanians) manifestly consist of equivalent objects but some others do not. Is there a way to modify moduli spaces in a way similar to the above, to arrive at some equivalent moduli spaces consisting of equivalent objects?


I have vague feeling that this construction might be related to switching from coarse moduli spaces to fine moduli stacks, does this make sense and can it be made rigorous?


If this is not too much, one more question.


A dual construction suggests itself,$$
\hat X\_y=\prod\_{y'}X\_{y'}^{\operatorname{paths}(y,y')}.
$$It is as easy to show that all $\hat X\_y$ are equivalent to each other. However this time I think total space is not equivalent to the total space of the original family. Instead, the spaces of all global sections are equivalent.


Does this dual thing occur anywhere? This time I don't even know whether it is used in homotopy theory itself.



Can Homotopy Type Theory or algebraic geometry deal with homotopy fibers in terms of families?
Yes, there is a certain sense in which your statements are true. As Mike Shulman and Qiaochu Yuan said, the strict fiber of a map cannot be defined in HoTT and doesn't make sense, but you can work from the other direction: instead of trying to associate a family of types to a map start with an arbitrary type family $P: X \to Type$. This includes any classical Serre fibrations: you associate to a point a fiber over it and to higher dimensional simplices some choice of their lifting, which is possible to do coherently by the path lifting property of fibrations. In the simplest case of a flat bundle you can make an explicit choice of lifts, which defines an equivalence between flat bundles and representations of the fundamental group of $X$. Homotopy-theoretically "every bundle is flat" in a sense that any two maps between fibers induced by a pair of equivalent paths are themselves (noncanonically) equivalent. The magic of HoTT and its models allows us to assume that all fibrations are given as representations of the path groupoid: path induction allows us to prove that any map of types is functorial in the sense that paths map to paths, composition to composition etc for all higher relations. This shows that a type family $P: X \to Type$ associates to any point $x: X$ a type $P(x): Type$, to any path $s: x=y$ a homotopy equivalence $ P(x) = P(y)$ etc (a map from paths in $Type$ to equivalences is automatic by path induction). In certain cases we can turn a coherent system of equivalences between fibers into a type family over $X$. The simplest case is when $X$ is defined as a higher inductive type, since higher inductive types are defined as representing objects of certain systems of equivalences between types. See chapter 6, in particular [6.12 The flattening lemma] in the HoTT book.


Given a type family $P: X \to Type$ we can construct its total space $Y := \sum\_{x:X} P(x)$ with a canonical projection map $Y \xrightarrow{p} X$ defined by induction on $\Sigma$. Then we can consider the type family of homotopy fibers of $p$: $$x:X \vdash \mathrm{fib}\_p(x) := \left( \sum\_{y:Y} x = p(y) \right) : Type$$


The resulting type family is equal to $P$ in the sense $\prod\_{x:X} P(x) = \mathrm{fib}\_p(x)$. By univalence we need to provide a homotopy equivalence between fibers. The map from left to right is the obvious inclusion of a strict fiber into a homotopy one. The map from right to left is constructed via induction on $\Sigma$ and paths. In the other direction, to any map $Y \xrightarrow{f} X$ we can associate its fiber type family $\mathrm{fib}\_f$ and its total space $\sum\_{x:X} \mathrm{fib}\_f(x)$. It will be equivalent to $Y$ as objects over $X$. The relevant reference here is [4.8 The object classifier] in the HoTT book. 


Essentially the big statement at work here is that from the PoV of higher category theory, the core groupoid for the overcategory $\mathbb{S}\_{/X}$ is "representable" by a certain object $Type: \mathbb{S}$ (more formally, we consider a filtration of the overcategory by subcategories of bounded increasing cardinalities and require that each of these functors should be representable, thus getting an increasing sequence of objects $Type\_{\kappa}$, see HTT [6.1.6. $\infty$-topoi and classifying objects]). In classical 1-topos theory and set theory this statement is limited to $(-1)$-truncated morphisms and type families and corresponds to the comprehension principle: any subset can be defined by a proposition which is true exactly for the elements of this subset, and vice versa. Type theory extends this principle to arbitrary constructions: any statement $P:X \to Type$ defines a type of "structures" on $X$ (the sigma type), and equivalently any map of types can be defined by some statement in a sense of a type family.


Regarding your "dual" construction: your type is defined as $\prod\_{y^\prime} \prod\_{y = y^\prime} X\_{y^\prime}$. By path induction this type is equivalent to $X\_y$, so your type family is equivalent to $X$.


Regarding the moduli spaces: I don't think this construction has really anything to do with them. Not that it's entirely irrelevant, but moduli spaces carry much more structure than homotopy types and you can't get around that unless you're willing to sacrifice most information. One possibility is to consider moduli spaces as stacks of groupoids on the Zariski (étale, flat, ...) site. Sheaves of groupoids naturally form a higher topos and should be a model of HoTT, however the information you get this way is mostly trivial: if your classified objects don't have any automorphisms, then the stack will be just a sheaf of sets, and if you have automorphisms, then you'll get the tautological description of locally isomorphic objects. Another possibility would be to enlarge your notion of equivalence, for example you could state that all fibers of the universal family are equivalent, e.g. by saying that an equivalence of $E$ and $E^\prime$ can be given as any fibration $X$ over $\mathbb{A}^1$ such that $X(0) \simeq E$ and $X(1) \simeq E^\prime$. This feels a lot like $\mathbb{A}^1$-homotopy theory, but I can't state anything more meaningful. In any case it feels like most (all?) of the algebraic information would be lost, even if one is very careful with definitions (I already see some problems in the one above).


Abstractly, the story of the moduli spaces is the story about classifying ringed topoi, while HoTT speak only about objects of a single higher topos (or topoi that arise as their overcategories). Sort of orthogonal beasts.


Regarding your "associated bundle --- principal bundle" comment. Indeed, one can view this construction for connected spaces in a similar way. Assume given a point $x:X$ and $X$ connected, then fibrations $P:X \to Type$ over $X$ are equivalent to homotopy representations of the ($A\_\infty$-)group of loops $\Omega\_x X$ in the automorphisms $Aut(P(x))$ of the fiber $P(x)$. This is certainly true in classical homotopy theory of spaces, but in HoTT there are complications. First there is a problem with the definition of $A\_\infty$-groups and their representations, which we will ignore. The construction itself in one direction is obvious, we already know that each loop induces an automorphism of the fiber. In the other direction $y=x$ is a right torsor over $\Omega\_x X$ so we can take the product over the loop group $(y = x) \times\_{\Omega\_x X} P(x)$. Classically this gives us back $P$, but in HoTT this requires clarification.


We define a $(\infty, 1)$-category $C$ as a type of objects $Ob\_C: Type$ and a family of morphism types $a,b:C \vdash C(a,b): Type$, together with units and composition which we suppress in the following discussion. As usual, a groupoid is a category in which all morphisms are invertible, and for any category $C$ we have its core groupoid $C^\sim$ which is the largest subgroupoid in $C$. For any $X: Type$ its path groupoid $\Pi X: Cat$ has $Ob\_{\Pi X} = X$ and $a, b:X \vdash \Pi X(a, b) := (a = b) : Type$. A category is called *univalent* if the natural functor $\Pi Ob\_C \to C^\sim$ is an equivalence. Our definition of a category follows the Segal space approach, and univalent categories are precisely complete Segal spaces. The category of types $Type$ has $Ob\_{Type} = Type$ and $X,Y : Type \vdash Type(X, Y) := (X \to Y)$. The classical axiom of univalence is precisely the statement that $Type$ is an univalent category. We also define the geometric realization functor $|C|$ as the left adjoint to the path groupoid functor, i.e. $Type(|C|, X) = Cat(C, \Pi X)$. For any ($A\_\infty$-)group or monoid $G$ we define the delooping category $\mathbb B G$ as $Ob\_{\mathbb B G} = 1$, $\mathbb B G(\ast, \ast) = G$. Presheaves of types on $\mathbb B G$ are the same as representations of $G$.


Now, the correspondence between type families and group representations stated above in these terms says that for any connected $X: Type$ with $x: X$ the categories $\mathbb B \Omega\_x X$ and $\Pi X$ are Morita equivalent, i.e. their categories of type presheaves are equivalent. We have an obvious inclusion $\mathbb B \Omega\_x X \to \Pi X$, however this is *not* an equivalence of categories, since an equivalence on object types would restrict to the statement $\forall y: X, x = y$ which means that $X$ is contractible. This is in stark contrast with the 1-categorical situation where any groupoid is equivalent to its full subgroupoid on one object. The classical statement relies on a choice principle to choose an equivalence for each nonempty $C(x, y)$, but constructively we can't have such strong choice. One can argue that this failure is due to non-univalence of $\mathbb B \Omega\_x X$ and it's true in a sense, but I have two objections. The first is that the truth of this equivalence for univalent subcategories is itself a nontrivial theorem, essentially it is May's delooping theorem together with its version for path groupoids. Using such strong statements for a basic notion of equivalence doesn't seem like a good idea. The second is that the delooping category is an extremely natural object, and being unable to naturally talk about it would be a problem. I also find it troubling that the simple construction of delooping category for a monoid would suddenly blow up into a much more complex path category if the monoid is a group. Similarly, it is natural to select subcategories on a set of objects, or consider action groupoids for groups, and none of them would be categories under the univalence requirement (e.g. the action groupoid on a torsor would have "too few" morphisms to be univalent and to be equivalent to its geometric realization, which is a point). Even the basic 1-categorical definition of a category wouldn't be a category if we require all categories to be univalent. Sure, we could do the Rezk completion, but that extra step would be unnecessary in half of situations and very nontrivial in the other half.


Non-univalent categories will break the homotopy hypothesis, but I view it as a lesser evil in this case. Groupoids should be *at least* as complicated as homotopy types, but there is no reason why they couldn't contain more information. 


That said, univalence of $Type$ is a very natural requirement. In particular, I don't know how to prove the Morita equivalence above without the univalence axiom, or even if it's true. With univalence it is easy to prove that for any groupoid its category of presheaves is equivalent to the category of type families over its geometric realization:


$$\begin {eqnarray}
C & \to & Type & \simeq\\
C & \to & Type^\sim & \simeq \\
C & \to & \Pi Type & \simeq \\
|C| & \to & Type & \simeq \\
\Pi |C| & \to & Type
\end{eqnarray}
$$


Together with the delooping theorem $|\mathbb B \Omega\_x X| = X$, $|\Pi X| = X$ this proves the Morita equivalence above. The part about path groupoids is easy to prove, but I'm not sure that the part about $\mathbb B$ can be proved without univalence.


In summary, assuming univalence, type families over connected inhabited types can be uniquely reconstructed from their fiber over some point together with an action of the loop group on it. At the moment there is no type-theoretic reference for the constructions that I performed above, but something like that should be in books on higher categories and topology.


