guanxi edward kmett...–gandalf the grey, about barliman butterbur “he thinks less than he talks,...

31
Edward Kmett GUANXI LOGIC PROGRAMMING A LA CARTE

Upload: others

Post on 20-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

Edward KmettGUANXI

LOGIC PROGRAMMING A LA CARTE

Page 2: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

https://intelligence.org/

Page 3: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”
Page 4: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”
Page 5: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”
Page 6: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”
Page 7: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

Marvin Minsky Aug 9, 1927 - Jan 24, 2016

Page 8: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”
Page 9: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

(MINI)KANRENLOGIC PROGRAMMING IN SCHEME

https://mitpress.mit.edu/books/reasoned-schemer-second-edition

Page 10: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

KANREN

Page 11: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

vs.

KANREN GUANXI

Page 12: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

https://www.youtube.com/watch?v=er_lLvkklsk

Page 13: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”
Page 14: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

–Gandalf the Grey, about Barliman Butterbur

“He thinks less than he talks, and slower; yet he can see

through a brick wall in time (as they say in Bree).”

https://github.com/webyrd/Barliman

Page 15: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”
Page 16: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

LOGICTclass MonadPlus m => MonadLogic m where msplit :: m a -> m (Maybe (a, m a))

reflect :: Maybe (a, m a) -> m areflect Nothing = mzeroreflect (Just (a, as)) = pure a <|> as

msplit >=> reflect = id

Page 17: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

LOGICT IS NOT DEPTH-FIRST

PROS

• Like breadth-first, it won’t get lost in a blind alley forever.

CONS

• This means it must keep manual environments around

• Not compatible w/ incremental SMT solvers

• It uses a ton of memory.

Page 18: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

TYPED LOGIC VARIABLES IN HASKELLUSE REAL REFERENCES THEN BACKTRACK

https://gup.ub.gu.se/file/207634

Page 19: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

• Idea: Learn to avoid where you’ve been. CDCL in SAT solvers does this already.

• Rapid restarts are a huge deal in SMT solving

Page 20: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

PROPAGATORSMONOTONE FUNCTIONS BETWEEN JOIN SEMILATTICES

https://www.youtube.com/watch?v=acZkF6Q2XKs

Page 21: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

UNION-FINDWORKHORSE OF THE UNIFICATION WORLD

Page 22: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

MONOID AND GROUP ACTIONSclass Monoid m => Group m where inv :: m -> m

-- act mempty = id-- act (m <> n) = act m . act nclass Monoid m => MonoidAction m s where act :: m -> s -> s

type GroupAction m s = (Group m, MonoidAction m s)

Page 23: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

UNIFICATION MODULO GROUP ACTION

x = act a y

z = act b y

y = act (inv a) x

z = act b (act (inv a)) x = act (b <> inv a) x

Page 24: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

USEFUL GROUP ACTIONS

• x = y + c (integer addition)

• x = (id | not) y (two element group)

• x = { +1, -1 } y + b (affine trans. w/ unit scale)

Page 25: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

O(1) GROUP ACTIONS ON CONTAINERSMANDATORY FOR OPTIMAL ASYMPTOTIC PERFORMANCE

Monoidal Parsing - Scala World 2017

https://www.youtube.com/watch?v=Txf7swrcLYs

Page 26: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

REFLECTION WITHOUT REMORSEFREE MONADS WITH BETTER ASYMPTOTICS SAFE DELIMITED CONTINUATIONS

Page 27: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

NATURAL DOMAIN SMTPERFORM CONFLICT DIRECTED CLAUSE LEARNING DIRECTLY IN THE SEMANTIC DOMAIN

Page 28: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

Key Observation: Guessing “too early” on some vertex separator can be a massive asymptotic performance win if your constraints are too hard to maintain!

NATURAL DOMAINS

• INTERVALS O(n)

• OCTAGONS O(n^4)

• POLYHEDRA O(2^n)

• PRESBURGER O(2^2^2^n)

Page 29: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

OTHER RESULTS

• Pay attention to K-L divergence in sampling. Feeding random bits to an arithmetic decoder beats the baseline strategy NeuralKanren was tested against! We can draw without replacement if I track where in the sample space I’ve been and that can be stored succinctly in 2n + o(n) bits per decision functionally, as the application state! Way smaller than all those environments.

• There is a close connection to property-based testing when you’re trying to find a syntax tree with some property.

• Seminaive evaluation of Datalog offers lessons about topological sorting the propagator network as well as tracking changes since last use rather than directly performing semilattice joins.

• Adding nondeterminism fixes a lot of the headaches of using propagators to describe SAT and many other domains.

• Luby-style rapid restarts are very important for performance

• Use brute force when appropriate! Dancing Links, Dancing with Decision Diagrams.

• Dropping the ‘dancing links’ part of the dancing links algorithm and replacing it with SIMD bit operations makes the tasks easily parallelizable and able to be run on a GPU

• Atze van der Ploeg’s “Key” type makes heterogeneous maps very easy to work with and keeps popping up.

• For the most part this is embarassingly parallel, 1000 machines takes Barliman well below the Doherty threshold.

Page 30: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

WANT MORE?

IRC: irc.freenode.net ##coda

Git: http://github.com/ekmett/guanxi

Twitch: http://twitch.tv/ekmett

Page 31: GUANXI Edward Kmett...–Gandalf the Grey, about Barliman Butterbur “He thinks less than he talks, and slower; yet he can see through a brick wall in time (as they say in Bree).”

QUESTIONS?