Possible Models Computation and Revision – A Practical Approach Peter Baumgartner Data61 | CSIRO The Australian National University
Situational Awareness ≈ comprehending system state as it evolves over time Factory Floor Are the operations carried out according to the schedule? Food Supply Chain Are goods delivered within 3 hours and stored below 25 ℃ ? Why is the truck late? What is the expected quality (shelf life) of the goods? Data Cleansing Does the database have complete, correct and relevant data? What is the difficulty? • Events happened ≠ events reported (errors, incomplete, late …) Belief revision • Need an integrated domain model with dependencies Logic program • Can only hope for multiple plausible explanations Models This talk: our approach to computing situational awareness 2
Events happened ≠ events reported Next: “Fixing the event stream” as computed by our implementation Reported logic program Load( 10, tomatoes, pallet) expressing this Load( 20, pallet, container) ? Load( 40, container, ship) Happened Fixed Unload(60, apples, pallet) Load( 10, apples , pallet) Load( 20, pallet, container) Load( 40, container, ship) Happened Unload(45, container, ship) Load( 10, tomatoes, pallet) Unload(50, pallet, container) Unload(60, apples, pallet) Load( 20, pallet, container) Happened Load( 40, container, ship) Load( 10, tomatoes, pallet) Fixed Fixed Load( 10, apples , pallet) Unload(45, container, ship) Load( 20, pallet, container) Load( 40, container, ship) Unload(50, pallet, container) Unload(45, container, ship) Unload(50, pallet, container) Unload(60, tomatoes , pallet) Unload(60, apples, pallet) 3
Logic Program for the Supply Chain Example Derived “ In ” relation Integrity constraints and revision // No Unload without earlier Load In(time, obj, cont) :- fail :- Load(time, obj, cont) Unload(time, obj, cont), not (Load(t, obj, cont), t < time)) // In transitivity “fail” heads for fixing In(time, obj, cont) :- the event stream // Unload a different object In(time, obj, c), fail (- Unload(time, obj, cont), In(time, c, cont) + Unload(time, o, cont)) :- Unload(time, obj, cont), not (Load(t, obj, cont), t < time), // Frame axiom for In In(next, obj, cont) :- Load(t, o, cont), In(time, obj, cont), t < time, Step(next, time), SameBatch(t, b), not Unload(next, obj, cont), ((b contains obj) && (b contains o)) not (In(time, obj, c), Unload(next, c, cont)) Default negation + 4 more rules 4
The Rest of This Talk Graph “Possible Models Computation and Revision -“ “A Practical Approach” Situational awareness Calculus Proof Procedure as (no surprises) Stratified model computation embedded expressed disrupted into through by Scala (two-way coupling) Logic programs Belief revision (specific ones) (rather simple) provides Method Semantics 5
Situational Awareness = Stratified Model Computation “Not known now” -> “never known” “Situational awareness” task is naturally stratified Makes default negation possible • Comprehend evolving situation from “past” and “now”, not “future” (*) → Stratification by time 0,1,2,…,now • Distinguish between events and states induced from these events → Stratification by sets of literals EDB / IDB (extensional database / intensional database) Revising events is simply addition/removal Stratified model computation (ignoring revision) Time 0,1,2 EDBs E 0,1,2,… E 0 E 1 E 2 Bottom-up application of logic program (*) Cannot change past state rules until fixpoint I 0 I 1 I 2 IDBs I 0,1,2,… Next: Stratified logic programs for computing models (E ∪ I) 0 , (E ∪ I) 1 , (E ∪ I) 2 , … 6
Stratified Logic Programs Consists of rules over literals head :- body , …, not body , … Range restriction s. th. (1) var (head) ⊆ fvar (body , …, not body , … ) ↝ Simple model computation (2) head has a time variable (“ now”) Stratification by time (3) one body lit has same time variable ↝ Effective model computation (4) other body lits have time ≤ time (5) EDB lits in not body have time ≤ time Avoids guessing whether head is true or false in final model (6) IDB lits in not body have time < time ↝ Efficient model computation Examples Closed world assumption I(time, x) :- J(time, x, y), I(time, y) E ∪ I ⊨ not body[x] iff I(time, x) :- J(time, x, y), I(t, y), t ≤ time not exists a s.th. body[a] ⊆ E ∪ I I(time, x) :- J(time, x, y), not (I(t, y), t < time) I(time, x) :- J(time, x, y), not (I(t, y), t ≤ time) No! I,J : IDB E : EDB I(time, x) :- J(time, x, y), not (E(t, y), t ≤ time) 7
Integrity Constraints Usual integrity constraints fail :- body , …, not body , … Semantics E ∪ I Generalized for revision of EDB literals fail(- e , …, + f, …) :- body , …, not body , … if E ∪ I ⊨ (body , …, not body , …) σ s. th. • “conditions for body as for ordinary rules” • EDB lits e and f have time ≤ time ( E \ e σ ) ∪ f σ Example … - // Unload a different object Unload(60, apples, pallet) fail (- Unload(time, obj, cont), + Unload(time, o, cont)) :- Unload(time, obj, cont), not (Load(t, obj, cont), t < time), … Load(t, o, cont), t < time, + Unload(60, tomatoes , pallet) … 8
Semantics of Programs With Fail Rules ⇢ init ⇢ 1 ⇢ 2 . . . Principles � 0 - Fail as early as possibly 1 - Collect all possible fails � 0 � 1 � 1 � 0 � 1 4 0 fail ( Æ fail () fail () 2 fail () 2 ) 0 0 1 2 4 0 4 1 fail ( Æ 0 ) fail ( Æ 0 ) Operational for a given EDB E Can branch out because of disjunctive heads for time t = 0,1,2, …, now compute { I 0 , I 1 , … all IDBs for time ≤ t } for I = I 0 , I 1 , … let F = { fail(…) heads derivable from E ∪ I } if F is non-empty then Declarative: see paper obtain new EDBs E 1 , E 2 , … as per F and abandon model candidate I 9
The Rest of This Talk Graph “Possible Models Computation and Revision -“ “A Practical Approach” Situational awareness Calculus Proof Procedure as We are here (no surprises) Stratified model computation embedded expressed disrupted into through by Scala (two-way coupling) Logic programs Belief revision (specific ones) (rather simple) provides Method Semantics 10
Embedding Into Scala: Translation Logic Scala Pred/Fun signature Class Input program ≈ Scala source code Interpretation Set of class instances Variable Variable Rule Partial function Matching subst Pattern matching type Time = Int case class Load(time: Time, obj: String, cont: String) extends Atom case class In(time: Time, obj: String, cont: String) extends Atom Macro annotation @rules val rules = List( In(time, obj, cont) : − (In(time, obj, c), In(time, c, cont) ) Macro expansion case List(In(time, obj, c), In(time0, c1, cont)) into partial if c == c1 && time == time0 => In(time, obj, cont) function + given-clause loop operating on such rules-as-partial-functions (In reality the macro expansion is more complicated because of default negation) 11
Embedding into Scala: Method “Natural” integration into Scala and vice versa val eventsCSV = List(“Load,10,tomatoes,pallet",“Load,20,pallet,container", …) // Compute alternative “fixes” and extract their Load/Unload events a CSV again eventsCSV map { line => line.split(",") match { case Array("Load", time, obj, cont) => Load(time.toInt, obj, cont) … } } saturate { @rules … fail (…) :— … (b ∋ obj) && (b ∋ o), def sameBatch( time : Time) = where { val b = sameBatch(t) } if ( time == 10) Set( "tomatoes" , "apples" ) else Set. ∅ [String] } map { I => I.toList.sortBy(_.time) flatMap { case Load(time, obj, cont) => List(s"Load,$time,$obj,$cont") … } } List(Load,10,tomatoes,pallet, Load,20,pallet,container, Load,40,container,ship, Unload,45,container,ship, Unload,50,pallet,container, Unload,60,tomatoes,pallet) List(Load,10,tomatoes,pallet, Load,10,apples,pallet, Load,20,pallet,container, Load,40,container,ship, Unload,45,container,ship, Unload,50,pallet,container, Unload,60,apples,pallet) List(Load,10,apples,pallet, Load,20,pallet,container, Load,40,container,ship, Unload,45,container,ship, Unload,50,pallet,container, Unload,60,apples,pallet) 12
Conclusions Talk Summary “Situational awareness = time-stratified logic programming + belief revision” Practical? (a) Scala embedding (b) structured data (c) controllable complexity In the Paper Disjunctive heads, possible model semantics: Hungry(t) ∨ Thirsty(t) :- GetUp(t) Partial correctness: soundness and model completeness theorem Current and Future Work Generalize two-layer EDB/IDB stratification to arbitrary many levels [implemented] Classical negation [implemented] Proper belief revision Timed LTL constraints □ t . 𝗍𝗂𝗃𝗊𝗊𝖿𝖾 ( B ) → ◊ s . s ≤ t + 5 ∧ 𝗌𝖿𝖽𝖿𝗃𝗐𝖿𝖾 ( B ) Probabilistic EDBs a la ProbLog Load(10, “tomatoes”, “pallet”) : 0.3 Get the implementation at https://bitbucket.csiro.au/users/bau050/repos/fusemate/ 13
Recommend
More recommend