A Bayesian approach to high-fidelity interferometric calibration – I. Mathematical formalism. Issue 1 (5th July 2022)