AFTD Auto-Formalizing Theoretical Domains

comparison_triangle_kappa

def

The real triangle relation vector kappa_abc : comparison_feature2 n → ℝ of a triangle a < b < c: kappa_abc = e_(ab,ac) - e_(ab,bc) + e_(ac,bc) - e_0, i.e. it is 1 at the quadratic coordinate of the edge set {ab, ac}, -1 at that of {ab, bc}, 1 at that of {ac, bc}, -1 at the constant coordinate, and 0 elsewhere.

Statement

def comparison_triangle_kappa {n : ℕ} (t : comparison_triangle n) : comparison_feature2 n → ℝ
Defined in
arXiv:2610.34762 (Quantum ordinal selection with two comparisons), Section 3.1, the notation before Lemma 1
Verified
08 Nov 2026
Axioms
none listed
Built on 5
  • comparison_feature2The type indexing the orthonormal coordinate basis of the formal quadratic feature space F_2 = span{1, d_e, d_e d_f}: the sum type of…
  • comparison_triangleThe type of triangles of the label set [n] = Fin n: the subtype of triples (a, (b, c)) in Fin n × Fin n × Fin n with a < b and b < c.
  • comparison_edgeThe type of edges of the label set [n] = Fin n: the subtype of pairs (a, b) in Fin n × Fin n with a < b, each unordered edge {a, b} being…
  • LinearOrder.toTotalPreorderEvery LinearOrder is a TotalPreorder.
  • TotalPreorderA total preorder: a preorder where ≤ is total (complete). This is weaker than LinearOrder — it does NOT require antisymmetry or…
Used by 6
  • comparison_pi_ord_mulVec_phi2Pi_ord fixes the quadratic evaluation vector phi_2(x) of every strict order x: U_triangle^T phi_2(x) = 0 by the triangle relations, hence…
  • comparison_triangle_kappa_mem_eval_kerEach triangle relation vector kappa_abc evaluates to zero on every strict order: d_ab d_ac - d_ab d_bc + d_ac d_bc - 1 = 0.
  • comparison_triangle_gramThe Gram matrix of the triangle relation vectors is U_triangle^T U_triangle = 3 I + 1 1^T: each kappa_abc has squared norm 4 and two…
  • comparison_triangle_matrixThe real matrix U_triangle with rows indexed by comparison_feature2 n and columns by triangles, whose column at the triangle t is the…
  • comparison_eval_ker_le_span_kappaEvery formal quadratic feature vector c in F_2 that evaluates to zero on every strict order (<phi_2(x), c> = 0 for all permutations x of…
  • quadratic_comparison_evaluation_kernel_and_projectorLet n >= 3, N = C(n,2), nu_triangle = C(n,3). Strict orders on [n] are given by permutations x of Fin n (x i = rank of label i); for an…

Read back from the Lean

Given a natural number n and a comparison triangle t = (a, b, c) in Fin n satisfying a < b < c, comparison_triangle_kappa defines a function from comparison_feature2 n (which is Option (comparison_edge n) ⊕ {s : Finset (comparison_edge n) // s.card = 2}) to ℝ. Specifically, letting ab = (a, b), ac = (a, c), and bc = (b, c) denote the three directed comparison edges formed from t, the function assigns: * 1 to Sum.inr {ab, ac} * -1 to Sum.inr {ab, bc} * 1 to Sum.inr {ac, bc} * -1 to Sum.inl none * 0 to all other elements of comparison_feature2 n.

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 real triangle relation vector kappa_abc : comparison_feature2 n → ℝ of a triangle a < b < c: kappa_abc = e_(ab,ac) - e_(ab,bc) + e_(ac,bc) - e_0, i.e. it is 1 at the quadratic coordinate of the edge set {ab, ac}, -1 at that of {ab, bc}, 1 at that of {ac, bc}, -1 at the constant coordinate, and 0 elsewhere. -/
def comparison_triangle_kappa {n : ℕ} (t : comparison_triangle n) : comparison_feature2 n → ℝ :=
  let ab : comparison_edge n := ⟨(t.1.1, t.1.2.1), t.2.1⟩
  let ac : comparison_edge n := ⟨(t.1.1, t.1.2.2), t.2.1.trans t.2.2⟩
  let bc : comparison_edge n := ⟨(t.1.2.1, t.1.2.2), t.2.2⟩
  have hab_ac : ab ≠ ac := fun h => (ne_of_lt t.2.2) (congrArg (fun p : comparison_edge n => p.1.2) h)
  have hab_bc : ab ≠ bc := fun h => (ne_of_lt t.2.1) (congrArg (fun p : comparison_edge n => p.1.1) h)
  have hac_bc : ac ≠ bc := fun h => (ne_of_lt t.2.1) (congrArg (fun p : comparison_edge n => p.1.1) h)
  let iabac : comparison_feature2 n := Sum.inr ⟨{ab, ac}, Finset.card_pair hab_ac⟩
  let iabbc : comparison_feature2 n := Sum.inr ⟨{ab, bc}, Finset.card_pair hab_bc⟩
  let iacbc : comparison_feature2 n := Sum.inr ⟨{ac, bc}, Finset.card_pair hac_bc⟩
  let i0 : comparison_feature2 n := Sum.inl none
  fun i => ((if i = iabac then 1 else 0) - (if i = iabbc then 1 else 0)
    + (if i = iacbc then 1 else 0) - (if i = i0 then 1 else 0) : ℝ)
See it in the graphDiscuss this resultChallenge it