Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 1 University of Texas at Dallas Coinductive Logic Programming and its Applications.

Slides:



Advertisements
Similar presentations
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Advertisements

C O - INDUCTIVE LOGIC PROGRAMMING AND ITS APPLICATIONS.
Computer Science CPSC 322 Lecture 25 Top Down Proof Procedure (Ch 5.2.2)
SLD-resolution Introduction Most general unifiers SLD-resolution
Chapter Three: Closure Properties for Regular Languages
Logic Programming Automated Reasoning in practice.
Automatic Verification Book: Chapter 6. What is verification? Traditionally, verification means proof of correctness automatic: model checking deductive:
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
1 Introduction to Prolog References: – – Bratko, I., Prolog Programming.
1 PROPERTIES OF A TYPE ABSTRACT INTERPRETATER. 2 MOTIVATION OF THE EXPERIMENT § a well understood case l type inference in functional programming à la.
Advanced Logic Programming-Languages and Systems (ALPS) UTD Slide- 1 University of Texas at Dallas Neda Saeedloei, Gopal Gupta Verifying Complex.
© M. Winter COSC 4P41 – Functional Programming Testing vs Proving Testing –uses a set of “typical” examples, –symbolic testing, –may find errors,
Answer Set Programming Overview Dr. Rogelio Dávila Pérez Profesor-Investigador División de Posgrado Universidad Autónoma de Guadalajara
CPSC 422, Lecture 21Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21 Mar, 4, 2015 Slide credit: some slides adapted from Stuart.
Copyright © Cengage Learning. All rights reserved.
Background information Formal verification methods based on theorem proving techniques and model­checking –to prove the absence of errors (in the formal.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
Introduction to Computability Theory
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Specification Formalisms Book: Chapter 5. Properties of formalisms Formal. Unique interpretation. Intuitive. Simple to understand (visual). Succinct.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
1 Program Analysis Mooly Sagiv Tel Aviv University Textbook: Principles of Program Analysis.
¹ -Calculus Based on: “Model Checking”, E. Clarke and O. Grumberg (ch. 6, 7) “Symbolic Model Checking: 10^20 States and Beyond”, Burch, Clark, et al “Introduction.
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
Artificial Intelligence Chapter 17 Knowledge-Based Systems Biointelligence Lab School of Computer Sci. & Eng. Seoul National University.
Recursion Chapter 7. Chapter 7: Recursion2 Chapter Objectives To understand how to think recursively To learn how to trace a recursive method To learn.
Recursion Chapter 7. Chapter 7: Recursion2 Chapter Objectives To understand how to think recursively To learn how to trace a recursive method To learn.
Programming Language Semantics Denotational Semantics Chapter 5 Part III Based on a lecture by Martin Abadi.
Program Analysis Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Towers of Hanoi. Introduction This problem is discussed in many maths texts, And in computer science an AI as an illustration of recursion and problem.
Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 1 University of Texas at Dallas Logic, Infinite Computation, and Coinduction Gopal.
 Let A and B be any sets A binary relation R from A to B is a subset of AxB Given an ordered pair (x, y), x is related to y by R iff (x, y) is in R. This.
Empirical Explorations with The Logical Theory Machine: A Case Study in Heuristics by Allen Newell, J. C. Shaw, & H. A. Simon by Allen Newell, J. C. Shaw,
Recursion Chapter 7. Chapter Objectives  To understand how to think recursively  To learn how to trace a recursive method  To learn how to write recursive.
MATH 224 – Discrete Mathematics
Advanced Logic Programming-Languages and Systems (ALPS) UTD Slide- 1 University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta. Predicate.
Advanced Logic Programming-Languages and Systems (ALPS) UTD Slide- 1 University of Texas at Dallas L. Simon, A. Bansal, A. Mallya, G. Gupta. Co-Logic.
1 Inference Rules and Proofs (Z); Program Specification and Verification Inference Rules and Proofs (Z); Program Specification and Verification.
Chapter 13 Recursion. Learning Objectives Recursive void Functions – Tracing recursive calls – Infinite recursion, overflows Recursive Functions that.
Advanced Topics in Propositional Logic Chapter 17 Language, Proof and Logic.
Slide 1 Propositional Definite Clause Logic: Syntax, Semantics and Bottom-up Proofs Jim Little UBC CS 322 – CSP October 20, 2014.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
Teaching LP: A Perspective Gopal Gupta Department of Computer Science University of Texas at Dallas.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Ch. 13 Ch. 131 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes?) Dr. Carter Tiernan.
Lecture 5 1 CSP tools for verification of Sec Prot Overview of the lecture The Casper interface Refinement checking and FDR Model checking Theorem proving.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 1 University of Texas at Dallas Modal Logic Gopal Gupta Department of Computer.
From Hoare Logic to Matching Logic Reachability Grigore Rosu and Andrei Stefanescu University of Illinois, USA.
Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 1 University of Texas at Dallas Coinductive Logic Programming and its Applications.
CPSC 422, Lecture 21Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21 Oct, 30, 2015 Slide credit: some slides adapted from Stuart.
Problem Reduction So far we have considered search strategies for OR graph. In OR graph, several arcs indicate a variety of ways in which the original.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
© Janice Regan, CMPT 128, February CMPT 128: Introduction to Computing Science for Engineering Students Recursion.
1 Reasoning with Infinite stable models Piero A. Bonatti presented by Axel Polleres (IJCAI 2001,
Formal Verification. Background Information Formal verification methods based on theorem proving techniques and model­checking –To prove the absence of.
Program Correctness. The designer of a distributed system has the responsibility of certifying the correctness of the system before users start using.
07/10/04 AIPP Lecture 5: List Processing1 List Processing Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 5 07/10/04.
Advanced Logic Programming-Languages and Systems (ALPS) UTD Slide- 1 University of Texas at Dallas L. Simon, A. Mallya, A. Bansal, G. Gupta. Extending.
Logic Programming Lecture 2: Unification and proof search.
Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 1 University of Texas at Dallas Coinductive Logic Programming and its Applications.
Goal-directed Execution of Answer Set Programs
Recursion Topic 5.
Logic, Infinite Computation, and Coinduction
Programming Languages 2nd edition Tucker and Noonan
Computer Security: Art and Science, 2nd Edition
Translating Linear Temporal Logic into Büchi Automata
Programming Languages 2nd edition Tucker and Noonan
Presentation transcript:

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 1 University of Texas at Dallas Coinductive Logic Programming and its Applications Gopal Gupta Luke Simon, Ajay Bansal, Ajay Mallya, Richard Min. Applied Logic, Programming-Languages and Systems (ALPS) Lab The University of Texas at Dallas, Richardson, Texas, USA

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 2 University of Texas at Dallas UT Dallas Computer Science Located in North Dallas in the middle of Telecom Corridor, home of more than 600 high tech companies (TI, Alcatel, EDS) 45 T/T faculty members; 10 instructors 900 UGs, 450 M.S. students, 150 Ph.D. 5 Major research areas: AI, Systems, Theory, S/W Engg, Networks Excess of $4 Million research funding Ranked 24 th in recent CACM research ranking Undergraduate students: encouraged to apply

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 3 University of Texas at Dallas Circular Phenomena in Comp. Sci. Circularity has dogged Mathematics and Computer Science ever since Set Theory was first developed: –The well known Russell’s Paradox: R = { x | x is a set that does not contain itself} Is R contained in R? Yes and No –Liar Paradox: I am a liar –Hypergame paradox (Zwicker & Smullyan) All these paradoxes involve self-reference through some type of negation Russell put the blame squarely on circularity and sought to ban it from scientific discourse: ``Whatever involves all of the collection must not be one of the collection”-- Russell 1908

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 4 University of Texas at Dallas Circularity in Computer Science Following Russell’s lead, Tarski proposed to ban self- referential sentences in a language Rather, have a hierarchy of languages All this changed with Kripke’s paper in 1975 who showed that circular phenomenon are far more common and circularity can’t simply be banned. Circularity has been banned from automated theorem proving and logic programming through the occurs check rule: An unbound variable cannot be unified with a term containing that variable What if we allowed such unification to proceed (as LP systems always did for efficiency reasons)?

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 5 University of Texas at Dallas Circularity in Computer Science If occurs check is removed, we’ll generate circular (infinite) structures: –X = [1,2,3 | X] Such structures, of course, arise in computing (circular linked lists), but banned in logic/LP. Subsequent LP systems did allow for such circular structures (rational terms), but they only exist as data-structures, there is no proof theory to go along with it. –One can hold the data-structure in memory within an LP execution, but one can’t reason about it.

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 6 University of Texas at Dallas Circularity in Everyday Life Circularity arises in every day life –Most natural phenomenon are cyclical Cyclical movement of the earth, moon, etc. Our digestive system works in cycles –Social interactions are cyclical: Conversation = (1 st speaker, (2 nd Speaker, Conversation) Shared conventions are cyclical concepts Numerous other examples can be found elsewhere (Barwise & Moss 1996)

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 7 University of Texas at Dallas Circularity in Computer Science Circular phenomenon are quite common in Computer Science: –Circular linked lists –Graphs (with cycles) –Controllers (run forever) –Bisimilarity –Interactive systems –Automata over infinite strings/Kripke structures –Perpetual processes Logic/LP not equipped to model circularity

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 8 University of Texas at Dallas Coinduction Circular structures are infinite structures Proofs about their properties are infinite-sized Coinduction is the technique for proving these properties –first proposed by Peter Aczel in the 80s Systematic presentation of coinduction & its application to computing, math. and set theory: “Vicious Circles” by Moss and Barwise (1996) Our focus: inclusion of coinductive reasoning techniques into LP and theorem proving

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 9 University of Texas at Dallas Induction vs Coinduction Induction is a mathematical technique for finitely reasoning about an infinite (countable) no. of things. Examples of inductive structures: –Naturals: 0, 1, 2, … –Lists: [ ], [X], [X, X], [X, X, X], … 3 components of an inductive definition: (1) Initiality, (2) iteration, (3) minimality –for example, the set of lists is specified as follows: [ ] – 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)

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 10 University of Texas at Dallas Induction vs 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, automata over infinite strings 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. –This coinductive interpretation specifies all infinite sized lists

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 11 University of Texas at Dallas 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 Least Fix Point (LFP) interpretation.

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 12 University of Texas at Dallas Example: Natural Numbers and Infinity   (S) = { 0 }  { succ(x) | x  S }   unambiguously defines another set N’ =   = N  {  } –  = succ( succ( succ(... ) ) ) = succ(  ) =  + 1 –where   is a greatest fixed-point Coinduction corresponds to Greatest Fixed Point (GFP) interpretation.

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 13 University of Texas at Dallas Mathematical Foundations Duality provides a source of new mathematical tools that reflect the sophistication of tried and true techniques. DefinitionProofMapping Least fixed pointInductionRecursion Greatest fixed pointCoinductionCorecursion Co-recursion: recursive def’n without a base case

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 14 University of Texas at Dallas Applications of Coinduction model checking bisimilarity proofs lazy evaluation in FP reasoning with infinite structures perpetual processes cyclic structures operational semantics of “coinductive logic programming” Type inference systems for lazy functional languages

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 15 University of Texas at Dallas Inductive Logic Programming Logic Programming –is actually inductive logic programming. –has inductive definition. –useful for writing programs for reasoning about finite things: - data structures - properties

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 16 University of Texas at Dallas Infinite Objects and Properties Traditional logic programming is unable to reason about infinite objects and/or properties. (The glass is only half-full) Example: perpetual binary streams –traditional logic programming cannot handle bit(0). bit(1). bitstream( [ H | T ] ) :- bit( H ), bitstream( T ). |?- X = [ 0, 1, 1, 0 | X ], bitstream( X ). Goal: Combine traditional LP with coinductive LP

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 17 University of Texas at Dallas Overview of Coinductive LP Coinductive Logic Program is a definite program with maximal co-Herbrand model declarative semantics. Declarative Semantics: across the board dual of traditional LP: –greatest fixed-points –terms: co-Herbrand universe U co (P) –atoms: co-Herbrand base B co (P) –program semantics: maximal co-Herbrand model M co (P).

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 18 University of Texas at Dallas Coinductive LP: An Example Let P 1 be the following coinductive program. :- coinductive from/2. from( N, [ N | T ] ) :- from( s(N), T ). |?- from( 0, _ ). co-Herbrand Universe: U co (P 1 ) = 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. co-Herbrand Model: M co (P 1 )={ from(t, [t, s(t), s(s(t)),... ]) | t  U co (P 1 ) } from(0, [0, s(0), s(s(0)),... ])  M co (P 1 ) implies the query holds Without “coinductive” declaration of from, M co (P 1 ’)=  This corresponds to traditional semantics of LP with infinite trees.

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 19 University of Texas at Dallas 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. => the query |?- p. will succeed. p( [ 1 | T ] ) :- p( T ). => |?- p(X) to succeed with X= [ 1 | X ]. transition rules –“coinductive hypothesis rule” if coinductive goal Q is called, and Q unifies with a call made earlier (e.g., P :- Q) then Q succeeds. –definite clause rule

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 20 University of Texas at Dallas 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  M co (P) has a rational proof, then A has a successful co- SLD derivation in program P.

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 21 University of Texas at Dallas Implementation Search strategy: hypothesis-first, leftmost, depth-first Meta-Interpreter implementation. query(Goal) :- solve([],Goal). solve(Hypothesis, (Goal1,Goal2)) :- solve( Hypothesis, Goal1), solve(Hypothesis,Goal2). solve( _, Atom) :- builtin(Atom), Atom. solve(Hypothesis,Atom):- member(Atom, Hypothesis). solve(Hypothesis,Atom):- notbuiltin(Atom), clause(Atom,Atoms), solve([Atom|Hypothesis],Atoms). real implementation atop YAP Prolog soon available

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 22 University of Texas at Dallas Example: Number Stream :- coinductive stream/1. stream( [ H | T ] ) :- num( H ), stream( T ). num( 0 ). num( s( N ) ) :- num( N ). |?- stream( [ 0, s( 0 ), s( s ( 0 ) ) | T ] ). 1.MEMO: stream( [ 0, s( 0 ), s( s ( 0 ) ) | T ] ) 2.MEMO: stream( [ s( 0 ), s( s ( 0 ) ) | T ] ) 3.MEMO: stream( [ s( s ( 0 ) ) | T ] ) Answers: T = [ 0, s(0), s(s(0)), s(s(0)) | T ] T = [ 0, s(0), s(s(0)), s(0), s(s(0)) | T ] T = [ 0, s(0), s(s(0)) | T ]... T = [ 0, s(0), s(s(0)) | X ] (where X is any rational list of numbers.)

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 23 University of Texas at Dallas Example: Append :- coinductive append/3. append( [ ], X, X ). append( [ H | T ], Y, [ H | Z ] ) :- append( T, Y, Z ). |?- Y = [ 4, 5, 6, | Y ], append( [ 1, 2, 3], Y, Z). Answer: Z = [ 1, 2, 3 | Y ], Y=[ 4, 5, 6, | Y] |?- X = [ 1, 2, 3, | X ], Y = [ 3, 4 | Y ], append( X, Y, Z). Answer: Z = [ 1, 2, 3 | Z ]. |?- Z = [ 1, 2 | Z ], append( X, Y, Z ). Answer:X = [ ], Y = [ 1, 2 | Z ] ; X = [ 1 ], Y = [ 2 | Z ] ; X = [ 1, 2 ], Y = Z

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 24 University of Texas at Dallas Example: Comember member(H, [ H | T ]). member(H, [ X | T ]) :- member(H, T). drop(H, [ H | T ], T). drop(H, [ X | T ], T1) :- drop(H, T, T1). :- coinductive comember/2. comember(X, L) :- drop(X, L, R), comember(X, R). ?- X=[ 1, 2, 3 | X ], comember(2,X). Answer: yes. ?- X=[ 1, 2, 3, 1, 2, 3], comember(2, X). Answer: no. ?- X=[1, 2, 3 | X], comember(Y, X). Answer: Y = 1; Y = 2; Y = 3;

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 25 University of Texas at Dallas Example: Sieve of Eratosthenes Lazy evaluation can be elegantly incorporated in LP :- coinductive sieve/2, filter/3, comember/2. primes(X) :- 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/2 int(X,[X | Y]) :- X1 is X+1, int(X1,Y). generate_infinite_list(I) :- int(2,I).

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 26 University of Texas at Dallas Co-Logic Programming combines both halves of logic programming: –traditional logic programming –coinductive logic programming syntactically identical to traditional logic programming, except predicates are labeled: –Inductive, or –coinductive and stratification restriction enforced where: –inductive and coinductive predicates cannot be mutually recursive. E.g., p :- q. q :- p. Program rejected, if p coinductive & q inductive

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 27 University of Texas at Dallas Semantics of Co-Logic Programs declarative semantics –recursive alternating fixed-point –well-defined due to stratification restriction for example. p :- q. q :- p. is not allowed. operational semantics –alternating SLD and co-SLD –low additional overhead –easy to implement Implementation on top of YAP Prolog available soon.

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 28 University of Texas at Dallas 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 co-logic programming provides an elegant framework for model checking traditional LP works for safety property (that is based on lfp) in an elegant manner, but not for liveness.

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 29 University of Texas at Dallas Verification of Properties Types of properties: safety and liveness Search for counter-example

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 30 University of Texas at Dallas Safety versus Liveness Safety –“nothing bad will happen” –naturally described inductively –straightforward encoding in traditional LP liveness –“something good will eventually happen” –dual of safety –naturally described coinductively –straightforward encoding in coinductive LP

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 31 University of Texas at Dallas Finite Automata automata([X|T], St):- trans(St, X, NewSt), automata(T, NewSt). 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]; X=[ a, b, e, a, b]; X=[ a, b, e, a, b, e, a, b]; ……

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 32 University of Texas at Dallas Infinite Automata automata([X|T], St):- trans(St, X, NewSt), automata(T, NewSt). 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 ];

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 33 University of Texas at Dallas Verifying Liveness Properties Verifying safety properties in LP is relatively easy: safety modeled by reachability Accomplished via tabled logic programming Verifying liveness is much harder: a counterexample to liveness is an infinite trace Verifying liveness is transformed into a safety check via use of negations in model checking and tabled LP –Considerable overhead incurred Co-LP solves the problem more elegantly: –Infinite traces that serve as counter-examples are easily produced as answers

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 34 University of Texas at Dallas 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).

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 35 University of Texas at Dallas Nested Finite and Infinite Automata :- coinductive state/2. state(s0, [s0,s1 | T]):- enter, work, state(s1,T). state(s1, [s1 | T]):- exit, state(s2,T). state(s2, [s2 | T]):- repeat, state(s0,T). state(s0, [s0 | T]):- error, state(s3,T). state(s3, [s3 | T]):- repeat, state(s0,T). work. enter. repeat. exit. error. work :- work. |?- state(s0,X), absent(s2,X). X=[ s0, s3 | X ]

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 36 University of Texas at Dallas Verification of Real-Time Systems “Train, Controller, Gate”  -automata with time constrained transitions straightforward encoding into CLP(R) + Co-LP

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 37 University of Texas at Dallas Verification of Real-Time Systems “Train, Controller, Gate” :- use_module(library(clpr)). :- coinductive driver/9. train(X, up, X, T1,T2,T2). % up=idle train(s0,approach,s1,T1,T2,T3) :- {T3=T1}. train(s1,in,s2,T1,T2,T3):-{T1-T2>2,T3=T2} train(s2,out,s3,T1,T2,T3). train(s3,exit,s0,T1,T2,T3):-{T3=T2,T1-T2<5}. train(X,lower,X,T1,T2,T2). train(X,down,X,T1,T2,T2). train(X,raise,X,T1,T2,T2).

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 38 University of Texas at Dallas Verification of Real-Time Systems “Train, Controller, Gate” contr(s0,approach,s1,T1,T2,T1). contr(s1,lower,s2,T1,T2,T3):- {T3=T2, T1-T2=1}. contr(s2,exit,s3,T1,T2,T1). contr(s3,raise,s0,T1,T2,T2):-{T1-T2<1}. contr(X,in,X,T1,T2,T2). contr(X,up,X,T1,T2,T2). contr(X,out,X,T1,T2,T2). contr(X,down,X,T1,T2,T2).

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 39 University of Texas at Dallas Verification of Real-Time Systems “Train, Controller, Gate” gate(s0,lower,s1,T1,T2,T3):- {T3=T1}. gate(s1,down,s2,T1,T2,T3):- {T3=T2,T1-T2<1}. gate(s2,raise,s3,T1,T2,T3):- {T3=T1}. gate(s3,up,s0,T1,T2,T3):- {T3=T2,T1-T2>1,T1-T2<2 }. gate(X,approach,X,T1,T2,T2). gate(X,in,X,T1,T2,T2). gate(X,out,X,T1,T2,T2). gate(X,exit,X,T1,T2,T2).

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 40 University of Texas at Dallas Verification of Real-Time Systems :- coinductive driver/9. 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.

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 41 University of Texas at Dallas Other Applications Goal-directed execution of answer set programming Proving bisimilarity –Suppose X = [a, b | X] and Y = [a, b, a, b | Y], X and Y are unifiable Reasoning about web services –service subsumption = type subsumption lazy logic programming concurrent logic programming Type inferences systems in functional languages (coinductive types can be easily handled)

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 42 University of Texas at Dallas Related Work rational trees (Colmerauer) declarative semantics for infinite SLD derivations (Lloyd’s book) coinductive tabling proof method (Jaffar et al) lazy functional logic prog. (Hanus et al)

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 43 University of Texas at Dallas Conclusion Circularity is a common concept in everyday life and computer science: Logic/LP is unable to cope with circularity Solution: introduce coinduction in Logic/LP –dual of traditional logic programming –operational semantics for coinduction –combining both halves of logic programming applications to verification, non monotonic reasoning, negation in LP, and web services Current work: incorporating coinductive reasoning in theorem proving

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 44 University of Texas at Dallas Related Publications 1.Luke Simon, Ajay Mallya, Ajay Bansal, and Gopal Gupta. Coinductive logic programming. In Proceedings of the Int’l Conf. on Logic Programming. (ICLP). Springer LNCS, Luke Simon, Ajay Bansal, Ajay Mallya, and Gopal Gupta. Co-Logic programming: Extending logic programming with coinduction. In Proc. Int’l Conf. on Automata, Lang. and Prog. (ICALP), Gopal Gupta, Ajay Bansal, Richard Min, Luke Simon, Ajay Mallya, Coinductive logic programming and its applications. Proceedings of the Int’l Conf. on Logic Programming. (tutorial paper), 2007.

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 45 University of Texas at Dallas Goal-directed execution of ASP Answer set programming (ASP) is a popular formalism for non monotonic reasoning Applications in real-world reasoning, planning, etc. Semantics given via lfp of a residual program obtained after “Gelfond-Lifschitz” transform Popular implementations: Smodels, DLV, etc. 1.No goal-directed execution strategy available 2.ASP limited to only finitely groundable programs Co-logic programming solves both these problems. Also provides a goal directed method for checking if a proposition is in a model, given a prop. formula

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 46 University of Texas at Dallas Goal-directed ASP No simple method for computing an answer set. Traditional methods: Guess an answer set, and then verify it. Coinductive LP makes a goal-directed execution method possible Need a negative coinductive hypothesis rule: –In the process of establishing not(p), if not(p) is seen again, then it succeeds Need the double negation rule: not(not(p)) = p

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 47 University of Texas at Dallas ASP Consider the following program, A : p :- not q. t. r :- t, s. q :- not p. s. A has 2 answer sets: {p, r, t, s} & {q, r, t, s}. Now suppose we add the following rule to A : h :- p, not h. (falsify p) Only one answer set remains: {q, r, t, s} Gelfond-Lifschitz Method: –Given an answer set S, for each p  S, delete all rules whose body contains “not p”; –delete all goals of the form “not q” in remaining rules –Compute the least fix point, L, of the residual program –If S = L, then S is an answer set

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 48 University of Texas at Dallas Goal-directed ASP Consider the following program, A’: p :- not q. t. r :- t, s. q :- not p, r. s. h :- p, not h. Separate into constraint and non-constraint rules: only 1 constraint rule. Suppose the query is ?- q. Expand as in co- LP: q  not p, r  not not q, r  q, r  r  t, s  s  success. Ans = {q, r, t, s} Next, we need to check that constraint rules will not reject the Answer set generated. –(it doesn’t in this case)

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 49 University of Texas at Dallas Goal-directed ASP Consider the following program, P1: (i) p :- not q. (ii) q:- not r. (iii) r :- not p. (iv) q :- not p. P1 has 1 answer set: {q, r}. Separate into 3 constraints (i, ii, iii) and 2 non-constraint rules (i, iv). p :- not(q). q :- not(r). r :- not(p). q :- not(p). chk_p :- not(p), not(q). chk_q :- not(q), not(r), not(p). chk_r :- not(r), not(p). not_p :- q. not_q :- r, p. not_r :- p. nmr_chk :- not(chk_p), not(chk_q), not(chk_r). Suppose the query is ?- r. Expand as in co-LP: r  not p  not not q  q (  not r  fail, backtrack)  not p  success. Ans={r, q} which satisfies the constraint rules of mnr_chk.

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 50 University of Texas at Dallas Goal-directed ASP Consider the following program, in general: (i) p :- a, not q. (ii) q:- b, not r. (iii) r :- c, not p. (iv) q :- d, not p. Separate into 3 constraint rules (i, ii, iii), and 2 non- constraint rules (i, iv). p :- a, not(q). q :- b, not(r). r :- c, not(p). q :- d, not(p). chk_p :- not(p), a, not(q). chk_q :- not(q), b, not(r). chk_r :- not(r), c, not(p). not_p :- not(a) ; q. not_q :- (not(b) ; r), (not(d) ; p). not_r :- not(c), p. nmr_chk :- not(chk_p), not(chk_q), not(chk_r).

Applied Logic, Programming-Languages and Systems (ALPS) UTD Slide- 51 University of Texas at Dallas Goal-directed ASP In general, for the constraint rules of p as head, which is { p:- B 1. p:- B p:- B n. }, this will generate C-rule(s) of: chk_p 1 :- not(p), B 1. chk_p 2 :- not(p), B chk_p n :- not(p), B n. not_p :- not(B 1 ), not(B 2 ),..., not(B n ). nmr_chk :- not(chk_p 1 ),..., not(chk_p n ). For a special constraint of “false” in its head (or for each headless rule i, for each rule i ) of :- B i, this will generate chk_cnst i :- B i. nmr_chk :- not(chk_const i ),...