An optical Bragg-like microcavity can be formed when extremely short light pulses interacting coherently with
the medium collide in the resonant medium. Here we present an analytical approach, based on the approximate
solution of the time-dependent Schrödinger equation, that reveals both the cavity formation and its control by the
half-cycle pulses colliding in the medium. This approach allows the calculation of cavity properties in the weakfield regime without the need for complex numerical simulations. Beyond the approximate analytical solutions,
our analytical results are confirmed by numerical simulations of the Maxwell-Bloch equations. Grating formation
is also studied in the strong-field regime, where collisions of self-induced transparency half-cycle pulses occur.
The results presented here reveal, to our knowledge, a new type of spatio-temporal photonic crystal in the form of
micro-cavities in a simple atomic medium. The results obtained demonstrate the feasibility of attosecond optical
switching in a simple atomic medium with half-cycle pulses.