next_inactive up previous






Computational Logic:
(Constraint) Logic Programming
Theory, practice, and implementation


Program Analysis, Debugging, and Optimization
A Tour of ciaopp: The Ciao Prolog Preprocessor

Department of Artificial Intelligence
School of Computer Science
Technical University of Madrid
28660-Boadilla del Monte, Madrid, SPAIN

Introduction: The Ciao Program Development System


Introduction: The Ciao Program Development System (Contd.)


CiaoPP: The Ciao System Preprocessor

Overview

Properties and Assertions - I


:- regtype list/1.                    | :- typedef list ::= [];[_|list].
list([]).                             |  
list([_|Y]) :- list(Y).               |__________________________________
______________________________________| :- regtype int/1 + impl_defined.
:- prop sorted/1.                     |__________________________________
sorted([]).                           | :- regtype peano_int/1.
sorted([_]).                          | peano_int(0).
sorted([X,Y|Z]) :- X>Y, sorted([Y|Z]).| peano_int(s(X)) :- peano_int(X).

Properties and Assertions - II

Examples:
  :- success qsort(A,B) : list(A) => ground(B).
  :- calls qsort(A,B) : (list(A),var(B)).
  :- comp qsort(A,B) : (list(A,int),var(B)) + (det,succeeds).

Examples:
  :- pred qsort(A,B) : (list(A,int),var(B)) => sorted(B) + (det,succeeds).
  :- pred qsort(A,B) : (var(A),list(B,int)) => ground(A) + succeeds.

Properties and Assertions - III


PART I: Analysis


Inference of Complex Properties : Non-failure (Intuition)

Inference of Complex Properties: Lower-Bounds on Cost (Intuition)

:- true pred append(A,B,C): list * list * var.
append([], L, L).
append([H|L], L1, [H|R]) :- append(L, L1, R).

``Resource awareness'' example (Upper-Bounds Cost Analysis)

PART II: Program Validation and Diagnosis (Debugging)

Validation Using Abstract Interpretation

Integrated Validation/Diagnosis in the Ciao Preprocessor



figure=Figs/framework_all_nmsu.eps,width=,height=0.9

A Program validation example

Debugging with Global Analysis


Finding Bugs with Global Analysis


Discussion: Comparison with ``Classical'' Types

Approximation Suitable assertion language
Abstract Interpretation Relating aproximations of actual and intended semantics

PART III: Using Analysis Results in Program Optimization

(Multiple) Specialization

Automatic Program Parallelization



figure=Figs/par_process_wide.ps,height=0.5

Automatic Program Parallelization (Contd.)

&-Prolog/Ciao parallelizer overview

figure=Figs/apcompiler.ps,width=0.7

Granularity Control


Granularity Control System Output


g_qsort([], []).
g_qsort([First|L1], L2) :-
  partition3o4o(First, L1, Ls, Lg, Size_Ls, Size_Lg),
  Size_Ls > 20 -> 
    (Size_Lg >  20 ->  g_qsort(Ls, Ls2) & g_qsort(Lg, Lg2);
                       g_qsort(Ls, Ls2),  s_qsort(Lg, Lg2));
    (Size_Lg > 20 ->   s_qsort(Ls, Ls2), g_qsort(Lg, Lg2);
                       s_qsort(Ls, Ls2), s_qsort(Lg, Lg2)),
  append(Ls2, [First|Lg2], L2).

partition3o4o(F, [], [], [], 0, 0).
partition3o4o(F, [X|Y], [X|Y1], Y2, SL, SG) :- 
        X =< F, partition3o4o(F, Y, Y1, Y2, SL1, SG), SL is SL1 + 1.
partition3o4o(F, [X|Y], Y1, [X|Y2], SL, SG) :- 
        X > F,  partition3o4o(F, Y, Y1, Y2, SL, SG1), xSG is SG1 + 1.

Genericity in the Ciao Preprocessor


figure=Figs/framework_all_nmsu.eps,width=0.85

Acknowledgements/Downloading the systems

»²¹حت¸¸¥

1
F. Bueno, D. Cabeza, M. Hermenegildo, and G. Puebla.
Global Analysis of Standard Prolog Programs.
In European Symposium on Programming, number 1058 in LNCS, pages 108-124, Sweden, April 1996. Springer-Verlag.

2
F. Bueno, M. García de la Banda, and M. Hermenegildo.
Effectiveness of Abstract Interpretation in Automatic Parallelization: A Case Study in Logic Programming.
ACM Transactions on Programming Languages and Systems, 21(2):189-238, March 1999.

3
S. K. Debray, P. López-García, M. Hermenegildo, and N.-W. Lin.
Lower Bound Cost Estimation for Logic Programs.
In 1997 International Logic Programming Symposium, pages 291-305. MIT Press, Cambridge, MA, October 1997.

4
S.K. Debray, P. López-García, and M. Hermenegildo.
Non-Failure Analysis for Logic Programs.
In 1997 International Conference on Logic Programming, pages 48-62, Cambridge, MA, June 1997. MIT Press, Cambridge, MA.

5
M. Hermenegildo, F. Bueno, D. Cabeza, M. Carro, M. García de la Banda, P. López-García, and G. Puebla.
The CIAO Multi-Dialect Compiler and System: An Experimentation Workbench for Future (C)LP Systems.
In Parallelism and Implementation of Logic and Constraint Logic Programming, pages 65-85. Nova Science, Commack, NY, USA, April 1999.

6
M. Hermenegildo, F. Bueno, G. Puebla, and P. López-García.
Program Analysis, Debugging and Optimization Using the Ciao System Preprocessor.
In 1999 Int'l. Conference on Logic Programming, pages 52-66, Cambridge, MA, November 1999. MIT Press.

7
M. Hermenegildo and The CLIP Group.
An Automatic Documentation Generator for (C)LP - Reference Manual.
The Ciao System Documentation Series-TR CLIP5/97.2, Facultad de Informática, UPM, August 1997.

8
M. Hermenegildo, G. Puebla, and F. Bueno.
Using Global Analysis, Partial Specifications, and an Extensible Assertion Language for Program Validation and Debugging.
In K. R. Apt, V. Marek, M. Truszczynski, and D. S. Warren, editors, The Logic Programming Paradigm: a 25-Year Perspective, pages 161-192. Springer-Verlag, July 1999.

9
M. Hermenegildo, G. Puebla, K. Marriott, and P. Stuckey.
Incremental Analysis of Logic Programs.
In International Conference on Logic Programming, pages 797-811. MIT Press, June 1995.

10
M. Hermenegildo, G. Puebla, K. Marriott, and P. Stuckey.
Incremental Analysis of Constraint Logic Programs.
ACM Transactions on Programming Languages and Systems, 22(2):187-223, March 2000.

11
P. López-García and M. Hermenegildo.
Efficient Term Size Computation for Granularity Control.
In International Conference on Logic Programming, pages 647-661, Cambridge, MA, June 1995. MIT Press, Cambridge, MA.

12
P. López-García, M. Hermenegildo, and S. K. Debray.
A Methodology for Granularity Based Control of Parallelism in Logic Programs.
Journal of Symbolic Computation, Special Issue on Parallel Symbolic Computation, 22:715-734, 1996.

13
G. Puebla, F. Bueno, and M. Hermenegildo.
An Assertion Language for Debugging of Constraint Logic Programs.
In Proceedings of the ILPS'97 Workshop on Tools and Environments for (Constraint) Logic Programming, October 1997.
Available from ftp://clip.dia.fi.upm.es/pub/papers/assert_lang_tr_discipldeliv.ps.gz as technical report CLIP2/97.1.

14
G. Puebla, F. Bueno, and M. Hermenegildo.
A Generic Preprocessor for Program Validation and Debugging.
In P. Deransart, M. Hermenegildo, and J. Maluszynski, editors, Analysis and Visualization Tools for Constraint Programming, number 1870 in LNCS, pages 63-107. Springer-Verlag, September 2000.

15
G. Puebla, F. Bueno, and M. Hermenegildo.
An Assertion Language for Constraint Logic Programs.
In P. Deransart, M. Hermenegildo, and J. Maluszynski, editors, Analysis and Visualization Tools for Constraint Programming, number 1870 in LNCS, pages 23-61. Springer-Verlag, September 2000.

16
G. Puebla and M. Hermenegildo.
Abstract Specialization and its Application to Program Parallelization.
In J. Gallagher, editor, Logic Program Synthesis and Transformation, number 1207 in LNCS, pages 169-186. Springer-Verlag, 1997.

17
G. Puebla and M. Hermenegildo.
Abstract Multiple Specialization and its Application to Program Parallelization.
J. of Logic Programming. Special Issue on Synthesis, Transformation and Analysis of Logic Programs, 41(2&3):279-316, November 1999.


next_inactive up previous
Last modification: Mon Feb 26 17:17:16 CET 2007 <webmaster@clip.dia.fi.upm.es>[CLIP] [FIM] [UNM]