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

flablom functional linear algebra with block matrices
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 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

slide-2
SLIDE 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

  • 1
  • 1

1 1

  

slide-3
SLIDE 3

Matrices

Desirable:

◮ Easy to program with ◮ Easy to write proofs with

slide-4
SLIDE 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 ◮ . . .

slide-5
SLIDE 5

Matrices: shapes

A type for shapes: data Shape : Set where L : Shape B : (s1 s2 : Shape) → Shape

slide-6
SLIDE 6

Matrices: shapes

A type for shapes: data Shape : Set where L : Shape B : (s1 s2 : Shape) → Shape Shapes for one dimension: (a vector/row matrix) B B L 1 L 3 L 16

slide-7
SLIDE 7

Matrices: building blocks

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

slide-8
SLIDE 8

Matrices: building blocks

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

[a] ,

  • [· · · ]

[· · · ]

  • ,

       

  • .

. .

  • .

. .

       ,        

  • ...
  • ...
  • ...
  • ...

       M a L L M a L (B c1 c2) M a (B r1 r2) L M a (B r1 r2) (B c1 c2)

slide-9
SLIDE 9

Matrices: a datatype

data M (a : Set) : (rows cols : Shape) → Set where One : a → M a L L Col : {r1 r2 : Shape } → M a r1 L → M a r2 L → M a (B r1 r2) L Row : {c1 c2 : Shape } → M a L c1 → M a L c2 → M a L (B c1 c2) Q : {r1 r2 c1 c2 : Shape } → M a r1 c1 → M a r1 c2 → M a r2 c1 → M a r2 c2 → M a (B r1 r2) (B c1 c2)

slide-10
SLIDE 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∗.

slide-11
SLIDE 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. Square : Shape → SemiNearRing → SemiNearRing Square′ : Shape → SemiRing → SemiRing Square′′ : Shape → ClosedSemiRing → ClosedSemiRing

slide-12
SLIDE 12

Lifting matrices

(Parts of) lifted equivalence: ≃S : ∀ {r c } → M s r c → M s r c → Set (One x) ≃S (One x1) = x ≃s x1 (Row m m1) ≃S (Row n n1) = (m ≃S n) × (m1 ≃S n1) (Parts of) lifted multiplication: ·

S

: ∀ {r m c } → M s r m → M s m c → M s r c One x ·

S One y

= One (x ·s y) Row m0 m1 ·

S Col n0 n1 = m0 · S n0 + S m1 · S n1

slide-13
SLIDE 13

Proofs: reflexivity

reflS : ∀ {r c } → (X : M s r c) → X ≃S X reflS (One x) = refls {x } reflS (Row X X1) = reflS X , reflS X1 reflS (Col X X1) = reflS X , reflS X1 reflS (Q X X1 X2 X3) = reflS X , reflS X1 , reflS X2 , reflS X3

slide-14
SLIDE 14

Closure for matrices

Computing the reflexive, transitive closure:

[a]∗ = [a∗]   A11 A12 A21 A22  

=   A∗

11 + A∗ 11 · A12 · ∆∗ · A21 · A∗ 11

A∗

11 · A12 · ∆∗

∆∗ · A21 · A∗

11

∆∗  

(with ∆ = A22 + A21 · A∗

11 · A12)

with proof that it satisfies w∗ ≃ 1 + w · w∗

slide-15
SLIDE 15

Reachability example

1 2 3 4      

  • 1
  • 1

    

slide-16
SLIDE 16

Reachability example

1 2 3 4      

  • 1
  • 1

    

=       1 1

  • 1
  • 1
  • 1

1 1

     1 2 3 4

slide-17
SLIDE 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.