slides - Daniel Wagner

Transcription

slides - Daniel Wagner
Generalizing Lenses
Daniel Wagner
August 19, 2013
Thesis Proposal
There are many fundamentally bidirectional settings
that call for generalizations of traditional lenses
where a language is possible and helpful.
Thesis Proposal
There are many fundamentally bidirectional settings
that call for generalizations of traditional lenses
where a language is possible and helpful.
Thesis Proposal
There are many fundamentally bidirectional settings
that call for generalizations of traditional lenses
where a language is possible and helpful.
Thesis Proposal
There are many fundamentally bidirectional settings
that call for generalizations of traditional lenses
where a language is possible and helpful.
Overview
Traditional lenses
Symmetry
Edits
Multidirectionality
Logistics
Traditional lenses
Jan
palindrome.jpg
May
gamer.jpg froghead.jpg
Jan
palindrome.jpg
May
gamer.jpg froghead.jpg
Jan
palindrome.jpg
May
gamer.jpg froghead.jpg
???
Jan
May
palindrome.jpg gamer.jpg froghead.jpg
burrito.jpg withperson.jpg
Jan
May
palindrome.jpg gamer.jpg froghead.jpg
burrito.jpg withperson.jpg
Abstract model
a
A lens ` ∈ X ↔ Y has components
get ∈ X → Y
put ∈ Y × X → X
Abstract model
a
A lens ` ∈ X ↔ Y has components
get ∈ X → Y
put ∈ Y × X → X
Synchronizing too often doesn’t hurt.
get(put(y , x)) = y
put(get(x), x) = x
Abstract model
a
A lens ` ∈ X ↔ Y has components
get ∈ X → Y
put ∈ Y × X → X
Synchronizing too often doesn’t hurt.
get(put(y , x)) = y
put(get(x), x) = x
put(y 0 , put(y , x)) = put(y 0 , x)
Not synchronizing often enough doesn’t hurt.
Related work: asymmetric lenses
I
I
I
I
I
I
Combinators for Bidirectional Tree Transformations
(Foster, Greenwald, Moore, Pierce, Schmitt;
POPL 2005)
Relational Lenses: A Language For Updateable Views
(Bohannon, Vaughn, and Pierce; PODS 2006)
Boomerang: Resourceful Lenses for String Data
(Bohannon, Foster, Pierce, Pilkiewicz, and Schmitt;
POPL 2008)
Bidirectional Programming Languages
(Foster; thesis 2009)
Bidirectionalizing Graph Transformations
(Hidaka, Hu, Inaba, and Kato; ICFP 2010)
Update Semantics of Relational Views
(Bancilhon and Spyratos; 1981)
Symmetry
(in collaboration with Martin Hofmann and Benjamin Pierce)
Jan
May
palindrome.jpg gamer.jpg froghead.jpg
burrito.jpg withperson.jpg
[costume,food]
Jan
May
palindrome.jpg gamer.jpg froghead.jpg
burrito.jpg withperson.jpg
[costume]
[costume]
[food,onlyface]
[]
[costume,food]
Jan
May
palindrome.jpg gamer.jpg froghead.jpg
[costume,food] [costume] [costume]
burrito.jpg withperson.jpg
[food,onlyface]
[]
[costume]
[costume]
[food,onlyface]
[]
[costume,food]
Jan
May
palindrome.jpg gamer.jpg froghead.jpg
[costume,food] [costume] [costume]
burrito.jpg withperson.jpg
[food,onlyface]
[]
[costume]
[costume]
[food,onlyface]
[]
[costume,food]
Jan
May
burrito.jpg withperson.jpg
palindrome.jpg gamer.jpg froghead.jpg
[costume]
[costume]
Jan
May
palindrome gamer froghead
burrito
withperson
[costume,food]
[costume]
[costume]
[food,onlyface]
[]
[food,onlyface]
[]
[costume,food]
Jan
May
burrito.jpg withperson.jpg
palindrome.jpg gamer.jpg froghead.jpg
[costume]
[costume]
Jan
May
X
palindrome gamer froghead
burrito
withperson
[costume,food]
[costume]
[costume]
[food,onlyface]
[]
[food,onlyface]
[]
Abstract model
s
A lens ` ∈ X ↔ Y has a set C and components
putr ∈ X × C → Y × C
putl ∈ Y × C → X × C
Abstract model
s
A lens ` ∈ X ↔ Y has a set C and components
putr ∈ X × C → Y × C
putl ∈ Y × C → X × C
Synchronizing too often doesn’t hurt.
putr (x, c) = (y , c 0 )
putl(y , c 0 ) = (x, c 0 )
Abstract model
s
A lens ` ∈ X ↔ Y has a set C and components
putr ∈ X × C → Y × C
putl ∈ Y × C → X × C
Synchronizing too often doesn’t hurt.
putr (x, c) = (y , c 0 )
putl(y , c 0 ) = (x, c 0 )
Not synchronizing often enough doesn’t hurt.
putr (x, c) = putr (x, c 0 )
Twist: equational reasoning
A
a
k
B
a
`
a
C m D
Nice property of asymmetric lenses:
(k; `); m = k; (`; m)
Twist: equational reasoning
A
a
k
B
a
`
a
C m D
Nice property of asymmetric lenses:
(k; `); m = k; (`; m)
Not true for symmetric lenses!
In dissertation
I
I
Observational equivalence
Point-free programming language
I
I
I
I
Basic (non-recursive) data types
Lists, with folds and unfolds
Some generalized container operations
Proof that this generalizes asymmetric lenses
Related work: other symmetric approaches
I
I
I
I
I
Symmetric Constraint Maintainers
(Meertens; 1998)
Towards an Algebraic Theory of Bidirectional
Transformations
(Stevens; ICGT 2008)
Bidirectional Model Transformations in QVT: Semantic
Issues and Open Questions
(Stevens; MoDELS 2007)
Algebraic Models for Bidirectional Model
Synchronization
(Diskin; MoDELS 2008)
Supporting Parallel Updates with Bidirectional Model
Transformations
(Xiong, Song, Hu, and Takeichi; ICMT 2009)
Edits
(in collaboration with Martin Hofmann and Benjamin Pierce)
[costume,food]
Jan
May
palindrome.jpg gamer.jpg froghead.jpg
burrito.jpg withperson.jpg
[costume]
[costume]
[food,onlyface]
[]
[cute]
[kitten,invisible,apathy]
[food,costume,cute]
[food]
[costume]
2012
[dog,kitten]
2013
[food]
[invisible,food]
[food,cute]
[food,cute]
January
February
March
April
May
June
July
August
September
October
November December
January
February
March
April
May
June
July
August
September
October
November December
[]
[]
[costume,dog]
[dog,kitten,invisible]
[]
gamer.jpg
wrapped.jpg
froghead.jpg
gamer.jpg
gamer.jpg
gamer.jpg
wrapped.jpg
burrito.jpg
palindrome.jpg
dune.jpg
palindrome.jpg
dune.jpgpalindrome.jpg
lobster.jpg
withperson.jpgwrapped.jpg
dune.jpg
froghead.jpg
dune.jpg burrito.jpg
froghead.jpg
dune.jpg
gamer.jpg
gamer.jpg
froghead.jpg
withperson.jpg burrito.jpg
froghead.jpg
dune.jpg
froghead.jpgpalindrome.jpg
lobster.jpg
gamer.jpgfroghead.jpg
gamer.jpg
gamer.jpg
withperson.jpg
palindrome.jpg
burrito.jpg
burrito.jpg
withperson.jpg
wrapped.jpg
dune.jpg
lobster.jpgfroghead.jpg
withperson.jpg
palindrome.jpg
wrapped.jpg
dune.jpg
froghead.jpg
palindrome.jpg
gamer.jpg
gamer.jpg
gamer.jpg
gamer.jpg
lobster.jpg
froghead.jpg
palindrome.jpgdune.jpg
withperson.jpg
dune.jpg
wrapped.jpg
withperson.jpg
burrito.jpg
withperson.jpg
froghead.jpg
lobster.jpg
wrapped.jpg
burrito.jpg
wrapped.jpg
palindrome.jpg
burrito.jpg
palindrome.jpg
withperson.jpg
burrito.jpg
wrapped.jpg
froghead.jpg
wrapped.jpg
withperson.jpg
froghead.jpg
lobster.jpg
palindrome.jpg
burrito.jpgfroghead.jpg
withperson.jpg
dune.jpg
burrito.jpg
withperson.jpg
wrapped.jpg
froghead.jpg
burrito.jpg
froghead.jpg
[]
[]
[]
[]
[food,dog]
[]
[kitten]
[]
[]
[invisible,cute,costume]
[]
[]
[food,invisible]
[kitten,dog]
[invisible,kitten]
[costume,cute,onlyface]
[cute]
[]
[]
[onlyface]
[invisible,onlyface]
[]
[]
[cute]
[]
[dog,cute]
[]
[costume]
[]
[]
[]
[kitten,apathy,cute]
[]
[onlyface]
[]
[food,cute,invisible]
[invisible,apathy,costume]
[dog]
[costume,dog]
[]
[dog]
[apathy]
[onlyface]
[kitten]
[costume,apathy]
[invisible,onlyface]
[kitten,onlyface,apathy]
[apathy,cute,onlyface]
[costume,apathy]
[onlyface,cute,invisible]
[costume]
[apathy,onlyface,costume]
[cute]
[cute,kitten]
[]
[]
[costume]
[]
[invisible]
[invisible]
[apathy,dog]
[onlyface]
[]
[costume,kitten]
[food,onlyface]
[apathy]
[onlyface,food]
[invisible,apathy,costume]
[onlyface,kitten]
[]
[]
[food,onlyface]
[cute,apathy]
[]
[dog,costume]
[cute,food]
[kitten,costume]
Abstract model
δ
Edit lens ` ∈ (M, X , ·) ↔ (N, Y , ) has set C and
dputr ∈ M × C → N × C
dputl ∈ N × C → M × C
Abstract model
δ
Edit lens ` ∈ (M, X , ·) ↔ (N, Y , ) has set C and
dputr ∈ M × C → N × C
dputl ∈ N × C → M × C
Synchronizing too often doesn’t hurt.
dputr (1M , c) = (1N , c)
Abstract model
δ
Edit lens ` ∈ (M, X , ·) ↔ (N, Y , ) has set C and
dputr ∈ M × C → N × C
dputl ∈ N × C → M × C
Synchronizing too often doesn’t hurt.
dputr (1M , c) = (1N , c)
Not synchronizing often enough doesn’t hurt.
dputr (m, c) = (n, c 0 )
dputr (m0 , c 0 ) = (n0 , c 00 )
dputr (mm0 , c) = (nn0 , c 00 )
Notable benefits
I
I
I
I
All changes reported, so synchronizing less
often is less controversial
Intentional information in edits aids alignment
Smaller complement in many cases!
Roundtrip laws are monoid homomorphism laws
Notable benefits
I
I
I
I
I
All changes reported, so synchronizing less
often is less controversial
Intentional information in edits aids alignment
Smaller complement in many cases!
Roundtrip laws are monoid homomorphism laws
Observational equivalence, combinator
language, generalizes symmetric lenses
Related work: other edit-based approaches
I
I
I
I
I
Towards an Algebraic Theory of Bidirectional
Transformations
(Stevens; ICGT 2008)
Matching Lenses: Alignment and View Update
(Barbosa, Cretin, Foster, Greenberg, and Pierce;
ICFP 2010)
From State- to Delta-based Bidirectional Model
Transformations
(Diskin, Xiong, Czarnecki; TPMT 2010)
From State- to Delta-based Bidirectional Model
Transformations: The Symmetric Case
(Diskin, Xiong, Czarnecki, Ehrig, Hermann,
and Orejas; MoDELS 2011)
Delta Lenses over Inductive Types
(Pacheco, Cunha, Hu; ECEASST 2012)
Multidirectionality
(in collaboration with Jen Paykin, Benjamin Pierce, Jeff
Vaughan, and Geoff Washburn)
[costume,food]
Jan
May
palindrome.jpg gamer.jpg froghead.jpg
burrito.jpg withperson.jpg
[costume]
[costume]
[food,onlyface]
[]
[costume,food]
[costume]
food
[costume]
[food,onlyface]
costume
onlyface
[]
New interaction mode
Students Equipment
2012 70000
2013 70000
Total 140000
Total
9000
4000
79000
74000
13000
153000
New interaction mode
Students Equipment
2012 70000
2013 70000
Total 140000
Total
9000
4000
79000
74000
13000
166000
New interaction mode
Students Equipment
2012 70000
2013 70000
Total 140000
Total
9000
4000
79000
74000
26000
166000
New interaction mode
Students Equipment
2012 70000
2013 70000
Total 140000
Total
18000
8000
79000
74000
26000
166000
New interaction mode
Students Equipment
2012 70000
2013 70000
Total 140000
Total
18000
8000
88000
78000
26000
166000
New interaction mode
Students Equipment
2012 70000
2013 70000
Total 140000
Total
18000
8000
88000
78000
26000
166000
New interaction mode
Students Equipment
2012 70000
2013 70000
Total 140000
Total
18000
8000
88000
78000
26000
166000
. . . and this happens behind the scenes, too.
Straw-man abstract model
For universe U, lens ` ∈ M (N) has components
put ∈ 2N → U N → U N
K ∈ 2U
N
Straw-man abstract model
For universe U, lens ` ∈ M (N) has components
put ∈ 2N → U N → U N
K ∈ 2U
N
Inputs are really inputs and consistency is restored.
put(S, f )|S = f |S
put(S, f ) ∈ K
Straw-man abstract model
For universe U, lens ` ∈ M (N) has components
put ∈ 2N → U N → U N
K ∈ 2U
N
Inputs are really inputs and consistency is restored.
put(S, f )|S = f |S
put(S, f ) ∈ K
put(∅, f ) = f
Synchronizing too often doesn’t hurt.
Unsolvable updates
Students Equipment Total
2012
2013
Total
70000
70000
9000
4000
79000
74000
0
0
1
Track sets of names that are always solvable.
Composition intuition
X
k
Y
Y
`
Z
Composition intuition
X
k
Y
X
k
Y
Y
`
`
Z
Z
Composition intuition
X
k
Y
X
k
Y
Y
`
`
Z
Y
X
k; `
Safe updates: {X } or {Z }.
Z
Z
Ambiguous updates
I
O1
I
k
`
O2
O2
⇓
I
k; `
O1
O2
O3
O3
Two plans
I
O1
k
`
O3
`
O3
O2
I
O1
k
O2
Observational equivalence is no help.
Remaining questions
I
I
I
I
Complete strategies for disambiguation?
Behavioral specifications for disambiguation?
How can we extend the static update check?
What dynamic update checks are possible?
Related work: bidirectional spreadsheets
I
I
I
I
I
I
I
Tiresias: The Database Oracle for How-To Queries
(Meliou and Suciu; SIGMOD ICMD 2012)
A Spreadsheet Based on Constraints
(Stadelmann; UIST 1993)
SkyBlue: A Multi-way Local Propagation Constraint Solver for
User Interface Construction
(Sannella; UIST 1994)
Expressing Multi-way Dataflow Constraint Systems as a
Commutative Monoid Makes Many of their Properties Obvious
(Järvi, Haveraaen, Freeman, and Marcus; SIGPLAN WGP 2012)
A Constraint-Based Spreadsheet for Cooperative Production
Planning
(Chew and David; KBPPSC 1992)
How to Use the Spreadsheet Manager
(Evans; tech report 1993)
Interval Constraint Spreadsheets for Financial Planning
(Hyvőnen; AIAWS 1991)
Logistics
Timeline
ICSE ESOP
PADL
now
Aug
Sept
Oct
PLDI
Nov
ambiguity research
I
I
I
I
FLOPS
Dec
Jan
ICLP
Feb
black box research
March
April
May
June
Aug
defense writing
Nailing ambiguity resolution is lynchpin
Extending static and dynamic checks is polish
Bad case: trade black box time for additional
ambiguity time
Worst case: biased composition
Why black boxes?
price = base + tax
tax = 0.08 ∗ base
base
const
rate
∗
+
tax
price
Why black boxes?
price = base + tax
tax = 0.08 ∗ base
base
const
rate
∗
+
tax
price
Why black boxes?
price = base + tax
tax = 0.08 ∗ base
base
const
rate
∗
+
tax
price
Why black boxes?
price = base + tax
tax = 0.08 ∗ base
base
const
rate
∗
+
tax
price
How to progress
B
A
`
A
C
constraint
I
I
I
I
B
`
B
A
`
C
C
sample methods
When any plan will do: greedy algorithm
Assign a cost to each method
Specification: min-cost set of methods
Implementation: search (efficient when
combining costs is monotonic)

Similar documents