Shannon's Theorem 6: perfect secrecy
OpenShannonSecrecy.perfect_secrecy_iff_msgToCrypto_eq_cryptoProbShannon 1949, Theorem 6 (p. 680). A necessary and sufficient condition for perfect secrecy is that
that is, must be independent of .
Fix a finite secrecy system: finite sets of messages , keys and cryptograms , an injective enciphering map for each key , and an a priori key distribution . Write
for the total probability of the keys that carry the message to the cryptogram , and, for an a priori message distribution ,
The system has perfect secrecy when, for every a priori message distribution and every cryptogram with , the a posteriori probabilities coincide with the a priori ones: for all . Requiring this for every is Shannon's stipulation that the equality hold "independently of the values of " — he explicitly discards the alternative escape .
The theorem asserts the equivalence of that condition with the statement that, for every a priori message distribution and every message–cryptogram pair, the key weight equals the unconditional cryptogram probability . Equivalently: the total probability of all keys transforming into a given cryptogram equals that of all keys transforming into the same , for all , and .
This is the structural characterization on which the rest of §10 rests: it is what makes the counting argument for the number of keys, and the Latin-square description of minimal perfect systems, possible.
Formalization Note The right-hand side quantifies over all a priori distributions ; since the left-hand side of the equality does not depend on , this is the same as saying that is independent of together with its common value being . Cryptograms of probability zero are excluded from the definition of perfect secrecy, because the a posteriori probability is a real quotient and is not meaningful there.
import Definitions.Def_shannon_secrecy_system
namespace ShannonSecrecy
theorem perfect_secrecy_iff_msgToCrypto_eq_cryptoProb
{M K E : Type*} [Fintype M] [Fintype K] [Fintype E] [DecidableEq E]
(C : Cipher M K E) :
PerfectSecrecy C ↔
∀ p : M → ℝ, IsPMF p → ∀ (m : M) (e : E), msgToCrypto C m e = cryptoProb C p e := by sorry
end ShannonSecrecyRead-back
What the Lean code literally says, in plain math · Aristotle (Harmonic) — NON-BLIND: same agent that drafted the statement
Provenance note — this read-back is NOT independent testimony. It is non-blind: it was written by the same agent that drafted the Lean statement it describes, working from the source paper and from its own formalization intent, and not by an independent auditor with a fresh context who saw only the Lean code. It therefore cannot corroborate the faithfulness of the formalization — an agreement between the statement and this read-back is self-agreement. Treat it as an annotation by the author, and obtain a blind read-back before relying on it during audit or moderation.
Let , and be finite types, with decidable equality on , and let be a cipher on them: a family of maps indexed by , each injective, together with weights summing to . Write
Call a PMF when pointwise and .
The statement asserts the equivalence of the following two conditions.
- For every PMF , every with , and every ,
- For every PMF , every and every (with no exclusion of the case ), .
Both sides range over all PMFs , so neither fixes an a priori distribution. In condition 1 the quotient is a real division, which returns when its denominator is ; that case is excluded by hypothesis. In condition 2 the left-hand side does not depend on , so the condition forces to be the same real number for all PMFs and the same for all messages .
Degenerate cases included by the quantifiers: if is empty, no PMF exists, so both conditions hold vacuously and the equivalence is trivially true for such a cipher; may be empty, in which case both sides are again vacuous; keys of probability are permitted, and is automatically nonempty because the weights sum to . No hypothesis requires to be surjective, nor the sets to have equal cardinality.