Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 1 University of Texas at Dallas L. Simon, A. Bansal, Co-Logic Programming: Extending Logic Programming with Coinduction by Luke Simon, Ajay Bansal, Ajay Mallya, Gopal Gupta. Presented by Richard Min. ICALP 2007 (Wroclaw, Poland) Advanced Logic Programming-Languages and Systems (ALPS) Lab The University of Texas at Dallas, Richardson, Texas, USA
37
Embed
Co-Logic Programming: Extending Logic Programming with Coinduction
Co-Logic Programming: Extending Logic Programming with Coinduction. by Luke Simon, Ajay Bansal, Ajay Mallya, Gopal Gupta. Presented by Richard Min. ICALP 2007 (Wroclaw, Poland) Advanced Logic Programming-Languages and Systems (ALPS) Lab - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 1
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
Co-Logic Programming: Extending Logic Programming
with Coinductionby
Luke Simon, Ajay Bansal, Ajay Mallya, Gopal Gupta.Presented by Richard Min.
ICALP 2007 (Wroclaw, Poland)
Advanced Logic Programming-Languages and Systems (ALPS) Lab
The University of Texas at Dallas, Richardson, Texas, USA
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 2
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
Induction and Coinduction• Induction is a mathematical technique for
finitely reasoning about an infinite number of things.– If there were only finitely many different things, than
induction would not be needed.– Naturals: 0, 1, 2, …– The naïve “proof”
• 3 components of inductive definition: (1) Initiality, (2) iteration, (3) minimality– for example, for example, for a list:
[ ] – an empty list is a list (initiality) [ H | T ] is a list if T is a list and H is a list (iteration)nothing else is a list (minimality)
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 3
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
Induction and Coinduction
• Coinduction is a mathematical technique for finitely reasoning about infinite things.– Mathematical dual of induction– If all things were finite, then coinduction would not
be needed.– Perpetual programs, – Infinite strings: networks, model checking
• 2 components of coinductive definition: (1) iteration, (2) maximality– for example, for a list
[ H | T ] is a list if T is a list and H is a list (iteration).Maximal set that satisfies the specification of a list.
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 4
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
Mathematical Foundations
• Duality provides a source of new mathematical tools that reflect the sophistication of tried and true techniques.
Definition Proof Mapping
Least fixed point Induction Recursion
Greatest fixed point Coinduction Corecursion
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 5
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
Example: Natural Numbers
(S) = { 0 } { succ(x) | x S }
• N =
– where is least fixed-point.
• aka “inductive definition”– Let N be the smallest set such that
• 0 N• x N implies x + 1 N
• Induction corresponds to LFP interpretation.
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 6
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
bit(0).bit(1).bitstream( [ H | T ] ) :- bit( H ), bitstream( T ).|?- X = [ 0, 1, 1, 0 | X ], bitstream( X ).
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 10
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
Thesis
• Logic Programming with its mathematical dual.– traditional logic programming– co-logic programming
• Duality can be exploited – traditional inductive logic programming – dual of it (= coinductive logic programming)– combining both using a stratification technique
• To Extend logic programming with – coinduction, corecursion (e.g., bitstream)– infinite data structure (e.g., infinite lists)– ability to reason about infinite objects or infinite
properties
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 11
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
Overview of Coinductive LP
• Programming Language= Syntax + Semantics
• Coinductive Logic Program is a definite program with maximal co-Herbrand model declarative semantics.
• Declarative Semantics– across the board dual, greatest fixed-points– terms: co-Herbrand universe Uco(P)– atoms: co-Herbrand base Bco(P)– program semantics: maximal co-Herbrand model
Mco(P).
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 12
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
Coinductive LP: An Example• Let P1 be the following coinductive program.
:- coinductive from/2.from( N, [ N | T ] ) :- from( s(N), T ).|?- from( 0, _ ).
• co-Herbrand Universe: Uco(P1) = N L where
N=[0, s(0), s(s(0)), ... ], ={ s(s(s( . . . ) ) ) }, and L is the the set of all finite and infinite lists of elements in N, and L.
• from(0, [0, s(0), s(s(0)), ... ]) Mco(P1) implies the query be “yes”
• Without “coinductive” declaration of from, Mco(P1’)=
This corresponds traditional semantics of LP with infinite trees.
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 13
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
Operational Semantics: co-SLD
• nondeterministic state transition system• states are pairs of
– a finite tree of syntactic atoms (as in Prolog)– a system of syntactic term equations in x = f (x).
• For a program p :- p. => a query |?- p. to succeed.• p( [ 1 | T ] ) :- p( T ). => |?- p(X) to succeed with X= [ 1
| X ].
• transition rules– “coinductive hypothesis rule”
• if coinductive Q is called, check whether to unify with Q called earlier (e.g., P :- Q)
if so, then Q succeeds.
– definite clause rule
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 14
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
Correctness
• Theorem (soundness). If atom A has a successful co-SLD derivation in program P, then E(A) is true in program P, where E is the resulting variable bindings for the derivation.
• Theorem (completeness). If A Mco(P) has a rational idealized proof, then A has a successful co-SLD derivation in program P.
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 15
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
generate_infinite_list(I),sieve(I,L),comember(X,L).sieve([H|T],[H,R]) :- filter(H,T,F),sieve(F,R).filter(H,[ ],[ ]).filter(H,[K | T],[K | T1]):- R is K mod H,
R>0,filter(H,T,T1).filter(H,[K | T],T1) :- 0 is K mod H, filter(H,T,T1).:-coinductive int/2int(X,[X | Y]) :- X1 is X+1, int(X1,Y).generate_infinite_list(I) :- int(2,I).
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 20
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
Co-Logic Programming
• combines both halves of logic programming:– traditional logic programming– coinductive logic programming
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 21
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
Syntax of Co-Logic Programs• syntactically identical to traditional logic
programming, except • predicates are labeled:
– inductive – coinductive
• and stratification restriction enforced where:– inductive and coinductive predicates cannot be
mutually recursive.p :- q.
q :- p.if p coinductive & q inductive, then this is not
allowed
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 22
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
Semantics of Co-Logic Programs
• declarative semantics– recursive alternating fixed-point – well-defined due to stratification restriction
• for example. p :- q. q :- p.
• operational semantics– alternating SLD and co-SLD– low additional overhead– easy to implement
• Implementation on top of YAP Prolog is available.
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 23
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
Application: Model Checking• automated verification of hardware and
software systems -automata
– accept infinite strings– accepting state must be traversed infinitely
often
• requires computation of lfp and gfp• easily accomplished in co-logic
programming• traditional LP works for safety property
(that is base on lfp) but not for liveness in an elegant manner.
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 24
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
Automatically Check Properties
• kinds of properties: safety and liveness
• search for counter-example
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 25
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
Safety versus Liveness
• Safety– “nothing bad will happen”– naturally described inductively– straightforward encoding into traditional LP
• liveness– “something good will happen”– dual of safety– naturally described coinductively– straightforward encoding into coinductive LP
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 26
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
automata([ ],St) :- final(St).trans(s0,a,s1). trans(s1,b,s2). trans(s2,c,s3). trans(s3,d,s0). trans(s2,3,s0). final(s2).?- automata(X,s0). X=[ a, b, c, d | X ]; X=[ a, b, e | X ];
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 27
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
Counter
sm1(N,[sm1|T]) :- N1 is N+1 mod 4, s0(N1,T), N1>=0.s0(N,[s0|T]) :- N1 is N+1 mod 4, s1(N1,T), N1>=0.s1(N,[s1|T]) :- N1 is N+1 mod 4, s2(N1,T), N1>=0.s2(N,[s2|T]) :- N1 is N+1 mod 4, s3(N1,T), N1>=0.s3(N,[s3|T]) :- N1 is N+1 mod 4, s0(N1,T), N1>=0.?- sm1(-1,X),comember(sm1,X). No. (because sm1 does not occur in X infinitely
often).
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 28
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.Verification of Real Time Systems
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 33
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
Verification of Real-Time Systems “Train, Controller, Gate”
driver(S0,S1,S2, T,T0,T1,T2, [ X | Rest ], [ (X,T) | R ]) :-train(S0,X,S00,T,T0,T00), contr(S1,X,S10,T,T1,T10),gate(S2,X,S20,T,T2,T20), {TA > T}, driver(S00,S10,S20,TA,T00,T10,T20,Rest,R).
|?- driver(s0,s0,s0,T,Ta,Tb,Tc,X,R). R=[(approach,A), (lower,B), (down,C), (in,D), (out,E), (exit,F), (raise,G), (up,H) | R ], X=[approach, lower, down, in, out, exit, raise, up | X] ; R=[(approach,A),(lower,B),(down,C),(in,D),(out,E),(exit,F),
(raise,G), (approach,H),(up,I)|R], X=[approach,lower,down,in,out,exit,raise,approach,up | X] ; % where A, B, C, ... H, I are the corresponding wall clock time of events
generated.
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 34
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
Other Applications
• goal-directed execution of ASP• reasoning about web services with
USDL– service subsumption = type subsumption
• lazy logic programming and concurrent logic programming
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 35
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
Related Work
• rational trees• declarative semantics for infinite SLD
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 36
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
Conclusion
• via duality, main contributions:– dual of traditional logic programming– operational semantics for coinduction– combining both halves of logic
programming
• main result: co-logic programming• applications to verification, planning,
and web services
Advanced Logic Programming-Languages and Systems (ALPS) Lab @ UTD Slide- 37
University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta.
Related Publications1. Luke Simon, Ajay Mallya, Ajay Bansal, and
Gopal Gupta. Coinductive logic programming. In Proceedings of the International Conference on Logic Programming. Lecture Notes in Computer Science. Springer, 2006.
2. Luke Simon, Ajay Mallya, Ajay Bansal, and Gopal Gupta. Co-Logic programming: Extending logic programming with coinduction. In Proceedings of the International Workshop on Software Verification and Validation, 2006.
3. Gopal Gupta, Ajay Bansal, Richard Min, Luke Simon, Ajay Mallya, Coinductive logic programming and its applications. (tutorial paper). In ICLP’07, 2007.