www.software.imdea.org Description and Evaluation of a Generic Design to Integrate CLP and Tabled Execution Joaquín Arias 1 , 2 Manuel Carro 1 , 2 1 IMDEA Software Institute, 2 Technical University of Madrid 1 / 23
www.software.imdea.org Integration of CLP and Tabled Execution • TCLP is an extension of Prolog which combines the benefits of: CLP: Reduce search, add expressiveness. Tabling: Detect loops, avoid recomputation. • Our design , Modular TCLP , facilitates the connection of CLP solvers with tabling. • The interface is implemented in Ciao Prolog, a system with tabling and CLP . • To validate our design we implemented the interface of several CLP solvers . External Modular TCLP Interface CLP solver Tabling engine Prolog-based CLP solver WAM madrid institute for advanced studies in software development technologies 1 / 23
www.software.imdea.org Background & Motivation Example: Find nodes in a weighted graph within a distance K from each other n 1 2 Comparison of termination properties of similar programs: 3 Written using: Prolog | CLP | Tabling | TCLP . Traversal: Acyclic graphs | Cyclic graphs . With: Right recursion | Left recursion . 4 madrid institute for advanced studies in software development technologies 2 / 23
www.software.imdea.org Background & Motivation - Prolog vs CLP Example: Find nodes in a weighted graph within a distance K from each other d i s t (X,Y,D) : � : � use_package ( clpq ) . edge (X, Z ,D1) , d i s t (Z ,Y,D2) , d i s t (X,Y,D) : � D i s D1 + D2. D1 #> 0 , D2 #> 0 , Prolog CLP d i s t (X,Y,D) : � D #= D1 + D2 , edge (X,Y,D) . edge (X, Z ,D1) , d i s t (Z ,Y,D2 ) . d i s t (X,Y,D) : � edge (1 ,2 ,50). edge ( . . . edge (X,Y,D) . ? � d i s t (1 ,Y,D) , D < 150 . ? � D #< 150 , d i s t (1 ,Y,D) . madrid institute for advanced studies in software development technologies 3 / 23
www.software.imdea.org Background & Motivation - Prolog vs CLP Example: Find nodes in a weighted graph within a distance K from each other d i s t (X,Y,D) : � : � use_package ( clpq ) . edge (X, Z ,D1) , d i s t (Z ,Y,D2) , d i s t (X,Y,D) : � D i s D1 + D2. D1 #> 0 , D2 #> 0 , Prolog CLP d i s t (X,Y,D) : � D #= D1 + D2 , edge (X,Y,D) . edge (X, Z ,D1) , d i s t (Z ,Y,D2 ) . d i s t (X,Y,D) : � edge (1 ,2 ,50). edge ( . . . edge (X,Y,D) . Prolog CLP Left recursion x x Without X X Right recursion cycles Left recursion x x With X Right recursion x cycles madrid institute for advanced studies in software development technologies 3 / 23
www.software.imdea.org Background & Motivation - Prolog vs Tabling Example: Find nodes in a weighted graph within a distance K from each other d i s t (X,Y,D) : � : � use_package ( t a b l i n g ) . edge (X, Z ,D1) , : � table d i s t / 3 . d i s t (Z ,Y,D2) , D i s D1 + D2. d i s t (X,Y,D) : � Prolog Tabling d i s t (X,Y,D) : � d i s t (X, Z ,D1) , edge (X,Y,D) . edge (Z ,Y,D2) , D i s D1 + D2. d i s t (X,Y,D) : � edge (1 ,2 ,50). edge ( . . . edge (X,Y,D) . ? � d i s t (1 ,Y,D) , D < 150. ? � d i s t (1 ,Y,D) , D < 150. madrid institute for advanced studies in software development technologies 4 / 23
www.software.imdea.org Background & Motivation - Prolog vs Tabling Example: Find nodes in a weighted graph within a distance K from each other d i s t (X,Y,D) : � : � use_package ( t a b l i n g ) . edge (X, Z ,D1) , : � table d i s t / 3 . d i s t (Z ,Y,D2) , D i s D1 + D2. d i s t (X,Y,D) : � Prolog Tabling d i s t (X,Y,D) : � d i s t (X, Z ,D1) , edge (X,Y,D) . edge (Z ,Y,D2) , D i s D1 + D2. d i s t (X,Y,D) : � edge (1 ,2 ,50). edge ( . . . edge (X,Y,D) . Prolog Tabling X Left recursion x Without X X Right recursion cycles Left recursion x x With Right recursion x x cycles madrid institute for advanced studies in software development technologies 4 / 23
www.software.imdea.org Background & Motivation - TCLP (with entailment) Example: Find nodes in a weighted graph within a distance K from each other : � use_package ( t a b l i n g ) . : � use_package ( t_clpq ) . : � table d i s t / 3 . d i s t (X,Y,D) : � TCLP D1 #> 0 , D2 #> 0 , D #= D1 + D2, d i s t (X, Z ,D1) , edge (Z ,Y,D2 ) . d i s t (X,Y,D) : � edge (X,Y,D) . ? � D #< 150 , d i s t (1 ,Y,D) . madrid institute for advanced studies in software development technologies 5 / 23
www.software.imdea.org Background & Motivation - TCLP (with entailment) Example: Find nodes in a weighted graph within a distance K from each other : � use_package ( t a b l i n g ) . : � use_package ( t_clpq ) . : � table d i s t / 3 . d i s t (X,Y,D) : � TCLP D1 #> 0 , D2 #> 0 , D #= D1 + D2, d i s t (X, Z ,D1) , edge (Z ,Y,D2 ) . Prolog TCLP d i s t (X,Y,D) : � edge (X,Y,D) . Left recursion x X Without Right recursion X X cycles Left recursion x X With ? � D #< 150 , d i s t (1 ,Y,D) . Right recursion x X cycles madrid institute for advanced studies in software development technologies 5 / 23
www.software.imdea.org Background & Motivation - TCLP (with entailment) Example: Find nodes in a weighted graph within a distance K from each other : � use_package ( t a b l i n g ) . edge (1 ,2 ,50). : � use_package ( t_clpq ) . edge (2 ,1 ,D) : � Graph : � table d i s t / 3 . D #> 30 , D #< 60. d i s t (X,Y,D) : � edge ( . . . TCLP D1 #> 0 , D2 #> 0 , D #= D1 + D2, d i s t (X, Z ,D1) , edge (Z ,Y,D2 ) . Prolog TCLP d i s t (X,Y,D) : � edge (X,Y,D) . Left recursion x X Without Right recursion X X cycles Left recursion x X With ? � D #< 150 , d i s t (1 ,Y,D) . Right recursion x X cycles madrid institute for advanced studies in software development technologies 5 / 23
www.software.imdea.org Background & Motivation Example: Find nodes in a weighted graph within a distance K from each other n 1 2 Prolog CLP Tabling TCLP Left recursion x x X X Without Right recursion X X X X cycles 3 X Left recursion x x x With X X Right recursion x x cycles Termination properties of similar programs. 4 madrid institute for advanced studies in software development technologies 6 / 23
www.software.imdea.org Background & Motivation - Applications Abstract interpretation: Tabling reaches the fixpoint. The constraint solvers detect more particular calls and make it possible to state preconditions. Reasoning on ontologies: Tabling makes it possible to define terminating left-recursive rules. The constraint solver formalize the types, properties, and interrelationships defined in the ontologies. Constraint-based verification: Tabling ensures termination and saves execution time. The constraint solvers encode verification rules. madrid institute for advanced studies in software development technologies 7 / 23
Recommend
More recommend