Hesam Samimi Alessandro War0h
Const4aints as a Desig7 Pa9er7
Lab Labs
Mahdi Eslamimehr Alan Bor7ing
Const4aints as a Desig7 Pa9er7 Hesam Samimi Alessandro - - PowerPoint PPT Presentation
Const4aints as a Desig7 Pa9er7 Hesam Samimi Alessandro War0h Mahdi Eslamimehr Alan Bor7ing Lab Labs MODULE bakeCarrotCake MAIN var timer, pan, bowl, grease, flour; oven.start(); WHILE (oven.heat < 350) END WHILE;
Hesam Samimi Alessandro War0h
Const4aints as a Desig7 Pa9er7
Lab Labs
Mahdi Eslamimehr Alan Bor7ing
MODULE bakeCarrotCake MAIN var timer, pan, bowl, grease, flour;
WHILE (oven.heat < 350) END WHILE; add(&pan, &grease); add(&pan, &flour); add(&bowl, &egg1); add(&bowl, &vanilla); add(&bowl, &carrots); timer.start(); place(&bowl, &oven); WHILE (timer.time() < 50) if (toothPickInCenterOfCake() && itComesOutClean()) { break; /* HACK FIXME */ } END WHILE; timer.reset(); WHILE (timer.time() < 10) END WHILE; remove(&bowl, &over); END
CARROT CAKE Serves: 18 Calories: 575
a 9x13 inch pan.
teaspoons vanilla. Mix in flour, baking soda, baking powder, salt and
toothpick inserted into the center of the cake comes out clean. Let cool in pan for 10 minutes, then turn out onto a wire rack and cool completely.
✔ ✔ ✔
CARROT CAKE Serves: 18 Calories: 575
a 9x13 inch pan.
teaspoons vanilla. Mix in flour, baking soda, baking powder, salt and
toothpick inserted into the center of the cake comes out clean. Let cool in pan for 10 minutes, then turn out onto a wire rack and cool completely.
✔ ✔ ✔
CARROT CAKE Serves: 18 Calories: 575
a 9x13 inch pan.
teaspoons vanilla. Mix in flour, baking soda, baking powder, salt and
toothpick inserted into the center of the cake comes out clean. Let cool in pan for 10 minutes, then turn out onto a wire rack and cool completely.
1K-1M LoC
⊙⊙ meaning??
CARROT CAKE Serves: 18 Calories: 575
a 9x13 inch pan.
teaspoons vanilla. Mix in flour, baking soda, baking powder, salt and
toothpick inserted into the center of the cake comes out clean. Let cool in pan for 10 minutes, then turn out onto a wire rack and cool completely.
✔ ✔ ✔
how what
CARROT CAKE Serves: 18 20 Calories: 575 350 1. 2. 3.
what
✗ ✗
CARROT CAKE Serves: 18 20 Calories: 575 350 1. 2. 3.
what how
✗ ✗
⊙⊙
CARROT CAKE Serves: 18 Calories: 575
how what
✗
a solution
constraint constraint solver solver
CARROT CAKE Serves: 18 20 Calories: 575 350
how what
✗
a solution
constraint constraint solver solver
✗ ✗
constraint constraint solver solver
constraint constraint solver solver
perforGance exJressivitL
MODULE bakeCarrotCake MAIN var timer, pan, bowl, grease, flour;
WHILE (oven.heat < 350) END WHILE; add(&pan, &grease); add(&pan, &flour); add(&bowl, &egg1); add(&bowl, &vanilla); add(&bowl, &carrots); timer.start(); place(&bowl, &oven); WHILE (timer.time() < 50) if (toothPickInCenterOfCake() && itComesOutClean()) { break; /* HACK FIXME */ } END WHILE; timer.reset(); WHILE (timer.time() < 10) END WHILE; remove(&bowl, &over); END
fallback to… ugly... works, fast!
First purely declarative prog4amming system?
Ivan Sutherland’s Sketchpad - 1961
Ivan Sutherland’s Sketchpad - 1961
inspiration method
prog4am
prog4am
constraints
constraints
prog4am
UI to interact w/ const4aints
specific solvers
prog4am
coded in imperative langZage
API in IMP to define const4aints & how to solve constraints
constraints constraints imperative imperative code code
prog4am
ü flexbilitL ü efficiency ü practicalitL ü modularitL ü understandabilitL ü ex0ensibilitL ü emergent behavior
code
{
SMT SAT numeric …
prog4am
constraints constraints imperative imperative code code
prog4am
constraints
prog4am
API to interact w/ const4aints
constraints
prog4am
UI to interact w/ const4aints
specific solvers
prog4am
coded in imperative langZage
API in IMP to define const4aints & how to solve constraints
Defining a Const4aint
p1 p2 l
Solving
constraint in isolation
Solving a Const4aint
p1 p2 l
Solving
constraint in isolation
Merging Solutions
Solving
constraint in isolation
iterative (relaxation)
hardcoded
Solving
Demo: Benefits
Related Work
vs.
code const4aints const4aints code
prog4am prog4am
Mixed Prog4amming e.g. Const4aint Imperative Prog4amming (CIP) ‘90 Const4aint as a Desig7 Pa9er7 (CDP)
always x + y = 100 y := 40;
h9J://www.cdglabs.org/sketchpad14
Thank you!
Execution…