Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Named source locations for ordinary matrix multiplication

Definition
CLRS_Chapter4_Algo2LeanExamples_MatrixMultiplyPoints

by Chutong · Oct 11, 2026 · Mathlib 0df444a (Lean v4.33.1)

algo2leanalgo2lean-clrs-chapter4-fd33cf9algorithmsclrsrunning-timetextbook

These observations identify named source locations and local variables in one supplied configuration of the compiled ordinary matrix multiplication program. A location predicate expresses program position only: it does not imply reachability from function entry or fix a transcript. The interface supports local loop contracts while leaving the generated algorithm definitions independent of label changes.

Formalization Note. This content is transcribed from Algo2Lean development snapshot fd33cf959b39f9e4a9fcfda4ef31d5a36b784d41, with explicit platform import and namespace adaptation. It is not attributed to public compiler v0.1.4. The submitted definition bundle must be checked without unfinished-proof assumptions.

Definition code
import Definitions.Def_CLRS_Chapter4_Algo2Lean
import Definitions.Def_CLRS_Chapter4_Algo2LeanExamples_MatrixMultiplyGenerated
import Std

set_option autoImplicit false
set_option backward.isDefEq.respectTransparency false
set_option backward.defeqAttrib.useBackward true

namespace CLRS

-- Generated by Algo2Lean 0.1.1 https://github.com/lunjiah/algo2lean

namespace «MatrixMultiplyLibrary»

open _root_.CLRS.Algo2LeanGenerated


open Algo2LeanGenerated

-- Named-line observations; changing labels leaves the imported algorithm unchanged.

-- Before source line 10, column 5; location only, not reachability.
def matrix_dot.At.dot_loop : Configuration → Prop
  | .active _ (.fn_matrix_dot 4 _) _ => True
  | _ => False
def matrix_dot.Local.a : Configuration → Option CollectionRef
  | .active _ (.fn_matrix_dot pc s) _ => if pc = 4 then some s.v0 else none
  | _ => none

def matrix_dot.Local.b : Configuration → Option CollectionRef
  | .active _ (.fn_matrix_dot pc s) _ => if pc = 4 then some s.v1 else none
  | _ => none

def matrix_dot.Local.n : Configuration → Option Int
  | .active _ (.fn_matrix_dot pc s) _ => if pc = 4 then some s.v2 else none
  | _ => none
def matrix_dot.Local.row : Configuration → Option Int
  | .active _ (.fn_matrix_dot pc s) _ => if pc = 4 then some s.v3 else none
  | _ => none
def matrix_dot.Local.column : Configuration → Option Int
  | .active _ (.fn_matrix_dot pc s) _ => if pc = 4 then some s.v4 else none
  | _ => none
def matrix_dot.Local.k : Configuration → Option Int
  | .active _ (.fn_matrix_dot pc s) _ => if pc = 4 then some s.v5 else none
  | _ => none
def matrix_dot.Local.total : Configuration → Option Int
  | .active _ (.fn_matrix_dot pc s) _ => if pc = 4 then some s.v6 else none
  | _ => none

-- Before source line 21, column 5; location only, not reachability.
def matrix_row.At.columns_loop : Configuration → Prop
  | .active _ (.fn_matrix_row 4 _) _ => True
  | _ => False
def matrix_row.Local.a : Configuration → Option CollectionRef
  | .active _ (.fn_matrix_row pc s) _ => if pc = 4 then some s.v0 else none
  | _ => none

def matrix_row.Local.b : Configuration → Option CollectionRef
  | .active _ (.fn_matrix_row pc s) _ => if pc = 4 then some s.v1 else none
  | _ => none

def matrix_row.Local.n : Configuration → Option Int
  | .active _ (.fn_matrix_row pc s) _ => if pc = 4 then some s.v2 else none
  | _ => none
def matrix_row.Local.row : Configuration → Option Int
  | .active _ (.fn_matrix_row pc s) _ => if pc = 4 then some s.v3 else none
  | _ => none
def matrix_row.Local.result : Configuration → Option SeqRef
  | .active _ (.fn_matrix_row pc s) _ => if pc = 4 then some s.v4 else none
  | _ => none

def matrix_row.Local.column : Configuration → Option Int
  | .active _ (.fn_matrix_row pc s) _ => if pc = 4 then some s.v5 else none
  | _ => none

-- Before source line 32, column 5; location only, not reachability.
def matrix_multiply.At.rows_loop : Configuration → Prop
  | .active _ (.fn_matrix_multiply 4 _) _ => True
  | _ => False
def matrix_multiply.Local.a : Configuration → Option CollectionRef
  | .active _ (.fn_matrix_multiply pc s) _ => if pc = 4 then some s.v0 else none
  | _ => none

def matrix_multiply.Local.b : Configuration → Option CollectionRef
  | .active _ (.fn_matrix_multiply pc s) _ => if pc = 4 then some s.v1 else none
  | _ => none

def matrix_multiply.Local.n : Configuration → Option Int
  | .active _ (.fn_matrix_multiply pc s) _ => if pc = 4 then some s.v2 else none
  | _ => none
def matrix_multiply.Local.result : Configuration → Option CollectionRef
  | .active _ (.fn_matrix_multiply pc s) _ => if pc = 4 then some s.v3 else none
  | _ => none

def matrix_multiply.Local.row : Configuration → Option Int
  | .active _ (.fn_matrix_multiply pc s) _ => if pc = 4 then some s.v4 else none
  | _ => none


end «MatrixMultiplyLibrary»

end CLRS
Source
Algo2Lean Chapter 4 development, module Algo2LeanExamples.MatrixMultiplyPoints, immutable source fd33cf959b39f9e4a9fcfda4ef31d5a36b784d41: https://github.com/chutongyang98/Lean_formalization/blob/fd33cf959b39f9e4a9fcfda4ef31d5a36b784d41/examples/matrix_multiply.algo; https://github.com/chutongyang98/Lean_formalization/blob/fd33cf959b39f9e4a9fcfda4ef31d5a36b784d41/examples/analysis/matrix_multiply.lean

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me