  We study gauge theories and quantum gravity in a finite interval of time
$\tau $, on a compact space manifold $\Omega $. The initial, final and boundary
conditions are formulated in gauge invariant and general covariant ways by
means of purely virtual extensions of the theories, which allow us to
"trivialize" the local symmetries and switch to invariant fields (the invariant
metric tensor, invariant quark and gluon fields, etc.). The evolution operator
$U(t_{\text{f}},t_{\text{i}})$ is worked out diagrammatically for arbitrary
initial and final states, as well as boundary conditions on $\partial \Omega $,
and shown to be well defined and unitary for arbitrary $\tau
=t_{\text{f}}-t_{\text{i}}<\infty $. We illustrate the basic properties in
Yang-Mills theory on the cylinder.
