Slide 1

Slide 1 text

P r o g r a m m a t i o n e n C l o g i q u e L a r s H u p e l : c l o j u r e D 2 0 2 0 - 0 2 - 2 9

Slide 2

Slide 2 text

(defne presentation [orateur] ([:lars] (fresh [questions] (blague :drole) #_(rire) (introduction :corelogic) (fonctions :cool) (audience questions) (repondre questions))))

Slide 3

Slide 3 text

P r o g r a m m a t i o n e n C l o g i q u e L a r s H u p e l : c l o j u r e D 2 0 2 0 - 0 2 - 2 9

Slide 4

Slide 4 text

(defne presentation [speaker] ([:lars] (fresh [questions] (joke :funny) #_(laugh) (introduction :corelogic) (features :cool) (audience questions) (answer questions))))

Slide 5

Slide 5 text

(defne presentation [speaker] ([:lars] (fresh [questions] (joke :funny) #_(laugh) (introduction :corelogic) (features :cool) (audience questions) (answer questions))))

Slide 6

Slide 6 text

W h o i n v e n t e d l o g i c p r o g r a m m i n g ? “ 1 . T h e w o r l d i s e v e r y t h i n g t h a t i s t h e c a s e . 1 .1 T h e w o r l d i s t h e t o t a l i t y o f f a c t s , n o t o f t h i n g s . 1 .1 1 T h e w o r l d i s d e t e r m i n e d b y t h e f a c t s , a n d b y t h e s e b e i n g a l l t h e f a c t s . ”

Slide 7

Slide 7 text

W h o i n v e n t e d l o g i c p r o g r a m m i n g ? “ 1 . T h e w o r l d i s e v e r y t h i n g t h a t i s t h e c a s e . 1 .1 T h e w o r l d i s t h e t o t a l i t y o f f a c t s , n o t o f t h i n g s . 1 .1 1 T h e w o r l d i s d e t e r m i n e d b y t h e f a c t s , a n d b y t h e s e b e i n g a l l t h e f a c t s . ” – L u d w i g W i t t g e n s t e i n , 1 9 1 8

Slide 8

Slide 8 text

(defne presentation [speaker] ([:lars] (fresh [questions] (joke :funny) #_(laugh) (introduction :corelogic) (features :cool) (audience questions) (answer questions))))

Slide 9

Slide 9 text

W h o i n v e n t e d P r o l o g ? • a p p e a r e d i n t h e e a r l y 7 0 s i n F r a n c e • o r i g i n a l d e v e l o p e r s : A l a i n C o l m e r a u e r a n d P h i l i p p e R o u s s e l • u s e d t h e .pl e x t e n s i o n b e f o r e P e r l • r a d i c a l l y d i f f e r e n t p r o g r a m m i n g p a r a d i g m • t h i s t a l k : u s i n g c o r e . l o g i c s y n t a x

Slide 10

Slide 10 text

A b r i e f p r i m e r o n P r o l o g 1 . P r o l o g p r o g r a m s a r e s e q u e n c e s o f r u l e s ( o r c l a u s e s ) .

Slide 11

Slide 11 text

A b r i e f p r i m e r o n P r o l o g 1 . P r o l o g p r o g r a m s a r e s e q u e n c e s o f r u l e s ( o r c l a u s e s ) . 2 . R u l e s c a n h a v e a r g u m e n t s .

Slide 12

Slide 12 text

A b r i e f p r i m e r o n P r o l o g 1 . P r o l o g p r o g r a m s a r e s e q u e n c e s o f r u l e s ( o r c l a u s e s ) . 2 . R u l e s c a n h a v e a r g u m e n t s . 3 . R u l e s c a n h a v e c o n d i t i o n s .

Slide 13

Slide 13 text

A b r i e f p r i m e r o n P r o l o g 1 . P r o l o g p r o g r a m s a r e s e q u e n c e s o f r u l e s ( o r c l a u s e s ) . 2 . R u l e s c a n h a v e a r g u m e n t s . 3 . R u l e s c a n h a v e c o n d i t i o n s . 4 . P r o g r a m s c a n b e q u e r i e d .

Slide 14

Slide 14 text

A b r i e f p r i m e r o n P r o l o g 1 . P r o l o g p r o g r a m s a r e s e q u e n c e s o f r u l e s ( o r c l a u s e s ) . 2 . R u l e s c a n h a v e a r g u m e n t s . 3 . R u l e s c a n h a v e c o n d i t i o n s . 4 . P r o g r a m s c a n b e q u e r i e d . 5 . A n y t h i n g t h a t i s n o t i n t h e p r o g r a m i s n o t t r u e .

Slide 15

Slide 15 text

E r l a n g , i n s p i r e d b y P r o l o g “ T h e f i r s t i n t e r p r e t e r w a s a s i m p l e P r o l o g m e t a i n t e r p r e t e r w h i c h a d d e d t h e n o t i o n o f a s u s p e n d a b l e p r o c e s s t o P r o l o g . . . [ i t ] w a s r a p i d l y m o d i f i e d ( a n d r e - w r i t t e n ) . . . ” – A r m s t r o n g , V i r d i n g , W i l l i a m s : U s e o f P r o l o g f o r d e v e l o p i n g a n e w p r o g r a m m i n g l a n g u a g e

Slide 16

Slide 16 text

H e l l o W o r l d ! P r o g r a m (defn hi [])

Slide 17

Slide 17 text

H e l l o W o r l d ! P r o g r a m (defn hi []) I n t e r p r e t e r => (run* (hi)) (_0)

Slide 18

Slide 18 text

H e l l o W o r l d ! P r o g r a m (defn hi []) I n t e r p r e t e r => (run* (hi)) (_0) (defn hello [x] (== x :world))

Slide 19

Slide 19 text

H e l l o W o r l d ! P r o g r a m (defn hi []) I n t e r p r e t e r => (run* (hi)) (_0) (defn hello [x] (== x :world)) => (run* [_] (hello :world)) (_0)

Slide 20

Slide 20 text

H e l l o W o r l d ! P r o g r a m (defn hi []) I n t e r p r e t e r => (run* (hi)) (_0) (defn hello [x] (== x :world)) => (run* [_] (hello :world)) (_0) => (run* [_] (hello :coworld)) ()

Slide 21

Slide 21 text

H e l l o W o r l d ! P r o g r a m (defn hi []) I n t e r p r e t e r => (run* (hi)) (_0) (defn hello [x] (== x :world)) => (run* [_] (hello :world)) (_0) => (run* [_] (hello :coworld)) ()

Slide 22

Slide 22 text

H e l l o W o r l d ! P r o g r a m (defn hi []) I n t e r p r e t e r => (run* (hi)) (_0) (defn hello [x] (== x :world)) => (run* [_] (hello :world)) (_0) => (run* [_] (hello :coworld)) () => (run* [x] (hello x)) (:world)

Slide 23

Slide 23 text

A s m a l l p r o g r a m F a c t s (defne location [place in] ([:munich :germany]) ([:augsburg :germany]) ([:germany :europe]) ([:london :unitedkingdom]) ([:unitedkingdom :europe]))

Slide 24

Slide 24 text

A s m a l l p r o g r a m F a c t s (defne location [place in] ([:munich :germany]) ([:augsburg :germany]) ([:germany :europe]) ([:london :unitedkingdom]) ([:unitedkingdom :europe])) EU Customs Union Council of Europe European Union EEA BSEC Eurozone Benelux Baltic Assembly EFTA GUAM CEFTA Schengen Area Union State Nordic Council Visegrád Group Common Travel Area Monetary agreement with the EU

Slide 25

Slide 25 text

A s m a l l p r o g r a m F a c t s (defne location [place in] ([:munich :germany]) ([:augsburg :germany]) ([:germany :europe]) ([:london :unitedkingdom]) ([:unitedkingdom :europe]))

Slide 26

Slide 26 text

A s m a l l p r o g r a m F a c t s (defne location [place in] ([:munich :germany]) ([:augsburg :germany]) ([:germany :europe]) ([:london :unitedkingdom]) ([:unitedkingdom :europe])) R u l e s (defn neighbour [x y] (fresh [z] (location x z) (location y z)))

Slide 27

Slide 27 text

A s m a l l p r o g r a m F a c t s (defne location [place in] ([:munich :germany]) ([:augsburg :germany]) ([:germany :europe]) ([:london :unitedkingdom]) ([:unitedkingdom :europe])) R u l e s (defn is-in [x y] (conde [(location x y)] [(fresh (z) (location x z) (is-in z y))]))

Slide 28

Slide 28 text

(defne presentation [speaker] ([:lars] (fresh [questions] (joke :funny) #_(laugh) (introduction :corelogic) (features :cool) (audience questions) (answer questions))))

Slide 29

Slide 29 text

B a c k t r a c k i n g (defn best-boy [x] (fresh [y] (dog :good x) (colour :dark_brown x) (behind x y) (colour :light_brown y)))

Slide 30

Slide 30 text

B a c k t r a c k i n g (defn best-boy [x] (fresh [y] (dog :good x) (colour :dark_brown x) (behind x y) (colour :light_brown y)))

Slide 31

Slide 31 text

B a c k t r a c k i n g (defn best-boy [x] (fresh [y] (dog :good x) (colour :dark_brown x) (behind x y) (colour :light_brown y)))

Slide 32

Slide 32 text

B a c k t r a c k i n g (defn best-boy [x] (fresh [y] (dog :good x) (colour :dark_brown x) (behind x y) (colour :light_brown y)))

Slide 33

Slide 33 text

B a c k t r a c k i n g (defn best-boy [x] (fresh [y] (dog :good x) (colour :dark_brown x) (behind x y) (colour :light_brown y)))

Slide 34

Slide 34 text

B a c k t r a c k i n g (defn best-boy [x] (fresh [y] (dog :good x) (colour :dark_brown x) (behind x y) (colour :light_brown y)))

Slide 35

Slide 35 text

B a c k t r a c k i n g (defn best-boy [x] (fresh [y] (dog :good x) (colour :dark_brown x) (behind x y) (colour :light_brown y)))

Slide 36

Slide 36 text

B a c k t r a c k i n g (defn best-boy [x] (fresh [y] (dog :good x) (colour :dark_brown x) (behind x y) (colour :light_brown y)))

Slide 37

Slide 37 text

B a c k t r a c k i n g (defn best-boy [x] (fresh [y] (dog :good x) (colour :dark_brown x) (behind x y) (colour :light_brown y)))

Slide 38

Slide 38 text

B a c k t r a c k i n g (defn best-boy [x] (fresh [y] (dog :good x) (colour :dark_brown x) (behind x y) (colour :light_brown y)))

Slide 39

Slide 39 text

B i - d i r e c t i o n a l c o m p u t i n g f : I → O

Slide 40

Slide 40 text

B i - d i r e c t i o n a l c o m p u t i n g f : I → O

Slide 41

Slide 41 text

B i - d i r e c t i o n a l c o m p u t i n g f : I → O R : (I × O ) → {0 , 1 }

Slide 42

Slide 42 text

B i - d i r e c t i o n a l c o m p u t i n g C l o j u r e (concat xs ys)

Slide 43

Slide 43 text

B i - d i r e c t i o n a l c o m p u t i n g C l o j u r e (concat xs ys) c o r e . l o g i c (appendo xs ys zs)

Slide 44

Slide 44 text

N o t a s i l v e r b u l l e t . . . H o w t o r e v e r s e flatten?

Slide 45

Slide 45 text

W h a t a b o u t n u m b e r s ? => (run* [x y] (membero x [1 2 3]) (== y 2) (> x y))

Slide 46

Slide 46 text

W h a t a b o u t n u m b e r s ? => (run* [x y] (membero x [1 2 3]) (== y 2) (> x y))

Slide 47

Slide 47 text

W h a t a b o u t n u m b e r s ? => (run* [x y] (membero x [1 2 3]) (== y 2) (> x y)) => (require '[clojure.core.logic.fd :as fd]) => (run* [x y] (membero x [1 2 3]) (== y 2) (fd/> x y)) ([3 2])

Slide 48

Slide 48 text

F a c t d a t a b a s e s H o w t o m o d e l f a c t s e v o l v i n g o v e r t i m e ?

Slide 49

Slide 49 text

F a c t d a t a b a s e s H o w t o m o d e l f a c t s e v o l v i n g o v e r t i m e ? S e l f - m o d i f y i n g c o d e ?

Slide 50

Slide 50 text

F a c t d a t a b a s e s H o w t o m o d e l f a c t s e v o l v i n g o v e r t i m e ? S e l f - m o d i f y i n g c o d e ? J u s t l i k e i n S Q L !

Slide 51

Slide 51 text

P L D B (pldb/db-rel location p q) (def facts (pldb/db [location :munich :germany] [location :augsburg :germany] [location :germany :europe] [location :london :unitedkingdom] [location :unitedkingdom :europe]))

Slide 52

Slide 52 text

P L D B a s r e a l d a t a b a s e • d a t a m o d e l i s s i m i l a r t o S Q L : s e t s o f t u p l e s ( “ r e l a t i o n s ” ) • P L D B i s s t a t i c & i m m u t a b l e

Slide 53

Slide 53 text

C o n s t r a i n t s o l v i n g P u z z l e T h e r e a r e f i v e h o u s e s . 1 . T h e E n g l i s h p e r s o n l i v e s i n t h e r e d h o u s e . 2 . T h e S w e d i s h p e r s o n o w n s a d o g . 3 . T h e D a n i s h p e r s o n l i k e s t o d r i n k t e a . 4 . T h e g r e e n h o u s e i s l e f t t o t h e w h i t e h o u s e . 5 . T h e o w n e r o f t h e g r e e n h o u s e d r i n k s c o f f e e . 6 . . . .

Slide 54

Slide 54 text

G r a m m a r s

Slide 55

Slide 55 text

G r a m m a r s

Slide 56

Slide 56 text

G r a m m a r s

Slide 57

Slide 57 text

G r a m m a r s (def-->e det [d] ([[:d 'the]] '[the]) ([[:d 'a]] '[a])) (def-->e noun-phrase [n] ([[:np ?d ?n]] (det ?d) (noun ?n)))

Slide 58

Slide 58 text

P r o l o g i s f o r p a r s i n g ? “ T h e p r o g r a m m i n g l a n g u a g e . . . w a s b o r n o f a p r o j e c t a i m e d n o t a t p r o d u c i n g a p r o g r a m m i n g l a n g u a g e b u t a t p r o c e s s i n g n a t u r a l l a n - g u a g e s ; i n t h i s c a s e , F r e n c h . ” – C o l m e r a u e r , R o u s s e l : T h e B i r t h o f P r o l o g

Slide 59

Slide 59 text

P r o l o g i s f o r p a r s i n g ? “ T h e p r o g r a m m i n g l a n g u a g e . . . w a s b o r n o f a p r o j e c t a i m e d n o t a t p r o d u c i n g a p r o g r a m m i n g l a n g u a g e b u t a t p r o c e s s i n g n a t u r a l l a n - g u a g e s ; i n t h i s c a s e , F r e n c h . ” – C o l m e r a u e r , R o u s s e l : T h e B i r t h o f P r o l o g

Slide 60

Slide 60 text

(defne presentation [speaker] ([:lars] (fresh [questions] (joke :funny) #_(laugh) (introduction :corelogic) (features :cool) (audience questions) (answer questions))))

Slide 61

Slide 61 text

Q & A L a r s H u p e l � l a r s . h u p e l @ i n n o q . c o m � @ l a r s r _ h w w w . i n n o q . c o m i n n o Q D e u t s c h l a n d G m b H K r i s c h e r s t r . 1 0 0 4 0 7 8 9 M o n h e i m a . R h . G e r m a n y + 4 9 2 1 7 3 3 3 6 6 - 0 O h l a u e r S t r . 4 3 1 0 9 9 9 B e r l i n G e r m a n y L u d w i g s t r . 1 8 0 E 6 3 0 6 7 O f f e n b a c h G e r m a n y K r e u z s t r . 1 6 8 0 3 3 1 M ü n c h e n G e r m a n y c / o W e W o r k H e r m a n n s t r a s s e 1 3 2 0 0 9 5 H a m b u r g G e r m a n y i n n o Q S c h w e i z G m b H G e w e r b e s t r . 1 1 C H - 6 3 3 0 C h a m S w i t z e r l a n d + 4 1 4 1 7 4 3 0 1 1 1 A l b u l a s t r . 5 5 8 0 4 8 Z ü r i c h S w i t z e r l a n d

Slide 62

Slide 62 text

L A R S H U P E L C o n s u l t a n t i n n o Q D e u t s c h l a n d G m b H L a r s e n j o y s p r o g r a m m i n g i n a v a r i e t y o f l a n - g u a g e s , i n c l u d i n g S c a l a , H a s k e l l , a n d R u s t . H e i s k n o w n a s a f r e q u e n t c o n f e r e n c e s p e a k e r a n d o n e o f t h e f o u n d e r s o f t h e T y p e l e v e l i n i t i a t i v e w h i c h i s d e d i c a t e d t o p r o v i d i n g p r i n c i p l e d , t y p e - d r i v e n S c a l a l i b r a r i e s .

Slide 63

Slide 63 text

I m a g e s o u r c e s • T i t l e ( m a p ) : https://pixabay.com/photos/world-europe-map-connections-1264062/ • S h i b a r o w : https://www.pinterest.de/pin/424112489894679416/ • S h i b a w i t h m l e m : https://www.reddit.com/r/mlem/comments/6tc1of/shibe_doing_a_mlem/ • H a p p y d o g : https://www.rover.com/blog/is-my-dog-happy/ • K i d w i t h c r o s s e d a r m s : https: //www.psychologytoday.com/us/blog/spycatcher/201410/9-truths-exposing-myth-about-body-language • N o a m C h o m s k y : https://en.wikipedia.org/wiki/File:Noam_Chomsky_Toronto_2011.jpg • A l a i n C o l m e r a u e r : https://de.wikipedia.org/wiki/Datei:A-Colmerauer_web-800x423.jpg • J o e A r m s t r o n g : E r l a n g , t h e M o v i e • S i g n a t u r e s : http://www.swi-prolog.org/pldoc/man?section=preddesc • Z e b r a p u z z l e : S t a c k O v e r f l o w c o n t r i b u t o r s ( https://stackoverflow.com/q/11122814/4776939) • O w l : https://www.theloop.ca/angry-owl-terrorizes-oregon-joggers/ • C l o c k : https://pixabay.com/photos/clock-alarm-alarm-clock-dial-time-1031503/ • F i l e s : https://pixabay.com/photos/files-ddr-archive-1633406/