Multicategories of multiary lenses Bob Rosebrugh (with Mike - - PowerPoint PPT Presentation

multicategories of multiary lenses
SMART_READER_LITE
LIVE PREVIEW

Multicategories of multiary lenses Bob Rosebrugh (with Mike - - PowerPoint PPT Presentation

Multicategories of multiary lenses Bob Rosebrugh (with Mike Johnson) Department of Mathematics and Computer Science Mount Allison University FMCS 2019-06-02 Backgound Bidirectional Transformations (BX) are n = 2 case, well studied commonly


slide-1
SLIDE 1

Multicategories of multiary lenses

Bob Rosebrugh

(with Mike Johnson)

Department of Mathematics and Computer Science Mount Allison University

FMCS 2019-06-02

slide-2
SLIDE 2

Backgound

Bidirectional Transformations (BX) are n = 2 case, well studied commonly modelled using symmetric and asymmetric lenses ◮ Assume synchronization data specifying when an X state and a Y state are consistent ◮ A lens L : X ← → Y models a (BX) and it includes:

◮ synchronizing data (encoded in various ways) and has ◮ consistency restoration or re-synchronization operator(s) for state changes

◮ Symmetric case: Consistent models with two-way re-synchronization, for example for database interoperation ◮ Asymmetric case: One-way synchronization/restoration with global/local states, for example database view updating

2

slide-3
SLIDE 3

Outline

◮ Multidirectional transformations as n-ary lenses

◮ first generalize (binary) symmetric lenses – more propagations ◮ also generalize spans of asymmetric lenses – to wide spans ◮ introduce “amendments” in both cases

◮ Resulting multiary lenses compose via wide spans ◮ A multicategory of multiary lenses ensues

3

slide-4
SLIDE 4

Multidirectional Transformations

An (n-ary) multimodel space M = ((Ai)i≤n, R) has ◮ Ai a category ◮ objects model states A1, A2, . . .; arrows: state updates ◮ R is synchronization data specifying consistent model states A Multidirectional Transformation (MX) has: ◮ a multimodel space M ◮ consistency restoration or re-synchronization operators after a model state changes (update) Generalizing lenses provides models of two types (below): ◮ n-ary symmetric lens ◮ (wide) span of asymmetric lenses

4

slide-5
SLIDE 5

n-ary Symmetric Lenses

Let M a multimodel space, Ai categories, R = (R, δ) is a function δ = (δi) : R

|A1| × . . . × |An| (call R elements corrs)

An n-ary symmetric lens (Diskin-Konig-Lawford) M = (M, p) has: ◮ Multimodel space M ◮ Consistency restoration operators p = (pi)i≤n

◮ Given corr R and update ui from Ai = δi(R) in Ai... ◮ pi gives updates of Aj = δj(R) target tuple consistent

For an example, think of database interoperation

5

slide-6
SLIDE 6

n-ary Symmetric Lenses

Suppose states (Aj)j≤n synchronized by corr R, R Ai ❥❥❥❥❥❥❥❥❥❥❥ R A1

❏ ❏ ❏ ❏

R Aj

❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨

· · · · · ·

6

slide-7
SLIDE 7

n-ary Symmetric Lenses

Suppose states (Aj)j synchronized by corr R, then given an update ui from state Ai to target A′

i

R Ai ❥❥❥❥❥❥❥❥❥❥❥ R A1

❏ ❏ ❏ ❏

R Aj

❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨

Ai A′

i ui

· · · · · ·

7

slide-8
SLIDE 8

n-ary Symmetric Lenses

Suppose states (Aj)j synchronized by corr R, then given an update from state Ai to target A′

i

the lens propagates updates u′

j of Aj’s (and A′ i) targets A′′ j

R Ai ❥❥❥❥❥❥❥❥❥❥❥ R A1

❏ ❏ ❏ ❏

R Aj

❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨

Ai A′

i ui

A′

i

A′′

i u′

i

A1 A′′

1 u′

1

✤ ✤ ✤ ✤

Aj A′′

j u′

j =pR ij (ui)

✤ ✤ ✤ ✤

pi · · · · · ·

8

slide-9
SLIDE 9

n-ary Symmetric Lenses

Suppose states (Aj)j synchronized by corr R, then given an update from state Ai to target A′

i

the lens propagates updates of Aj’s (and A′

i) to targets A′′ j

and, re-synchronization data R′ on (A′′

j )j.

R Ai ❥❥❥❥❥❥❥❥❥❥❥ R A1

❏ ❏ ❏ ❏

R Aj

❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨

Ai A′

i ui

A′

i

A′′

i u′

i

A1 A′′

1 u′

1

✤ ✤ ✤ ✤

Aj A′′

j u′

j =pR ij (ui)

✤ ✤ ✤ ✤

R′ A′′

i ❚ ❚ ❚ ❚ ❚ ❚ R′

A′′

1

  • t

t

R′ A′′

j

❡ ❡ ❡ ❡ ❡ ❡ ❡ ❡ ❡

pi · · · · · · · · · · · ·

9

slide-10
SLIDE 10

n-ary Symmetric Lenses

A small example with A1 = NA = set2, A2 = AC = set2; R = {(X, X ′) | X1 = X ′

0}

Formal notation for the propagation operation pi R′ = pR

i (ui)

u′

j = pR ij (ui)

j = i u′

i = pR ii (ui)

Call pR

ii (ui) the amendment (update) of ui

Amendment may arise (be necessary) if, for example, no corr synchronizes A′

i with other model states.

Update ui is R-closed when pR

ii (ui) = idAi (trivial amendment)

Lens L is closed if it is R-closed for all R and ui

10

slide-11
SLIDE 11

Well-behaved lenses

An n-ary symmetric lens M = (M, p) is well-behaved if satisfies: ◮ (Stable): Identities propagate to identities: pR

ij (idAi) = idAj 1 ≤ j ≤ n and pR i (idAi) = R

◮ (Refl2): Amended updates propagate like the unamended: pR

ij (pR ii (ui)ui) = pR ij (ui) for j = i,

◮ (Refl3): Amended updates are closed: pR

ii (ui)ui is R-closed 11

slide-12
SLIDE 12

Asymmetric Amendment Lenses

◮ Asymmetric lenses arose as strategy for the database View Update Problem. ◮ First were set based, then algebraic, and categorical ◮ As delta lenses, spans represent (binary) symmetric lenses ◮ Amendments a recent addition (D-K-L), paralleling n-ary symmetric lens

12

slide-13
SLIDE 13

Asymmetric Amendment Lenses

An aa-lens L = (A, B, g, p) has ◮ categories A, B the base and view model spaces ◮ g : A

B a functor called the get

◮ p = {pA | A ∈ A} family of operations delivering for any view state update v : g(A)

B′ ◮ pA

b (v) : A

A′′ the putback of v ◮ pA

a (v) : B′

B′′ the amendment of v also satisfying B′′ = g(A′′)

View update v : g(A)

B′ is closed if its amendment is identity

L a closed aa-lens if all view updates are closed Small examples with A = set3; B = set2. . .

13

slide-14
SLIDE 14

Asymmetric Amendment Lenses

The aa-lenses compose: For L = (A, B, g, p), L′ = (B, C, h, q) the composite is L′L = (A, C, hg, r) where for w : hg(A)

C ′, define rA

b (w) = pA b (qg(A) b

(w)) for v = pA

a (qg(A) b

(w)), define rA

a (w) = h(v) · qg(A) a

(w) as in: g(A) B” A g(A) A A” A” B” hg(A) C ′′′ g(A) hg(A) g(A) B” B” C ′′′ A A”

pA

b (qg(A) b

(w))

  • g(A)

B′

qg(A)

b

(w)

B′

B”

v

  • hg(A)

C ′

w

C ′

C ′′

qg(A)

a

(w)

  • B′

C ′′ C ′′ C ′′′

h(v)

  • 14
slide-15
SLIDE 15

Well-Behaved aa-Lenses

aa-lens is L = (A, B, g, p) is well-behaved if it is: ◮ (Stable) Identities putback to identities ◮ (Refl0) B′ = g(X) for X ∈ A implies pA

a (v) = idB′

(if B′ is a g image, then no amendment) ◮ (Refl2) putback of the amended update same as unamended pA

b (pA a (v)v) = pA b (v)

◮ (PutGet) the get of a putback is the amended update Stable, Refl0 and PutGet compose, as does closed, but not Refl2, and it turns out that. . . Convenient category spg-lens has arrows those aa-lenses satisfying Stable and PutGet properties.

15

slide-16
SLIDE 16

spg Lens Spans and n-ary Symmetric Lenses

Two Constructions: First, from n-wide span L of spg-lens (domains S) to n-ary symmetric ML: S Ai

(gi,pi)

❥❥❥❥❥❥❥❥❥❥❥ S

A1

(g1,p1)

❏ ❏ ❏ ❏ ❏

S Aj

(gj,pj)

❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨

· · · · · · Let ML = (M, p) where M = ((Ai), R) and ◮ R = |S| (objects of S), δi(S) = gi(S) ◮ Define propagation pi for ui : gi(S)

A′

i by

◮ the j’th put of ui is the j’th get of the i’th put: pS

ij (ui) = gj(pS i,b(ui))

◮ the ML amendment of ui is its Li amendment

Note that ML is stable, closed if the Li are

16

slide-17
SLIDE 17

spg Lens Spans and n-ary Symmetric Lenses

Next, from n-ary symmetric M to n-wide span LM of spg-lens: With M = (M, p) and M = ((Ai), R) Objects of the head S of LM are the corr set R Arrows S(R, R′) = {(ui)i≤n | ui : δi(R)

δi(R′)}

R A1 ❥❥❥❥❥❥❥❥❥❥❥ R A2

⑧ ⑧ ⑧R

An

❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨ ❨

A1 A′

1 u1

  • A2

A′

2 u2

  • An

A′

n un

  • R′

A′

1 ❚❚❚❚❚❚❚❚❚❚❚ R′

A′

2 ❄

R′ A′

n

❡ ❡ ❡ ❡ ❡ ❡ ❡ ❡ ❡ ❡ ❡ ❡ ❡ ❡ ❡ ❡ ❡ ❡

· · · · · · · · · · · ·

17

slide-18
SLIDE 18

spg Lens Spans and n-ary Symmetric Lenses

For the lens (LM)i ◮ Define gi(R) = δi(R) on objects, similarly on arrows ◮ For ui : gi(R)

A′

i the put is

(pR

i,b(ui))j

= pR

ij (ui)

j = i (pR

i,b(ui))i

= pR

ii (ui)ui

and the put amendment is that for pi The two constructions are not mutually inverse, and in any case wide spans of spg lenses and n-ary symmetric lenses with same behaviour should be made equivalent .

18

slide-19
SLIDE 19

Two Equivalence Relations

Let L1 = (S1, Ai, gi, pi)i≤n and L2 = (S2, Ai, g′

i , p′ i)i≤n be

n-wide spans of spg-lenses (with same feet). L1 E-related to L2 iff there is functor Φ : S1

S2 such that:

◮ Φ commutes with all gi ◮ Φ surjective on objects, and ◮ If ΦS1 = S2, then for ui : gi(S1) = g′

i (S2)

A′

i, we have

p′

i,a(ui) = pi,a(ui) and p′S2 i,b (ui) = ΦpS1 i,b(ui).

So put behaviours correspond by Φ and amendments agree. ≡spg the equivalence relation generated by E-relatedness (generalizing the n = 2 case).

19

slide-20
SLIDE 20

Two Equivalence Relations

Let L1 = (M, p) and L2 = (N, q) be n-ary symmetric lenses with M = ((Ai), R1) and N = ((Ai), R2) L1 ≡n L2 iff there is relation σ from R1 to R2 such that: ◮ σ is compatible with the δi’s ◮ σ is total in both directions ◮ R1σR2 and ui : Ai

A′

i in Ai then p and q have the same

put behaviour and amendments and σ-related target corrs ≡n is equivalence relation (generalizing the n = 2 case)

20

slide-21
SLIDE 21

Two Equivalence Relations

The constructions above from n-ary symmetric lenses to n-wide spans of spg-lenses and back are closely related

Proposition

With the notation of the constructions, we have: for an n-ary symmetric lens M and an n-wide span L of spg-lenses M = MLM and L ≡spg LML

Corollary

There is a bijection between ≡n equiv classes of n-ary symmetrics and ≡spg equiv classes of n-wide spans in spg-lens From here, we consider (≡spg classes of) wide spans of spg-lenses

21

slide-22
SLIDE 22

Composing Spans

Want to define a wide span composite, but no obvious choice of domain/codomain (requirement below makes choice) A well-behaved, closed aa-lens with PutPut law is a delta-lens The head of (binary) span composite of delta-lens is the cat pullback of the cospan – though not a delta-lens pullback However, with amendments the pullback projection leg puts are non-obvious even for spg-lenses But can work with (binary) spans with closed left leg in spg-lens:

22

slide-23
SLIDE 23

Composing Spans

Consider spans of spg-lenses with heads S and T such that: both (g, p) and (g′, p′) are closed. Let U the cat pullback of h and g′, and k, m the projections S T U S

(k,r)

ssssssss U

T

(m,s)

❑ ❑ ❑ ❑ ❑ ❑

S Y

(h,q)

❑ ❑ ❑ ❑ ❑ ❑ ❑

S T T Y

(g′,p′)

sssssss

S X

(g,p)

ssssssss

T Z

(h′,q′)

❑ ❑ ❑ ❑ ❑ ❑ ❑

Puts r and s are definable, and (k, r) is closed

Proposition

Composite span from X to Z respects ≡spg

23

slide-24
SLIDE 24

Composing Wide Spans

Binary composite helps define wide span composites: Denote an n-wide span L with closed left-most leg (g1, p1) by: S A1

(g1,p1)

✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈

. . . S A2

(g2,p2)

✷ ✷ ✷ ✷ ✷ ✷ ✷ ✷ ✷

S Ai

(gi,pi)

▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼

. . .

24

slide-25
SLIDE 25

Composing Wide Spans

Then given an n′-wide span with head T and closed left-most leg (g′

1, p′ 1) and with

codomain of gi matching codomain of g′

1 (Ai = A′ 1):

S A1

(g1,p1)

rrrrrrrrrr

. . . S A2

✯ ✯ ✯ ✯

S Ai = A′

1 (gi,pi)

◗ ◗ ◗ ◗ ◗ ◗ ◗ ◗ ◗ ◗

. . . T Ai = A′

1 (g′

1,p′ 1)

rrrrrrrr T

A′

2

✯ ✯ ✯

T A′

n′ (g′

n′,p′ n′)

❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯

. . .

25

slide-26
SLIDE 26

Composing Wide Spans

Apply the ”pullback” construction to obtain an n + n′ − 2-wide span with head U S A1

(g1,p1)

rrrrrrrrrr

. . . S A2

✯ ✯ ✯ ✯

S Ai = A′

1 (gi,pi)

◗ ◗ ◗ ◗ ◗ ◗ ◗ ◗ ◗ ◗

. . . T Ai = A′

1 (g′

1,p′ 1)

rrrrrrrr T

A′

2

✯ ✯ ✯

T A′

n′ (g′

n′,p′ n′)

❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯

. . . U S

(k,r)

♦♦♦♦♦♦♦♦♦♦♦♦ U

T

(m,s)

❖ ❖ ❖ ❖ ❖ ❖ ❖ ❖ ❖ ❖ ❖

Proposition

This i-composite has closed left leg (g1, p1)(k, r), and is independent of ≡spg representative

26

slide-27
SLIDE 27

Multicategories

Introduced by Lambek in the 1960’s, aka coloured operads... A multicategory C consists of the following data: ◮ Collection C0 of objects c0, c1, . . . ◮ Collection C1 of multimorphisms f : c1 . . . cn

c

◮ Source map s : C1

(C0)∗ to finite lists of objects,

(C0)∗ the free monoid generated by C0 ◮ Target map t : C1

C0

Write f : c1 . . . cn

c to indicate the source and target of a

multimorphism f

27

slide-28
SLIDE 28

Multicategories

and operations: ◮ Identity operation: a map 1(−) : C0

C1 with 1c : c c

◮ Composition operation assigns, to f : c1 . . . cn

c

and n-tuple (fi : − → ci

ci, i = 1, . . . , n), a composite

f (f1, . . . , fn) : − → c1 . . . − → cn

c (source is concatenated lists)

Operations satisfy the expected associativity and identity laws Examples: - Sets and n-ary functions f : X1 × . . . Xn

X

  • objects and n-ary arrows X1 ⊗ . . . ⊗ Xn

X in monoidal V

28

slide-29
SLIDE 29

Multiary Lenses

A multiary lens is an ≡spg class of n-wide spans of spg-lenses with closed left leg

Proposition

Multiary lenses are the arrows of a multicategory ML: ◮ Object of ML is a category ◮ Multimorphism f of ML is a multiary lens ◮ Suppose f = [L]≡spg a multimorphism with L = (S, Ai, gi, pi)i≤n. Source is A2 . . . An; target is A1 ◮ For category A, identity morphism is equiv class of the span (so n = 2) of identity spg-lenses from A to A ◮ composition is more complicated...

29

slide-30
SLIDE 30

Multiary Lenses

Composition in ML is based on the composites above Suppose f = [L]≡spg with representative L = (S, Ai, gi, pi)i≤n Suppose for 2 ≤ i ≤ n, fi = [Mi]≡spg multimorphisms with Mi = (Ti, Bij, hij, qij)j≤mi satisfying Bi1 = Ai Need representative of f (f2, . . . , fn) : B21 . . . B2m2 . . . Bn1 . . . Bnmn

A1

Composite of L and Mi at Ai is the wide span: S A1

(g1,p1)

rrrrrrrrrr S

Ai = Bi1

(gi,pi)

▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲

Ti Ai = Bi1

(hi1,qi1)

rrrrrrrr Ti

Bi2

(hi2,qi2)

❄ ❄ ❄ ❄

Ti Bimi

(himi ,qimi )

❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯ ❯

. . . Ui S

(ki,ri)

rrrrrrrrrr Ui

Ti

(mi,si)

▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲

where Ui is the “pullback”; Ui to Bij denoted (kij, rij)

30

slide-31
SLIDE 31

Multiary Lenses

Finally, ... Head of composite is the wide “pullback” V

  • f the (g1, p1)(ki, ri) (from above)

U1 A1

(g1,p1)(k1,r1)

rrrrrrrrr

. . . U1 B12

✯ ✯ ✯

U1 B1m1

❖ ❖ ❖ ❖ ❖ ❖ ❖ ❖ ❖

U2 A1 ❡❡❡❡❡❡❡❡❡❡❡❡❡❡❡❡❡❡❡❡❡❡❡❡❡❡❡❡❡❡ U2 B22

✯ ✯ ✯

U2 B2m2

❖ ❖ ❖ ❖ ❖ ❖ ❖ ❖ ❖

. . . . . . V U1

rrrrrrrrr V

U2

▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲

Left leg the common (closed) spg-lens from V to A1 Leg V to Bij is projection from V to Ui then (kij, rij)

31

slide-32
SLIDE 32

Conclusion

◮ n-ary symmetric lenses model MX ◮ Spans (wide) of spg lenses also model MX ◮ Spans and n-ary symmetrics correspond ◮ Some wide spans of spg lenses compose ◮ Multicategory of multiary lenses results ◮ Future work:

◮ Cospan representations ◮ Amendment “compatibility” relation (D-K-L) ◮ Properties of ML ◮ Other MX topologies

32

slide-33
SLIDE 33

Some references

◮ Z. Diskin, H, K¨

  • nig, and M. Lawford, Multiple model

synchronization with multiary delta lenses, LNCS 10802, 2018, 21–37. ◮ Multidirectional Transformations and Synchronisations, Report from Dagstuhl Seminar 18491, Edited by A. Cleve, E. Kindler, P. Stevens, and V. Zaytsev, 48pp, 2019, ◮ MJ and RR, Symmetric delta lenses and spans of asymmetric delta lenses. Journal of Object Technology 16 2017, 2:1–32. ◮ MJ and RR, Multicategories of multiary lenses, Proceedings of the 8th International Workshop on Bidirectional Transformations, 2019, 30–44.

33