Documentation

CslibFrontier.Algorithms.LinearAlgebra.SparseLDLRowRanges

Checking sparse certificates by row ranges #

The kernel keeps every term it reduces while it checks one declaration, so the memory of a decide +kernel proof of Cslib.LinearAlgebra.SparseLyapunovCert.check grows with the size of the certificate. This module splits the check into a cheap head, of shapes and lengths, and a check of the k rows from row a on, so that each declaration checks a limited range of output rows.

This limits the rows that one declaration checks, not, in general, what it reads or computes. A range check reaches its rows by List.drop, and the kernel reduces lazily, so the rows before a of the recomputed Lyapunov residual are skipped without being multiplied out. But every range still depends on data outside it:

So no memory bound in terms of the range size alone, or independent of n, is claimed. What was measured, on the benchmark families of #9452 (peak RSS of lake env lean, single-threaded, of which elaborating the certificate and checking the head take 1.6–2.0 GiB): ranges of 64 rows took 2.4 GiB against 5.8 GiB for one check (ladder, 512 states) and 3.7 GiB against 13.4 GiB (coupled ladders, 512 states), and ranges of 128 rows 4.1 GiB against 8.8 GiB (RC tree, 1023 states). With the range size fixed, the peak still grew with n: ranges of 64 rows took 2.0 and 2.4 GiB for ladders of 256 and 512 states, and 3.1 and 3.7 GiB for coupled ladders.

A client checks the head and each range by decide +kernel, in separate theorems, and combines them with SparseLyapunovCert.checkRows_add and SparseLyapunovCert.check_of_checkRows into c.check n A P = true, the hypothesis of SparseLyapunovCert.posDef_of_check. The soundness theorems are therefore the same; a range proof is only a way to evaluate the same checker.

The split is exactly as complete as check (SparseLyapunovCert.check_iff_checkHead_and_checkRows): check accepts if and only if the head and every range accept. A remainder may have more than n rows. They do not change the matrix ofSparse n n, but check still asks them to be diagonally dominant and to agree with the rows below n that store their columns, so cutting them off would not be harmless. The head checks them instead (transRows and ddRows from row n on), which costs nothing for the usual remainder of n rows.

Main definitions #

Main results #

Transposes and dominance on a range of rows #

def Cslib.LinearAlgebra.transRows {α : Type u_1} [Add α] [Zero α] [BEq α] (A B : List (List (ℕ × α))) (a k : ℕ) :

Whether the stored entries of the rows a, …, a + k - 1 of A agree with the transposed entries of B: the part of transGo 0 [] B A for those rows. The zipper starts with the rows of B before row a, reversed.

theorem Cslib.LinearAlgebra.transRows_add {α : Type u_1} [Add α] [Zero α] [BEq α] {A B : List (List (ℕ × α))} {a k₁ k₂ : ℕ} (h₁ : transRows A B a k₁ = true) (h₂ : transRows A B (a + k₁) k₂ = true) :
transRows A B a (k₁ + k₂) = true
theorem Cslib.LinearAlgebra.transRows_of_transGo {α : Type u_1} [Add α] [Zero α] [BEq α] {A B : List (List (ℕ × α))} (h : transGo 0 [] B A = true) (a k : ℕ) :
transRows A B a k = true

An accepted transGo 0 [] B A accepts every range.

def Cslib.LinearAlgebra.ddRows (rows : List (List (ℕ × ℚ))) (a k : ℕ) :

Whether the rows a, …, a + k - 1 of rows are diagonally dominant by their stored entries: the part of ddGo 0 rows for those rows.

theorem Cslib.LinearAlgebra.ddRows_add {rows : List (List (ℕ × ℚ))} {a k₁ k₂ : ℕ} (h₁ : ddRows rows a k₁ = true) (h₂ : ddRows rows (a + k₁) k₂ = true) :
ddRows rows a (k₁ + k₂) = true
theorem Cslib.LinearAlgebra.ddRows_of_ddGo {rows : List (List (ℕ × ℚ))} (h : ddGo 0 rows = true) (a k : ℕ) :
ddRows rows a k = true

Envelope certificates on a range of rows #

Whether the rows a, …, a + k - 1 of the n × n matrix with sparse rows rows agree with L * diagonal d * Lᵀ on the envelope and store only zeros left of it: the part of checkGo [] c.lower c.diag rows for those rows. The data of the rows above row a are those of the rows 0, …, a - 1 of c.

theorem Cslib.LinearAlgebra.EnvLDLCert.envRows_add (c : EnvLDLCert) {rows : List (List (ℕ × ℚ))} {a k₁ k₂ : ℕ} (h₁ : c.envRows rows a k₁ = true) (h₂ : c.envRows rows (a + k₁) k₂ = true) :
c.envRows rows a (k₁ + k₂) = true
theorem Cslib.LinearAlgebra.EnvLDLCert.envRows_of_checkGo (c : EnvLDLCert) {rows : List (List (ℕ × ℚ))} (hd : c.diag.length = c.lower.length) (hr : rows.length = c.lower.length) (h : checkGo [] c.lower c.diag rows = true) (a k : ℕ) :
c.envRows rows a k = true

The checks of factorsWith that do not walk the first n rows: c.lower and c.diag have n entries, the rows of L reach the diagonal and end in 1, and the rows of the remainder from row n on, if any, pass the symmetry and dominance checks.

The checks of factorsWith on the rows a, …, a + k - 1: the symmetry and diagonal dominance of the remainder and the envelope check of M - R.

theorem Cslib.LinearAlgebra.EnvLDLCert.factorsWithRows_add {c : EnvLDLCert} {rows : List (List (ℕ × ℚ))} {a k₁ k₂ : ℕ} (h₁ : c.factorsWithRows rows a k₁ = true) (h₂ : c.factorsWithRows rows (a + k₁) k₂ = true) :
c.factorsWithRows rows a (k₁ + k₂) = true
theorem Cslib.LinearAlgebra.EnvLDLCert.factorsWith_of_rows {c : EnvLDLCert} {n : ℕ} {rows : List (List (ℕ × ℚ))} (hr : rows.length = n) (hh : c.factorsWithHead n = true) (h : c.factorsWithRows rows 0 n = true) :
c.factorsWith n rows = true

The head and the range of the first n rows give factorsWith.

An accepted factorsWith accepts the head.

theorem Cslib.LinearAlgebra.EnvLDLCert.factorsWithRows_of_factorsWith {c : EnvLDLCert} {n : ℕ} {rows : List (List (ℕ × ℚ))} (hr : rows.length = n) (h : c.factorsWith n rows = true) (a k : ℕ) :

An accepted factorsWith for n rows accepts every range.

theorem Cslib.LinearAlgebra.EnvLDLCert.factorsWith_iff_rows {c : EnvLDLCert} {n : ℕ} {rows : List (List (ℕ × ℚ))} (hr : rows.length = n) :
c.factorsWith n rows = true ↔ c.factorsWithHead n = true ∧ ∀ (a k : ℕ), c.factorsWithRows rows a k = true

Checking factorsWith by ranges. For n rows, factorsWith accepts if and only if the head and every range accept.

The checks of factors that do not walk the first n rows: the shape of rows and factorsWithHead.

The checks of factors on the rows a, …, a + k - 1: the symmetry of rows and factorsWithRows.

theorem Cslib.LinearAlgebra.EnvLDLCert.factorsRows_add {c : EnvLDLCert} {rows : List (List (ℕ × ℚ))} {a k₁ k₂ : ℕ} (h₁ : c.factorsRows rows a k₁ = true) (h₂ : c.factorsRows rows (a + k₁) k₂ = true) :
c.factorsRows rows a (k₁ + k₂) = true
theorem Cslib.LinearAlgebra.EnvLDLCert.factors_of_rows {c : EnvLDLCert} {n : ℕ} {rows : List (List (ℕ × ℚ))} (hh : c.factorsHead n rows = true) (h : c.factorsRows rows 0 n = true) :
c.factors n rows = true

The head and the range of the first n rows give factors.

theorem Cslib.LinearAlgebra.EnvLDLCert.factors_iff_rows {c : EnvLDLCert} {n : ℕ} {rows : List (List (ℕ × ℚ))} :
c.factors n rows = true ↔ c.factorsHead n rows = true ∧ ∀ (a k : ℕ), c.factorsRows rows a k = true

Checking factors by ranges. factors accepts if and only if the head and every range accept.

Sparse Lyapunov certificates on a range of rows #

The checks of check that do not walk the first n rows: the shapes of A, Aᵀ and P, the heads of both envelope certificates, and the signs of their pivots.

The checks of check on the rows a, …, a + k - 1: that c.At is the transpose of A, and the envelope checks of P and of the residual -(Aᵀ * P + P * A), which is recomputed only on those rows.

theorem Cslib.LinearAlgebra.SparseLyapunovCert.checkRows_add {c : SparseLyapunovCert} {A P : List (List (ℕ × ℚ))} {a k₁ k₂ : ℕ} (h₁ : c.checkRows A P a k₁ = true) (h₂ : c.checkRows A P (a + k₁) k₂ = true) :
c.checkRows A P a (k₁ + k₂) = true
theorem Cslib.LinearAlgebra.SparseLyapunovCert.check_of_checkRows {c : SparseLyapunovCert} {n : ℕ} {A P : List (List (ℕ × ℚ))} (hh : c.checkHead n A P = true) (h : c.checkRows A P 0 n = true) :
c.check n A P = true

Checking by ranges. The head and the range of all rows give check, so that posDef_of_check and its clients apply. Adjacent ranges combine by checkRows_add.

Checking by ranges is exactly as complete as check. check accepts if and only if the head and every range of rows accept.