flablom functional linear algebra with block matrices
play

FLABloM: Functional linear algebra with block matrices Adam - PowerPoint PPT Presentation

FLABloM: Functional linear algebra with block matrices Adam Sandberg Eriksson Patrik Jansson Chalmers University of Technology, Sweden { saadam,patrikj } @chalmers.se May 26, 2016 Functional linear algebra with block matrices Inspired by


  1. FLABloM: Functional linear algebra with block matrices Adam Sandberg Eriksson Patrik Jansson Chalmers University of Technology, Sweden { saadam,patrikj } @chalmers.se May 26, 2016

  2. Functional linear algebra with block matrices ◮ Inspired by work on parallel parsing by Bernardy & Jansson ◮ Matrices in Agda ◮ Reflexive, transitive closure of matrices � �  1 0 1   � 0 � 1    � � 1   0 0 1

  3. Matrices Desirable: ◮ Easy to program with ◮ Easy to write proofs with

  4. Matrices Desirable: ◮ Easy to program with ◮ Easy to write proofs with Possibilities: ◮ Vectors of vectors: Vec ( Vec a n ) m ◮ Functions from indices: Fin m → Fin n → a ◮ . . .

  5. Matrices: shapes A type for shapes: data Shape : Set where L : Shape B : ( s 1 s 2 : Shape ) → Shape

  6. Matrices: shapes A type for shapes: data Shape : Set where L : Shape B : ( s 1 s 2 : Shape ) → Shape Shapes for one dimension: (a vector/row matrix) B B L L L 1 3 16

  7. Matrices: building blocks Matrices are indexed by two shapes: data M ( a : Set ) : ( rows cols : Shape ) → Set

  8. Matrices: building blocks Matrices are indexed by two shapes: data M ( a : Set ) : ( rows cols : Shape ) → Set  � �   � � � �  . ... ... . .         � �     [ a ] , [ · · · ] [ · · · ]     , ,  � �   � � � �  . ... ...  .    .     M a L ( B c 1 c 2 ) M a ( B r 1 r 2 ) L M a ( B r 1 r 2 ) ( B c 1 c 2 ) M a L L

  9. Matrices: a datatype data M ( a : Set ) : ( rows cols : Shape ) → Set where One : a → M a L L Col : { r 1 r 2 : Shape } → M a r 1 L → M a r 2 L → M a ( B r 1 r 2 ) L Row : { c 1 c 2 : Shape } → M a L c 1 → M a L c 2 → M a L ( B c 1 c 2 ) Q : { r 1 r 2 c 1 c 2 : Shape } → M a r 1 c 1 → M a r 1 c 2 → M a r 2 c 1 → M a r 2 c 2 → M a ( B r 1 r 2 ) ( B c 1 c 2 )

  10. Rings A hierarchy of rings as Agda records: ◮ SemiNearRing ≃ , +, · , 0 (+ is associative and commutes, 0 identity of + and zero of · , · distributes over +) ◮ SemiRing 1 (1 identity of · , · is associative) ◮ ClosedSemiRing an operation ∗ with w ∗ ≃ 1 + w · w ∗ .

  11. Lifting matrices We take a semi-(near)-ring and lift it to square matrices. A lifting function Square for each Shape and ring structure. : Shape → SemiNearRing → SemiNearRing Square Square ′ : Shape → SemiRing → SemiRing Square ′′ : Shape → ClosedSemiRing → ClosedSemiRing

  12. Lifting matrices (Parts of) lifted equivalence: ≃ S : ∀ { r c } → M s r c → M s r c → Set ( One x ) ≃ S ( One x 1 ) = x ≃ s x 1 ( Row m m 1 ) ≃ S ( Row n n 1 ) = ( m ≃ S n ) × ( m 1 ≃ S n 1 ) (Parts of) lifted multiplication: · : ∀ { r m c } → M s r m → M s m c → M s r c S · = One ( x · s y ) One x S One y Row m 0 m 1 · S Col n 0 n 1 = m 0 · S n 0 + S m 1 · S n 1

  13. Proofs: reflexivity reflS : ∀ { r c } → ( X : M s r c ) → X ≃ S X reflS ( One x ) = refl s { x } reflS ( Row X X 1 ) = reflS X , reflS X 1 reflS ( Col X X 1 ) = reflS X , reflS X 1 reflS ( Q X X 1 X 2 X 3 ) = reflS X , reflS X 1 , reflS X 2 , reflS X 3

  14. Closure for matrices Computing the reflexive, transitive closure: [ a ] ∗ = [ a ∗ ] 11 · A 12 · ∆ ∗ · A 21 · A ∗   ∗   11 + A ∗ 11 · A 12 · ∆ ∗ A 11 A 12 A ∗ A ∗ 11 =     ∆ ∗ · A 21 · A ∗ ∆ ∗ A 21 A 22 11 (with ∆ = A 22 + A 21 · A ∗ 11 · A 12 ) with proof that it satisfies w ∗ ≃ 1 + w · w ∗

  15. Reachability example 1 2 3 4 � 0 � 0 ∗ � �  0 0  0 0 0 1      � 0 � 0    � � 1 0   0 0 0 0

  16. Reachability example 1 2 3 4 � 0 � 0 � 1 � 0 ∗ � � � �  0 0   0 0  0 0 0 1 0 1 0 1         =  � 0 � 0   � 0 � 1      � � � � 1 0 1 1     0 0 0 0 0 0 0 1 1 2 3 4

  17. Wrapping up Conclusions, further work, et.c. ◮ This matrix definition is useable... ◮ A more flexible matrix definition: sparse? fewer constructors? ◮ Automation (of proofs)! ◮ Generalisation to closed semi-near-ring for parsing applications. ◮ Agda development available at https://github.com/DSLsofMath/FLABloM .

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend