AFTD Auto-Formalizing Theoretical Domains

doubled_triangle_edge_faces

def

Given an edge e of type DoubledTriangleEdge n in the doubled equilateral triangle triangulation T(n), doubled_triangle_edge_faces returns the ordered pair of faces (DoubledTriangleFace n × DoubledTriangleFace n) incident to e, with boundary edges returning the front and back up faces, and interior edges returning the up face and down face on the same sheet.

Statement

def doubled_triangle_edge_faces {n : ℕ} (e : DoubledTriangleEdge n) :
    DoubledTriangleFace n × DoubledTriangleFace n
Defined in
arXiv:2611.12065, Section 2.1
Verified
10 Nov 2026
Axioms
none listed
Built on 2
  • DoubledTriangleFaceA face of the doubled equilateral triangle triangulation T(n) of side n, which is either an up-triangle U(i,j) or a down-triangle D(i,j)…
  • DoubledTriangleEdgeThe inductive type DoubledTriangleEdge n of edges in the doubled equilateral triangle triangulation T(n), with six constructors:…
Used by 2

Read back from the Lean

A function doubled_triangle_edge_faces that takes an implicit natural number n and an edge e : DoubledTriangleEdge n of a doubled triangle of parameter n, and returns an ordered pair of faces (f₁, f₂) : DoubledTriangleFace n × DoubledTriangleFace n incident to e, defined by cases on e: 1. If e = DoubledTriangleEdge.horiz_boundary i for i : Fin n: returns (DoubledTriangleFace.up true i ⟨0, _⟩ _, DoubledTriangleFace.up false i ⟨0, _⟩ _), pairing the front and back upward-pointing faces at coordinate (i, 0). 2. If e = DoubledTriangleEdge.horiz_interior front i j h hj for front : Bool, i, j : Fin n, h : (i : ℕ) + j < n, and hj : 0 < (j : ℕ): returns (DoubledTriangleFace.up front i j h, DoubledTriangleFace.down front i ⟨(j : ℕ) - 1, _⟩ _), pairing the upward-pointing face at (i, j) and the downward-pointing face at (i, j - 1) on the sheet specified by front. 3. If e = DoubledTriangleEdge.vert_boundary j for j : Fin n: returns (DoubledTriangleFace.up true ⟨0, _⟩ j _, DoubledTriangleFace.up false ⟨0, _⟩ j _), pairing the front and back upward-pointing faces at coordinate (0, j). 4. If e = DoubledTriangleEdge.vert_interior front i j h hi for front : Bool, i, j : Fin n, h : (i : ℕ) + j < n, and hi : 0 < (i : ℕ): returns (DoubledTriangleFace.up front i j h, DoubledTriangleFace.down front ⟨(i : ℕ) - 1, _⟩ j _), pairing the upward-pointing face at (i, j) and the downward-pointing face at (i - 1, j) on the sheet specified by front. 5. If e = DoubledTriangleEdge.diag_boundary i for i : Fin n: returns (DoubledTriangleFace.up true i ⟨n - 1 - (i : ℕ), _⟩ _, DoubledTriangleFace.up false i ⟨n - 1 - (i : ℕ), _⟩ _), pairing the front and back upward-pointing faces at coordinate (i, n - 1 - i). 6. If e = DoubledTriangleEdge.diag_interior front i j h for front : Bool, i, j : Fin n, and h : (i : ℕ) + j + 1 < n: returns (DoubledTriangleFace.up front i j _, DoubledTriangleFace.down front i j h), pairing the upward-pointing face at (i, j) and the downward-pointing face at (i, j) on the sheet specified by front.

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 two faces incident to an edge of T(n). -/
def doubled_triangle_edge_faces {n : ℕ} (e : DoubledTriangleEdge n) :
    DoubledTriangleFace n × DoubledTriangleFace n := match e with
  | .horiz_boundary i =>
    have hn : 0 < n := lt_of_le_of_lt (Nat.zero_le (i : ℕ)) i.isLt
    have h : (i : ℕ) + 0 < n := by omega
    (DoubledTriangleFace.up true i ⟨0, hn⟩ h, DoubledTriangleFace.up false i ⟨0, hn⟩ h)
  | .horiz_interior front i j h hj =>
    have hj_pred : (j : ℕ) - 1 < n := by omega
    have h_down : (i : ℕ) + ((j : ℕ) - 1) + 1 < n := by omega
    (DoubledTriangleFace.up front i j h, DoubledTriangleFace.down front i ⟨(j : ℕ) - 1, hj_pred⟩ h_down)
  | .vert_boundary j =>
    have hn : 0 < n := lt_of_le_of_lt (Nat.zero_le (j : ℕ)) j.isLt
    have h : 0 + (j : ℕ) < n := by omega
    (DoubledTriangleFace.up true ⟨0, hn⟩ j h, DoubledTriangleFace.up false ⟨0, hn⟩ j h)
  | .vert_interior front i j h hi =>
    have hi_pred : (i : ℕ) - 1 < n := by omega
    have h_down : ((i : ℕ) - 1) + (j : ℕ) + 1 < n := by omega
    (DoubledTriangleFace.up front i j h, DoubledTriangleFace.down front ⟨(i : ℕ) - 1, hi_pred⟩ j h_down)
  | .diag_boundary i =>
    have hj_val : n - 1 - (i : ℕ) < n := by omega
    have h : (i : ℕ) + (n - 1 - (i : ℕ)) < n := by omega
    (DoubledTriangleFace.up true i ⟨n - 1 - (i : ℕ), hj_val⟩ h,
     DoubledTriangleFace.up false i ⟨n - 1 - (i : ℕ), hj_val⟩ h)
  | .diag_interior front i j h =>
    have h_up : (i : ℕ) + j < n := by omega
    (DoubledTriangleFace.up front i j h_up, DoubledTriangleFace.down front i j h)
See it in the graphDiscuss this resultChallenge it