Minimal perfect systems are Latin squares with equiprobable keys
OpenShannonSecrecy.perfect_secrecy_latin_squareShannon 1949, §10, p. 681. Perfect systems in which the number of cryptograms, the number of messages, and the number of keys are all equal are characterized by the properties that (1) each message is connected to each cryptogram by exactly one line, and (2) all keys are equally likely; thus the matrix representation of the system is a "Latin square".
Concretely: let a finite secrecy system have perfect secrecy and satisfy . Then
- for every message and every cryptogram there is exactly one key with , and
- all keys have the same a priori probability (necessarily ).
Consequently the table whose entry is the unique key carrying to is a Latin square: each key occurs exactly once in each row and once in each column. This identifies the minimal perfect systems — those meeting the bound "as many keys as messages" — up to relabelling.
Formalization Note "Exactly one line from to " is the unique-existence of a key with ; "all keys equally likely" is stated as the equality of the a priori probabilities of any two keys, from which the value follows by normalization. The cardinality hypotheses are exactly Shannon's "the number of cryptograms, the number of messages, and the number of keys are all equal".
import Definitions.Def_shannon_secrecy_system
namespace ShannonSecrecy
theorem perfect_secrecy_latin_square
{M K E : Type*} [Fintype M] [Fintype K] [Fintype E] [DecidableEq E]
(C : Cipher M K E) (h : PerfectSecrecy C)
(hMK : Fintype.card M = Fintype.card K) (hKE : Fintype.card K = Fintype.card E) :
(∀ (m : M) (e : E), ∃! k : K, C.encipher k m = e) ∧
∀ k k' : K, C.keyProb k = C.keyProb k' := 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 , , be finite types with decidable equality on , and let be a cipher: injective maps for , weights with . Assume:
- has the perfect-secrecy property — for every with and , for every with nonzero total probability , and for every , the a posteriori ratio equals ;
- ;
- .
The conclusion is a conjunction:
- (i) for every message and every cryptogram there exists a unique key with — existence and uniqueness, for every pair, with no exclusion of any or ;
- (ii) for all keys , ; that is, the key weights are constant. The common value is not named in the statement, although constancy together with pins it down.
Degenerate case: if all three types are empty — excluded here, since forces to be nonempty — both clauses would be vacuous. With the cardinality hypotheses force and to be nonempty as well, so clause (i) has content. Nothing in the conclusion mentions a Latin square or a matrix; it is the pair of properties (i) and (ii) only.