substance and style domain specific languages for
play

Substance and Style: domain-specific languages for mathematical - PowerPoint PPT Presentation

B A A B A B Definition Surjection(Map f, Set X, Set Y): forall y : Y | exists x : X | f(x) = y f: A -> B Set A, B Surjection(f, A, B) Substance and Style: domain-specific languages for mathematical diagrams Wode Nimo Ni Columbia


  1. B A A B A B Definition Surjection(Map f, Set X, Set Y): forall y : Y | exists x : X | f(x) = y f: A -> B Set A, B Surjection(f, A, B) Substance and Style: domain-specific languages for mathematical diagrams Wode “Nimo” Ni Columbia University with Katherine Ye, Joshua Sunshine, Jonathan Aldrich, Keenan Crane 1

  2. Diagram from Wikipedia page for “sine”. h?ps://commons.wikimedia.org/wiki/File:Circle_cos_sin.gif 2

  3. Illustrating Venn diagram in TikZ \documentclass{article} \usepackage{tikz} \begin{document} \pagestyle{empty} \begin{tikzpicture} \begin{scope}[shift={(3cm,-5cm)}, fill opacity=0.5] \draw[fill=red, draw = black] (0,0) circle (5); \draw[fill=green, draw = black] (-1.5,0) circle (3); \draw[fill=blue, draw = black] (1.5,0) circle (3); \node at (0,4) (A) {\large\textbf{A}}; \node at (-2,1) (B) {\large\textbf{B}}; \node at (2,1) (C) {\large\textbf{C}}; \node at (0,0) (D) {\large\textbf{D}}; \end{scope} \end{tikzpicture} \end{document} 3

  4. Illustrating Venn diagram in TikZ \documentclass{article} \usepackage{tikz} \begin{document} \pagestyle{empty} \begin{tikzpicture} 1. Specify the colors, sizes, and locations of the circles 2. Create “nodes” for the labels and determine the locations of the labels \end{tikzpicture} \end{document} 4

  5. Illustrating Venn diagram in TikZ \documentclass{article} \usepackage{tikz} \begin{document} \pagestyle{empty} \begin{tikzpicture} \begin{scope}[shift={(3cm,-5cm)}, fill opacity=0.5] \draw[fill=red, draw = black] (0,0) circle (5); \draw[fill=green, draw = black] (-1.5,0) circle (3); \draw[fill=blue, draw = black] (1.5,0) circle (3); \node at (0,4) (A) {\large\textbf{A}}; \node at (-2,1) (B) {\large\textbf{B}}; \node at (2,1) (C) {\large\textbf{C}}; \node at (0,0) (D) {\large\textbf{D}}; \end{scope} \end{tikzpicture} \end{document} 5

  6. Illustrating Venn diagram in TikZ \documentclass{article} \usepackage{tikz} \begin{document} Low-level manipulation \pagestyle{empty} \begin{tikzpicture} \begin{scope}[shift={(3cm,-5cm)}, fill opacity=0.5] down to pixels. \draw[fill=red, draw = black] (0,0) circle (5); \draw[fill=green, draw = black] (-1.5,0) circle (3); \draw[fill=blue, draw = black] (1.5,0) circle (3); Semantics of the diagram \node at (0,4) (A) {\large\textbf{A}}; \node at (-2,1) (B) {\large\textbf{B}}; is completely lost. \node at (2,1) (C) {\large\textbf{C}}; \node at (0,0) (D) {\large\textbf{D}}; \end{scope} \end{tikzpicture} \end{document} 6

  7. Illustrating Venn diagram in TikZ \documentclass{article} What were \usepackage{tikz} \begin{document} we trying to \pagestyle{empty} \begin{tikzpicture} illustrate \begin{scope}[shift={(3cm,-5cm)}, fill opacity=0.5] \draw[fill=red, draw = black] (0,0) circle (5); \draw[fill=green, draw = black] (-1.5,0) circle (3); originally? \draw[fill=blue, draw = black] (1.5,0) circle (3); \node at (0,4) (A) {\large\textbf{A}}; Circles and \node at (-2,1) (B) {\large\textbf{B}}; \node at (2,1) (C) {\large\textbf{C}}; \node at (0,0) (D) {\large\textbf{D}}; text labels? \end{scope} \end{tikzpicture} \end{document} 7

  8. Graph visualization using Graphviz graph G { a e b subgraph clusterA { a -- b; subgraph clusterC { D C -- D; } C } d subgraph clusterB { d -- f f } d -- D e -- clusterB e clusterC -- clusterB } 8

  9. Graph visualization using Graphviz graph G { a e b subgraph clusterA { High-level and a -- b; subgraph clusterC { D clean, but only C -- D; } C works for } d subgraph clusterB { d -- f graphs! f } d -- D e -- clusterB e clusterC -- clusterB } 9

  10. Direct manipulation tools 10

  11. Penrose 11

  12. Language design 12

  13. Penrose has two extensible DSLs Substance Style High-level declaration of Specifies the visual presentation mathematical objects of the objects Set A { shape = Circle{ } Set A, B } Intersect A B Intersect X Y { ensure X overlapping Y } 13

  14. Set A, B Intersect A B A Set A { shape = Circle{ } } B Intersect X Y { ensure X overlapping Y } 14

  15. Substance and Style Power Casual users users • Power users encode domain expertise in Style • Casual users create diagrams declaratively using Substance 15

  16. Dr. M wants to visualize a function… How should I draw ? f : X → Y 16

  17. Dr. M wants to visualize a function… f: X -> Y How should I draw ? f : X → Y 16

  18. Dr. M wants to visualize a function… f: X -> Y Abstract Cartesian .sty .sty Style file for functions How should I draw ? f : X → Y 16

  19. Dr. M wants to visualize a function… How should I draw f: X -> Y? 17

  20. Dr. M wants to visualize a function… f Abstract X Y .sty Cartesian .sty 18

  21. Style language Set X { C shape = Circle { color = blue B } A } Selectors using pa?ern matching 19

  22. Style language Set X { shape = Circle { color = blue C } } B Subset X Y { A X.color = green } Cascading: later rules override the earlier ones 20

  23. Style language Set X { shape = Circle { color = blue C } } Subset X Y { B A X.color = green } Set `A` { A.color = pink } 21

  24. Style language Set X { shape = Circle { color = blue C } } Subset X Y { B A X.color = green } Set `A` { A.color = pink Wait . How does Penrose choose } the positions and sizes of them? 22

  25. Style language Set X { shape = Circle { color = blue } } C Subset X Y { B A X.color = green } Set `A` { A.color = pink Wait . How does Penrose choose } the positions and sizes of them? 23

  26. Optimization-based layout 24

  27. Specifying Layout in Style Set X { C shape = Circle { color = blue B A } ensure X contains X.label } Subset X Y { Declaratively specify X.color = green optimization requirements! ensure Y contains X ensure X smallerThan Y ensure Y.label outsideOf X } 25

  28. Optimizing diagram layout Energy Time 26

  29. Optimizing diagram layout E F G Exterior point method + line search B D C F E G A B Energy D D F C E B G D F A E B C G C A A Time 27

  30. Illustrating abstract function definitions 28

  31. Injective functions A function is injective , or “ one-to-one ,” if every element of its codomain is mapped from at most one element of the domain. ∀ x, x 0 ∈ X, f ( x ) = f ( x 0 ) → x = x 0 . Definition Injection(Map f, Set A): forall a1, a2 : A | f(a1) = f(a2) implies a1 = a2 29

  32. Extend with external tools • Penrose doesn’t have to understand first order logic! • Extend the system to integrate with an external tool, Alloy , to generate concrete instances given the definition of injective functions. Definition Injection(Map f, Set A): forall a1, a2 : A | f(a1) = f(a2) implies a1 = a2 f: A -> B Set A, B Injection(f, A) Penrose program 30

  33. Extend with external tools • Penrose doesn’t have to understand first order logic! • Extend the system to integrate with an external tool, Alloy , to generate concrete instances given the definition of injective functions. Definition Injection(Map f, Set A): forall a1, a2 : A | f(a1) = f(a2) implies a1 = a2 f: A -> B Set A, B Injection(f, A) Penrose program 30

  34. Extend with external tools • Penrose doesn’t have to understand first order logic! • Extend the system to integrate with an external tool, Alloy , to generate concrete instances given the definition of injective functions. 30

  35. Extend with external tools • Penrose doesn’t have to understand first order logic! • Extend the system to integrate with an external tool, Alloy , to generate concrete instances given the definition of injective functions. sig A { f : B } sig B { } fact { all a1,a2 : A | a1.f = a2.f implies a1 = a2 } pred show() { } run show for 5 30 All

  36. Extend with external tools • Penrose doesn’t have to understand first order logic! • Extend the system to integrate with an external tool, Alloy , to generate concrete instances given the definition of injective functions. sig A { f : B } sig B { } fact { all a1,a2 : A | a1.f = a2.f implies a1 = a2 } pred show() { } run show for 5 All 30

  37. Extend with external tools • Penrose doesn’t have to understand first order logic! • Extend the system to integrate with an external tool, Alloy , to generate concrete instances given the definition of injective functions. A: {A$0} B: {B$0, B$1, B$2, B$3, B$4} sig A { f : B } sig B { f: {A$0->B$4} } fact { all a1,a2 : A | a1.f = a2.f implies a1 = a2 } pred show() { } run show for 5 Alloy instances All 30

  38. Extend with external tools • Penrose doesn’t have to understand first order logic! • Extend the system to integrate with an external tool, Alloy , to generate concrete instances given the definition of injective functions. 30

  39. Extend with external tools • Penrose doesn’t understand first order logic! • Extend the system to integrate with an external tool, Alloy , to generate concrete instances given the definition of injective functions. A B 31

  40. Visualizing injective functions B A 32

  41. Visualizing injective functions B A B A 32

  42. Visualizing injective functions B A B A B A 32

  43. Visualizing injective functions B A B A B A A bijection is a special case of injection! 32

Recommend


More recommend