Contents

 

 
Computational Logic
 
Developing Programs with a Logic Programming System
 

System used in the Course

Using the Ciao System

 

 
The following slides are intended as a very brief introduction to some aspects of running programs on a logic programming system. It is highly encouraged to also look at the corresponding parts of the Ciao manuals regarding the use of the compiler, top-level, debuggers, environment, module system, etc.  

The Classical Top-Level Shell

Program Load in the Top-Level Shell

Top Level Interaction Example

Defining a module, its exports, and packages to load

Pure modules and search rule selection

(ISO-)Prolog modules

Defining modules and exports (Contd.)

Importing from another module

Tracing an Execution with The “Byrd Box Model”

Debugging Example

Ciao 1.XX ...
?- use_module('/home/logalg/public_html/slides/lmember.pl').
yes
?- debug_module(lmember).
{Consider reloading module lmember}
{Modules selected for debugging: [lmember]}
{No module is selected for source debugging}
yes
?- trace.
{The debugger will first creep -- showing everything (trace)}
yes
{trace}
?- 

Debugging Example (Contd.)

?- lmember(X,[a,b]).
   1  1  Call: lmember:lmember(_282,[a,b]) ? 
   1  1  Exit: lmember:lmember(a,[a,b]) ? 
X = a ? ;
   1  1  Redo: lmember:lmember(a,[a,b]) ? 
   2  2  Call: lmember:lmember(_282,[b]) ? 
   2  2  Exit: lmember:lmember(b,[b]) ? 
   1  1  Exit: lmember:lmember(b,[a,b]) ? 
X = b ? ;
   1  1  Redo: lmember:lmember(b,[a,b]) ? 
   2  2  Redo: lmember:lmember(b,[b]) ? 
   3  3  Call: lmember:lmember(_282,[]) ? 
   3  3  Fail: lmember:lmember(_282,[]) ? 
   2  2  Fail: lmember:lmember(_282,[b]) ? 
   1  1  Fail: lmember:lmember(_282,[a,b]) ? 
no

Options During Tracing

h Get help — gives this list (possibly with more options)
c Creep forward to the next event
Advances execution until next call/exit/redo/fail
intro (same as above)
s Skip over the details of executing the current goal
Resume tracing when execution returns from current goal
l Leap forward to next “spypoint” (see below)
f Make the current goal fail
This forces the last pending branch to be taken
a Abort the current execution
r Redo the current goal execution
very useful after a failure or exit with weird result
b Break — invoke a recursive top level

Spypoints (and breakpoints)

Debugger Modes

Creating Executables