<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>PPDL: Probabilistic Programming with Datalog</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Balder ten Cate</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Benny Kimelfeld?</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Dan Olteanu</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>LogicBlox</string-name>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Technion</institution>
          ,
          <country country="IL">Israel</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>University of Oxford</institution>
          ,
          <country country="UK">UK</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>There has been a substantial recent focus on the concept of probabilistic programming [6] towards its positioning as a prominent paradigm for advancing and facilitating the development of machine-learning applications.4 A probabilisticprogramming language typically consists of two components: a speci cation of a stochastic process (the prior), and a speci cation of observations that restrict the probability space to a conditional subspace (the posterior). This paper gives a brief overview of Probabilistic Programming DataLog (PPDL), a recently proposed declarative framework for specifying statistical models on top of a database, through an appropriate extension of Datalog [1]. By virtue of extending Datalog, PPDL o ers a natural integration with the database, and has a robust declarative semantics, that is, semantic independence from the algorithmic evaluation of rules, and semantic invariance under logical program transformations. It provides convenient mechanisms to allow common numerical probability functions as rst-class citizens in the language; in particular, conclusions of rules may contain values drawn from such functions.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
    </sec>
    <sec id="sec-2">
      <title>PPDL</title>
      <p>
        The semantics of a PPDL program is a probability distribution over the possible
outcomes of the input database with respect to the program. These outcomes are
minimal solutions with respect to a related program that involves existentially
quanti ed variables in conclusions. Observations are incorporated by means of
logical integrity constraints. As argued in [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], the ability to express
probabilistic models concisely and declaratively in a Datalog extension, with probability
distributions as rst-class citizens, is what sets PPDL apart from the wealth of
literature on probabilistic Datalog [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], probabilistic databases [
        <xref ref-type="bibr" rid="ref11 ref8">8,11</xref>
        ], and Markov
Logic Networks [
        <xref ref-type="bibr" rid="ref10 ref4 ref7">4, 7, 10</xref>
        ]. In the remaining of this section we introduce PPDL
using an example program, and show how to interpret it probabilistically.
      </p>
      <p>Our example is inspired by the burglar example of Pearl that has been
frequently used for illustrating probabilistic programming. This example models a
statistical process of alarming due to burglaries and earthquakes, and the goal is
? Taub Fellow { supported by the Taub Foundation
4 An e ort in this direction is led by DARPA's Probabilistic Programming for
Advancing Machine Learning (PPAML) program.</p>
      <p>House
id city
NP1 Napa
NP2 Napa
YC1 Yucaipa</p>
      <sec id="sec-2-1">
        <title>Business</title>
        <p>id city
NP3 Napa
YC1 Yucaipa</p>
      </sec>
      <sec id="sec-2-2">
        <title>City</title>
        <p>name burglaryrate
Napa 0:03
Yucaipa 0:01</p>
      </sec>
      <sec id="sec-2-3">
        <title>ObservedAlarm</title>
        <p>unit
NP1
YC1
YC2
to estimate the likelihood that a given collection of alarms indicates these
alarming events. Consider a database consisting of the following relations: House(h; c)
represents houses h and their location cities c, Business(b; c) represents businesses
b and their location cities c, City(c; r) represents cities c and their associated
burglary rates r, and ObservedAlarm(x) represents units (houses or businesses) x
where the alarm went o . These are the EDB relations that are not changed
by the program. Figure 1 shows an instance over the schema. Now consider the
PPDL program P in Figure 2, where some rules use the Flip distribution in their
heads. The rst rule states, intuitively, that for every fact of the form City(c; r),
there must be a fact Earthquake(c; y) where y is drawn from the Flip (Bernoulli)
distribution with the parameter 0:01. The fourth rule states that a burglary
happens in a unit (house or business) with probability r, where r is a number that
represents the rate of burglaries in the city of the unit (note that we represent by
Burglary(x; c; 1) and Burglary(x; c; 0) the fact that a Burglary did, respectively,
did not happen at unit x in city c; likewise for Earthquake and Trig). Finally,
c1 is a constraint stating that Alarm and ObservedAlarm have the same tuples.</p>
        <p>
          We now address the semantics of a program. What does it mean for a rule
head like Earthquake(c; Flip[0:01]) to be satis ed ? What if this fact is derived
by multiple, or even equivalent, rules? Do we need to sample more than once?
The probabilistic semantics of the above PPDL program is established via an
extension to Datalog, named Datalog9, where rule heads can have existential
quanti ers. Datalog9 rules (a.k.a. existential rules, which are syntactically
isomorphic to tuple-generating dependencies), have been used extensively in many
areas, including data exchange [
          <xref ref-type="bibr" rid="ref5">5</xref>
          ] and ontological reasoning [
          <xref ref-type="bibr" rid="ref2 ref9">2, 9</xref>
          ]. Our PPDL
1. Earthquake(c; Flip[0:01]) City(c; r)
2. Unit(h; c) Home(h; c)
3. Unit(b; c) Business(b; c)
4. Burglary(x; c; Flip[r]) Unit(x; c) ; City(c; r)
5. Trig(x; Flip[0:6]) Unit(x; c) ; Earthquake(c; 1)
6. Trig(x; Flip[0:9]) Burglary(x; c; 1)
7. Alarm(x) Trig(x; 1)
c1. Alarm(x) $ ObservedAlarm(x)
1. 9y EarthquakeF2lip(c; y; 0:01)
2. Unit(h; c) Home(h; c)
3. Unit(b; c) Business(b; c)
4. 9y BurglaryF3lip(x; c; y; r)
5. 9y TrigF2lip(x; y; 0:6)
6. 9y TrigF2lip(x; y; 0:9)
        </p>
      </sec>
      <sec id="sec-2-4">
        <title>Unit(x; c) ; City(c; r)</title>
        <p>Unit(x; c) ; Earthquake(c; 1)</p>
        <p>Burglary(x; c; 1)
7. Alarm(x) Trig(x; 1)
8. Earthquake(c; d) EarthquakeF2lip(c; d; p)
9. Burglary(x; c; b) BurglaryF3lip(x; c; b; p)
10. Trig(x; y) TrigF2lip(x; y; p)
program P gives rise to the Datalog9 program Pb in Figure 3. Note that this
program does not take into account the constraints. To illustrate the
translation, note how rule 6 in P becomes rule 6 in Pb. A special, distributional relation
symbol Trig2Flip is created for Trig that captures the intention of the rule:
whenever the premise holds (there is a Burglary at a unit x), then there exists a fact
Trig2Flip(x; y; 0:9) where y is drawn from a Bernoulli distribution with parameter
0:9. Rule 10 is implicitly added to update Trig with the content of Trig2Flip, where
the additional parameter (i.e., the above 0.9) is projected out.</p>
        <p>
          In the absence of constraints, a possible outcome of an input database
instance I (a \possible world") is a minimal super-instance of I that satis es
the rules of the program. One possible outcome of the input instance in
Figure 1 with respect to the rules of P is the database instance formed by the
input instance and the relations in Figure 4. Each tuple of a distributional
relation has a weight, which is the probability of the random choice made for that
fact. For presentation's sake, the sampled values are under the attribute name
draw . Ignoring the constraints (c1 in the example), the probability of this
outcome is the product of all of the numbers in the columns titled \w(f )," that is,
0:01 0:99 0:03 0:4. Note that this multiplication is an instance of the
chain rule Pr(A1 ^ ^ An) = Pr(A1) Pr(A2jA1) : : : , and does not re ect an
assumption of independence among the involved draws. One needs to show that
this formula gives a proper probability space (i.e., the probabilities of all possible
worlds sum up to 1). We do so via an adaptation of the chase procedure [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ].
        </p>
        <p>Constraints, such as c1 in our example, do not trigger generation of tuples,
but rather have the semantics of conditional probability: violating possible worlds
(where Alarm is di erent from ObservedAlarm) are eliminated, and the
probability is normalized across the remaining worlds. Hence, we unify the concept of
observations in Bayesian statistics with that of integrity constraints in databases.</p>
        <p>In summary, a PPDL program associates to every given input instance a
probability distribution over possible outcomes. One can then, for example, ask for
the marginal probability of an event such as Burglary(NP1). Standard techniques
city
Napa
Yucaipa</p>
        <p>EarthquakeF2lip
draw param w(f )
1 0:01 0:01
0 0:01 0:99</p>
      </sec>
      <sec id="sec-2-5">
        <title>Earthquake</title>
        <p>city draw
Napa 1
Yucaipa 0</p>
      </sec>
      <sec id="sec-2-6">
        <title>Alarm</title>
        <p>unit
NP1
NP2</p>
      </sec>
      <sec id="sec-2-7">
        <title>Burglary</title>
        <p>unit city
NP1 Napa
NP2 Napa
NP3 Napa
YU1 Yucaipa
from the probabilistic programming literature (analytical, as lifted inference, or
sampling-based, as MCMC) can be used to answer such questions.
3</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Discussion</title>
      <p>
        Currently, PPDL semantics supports only discrete numerical distributions (e.g.,
Poisson). But even then, the space of possible outcomes may be uncountable (as
possible outcomes may be in nite). We have de ned a probability measure over
possible outcomes by applying the known concept of cylinder sets to a
probabilistic chase procedure. We have also shown that the resulting semantics is robust
under di erent chases; moreover, we have identi ed conditions guaranteeing that
all possible outcomes are nite (and then the probability space is discrete) [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ].
The framework has a natural extension to continuous distributions (e.g.,
Gaussian or Pareto), though this requires a nontrivial generalization of our semantics.
Additional future directions include an investigation of semantic aspects of
expressive power, tractability of inference, and a practical implementation (e.g.,
corresponding sampling techniques).
      </p>
      <p>Acknowledgements
We are thankful to Molham Aref, Vince Barany, Todd J. Green and Emir Pasalic
Zografoula Vagena for insightful discussions and feedback on this work. We
are grateful to Kathleen Fisher and Suresh Jagannathan for including us in
DARPA's PPAML initiative; this work came from our e orts to design
translations of probabilistic programs into statistical solvers.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>V.</given-names>
            <surname>Barany</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            ten
            <surname>Cate</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Kimelfeld</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Olteanu</surname>
          </string-name>
          , and
          <string-name>
            <given-names>Z.</given-names>
            <surname>Vagena</surname>
          </string-name>
          .
          <article-title>Declarative statistical modeling with Datalog</article-title>
          .
          <source>CoRR, abs/1412.2221</source>
          ,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>A.</given-names>
            <surname>Cal</surname>
          </string-name>
          , G. Gottlob,
          <string-name>
            <given-names>T.</given-names>
            <surname>Lukasiewicz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Marnette</surname>
          </string-name>
          ,
          <article-title>and</article-title>
          <string-name>
            <given-names>A.</given-names>
            <surname>Pieris</surname>
          </string-name>
          . Datalog+/
          <article-title>-: A family of logical knowledge representation and query languages for new applications</article-title>
          .
          <source>In LICS</source>
          , pages
          <volume>228</volume>
          {
          <fpage>242</fpage>
          ,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>D.</given-names>
            <surname>Deutch</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Koch</surname>
          </string-name>
          , and
          <string-name>
            <given-names>T.</given-names>
            <surname>Milo</surname>
          </string-name>
          .
          <article-title>On probabilistic xpoint and Markov chain query languages</article-title>
          .
          <source>In PODS</source>
          , pages
          <volume>215</volume>
          {
          <fpage>226</fpage>
          ,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>P.</given-names>
            <surname>Domingos</surname>
          </string-name>
          and
          <string-name>
            <given-names>D.</given-names>
            <surname>Lowd</surname>
          </string-name>
          .
          <article-title>Markov Logic: An Interface Layer for Arti cial Intelligence</article-title>
          .
          <source>Synthesis Lectures on AI and Machine Learning</source>
          . Morgan &amp; Claypool Publishers,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>R.</given-names>
            <surname>Fagin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P. G.</given-names>
            <surname>Kolaitis</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R. J.</given-names>
            <surname>Miller</surname>
          </string-name>
          , and
          <string-name>
            <given-names>L.</given-names>
            <surname>Popa</surname>
          </string-name>
          .
          <article-title>Data exchange: Semantics and query answering</article-title>
          .
          <source>In ICDT</source>
          , volume
          <volume>2572</volume>
          <source>of LNCS</source>
          , pages
          <volume>207</volume>
          {
          <fpage>224</fpage>
          . Springer,
          <year>2003</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>N. D.</given-names>
            <surname>Goodman</surname>
          </string-name>
          .
          <article-title>The principles and practice of probabilistic programming</article-title>
          .
          <source>In POPL</source>
          , pages
          <volume>399</volume>
          {
          <fpage>402</fpage>
          ,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <given-names>G.</given-names>
            <surname>Gottlob</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Lukasiewicz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Martinez</surname>
          </string-name>
          , and
          <string-name>
            <given-names>G.</given-names>
            <surname>Simari</surname>
          </string-name>
          .
          <article-title>Query answering under probabilistic uncertainty in Datalog+/ ontologies</article-title>
          .
          <source>Annals of Math.&amp; AI</source>
          ,
          <volume>69</volume>
          (
          <issue>1</issue>
          ):
          <volume>37</volume>
          {
          <fpage>72</fpage>
          ,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <given-names>B.</given-names>
            <surname>Kimelfeld</surname>
          </string-name>
          and
          <string-name>
            <given-names>P.</given-names>
            <surname>Senellart</surname>
          </string-name>
          .
          <article-title>Probabilistic XML: models and complexity</article-title>
          .
          <source>In Adv. in Probabl. Databases for Uncertain Information Management</source>
          , volume
          <volume>304</volume>
          <source>of Studies in Fuzziness and Soft Computing</source>
          , pages
          <volume>39</volume>
          {
          <fpage>66</fpage>
          .
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <given-names>M.</given-names>
            <surname>Kr</surname>
          </string-name>
          <article-title>otzsch and</article-title>
          <string-name>
            <given-names>S.</given-names>
            <surname>Rudolph</surname>
          </string-name>
          .
          <article-title>Extending decidable existential rules by joining acyclicity and guardedness</article-title>
          .
          <source>In IJCAI</source>
          , pages
          <volume>963</volume>
          {
          <fpage>968</fpage>
          ,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <given-names>F.</given-names>
            <surname>Niu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Re</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Doan</surname>
          </string-name>
          , and
          <string-name>
            <given-names>J. W.</given-names>
            <surname>Shavlik</surname>
          </string-name>
          .
          <article-title>Tu y: Scaling up statistical inference in Markov Logic Networks using an RDBMS</article-title>
          .
          <source>PVLDB</source>
          ,
          <volume>4</volume>
          (
          <issue>6</issue>
          ):
          <volume>373</volume>
          {
          <fpage>384</fpage>
          ,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <given-names>D.</given-names>
            <surname>Suciu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Olteanu</surname>
          </string-name>
          , C. Re, and
          <string-name>
            <given-names>C.</given-names>
            <surname>Koch</surname>
          </string-name>
          . Probabilistic Databases.
          <source>Synthesis Lectures on Data Management</source>
          . Morgan &amp; Claypool Publishers,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>