opl2_second_freq
Given a natural number n, an n × n partial array of pairs M : Fin n → Fin n → Option (Fin n × Fin n), and an element y : Fin n, the second entry frequency opl2_second_freq M y is the cardinality of the finset of cell indices (r, c) : Fin n × Fin n such that (M r c).map Prod.snd = some y.
Statement
def opl2_second_freq {n : ℕ} (M : Fin n → Fin n → Option (Fin n × Fin n)) (y : Fin n) : ℕ- Defined in
- arXiv:2611.13961, Section 2
- Verified
- 13 Nov 2026
- Axioms
- none listed
Read back from the Lean
Given a natural number $n$, a function $M : \text{Fin } n \to \text{Fin } n \to \text{Option}(\text{Fin } n \times \text{Fin } n)$, and an element $y : \text{Fin } n$, opl2_second_freq M y is defined as the cardinality of the set of pairs $(i, j) \in \text{Fin } n \times \text{Fin } n$ such that $(M(i, j)).\text{map}(\text{Prod.snd}) = \text{some } y$ (that is, $M(i, j)$ is defined and its second component is equal to $y$).
Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.
Lean source view module on GitHub
/-- The number of occurrences of y as a second entry in an n × n partial array of pairs. -/ def opl2_second_freq {n : ℕ} (M : Fin n → Fin n → Option (Fin n × Fin n)) (y : Fin n) : ℕ := ((Finset.univ : Finset (Fin n × Fin n)).filter (fun p => (M p.1 p.2).map Prod.snd = some y)).card