Documentation

CslibFrontier.Languages.Probabilistic.RandomPermutation.ExtPermsCard

Counting permutations that extend a finite partial assignment #

For k distinct domain points xs : Fin k ↪ α and target values ys : Fin k → α, the set RandomPermutation.extPerms (List.ofFn fun i => (xs i, ys i)) of permutations of a finite type α sending each xs i to ys i has at most (Fintype.card α)! / (Fintype.card α).descFactorial k elements. Equivalently, a uniformly random permutation takes k prescribed values at k distinct points with probability at most 1 / (|α| (|α| - 1) ⋯ (|α| - k + 1)). These results depend only on RandomPermutation.extPerms, not on any cipher construction.

Main results #

theorem Cslib.RandomPermutation.extPerms_ofFn_eq {α : Type} [Fintype α] [DecidableEq α] {k : ℕ} (xs ys : Fin k → α) :
extPerms (List.ofFn fun (i : Fin k) => (xs i, ys i)) = {π : Equiv.Perm α | ∀ (i : Fin k), π (xs i) = ys i}

The extensions of the cache List.ofFn fun i => (xs i, ys i) are the permutations sending every xs i to ys i.

theorem Cslib.RandomPermutation.card_extPerms_ofFn_eq {α : Type} [Fintype α] [DecidableEq α] {k : ℕ} (xs : Fin k → α) (e e' : Fin k ↪ α) :
(extPerms (List.ofFn fun (i : Fin k) => (xs i, e i))).card = (extPerms (List.ofFn fun (i : Fin k) => (xs i, e' i))).card

For distinct domain points xs, the number of permutations extending the cache List.ofFn fun i => (xs i, e i) does not depend on the injective target tuple e.

theorem Cslib.RandomPermutation.sum_card_extPerms_ofFn {α : Type} [Fintype α] [DecidableEq α] {k : ℕ} (xs : Fin k ↪ α) :
∑ e : Fin k ↪ α, (extPerms (List.ofFn fun (i : Fin k) => (xs i, e i))).card = (Fintype.card α).factorial

Summing the extension counts over all injective target tuples e : Fin k ↪ α counts every permutation of α exactly once.

theorem Cslib.RandomPermutation.card_extPerms_ofFn_mul_descFactorial_le {α : Type} [Fintype α] [DecidableEq α] {k : ℕ} (xs : Fin k ↪ α) (ys : Fin k → α) :

Falling-factorial upper bound on k-point extPerms fibers (original): for any k distinct domain points xs : Fin k ↪ α and any target values ys : Fin k → α, #(extPerms (List.ofFn fun i => (xs i, ys i))) * (Fintype.card α).descFactorial k ≤ (Fintype.card α).factorial.

The one-point case of card_extPerms_ofFn_mul_descFactorial_le: at most (Fintype.card α)! / Fintype.card α permutations of α send x to a.