Bidirectional Transformations a PL perspective BIRS meeting on - - PowerPoint PPT Presentation

▶
bidirectional transformations a pl perspective
SMART_READER_LITE
LIVE PREVIEW

Bidirectional Transformations a PL perspective BIRS meeting on - - PowerPoint PPT Presentation

Bidirectional Transformations a PL perspective BIRS meeting on BX, 2013 Bidirectional Transformations (BX) to A B from database source materialized view software model code document representation screen visualization


slide-1
SLIDE 1

Bidirectional Transformations — a PL perspective

BIRS meeting on BX, 2013

slide-2
SLIDE 2

Bidirectional Transformations (BX) A B to from database source ⇔ materialized view software model ⇔ code document representation ⇔ screen visualization concrete syntax ⇔ abstract syntax abstract datatype ⇔ actual implementation program input ⇔ program output

1 – 1/1

slide-3
SLIDE 3

Bidirectional Transformations

a1 b1 to

2 – 2/11

slide-4
SLIDE 4

Bidirectional Transformations

a1 b1 to b2

2 – 3/11

slide-5
SLIDE 5

Bidirectional Transformations

a1 b1 to b2 a2 from

2 – 4/11

slide-6
SLIDE 6

Bidirectional Transformations

a1 b1 to b2 a2 from a3

2 – 5/11

slide-7
SLIDE 7

Bidirectional Transformations

a1 b1 to b2 a2 from a3 b3 to

2 – 6/11

slide-8
SLIDE 8

Bidirectional Transformations

a1 b1 to b2 a2 from a3 b3 to

2 – 7/11

slide-9
SLIDE 9

Bidirectional Transformations

a1 b1 to b2 a2 from a3 b3 to

2 – 8/11

unless bijective, typically additional information needed/useful

slide-10
SLIDE 10

Bidirectional Transformations

a1 b1 to b2 a2 from a3 b3 to

2 – 9/11

unless bijective, typically additional information needed/useful:

◮ about connections

between A and B (objects)

slide-11
SLIDE 11

Bidirectional Transformations

a1 b1 to b2 ∆ a2 from a3 ∆ b3 to ∆

2 – 10/11

unless bijective, typically additional information needed/useful:

◮ about connections

between A and B (objects)

◮ about the updates

  • n either side
slide-12
SLIDE 12

Bidirectional Transformations

a1 b1 to b2 ∆ a2 from a3 ∆ b3 to ∆ ∆ ∆

2 – 11/11

unless bijective, typically additional information needed/useful:

◮ about connections

between A and B (objects)

◮ about the updates

  • n either side
slide-13
SLIDE 13

Objectives for this Talk

◮ get everybody into “BX mode” for the week ◮ set out basic premises of the PL approach,

paradigmatic problems

◮ introduce terminology and semantic principles ◮ no details of specific solutions ◮ relate to what “we” think is solved and what not ◮ open discussion

3 – 12/12

slide-14
SLIDE 14

What’s specific about “the PL approach”, anyway?

4 – 13/19

slide-15
SLIDE 15

What’s specific about “the PL approach”, anyway?

◮ focus on the transformations/functions

themselves, not so much on the data

4 – 14/19

slide-16
SLIDE 16

What’s specific about “the PL approach”, anyway?

◮ focus on the transformations/functions

themselves, not so much on the data

◮ focus on extensional semantics and laws

4 – 15/19

slide-17
SLIDE 17

What’s specific about “the PL approach”, anyway?

◮ focus on the transformations/functions

themselves, not so much on the data

◮ focus on extensional semantics and laws ◮ correctness by construction/derivation

(as opposed to a-posteriori verification)

4 – 16/19

slide-18
SLIDE 18

What’s specific about “the PL approach”, anyway?

◮ focus on the transformations/functions

themselves, not so much on the data

◮ focus on extensional semantics and laws ◮ correctness by construction/derivation

(as opposed to a-posteriori verification)

◮ assuming a very clean setting (naive?)

4 – 17/19

slide-19
SLIDE 19

What’s specific about “the PL approach”, anyway?

◮ focus on the transformations/functions

themselves, not so much on the data

◮ focus on extensional semantics and laws ◮ correctness by construction/derivation

(as opposed to a-posteriori verification)

◮ assuming a very clean setting (naive?) ◮ being driven by our favourite new PL techniques

4 – 18/19

slide-20
SLIDE 20

What’s specific about “the PL approach”, anyway?

◮ focus on the transformations/functions

themselves, not so much on the data

◮ focus on extensional semantics and laws ◮ correctness by construction/derivation

(as opposed to a-posteriori verification)

◮ assuming a very clean setting (naive?) ◮ being driven by our favourite new PL techniques ◮ typically, algebraic data domains

4 – 19/19

slide-21
SLIDE 21

Bidirectional Transformations

a1 b1 to b2 ∆ a2 from a3 ∆ b3 to ∆ ∆ ∆

5 – 20/20

unless bijective, typically additional information needed/useful:

◮ about connections

between A and B (objects)

◮ about the updates

  • n either side
slide-22
SLIDE 22

Bidirectional Transformations

a1 b1 to b2 ∆ a2 from ∆

6 – 21/23

focus on:

◮ single-side updates ◮ one-step updates

slide-23
SLIDE 23

Bidirectional Transformations

a1 b1 to b2 ∆ a2 from ∆

also, focus on asymmetric setting:

◮ to usually non-injective, henceforth called get ◮ from then called put, definitely needs extra info ◮ for simplicity, state-based ◮ “sources” and “views”

6 – 22/23

focus on:

◮ single-side updates ◮ one-step updates

slide-24
SLIDE 24

Bidirectional Transformations

s v get v ′ ∆ s′ put ∆

also, focus on asymmetric setting:

◮ to usually non-injective, henceforth called get ◮ from then called put, definitely needs extra info ◮ for simplicity, state-based ◮ “sources” and “views”

6 – 23/23

focus on:

◮ single-side updates ◮ one-step updates

slide-25
SLIDE 25

Bidirectional Transformations A closer look at representing s v connections. For example:

x y z u v y z u v get

7 – 24/29

slide-26
SLIDE 26

Bidirectional Transformations A closer look at representing s v connections. For example:

x y z u v y z u v get

7 – 25/29

slide-27
SLIDE 27

Bidirectional Transformations A closer look at representing s v connections. For example:

x y z u v y z u v get

  • r

x y z u v y z u v get x

7 – 26/29

slide-28
SLIDE 28

Bidirectional Transformations A closer look at representing s v connections. For example:

x y z u v y z u v get

  • r

x y z u v y z u v get x

  • r

x y z u v y z u v

7 – 27/29

slide-29
SLIDE 29

Bidirectional Transformations A closer look at representing s v connections. For example:

x y z u v y z u v get

  • r

x y z u v y z u v get x

  • r

x y z u v y z u v

Why is it not enough to look just at the data?

x y z u v x y z u

7 – 28/29

slide-30
SLIDE 30

Bidirectional Transformations A closer look at representing s v connections. For example:

x y z u v y z u v get

  • r

x y z u v y z u v get x

  • r

x y z u v y z u v

Why is it not enough to look just at the data?

x y z u v x y z u

Because of:

x x x x x x x x x

7 – 29/29

slide-31
SLIDE 31

Bidirectional Transformations Some further relevant aspects:

◮ What artifacts need to be specified?

◮ both get and put ◮ only one of them, the other derived ◮ a more abstract artifact, from which both derivable

◮ How are they specified, manipulated, analyzed? ◮ What properties are they expected to have? ◮ What influence does a user, modeller,

programmer have?

8 – 30/30

slide-32
SLIDE 32

Properties / Laws

slide-33
SLIDE 33

Bidirectional Transformations Specific asymmetric setting, state-based:

source view s v s′ v ′ get put update

get :: S → V put :: S → V → S

10 – 32/33

slide-34
SLIDE 34

Bidirectional Transformations Specific asymmetric setting, state-based:

source view s v s′ v ′ get put update

get :: S → V put :: S → V → S

10 – 33/33

assumed total!

slide-35
SLIDE 35

About Behavior under No-Change

foo 5 foo

project out string component

11 – 34/40

slide-36
SLIDE 36

About Behavior under No-Change

foo 5 bar foo

11 – 35/40

slide-37
SLIDE 37

About Behavior under No-Change

foo 5 bar bar foo

propagate updated string always set numeric field to 0

11 – 36/40

slide-38
SLIDE 38

About Behavior under No-Change

foo 5 foo foo

=

11 – 37/40

slide-39
SLIDE 39

About Behavior under No-Change

foo 5 foo foo foo

= ≠

11 – 38/40

slide-40
SLIDE 40

About Behavior under No-Change

foo 5 foo foo foo

= ≠

To prevent this, the GetPut law: put s (get s) = s

11 – 39/40

Principle: If the view does not change, neither should the source.

slide-41
SLIDE 41

About Behavior under No-Change

foo 5 foo foo foo

= ≠

To prevent this, the GetPut law: put s (get s) = s NB: For this, put must be surjective.

11 – 40/40

Principle: If the view does not change, neither should the source.

slide-42
SLIDE 42

About Preservation of Changes

foo foo

project out string component

12 – 41/46

slide-43
SLIDE 43

About Preservation of Changes

foo bar foo

12 – 42/46

slide-44
SLIDE 44

About Preservation of Changes

foo blech 5 bar foo

return a constant

12 – 43/46

slide-45
SLIDE 45

About Preservation of Changes

foo blech 5 bar foo blech

≠

12 – 44/46

slide-46
SLIDE 46

About Preservation of Changes

foo blech 5 bar foo blech

≠

To prevent this, the PutGet law: get (put s v) = v

12 – 45/46

Principle: Updates should be translated exactly.

slide-47
SLIDE 47

About Preservation of Changes

foo blech 5 bar foo blech

≠

To prevent this, the PutGet law: get (put s v) = v NB: For this, put s must be injective for every s.

12 – 46/46

Principle: Updates should be translated exactly.

slide-48
SLIDE 48

Somewhat more Challenging

foo foo

project out and duplicate string component

foo

13 – 47/51

slide-49
SLIDE 49

Somewhat more Challenging

foo bar foo foo foo

13 – 48/51

slide-50
SLIDE 50

Somewhat more Challenging

foo bar bar foo

propagate "newest" string

foo foo

13 – 49/51

slide-51
SLIDE 51

Somewhat more Challenging

foo bar bar foo bar

≠

foo foo bar

13 – 50/51

slide-52
SLIDE 52

Somewhat more Challenging

foo bar bar foo bar

≠

foo foo bar

If we want to allow such behavior, we need to weaken the PutGet law (and people have done so).

13 – 51/51

slide-53
SLIDE 53

About Consistent Composition

foo foo

project out string component

14 – 52/59

slide-54
SLIDE 54

About Consistent Composition

foo bar foo

14 – 53/59

slide-55
SLIDE 55

About Consistent Composition

foo bar 1 bar foo

increment numeric component if string component has changed

14 – 54/59

slide-56
SLIDE 56

About Consistent Composition

foo bar 1 quux bar foo

14 – 55/59

slide-57
SLIDE 57

About Consistent Composition

foo bar 1 quux 2 quux bar foo

translated updates produce "side effects" on source

14 – 56/59

slide-58
SLIDE 58

About Consistent Composition

foo bar 1 foo bar foo

restore original target

14 – 57/59

slide-59
SLIDE 59

About Consistent Composition

foo bar 1 foo 2 foo bar foo

  • riginal source

is not restored

14 – 58/59

slide-60
SLIDE 60

About Consistent Composition

foo bar 1 foo 2 foo bar foo

  • riginal source

is not restored

To prevent this, the PutPut law: put (put s v) v ′ = put s v ′

14 – 59/59

slide-61
SLIDE 61

Less Debatable Actually a consequence of GetPut and PutGet, the PutTwice law: put (put s v) v = put s v

15 – 60/61

slide-62
SLIDE 62

Less Debatable Actually a consequence of GetPut and PutGet, the PutTwice law: put (put s v) v = put s v We’ll get back to this property in a moment.

15 – 61/61

slide-63
SLIDE 63

Ambiguity of put

slide-64
SLIDE 64

How many puts are there?

S V

Due to non-injectivity, get can map many objects from S onto the same object from V .

17 – 63/69

slide-65
SLIDE 65

How many puts are there?

S V

In essence, get projects out part of the information in the source object. . .

17 – 64/69

slide-66
SLIDE 66

How many puts are there?

S V

In essence, get projects out part of the information in the source object. . . and throws away the rest.

17 – 65/69

slide-67
SLIDE 67

How many puts are there?

S V

After an update,

17 – 66/69

slide-68
SLIDE 68

How many puts are there?

S V

After an update, the “view part” of the new source

  • bject is fixed by PutGet. . .

17 – 67/69

slide-69
SLIDE 69

How many puts are there?

S V

After an update, the “view part” of the new source

  • bject is fixed by PutGet. . . and if the lens obeys

PutPut, the “projected away part” is fixed to be exactly the one from the original source.

17 – 68/69

slide-70
SLIDE 70

How many puts are there?

S V

After an update, the “view part” of the new source

  • bject is fixed by PutGet. . . and if the lens obeys

PutPut, the “projected away part” is fixed to be exactly the one from the original source.

17 – 69/69

Even this doesn’t mean that there is

  • nly exactly one “very well-behaved”

put per get!

slide-71
SLIDE 71

How many puts are there?

S V

?? ? Moreover, if the lens doesn’t need to obey PutPut, then the behavior of put is much less constrained. . . . . . and there are even more puts to choose from!

18 – 70/71

slide-72
SLIDE 72

How many puts are there?

S V

Moreover, if the lens doesn’t need to obey PutPut, then the behavior of put is much less constrained. . . . . . and there are even more puts to choose from! So, definitely need extra information to select one.

18 – 71/71

slide-73
SLIDE 73

On the Other Hand. . . . . . there is only one get per “well-behaving” put!

19 – 72/75

slide-74
SLIDE 74

On the Other Hand. . . . . . there is only one get per “well-behaving” put! Specifically, if put is surjective, is injective for every s, and satisfies PutTwice, then there is exactly

  • ne get such that the two together satisfy GetPut

and PutGet.

19 – 73/75

slide-75
SLIDE 75

On the Other Hand. . . . . . there is only one get per “well-behaving” put! Specifically, if put is surjective, is injective for every s, and satisfies PutTwice, then there is exactly

  • ne get such that the two together satisfy GetPut

and PutGet. And, there are equivalent, even nicer conditions formulated just in terms of put as well. [Fischer, Hu, Pacheco]

19 – 74/75

slide-76
SLIDE 76

On the Other Hand. . . . . . there is only one get per “well-behaving” put! Specifically, if put is surjective, is injective for every s, and satisfies PutTwice, then there is exactly

  • ne get such that the two together satisfy GetPut

and PutGet. And, there are equivalent, even nicer conditions formulated just in terms of put as well. [Fischer, Hu, Pacheco] There are even first concrete bidirectionalization techniques derived from this put-based approach!

19 – 75/75

slide-77
SLIDE 77

Conclusion / Discussion (?)

slide-78
SLIDE 78

“Solved”

◮ a lot of very nice definitive work on semantics ◮ successful methods for automatic derivation of

reasonable put- from get-functions on strings, trees, and graphs (?)

◮ combinator languages with powerful

type systems

◮ program transformations based on

constant-complement

◮ query languages with automatic tracing ◮ grammar-based approaches 21 – 77/77

slide-79
SLIDE 79

Open Problems Leaving the academic niche:

◮ “How to deliver BX to the masses? Some

effective way to integrate BX with existing general programming languages would be nice. Most tools/languages are very academic, and I don’t see them being used for industrial case

  • studies. . . ”

◮ “But I think to really achieve world domination,

a BX framework will need to make substantial progress on having an attractive and intuitive front-end.”

22 – 78/78

slide-80
SLIDE 80

Open Problems Tackling ambiguities effectively:

◮ “Can we design a declarative language that can

be used to describe any intentional bidirectional behavior (i.e., have full control of bidirectional behavior)?”

◮ “We still lack effective, intuitive (user-friendly)

and generic mechanisms to tame the non-determinism of backwards transformation.”

◮ “Ability to control the choice between multiple

valid backward transformation results. [. . . ] clarify to what extent user can control by writing different get (forward) transformations.”

23 – 79/79

slide-81
SLIDE 81

Open Problems Handling richer semantic domains:

◮ “[. . . ] still no effective solution for non-tree

shaped domains.”

◮ “Bx on ordered graphs (outgoing edges are

  • rdered) and graphs in which ordered and

unordered edges are mixed.”

◮ “Handling of constraints over the domains (that

is, handling non CFG-like domains). DB people have some work on this (handling keys, functional dependencies, inclusion dependencies, etc), but the issue seems ignored by PL people.”

24 – 80/80

slide-82
SLIDE 82

“Conclusion” There is a lot of potential and possible inspiration from PL land for the general area of BX. Challenges remain:

◮ scaling up in every way ◮ providing control over nondeterminism ◮ capturing user/programmer intentions ◮ handling richer structures/domains ◮ running efficiently

25 – 81/81