1: %\documentstyle[12pt]{article}
2:
3: %\documentstyle[graphics]{llncs}
4:
5:
6: \documentclass[twoside,12pt]{article}
7:
8:
9: %\documentclass{scrartcl} % Specifies the document style.
10: \usepackage{times}
11: \usepackage{amsmath}
12: \usepackage{alltt}
13: \usepackage{epsfig}
14:
15: \newtheorem{lemma}{Lemma}
16:
17: \renewcommand{\baselinestretch}{0.86}
18:
19: \textwidth 480pt
20: \textheight 680pt
21:
22: \overfullrule 0pt
23: \pagestyle{headings}
24: \voffset -10 truemm
25: \hoffset -12 truemm
26: \addtolength{\leftmargin}{-5cm}
27:
28:
29: \def\crrr{}
30:
31: \def\bbbr{{\rm \mathbf I\!R}}
32:
33: \newlength{\eztab}
34: \setlength{\eztab}{23pt}
35: \def\ta{\displaystyle\rm}
36: \def\tb{\displaystyle\rm\hspace*{\eztab}}
37: \def\tc{\displaystyle\rm\hspace*{2\eztab}}
38: \def\td{\displaystyle\rm\hspace*{3\eztab}}
39: \def\te{\displaystyle\rm\hspace*{4\eztab}}
40: \def\tf{\displaystyle\rm\hspace*{5\eztab}}
41: \def\ttb{\rm\mspace{-80mu}}
42:
43: \newcommand{\avec}{{\boldsymbol\alpha}}
44: \newcommand{\mvec}{{\boldsymbol\mu}}
45: \newcommand{\boldh}{{\cal H}}
46: \newcommand{\boldf}{{\cal F}}
47: \newcommand{\data}[6]
48: {
49: { ${ \ttb
50: \begin{smallmatrix}
51: \rule{0pt}{10pt} {\ta #1} \\
52: \rule{0pt}{7pt} {\tb #2} \\
53: \rule{0pt}{7pt} {\tc #3} \\
54: \rule{0pt}{7pt} {\td #4} \\
55: \rule{0pt}{7pt} {\te #5} \\
56: \rule{0pt}{7pt} {\tf #6} \\
57: \rule{0pt}{1pt}
58: \end{smallmatrix} }$}
59: }
60:
61: \newcommand{\head}
62: {
63: {\tiny ${
64: \mspace{-100mu}
65: \begin{smallmatrix}
66: \rule{0pt}{8pt} {\ta TiMBL} \\ \rule{0pt}{6pt} {\tb C4.5} \\
67: \rule{0pt}{6pt} {\tc OC1} \\ \rule{0pt}{6pt} {\td ANN} \\
68: \rule{0pt}{6pt} {\te GMM} \\
69: \rule{0pt}{6pt} {\tf SVM}
70: \\ { }
71: \end{smallmatrix} }$}
72: }
73:
74: \newcommand{\headd}[2]
75: {
76: $\begin{array}{c}
77: {\mathbf{#1}}\\
78: {#2}
79: \end{array}$
80: }
81:
82:
83: \begin{document}
84:
85:
86:
87: \pagestyle{myheadings}
88: \markboth{AADEBUG 2000}{Slicing of Constraint Logic Programs}
89:
90: \title{Slicing of Constraint Logic Programs }
91:
92:
93:
94: \footnote{In M. Ducass\'e (ed), proceedings of the Fourth International
95: Workshop on Automated Debugging (AADEBUG 2000), August 2000, Munich.
96: COmputer Research Repository (http://www.acm.org/corr/),
97: cs.SE/0012014; whole proceedings: cs.SE/0010035.}
98:
99:
100: \author{Gy\"ongyi Szil\'agyi$^1$, Tibor Gyim\'othy$^1$ and Jan
101: Ma{\l}uszy{\'n}ski $^2$ \\
102: $^1$ Research Group on Artificial Intelligence Hungarian Academy of Sciences \\
103: $^2$ Dept. of Computer and Information Sci.,
104: Link{\"o}ping University, Sweden\\
105: E-mail:\{szilagyi,gyimi\}@inf.u-szeged.hu, janma@ida.liu.se}
106: %\thanks{The work of the first and second authors was supported by the grant OTKA T52721}
107:
108:
109:
110: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
111:
112: \date{}
113: \maketitle
114:
115:
116: \begin{abstract}
117: {\bf Abstract. } {\em
118: Slicing is a program analysis technique originally developed
119: for imperative languages. It facilitates understanding of data flow
120: and debugging.
121:
122: This paper discusses slicing of Constraint Logic Programs.
123: Constraint Logic Programming (CLP) is an emerging software technology
124: with a growing number of applications.
125: Data flow in constraint programs is not explicit, and for this reason
126: the concepts of slice and the slicing
127: techniques of imperative languages are not directly applicable.
128:
129:
130: This paper formulates declarative notions of slice suitable
131: for CLP. They provide a basis for defining
132: slicing techniques (both dynamic and static) based on variable
133: sharing. The techniques are further extended by using
134: groundness information.
135:
136: A prototype dynamic slicer of CLP programs implementing
137: the presented ideas is briefly described together with the results of
138: some slicing experiments. }
139:
140: \end{abstract}
141: %\trabstractpage
142:
143: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
144:
145:
146:
147: \input epsf
148:
149:
150: %\newtheorem{de}[theorem]{Definition}
151:
152: %\newenvironment{definition}{\begin{de} \rm \normalsize}{\hfill
153:
154: %$\Box$\par\end{de}}
155:
156:
157:
158: \newtheorem{theo}{Theorem}%[section]
159:
160: %\newtheorem{lemma}[theo]{Lemma}%[section]
161:
162: \newtheorem{prop}[theo]{Proposition}%[section]
163:
164: \newtheorem{con}[theo]{Consequence}%[section]
165:
166: \newtheorem{defi}{Definition}%[section]
167:
168: \newtheorem{ex}{Example}%[section]
169:
170: \newcommand{\bd}{\begin{defi}}
171:
172: \newcommand{\ed}{\end{defi}}
173:
174: \newcommand{\bt}{\begin{theo}}
175:
176: \newcommand{\et}{\end{theo}}
177:
178: \newcommand{\bl}{\begin{lemma}}
179:
180: \newcommand{\el}{\end{lemma}}
181:
182: \newcommand{\be}{\begin{ex}}
183:
184: \newcommand{\ee}{\end{ex}}
185:
186:
187:
188:
189:
190:
191:
192: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
193:
194:
195:
196:
197: \section{Introduction}
198:
199:
200:
201: %\footnote{} Slicing is a program analysis technique originally developed
202: %for imperative languages. It facilitates the understanding of data flow
203: %and debugging (see e.g. \cite{HR92, GBF, KAR97, KAM93, Reps94, Tip}).
204:
205: This paper discusses slicing of Constraint Logic Programs.
206: Constraint Logic Programming (CLP) (see e.g. \cite{Mar98})
207: is an emerging software technology
208: with growing number of applications.
209: Data flow in constraint programs is not explicit, and for this reason
210: the concept of a slice and the slicing
211: techniques of imperative languages are not directly applicable.
212: Also, implicit data flow makes the
213: understanding of program behaviour rather difficult. Thus
214: program analysis tools explaining data flow to the user
215: could be of great practical importance. This paper presents
216: a prototype tool based on the slice concept applied to CLP.
217:
218:
219:
220: %The aim of slicing is to find fragments of the program
221: %which influence
222: %the value of a selected variable at a given program
223: %point.
224:
225: Intuitively a program {\em slice}
226: with respect to a specific variable at some program point
227: contains all those parts of the program that may affect the value of
228: the variable ({\em backward slice}) or may be affected by the value
229: of the variable ({\em forward slice}). Slicing algorithms
230: can be classified according to whether they only use statically
231: available information ({\em static slicing}), or compute those
232: statements which influence the value of a variable occurrence for
233: a specific program input ({\em dynamic slice}).
234: The slice provides a focus for analysis of the
235: origin of the computed values of the variable in question.
236: In the context of CLP the intuition remains the same, but
237: the concept of slice requires precise definition since the nature
238: of CLP computations is different from the nature of imperative
239: computing.
240:
241:
242:
243: Slicing techniques for logic programs have been discussed in
244: \cite{Gyi, Duc, Zhao3}. CLP extends logic programming with
245: constraints. This is a substantial extension and the slicing
246: of CLP program has, to our knowledge, not yet been addressed
247: by other authors.
248: Novel contributions presented in this paper are:
249: \begin{itemize}
250: \item {\em A precise formulation of the slicing problem for CLP programs.}
251: We first define a concept of slice for a set of constraints,
252: which is then used to define slices of {\em derivation trees}, representing
253: states of CLP computations.
254: Then we define slices of a program
255: in terms of the slices of its derivation trees.
256: \item {\em Slicing techniques for CLP.}
257: We present slicing techniques that make it possible to construct
258: slices according to the definitions. The techniques are
259: based on a simple analysis of variable sharing and groundness.
260: \item {\em A prototype dynamic slicer.}
261: A tool implementing the proposed techniques and some experiments with its use are briefly described.
262: \end{itemize}
263:
264: The precisely defined concepts of slice gives a solid foundation
265: for development of slicing techniques. The prototype tool, including
266: some visualisation facilities, helps the user in better understanding of
267: the program and in (manual) search for errors.
268: Integration of this
269: tool with more advanced debuggers is a topic of future work.
270:
271:
272: The paper is organized as follows.
273: Section 2 outlines some basic concepts which are then used in
274: Section 3 to formulate the problem of slicing.
275: Section 4 presents and justifies a declarative formalization of CLP slicing,
276: based on a notion of dependency relation.
277: Section 5 discusses a dynamic backward slicing technique, and the use
278: of directionality information
279: for reducing the size of slices.
280: Our prototype tool is described in Section 6, together with
281: results of some experiments.
282: Section 7 then discusses relations to other work. Finally
283: in Section 8 we present our conclusions and suggestions for future work.
284:
285:
286:
287:
288:
289:
290:
291:
292:
293: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
294:
295:
296:
297:
298:
299:
300:
301:
302: \section{Constraint Logic Programs}
303:
304: %Constraint logic programming is an extension of
305:
306:
307:
308: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
309:
310:
311: %\subsection{Constraint Logic Programs and Derivation Trees}
312:
313:
314: The cornerstone of
315: {\bf Constraint Logic Programming (CLP)} \cite{JaM, Mar98}
316: is the notion of constraint. Constraints are formulae constructed
317: with some {\bf constraint predicates} with a predefined interpretation.
318: A typical example of a
319: constraint is a linear arithmetic equation
320: or inequality
321: with rational coefficients where the
322: constraint predicate used is equality interpreted over
323: rational numbers, e.g. $X-Y=1$. The variables of a constraint range
324: over the domain of interpretation.
325: A {\bf valuation} of a set $S$ of variables is a mapping $\theta$
326: from $S$ to the interpretation domain.
327: A set of constraints $C$ {\bf is satisfiable } if
328: there exists a valuation $\theta$ for the set of variables occurring
329: in $C$, such that $\theta (C)$ holds in the constraint domain. \\
330:
331: A {\bf constraint logic program} is a set of {\bf clauses}
332: of the form $h :- b_1,...,b_n$, $n\geq 0$ , where $h,b_1,...,b_n$
333: are {\bf atomic formulae}. The predicates used to construct
334: $b_1,...,b_n$ are either constraint predicates or other predicates
335: (sometimes called {\bf defined predicates}). The predicate of $h$
336: is a defined predicate. A {\bf goal} is a clause without $h$.
337: This syntax extends
338: logic programs with the possibility of including constraints
339: into the clauses.
340: \be
341: In the following constraint program
342: the equality constraint
343: and symbols of arithmetic operations are
344: interpreted over the domain of rational numbers.
345: This simple example is chosen to simplify
346: the forthcoming illustration
347: of slicing concepts and techniques. The constraints are distinguished
348: by the curly brackets $\{\}$.
349:
350: \begin{verbatim}
351: p(X,Y,Z):- {X-Y=1}, q(X,Y), r(Z).
352: q(U,V):- {U+V=3}.
353: r(42).
354: \end{verbatim}
355: \ee
356:
357: Slicing refers to computations. Abstractly, a computation
358: can be seen as construction of a tree, from
359: renamed instances of clauses. We explain briefly
360: the idea discussed formally in \cite{DM93}.
361:
362: Intuitively, a clause $c$ can be seen as a tree with root $h$ {\bf head}
363: and leaves $b_1,...,b_n$ {\bf body atoms}. If the predicate of
364: $b_i$ appears in the head of a clause $c'$ then a renamed copy $c''$ of
365: $c'$ can be composed with $c$ by attaching the head of $c''$
366: to $b_i$. This implicitly adds equality constraints for the corresponding
367: arguments of the atoms.
368: This process can be repeated for the leaves of
369: the resulting tree. More formally this is captured by the following
370: notion. A {\bf skeleton} for a program $P$ is a labeled ordered tree with
371: the root labeled by a goal clause and with the
372: nodes labeled by (renamed) clauses of the program; some leaves may instead be
373: labeled "?" in which case they are called {\bf incomplete
374: nodes}.
375: Each non-leaf
376: node has as many children as the non-constraint atoms of its body.
377: The head predicate of the $i$-th child of a node is the same as the
378: predicate of the $i$-th non-constraint body atom of the clause labeling
379: the node.
380:
381:
382:
383: For a given skeleton $S$ the set $C(S)$ of constraints,
384: which will be called {\bf the set of constraints of $S$}, consists of :
385: \begin{itemize}
386: \item the constraints of all clauses labeling the nodes of $S$
387: \item all equations $\vec{x} = \vec{y}$ where $\vec{x}$ are the
388: arguments of the $i$-th body atom of the
389: clause labeling a node $n$ of $S$, and $\vec{y}$ are the arguments of
390: the head atom of the clause labeling the $i$-th child of $n$. (No equation is created if the
391: $i$-th child of $n$ is an incomplete node).
392: \end{itemize}
393: A {\bf derivation tree} for a program $P$
394: is a skeleton for $P$ whose set of
395: constraints is satisfiable.
396: If the skeleton is complete (i.e. it has no incomplete node)
397: the derivation tree is called a {\bf proof tree}.
398: Figure \ref{1kep} shows a complete skeleton tree for the program in
399: Example 1.
400:
401:
402: \begin{figure}[h]
403: \begin{center}
404: \epsfbox{kep5.eps}
405: \caption{A skeleton for the CLP program of Example 1.}
406: \label{1kep}
407: \end{center}
408: \end{figure}
409:
410: The set of constraints of this skeleton is:
411: $C(S)= \{X-Y=1, X=U, Y=V, U+V=3, Z=42\}$
412: and it is satisfiable. Thus the skeleton is a proof tree.
413:
414:
415:
416: For the presentation of the slicing techniques we need to refer
417: to {\bf program positions}
418: and to {\bf derivation tree positions}. A slice is
419: defined with respect to some particular occurrence of a variable
420: (in a program or derivation tree), and positions are used to identify
421: these ocurrences. Positions also identify arguments of the atomic formulae
422: and their subterms.
423:
424: To define the notion of position we assume that some standard
425: way of enumeration of the nodes of any given tree $T$ is adopted.
426: The indices of the nodes of $T$ are called {\bf positions} of $T$
427: and the set of all positions is denoted $Pos(T)$. Each position
428: determines a unique subtree of $T$. On the other hand,
429: $T$ may have several identical subtrees $T_0$ at different
430: positions.
431:
432: This notation extends also for atomic formulae and terms,
433: where the positions determine unique subterms.
434: A position of a term such that the corresponding subterm
435: is a variable will be called a {\em variable position}.
436: We extend the adopted way of enumeration to clauses and
437: programs; a {\em program position} is an index in this enumeration
438: that identifies an atomic formula or a term in a clause of the program.
439:
440:
441: A single clause may be treated as a one-clause program.
442: As discussed above, a derivation tree has its nodes labeled
443: by renamed variants of program clauses. By a {\em derivation
444: tree position} of a derivation tree $T$
445: we mean a pair $(i_1,i_2)$, where $i_1$ is a position of the skeleton of $T$
446: and $i_2$ is a position of the clause labeling node $i_1$ in $T$.
447: The set of all tree positions of a derivation tree $T$
448: will be denoted by $Pos(T)$.
449:
450: Recall that each label of a derivation tree $T$ is a variant of
451: a program clause, or of a goal. Therefore the
452: positions of $T$ can be mapped in a natural way into the corresponding
453: program positions.
454:
455:
456: Similary, each occurrence of a variable $X$
457: in $C(T)$ (the constraint set of $T$) originates from
458: a variable position of $X$ in $T$.
459: Thus variable positions of $T$ can be linked to the
460: related constraints of $C(T)$.
461:
462: Let $\cal P$ be a set of positions of $T$, and
463: $\Psi_T({\cal P})$ the set of all variables
464: that appear in the terms on positions in $\cal P$. In this way $\cal P$
465: identifies
466: the subset $C_{\cal P}$ of $C(T)$ consisting of all
467: constraints including variables in $\Psi_T(\cal P)$.
468: \be
469: Consider the derivation tree of Figure 1.\\
470: Let $\cal(P)=\{$ derivation tree positions of the atom $q(X,Y)\} \subseteq Pos(T).$ \\
471: Then $\Psi_T {\cal(P)} = \{X,Y\}$ and $C_{\cal P}=\{X-Y=1, X=U, Y=V\}. $
472: %\subseteq C(T).$
473: \ee
474:
475:
476: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
477:
478:
479: \section{The Slicing Problem}
480:
481: Given a variable $X$ in a CLP program we would like to find a fragment
482: of the program that may affect the value of $X$.
483: This is rather imprecise, hence our objective is to formalize
484: this intuition.
485: We first define the notion of a slice of a satisfiable set
486: of constraints. A variable $X$ in a derivation tree $T$
487: has its valuations \cite{JaM, Mar98} restricted by
488: the set of constraints of $T$ (which is satisfiable),
489: so our second task will be to define a slice of a derivation tree,
490: and finally a slice of a program (see Figure \ref{slice1}).
491:
492: \begin{figure}[h]
493: \begin{center}
494: \epsfbox{slice.eps}
495: \caption{A slice of a constraint set, a proof tree and a program.}
496: \label{slice1}
497: \end{center}
498: \end{figure}
499:
500: Let $C$ be a set of constraints. Intuitively we would like to remove all
501: constraints of the set that do not restrict the valuation of a given variable.
502: The binding of a variable
503: $X$ to a value $v$ is said to be a {\em solution} of $C$ with respect to
504: $X$ iff there exists a valuation $\nu$ such that $\nu(X)=v$
505: and $\nu$ satisfies $C$.
506: The set of all solutions of $C$ with respect to $X$ will be denoted by
507: $Sol(X,C)$.
508:
509: \bd
510: A {\bf slice of a satisfiable constraint set $C$}
511: with respect to $X$ is a subset $S \subseteq C$ such
512: that $Sol(X,S) = Sol(X,C)$.
513: \ed
514: In other words the set of all solutions of a slice $S$ of $C$
515: with respect to $X$ is equal to the set of
516: all solutions of $C$ with respect to $X$.
517: Definition 1 gives implicitly a notion of {\bf minimal slice}:
518: it is a slice $S$ of $C$ such that if we further reduce $S$ to $S'$,
519: then $Sol(X,S')$ is different from $Sol(X,C)$.
520: Notice that the whole set $C$ is a slice of itself,
521: and that the definition does not provide
522: any hint about how to find a minimal slice. The problem of finding minimal
523: slices may be undecidable in general, since satisfiability may be undecidable.
524: So reasoning about minimality of the constructed slices
525: seems only be possible in very restricted cases, and for some
526: specific constraint domains. Our general technique is domain
527: independent but we show in Section 5 how the groundness
528: information ( which may be provided by a specific
529: constraint solver) can be used to reduce the size of the
530: slices constructed by the general technique.
531:
532:
533: We now formulate the slicing problem for derivation trees.
534: A derivation tree $T$ is a skeleton with a set of constraints $C(T)$.
535: The variables of $C(T)$ originate from positions of $T$.
536: Let $\cal P$ be a set of positions of $T$, i.e. ${\cal P} \subseteq
537: Pos(T)$.
538: Then $\Psi({\cal P})$ identifies the variables of $C(T)$ with
539: occurrences originating from positions in $\cal P$.
540: We denote by $C_{\cal P}$ the set of all constraints of $C(T)$ that include
541: these variables.
542:
543: \bd
544: A {\bf slice of a derivation tree} $T$ with respect to
545: a variable position of $X$
546: is any subset $\cal P$ of the positions of $T$
547: such that $C_{\cal P}$ is a slice of $C(T)$ with respect to $X$.
548: \ed
549:
550: The intuition reflected by this definition is
551: that the constraints connected with the
552: positions of the tree not included in a slice
553: do not influence restrictions on the
554: valuation of $X$ imposed by the tree.
555: We formalize this by referring to the formal
556: notion of the slice of a set of constraints.
557: Notice that any superset of a slice
558: is also a slice.
559:
560: Finally we define the notion of a CLP program slice
561: with respect to a variable position. We notice that every position
562: of a derivation tree $T$ is a (renamed) copy of a program position
563: or of a goal position. This provides a natural map
564: $\Phi_T$ of the positions of $T$
565: into program positions and goal positions. Corresponding to this definition of
566: $\Phi_T$, for a program position $q$ the set $\Phi^{-1}_T(q)$ contains those proof
567: tree positions such that if $r \in \Phi^{-1}_T(q)$ then $\Phi_T(r)=q$.
568:
569:
570:
571:
572:
573: \bd {\bf A slice of a CLP program} $P$ with respect to a program position
574: $q$ is any set $S$ of positions of $P$ such that
575: for every derivation tree $T$ whenever its position $r$
576: is in $\Phi_T^{-1}(q),$
577: there exists a slice $Q$ of $T$ with respect to $r$ such that
578: $\Phi_T(Q)\subseteq S$.
579: \ed
580:
581: This means that for any derivation tree position $r$, such that $\Phi_T(r)=q$,
582: and program slice $S$ with respect to $q$, the value of the variable in $r$
583: can only be influenced by variants of the program positions in $S$.
584:
585: %Intuitively, we expect the positions of $P$ not included in a slice
586: %$S$ with respect to an occurrence of a
587: %variable $X$ in the program not to influence the solutions
588: %of $X$ in any computation of $P$. In other words,
589: %for every position of $X$ in any derivation tree $T$
590: %there should exist a slice of $T$ with respect to this position
591: %that maps into a subset of $S$.
592:
593:
594: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
595:
596:
597: \section{Dependency-based slicing}
598:
599: The formal definitions of the previous section
600: make it possible to state
601: precisely our objective, which is automatic construction of slices.
602:
603: Our formulation defines slicing of a CLP program in terms of
604: the slicing of sets of constraints.
605: Generally it is undecidable whether a subset of
606: a set of constraints is a slice.
607: This section presents a rather straightforward sufficient
608: condition for this.
609: We provide here a ``syntactic'' approach to slicing
610: constraint stores, proof trees and programs.
611: The propositions follow easily from the definitions
612: and will be stated without proof.
613: More details can be found in the technical report \cite{Mal98}.
614:
615: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
616:
617:
618: \subsection{Slicing sets of constraints}
619:
620:
621: We use variable sharing between constraints
622: as a basis for slicing sets of constraints.
623: Let $C$ be a set of constraints, and $vars(C)$
624: the set of all variables occurring in the constraints
625: in $C$. Let $X,Y$ be variables in $vars(C)$.
626: $X$ is said to {\bf depend explicitly}
627: on $Y$ iff both occur in a constraint $c$ in $C$.
628: Notice that the explicit dependency relation is symmetric
629: and reflexive but need not be transitive.
630:
631: \bd
632: A {\bf dependency relation} on $vars(C)$ is
633: the transitive closure of the explicit dependency
634: relation.
635: \ed
636: The dependency relation on $C$ will be denoted by $dep_C$.
637: Notice that $dep_C$ is an equivalence relation on $vars(C)$.
638: We map any equivalence class $[X]_{dep_C}$ to the
639: subset $C_X$ of $C$ that consists of all constraints that include variables in $[X]_{dep}$. Then {\bf $C_X$ is a slice of $C$} (see \cite{Mal98}).
640:
641: \be
642: For the set of constraints of
643: Example 1 the dependency relation has
644: two equivalence classes:
645: $\{X,Y,U,V\}$ and $\{Z\}$ and gives the
646: following slice of $C$ with respect to $X$:
647: \[C_X = \{X-Y=1, \ X=U, \ Y=V, \ U+V=3 \} \]
648: \ee
649: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
650:
651:
652: \subsection{Slicing of derivation trees}
653:
654: We defined the concept of slice for a derivation
655: tree by referring to the notion of slice of
656: a set of constraints. To construct slices of
657: derivation trees we introduce a dependency relation
658: on the positions of a derivation tree.
659: We now define a direct dependency relation
660: $\sim_T$ on $Pos(T)$. It can be related to the dependency relation on
661: $vars(C(T))$ \cite{Mal98} and hence can be used for slicing $T$.
662:
663: \bd
664: Let $T$ be a derivation tree. The direct dependency
665: relation $\sim_T$ on $Pos(T)$ is defined as follows:\\
666: $\alpha \sim _T \beta$ iff one of the following conditions holds:
667: \begin{enumerate}
668: \item $\alpha$ and $\beta$ are positions in an occurrence
669: of a clause constraint (constraint edge).
670: \item $\alpha$ and $\beta$ are positions in a node equation (transition edge).
671: \item $\alpha$ and $\beta$ are positions in an occurrence
672: of a term (functor edge).
673: \item $\alpha$ and $\beta$ share a variable (local edge).
674: \end{enumerate}
675: \ed
676: Observe that the relation is both reflexive and symmetric.
677: The transitive closure $\sim^*_T$ of the direct
678: dependency relation will be called the {\em dependency relation}
679: on $Pos(T)$. So $\sim^*_T$ is an equivalence relation.
680:
681: \begin{prop}
682: Let $T$ be a proof tree and let $\alpha$ be a variable
683: position of $T$. Then $[\alpha]_{\sim^*_T}$ is a slice
684: of $T$ with respect to $\alpha$.
685: \end{prop}
686:
687:
688:
689:
690: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
691:
692:
693: \subsection{Slicing of CLP programs}
694:
695:
696:
697: This section defines a dependency relation on the positions of the program
698: and then makes use of it in constructing program slices.
699: Recall that each position of a derivation tree $T$ ``originates''
700: from a position of the selected program $P$. This is formally
701: captured by the map $\Phi: Pos(T) \rightarrow Pos(P)$.
702: The dependency relation $\sim_P$ on $Pos(P)$ we are going to define
703: should reflect dependency relations in all proof trees of $P$.
704: More precisely, whenever $\alpha \sim_T \beta$
705: in some tree $T$ we would also like to have $\Phi(\alpha) \sim_P
706: \Phi(\beta)$.
707:
708:
709: \bd
710: Let $P$ be a CLP program. The direct dependency relation $\sim_P$
711: on $Pos(P)$ is defined as follows: $\alpha \sim_P \beta$
712: iff at least one of the following conditions holds:
713:
714: \begin{enumerate}
715: \item $\alpha$ and $\beta$ are positions of the same constraint (constraint edge).
716: \item $\alpha$ is a position of the head atom of a clause
717: $c$ and $\beta$ is a position of a body atom of a clause
718: $d$ and both atoms have the same
719: predicate symbol (transition edge).
720: \item $\alpha$ and $\beta$ belong to the same argument of a
721: function (functor edge).
722: \item $\alpha$ and $\beta$ are in the same clause and have
723: a common variable (local edge).
724: \end{enumerate}
725: \ed
726:
727: The dependency relation of a program can be represented
728: as a graph.
729:
730:
731: \begin{figure}[h]
732: \begin{center}
733: \epsfbox{kep9.eps}
734: \caption{Program dependence represented in graphical form and the backward slice with respect to Z in p(X,Y,Z))}
735: \label{slice2}
736: \end{center}
737: \end{figure}
738:
739:
740: Comparing the definitions of $\sim_T$ and $\sim_P$ one can
741: check that whenever
742: $\alpha \sim_T \beta$
743: in some tree $T$ of $P$ then
744: $\Phi(\alpha) \sim_P \Phi(\beta)$ as well.
745: Consequently, for any proof tree $T$
746: $(\alpha \sim_T^* \beta) \Rightarrow \Phi(\alpha) \sim_P^* \Phi(\beta)$.
747: The transitive closure $\sim_P^*$ is an equivalence relation on
748: $Pos(P)$.
749: The following result shows how $\sim_P^*$ can be used for the slicing
750: of $P$.
751:
752: \begin{prop}
753: Let $P$ be a CLP program and let $\beta$ be a position of $P$.
754: Then $[\beta]_{\sim_P^*}$ is a slice of $P$ with respect to $\beta$.
755: \end{prop}
756:
757: Figure \ref{slice2} shows the program dependences and a backward slice of the program in Example 1 with respect to $Z$ in $p(X,Y,Z)$. For the program in Example 1 $\sim_P^*$ has two equivalence classes.
758: One of them includes all occurrences of $Z$ and the
759: occurrence of the constant 42. The other consists of the
760: remaining positions.
761:
762:
763: Definition 6 with Proposition 2 give a method for constructing
764: program slices without referring to proof trees.
765: Thus, we obtain a {\bf static slicing}
766: technique for CLP. The mapping $\Phi$ was introduced to argue about
767: correctness of this technique.
768: These results also confirm the correctness of the
769: slicing algorithm in \cite{Gyi} since a logic program can be viewed as
770: a constraint logic program. \\
771: The proposition shows that the concept of dependency relation
772: on program positions provides a sufficient condition for slicing
773: a CLP program. However, the slice obtained may be quite large, sometimes
774: it may even include the whole constraint store.
775:
776: We propose two ways for addressing this problem.
777: On one hand, improvement is possible if we handle the so called
778: ``calling context problem''\cite{Reps94} which appears when
779: the same predicate is called from two different clauses.
780: As we explained in \cite{Mal98} it is possible to adapt to CLP
781: the solution proposed by Horwitz et. al \cite{Reps94} for procedural languages. Another way of reducing the size
782: of slices is to infer and to take into account
783: information about proliferation of ground instantiations
784: during the execution of the program. A directional
785: dynamic slicing technique based on this idea
786: is presented in the next section.
787:
788:
789: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
790:
791:
792:
793: \section{Dynamic directional slicing}
794:
795: All the dependency relations discussed so far were symmetric.
796: Intuitively, for a constraint $c(X,Y)$
797: a restriction imposed on valuations of $X$ usually
798: influences admissible valuations of $Y$ and vice versa.
799: However if $c(X,Y)$ belongs to a satisfiable constraint set $C$
800: and some other constraints of $C$ make $X$ ground then
801: the slice of $C$ with respect to $X$ need not include $c(X,Y)$.
802: For example, if $C = \{X+1=0, Y>X \}$ is interpreted on the integer
803: domain then $\{X+1=0\}$ is a slice of $C$ with respect to $X$.
804: This slice can be constructed by using information about
805: groundness of variables occurring in the dependency graph.
806: %This slice cannot be obtained by analysis of $dep_C$ alone.
807:
808:
809:
810: This section shows how to use groundness information
811: in derivation tree slicing, that is in dynamic slicing
812: of CLP programs. It extends to CLP the ideas of dynamic
813: slicing for logic programs presented in \cite{Gyi}.
814: In our approach groundness
815: is captured by adding directionality information to dependency graphs.
816: The directed graphs show the propagation of ground data
817: during the execution of CLP programs, and these graphs can then be used to
818: produce more precise slices.
819: The groundness information will be collected during
820: the computation that constructs the derivation tree to be
821: sliced. The proposed concepts are also applicable to the case
822: of static slicing, where the groundness information has to
823: be inferred by static analysis of the program. This is however
824: not discussed in this paper.
825: %The novelty of this section is that we extended a backward dynamic logic
826: % programming slicing technique \cite{Gyi} for constraint logic programs
827: %using the results of the dependency analysis defined in the previous
828: %sections.
829:
830: \subsection{Groundness Annotations}
831:
832: Groundness information associated with a derivation tree will be
833: expressed as an annotation of its positions.
834: The annotation classifies the positions of a derivation tree or
835: the positions of the CLP program.
836: The positions are classified as
837: {\em inherited} (marked with $\downarrow$),
838: {\em synthesized} ($\uparrow$) and {\em dual} ($\updownarrow$).
839: An annotation is {\em partial} if some positions are dual. Formally speaking,
840: an annotation is a mapping
841: $\mu$ from the positions into the set
842: $\{\downarrow,\uparrow,\updownarrow\}$ \cite{DM93}.
843:
844: The intended meaning of the annotation is as follows.
845: An inherited position is a position which is ground at time of
846: calling, that is when the equation involving this position
847: is first created during the construction of the derivation tree.
848: A synthesized positions is a position which is ground at
849: success, that is when the subtree having the position in its
850: root label is completed in the computation process.
851: The dual positions of a proof tree are those for which
852: no groundness information is given, including those
853: which are ground neither at call nor at success.
854:
855:
856:
857: The annotations will be collected during the execution
858: of the program. Alternatively, they may be inferred
859: with some straightforward inference rules discussed in \cite{Mal98}.
860:
861:
862: %The annotations may be
863: % given by the user or inferred from partial annotations.
864: We now introduce the following auxiliary terminology relevant to the
865: annotated positions of a CLP program.
866: The inherited positions of the head atoms and the synthesized positions of the
867: body atoms are called {\em input positions}. Similarly, the synthesized
868: positions of the head atoms and inherited positions of the body atoms are
869: called {\em output positions}.
870: Note that dual positions
871: are not strictly classified as input or output ones.
872: Alternatively, if we say that a position is annotated as an
873: output we mean that it is annotated
874: as inherited provided it is a position in a body atom,
875: or annotated as synthesized if it is a position of the head of a
876: clause.
877:
878: \be Consider the following CLP program:
879: \begin{verbatim}
880: 1. p(X,Y) :- r(X), q(X,Y).
881: 2. r(3).
882: 3. q(U,V) :- {U+V = 5}.
883: \end{verbatim}
884:
885: \ee
886: The corresponding annotated proof tree for the goal $p(X,Y)$
887: is presented in Figure \ref{annot1}, where the actual positions have been
888: replaced
889: by I (the input positions) and by O (the output positions):
890:
891: \begin{figure}[h]
892: \begin{center}
893: \epsfbox{skep20.eps}
894: \caption{The annotated proof tree for Example 5}
895: \label{annot1}
896: \end{center}
897: \end{figure}
898:
899: The annotation reflects groundness propagation during
900: the computation, as discussed below.
901: The variables $X$ and $Y$ of $p(X,Y)$ are annotated as output, since they are
902: ground at success of $p$, and $p(X,Y)$ is a head atom. For the same reason the
903: argument of the fact $r(3)$ in node 2 is annotated as output.
904: The variable $U$ in the first argument of the predicate $q(U,V)$ in node 3 is
905: ground at call, so it is annotated as input, while $V$ is ground at success of
906: $q$ so it
907: is annotated as output.
908:
909: % Having input/output information for the head predicates
910: %in a proof tree, we can extend it in a certain way to the body predicates. For
911: %example the variable $X$ of predicate $r(X)$ in the body of node 1 is
912: %annotated
913: %to Input, since this is a body predicate that became ground at success. This
914: %is
915: %clear from the fact that node 2 is a child of node 1, and $U$ is annotated to
916: %Output in $r(U)$. \\
917: %In \cite{Mal98} we defined rules for extending the annotation over the whole
918: %proof tree. \\
919:
920: In a CLP program groundness of a position depends generally on
921: the used constraint solver.
922: % {\bf Also the semantics of specific constraints may identify some constraint
923: %positions as inputs or outputs.
924: Monitoring the execution, also in this case, we are able to annotate
925: certain positions as inputs or outputs.
926: For example the $indomain(X)$ constraint
927: of CHIP instantiates $X$ to a value in its domain, so that $X$ is an input
928: position.
929: Rational solvers can usually solve linear equations. For example in the
930: rational constraint $Y=2*X+Z$, $X$ can be annotated input if $Y$
931: an $Z$ are output.
932:
933: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
934:
935: \subsection{Directional slicing of derivation trees}
936:
937:
938:
939: Having input/output information for positions of a derivation tree,
940: we then add directions to its dependence graph. The following definition
941: describes how it can be achieved.
942:
943: \bd {\bf Directed Dependency Graph of a Proof Tree} \\
944: Let $T$ be a proof tree, $T_G = (TreePos(T), \sim _T)$
945: its proof tree dependence graph,
946: then the directed dependence graph of $T(P)$ can be defined as: \\
947: $T_{DG} = (TreePos(T), \rightarrow_{T})$, where:
948: \begin{itemize}
949: \item $\alpha \rightarrow _{T(G)} \beta$ if
950: $\alpha \sim _{T (G)} \beta $ is a transition edge,
951: $\alpha$ is an output position and $\beta$ is an input
952: position
953: \item $\alpha \rightarrow _{T(G)} \beta$
954: if $\alpha \sim _{T(G)} \beta $ is a local edge,
955: $\alpha$ is an input position and $\beta$ is an output position
956: \item $\alpha \rightarrow _{T(G)} \beta$
957: and $\beta \rightarrow _{T(G)} \alpha$
958: in every other case when $\alpha \sim _{T(G)} \beta$
959: \end{itemize}
960: \ed
961:
962: From the definition of $\rightarrow_{T(G)}$
963: assuming correctness
964: of the annotation we find that if $\alpha$ is a position
965: of $X$ in $T$ and it is annotated as input or as output then $C(T)$
966: binds $X$ to a single value. This value is determined
967: by the constraints connected with those positions that are in the set
968: $\{\beta | {\beta} \rightarrow^*_{T(G)} \alpha\}$. Thus we have:
969:
970:
971:
972: \begin{prop}
973: $\{\beta | {\beta} \rightarrow ^*_{T(G)} \alpha\}$ is a slice
974: of $T$ with respect to $\alpha$.
975: \end{prop}
976:
977:
978: These slices are usually more precise than in the case when the groundness
979: information is not used.
980:
981: %By using directed dependency graphs obtain more precise slices
982: %in numerous cases.
983:
984: %The annotation inference rules used for derivation trees
985: %are not directly applicable to programs.
986: The concept of directed dependency graph can be extended
987: to programs and used for static slicing. This requires good
988: methods for static groundness analysis to infer annotations
989: for program positions. Some suggestions for that can be
990: found in \cite{Mal98}.
991:
992:
993:
994:
995:
996:
997:
998:
999:
1000:
1001:
1002:
1003:
1004:
1005:
1006: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1007:
1008:
1009: \section{A Prototype Implementation }
1010:
1011: We developed a prototype in SICStus Prolog for dynamic backward slicing
1012: of constraint logic programs written in SICStus.
1013: The tool handles a realistic subset of Prolog,
1014: including constructs such as {\em cut, if-then} and {\em or}.
1015: The {\em inputs} of the slicing system are: the source code,
1016: a test case (a goal) and (after the execution)
1017: the execution traces given by the Prolog interpreter.
1018: From this information the
1019: {\em Directed Proof Tree Dependence Graph} (Definition 7)
1020: may be constructed.
1021: The following three types of slice algorithms were implemented
1022: (see Figure \ref{slice4}):
1023: \begin{enumerate}
1024: \item {\bf Proof tree slice} \\
1025: In this case the user chooses an argument position of the created Proof Tree,
1026: and the slice is constructed with respect to this proof tree position
1027: using the Directed Proof Tree Dependency Graph (see Definition 7).
1028: This kind of slice is useful when the user is interested in the data dependences
1029: of the Proof Tree.
1030: \item {\bf Dynamic slice} \\
1031: This case is very similar to 1, but the constructed slice
1032: of the Proof Tree is mapped back to the program.
1033: This is the
1034: classic dynamic slice approach \cite{KAR97}, as in the case
1035: of procedural languages.
1036: So this slice provides a slice of the program.
1037: \item {\bf Program position slice} \\
1038: In this case the user selects a program position. The system provides all
1039: instances of this program position in the Proof Tree, creates
1040: the proof tree slice for every instance, then the union of these
1041: slices are constructed and mapped back to the program. So this
1042: algorithm also provides a slice of the program,
1043: which shows all dependences of a program position for a given test case.
1044: \end{enumerate}
1045: \begin{figure}[h]
1046: \begin{center}
1047: \epsfbox{skep21.eps}
1048: \caption{Proof Tree, Dynamic and Program Position Slice.}
1049: \label{slice4}
1050: \end{center}
1051: \end{figure}
1052: A graphical interface draws the proof tree (see Figure 7), marked with different
1053: colored nodes that are in the Proof tree slice, and
1054: in the case of a dynamic slice and program position slice the
1055: corresponding slice of the program is highlighted. The label of the nodes
1056: identify the nodes of the proof tree including the name of the predicate and the
1057: annotation of its arguments.
1058:
1059:
1060: In the implementation we applied a very simple annotation technique:
1061: the inherited positions were those which were ground at the time of calling,
1062: while synthesized positions were those which were ground at success.
1063: This method provides precise annotation, because we continuously extract information
1064: from the actual state of the constraint store. However, in the current
1065: implementation slicing can only be done on argument positions. If an argument
1066: includes several variables it is not possible to distinguish between them,
1067: which makes
1068: the constructed slice "less precise" (compared to the minimal slice).
1069: So, our aim is to improve the
1070: existing implementation, extend it to variable positions.
1071:
1072:
1073: In the present version of the tool
1074: the sliced proof tree corresponds to the first
1075: success branch of the SLD tree. As the proof tree slice definition
1076: is quite general, there is no real difficulty in applying the
1077: technique to all success branches of SLD tree.
1078: The extension to failure branches is discussed in
1079: \cite{Deb99}. Currently we are working on an implementation of these extensions.
1080:
1081:
1082: %To obtain real experiments of the feasibility of using slicing
1083: Systematic slicing experiments were performed on a number
1084: of constraint logic programs (written in SICSTus Prolog).
1085: Each of them was executed with a number of test inputs
1086: to collect data about the relative size of a slice with respect
1087: to the proof tree, depending on the choice of the position.
1088: %Metrics about each individual slice were output for analysis.
1089: The selected application programs \cite{JaM, Mar98} had different
1090: language structures (use of cut, or, if-then, databases, compound
1091: constraint), and were of different size.
1092:
1093:
1094: The summarized data of the test results on proof tree slicing
1095: is listed in {\em Table 1}.
1096: The comparison of the three kind of slices with respect to the number of nodes
1097: are shown in Figure \ref{slices}.
1098:
1099: \begin{table}[!h]
1100: {\tiny
1101: \begin{tabular}{|ll|c|c|c|lr|lr|} \hline
1102: &PROGRAM&NUMBER OF&NUMBER OF &NUM. OF COMP-& AVERAGE &SIZE OF&AVERAGE& SIZE OF \\
1103: &&CLAUSES&TEST CASES&UTED SLICES&THE PROOF& TREE&SLICES \\ \hline
1104: & & & & & NODE & ARG. POS.& NODE & ARG.POS.\\ \hline
1105:
1106: 1 & LIGHTMEAL & 11 & 1 & 17 & 9 & 15 & 44.64 \% & 41.17 \% \\ \hline
1107: 2 & CIRC & 5 & 2 & 139 & 33.35 & 54.09 & 35.14 \% & 54.44 \% \\ \hline
1108: 3 & SUM & 6 & 4 & 626 & 80.26 & 120.77 & 30.46 \% & 49.34 \% \\ \hline
1109: 4 & FIB & 4 & 6 &1349 &399.57 & 533.51 & 7.56 \% & 8.53 \% \\ \hline
1110: 5 & SCHEDULING & 20 & 1 & 575 & 134 & 390 & 51.21 \% & 71.66 \% \\ \hline
1111: 6 & PUZZLE & 30 & 2 &1363 &227.57 & 607.82 & 19.05 \% & 14.93 \% \\ \hline
1112: \end{tabular}
1113: }
1114: \caption{Proof Tree Slice}
1115: \end{table}
1116:
1117:
1118: \begin{figure}[h]
1119: \begin{center}
1120: \epsfbox{dia2.eps}
1121: \caption{Comparison of the Proof Tree Slice, Dynamic Slice and the Program Position Slice.}
1122: \label{slices}
1123: \end{center}
1124: \end{figure}
1125:
1126:
1127:
1128: \begin{figure}[h]
1129: \begin{center}
1130: \epsfbox{gr4.eps }
1131: \caption{Displayed program and proof tree slices.}
1132: \label{elso1 kep}
1133: \end{center}
1134: \end{figure}
1135:
1136:
1137: %There are few things that should be observed from these results:
1138: It should be mentioned that
1139: the average slice size (in percent) in these experiments
1140: had no correlation with the size of the program.
1141: The average slice size was $32\%$ of
1142: the number of executed nodes and $40\%$ of the executed argument positions.
1143:
1144:
1145: The intended application of our slicing method is
1146: to support debugging of constraint programs.
1147: A bug in a program shows up as a symptom during the
1148: execution of the program on some input.
1149: This means that in some computation step
1150: (i.e. in some derivation tree)
1151: a variable of the program is bound in a way
1152: that does not conform to user expectations.
1153: A slice of the derivation tree with respect to this occurrence
1154: of the variable can be mapped into the text of the program
1155: and will identify a part of the program
1156: where the undesired binding was produced.
1157: This would provide a focus for debugging,
1158: whatever is the debugging technique used.
1159: Intersection of the slices produced for different
1160: runs of the buggy program may further narrow the focus.
1161:
1162: In particular, our slicing technique can be combined
1163: with Shapiro's algorithmic debugging \cite{Shap},
1164: designed originally for logic programs.
1165: As shown in \cite{IDTS} the slice of a derivation tree
1166: of a logic program may reduce the number of queries of
1167: algorithmic debugger.
1168: This technique can also be applied to
1169: the case of algorithmic debugging of CLP programs
1170: discussed in [19].
1171:
1172:
1173:
1174:
1175:
1176:
1177:
1178:
1179:
1180:
1181:
1182: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1183:
1184: \section{Related Work}
1185:
1186: Program slicing has been widely studied for imperative programs
1187: \cite{GBF, KAM93, HR92, KAR97, Reps94}. To our knowledge only
1188: a few papers have dealt with the problem of slicing logic programs,
1189: and slicing of
1190: constraint logic programs has not been investigated till now.
1191:
1192: We provided a theoretical basis for the slicing of proof
1193: trees and programs starting from a semantic definition of the
1194: constraint set dependence. This applies as well to the special case
1195: of logic programs (the Herbrand domain). In particular it justifies
1196: the slicing technique of Gyim\'othy and Paakki \cite{Gyi}
1197: developed to reduce the number of queries for algorithmic debugger
1198: and makes it possible to extend the latter to the general case of CLP.
1199: The directional slicing of Section 5 is an extension of this
1200: technique to the general case of CLP.
1201:
1202:
1203: Schoening and Ducass\'e \cite{Duc} proposed a backward slicing
1204: algorithm for Prolog which produces executable slices. For a target
1205: Prolog program they defined a slicing criterion which consists of a
1206: goal of $P$ and a set of argument positions $P_a$, along with a slice
1207: $S$ as a reduced and executable program derived from $P$.
1208: An executable slice is usually less precise but it may be used
1209: for additional test runs. Hence the objectives of their work are somewhat
1210: different from ours, and
1211: their algorithm is applicable to a limited subset of Prolog
1212: programs.
1213:
1214: In \cite{Zhao3} Zhao et al defined some static and dynamic
1215: slices of concurrent logic programs called literal dependence nets.
1216: They presented a new program representation
1217: called the argument dependence net for concurrent logic programs to
1218: produce static slices at the argument level. There are some
1219: similarities between our slicing techniques and Zhao's methods,
1220: since we also rely on some dependency relations. However,
1221: the focus of our work has been on CLP not on concurrent logic programs,
1222: and our main aim has been a declarative formulation of the slicing problem
1223: whic provides a clear reference basis for
1224: proving the correctness of the proposed slicing methods.
1225:
1226:
1227: The results of the ESPRIT Project DiSCiPl \cite{DHM00} show the importance
1228: of visualisation in the debugging of constraint programs. Our tool
1229: provides a rudimentary visualisation of the sliced proof tree.
1230: It was pointed out by Deransart and Aillaud \cite{DA00}
1231: that abstraction techniques
1232: are needed in the visualisation of the search space.
1233: Program position slicing, if applied
1234: to all branches of the SLD-tree, provides
1235: yet another abstraction of the search space.
1236:
1237:
1238: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1239: \section{Conclusions}
1240:
1241:
1242: The paper offers a precise declarative formulation of the slicing problem
1243: for CLP. It also gives a solid reference basis
1244: for deriving various techniques of slicing CLP programs
1245: in general and for logic programs treated as a special case.
1246: This technique was illustrated by deriving
1247: the directional data flow slicing technique for CLP,
1248: which is an extension of \cite{Gyi} applied to CLP. As a side effect, the latter, which was presented
1249: in somewhat pragmatic setting, obtains a theoretical
1250: justification.
1251:
1252: The paper presents also a prototype slicing tool using
1253: this technique. The experiments with the tool show that
1254: the obtained slices were quite precise in some cases,
1255: and on average provided a substantial reduction of the
1256: program.
1257:
1258: The future work will focus on the application
1259: of slicing techniques to
1260: constraint programs debugging. Two aspects being considered.
1261: Firstly, in the manual debugging of CLP programs it is necessary
1262: to support user with a tool that facilitates the understanding
1263: of the program. We believe that a future version of our slicer
1264: equipped with suitable visualisation features could
1265: be very suitable for this purpose.
1266: Secondly, the slicing of a derivation tree
1267: can often reduce the number of queries in
1268: algorithmic debugging of logic programs \cite{Shap}.
1269: (The algorithmic debugging technique has been extended
1270: to CLP \cite{TF00}).
1271:
1272: As a first step in this direction we are going to integrate
1273: our CLP slicing
1274: tool with the IDTS algorithmic debugger \cite{IDTS}, originally
1275: developed for pure logic programs.\vspace{1.5cm}
1276:
1277: {\bf Acknowledgments} \\
1278:
1279: The work of the first and second authors was supported by the grants
1280: OTKA T52721 and IKTA 8/99.
1281:
1282:
1283:
1284:
1285:
1286:
1287:
1288:
1289: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1290:
1291: \bibliographystyle{plain}
1292:
1293: \begin{thebibliography}{99}
1294:
1295:
1296:
1297:
1298:
1299:
1300: %\bibitem{BPM93} J. Boye, J. Paakki, J. Maluszy\'nski: Synthesis
1301: %of Directionality Information for Functional Logic Programs, {\em In Proceedings
1302: %of Third International Workshop on Static Analysis}, LNCS 724, Springer Verlag,
1303: %pages 165-177, Padova, 1993.
1304:
1305:
1306: \bibitem{DA00} P. Deransart and C. Aillaud: {\em Towards a Language
1307: for CLP Choice-tree Visualisation}, In:
1308: P.~Deransart, M.~Hermenegildo, and J.~Ma{\l}uszy\'nski, (editors),
1309: {\em Analysis and Visualization Tools for Constraint Programming}, LNCS.
1310: Springer Verlag, 2000 (to appear).
1311:
1312: \bibitem{DHM00}
1313: P.~Deransart, M.~Hermenegildo, and J.~Ma{\l}uszy\'nski, (editors),
1314: {\em Analysis and Visualization Tools for Constraint Programming}, LNCS.
1315: Springer Verlag, 2000 (to appear).
1316:
1317: \bibitem{DM93} P. Deransart and J. Ma{\l}uszy{\'n}ski:
1318: {\em A grammatical view of logic programming}. The MIT Press 1993.
1319:
1320: %\bibitem{Duc95} M. Ducass\'e and J. Noy\'e: Logic Programming Environments: Dynamic Program Analysis and Debugging, {\em Journal of Logic Programming },vol. 19/20, pages 351-384, May/July 1994.
1321:
1322: \bibitem{GBF} T. Gyim\'othy, \'A. Besz\'edes and I. Forg\'acs: An Efficient
1323: Relevant Slicing Method for Debugging. {\em In Proceedings of 7th European
1324: Software Engineering Conference (ESEC'99)}, LNCS 1687 Springer Verlag,
1325: pages 303-322, Toulouse, France, September 1999.
1326:
1327: \bibitem{Gyi} T. Gyim\'othy and J. Paakki: Static Slicing of Logic
1328: Programs. {\em In Proceedings of Second International Workshop on Automated and
1329: Algorithmic Debugging (AADEBUG'95)}, pages 85-105, Saint Malo, France, May 1995.
1330:
1331: \bibitem{Deb99} Harmath L., Szil\'agyi Gy., Gyim\'othy, T., Csirik J.: Dynamic Slicing of Logic Programs. {\em Program Analysis and verification, Fenno-Ugric
1332: Symposium (FUSST'99)}, pages 101-113, Tallin, Estonia 1999.
1333:
1334: \bibitem{Reps94} S. Horwitz, T. Reps and D. Binkley: Interprocedural Slicing Using Dependence Graphs. {\em In Proceedings of ACM Transactions on Programming Languages and Systems 12}, pages 26-61, 1990.
1335:
1336: \bibitem{HR92} S. Horwitz and T. Reps: The Use of Program Dependence
1337: Graphs in Software Engineering. {\em In Proceedings of the Fourteenth International
1338: Conference on Software Engineering }, pages
1339: 392-411, Melbourne, Australia, May 1992.
1340:
1341: \bibitem{JaM} J.Jaffar and M.J.Maher: Constraint logic programming: A
1342: survey.
1343: {\em The Journal of Logic Programming} 19/20:503-582, 1994.
1344:
1345: \bibitem{KAM93} M. Kamkar and P. Fritzson: Evaluation of Program
1346: Slicing tools. {\em In 2nd International Workshop on Automated and
1347: Algorithmic Debugging (AADEBUG'95) }, pages 51-69, Saint Malo, France,
1348: May 1995.
1349:
1350: \bibitem{IDTS} G. K\'okai, L Harmath, T. Gyim\'othy: Algorithmic Debugging and
1351: Testing of Prolog Programs, {\em In Proceedings of the Fourteenth International
1352: Conference on Logic Programming, Eighth Workshop on Logic Programming
1353: Environments (ICLP'97)}, pages 14-21, Leuven, Belgium, September 1997.
1354:
1355: \bibitem{KAR97} B. Korel and J. Rilling: Application of Dynamic
1356: Slicing in Program Debugging. {\em In Proceedings of the Third
1357: International Workshop on Automatic Debugging (AADEBUG '97)},
1358: Link\"oping, pages 43-59, Sweden, May 1997.
1359:
1360: \bibitem{Mar98} K. Marriott and P.J. Stuckey: Programming with Constraints.
1361: An Introduction. The MIT Press, 1998
1362:
1363:
1364:
1365:
1366:
1367:
1368: %\bibitem{STE98}C. Steindl: Intermodular Slicing of Object-oriented
1369: %Programs. {\em In International Conference on Compiler Construction
1370: %(CC'98)}, 1998.
1371:
1372: \bibitem{Duc} S. Schoening and M. Ducass\'e: A Backward Slicing
1373: Algorithm for Prolog. {\em In Proceedings of Third International Static Analysis Symposium SAS'96}, LNCS 1145, 317-331, Springer-Verlag 1996.
1374:
1375:
1376: \bibitem{Shap} E. Shapiro: Algorithmic Debugging. {\em The MIT
1377: Press}, 1983.
1378:
1379: \bibitem{Mal98} Gy. Szil\'agyi, T. Gyim\'othy, J. Maluszy\'nski:
1380: Slicing of Constraint Logic Programs. Technical Report, {\em Link\"oping University
1381: Electronic Press} 1998/020, {\em www.ep.liu.se/ea/cis/1998/002}.
1382:
1383:
1384:
1385: \bibitem{TF00} A. Tessier and G. F{\` e}rrand. {\em Declarative Diagnosis in
1386: the CLP Scheme}, In:
1387: P. Deransart, M. Hermenegildo, and J.~Ma{\l}uszy\'nski, (editors),
1388: {\em Analysis and Visualization Tools for Constraint Programming}, LNCS.
1389: Springer Verlag, 2000 (to appear).
1390:
1391: \bibitem{Tip} F. Tip: A survey of Program Slicing Techniques. {\em
1392: Journal of Programming Languauges}, Vol.3., No.3, pages 121-189,
1393: September, 1995.
1394:
1395:
1396: %\bibitem{We} M. Weiser: Program Slicing.
1397: %{\em IEEE Transactions on Software Engineering,} pages 352-357, July
1398: %1984.
1399:
1400: \bibitem{Zhao3} J. Zhao, J. Cheng and K. Ushijima: Slicing Concurrent
1401: Logic Programs. {\em In Proceedings of Second Fuji International Workshop on
1402: Functional and Logic Programming}, pages 143-162, 1997.
1403:
1404:
1405: \end{thebibliography}
1406: \end{document}
1407:
1408: