Certificate-chain evaluator for BirdDet.birdDet #
This file contains an evaluator that computes the ring tactic normal form of
Mathlib.LinearAlgebra.Matrix.Determinant.Bird.Defs.birdDet via iteratively
unfolding its definition, using the ring tactic for ring operations, and caching
intermediate certificates.
The structure Cert rα carries the proof certificate and the evaluator builds
larger certificates as birdDet is unfolded.
The entrypoint of the evaluator certBirdDet follows the two branches (n=0,
n=k+1) of the birdDet function:
certBirdDet (birdDet n A)
n = 0:
birdDet n A
= 1 -- via BirdDet.birdDet_zero
= ring normal form of 1 -- via certEval
n = k + 1:
birdDet n A
= (-1)^k * (stepEntry n A)^[k] (get n A) 0 0 -- via BirdDet.birdDet_eq
= ring normal form of the product -- certMul (certBirdSign k) (certIterStepEntry k 0 0)
The (stepEntry n A)^[k] (get n A) i j expression branches on k, so
certIterStepEntry has two branches:
certIterStepEntry k i j
k = 0:
(stepEntry n A)^[0] F i j
= F i j -- via Function.iterate_zero_apply
= ring normal form of A[i][j] -- via certEntry i j
k = t + 1:
(stepEntry n A)^[t + 1] F i j
= -(sumFrom n (i + 1) fun k => (stepEntry n A)^[t] F k k) * get n A i j
+ sumFrom n (i + 1) fun k => (stepEntry n A)^[t] F i k * get n A k j
-- via Function.iterate_succ_apply'
= normal form of the first summand + normal form of the second summand
-- via certAdd
(certMul (certNeg (certDiag t (i + 1))) (certEntry i j))
(certTail t i j (i + 1))
Then the certDiag and certTail functions certify the two kinds of sumFrom
expressions.
The evaluator also memoizes certIterStepEntry, certDiag and certEntry to
improve performance.
Main definitions #
certEntrycertifiesBirdDet.get.certSumFromStopandcertSumFromStepcertifyBirdDet.sumFrom_stopandBirdDet.sumFrom_step.certIterStepEntrycertifies entries of(BirdDet.stepEntry n A)^[t] (BirdDet.get n A).certBirdDetcertifiesBirdDet.birdDet_zeroandBirdDet.birdDet_eq.
The ring tactic normal-form value.
Equations
Instances For
The ring tactic result carried by a certificate.
Equations
- Mathlib.Tactic.Determinant.CertResult rα subject = Mathlib.Tactic.Ring.Common.Result (Mathlib.Tactic.Determinant.CertVal rα) subject
Instances For
Return the expression (stepEntry n A)^[t] (get n A).
Equations
- ctx.iterStepEntry t = q((BirdDet.stepEntry unknown_1 unknown_2)^[«$t»] (BirdDet.get unknown_1 unknown_2))
Instances For
Return an expression sumFrom n lo f
Equations
- ctx.sumFrom lo f = q(BirdDet.sumFrom unknown_1 «$lo» «$f»)
Instances For
A certificate that proves subject = result.norm via result.proof
- subject : Q(«$α»)
The expression being certified.
- result : CertResult rα self.subject
The result of evaluating
subjectusing the ring tactic. - isZero : Bool
truewhennormis zero, used as a hint to the evaluator.
Instances For
Prepend an equality to an existing normalized certificate.
Given c.proof : s.subject = c.norm and h : lhs = s.subject return a
certificate with proof : lhs = c.norm.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Cache certificates that are reused by the recursive Bird evaluator.
- entryCache : Std.HashMap (ℕ × ℕ) (Cert rα)
Cache for entry certificates, keyed by matrix indices.
Cache for iterated
stepEntrycertificates, keyed by step and matrix indices.- diagCache : Std.HashMap (ℕ × ℕ) (Cert rα)
Cache for diagonal-tail certificates, keyed by recursion index and lower bound.
Instances For
The monad used by the certificate-chaining evaluator
Equations
Instances For
Checks if val is zero according to the ring tactic
Equations
Instances For
Construct a Cert rα from a ring tactic result
Equations
- Mathlib.Tactic.Determinant.toCert res = { subject := e, result := res, isZero := Mathlib.Tactic.Determinant.isZeroVal res.val }
Instances For
Build a zero certificate from a proof lhs = 0.
Equations
- Mathlib.Tactic.Determinant.zeroCertOfProof h = { subject := lhs, result := { expr := q(0), val := Mathlib.Tactic.Ring.Common.ExSum.zero, proof := h }, isZero := true }
Instances For
If c.norm = 0, return a certificate with proof x * c.subject = 0 without
recursively certifying x.
Equations
Instances For
Certify e = norm by evaluating e with the ring normalizer.
Equations
- Mathlib.Tactic.Determinant.certEval e = do let ctx ← read let res ← liftM (Mathlib.Tactic.Ring.Common.eval Mathlib.Tactic.Ring.rcℕ ctx.rc ctx.cα e) pure (Mathlib.Tactic.Determinant.toCert res)
Instances For
Certify a.subject + b.subject from certificates for a and b.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Certify a.subject * b.subject from certificates for a and b.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Certify -a.subject from a certificate for a.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Certify the sign factor (-1)^k from BirdDet.birdDet_eq.
Equations
Instances For
Certify one matrix entry lookup BirdDet.get n A i j.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Certify the stop branch of BirdDet.sumFrom.
This corresponds to the else 0 branch of:
sumFrom n lo f = if lo < n then f lo + sumFrom n (lo + 1) f else 0
Throws a meta-level error if called with lo such that lo < ctx.dimension.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Certify the step branch of BirdDet.sumFrom.
This corresponds to the lo < n branch of:
sumFrom n lo f = if lo < n then f lo + sumFrom n (lo + 1) f else 0
Throws a meta-level error if called with lo such that ¬ lo < ctx.dimension.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Certify an entry of (BirdDet.stepEntry n A)^[t] (BirdDet.get n A).
Certify the diagonal tail sum in one BirdDet.stepEntry application:
sumFrom n (i + 1) fun k => (stepEntry n A)^[t] F k k)
Certify the upper-tail sum in one BirdDet.stepEntry application:
sumFrom n (i + 1) fun k => (stepEntry n A)^[t] F i k * get n A k j
Certify a BirdDet.birdDet n A call.
Equations
- One or more equations did not get rendered due to their size.