I'm looking for directions to the literature that might contain fairly explicit constructions that might be called (the algebra of functions on) the "derived mapping space" from a simplicial set to a simplicial (affine) scheme. To make the question reasonably self-contained and to give a sense of my background and current understanding, I will begin with some general abstract nonsense, and then point to a construction that I have found in the literature and that does not work to my satisfaction.


A little abstract nonsense
--------------------------


Let $C$ and $D$ be categories. In a bit, I will give them specific values, but for now I will ask only that $D$ be small, and that $C$ have any necessary limits and colimits. A *(generalized) $D$-object in $C$* is a presheaf on $D$ valued in $C$, i.e. a functor $X : D^{\mathrm{op}}\to C$. Each $d\in D$ determines (and is determined by) a $D$-object in $\mathrm{SET}$, by the usual Yoneda embedding $d \mapsto \operatorname{hom}\_D(-,d)$. It will be convenient for me to denote the presheaf $\operatorname{hom}\_D(-,d)$ by $[d]$, and given $k\in D$ and $X : D^{\mathrm{op}}\to C$, I will write $X\_k$ for $X(k)$.


For $x\in C$ and $s\in \mathrm{SET}$, there is an object $\operatorname{maps}(s,x) = x^s = \prod\_s x \in C$, which is the $s$-fold cartesian product of $x$ with itself. Now, let $X : D^{\mathrm{op}} \to C$ be a $D$-object in $C$, and $S: D^{\mathrm{op}} \to \mathrm{SET}$ a $D$-set. Then there is an object $\operatorname{hom}\_D(S,X) \in C$, which is built as a certain limit ranging over the objects $\operatorname{maps}(S\_k,X\_k)$ for $k\in D$. Even better, the categories of $D$-sets and $D$-objects in $C$ have products — the ("categorical") cartesian product of functors is constructed by taking the product for each — and so we can define an enriched hom by:
$$ \underline{\operatorname{hom}}\_D(S,X) : D^{\mathrm{op}} \to C, \quad d \mapsto \operatorname{hom}\_D(S \times [d],X). $$
Finally, there is one more, much more naive "mapping space" between $D$-objects, which I will denote by $\operatorname{maps}(S,X) : D \times D^{\mathrm{op}} \to C$, sending $(d,k) \mapsto \operatorname{maps}(S\_d,X\_k)$.


A little concrete nonsense
--------------------------


I will be interested in the situation where $D = \Delta$ is the category of finite nonempty totally-ordered sets (and monotonic maps). It has a skeletalization with objects indexed by the natural numbers, given by $[n] = \lbrace 0 < \dots < n \rbrace$. Note that the $\Delta$-set $[0]$ is terminal, so $\underline{\operatorname{hom}}\_D(S,X)\_0 = \operatorname{hom}\_D(S,X)$. An object $X : D^{\mathrm{op}} \to C$ determines, among other data, two maps $X\_1 \rightrightarrows X\_0$, corresponding to the two inclusions $[0] \rightrightarrows [1]$. By definition, $\pi\_0(X) \in C$ is the coequalizer of the two arrows $X\_1 \rightrightarrows X\_0$.


Fix a commutative ring $\mathbb K$. I will not be upset if you would like to make further assumptions on $\mathbb K$, e.g. that $\mathbb K \supseteq \mathbb Q$, or that $\mathbb K$ is an algebraically closed field. I believe that I am primarily interested in the following two values for $C$, but I am open to being convinced otherwise:


1. $C = \mathrm{CAlg}^{\mathrm{op}}\_{\mathbb K}$ is the category of affine schemes over $\mathbb K$.
2. $C = \mathrm{Mod}\_{\mathbb K}$ is the category of $\mathbb K$-modules.


There is a well-known contravariant forgetful functor $\mathcal O$ from $\mathrm{CAlg}^{\mathrm{op}}\_{\mathbb K}$ to $\mathrm{Mod}\_{\mathbb K}$.


I will also take inspiration from the case $C = \mathrm{Top}$ of nice enough topological spaces.


There is a further functor $\operatorname{ch}: \Delta\mathrm{Mod}\_{\mathbb K} \to \mathrm{DGMod}\_{\mathbb K}$ (the category of homologically-graded chain complexes of $\mathbb K$-modules) which sets $\operatorname{ch}(X)\_k = X\_k$ with differential a certain well-known alternating sum. There is a standard symmetric monoidal structure on $\mathrm{DGMod}\_{\mathbb K}$ which sums the homological degrees, and for this structure $\operatorname{ch}$ is not strongly monoidal, but there is a canonical *Eilenberg–Zilber* map $\operatorname{ch}(X) \otimes \operatorname{ch}(Y) \to \operatorname{ch}(X \otimes Y)$, which sums over all $(k+\ell)$-simplices in a product of a $k$-simplex with an $\ell$-simplex (closely related is the fact that for simplicial sets, the geometric realization of a product is *homeomorphic* to the product (in the category of compactly-generated spaces) of geometric realizations), making $\operatorname{ch}$ into a "lax symmetric monoidal functor". The Eilenberg–Zilber map is a quasi-isomorphism, and one choice of quasi-inverse is the (non-symmetric) *Alexander–Whitney* map; if $\mathbb K \supseteq \mathbb Q$, there are other more symmetrical choices. In any case, the Eilenberg–Zilber map means that any simplicial commutative algebra determines canonically a dg commutative algebra. Of course, when $C = \mathrm{CAlg}^{\mathrm{op}}\_{\mathbb K}$, a simplicial affine scheme $X : \Delta^{\mathrm{op}} \to \mathrm{CAlg}^{\mathrm{op}}\_{\mathbb K}$ determines a *co*simplicial commutative algebra $\mathcal{O}(X)$, and so $\operatorname{ch}(\mathcal{O}(X))$ is not quite a dgca (the Alexander–Whitney map makes it into a dga). Anyway, this all won't matter much for me.



What I wanted to mention about all this is that if $X : \Delta^{\mathrm{op}} \to \mathrm{CAlg}^{\mathrm{op}}\_{\mathbb K}$ is a simplicial affine scheme, then $\operatorname{H}\_\bullet(\operatorname{ch}(\mathcal{O}(X)))$ is canonically a graded commutative algebra (supported in nonpositive homological degrees; and there is more algebraic data in the form of Massey products) and
$$ \operatorname{H}\_0(\operatorname{ch}(\mathcal{O}(X))) = \mathcal{O}(\pi\_0(X)). $$



Examples
--------


Let $A$ be a commutative $\mathbb K$-algebra, with corresponding affine scheme $X = \operatorname{spec}(A) \in \mathrm{CAlg}^{\mathrm{op}}\_{\mathbb K}$. If you want, you can extend $X$ to a constant functor $X : \Delta^{\mathrm{op}} \to \mathrm{CAlg}^{\mathrm{op}}\_{\mathbb K}$. Let $S^1$ denote the simplicial set generated by one nondegenerate $0$-simplex and one nondegenerate $1$-simplex. Then $\operatorname{maps}(S^1, X)$ is a cosimplicial affine scheme (or simplicial cosimplicial, but constant in the simplicial direction), and so $\mathcal{O}(\operatorname{maps}(S^1, X))$ is a simplicial commutative algebra. By definition,
$$ \operatorname{HH}\_\bullet(A) = \operatorname{H}\_\bullet(\operatorname{ch}(\mathcal{O}(\operatorname{maps}(S^1, X)))) $$
is the *Hochschild homology* of $A$. The complex $\operatorname{ch}(\mathcal{O}(\operatorname{maps}(S^1, X)))$ can be alternately defined by making a certain choice of resolution of $A$ as an $(A\otimes A)$-module, and using this resolution to construct the derived tensor product $A \otimes\_{A\otimes A} A$.



Let $G$ be an affine algebraic group over $\mathbb K$ (e.g. a finite group). There is a well-known simplicial affine scheme $X = \mathrm{B}G$ whose space of $k$-simplices is $G^k$, with boundary maps that encode the multiplication. Let $M$ be a simplicial set, and I am primarily interested in the case that $M$ is a simplicial finite set describing the homotopy type of a finite-dimensional compact manifold. The simplicial affine scheme $\underline{\operatorname{hom}}\_\Delta(M,\mathrm{B}G)$ is the space if *$G$-local systems on $M$*. In particular, $\pi\_0(\underline{\operatorname{hom}}\_\Delta(M,\mathrm{B}G))$ is the *character variety* of $M$.



My question
-----------


I am looking for a general construction, of the flavor above, that incorporates both examples. More specifically, the construction should:


* input a simplicial (finite) set $M$ and a a simplicial affine scheme $X$ over $\mathbb K$
* output a chain complex $V(M,X)$ over $\mathbb K$, supported in both directions, that deserves to be thought of as a "derived space of global functions on the space of maps from $M$ to $X$"
* have good functoriality and monoidality properties in both variables (implying for instance that $V(M,X)$ has a strongly-homotopy commutative dg algebra structure, coming from various diagonal and Eilenberg–Zilber-like maps)
* if $X = \operatorname{spec}(A)$ is a constant simplicial scheme, then $V(M,\operatorname{spec}(A))$ is the generalized Hochschild homology of $A$ determined by $M$
* $\operatorname{H}\_0(V(M,X)) = \mathcal{O}(\pi\_0(\underline{\operatorname{hom}}\_\Delta(M,X)))$


Some near misses
----------------


The problem seems to be when $X$ is not "simply connected". In particular, I have not come across a construction that works even when $X = \mathrm{B}G$ for $G$ a finite simple group.


Greg Ginot and collaborators (see e.g. [Higher order Hochschild cohomology](http://www.math.jussieu.fr/~ginot/papers/Higher-Order-Hochschild-Long.pdf), [Derived Higher Hochschild Homology, Topological Chiral Homology and Factorization algebras](http://arxiv.org/abs/1011.6483), and [A Chen model for mapping spaces and the surface product](http://arxiv.org/abs/0905.2231)) have extended [work by Pirashvili](http://archive.numdam.org/ARCHIVE/ASENS/ASENS_2000_4_33_2/ASENS_2000_4_33_2_151_0/ASENS_2000_4_33_2_151_0.pdf) defining the generalized Hochschild homology. Let $A$ be a cdga over $\mathbb K \supseteq \mathbb Q$ and let $M$ be a simplicial set. Then there is a simplicial cdga $\int\_M A = \mathcal{O}(\operatorname{maps}(M,\operatorname{spec}(A)))$ with good functoriality and monoidality properties, which agrees up to quasi-isomorphism with Lurie's "topological chiral homology." 


By definition, a *quasi-isomorphism* of cdgas is a morphism that induces isomorphisms on homology. One of the things that Ginot et al prove is that a quasi-isomorphism $A \to B$ induces a quasi-isomorphism $\int\_M A \to \int\_M B$. Thus in particular when $A = \mathcal{O}(\mathrm{B}G) = \operatorname{Ext}\_G(\mathbb K,\mathbb K)$, for any meaning of this, and $G$ is a finite simple group, then the canonical map $\mathbb K \to A$ is a quasi-isomorphism, and so the chain complex $\int\_M A$ will never contain data. So this construction fails my last condition, e.g.: $\pi\_0(\underline{\operatorname{hom}}\_\Delta(S^1,\mathrm{B}G)) = G/G^{\mathrm{conj}}$ and $\mathcal{O}(\pi\_0(\underline{\operatorname{hom}}\_\Delta(S^1,\mathrm{B}G))) = \mathcal{O}(G)^G$ is the algebra of class functions on $G$, whereas $\operatorname{H}\_0(\int\_{S^1}\mathcal{O}(\mathrm{B}G)) = \mathbb K$.


Ben-Zvi and Nadler have discussed [loop spaces and connections](http://arxiv.org/abs/1002.3636) their relationships to Hochschild homology and [representations](http://arxiv.org/abs/1004.5120). They run into what I believe are related issues, but work primarily with not the space of loops in a derived scheme, but rather the infinitesimal neighborhood of the constant loops within that space. I should also mention that for my particular application, I really am looking for an explicit one-categorical construction (akin to the Pirashvili-style work), rather than quickly moving to model or $\infty$ categories.


Finally, perhaps the result I should have started with is one I learned from [a review by Loday](http://arxiv.org/abs/1110.0405) (original references are included there). Suppose that $M$ is a simplicial approximation of an $n$-dimensional manifold, and that $X$ is a simplicial set which is *$n$-connected*, in $\pi\_{\leq n}(X)$ is trivial. (So *$1$-connected* means connected simply-connected.) I can build a cosimplicial simplicial set $\operatorname{maps}(M,X)$, and a simplicial set $\underline{\operatorname{hom}}\_\Delta(M,X)$, as discussed above. There is a \_free $\mathbb K$-module\_ functor $\mathbb K : \mathrm{SET} \to \mathrm{Mod}\_{\mathbb K}$, and with is I get a cosimplicial simplicial $\mathbb K$-module $\mathbb K\operatorname{maps}(M,X)$ and a simplicial $\mathbb K$-module $\mathbb K\underline{\operatorname{hom}}\_\Delta(M,X)$. Of course, given a cosimplicial simplicial $\mathbb K$-module, I can apply the "alternating sum of boundaries" functor $\operatorname{ch}$ to get a bicomplex, which I can then totalize. Unless I have made a mistake, I believe the statement is that under the conditions on $M$ and $X$, the canonical map of chain complexes between $\operatorname{ch}(\mathbb K\operatorname{maps}(M,X))$ and $\operatorname{ch}(\mathbb K\underline{\operatorname{hom}}\_\Delta(M,X))$ is a quasi-isomorphism. This example specifically does not include classifying spaces of finite groups.


 Final comments and examples
----------------------------


Truth be told, I am most interested in the case $X = \mathrm B G$ for $G = \mathrm{SL}(2)$ and $M$ a simplicial approximation of a three-manifold. Note that the topological space $\mathrm{B}(\mathrm{SL}(2,\mathbb C))$ is $3$-connected (it is homotopy equivalent to $\mathrm{B}(\mathrm{Spin}(3,\mathbb R))$), but I don't have a good sense about notions like "3-connected" for algebraic stacks. And, besides, I would like a robust construction.


Let me end with an example that does work. A much easier category than $\mathrm{CAlg}^{\mathrm{op}}\_{\mathbb K}$ is the category $\mathrm{CCog}\_{\mathbb K}$ of cocommutative coalgebras (or "cogebres" in French, hence the name). A group object in $\mathrm{CCog}\_{\mathbb K}$ is a *cocommutative* Hopf algebra, and a good example is the universal enveloping algebra $U\mathfrak g$ of a Lie algebra $\mathfrak g$. Then $\mathrm B U\mathfrak g = \mathrm B \mathfrak g$ is a simplicial cocommutative coalgebra, which is quasi-isomorphic to the dg cocomutative coalgebra $\mathrm{CE}(\mathfrak g)$ of Chevalley–Eilenberg cochains with trivial coefficients. I believe that it \_is\_ true that Hochschild homology of $\mathrm{CE}(\mathfrak g)$ is the Chevalley–Eilenberg cochain complex with coefficients in $U\mathfrak g$, as it should be if you think about loop spaces.




Is there an algebraic "derived mapping space" construction that encompasses both Hochschild homology and loop spaces of non-simply-connected spaces?
There is a standard answer to your question, unless I'm missing something, that I learned from the great [survey by Toen](http://arxiv.org/abs/math/0604504) and satisfies everything you want. However to satisfy your requirements - ie to get the correct Hochschild complex - you must (explicitly or implicitly) embed simplicial schemes into a larger world of derived algebraic geometry, ie change from rings to simplicial rings (cosimplicial affine schemes) or some variant (homological cdgas in characteristic zero for example).


The construction is "the obvious one" - given any finite simplicial set think of it as a constant functor on your category of affines and construct the mapping space into your given target $X$.
Then pass to functions on the mapping space $X^M$, ie (derived) global sections of the structure sheaf.
When $M=S^1$, then say $BG^{S^1}=G/G$ the adjoint quotient stack. For any (derived) ring $R$ we have 
that functions on $Spec(R)^{S^1}$ is Hochschild chains of $R$ (very close to the definition).
Much stronger things are true about these loop spaces, eg for any perfect stack (a very large class of well behaved stacks with affine diagonal map, eg any quasicompact separated scheme) and any finite simplicial set we have $QC(X^M)\simeq QC(X)\otimes M$ ($QC$=quasicoherent sheaves).
$BSL\_2$ is such a perfect stack (in characteristic not 2 I think) and $BSL\_2^M$ is a great object to consider, with $QC(BSL\_2^M)$ being functions on the derived stack of $SL\_2$ local systems on your space $M$. Not sure what else you want to hold but this is a very robust nice functorial monoidal construction which has already seen quite a lot of applications.


