coherent and strongly discrete rings in type theory · coherent rings theorem: possible to solve mx...
TRANSCRIPT
![Page 1: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/1.jpg)
Coherent and Strongly Discrete Rings inType Theory
Thierry Coquand, Anders Mortberg and Vincent Siles
Department of Computer Science and Engineering – Chalmers University ofTechnology and University of Gothenbug, Sweden
December 15 – CPP 2012
![Page 2: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/2.jpg)
Introduction
(0 21 0
)T (x1x2
)=
(20
)
(x1x2
)=
(02
)
![Page 3: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/3.jpg)
Introduction
(0 21 0
)T (x1x2
)=
(20
)
(x1x2
)=
(02
)
![Page 4: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/4.jpg)
Introduction
A=[ 0 2 ; 1 0 ];
b=[ 2 ; 0 ];
A’\b
ans =
0
1
![Page 5: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/5.jpg)
Introduction
A=[ 0 2 ; 1 0 ];
b=[ 2 ; 0 ];
A’\b
ans =
0
1
![Page 6: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/6.jpg)
Introduction
(02
)6=
(01
)
![Page 7: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/7.jpg)
Introduction
I “The bug seems to be new in release R2009b and applies toLinux and Windows 32 and 64 bit versions.”http://www.netlib.org/na-digest-html/09/v09n48.html
I A serious bug in Matlab2009b?http://www.walkingrandomly.com/?p=1964
![Page 8: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/8.jpg)
Introduction
Goal: Formally verified algorithms for solving (in)homogeneoussystems of equations over commutative rings in Coq/SSReflect
Motivation: Simplifying systems of differential equations,computing homology groups...
![Page 9: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/9.jpg)
Coherent rings
For every row matrix M ∈ R1×m there exists L ∈ Rm×n such that
MX = 0↔ ∃Y .X = LY
L generate the module of solutions for MX = 0
![Page 10: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/10.jpg)
Coherent rings
Theorem: Possible to solve MX = 0 where M ∈ Rm×n, i.e. wecan compute L such that
MX = 0↔ ∃Y .X = LY
Constructive proof ⇒ algorithm computing generators of solutions
Constructive proof = Program + Specification + Correctness proof
![Page 11: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/11.jpg)
Coherent rings
Theorem: Possible to solve MX = 0 where M ∈ Rm×n, i.e. wecan compute L such that
MX = 0↔ ∃Y .X = LY
Constructive proof ⇒ algorithm computing generators of solutions
Constructive proof = Program + Specification + Correctness proof
![Page 12: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/12.jpg)
Coherent rings
Fixpoint solve m n : forall (M : ’M_(m,n)),
’M_(n,size_solve M) := match m with
| S p => fun (M : ’M_(1+p,n)) =>
let G1 := solve_row (usubmx M) in
G1 *m solve (dsubmx M *m G1)
| _ => fun _ => 1%:M
end.
Lemma solveP m n (M : ’M[R]_(m,n)) (X : ’cV[R]_n) :
reflect (exists Y, X = solve M *m Y) (M *m X == 0).
Proof.
...
Qed.
![Page 13: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/13.jpg)
Coherent rings
How do we prove that R is coherent?
Theorem: If I ∩ J is finitely generated for finitely generated idealsI and J in R then R is coherent.
Problems: How do we represent I ∩ J? How do we represent ideals?
![Page 14: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/14.jpg)
Coherent rings
How do we prove that R is coherent?
Theorem: If I ∩ J is finitely generated for finitely generated idealsI and J in R then R is coherent.
Problems: How do we represent I ∩ J? How do we represent ideals?
![Page 15: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/15.jpg)
Coherent rings
How do we prove that R is coherent?
Theorem: If I ∩ J is finitely generated for finitely generated idealsI and J in R then R is coherent.
Problems: How do we represent I ∩ J?
How do we represent ideals?
![Page 16: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/16.jpg)
Coherent rings
How do we prove that R is coherent?
Theorem: If I ∩ J is finitely generated for finitely generated idealsI and J in R then R is coherent.
Problems: How do we represent I ∩ J? How do we represent ideals?
![Page 17: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/17.jpg)
Strongly discrete rings
There exists an algorithm testing if x ∈ I for finitely generatedideal I and if this is the case produce a witness.
That is, if I = (x1, . . . , xn) compute w1, . . . ,wn such that
x = x1w1 + · · ·+ xnwn
![Page 18: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/18.jpg)
Strongly discrete rings
There exists an algorithm testing if x ∈ I for finitely generatedideal I and if this is the case produce a witness.
That is, if I = (x1, . . . , xn) compute w1, . . . ,wn such that
x = x1w1 + · · ·+ xnwn
![Page 19: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/19.jpg)
Strongly discrete rings
I Suitable for developing ideal theory in type theory:I Decidable ideal membership: x ∈ II Decidable ideal inclusion: I ⊆ JI Decidable ideal equality: I = J ↔ I ⊆ J ∧ J ⊆ I
I Key idea: Represent finitely generated ideals as row matrices
![Page 20: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/20.jpg)
Ideals
Definition subid (I : ’rV[R]_m) (J : ’rV[R]_n) := ...
Notation "I <= J" := (subid I J).
Lemma subidP (I : ’rV[R]_m) (J : ’rV[R]_n) :
reflect (exists D, I = J *m D) (I <= J)%IS.
Definition addid (I : ’rV[R]_m) (J : ’rV[R]_n) :=
row_mx I J.
Notation "I +i J" := (addid I J).
Lemma subid_addidC (I : ’rV[R]_m) (J : ’rV[R]_n) :
(I +i J <= J +i I)%IS.
![Page 21: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/21.jpg)
I ∩ J revisited
I I ∩ J can be defined as an ideal such that:
I ∩ J ⊆ I
I ∩ J ⊆ J
∀x . (x ∈ I ∧ x ∈ J)→ x ∈ I ∩ J
I Now we can prove (constructively) that if I ∩ J is finitelygenerated then R is coherent
![Page 22: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/22.jpg)
Coherent strongly discrete rings
Recap:
I R is coherent if we can find generators for solutions ofMX = 0
I R is strongly discrete if we can decide if x ∈ I for a finitelygenerated ideal I in R
Theorem: If R is coherent and strongly discrete we can decide if asystem MX = A has a solution
![Page 23: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/23.jpg)
Coherent rings
Examples of coherent rings:
I Fields – Gaussian elimination
I Bezout domains – Z, Q[x ], . . .
I Prufer domains – Z[√−5], Q[x , y ]/(y2 − 1 + x4), . . .
I Polynomial rings – k[x1, . . . , xn] via Grobner bases
I ...
![Page 24: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/24.jpg)
Coherent rings
Examples of coherent rings:
I Fields – Gaussian elimination
I Bezout domains – Z, Q[x ], . . .
I Prufer domains – Z[√−5], Q[x , y ]/(y2 − 1 + x4), . . .
I Polynomial rings – k[x1, . . . , xn] via Grobner bases
I ...
![Page 25: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/25.jpg)
Bezout domains
I Bezout domains: Every finitely generated ideal is principal, i.e.for all finitely generated ideals I there is a ∈ R such thatI = (a)
I Equivalent definition:
∀ab.∃xy . ax + by = gcd(a, b)
![Page 26: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/26.jpg)
Bezout domains
Theorem: Bezout domains (with explicit divisibility) are stronglydiscrete
Theorem: Bezout domains are coherent
Get algorithm for solving MX = A over Z and k[x ]
![Page 27: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/27.jpg)
Prufer domains
I First-order characterization:
∀ab.∃uvw . ua = vb ∧ (1− u)b = wa
I Has many nice ideal properties
I Examples: Bezout domains, algebraic numbers (Z[√−5]),
algebraic curves (Q[x , y ]/(y2 − 1 + x4)), ...
![Page 28: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/28.jpg)
Prufer domains
Theorem: Prufer domains (with explicit divisibility) are stronglydiscrete
Theorem: Prufer domains are coherent
Get algorithm for solving system MX = A over Prufer domains
![Page 29: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/29.jpg)
Computation in Coq
I Matrices in SSReflect are represented as:
Inductive matrix R m n :=
Matrix of {ffun ’I_m * ’I_n -> R}.
I Well suited for proofs, but not for computation...
I Solution: Data refinements
![Page 30: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/30.jpg)
Computation in Coq
I Matrices in SSReflect are represented as:
Inductive matrix R m n :=
Matrix of {ffun ’I_m * ’I_n -> R}.
I Well suited for proofs, but not for computation...
I Solution: Data refinements
![Page 31: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/31.jpg)
Data refinements
’M[R]_(m,n)
seq (seq R)
seqmx_of_mx
![Page 32: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/32.jpg)
Data refinements
’M[R]_(m,n)
seq (seq R)
seqmx_of_mx
![Page 33: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/33.jpg)
Data refinements
’M[R]_(m,n)
+, ×, ·T ,. . .
seq (seq R)
addseqmx,
mulseqmx,
trseqmx, . . .
seqmx_of_mx
![Page 34: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/34.jpg)
Computations
Solve (0 21 0
)T (x1x2
)=
(20
)
Eval compute in
csolveGeneral 2 2
(trseqmx [::[:: 0; 2];[:: 1; 0]])
[::[:: 2];[:: 0]].
= Some [:: [:: 0]; [:: 2]]
![Page 35: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/35.jpg)
Computations
Solve (0 21 0
)T (x1x2
)=
(20
)
Eval compute in
csolveGeneral 2 2
(trseqmx [::[:: 0; 2];[:: 1; 0]])
[::[:: 2];[:: 0]].
= Some [:: [:: 0]; [:: 2]]
![Page 36: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/36.jpg)
Summary and conclusions
I Implementation of formally verified algorithms for solvingsystems of equations over:
I Bezout domains: Z, Q[x ], ...I Prufer domains: Z[
√−5], Q[x , y ]/(y2 − 1 + x4),...
I Using data refinements to implement efficient algorithmsworks well
I CoqEAL1 – The Coq Effective Algebra Library
1http://www-sop.inria.fr/members/Maxime.Denes/coqeal/
![Page 37: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/37.jpg)
Thank you!
This work has been partially funded by the FORMATH project, nr. 243847, of the FET program within the 7thFramework program of the European Commission
![Page 38: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/38.jpg)
Extra slides
![Page 39: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/39.jpg)
Bezout domains: Coherent
Theorem: Bezout domains are coherent
I It suffices to show that I ∩ J is finitely generated for finitelygenerated ideals I and J.
I Compute a and b such that I = (a) and J = (b).
I Can prove I ∩ J = (lcm(a, b))
![Page 40: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/40.jpg)
Prufer domains
Theorem: Every nonzero finitely generated ideal is invertible
Given a finitely generated ideal I over R there exists I−1 such thatII−1 = (a) for some a ∈ R
![Page 41: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/41.jpg)
Coherence of Prufer domains
Theorem: Prufer domains are coherent
I Given finitely generated I and J we have (I + J)(I ∩ J) = IJ
I To compute I ∩ J invert I + J and multiply on both sides:
(a)(I ∩ J) = (I + J)−1IJ
I Hence we can compute I ∩ J
![Page 42: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/42.jpg)
Optimizations
I We can also do program refinements to optimize ouralgorithms
I Simple example: Ideal additionI Problems with naive implementation: Zeroes? Duplicate
elements?I Solution: Implement more efficient version +′ such that
I + J = I +′ J and then refine +′ to lists
![Page 43: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/43.jpg)
Future work
I Polynomial rings – k[x1, . . . , xn] via Grobner bases
I Implement library of homological algebra – Homalg project2
2http://homalg.math.rwth-aachen.de/
![Page 44: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/44.jpg)
SSReflect matrices
Inductive matrix R m n :=
Matrix of {ffun ’I_m * ’I_n -> R}.
Matrix
Finite function
Tuple
Sequence
I Fine-grained architecture
I Proof-oriented design
I Had to be locked to avoid term sizeexplosion
I Not suited for computation
![Page 45: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/45.jpg)
SSReflect matrices
Inductive matrix R m n :=
Matrix of {ffun ’I_m * ’I_n -> R}.
Matrix
Finite function
Tuple
Sequence
I Fine-grained architecture
I Proof-oriented design
I Had to be locked to avoid term sizeexplosion
I Not suited for computation
![Page 46: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/46.jpg)
SSReflect matrices
Inductive matrix R m n :=
Matrix of {ffun ’I_m * ’I_n -> R}.
Matrix
Finite function
Tuple
Sequence
I Fine-grained architecture
I Proof-oriented design
I Had to be locked to avoid term sizeexplosion
I Not suited for computation
![Page 47: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/47.jpg)
Objective
I Define concrete and executable representations and operationson matrices, using a relaxed datatype (unsized lists)
I Devise a way to link them with the theory in SSReflect
I Still be able to use convenient tools to reason about thealgorithms we implement
![Page 48: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/48.jpg)
Methodology
’M[R]_(m,n)
seq (seq R)
seqmx_of_mx
![Page 49: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/49.jpg)
Methodology
’M[R]_(m,n)
seq (seq R)
seqmx_of_mx
![Page 50: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/50.jpg)
Methodology
’M[R]_(m,n)
+, ×, ·T ,. . .
seq (seq R)
addseqmx,
mulseqmx,
trseqmx, . . .
seqmx_of_mx
![Page 51: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/51.jpg)
List-based representation of matrices
Variable R : ringType.
Definition seqmatrix := seq (seq R).
Definition seqmx_of_mx (M : ’M_(m,n)) : seqmatrix :=
map (fun i => map (fun j => M i j) (enum ’I_n))
(enum ’I_m).
Lemma seqmx_eqP (M N : ’M_(m,n)) :
reflect (M = N) (seqmx_of_mx M == seqmx_of_mx N).
Definition addseqmx (M N : seqmatrix) : seqmatrix :=
zipwith (zipwith (fun x y => x + y)) M N.
Lemma addseqmxE (M N : ’M[R]_(m,n)) :
seqmx_of_mx (M + N) =
addseqmx (seqmx_of_mx M) (seqmx_of_mx N).
![Page 52: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/52.jpg)
List-based representation of matrices
Variable R : ringType.
Definition seqmatrix := seq (seq R).
Definition seqmx_of_mx (M : ’M_(m,n)) : seqmatrix :=
map (fun i => map (fun j => M i j) (enum ’I_n))
(enum ’I_m).
Lemma seqmx_eqP (M N : ’M_(m,n)) :
reflect (M = N) (seqmx_of_mx M == seqmx_of_mx N).
Definition addseqmx (M N : seqmatrix) : seqmatrix :=
zipwith (zipwith (fun x y => x + y)) M N.
Lemma addseqmxE (M N : ’M[R]_(m,n)) :
seqmx_of_mx (M + N) =
addseqmx (seqmx_of_mx M) (seqmx_of_mx N).
![Page 53: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/53.jpg)
List-based representation of matrices
Variable R : ringType.
Definition seqmatrix := seq (seq R).
Definition seqmx_of_mx (M : ’M_(m,n)) : seqmatrix :=
map (fun i => map (fun j => M i j) (enum ’I_n))
(enum ’I_m).
Lemma seqmx_eqP (M N : ’M_(m,n)) :
reflect (M = N) (seqmx_of_mx M == seqmx_of_mx N).
Definition addseqmx (M N : seqmatrix) : seqmatrix :=
zipwith (zipwith (fun x y => x + y)) M N.
Lemma addseqmxE (M N : ’M[R]_(m,n)) :
seqmx_of_mx (M + N) =
addseqmx (seqmx_of_mx M) (seqmx_of_mx N).
![Page 54: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/54.jpg)
List-based representation of matrices
Variable R : ringType.
Definition seqmatrix := seq (seq R).
Definition seqmx_of_mx (M : ’M_(m,n)) : seqmatrix :=
map (fun i => map (fun j => M i j) (enum ’I_n))
(enum ’I_m).
Lemma seqmx_eqP (M N : ’M_(m,n)) :
reflect (M = N) (seqmx_of_mx M == seqmx_of_mx N).
Definition addseqmx (M N : seqmatrix) : seqmatrix :=
zipwith (zipwith (fun x y => x + y)) M N.
Lemma addseqmxE (M N : ’M[R]_(m,n)) :
seqmx_of_mx (M + N) =
addseqmx (seqmx_of_mx M) (seqmx_of_mx N).
![Page 55: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/55.jpg)
Methodology
’M[R]_(m,n)
+, ×, ·T ,. . .
seq (seq R)
addseqmx,
mulseqmx,
trseqmx, . . .
seqmx_of_mx
![Page 56: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/56.jpg)
Methodology
Specification
seq (seq R)
addseqmx,
mulseqmx,
trseqmx, . . .
seqmx_of_mx
![Page 57: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/57.jpg)
Methodology
Specification
Implementation
seqmx_of_mx
![Page 58: Coherent and Strongly Discrete Rings in Type Theory · Coherent rings Theorem: Possible to solve MX = 0 where M 2Rm n, i.e. we can compute L such that MX = 0 $9Y:X = LY Constructive](https://reader033.vdocuments.us/reader033/viewer/2022050205/5f588bfc4a9a682e524c5413/html5/thumbnails/58.jpg)
Methodology
Specification
Implementation
Morphism