  Maxwell's Demon, 'a being whose faculties are so sharpened that he can follow
every molecule in its course', has been the centre of much debate about its
abilities to violate the second law of thermodynamics. Landauer's hypothesis,
that the Demon must erase its memory and incur a thermodynamic cost, has become
the standard response to Maxwell's dilemma, and its implications for the
thermodynamics of computation reach into many areas of quantum and classical
computing. It remains, however, still a hypothesis. Debate has often centred
around simple toy models of a single particle in a box. Despite their
simplicity, the ability of these systems to accurately represent thermodynamics
(specifically to satisfy the second law) and whether or not they display
Landauer Erasure, has been a matter of ongoing argument. The recent
Norton-Ladyman controversy is one such example.
  In this paper we introduce a programming language to describe these simple
thermodynamic processes, and give a formal operational semantics and program
logic as a basis for formal reasoning about thermodynamic systems. We formalise
the basic single-particle operations as statements in the language, and then
show that the second law must be satisfied by any composition of these basic
operations. This is done by finding a computational invariant of the system. We
show, furthermore, that this invariant requires an erasure cost to exist within
the system, equal to kTln2 for a bit of information: Landauer Erasure becomes a
theorem of the formal system. The Norton-Ladyman controversy can therefore be
resolved in a rigorous fashion, and moreover the formalism we introduce gives a
set of reasoning tools for further analysis of Landauer erasure, which are
provably consistent with the second law of thermodynamics.
