Coalgebraic Semantics for Parallel Derivation Strategies in Logic Programming. Ekaterina Komendantskaya, joint work with John Power and Guy McCusker 13th International Conference on Algebraic Methodology and Software Technology AMAST10, 24 June 2010 Katya (AMAST2010) Coalgebraic Semantics for Parallel Derivation Strategies in Logic Programming. AMAST10 1 / 33
Outline Introduction 1 Katya (AMAST2010) Coalgebraic Semantics for Parallel Derivation Strategies in Logic Programming. AMAST10 2 / 33
Outline Introduction 1 Derivations in Logic Programming 2 Katya (AMAST2010) Coalgebraic Semantics for Parallel Derivation Strategies in Logic Programming. AMAST10 2 / 33
Outline Introduction 1 Derivations in Logic Programming 2 The Theory of Observables 3 Katya (AMAST2010) Coalgebraic Semantics for Parallel Derivation Strategies in Logic Programming. AMAST10 2 / 33
Outline Introduction 1 Derivations in Logic Programming 2 The Theory of Observables 3 Conclusions 4 Katya (AMAST2010) Coalgebraic Semantics for Parallel Derivation Strategies in Logic Programming. AMAST10 2 / 33
Logic programs A first-order logic program consists of a finite set of clauses of the form A ← A 1 , . . . , A n where A and the A i ’s are atomic formulae, typically containing free variables; and A 1 , . . . , A n is to mean the conjunction of the A i ’s. Definition Let a goal G be ← A 1 , . . . , A m , . . . , A k and a clause C be A ← B 1 , . . . , B q . Then G ′ is derived from G and C using mgu θ if the following conditions hold: • A m is an atom, called the selected atom, in G . • θ is an mgu of A m and A . • G ′ is the goal ← ( A 1 , . . . , A m − 1 , B 1 , . . . , B q , A m +1 , . . . , A k ) θ . Katya (AMAST2010) Coalgebraic Semantics for Parallel Derivation Strategies in Logic Programming. AMAST10 3 / 33
Example: Goal ← p ( a ). q(b,a) ← s(a,b) ← p ( a ) ← q(b,a) s(a,b) ← ← q ( b , a ) , s ( a , b ) ← p(a) q(b,a) , s(a,b) Katya (AMAST2010) Coalgebraic Semantics for Parallel Derivation Strategies in Logic Programming. AMAST10 4 / 33
Example: Goal ← p ( a ). ← p ( a ) q(b,a) ← s(a,b) ← q(b,a) ← q ( b , a ) , s ( a , b ) s(a,b) ← ← p(a) q(b,a) , s(a,b) ← s ( a , b ) , s ( a , b ) Katya (AMAST2010) Coalgebraic Semantics for Parallel Derivation Strategies in Logic Programming. AMAST10 5 / 33
Example: Goal ← p ( a ). ← p ( a ) ← q(b,a) s(a,b) ← q ( b , a ) , s ( a , b ) ← q(b,a) ← s(a,b) ← s ( a , b ) , s ( a , b ) p(a) ← q(b,a) , s(a,b) ← s ( a , b ) Katya (AMAST2010) Coalgebraic Semantics for Parallel Derivation Strategies in Logic Programming. AMAST10 6 / 33
Example: Goal ← p ( a ). ← p ( a ) ← q ( b , a ) , s ( a , b ) q(b,a) ← s(a,b) ← q(b,a) ← s ( a , b ) , s ( a , b ) s(a,b) ← ← p(a) q(b,a) , s(a,b) ← s ( a , b ) � Katya (AMAST2010) Coalgebraic Semantics for Parallel Derivation Strategies in Logic Programming. AMAST10 7 / 33
� � � � � � � Algebraic and coalgebraic semantics for LP �� �� �� �� �� �� �� �� Algebraic Coalgebraic Least fixed Greatest fixed �� �� �� fibrational �� �� �� �� fibrational �� point of T P point of T P semantics semantics ������� � ������� � ������� � � � � � � � � � � � � Finite Finite and Infinite SLD-derivations SLD-derivations Katya (AMAST2010) Coalgebraic Semantics for Parallel Derivation Strategies in Logic Programming. AMAST10 8 / 33
Coalgebraic Analysis of Logic Programs Generally, given a functor F , an F -coalgebra is a pair ( S , α ) consisting of a set S and a function α : S − → F ( S ). We will take a powerset functor P f . Proposition For any set At , there is a bijection between the set of variable-free logic programs over the set of atoms At and the set of P f P f -coalgebra structures on At . Proof. Given a variable-free logic program P , let At be the set of all atoms appearing in P . Then P can be identified with a P f P f -coalgebra ( At , p ), where p : At − → P f ( P f ( At )) sends an atom A to the set of bodies of those clauses in P with head A , each body being viewed as the set of atoms that appear in it. Katya (AMAST2010) Coalgebraic Semantics for Parallel Derivation Strategies in Logic Programming. AMAST10 9 / 33
Example Example Consider the logic program from the previous Example. ← q(b,a) s(a,b) ← q(b,a) s(a,b) ← ← q(b,a) , s(a,b) p(a) The program has three atoms, namely q(b,a) , s(a,b) and p(a) . So At = { q(b,a) , s(a,b) , p(a) } . And the program can be identified with the P f P f -coalgebra structure on At given by p ( q(b,a) ) = {{} , { s(a,b) }} , where {} is the empty set. p ( s(a,b) ) = {{}} , i.e., the one element set consisting of the empty set. p ( p(a) ) = {{ q(b,a),s(a,b) }} . Katya (AMAST2010) Coalgebraic Semantics for Parallel Derivation Strategies in Logic Programming. AMAST10 10 / 33
� � � � � � � � � Right adjoint Definition Given two categories C and D , the functor U : C → D has a right adjoint if for all A ∈ D there exists GA ∈ C and there exists ǫ A : UGA → A such that for all B ∈ C and for all f : UB → A there exists a unique g : B → GA such that the following diagram commutes: ǫ A UGA A GA � ����������� � � � � � g Ug f � � � � � � � UB B Katya (AMAST2010) Coalgebraic Semantics for Parallel Derivation Strategies in Logic Programming. AMAST10 11 / 33
Coalgebraic Analysis of derivations in Logic Programs Theorem Given an endofunctor H : Set − → Set with a rank, the forgetful functor U : H -Coalg − → Set has a right adjoint R. R is constructed as follows. Given Y ∈ Set , we define a transfinite sequence of objects as follows. Put Y 0 = Y , and Y α +1 = Y × H ( Y α ). We define δ α : Y n +1 − → Y n inductively by Y × H δ α − 1 Y α +1 = Y × HY α − → Y × HY α − 1 = Y α , π 1 with the case of α = 0 given by the map Y 1 = Y × HY − → Y . For a limit ordinal, let Y α = lim β<α ( Y β ), determined by the sequence δ β Y β +1 − → Y β . If H has a rank, there exists α such that Y α is isomorphic to Y × HY α . This Y α forms the cofree coalgebra on Y . Katya (AMAST2010) Coalgebraic Semantics for Parallel Derivation Strategies in Logic Programming. AMAST10 12 / 33
� � Coalgebraic Analysis of derivations in Logic Programs R U: H-Coalg Set Corollary If H has a rank, U has a right adjoint R and putting G = RU, G possesses a canonical comonad structure and there is a coherent isomorphism of categories G -Coalg ∼ = H -Coalg , where G -Coalg is the category of G-coalgebras for the comonad G. Given an H -coalgebra p : Y − → HY , we construct maps p α : Y − → Y α for each ordinal α as follows. The map p 0 : Y − → Y is the identity, and for a successor ordinal, p α +1 = � id , Hp α ◦ p � : Y − → Y × HY α . For limit ordinals, p α is given by the appropriate limit. By definition, the object GY is given by Y α for some α , and the corresponding p α is the required G -coalgebra. Katya (AMAST2010) Coalgebraic Semantics for Parallel Derivation Strategies in Logic Programming. AMAST10 13 / 33
Coalgebraic Analysis of derivations in Logic Programs Taking p : At − → P f P f ( At ), by the proof of Theorem 1, the corresponding C ( P f P f )-coalgebra where C ( P f P f ) is the cofree comonad on P f P f is given as follows: C ( P f P f )( At ) is given by a limit of the form . . . − → At × P f P f ( At × P f P f ( At )) − → At × P f P f ( At ) − → At . This chain has length ω . As above, we inductively define the objects At 0 = At and At n +1 = At × P f P f At n , and the cone p 0 = id : At − → At (= At 0 ) p n +1 = � id , P f P f ( p n ) ◦ p � : At − → At × P f P f At n (= At n +1 ) and the limit determines the required coalgebra p : At − → C ( P f P f )( At ). Katya (AMAST2010) Coalgebraic Semantics for Parallel Derivation Strategies in Logic Programming. AMAST10 14 / 33
Examples of a derivations The action of p : At − → C ( P f P f )( At ) on p(a) ← p ( a ) q ( b , a ) s ( a , b ) s ( a , b ) � � � Katya (AMAST2010) Coalgebraic Semantics for Parallel Derivation Strategies in Logic Programming. AMAST10 15 / 33
Examples of a derivations The action of p : At − → C ( P f P f )( At ) on The SLD derivation from a p(a) previous example ← p ( a ) ← p ( a ) ← q ( b , a ) , s ( a , b ) q ( b , a ) s ( a , b ) ← s ( a , b ) , s ( a , b ) ← s ( a , b ) s ( a , b ) � � � � Katya (AMAST2010) Coalgebraic Semantics for Parallel Derivation Strategies in Logic Programming. AMAST10 15 / 33
Examples of a derivations The action of p : At − → C ( P f P f )( At ) on p(a) The proof tree ← p ( a ) ← p ( a ) q ( b , a ) s ( a , b ) ← q ( b , a ) ← s ( a , b ) � � s ( a , b ) � � � Katya (AMAST2010) Coalgebraic Semantics for Parallel Derivation Strategies in Logic Programming. AMAST10 16 / 33
Recommend
More recommend