AFTD Auto-Formalizing Theoretical Domains

opl2_filled_count

def

Given a natural number n and an n × n partial array of pairs M : Fin n → Fin n → Option (Fin n × Fin n), the number of filled cells opl2_filled_count M is the cardinality of the finset of indices (r, c) : Fin n × Fin n such that M r c is not none.

Statement

def opl2_filled_count {n : ℕ} (M : Fin n → Fin n → Option (Fin n × Fin n)) : ℕ
Defined in
arXiv:2611.13961, Section 1
Verified
13 Nov 2026
Axioms
none listed

Read back from the Lean

For a natural number n and a function M : Fin n → Fin n → Option (Fin n × Fin n), opl2_filled_count M is defined as the cardinality of the set of pairs p = (p₁, p₂) ∈ Fin n × Fin n such that M p₁ p₂ is not none (that is, (M p₁ p₂).isSome holds).

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 filled cells F in an n × n partial array of pairs. -/
def opl2_filled_count {n : ℕ} (M : Fin n → Fin n → Option (Fin n × Fin n)) : ℕ :=
  ((Finset.univ : Finset (Fin n × Fin n)).filter (fun p => (M p.1 p.2).isSome)).card
See it in the graphDiscuss this resultChallenge it