AFTD Auto-Formalizing Theoretical Domains

opl2_first_freq

def

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 x : Fin n, the first entry frequency opl2_first_freq M x is the cardinality of the finset of cell indices (r, c) : Fin n × Fin n such that (M r c).map Prod.fst = some x.

Statement

def opl2_first_freq {n : ℕ} (M : Fin n → Fin n → Option (Fin n × Fin n)) (x : 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 : Fin n → Fin n → Option (Fin n × Fin n), and an element x : Fin n, opl2_first_freq M x is defined as the number of pairs p = (p₁, p₂) : Fin n × Fin n such that (M p₁ p₂).map Prod.fst = some x (i.e., M p₁ p₂ is some (a, b) with a = x).

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 x as a first entry in an n × n partial array of pairs. -/
def opl2_first_freq {n : ℕ} (M : Fin n → Fin n → Option (Fin n × Fin n)) (x : Fin n) : ℕ :=
  ((Finset.univ : Finset (Fin n × Fin n)).filter (fun p => (M p.1 p.2).map Prod.fst = some x)).card
See it in the graphDiscuss this resultChallenge it