

<!DOCTYPE html>
<!-- Server: sfs-forge-3 -->


    

















<html lang="en" class="no-js">
<head>
    <meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
    <title>
  XSB / Src  (SVN)-old /
  [r8472]
  /trunk/XSB/docs/userman/debugging.tex
</title>
    

<meta name="viewport" content="width=1100">


<link rel="icon" sizes="180x180" href="https://a.fsdn.com/con/img/sandiego/logo-180x180.png" type="image/png">
<link rel="icon" sizes="any" href="https://a.fsdn.com/con/img/sandiego/svg/originals/sf-icon-orange-no_sf.svg" type="image/svg+xml">
<link rel="apple-touch-icon" sizes="180x180" href="https://a.fsdn.com/con/img/sandiego/logo-180x180.png">
<link rel="mask-icon" href="https://a.fsdn.com/con/img/sandiego/svg/originals/sf-icon-orange-no_sf.svg" color="#FF6600">


<script src="https://a.fsdn.com/allura/nf/1753456284/_ew_/theme/sftheme/js/sftheme/cmp2.js"></script>






    
    
    
    
    
    
    
    
    <link rel="stylesheet" href="https://a.fsdn.com/con/css/lato.css?">


<script>
if (!window.SF) { window.SF = {}; }
SF.sandiego = false;
SF.sandiego_chrome = true;
SF.cdn = "https://a.fsdn.com/con";
SF.fpid = '40425d16-b155-40c1-a775-0b52becd008c';
SF.billboard_route = '/software/product/$slug/';
</script>
    
        <!-- ew:head_css -->

    
        <link rel="stylesheet"
                type="text/css"
                href="https://a.fsdn.com/allura/nf/1753456284/_ew_/_slim/css?href=allura%2Fcss%2Fforge%2Fhilite.css%3Ballura%2Fcss%2Fforge%2Ftooltipster.css"
                >
    
        <link rel="stylesheet"
                type="text/css"
                href="https://a.fsdn.com/allura/nf/1753456284/_ew_/allura/css/font-awesome.min.css"
                >
    
        <link rel="stylesheet"
                type="text/css"
                href="https://a.fsdn.com/allura/nf/1753456284/_ew_/theme/sftheme/css/forge.css"
                >
    
        
<!-- /ew:head_css -->

    
    
        <!-- ew:head_js -->

    
        <script type="text/javascript" src="https://a.fsdn.com/allura/nf/1753456284/_ew_/_slim/js?href=allura%2Fjs%2Fjquery-3.6.0.min.js%3Ballura%2Fjs%2Fjquery.cookie-1.4.1.js%3Btheme%2Fsftheme%2Fjs%2Fsftheme%2Fshared_head.js%3Btheme%2Fsftheme%2Fjs%2Fsftheme%2Ftypescript%2Fcompliance.js"></script>
    
        
<!-- /ew:head_js -->

    

    
        <style type="text/css">
            /* make URL &amp; Project custom fields in support tickets not get hidden as much */
.project-forge.mountpoint-site-support .view_holder .grid-4:nth-child(5),
.project-forge.mountpoint-site-support .view_holder .grid-4:nth-child(6) {
  overflow: visible;
  font-size: 22px;
  width: 340px;
  line-height: 1;
  margin-bottom: 5px;
}
.project-forge.mountpoint-site-support .view_holder .grid-4:nth-child(5) label, .project-forge.mountpoint-site-support .view_holder .grid-4:nth-child(6) label {
  font-size: 14px;
}
        </style>
    
    
    <link rel="alternate" type="application/rss+xml" title="RSS" href="/p/xsb/src/feed.rss"/>
    <link rel="alternate" type="application/atom+xml" title="Atom" href="/p/xsb/src/feed.atom"/>
    <style type="text/css">
        #access_urls .btn-set {
            
            min-width: 14em;
        }
    </style>

    <style>.XAlDDrcKxwqDCsrDgKWMMOlcMONcKNcFjDqcOhVA {
        display: none
    }</style>

    
    
    
        <link rel="canonical" href="https://sourceforge.net/p/xsb/src/8472/tree/trunk/XSB/docs/userman/debugging.tex" />
    


    

<script>
    var data = {hem: null };
    bizx.uids.gatherAndClean(data);
</script>



<script>
    function initPiwik(){
      var _paq = window._paq = window._paq || [];
      _paq.push(['trackPageView', document.title, {
            dimension1: 'xsb',
            dimension2: 'svn'
      }]);
      _paq.push(['enableLinkTracking']);
      
          _paq.push(['enableHeartBeatTimer']);
      
      (function() {
        var u="//analytics.slashdotmedia.com/";
        _paq.push(['setTrackerUrl', u+'sf.php']);
        _paq.push(['setSiteId', 39]);
        
        var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
        g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'sf.js'; s.parentNode.insertBefore(g,s);
      })();
    }
    bizx.cmp.ifConsent({ purposes: ['storage', 'measurement'], vendors: 'sdm'}, initPiwik);
</script>






<!-- Hubspot tracking -->






 <script>
    $(function() {
        bizx.cmp.ifConsent({ purposes: 'all' , vendors: 'narrative'}, function() {
            var current_time = (new Date()).getTime();
            let imageUrl = "https://io.narrative.io/?companyId=2440&id=first_party%3A40425d16-b155-40c1-a775-0b52becd008c&id=site_name%3Asourceforge.net&id=url%3A%2Fp%2Fxsb%2Fsrc%2F8472%2Ftree%2Ftrunk%2FXSB%2Fdocs%2Fuserman%2Fdebugging.tex&id=pagetitle%3A%24PAGE_TITLE&id=vertical%3AOpen+Source+Software&id=product%3AXSB";
            imageUrl = imageUrl.replace(encodeURIComponent("$PAGE_TITLE"), document.title);  

            imageUrl = URL.parse(imageUrl);
            let hem = bizx.uids.getHem();
            if (hem) {
                imageUrl.searchParams.append('id', 'hem:' + hem);
            }
            imageUrl.searchParams.append('rand', current_time);

            var image = new Image();
            image.src = imageUrl.toString();
            image.style.display = "none";
            image.style.height = 0;
            image.style.width = 0;
            document.body.appendChild(image);
        });
    });
</script>



</head>

<body class="
body_class sandiego_chrome  legacy_chrome  l-allow-natural-width 
" id="forge">

    
        <!-- ew:body_top_js -->

    
        
<!-- /ew:body_top_js -->

    





<div class="off-canvas position-right" id="offCanvas" data-off-canvas>
    <!-- Menu -->
    <ul class="header-nav-menulist">
        <li class="highlight search">
            
            
                
            
            
    <form method="get" action="/directory/" class="m-search-form">
    
        <input type="text" placeholder="Search for software or solutions" autocomplete="off" name="q" >
        
        <label >
            <input type="submit" class="bt" value="">
            


<svg  data-name="search" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1216 832q0-185-131.5-316.5t-316.5-131.5-316.5 131.5-131.5 316.5 131.5 316.5 316.5 131.5 316.5-131.5 131.5-316.5zm512 832q0 52-38 90t-90 38q-54 0-90-38l-343-342q-179 124-399 124-143 0-273.5-55.5t-225-150-150-225-55.5-273.5 55.5-273.5 150-225 225-150 273.5-55.5 273.5 55.5 225 150 150 225 55.5 273.5q0 220-124 399l343 343q37 37 37 90z"/></svg>
        </label>
    </form>
        </li>
        
        <li class="highlight"><a href="/auth/">Join/Login</a></li>
        
        <li><a href="/software/">Business Software</a></li>
        <li><a href="/directory/">Open Source Software</a></li>
        <li><a  href="/software/vendors/" title="For Vendors">For Vendors</a></li>
        <li><a href="/blog/" title="Blog">Blog</a></li>
        <li><a href="/about">About</a></li>
        <li><a id="header-nav-more" data-toggle="header-nav-more header-nav-more-content" data-toggler=".toggled">More</a></li>
        <li>
            <ul id="header-nav-more-content" class="toggled" data-toggler=".toggled">
                
    

    
    
        <li><a href="/articles/">Articles</a></li>
    
    

    
 
                
                <li><a href="/create">Create</a></li>
                
                <li><a href="https://sourceforge.net/articles/category/sourceforge-podcast/">SourceForge Podcast</a></li>
                
                    <li><a href="https://sourceforge.net/p/forge/documentation/Docs%20Home/">Site Documentation</a></li>
                
                <li><a href="/user/newsletters">Subscribe to our Newsletter</a></li>
                <li><a href="/support">Support Request</a></li>
            </ul>
        </li>
    </ul>
</div>
<div class="off-canvas-content" data-off-canvas-content>

    




<script>
    SF.linkout_icon = '<svg  data-name="sf-linkout-icon" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 300 300" style="enable-background:new 0 0 300 300;" xml:space="preserve"><polygon class="st0" points="243.2,243.2 56.8,243.2 56.8,56.8 123,56.8 123,9 9,9 9,291 291,291 291,179.4 243.2,179 "/><polygon class="st0" points="128.5,213 155,186.5 176,165.5 206.7,196.3 235.5,132.5 248.9,102.6 290.6,9.8 291,9 290.6,9.2 197.4,51.1 169.1,63.8 103.7,93.3 137,126.5 115.9,147.5 89.5,174 "/></svg>';
</script>


<div class="l-header-nav  sandiego">

    <section class="sandiego l-header-nav-top show-for-large">
        <div class="row">
            <a href="/" title="Home" class="sf-logo">
                
    
    <img src="https://a.fsdn.com/con/images/sandiego/sf-logo-full.svg"  alt="SourceForge logo" class="sf-logo-full"/>
            </a>
            <nav class="links">
                
                    <a href="/user/newsletters" title="Subscribe to our newsletter"><span class="newsletter-icon">


<svg  data-name="mmSF_11mail" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 42 42" enable-background="new 0 0 42 42" xml:space="preserve"><path fill="#FFFFFF" d="M0,6v30h42V6H0z M24.2,21.2c-0.8,0.8-2.3,2-3.2,2c-0.9,0-2.4-1.2-3.2-2L5.8,9.7h30.3L24.2,21.2z M13.7,21l-9.9,9.4V11.6L13.7,21z M15.7,23L15.7,23c0.5,0.5,2.9,2.9,5.3,2.9c2.4,0,4.8-2.4,5.2-2.8l0.1-0.1l9.8,9.4H5.8L15.7,23z M28.3,21l9.9-9.5v18.9L28.3,21z"/></svg></span></a>
                
                <a href="/software/vendors/" title="For Vendors">For Vendors</a>
                
                
                    <a href="/support" title="Help">Help</a>
                    <a href="/create/" title="Create">Create</a>
                

                
                <a href="/user/registration" title="Join" >Join</a>
                <a href="/auth/" title="Login">Login</a>
                
            </nav>
        </div>
    </section>

    <section class="sandiego l-header-nav-top hide-for-large">
        <div class="row">
            <a href="/" title="Home" class="sf-logo">
                
    
    <img src="https://a.fsdn.com/con/images/sandiego/sf-logo-full.svg"  alt="SourceForge logo" class="sf-logo-full"/>
            </a>
            <div class="title-bar-right">
                <button type="button" aria-label="Toggle Main Menu" class="menu-icon" data-toggle="offCanvas"></button>
            </div>
        </div>
    </section>
    <section class="sandiego l-header-nav-bottom">
        <nav class="row">
            <a href="/" title="Home" class="sf-logo">
                
    
    <img src="https://a.fsdn.com/con/images/sandiego/sf-logo-full.svg"  alt="SourceForge logo" class="sf-logo-full"/>
            </a>
            <div class="links">
                
    
        <div class="nav-dropdown">
            <a href="/software/">Business Software</a>
            
        </div>
        <div class="nav-dropdown">
            <a href="/directory/" title="Browse">Open Source Software</a>
            
        </div>
        <div class="nav-dropdown">
            <a href="https://sourceforge.net/articles/category/sourceforge-podcast/">SourceForge Podcast</a>
        </div>
        <div class="nav-dropdown">
            <a>Resources</a>
            <ul class="nav-dropdown-menu">
                  <li><a href="/articles/">Articles</a></li>
                  
                  <li><a href="/software/case-studies/">Case Studies</a></li>
                  
                  <li><a href="/blog/">Blog</a></li>
            </ul>
        </div>
    

                <div class="dev-menu-when-stuck">
                    Menu
                    <ul class="dev-menu-dropdown header-nav-menulist">
                        <li><a href="/support">Help</a></li>
                        <li><a href="/create">Create</a></li>
                        <li><a href="/user/registration/" title="Join" >Join</a></li>
                        <li><a href="/auth/" title="Login">Login</a></li>
                    </ul>
                </div>
                <div class="search-toggle-when-stuck">
                    <a class="search-toggle">
                        


<svg  data-name="search" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1216 832q0-185-131.5-316.5t-316.5-131.5-316.5 131.5-131.5 316.5 131.5 316.5 316.5 131.5 316.5-131.5 131.5-316.5zm512 832q0 52-38 90t-90 38q-54 0-90-38l-343-342q-179 124-399 124-143 0-273.5-55.5t-225-150-150-225-55.5-273.5 55.5-273.5 150-225 225-150 273.5-55.5 273.5 55.5 225 150 150 225 55.5 273.5q0 220-124 399l343 343q37 37 37 90z"/></svg>
                    </a>
                </div>
            </div>

            <div class="search">
                
                
    
    
        <div class="main-nav-link">
            
            
            <a href="https://www.avast.com/lp-free-av?full_trSrc=mmm_srf_dlp_008_406_a&amp;utm_medium=referral&amp;utm_source=sourceforge&amp;utm_campaign=srf_dlp_008_406_a:site_banner" rel="nofollow" target="_blank" id="main-nav-badge-link" data-label="avastjuly">
                <img src="https://a.fsdn.com/con/assets/maxnav/sourceforge/ai-protection-32-75dd98b2.png"  srcset="https://a.fsdn.com/con/assets/maxnav/sourceforge/ai-protection-75de80f6.png 2x"  alt="" id="main-nav-image"/>
            </a>
        </div>
    


                
                    
                
                
                
                
    <form method="get" action="/directory/" class="m-search-form">
    
    <div class="typeahead__container">
      <div class="typeahead__field">
        <div class="typeahead__query">
        
        <input type="text" placeholder="Search for software or solutions" autocomplete="off" name="q" >
        
        </div>
        
        <label >
            <input type="submit" class="bt" value="">
            


<svg  data-name="search" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1216 832q0-185-131.5-316.5t-316.5-131.5-316.5 131.5-131.5 316.5 131.5 316.5 316.5 131.5 316.5-131.5 131.5-316.5zm512 832q0 52-38 90t-90 38q-54 0-90-38l-343-342q-179 124-399 124-143 0-273.5-55.5t-225-150-150-225-55.5-273.5 55.5-273.5 150-225 225-150 273.5-55.5 273.5 55.5 225 150 150 225 55.5 273.5q0 220-124 399l343 343q37 37 37 90z"/></svg>
        </label>
      </div>
    </div>
    
    </form>
                
            </div>
        </nav>
        
    </section>
    
</div>
    
    
    <div class="notification-on-project-page">
    
        
    
    
    
    </div>
    
    


    <section id="page-body" class=" neighborhood-Projects project-xsb mountpoint-src 

">
        <div id="nav_menu_holder">
            
                
                    
    <div class="sandiego"> 
            
            
            
            
<section class="project-masthead"> 
    
    

    
<div class="backdrop" style="box-sizing: content-box; padding-bottom: 24px"></div>

    <div class="content">
    
        
    <nav id="breadcrumbs" class="breadcrumbs rtl">
        <ul itemscope itemtype="http://schema.org/BreadcrumbList">
            <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
                <a itemprop="item" href="/"><span itemprop="name">Home</span></a>
                <meta itemprop="position" content="1"/>
            </li>
            <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
                <a itemprop="item" href="/directory/"><span itemprop="name">Browse</span></a>
                <meta itemprop="position" content="2"/>
            </li>
            
            
                
                
            
            
                
            
            
                <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
                    <a itemprop="item" href="/p/xsb/"><span itemprop="name">XSB</span></a>
                <meta itemprop="position" content="3"/>
                </li>
            
                <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
                    <span itemprop="name">Src  (SVN)-old</span>
                <meta itemprop="position" content="4"/>
                </li>
            
        </ul>
    </nav>
    
    
    
        
                
                
<div class="overview">
    


<div class="project-icon   " >
    
    
    <img itemprop="image" alt="XSB" title="XSB" 
    
    
    src="https://a.fsdn.com/allura/p/xsb/icon?1368563712"
    /></div>


    
    <div class="title "> 

        <meta itemprop="name" content="XSB"/>
        <h1  >XSB Src  (SVN)-old
        </h1>
        
            
            
          
        
            
            
            <div class="as-h3 brought-by">
                
                Brought to you by:
                
                    <a href="/u/carlandersen/profile/">carlandersen</a>,
                    
                
                    <a href="/u/dwarren/profile/">dwarren</a>,
                    
                
                    <a href="/u/evansbj/profile/">evansbj</a>,
                    
                
                    <a href="/u/kifer/profile/">kifer</a>,
                    
                
                    
                        and <a href="/p/xsb/_members/">3 others</a>
                    
                
            </div>
            
        

        

        
    </div>


    

</div>

                
                
    
  
            
            
        
    </div>
</section>

        </div>
    

                
            
        </div>
        <div id="top_nav" class="">
            
                
<div id="top_nav_admin">
<ul class="dropdown">
  
  
    <li class="">
        <a href="/projects/xsb/" class="tool-summary-32" >
            Summary
        </a>
        
        
    </li>
  
    <li class="">
        <a href="/projects/xsb/files/" class="tool-files-sf-32" >
            Files
        </a>
        
        
    </li>
  
    <li class="">
        <a href="/projects/xsb/reviews/" class="tool-reviews-32" >
            Reviews
        </a>
        
        
    </li>
  
    <li class="">
        <a href="/projects/xsb/support" class="tool-support-32" >
            Support
        </a>
        
        
    </li>
  
    <li class="">
        <a href="/p/xsb/mailman/" class="tool-mailman-32" >
            Mail Lists
        </a>
        
        
    </li>
  
    <li class="">
        <a href="/p/xsb/_list/tickets" class="tool-tickets-32" >
            Tickets ▾
        </a>
        
        
            <ul>
                
                    <li class=""><a href="/p/xsb/bugs/" >Bugs</a></li>
                
                    <li class=""><a href="/p/xsb/feature-requests/" >Feature Requests</a></li>
                
                    <li class=""><a href="/p/xsb/support-requests/" >Support Requests</a></li>
                
                    <li class=""><a href="/p/xsb/patches/" >Patches</a></li>
                
            </ul>
        
    </li>
  
    <li class="">
        <a href="/p/xsb/news/" class="tool-blog-32" >
            News
        </a>
        
        
    </li>
  
    <li class="">
        <a href="/p/xsb/code/" class="tool-git-32" >
            Sources (GIT)
        </a>
        
        
    </li>
  
    <li class="selected">
        <a href="/p/xsb/src/" class="tool-svn-32" >
            Src  (SVN)-old
        </a>
        
        
    </li>
  
  
</ul>
</div>


            
        </div>
        <div id="content_base">
            

    
                
                    
<a id="sidebar-activate" href="#">
    <span class="btn-label">Menu</span>
    <span class="btn-arrow-down">▾</span>
    <span class="btn-arrow-up">▴</span>
</a>

                        


<div id="sidebar">
  
    <div class="placeholder-no-searchbox">&nbsp;</div>
  
    
    
      
      
        
    
      <ul class="sidebarmenu">
      
    
  <li>
      
        <a class="icon" href="/p/xsb/src/commit_browser" rel="nofollow" title="Browse Commits"><i class="fa fa-list"></i>
      
      <span>Browse Commits</span>
      </a>
  </li>
  
      
        
    
  <li>
      
        <a href="/p/xsb/src/"  rel="nofollow" >
      
      <span>Browse Files</span>
      </a>
  </li>
  
      
    
    
      </ul>
      
    
    
</div>



<script>
$('#sidebar-admin-header').on('click', function(e){
    $("#sidebar-admin-menu").toggleClass("hidden");
    $(this).toggleClass("expanded");
    e.preventDefault();
});
</script>

                    

                    
                
                
                    
                
                <div class="grid-20 pad">
                    <h2 class="dark title">
                        <span>
<a href="/p/xsb/src/8472/" rel="nofollow">[r8472]</a>:

  
      <a href="./../../../../" rel="nofollow"><b class="fa fa-folder-open-o" title="Root directory"></b></a> /
  
  
    <a href="./../../../" rel="nofollow">trunk</a> /
  
    <a href="./../../" rel="nofollow">XSB</a> /
  
    <a href="./../" rel="nofollow">docs</a> /
  
    <a href="./" rel="nofollow">userman</a> /
  
 debugging.tex
</span>
                        <!-- actions -->
                        <small>
                            

    
    <a class="icon" href="#" id="maximize-content" title="Maximize"><i class="fa fa-expand"></i>&nbsp;Maximize</a>
    <a class="icon" href="#" id="restore-content" title="Restore"><i class="fa fa-compress"></i>&nbsp;Restore</a>
<a class="icon" href="/p/xsb/src/8472/log/?path=/trunk/XSB/docs/userman/debugging.tex" rel="nofollow" title="History"><i class="fa fa-calendar"></i>&nbsp;History</a>

                        </small>
                        <!-- /actions -->
                    </h2>
                    
                    <div>
                        
  

                        
  
    <p><a rel="nofollow" href="?format=raw">Download this file</a></p>
    <div class="clip grid-19 codebrowser">
      <h3>
        1228 lines (1115 with data), 58.7 kB
      </h3>
      
        <div class="codehilite"><table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">   1</span>
<span class="normal">   2</span>
<span class="normal">   3</span>
<span class="normal">   4</span>
<span class="normal">   5</span>
<span class="normal">   6</span>
<span class="normal">   7</span>
<span class="normal">   8</span>
<span class="normal">   9</span>
<span class="normal">  10</span>
<span class="normal">  11</span>
<span class="normal">  12</span>
<span class="normal">  13</span>
<span class="normal">  14</span>
<span class="normal">  15</span>
<span class="normal">  16</span>
<span class="normal">  17</span>
<span class="normal">  18</span>
<span class="normal">  19</span>
<span class="normal">  20</span>
<span class="normal">  21</span>
<span class="normal">  22</span>
<span class="normal">  23</span>
<span class="normal">  24</span>
<span class="normal">  25</span>
<span class="normal">  26</span>
<span class="normal">  27</span>
<span class="normal">  28</span>
<span class="normal">  29</span>
<span class="normal">  30</span>
<span class="normal">  31</span>
<span class="normal">  32</span>
<span class="normal">  33</span>
<span class="normal">  34</span>
<span class="normal">  35</span>
<span class="normal">  36</span>
<span class="normal">  37</span>
<span class="normal">  38</span>
<span class="normal">  39</span>
<span class="normal">  40</span>
<span class="normal">  41</span>
<span class="normal">  42</span>
<span class="normal">  43</span>
<span class="normal">  44</span>
<span class="normal">  45</span>
<span class="normal">  46</span>
<span class="normal">  47</span>
<span class="normal">  48</span>
<span class="normal">  49</span>
<span class="normal">  50</span>
<span class="normal">  51</span>
<span class="normal">  52</span>
<span class="normal">  53</span>
<span class="normal">  54</span>
<span class="normal">  55</span>
<span class="normal">  56</span>
<span class="normal">  57</span>
<span class="normal">  58</span>
<span class="normal">  59</span>
<span class="normal">  60</span>
<span class="normal">  61</span>
<span class="normal">  62</span>
<span class="normal">  63</span>
<span class="normal">  64</span>
<span class="normal">  65</span>
<span class="normal">  66</span>
<span class="normal">  67</span>
<span class="normal">  68</span>
<span class="normal">  69</span>
<span class="normal">  70</span>
<span class="normal">  71</span>
<span class="normal">  72</span>
<span class="normal">  73</span>
<span class="normal">  74</span>
<span class="normal">  75</span>
<span class="normal">  76</span>
<span class="normal">  77</span>
<span class="normal">  78</span>
<span class="normal">  79</span>
<span class="normal">  80</span>
<span class="normal">  81</span>
<span class="normal">  82</span>
<span class="normal">  83</span>
<span class="normal">  84</span>
<span class="normal">  85</span>
<span class="normal">  86</span>
<span class="normal">  87</span>
<span class="normal">  88</span>
<span class="normal">  89</span>
<span class="normal">  90</span>
<span class="normal">  91</span>
<span class="normal">  92</span>
<span class="normal">  93</span>
<span class="normal">  94</span>
<span class="normal">  95</span>
<span class="normal">  96</span>
<span class="normal">  97</span>
<span class="normal">  98</span>
<span class="normal">  99</span>
<span class="normal"> 100</span>
<span class="normal"> 101</span>
<span class="normal"> 102</span>
<span class="normal"> 103</span>
<span class="normal"> 104</span>
<span class="normal"> 105</span>
<span class="normal"> 106</span>
<span class="normal"> 107</span>
<span class="normal"> 108</span>
<span class="normal"> 109</span>
<span class="normal"> 110</span>
<span class="normal"> 111</span>
<span class="normal"> 112</span>
<span class="normal"> 113</span>
<span class="normal"> 114</span>
<span class="normal"> 115</span>
<span class="normal"> 116</span>
<span class="normal"> 117</span>
<span class="normal"> 118</span>
<span class="normal"> 119</span>
<span class="normal"> 120</span>
<span class="normal"> 121</span>
<span class="normal"> 122</span>
<span class="normal"> 123</span>
<span class="normal"> 124</span>
<span class="normal"> 125</span>
<span class="normal"> 126</span>
<span class="normal"> 127</span>
<span class="normal"> 128</span>
<span class="normal"> 129</span>
<span class="normal"> 130</span>
<span class="normal"> 131</span>
<span class="normal"> 132</span>
<span class="normal"> 133</span>
<span class="normal"> 134</span>
<span class="normal"> 135</span>
<span class="normal"> 136</span>
<span class="normal"> 137</span>
<span class="normal"> 138</span>
<span class="normal"> 139</span>
<span class="normal"> 140</span>
<span class="normal"> 141</span>
<span class="normal"> 142</span>
<span class="normal"> 143</span>
<span class="normal"> 144</span>
<span class="normal"> 145</span>
<span class="normal"> 146</span>
<span class="normal"> 147</span>
<span class="normal"> 148</span>
<span class="normal"> 149</span>
<span class="normal"> 150</span>
<span class="normal"> 151</span>
<span class="normal"> 152</span>
<span class="normal"> 153</span>
<span class="normal"> 154</span>
<span class="normal"> 155</span>
<span class="normal"> 156</span>
<span class="normal"> 157</span>
<span class="normal"> 158</span>
<span class="normal"> 159</span>
<span class="normal"> 160</span>
<span class="normal"> 161</span>
<span class="normal"> 162</span>
<span class="normal"> 163</span>
<span class="normal"> 164</span>
<span class="normal"> 165</span>
<span class="normal"> 166</span>
<span class="normal"> 167</span>
<span class="normal"> 168</span>
<span class="normal"> 169</span>
<span class="normal"> 170</span>
<span class="normal"> 171</span>
<span class="normal"> 172</span>
<span class="normal"> 173</span>
<span class="normal"> 174</span>
<span class="normal"> 175</span>
<span class="normal"> 176</span>
<span class="normal"> 177</span>
<span class="normal"> 178</span>
<span class="normal"> 179</span>
<span class="normal"> 180</span>
<span class="normal"> 181</span>
<span class="normal"> 182</span>
<span class="normal"> 183</span>
<span class="normal"> 184</span>
<span class="normal"> 185</span>
<span class="normal"> 186</span>
<span class="normal"> 187</span>
<span class="normal"> 188</span>
<span class="normal"> 189</span>
<span class="normal"> 190</span>
<span class="normal"> 191</span>
<span class="normal"> 192</span>
<span class="normal"> 193</span>
<span class="normal"> 194</span>
<span class="normal"> 195</span>
<span class="normal"> 196</span>
<span class="normal"> 197</span>
<span class="normal"> 198</span>
<span class="normal"> 199</span>
<span class="normal"> 200</span>
<span class="normal"> 201</span>
<span class="normal"> 202</span>
<span class="normal"> 203</span>
<span class="normal"> 204</span>
<span class="normal"> 205</span>
<span class="normal"> 206</span>
<span class="normal"> 207</span>
<span class="normal"> 208</span>
<span class="normal"> 209</span>
<span class="normal"> 210</span>
<span class="normal"> 211</span>
<span class="normal"> 212</span>
<span class="normal"> 213</span>
<span class="normal"> 214</span>
<span class="normal"> 215</span>
<span class="normal"> 216</span>
<span class="normal"> 217</span>
<span class="normal"> 218</span>
<span class="normal"> 219</span>
<span class="normal"> 220</span>
<span class="normal"> 221</span>
<span class="normal"> 222</span>
<span class="normal"> 223</span>
<span class="normal"> 224</span>
<span class="normal"> 225</span>
<span class="normal"> 226</span>
<span class="normal"> 227</span>
<span class="normal"> 228</span>
<span class="normal"> 229</span>
<span class="normal"> 230</span>
<span class="normal"> 231</span>
<span class="normal"> 232</span>
<span class="normal"> 233</span>
<span class="normal"> 234</span>
<span class="normal"> 235</span>
<span class="normal"> 236</span>
<span class="normal"> 237</span>
<span class="normal"> 238</span>
<span class="normal"> 239</span>
<span class="normal"> 240</span>
<span class="normal"> 241</span>
<span class="normal"> 242</span>
<span class="normal"> 243</span>
<span class="normal"> 244</span>
<span class="normal"> 245</span>
<span class="normal"> 246</span>
<span class="normal"> 247</span>
<span class="normal"> 248</span>
<span class="normal"> 249</span>
<span class="normal"> 250</span>
<span class="normal"> 251</span>
<span class="normal"> 252</span>
<span class="normal"> 253</span>
<span class="normal"> 254</span>
<span class="normal"> 255</span>
<span class="normal"> 256</span>
<span class="normal"> 257</span>
<span class="normal"> 258</span>
<span class="normal"> 259</span>
<span class="normal"> 260</span>
<span class="normal"> 261</span>
<span class="normal"> 262</span>
<span class="normal"> 263</span>
<span class="normal"> 264</span>
<span class="normal"> 265</span>
<span class="normal"> 266</span>
<span class="normal"> 267</span>
<span class="normal"> 268</span>
<span class="normal"> 269</span>
<span class="normal"> 270</span>
<span class="normal"> 271</span>
<span class="normal"> 272</span>
<span class="normal"> 273</span>
<span class="normal"> 274</span>
<span class="normal"> 275</span>
<span class="normal"> 276</span>
<span class="normal"> 277</span>
<span class="normal"> 278</span>
<span class="normal"> 279</span>
<span class="normal"> 280</span>
<span class="normal"> 281</span>
<span class="normal"> 282</span>
<span class="normal"> 283</span>
<span class="normal"> 284</span>
<span class="normal"> 285</span>
<span class="normal"> 286</span>
<span class="normal"> 287</span>
<span class="normal"> 288</span>
<span class="normal"> 289</span>
<span class="normal"> 290</span>
<span class="normal"> 291</span>
<span class="normal"> 292</span>
<span class="normal"> 293</span>
<span class="normal"> 294</span>
<span class="normal"> 295</span>
<span class="normal"> 296</span>
<span class="normal"> 297</span>
<span class="normal"> 298</span>
<span class="normal"> 299</span>
<span class="normal"> 300</span>
<span class="normal"> 301</span>
<span class="normal"> 302</span>
<span class="normal"> 303</span>
<span class="normal"> 304</span>
<span class="normal"> 305</span>
<span class="normal"> 306</span>
<span class="normal"> 307</span>
<span class="normal"> 308</span>
<span class="normal"> 309</span>
<span class="normal"> 310</span>
<span class="normal"> 311</span>
<span class="normal"> 312</span>
<span class="normal"> 313</span>
<span class="normal"> 314</span>
<span class="normal"> 315</span>
<span class="normal"> 316</span>
<span class="normal"> 317</span>
<span class="normal"> 318</span>
<span class="normal"> 319</span>
<span class="normal"> 320</span>
<span class="normal"> 321</span>
<span class="normal"> 322</span>
<span class="normal"> 323</span>
<span class="normal"> 324</span>
<span class="normal"> 325</span>
<span class="normal"> 326</span>
<span class="normal"> 327</span>
<span class="normal"> 328</span>
<span class="normal"> 329</span>
<span class="normal"> 330</span>
<span class="normal"> 331</span>
<span class="normal"> 332</span>
<span class="normal"> 333</span>
<span class="normal"> 334</span>
<span class="normal"> 335</span>
<span class="normal"> 336</span>
<span class="normal"> 337</span>
<span class="normal"> 338</span>
<span class="normal"> 339</span>
<span class="normal"> 340</span>
<span class="normal"> 341</span>
<span class="normal"> 342</span>
<span class="normal"> 343</span>
<span class="normal"> 344</span>
<span class="normal"> 345</span>
<span class="normal"> 346</span>
<span class="normal"> 347</span>
<span class="normal"> 348</span>
<span class="normal"> 349</span>
<span class="normal"> 350</span>
<span class="normal"> 351</span>
<span class="normal"> 352</span>
<span class="normal"> 353</span>
<span class="normal"> 354</span>
<span class="normal"> 355</span>
<span class="normal"> 356</span>
<span class="normal"> 357</span>
<span class="normal"> 358</span>
<span class="normal"> 359</span>
<span class="normal"> 360</span>
<span class="normal"> 361</span>
<span class="normal"> 362</span>
<span class="normal"> 363</span>
<span class="normal"> 364</span>
<span class="normal"> 365</span>
<span class="normal"> 366</span>
<span class="normal"> 367</span>
<span class="normal"> 368</span>
<span class="normal"> 369</span>
<span class="normal"> 370</span>
<span class="normal"> 371</span>
<span class="normal"> 372</span>
<span class="normal"> 373</span>
<span class="normal"> 374</span>
<span class="normal"> 375</span>
<span class="normal"> 376</span>
<span class="normal"> 377</span>
<span class="normal"> 378</span>
<span class="normal"> 379</span>
<span class="normal"> 380</span>
<span class="normal"> 381</span>
<span class="normal"> 382</span>
<span class="normal"> 383</span>
<span class="normal"> 384</span>
<span class="normal"> 385</span>
<span class="normal"> 386</span>
<span class="normal"> 387</span>
<span class="normal"> 388</span>
<span class="normal"> 389</span>
<span class="normal"> 390</span>
<span class="normal"> 391</span>
<span class="normal"> 392</span>
<span class="normal"> 393</span>
<span class="normal"> 394</span>
<span class="normal"> 395</span>
<span class="normal"> 396</span>
<span class="normal"> 397</span>
<span class="normal"> 398</span>
<span class="normal"> 399</span>
<span class="normal"> 400</span>
<span class="normal"> 401</span>
<span class="normal"> 402</span>
<span class="normal"> 403</span>
<span class="normal"> 404</span>
<span class="normal"> 405</span>
<span class="normal"> 406</span>
<span class="normal"> 407</span>
<span class="normal"> 408</span>
<span class="normal"> 409</span>
<span class="normal"> 410</span>
<span class="normal"> 411</span>
<span class="normal"> 412</span>
<span class="normal"> 413</span>
<span class="normal"> 414</span>
<span class="normal"> 415</span>
<span class="normal"> 416</span>
<span class="normal"> 417</span>
<span class="normal"> 418</span>
<span class="normal"> 419</span>
<span class="normal"> 420</span>
<span class="normal"> 421</span>
<span class="normal"> 422</span>
<span class="normal"> 423</span>
<span class="normal"> 424</span>
<span class="normal"> 425</span>
<span class="normal"> 426</span>
<span class="normal"> 427</span>
<span class="normal"> 428</span>
<span class="normal"> 429</span>
<span class="normal"> 430</span>
<span class="normal"> 431</span>
<span class="normal"> 432</span>
<span class="normal"> 433</span>
<span class="normal"> 434</span>
<span class="normal"> 435</span>
<span class="normal"> 436</span>
<span class="normal"> 437</span>
<span class="normal"> 438</span>
<span class="normal"> 439</span>
<span class="normal"> 440</span>
<span class="normal"> 441</span>
<span class="normal"> 442</span>
<span class="normal"> 443</span>
<span class="normal"> 444</span>
<span class="normal"> 445</span>
<span class="normal"> 446</span>
<span class="normal"> 447</span>
<span class="normal"> 448</span>
<span class="normal"> 449</span>
<span class="normal"> 450</span>
<span class="normal"> 451</span>
<span class="normal"> 452</span>
<span class="normal"> 453</span>
<span class="normal"> 454</span>
<span class="normal"> 455</span>
<span class="normal"> 456</span>
<span class="normal"> 457</span>
<span class="normal"> 458</span>
<span class="normal"> 459</span>
<span class="normal"> 460</span>
<span class="normal"> 461</span>
<span class="normal"> 462</span>
<span class="normal"> 463</span>
<span class="normal"> 464</span>
<span class="normal"> 465</span>
<span class="normal"> 466</span>
<span class="normal"> 467</span>
<span class="normal"> 468</span>
<span class="normal"> 469</span>
<span class="normal"> 470</span>
<span class="normal"> 471</span>
<span class="normal"> 472</span>
<span class="normal"> 473</span>
<span class="normal"> 474</span>
<span class="normal"> 475</span>
<span class="normal"> 476</span>
<span class="normal"> 477</span>
<span class="normal"> 478</span>
<span class="normal"> 479</span>
<span class="normal"> 480</span>
<span class="normal"> 481</span>
<span class="normal"> 482</span>
<span class="normal"> 483</span>
<span class="normal"> 484</span>
<span class="normal"> 485</span>
<span class="normal"> 486</span>
<span class="normal"> 487</span>
<span class="normal"> 488</span>
<span class="normal"> 489</span>
<span class="normal"> 490</span>
<span class="normal"> 491</span>
<span class="normal"> 492</span>
<span class="normal"> 493</span>
<span class="normal"> 494</span>
<span class="normal"> 495</span>
<span class="normal"> 496</span>
<span class="normal"> 497</span>
<span class="normal"> 498</span>
<span class="normal"> 499</span>
<span class="normal"> 500</span>
<span class="normal"> 501</span>
<span class="normal"> 502</span>
<span class="normal"> 503</span>
<span class="normal"> 504</span>
<span class="normal"> 505</span>
<span class="normal"> 506</span>
<span class="normal"> 507</span>
<span class="normal"> 508</span>
<span class="normal"> 509</span>
<span class="normal"> 510</span>
<span class="normal"> 511</span>
<span class="normal"> 512</span>
<span class="normal"> 513</span>
<span class="normal"> 514</span>
<span class="normal"> 515</span>
<span class="normal"> 516</span>
<span class="normal"> 517</span>
<span class="normal"> 518</span>
<span class="normal"> 519</span>
<span class="normal"> 520</span>
<span class="normal"> 521</span>
<span class="normal"> 522</span>
<span class="normal"> 523</span>
<span class="normal"> 524</span>
<span class="normal"> 525</span>
<span class="normal"> 526</span>
<span class="normal"> 527</span>
<span class="normal"> 528</span>
<span class="normal"> 529</span>
<span class="normal"> 530</span>
<span class="normal"> 531</span>
<span class="normal"> 532</span>
<span class="normal"> 533</span>
<span class="normal"> 534</span>
<span class="normal"> 535</span>
<span class="normal"> 536</span>
<span class="normal"> 537</span>
<span class="normal"> 538</span>
<span class="normal"> 539</span>
<span class="normal"> 540</span>
<span class="normal"> 541</span>
<span class="normal"> 542</span>
<span class="normal"> 543</span>
<span class="normal"> 544</span>
<span class="normal"> 545</span>
<span class="normal"> 546</span>
<span class="normal"> 547</span>
<span class="normal"> 548</span>
<span class="normal"> 549</span>
<span class="normal"> 550</span>
<span class="normal"> 551</span>
<span class="normal"> 552</span>
<span class="normal"> 553</span>
<span class="normal"> 554</span>
<span class="normal"> 555</span>
<span class="normal"> 556</span>
<span class="normal"> 557</span>
<span class="normal"> 558</span>
<span class="normal"> 559</span>
<span class="normal"> 560</span>
<span class="normal"> 561</span>
<span class="normal"> 562</span>
<span class="normal"> 563</span>
<span class="normal"> 564</span>
<span class="normal"> 565</span>
<span class="normal"> 566</span>
<span class="normal"> 567</span>
<span class="normal"> 568</span>
<span class="normal"> 569</span>
<span class="normal"> 570</span>
<span class="normal"> 571</span>
<span class="normal"> 572</span>
<span class="normal"> 573</span>
<span class="normal"> 574</span>
<span class="normal"> 575</span>
<span class="normal"> 576</span>
<span class="normal"> 577</span>
<span class="normal"> 578</span>
<span class="normal"> 579</span>
<span class="normal"> 580</span>
<span class="normal"> 581</span>
<span class="normal"> 582</span>
<span class="normal"> 583</span>
<span class="normal"> 584</span>
<span class="normal"> 585</span>
<span class="normal"> 586</span>
<span class="normal"> 587</span>
<span class="normal"> 588</span>
<span class="normal"> 589</span>
<span class="normal"> 590</span>
<span class="normal"> 591</span>
<span class="normal"> 592</span>
<span class="normal"> 593</span>
<span class="normal"> 594</span>
<span class="normal"> 595</span>
<span class="normal"> 596</span>
<span class="normal"> 597</span>
<span class="normal"> 598</span>
<span class="normal"> 599</span>
<span class="normal"> 600</span>
<span class="normal"> 601</span>
<span class="normal"> 602</span>
<span class="normal"> 603</span>
<span class="normal"> 604</span>
<span class="normal"> 605</span>
<span class="normal"> 606</span>
<span class="normal"> 607</span>
<span class="normal"> 608</span>
<span class="normal"> 609</span>
<span class="normal"> 610</span>
<span class="normal"> 611</span>
<span class="normal"> 612</span>
<span class="normal"> 613</span>
<span class="normal"> 614</span>
<span class="normal"> 615</span>
<span class="normal"> 616</span>
<span class="normal"> 617</span>
<span class="normal"> 618</span>
<span class="normal"> 619</span>
<span class="normal"> 620</span>
<span class="normal"> 621</span>
<span class="normal"> 622</span>
<span class="normal"> 623</span>
<span class="normal"> 624</span>
<span class="normal"> 625</span>
<span class="normal"> 626</span>
<span class="normal"> 627</span>
<span class="normal"> 628</span>
<span class="normal"> 629</span>
<span class="normal"> 630</span>
<span class="normal"> 631</span>
<span class="normal"> 632</span>
<span class="normal"> 633</span>
<span class="normal"> 634</span>
<span class="normal"> 635</span>
<span class="normal"> 636</span>
<span class="normal"> 637</span>
<span class="normal"> 638</span>
<span class="normal"> 639</span>
<span class="normal"> 640</span>
<span class="normal"> 641</span>
<span class="normal"> 642</span>
<span class="normal"> 643</span>
<span class="normal"> 644</span>
<span class="normal"> 645</span>
<span class="normal"> 646</span>
<span class="normal"> 647</span>
<span class="normal"> 648</span>
<span class="normal"> 649</span>
<span class="normal"> 650</span>
<span class="normal"> 651</span>
<span class="normal"> 652</span>
<span class="normal"> 653</span>
<span class="normal"> 654</span>
<span class="normal"> 655</span>
<span class="normal"> 656</span>
<span class="normal"> 657</span>
<span class="normal"> 658</span>
<span class="normal"> 659</span>
<span class="normal"> 660</span>
<span class="normal"> 661</span>
<span class="normal"> 662</span>
<span class="normal"> 663</span>
<span class="normal"> 664</span>
<span class="normal"> 665</span>
<span class="normal"> 666</span>
<span class="normal"> 667</span>
<span class="normal"> 668</span>
<span class="normal"> 669</span>
<span class="normal"> 670</span>
<span class="normal"> 671</span>
<span class="normal"> 672</span>
<span class="normal"> 673</span>
<span class="normal"> 674</span>
<span class="normal"> 675</span>
<span class="normal"> 676</span>
<span class="normal"> 677</span>
<span class="normal"> 678</span>
<span class="normal"> 679</span>
<span class="normal"> 680</span>
<span class="normal"> 681</span>
<span class="normal"> 682</span>
<span class="normal"> 683</span>
<span class="normal"> 684</span>
<span class="normal"> 685</span>
<span class="normal"> 686</span>
<span class="normal"> 687</span>
<span class="normal"> 688</span>
<span class="normal"> 689</span>
<span class="normal"> 690</span>
<span class="normal"> 691</span>
<span class="normal"> 692</span>
<span class="normal"> 693</span>
<span class="normal"> 694</span>
<span class="normal"> 695</span>
<span class="normal"> 696</span>
<span class="normal"> 697</span>
<span class="normal"> 698</span>
<span class="normal"> 699</span>
<span class="normal"> 700</span>
<span class="normal"> 701</span>
<span class="normal"> 702</span>
<span class="normal"> 703</span>
<span class="normal"> 704</span>
<span class="normal"> 705</span>
<span class="normal"> 706</span>
<span class="normal"> 707</span>
<span class="normal"> 708</span>
<span class="normal"> 709</span>
<span class="normal"> 710</span>
<span class="normal"> 711</span>
<span class="normal"> 712</span>
<span class="normal"> 713</span>
<span class="normal"> 714</span>
<span class="normal"> 715</span>
<span class="normal"> 716</span>
<span class="normal"> 717</span>
<span class="normal"> 718</span>
<span class="normal"> 719</span>
<span class="normal"> 720</span>
<span class="normal"> 721</span>
<span class="normal"> 722</span>
<span class="normal"> 723</span>
<span class="normal"> 724</span>
<span class="normal"> 725</span>
<span class="normal"> 726</span>
<span class="normal"> 727</span>
<span class="normal"> 728</span>
<span class="normal"> 729</span>
<span class="normal"> 730</span>
<span class="normal"> 731</span>
<span class="normal"> 732</span>
<span class="normal"> 733</span>
<span class="normal"> 734</span>
<span class="normal"> 735</span>
<span class="normal"> 736</span>
<span class="normal"> 737</span>
<span class="normal"> 738</span>
<span class="normal"> 739</span>
<span class="normal"> 740</span>
<span class="normal"> 741</span>
<span class="normal"> 742</span>
<span class="normal"> 743</span>
<span class="normal"> 744</span>
<span class="normal"> 745</span>
<span class="normal"> 746</span>
<span class="normal"> 747</span>
<span class="normal"> 748</span>
<span class="normal"> 749</span>
<span class="normal"> 750</span>
<span class="normal"> 751</span>
<span class="normal"> 752</span>
<span class="normal"> 753</span>
<span class="normal"> 754</span>
<span class="normal"> 755</span>
<span class="normal"> 756</span>
<span class="normal"> 757</span>
<span class="normal"> 758</span>
<span class="normal"> 759</span>
<span class="normal"> 760</span>
<span class="normal"> 761</span>
<span class="normal"> 762</span>
<span class="normal"> 763</span>
<span class="normal"> 764</span>
<span class="normal"> 765</span>
<span class="normal"> 766</span>
<span class="normal"> 767</span>
<span class="normal"> 768</span>
<span class="normal"> 769</span>
<span class="normal"> 770</span>
<span class="normal"> 771</span>
<span class="normal"> 772</span>
<span class="normal"> 773</span>
<span class="normal"> 774</span>
<span class="normal"> 775</span>
<span class="normal"> 776</span>
<span class="normal"> 777</span>
<span class="normal"> 778</span>
<span class="normal"> 779</span>
<span class="normal"> 780</span>
<span class="normal"> 781</span>
<span class="normal"> 782</span>
<span class="normal"> 783</span>
<span class="normal"> 784</span>
<span class="normal"> 785</span>
<span class="normal"> 786</span>
<span class="normal"> 787</span>
<span class="normal"> 788</span>
<span class="normal"> 789</span>
<span class="normal"> 790</span>
<span class="normal"> 791</span>
<span class="normal"> 792</span>
<span class="normal"> 793</span>
<span class="normal"> 794</span>
<span class="normal"> 795</span>
<span class="normal"> 796</span>
<span class="normal"> 797</span>
<span class="normal"> 798</span>
<span class="normal"> 799</span>
<span class="normal"> 800</span>
<span class="normal"> 801</span>
<span class="normal"> 802</span>
<span class="normal"> 803</span>
<span class="normal"> 804</span>
<span class="normal"> 805</span>
<span class="normal"> 806</span>
<span class="normal"> 807</span>
<span class="normal"> 808</span>
<span class="normal"> 809</span>
<span class="normal"> 810</span>
<span class="normal"> 811</span>
<span class="normal"> 812</span>
<span class="normal"> 813</span>
<span class="normal"> 814</span>
<span class="normal"> 815</span>
<span class="normal"> 816</span>
<span class="normal"> 817</span>
<span class="normal"> 818</span>
<span class="normal"> 819</span>
<span class="normal"> 820</span>
<span class="normal"> 821</span>
<span class="normal"> 822</span>
<span class="normal"> 823</span>
<span class="normal"> 824</span>
<span class="normal"> 825</span>
<span class="normal"> 826</span>
<span class="normal"> 827</span>
<span class="normal"> 828</span>
<span class="normal"> 829</span>
<span class="normal"> 830</span>
<span class="normal"> 831</span>
<span class="normal"> 832</span>
<span class="normal"> 833</span>
<span class="normal"> 834</span>
<span class="normal"> 835</span>
<span class="normal"> 836</span>
<span class="normal"> 837</span>
<span class="normal"> 838</span>
<span class="normal"> 839</span>
<span class="normal"> 840</span>
<span class="normal"> 841</span>
<span class="normal"> 842</span>
<span class="normal"> 843</span>
<span class="normal"> 844</span>
<span class="normal"> 845</span>
<span class="normal"> 846</span>
<span class="normal"> 847</span>
<span class="normal"> 848</span>
<span class="normal"> 849</span>
<span class="normal"> 850</span>
<span class="normal"> 851</span>
<span class="normal"> 852</span>
<span class="normal"> 853</span>
<span class="normal"> 854</span>
<span class="normal"> 855</span>
<span class="normal"> 856</span>
<span class="normal"> 857</span>
<span class="normal"> 858</span>
<span class="normal"> 859</span>
<span class="normal"> 860</span>
<span class="normal"> 861</span>
<span class="normal"> 862</span>
<span class="normal"> 863</span>
<span class="normal"> 864</span>
<span class="normal"> 865</span>
<span class="normal"> 866</span>
<span class="normal"> 867</span>
<span class="normal"> 868</span>
<span class="normal"> 869</span>
<span class="normal"> 870</span>
<span class="normal"> 871</span>
<span class="normal"> 872</span>
<span class="normal"> 873</span>
<span class="normal"> 874</span>
<span class="normal"> 875</span>
<span class="normal"> 876</span>
<span class="normal"> 877</span>
<span class="normal"> 878</span>
<span class="normal"> 879</span>
<span class="normal"> 880</span>
<span class="normal"> 881</span>
<span class="normal"> 882</span>
<span class="normal"> 883</span>
<span class="normal"> 884</span>
<span class="normal"> 885</span>
<span class="normal"> 886</span>
<span class="normal"> 887</span>
<span class="normal"> 888</span>
<span class="normal"> 889</span>
<span class="normal"> 890</span>
<span class="normal"> 891</span>
<span class="normal"> 892</span>
<span class="normal"> 893</span>
<span class="normal"> 894</span>
<span class="normal"> 895</span>
<span class="normal"> 896</span>
<span class="normal"> 897</span>
<span class="normal"> 898</span>
<span class="normal"> 899</span>
<span class="normal"> 900</span>
<span class="normal"> 901</span>
<span class="normal"> 902</span>
<span class="normal"> 903</span>
<span class="normal"> 904</span>
<span class="normal"> 905</span>
<span class="normal"> 906</span>
<span class="normal"> 907</span>
<span class="normal"> 908</span>
<span class="normal"> 909</span>
<span class="normal"> 910</span>
<span class="normal"> 911</span>
<span class="normal"> 912</span>
<span class="normal"> 913</span>
<span class="normal"> 914</span>
<span class="normal"> 915</span>
<span class="normal"> 916</span>
<span class="normal"> 917</span>
<span class="normal"> 918</span>
<span class="normal"> 919</span>
<span class="normal"> 920</span>
<span class="normal"> 921</span>
<span class="normal"> 922</span>
<span class="normal"> 923</span>
<span class="normal"> 924</span>
<span class="normal"> 925</span>
<span class="normal"> 926</span>
<span class="normal"> 927</span>
<span class="normal"> 928</span>
<span class="normal"> 929</span>
<span class="normal"> 930</span>
<span class="normal"> 931</span>
<span class="normal"> 932</span>
<span class="normal"> 933</span>
<span class="normal"> 934</span>
<span class="normal"> 935</span>
<span class="normal"> 936</span>
<span class="normal"> 937</span>
<span class="normal"> 938</span>
<span class="normal"> 939</span>
<span class="normal"> 940</span>
<span class="normal"> 941</span>
<span class="normal"> 942</span>
<span class="normal"> 943</span>
<span class="normal"> 944</span>
<span class="normal"> 945</span>
<span class="normal"> 946</span>
<span class="normal"> 947</span>
<span class="normal"> 948</span>
<span class="normal"> 949</span>
<span class="normal"> 950</span>
<span class="normal"> 951</span>
<span class="normal"> 952</span>
<span class="normal"> 953</span>
<span class="normal"> 954</span>
<span class="normal"> 955</span>
<span class="normal"> 956</span>
<span class="normal"> 957</span>
<span class="normal"> 958</span>
<span class="normal"> 959</span>
<span class="normal"> 960</span>
<span class="normal"> 961</span>
<span class="normal"> 962</span>
<span class="normal"> 963</span>
<span class="normal"> 964</span>
<span class="normal"> 965</span>
<span class="normal"> 966</span>
<span class="normal"> 967</span>
<span class="normal"> 968</span>
<span class="normal"> 969</span>
<span class="normal"> 970</span>
<span class="normal"> 971</span>
<span class="normal"> 972</span>
<span class="normal"> 973</span>
<span class="normal"> 974</span>
<span class="normal"> 975</span>
<span class="normal"> 976</span>
<span class="normal"> 977</span>
<span class="normal"> 978</span>
<span class="normal"> 979</span>
<span class="normal"> 980</span>
<span class="normal"> 981</span>
<span class="normal"> 982</span>
<span class="normal"> 983</span>
<span class="normal"> 984</span>
<span class="normal"> 985</span>
<span class="normal"> 986</span>
<span class="normal"> 987</span>
<span class="normal"> 988</span>
<span class="normal"> 989</span>
<span class="normal"> 990</span>
<span class="normal"> 991</span>
<span class="normal"> 992</span>
<span class="normal"> 993</span>
<span class="normal"> 994</span>
<span class="normal"> 995</span>
<span class="normal"> 996</span>
<span class="normal"> 997</span>
<span class="normal"> 998</span>
<span class="normal"> 999</span>
<span class="normal">1000</span>
<span class="normal">1001</span>
<span class="normal">1002</span>
<span class="normal">1003</span>
<span class="normal">1004</span>
<span class="normal">1005</span>
<span class="normal">1006</span>
<span class="normal">1007</span>
<span class="normal">1008</span>
<span class="normal">1009</span>
<span class="normal">1010</span>
<span class="normal">1011</span>
<span class="normal">1012</span>
<span class="normal">1013</span>
<span class="normal">1014</span>
<span class="normal">1015</span>
<span class="normal">1016</span>
<span class="normal">1017</span>
<span class="normal">1018</span>
<span class="normal">1019</span>
<span class="normal">1020</span>
<span class="normal">1021</span>
<span class="normal">1022</span>
<span class="normal">1023</span>
<span class="normal">1024</span>
<span class="normal">1025</span>
<span class="normal">1026</span>
<span class="normal">1027</span>
<span class="normal">1028</span>
<span class="normal">1029</span>
<span class="normal">1030</span>
<span class="normal">1031</span>
<span class="normal">1032</span>
<span class="normal">1033</span>
<span class="normal">1034</span>
<span class="normal">1035</span>
<span class="normal">1036</span>
<span class="normal">1037</span>
<span class="normal">1038</span>
<span class="normal">1039</span>
<span class="normal">1040</span>
<span class="normal">1041</span>
<span class="normal">1042</span>
<span class="normal">1043</span>
<span class="normal">1044</span>
<span class="normal">1045</span>
<span class="normal">1046</span>
<span class="normal">1047</span>
<span class="normal">1048</span>
<span class="normal">1049</span>
<span class="normal">1050</span>
<span class="normal">1051</span>
<span class="normal">1052</span>
<span class="normal">1053</span>
<span class="normal">1054</span>
<span class="normal">1055</span>
<span class="normal">1056</span>
<span class="normal">1057</span>
<span class="normal">1058</span>
<span class="normal">1059</span>
<span class="normal">1060</span>
<span class="normal">1061</span>
<span class="normal">1062</span>
<span class="normal">1063</span>
<span class="normal">1064</span>
<span class="normal">1065</span>
<span class="normal">1066</span>
<span class="normal">1067</span>
<span class="normal">1068</span>
<span class="normal">1069</span>
<span class="normal">1070</span>
<span class="normal">1071</span>
<span class="normal">1072</span>
<span class="normal">1073</span>
<span class="normal">1074</span>
<span class="normal">1075</span>
<span class="normal">1076</span>
<span class="normal">1077</span>
<span class="normal">1078</span>
<span class="normal">1079</span>
<span class="normal">1080</span>
<span class="normal">1081</span>
<span class="normal">1082</span>
<span class="normal">1083</span>
<span class="normal">1084</span>
<span class="normal">1085</span>
<span class="normal">1086</span>
<span class="normal">1087</span>
<span class="normal">1088</span>
<span class="normal">1089</span>
<span class="normal">1090</span>
<span class="normal">1091</span>
<span class="normal">1092</span>
<span class="normal">1093</span>
<span class="normal">1094</span>
<span class="normal">1095</span>
<span class="normal">1096</span>
<span class="normal">1097</span>
<span class="normal">1098</span>
<span class="normal">1099</span>
<span class="normal">1100</span>
<span class="normal">1101</span>
<span class="normal">1102</span>
<span class="normal">1103</span>
<span class="normal">1104</span>
<span class="normal">1105</span>
<span class="normal">1106</span>
<span class="normal">1107</span>
<span class="normal">1108</span>
<span class="normal">1109</span>
<span class="normal">1110</span>
<span class="normal">1111</span>
<span class="normal">1112</span>
<span class="normal">1113</span>
<span class="normal">1114</span>
<span class="normal">1115</span>
<span class="normal">1116</span>
<span class="normal">1117</span>
<span class="normal">1118</span>
<span class="normal">1119</span>
<span class="normal">1120</span>
<span class="normal">1121</span>
<span class="normal">1122</span>
<span class="normal">1123</span>
<span class="normal">1124</span>
<span class="normal">1125</span>
<span class="normal">1126</span>
<span class="normal">1127</span>
<span class="normal">1128</span>
<span class="normal">1129</span>
<span class="normal">1130</span>
<span class="normal">1131</span>
<span class="normal">1132</span>
<span class="normal">1133</span>
<span class="normal">1134</span>
<span class="normal">1135</span>
<span class="normal">1136</span>
<span class="normal">1137</span>
<span class="normal">1138</span>
<span class="normal">1139</span>
<span class="normal">1140</span>
<span class="normal">1141</span>
<span class="normal">1142</span>
<span class="normal">1143</span>
<span class="normal">1144</span>
<span class="normal">1145</span>
<span class="normal">1146</span>
<span class="normal">1147</span>
<span class="normal">1148</span>
<span class="normal">1149</span>
<span class="normal">1150</span>
<span class="normal">1151</span>
<span class="normal">1152</span>
<span class="normal">1153</span>
<span class="normal">1154</span>
<span class="normal">1155</span>
<span class="normal">1156</span>
<span class="normal">1157</span>
<span class="normal">1158</span>
<span class="normal">1159</span>
<span class="normal">1160</span>
<span class="normal">1161</span>
<span class="normal">1162</span>
<span class="normal">1163</span>
<span class="normal">1164</span>
<span class="normal">1165</span>
<span class="normal">1166</span>
<span class="normal">1167</span>
<span class="normal">1168</span>
<span class="normal">1169</span>
<span class="normal">1170</span>
<span class="normal">1171</span>
<span class="normal">1172</span>
<span class="normal">1173</span>
<span class="normal">1174</span>
<span class="normal">1175</span>
<span class="normal">1176</span>
<span class="normal">1177</span>
<span class="normal">1178</span>
<span class="normal">1179</span>
<span class="normal">1180</span>
<span class="normal">1181</span>
<span class="normal">1182</span>
<span class="normal">1183</span>
<span class="normal">1184</span>
<span class="normal">1185</span>
<span class="normal">1186</span>
<span class="normal">1187</span>
<span class="normal">1188</span>
<span class="normal">1189</span>
<span class="normal">1190</span>
<span class="normal">1191</span>
<span class="normal">1192</span>
<span class="normal">1193</span>
<span class="normal">1194</span>
<span class="normal">1195</span>
<span class="normal">1196</span>
<span class="normal">1197</span>
<span class="normal">1198</span>
<span class="normal">1199</span>
<span class="normal">1200</span>
<span class="normal">1201</span>
<span class="normal">1202</span>
<span class="normal">1203</span>
<span class="normal">1204</span>
<span class="normal">1205</span>
<span class="normal">1206</span>
<span class="normal">1207</span>
<span class="normal">1208</span>
<span class="normal">1209</span>
<span class="normal">1210</span>
<span class="normal">1211</span>
<span class="normal">1212</span>
<span class="normal">1213</span>
<span class="normal">1214</span>
<span class="normal">1215</span>
<span class="normal">1216</span>
<span class="normal">1217</span>
<span class="normal">1218</span>
<span class="normal">1219</span>
<span class="normal">1220</span>
<span class="normal">1221</span>
<span class="normal">1222</span>
<span class="normal">1223</span>
<span class="normal">1224</span>
<span class="normal">1225</span>
<span class="normal">1226</span>
<span class="normal">1227</span></pre></div></td><td class="code"><div><pre><div id="l1" class="code_block"><span class="k">\chapter</span><span class="nb">{</span>Debugging and Profiling<span class="nb">}</span> <span class="k">\label</span><span class="nb">{</span>debugging<span class="nb">}</span>
</div><div id="l2" class="code_block"><span class="c">%====================================</span>
</div><div id="l3" class="code_block"><span class="k">\index</span><span class="nb">{</span>debugger<span class="nb">}</span>
</div><div id="l4" class="code_block"><span class="k">\index</span><span class="nb">{</span>tracing|(<span class="nb">}</span>
</div><div id="l5" class="code_block"><span class="k">\section</span><span class="nb">{</span>Prolog-style Tracing and Debugging<span class="nb">}</span>
</div><div id="l6" class="code_block"><span class="c">%===========================</span>
</div><div id="l7" class="code_block"><span class="k">\index</span><span class="nb">{</span>high-level tracing<span class="nb">}</span> <span class="k">\index</span><span class="nb">{</span>tracing!Prolog Programs<span class="nb">}</span>
</div><div id="l8" class="code_block"><span class="c">%</span>
</div><div id="l9" class="code_block">XSB supports a version of the Byrd four-port debugger for interactive
</div><div id="l10" class="code_block">debugging and tracing of Prolog code.  In this release (<span class="k">\version</span>), it
</div><div id="l11" class="code_block">does not work very well when debugging code involving tabled
</div><div id="l12" class="code_block">predicates~<span class="k">\footnote</span><span class="nb">{</span>The current version of XSB&#39;s Prolog debugger does
</div><div id="l13" class="code_block">  not include exceptions as a debugging port.<span class="nb">}</span>.  If one only creeps
</div><div id="l14" class="code_block">(see below), the tracing can provide some useful information.  For
</div><div id="l15" class="code_block">programs that involve large amounts of tabling forest-view tracing can
</div><div id="l16" class="code_block">be used (Section~<span class="k">\ref</span><span class="nb">{</span>sec:forest-trace<span class="nb">}</span>).
</div><div id="l17" class="code_block">To turn on tracing, use <span class="nb">{</span><span class="k">\tt</span> trace/0<span class="nb">}</span>, <span class="nb">{</span><span class="k">\tt</span> trace/1<span class="nb">}</span>, or <span class="nb">{</span><span class="k">\tt</span> trace/2<span class="nb">}</span>.  To
</div><div id="l18" class="code_block">turn tracing off, use <span class="nb">{</span><span class="k">\tt</span> notrace/0<span class="nb">}</span>.
</div><div id="l19" class="code_block">
</div><div id="l20" class="code_block"><span class="k">\begin</span><span class="nb">{</span>description<span class="nb">}</span>
</div><div id="l21" class="code_block"><span class="k">\repeatstandarditem</span><span class="nb">{</span>trace<span class="nb">}{</span>trace/0<span class="nb">}</span>
</div><div id="l22" class="code_block"><span class="k">\standarditem</span><span class="nb">{</span>notrace<span class="nb">}{</span>notrace/0<span class="nb">}</span>
</div><div id="l23" class="code_block">
</div><div id="l24" class="code_block">When tracing is on, the system will print a message each time a
</div><div id="l25" class="code_block">predicate is:
</div><div id="l26" class="code_block"><span class="k">\begin</span><span class="nb">{</span>enumerate<span class="nb">}</span> <span class="k">\index</span><span class="nb">{</span>debugger!ports<span class="nb">}</span>
</div><div id="l27" class="code_block"><span class="k">\item</span> initially entered (Call), 
</div><div id="l28" class="code_block"><span class="k">\item</span> successfully returned from (Exit), 
</div><div id="l29" class="code_block"><span class="k">\item</span> failed back into (Redo), and
</div><div id="l30" class="code_block"><span class="k">\item</span> completely failed out of (Fail).  
</div><div id="l31" class="code_block"><span class="k">\end</span><span class="nb">{</span>enumerate<span class="nb">}</span>
</div><div id="l32" class="code_block">When debugging interactively, a message may be printed and tracer
</div><div id="l33" class="code_block">stopped and prompts for input.  (See the predicates <span class="nb">{</span><span class="k">\tt</span> show/1<span class="nb">}</span> and
</div><div id="l34" class="code_block"><span class="nb">{</span><span class="k">\tt</span> leash/1<span class="nb">}</span> described below to modify what is traced and when the
</div><div id="l35" class="code_block">user is prompted.)
</div><div id="l36" class="code_block">
</div><div id="l37" class="code_block">In addition to single-step tracing, the user can set spy points to
</div><div id="l38" class="code_block">influence how the tracing/debugging works.  A spy point is set using
</div><div id="l39" class="code_block"><span class="nb">{</span><span class="k">\tt</span> spy/1<span class="nb">}</span>.  Spy points can be used to cause the system to enter the
</div><div id="l40" class="code_block">tracer when a particular predicate is entered. Also the tracer allows
</div><div id="l41" class="code_block">``leaping&#39;&#39; from spy point to spy point during the debugging process.
</div><div id="l42" class="code_block"><span class="c">%</span>
</div><div id="l43" class="code_block">The debugger also has profiling capabilities, which can measure the cpu
</div><div id="l44" class="code_block">time spent in each call. The cpu time is measured only down to 0.0001-th
</div><div id="l45" class="code_block">of a second.
</div><div id="l46" class="code_block">g
</div><div id="l47" class="code_block">When the tracer prompts for input, the user may enter a return, or a single
</div><div id="l48" class="code_block">character followed by a return, with the following meanings:
</div><div id="l49" class="code_block"><span class="k">\bi</span>
</div><div id="l50" class="code_block"><span class="k">\index</span><span class="nb">{</span>trace!options<span class="nb">}</span>
</div><div id="l51" class="code_block"><span class="k">\item</span><span class="nb">{</span><span class="k">\tt</span> c, &lt;CR&gt;<span class="nb">}</span>: <span class="nb">{</span><span class="k">\em</span> Creep<span class="nb">}</span>~ Causes the system to single-step to
</div><div id="l52" class="code_block">  the next port (i.e.<span class="k">\</span> either the entry to a traced predicate called
</div><div id="l53" class="code_block">  by the executed clause, or the success or failure exit from that
</div><div id="l54" class="code_block">  clause).
</div><div id="l55" class="code_block"><span class="k">\item</span><span class="nb">{</span><span class="k">\tt</span> a<span class="nb">}</span>: <span class="nb">{</span><span class="k">\em</span> Abort<span class="nb">}</span>~ <span class="k">\index</span><span class="nb">{</span>abort!trace facility<span class="nb">}</span> Causes execution to abort
</div><div id="l56" class="code_block">  and control to return to the top level interpreter.
</div><div id="l57" class="code_block"><span class="k">\index</span><span class="nb">{</span>break level<span class="nb">}</span>
</div><div id="l58" class="code_block"><span class="k">\item</span><span class="nb">{</span><span class="k">\tt</span> b<span class="nb">}</span>: <span class="nb">{</span><span class="k">\em</span> Break<span class="nb">}</span>~ Calls the evaluable predicate <span class="nb">{</span><span class="k">\em</span> break<span class="nb">}</span>,
</div><div id="l59" class="code_block">  thus invoking recursively a new incarnation of the system
</div><div id="l60" class="code_block">  interpreter.  The command prompt at break level <span class="s">$</span><span class="nb">n</span><span class="s">$</span> is
</div><div id="l61" class="code_block">  <span class="k">\begin</span><span class="nb">{</span>center<span class="nb">}</span>
</div><div id="l62" class="code_block">    <span class="nb">{</span><span class="k">\tt</span> <span class="s">$</span><span class="nb">n</span><span class="s">$</span>: <span class="k">\tt</span> ?-<span class="nb">}</span>
</div><div id="l63" class="code_block">  <span class="k">\end</span><span class="nb">{</span>center<span class="nb">}</span>
</div><div id="l64" class="code_block">  The user may return to the previous break level by entering the system
</div><div id="l65" class="code_block">  end-of-file character (e.g.<span class="k">\</span> <span class="nb">{</span><span class="k">\tt</span> ctrl-D<span class="nb">}</span>), or typing in the atom 
</div><div id="l66" class="code_block">  <span class="nb">{</span><span class="k">\tt</span> end<span class="k">\_of\_file</span><span class="nb">}</span>; or to the top level interpreter by typing in
</div><div id="l67" class="code_block">  <span class="nb">{</span><span class="k">\tt</span> abort<span class="nb">}</span>.
</div><div id="l68" class="code_block"><span class="k">\item</span><span class="nb">{</span><span class="k">\tt</span> f<span class="nb">}</span>: <span class="nb">{</span><span class="k">\em</span> Fail<span class="nb">}</span>~ Causes execution to fail, thus transferring
</div><div id="l69" class="code_block">  control to the Fail port of the current execution.
</div><div id="l70" class="code_block"><span class="k">\item</span><span class="nb">{</span><span class="k">\tt</span> h<span class="nb">}</span>: <span class="nb">{</span><span class="k">\em</span> Help<span class="nb">}</span>~ Displays the table of debugging options.
</div><div id="l71" class="code_block"><span class="k">\item</span><span class="nb">{</span><span class="k">\tt</span> l<span class="nb">}</span>: <span class="nb">{</span><span class="k">\em</span> Leap<span class="nb">}</span>~ Causes the system to resume running the
</div><div id="l72" class="code_block">  program, only stopping when a spy-point is reached or the program
</div><div id="l73" class="code_block">  terminates.  This allows the user to follow the execution at a
</div><div id="l74" class="code_block">  higher level than exhaustive tracing.
</div><div id="l75" class="code_block"><span class="k">\item</span><span class="nb">{</span><span class="k">\tt</span> n<span class="nb">}</span>: <span class="nb">{</span><span class="k">\em</span> Nodebug<span class="nb">}</span>~ Turns off debug mode.
</div><div id="l76" class="code_block"><span class="k">\item</span><span class="nb">{</span><span class="k">\tt</span> r<span class="nb">}</span>: <span class="nb">{</span><span class="k">\em</span> Retry (fail)<span class="nb">}</span>~ Transfers to the Call port of the current
</div><div id="l77" class="code_block">  goal.  Note, however, that side effects, such as database modifications
</div><div id="l78" class="code_block">  etc., are not undone.
</div><div id="l79" class="code_block"><span class="k">\item</span><span class="nb">{</span><span class="k">\tt</span> s<span class="nb">}</span>: <span class="nb">{</span><span class="k">\em</span> Skip<span class="nb">}</span>~ Causes tracing to be turned off for the entire
</div><div id="l80" class="code_block">  execution of the procedure.  Thus, nothing is seen until control comes
</div><div id="l81" class="code_block">  back to that procedure, either at the Success or the Failure port.
</div><div id="l82" class="code_block"><span class="k">\item</span><span class="nb">{</span><span class="k">\tt</span> q<span class="nb">}</span>: <span class="nb">{</span><span class="k">\em</span> Quasi-skip<span class="nb">}</span> This is like Skip except that it does not mask
</div><div id="l83" class="code_block">  out spy points.
</div><div id="l84" class="code_block"><span class="k">\item</span><span class="nb">{</span><span class="k">\tt</span> S<span class="nb">}</span>: <span class="nb">{</span><span class="k">\em</span> Verbose skip<span class="nb">}</span>~ Similar to <span class="nb">{</span><span class="k">\tt</span> Skip<span class="nb">}</span> mode, but trace
</div><div id="l85" class="code_block">  continues to be printed. The user is prompted again when the current call
</div><div id="l86" class="code_block">  terminates with success or failure.  This can be used to obtain a full
</div><div id="l87" class="code_block">  trace to the point where an error occurred or for code profiling. (See
</div><div id="l88" class="code_block">  more about profiling below.)
</div><div id="l89" class="code_block"><span class="k">\item</span><span class="nb">{</span><span class="k">\tt</span> e<span class="nb">}</span>: <span class="nb">{</span><span class="k">\em</span> Exit<span class="nb">}</span>~ Causes immediate exit from <span class="k">\ourprolog\</span> back to the
</div><div id="l90" class="code_block">  operating system.
</div><div id="l91" class="code_block"><span class="k">\ei</span>
</div><div id="l92" class="code_block"><span class="c">%/* TLS: it seems like there may not be much use for the non-queryable trace/1 */</span>
</div><div id="l93" class="code_block">
</div><div id="l94" class="code_block"><span class="k">\standarditem</span><span class="nb">{</span>trace(+Filename,+option)<span class="nb">}{</span>trace/2<span class="nb">}</span>
</div><div id="l95" class="code_block"><span class="k">\index</span><span class="nb">{</span>trace!logging<span class="nb">}</span>
</div><div id="l96" class="code_block"><span class="c">%\index[pred]{\texttt{trace/1}}</span>
</div><div id="l97" class="code_block"><span class="c">%\index{\texttt{trace/1}}</span>
</div><div id="l98" class="code_block"><span class="c">%</span>
</div><div id="l99" class="code_block"><span class="nb">{</span><span class="k">\tt</span> trace/2<span class="nb">}</span> is like <span class="nb">{</span><span class="k">\tt</span> trace/0<span class="nb">}</span> except that it is non-interactive
</div><div id="l100" class="code_block">and dumps trace information into a log file, <span class="nb">{</span><span class="k">\tt</span> Filename<span class="nb">}</span>.
</div><div id="l101" class="code_block">Currently the only supported option is <span class="k">\texttt</span><span class="nb">{</span>log<span class="nb">}</span>.  However, the log
</div><div id="l102" class="code_block">is written in the form of Prolog facts, which can be loaded
</div><div id="l103" class="code_block">queried. The format of the facts is:
</div><div id="l104" class="code_block"><span class="c">%% </span>
</div><div id="l105" class="code_block"><span class="k">\begin</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l106" class="code_block">xsb<span class="nb">_</span>tracelog(CallId,CallNum,PortType,ParentCallNum,DepthOfCall,CurrentCall,Time)
</div><div id="l107" class="code_block"><span class="k">\end</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l108" class="code_block"><span class="c">%% </span>
</div><div id="l109" class="code_block">where <span class="k">\texttt</span><span class="nb">{</span>CallId<span class="nb">}</span> is an identifier generated when XSB encounters a
</div><div id="l110" class="code_block">new top-level call. This identifier remains the same for all subgoals
</div><div id="l111" class="code_block">called while tracing that top-level call.
</div><div id="l112" class="code_block"><span class="k">\bi</span>
</div><div id="l113" class="code_block"><span class="k">\item</span> <span class="k">\texttt</span><span class="nb">{</span>CallNum<span class="nb">}</span> is a generated number to show the nesting of
</div><div id="l114" class="code_block">  the calls being traced. It is the same number that the user sees
</div><div id="l115" class="code_block">  when tracing interactively.
</div><div id="l116" class="code_block"><span class="c">%</span>
</div><div id="l117" class="code_block"><span class="k">\item</span> <span class="k">\texttt</span><span class="nb">{</span>PortType<span class="nb">}</span> is <span class="k">\texttt</span><span class="nb">{</span>&#39;Call&#39;<span class="nb">}</span>, <span class="k">\texttt</span><span class="nb">{</span>&#39;Redo&#39;<span class="nb">}</span>,
</div><div id="l118" class="code_block">  <span class="k">\texttt</span><span class="nb">{</span>&#39;Exit&#39;<span class="nb">}</span>, or <span class="k">\texttt</span><span class="nb">{</span>&#39;Fail&#39;<span class="nb">}</span>.  
</div><div id="l119" class="code_block"><span class="k">\item</span> <span class="k">\texttt</span><span class="nb">{</span>ParentCallNum<span class="nb">}</span> is the call number of the parent call.
</div><div id="l120" class="code_block"><span class="c">%</span>
</div><div id="l121" class="code_block"><span class="k">\item</span> <span class="k">\texttt</span><span class="nb">{</span>DepthOfCall<span class="nb">}</span> is the nesting depth of the current call
</div><div id="l122" class="code_block">  with respect to its ancestor calls.  
</div><div id="l123" class="code_block"><span class="c">%</span>
</div><div id="l124" class="code_block"><span class="k">\item</span> <span class="k">\texttt</span><span class="nb">{</span>CurrentCall<span class="nb">}</span> is the call being traced
</div><div id="l125" class="code_block"><span class="c">%</span>
</div><div id="l126" class="code_block"><span class="k">\item</span> <span class="k">\texttt</span><span class="nb">{</span>Time<span class="nb">}</span> is the CPU time it took to execute
</div><div id="l127" class="code_block">  <span class="k">\texttt</span><span class="nb">{</span>CurrentCall<span class="nb">}</span>. On <span class="k">\texttt</span><span class="nb">{</span>&#39;Call&#39;<span class="nb">}</span> and <span class="k">\texttt</span><span class="nb">{</span>&#39;Redo&#39;<span class="nb">}</span>,
</div><div id="l128" class="code_block">  <span class="k">\texttt</span><span class="nb">{</span>Time<span class="nb">}</span> is always 0 --- it has a meaningful value only for the
</div><div id="l129" class="code_block">  <span class="k">\texttt</span><span class="nb">{</span>&#39;Exit&#39;<span class="nb">}</span> and <span class="k">\texttt</span><span class="nb">{</span>&#39;Fail&#39;<span class="nb">}</span> log entries. 
</div><div id="l130" class="code_block"><span class="k">\end</span><span class="nb">{</span>itemize<span class="nb">}</span>
</div><div id="l131" class="code_block">It should be noted that when calls are delayed due to the well-founded
</div><div id="l132" class="code_block">negation computation of because of the <span class="k">\texttt</span><span class="nb">{</span>when/2<span class="nb">}</span> primitive, the
</div><div id="l133" class="code_block">parent call might be off in some cases. However, the parent property
</div><div id="l134" class="code_block">repairs itself for subsequent calls.
</div><div id="l135" class="code_block">
</div><div id="l136" class="code_block">`The name of the predicate (<span class="k">\texttt</span><span class="nb">{</span>xsb<span class="k">\_tracelog</span><span class="nb">}</span>) used for logging
</div><div id="l137" class="code_block">can be changed by asserting it into the predicate
</div><div id="l138" class="code_block"><span class="k">\texttt</span><span class="nb">{</span>debug<span class="k">\_tracelog\_predicate</span>/1<span class="nb">}</span>, which should be imported from
</div><div id="l139" class="code_block"><span class="k">\texttt</span><span class="nb">{</span>usermod<span class="nb">}</span>. For instance,
</div><div id="l140" class="code_block"><span class="c">%% </span>
</div><div id="l141" class="code_block"><span class="k">\begin</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l142" class="code_block">   :- import debug<span class="nb">_</span>tracelog<span class="nb">_</span>predicate/1 from usermod.
</div><div id="l143" class="code_block">   ?- assert(debug<span class="nb">_</span>tracelog<span class="nb">_</span>predicate(foobar)).
</div><div id="l144" class="code_block"><span class="k">\end</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l145" class="code_block"><span class="c">%% </span>
</div><div id="l146" class="code_block">
</div><div id="l147" class="code_block"><span class="k">\standarditem</span><span class="nb">{</span>spy(Preds)<span class="nb">}{</span>spy/1<span class="nb">}</span>
</div><div id="l148" class="code_block">    where <span class="nb">{</span><span class="k">\tt</span> Preds<span class="nb">}</span> is a spy specification or a list of such
</div><div id="l149" class="code_block">    specifications, and must be instantiated. This predicate sets spy
</div><div id="l150" class="code_block">    points (conditional or unconditional) on predicates.  A spy
</div><div id="l151" class="code_block">    specification can be of several forms. Most simply, it is a term
</div><div id="l152" class="code_block">    of the form <span class="s">$</span><span class="nb">P</span><span class="s">$</span>/<span class="s">$</span><span class="nb">N</span><span class="s">$</span>, where <span class="s">$</span><span class="nb">P</span><span class="s">$</span> is a predicate name and <span class="s">$</span><span class="nb">N</span><span class="s">$</span> its
</div><div id="l153" class="code_block">    arity.  Optionally, only a predicate name can be provided, in
</div><div id="l154" class="code_block">    which case it refers to all predicates of any arity currently
</div><div id="l155" class="code_block">    defined in <span class="nb">{</span><span class="k">\tt</span> usermod<span class="nb">}</span>.  It may optionally be prefixed by a
</div><div id="l156" class="code_block">    module name, e.g.  <span class="s">$</span><span class="nb">ModName</span><span class="s">$</span>:<span class="s">$</span><span class="nb">P</span><span class="s">$</span>/<span class="s">$</span><span class="nb">N</span><span class="s">$</span>. (Again, if the arity is
</div><div id="l157" class="code_block">    omitted, the specification refers to all predicates of any arity
</div><div id="l158" class="code_block">    with the given name currently defined in the given module.)  A spy
</div><div id="l159" class="code_block">    specification may also indicate a conditional spy point. A
</div><div id="l160" class="code_block">    conditional spy specification is a Prolog rule, the head
</div><div id="l161" class="code_block">    indicating the predicate to spy, and the body indicating
</div><div id="l162" class="code_block">    conditions under which to spy. For example, to spy the predicate
</div><div id="l163" class="code_block">    p/2 when the first argument is not a variable, one would write:
</div><div id="l164" class="code_block">    <span class="s">$</span><span class="nb">spy </span><span class="o">(</span><span class="nb">p</span><span class="o">(</span><span class="nb">X,</span><span class="nv">\_</span><span class="o">)</span><span class="nb">:</span><span class="o">-</span><span class="nb">nonvar</span><span class="o">(</span><span class="nb">X</span><span class="o">))</span><span class="nb">.</span><span class="s">$</span> (Notice that the parentheses around
</div><div id="l165" class="code_block">    the rule are necessary). The body may be empty, i.e., the rule may
</div><div id="l166" class="code_block">    just be a fact.  The head of a rule may also be prefixed (using
</div><div id="l167" class="code_block">    <span class="s">$</span><span class="nb">:</span><span class="s">$</span>) with a module name. One should not put both conditional and
</div><div id="l168" class="code_block">    unconditional spy points on the same predicate.
</div><div id="l169" class="code_block">
</div><div id="l170" class="code_block"><span class="k">\standarditem</span><span class="nb">{</span>nospy(Preds)<span class="nb">}{</span>nospy/1<span class="nb">}</span>
</div><div id="l171" class="code_block">    where <span class="nb">{</span><span class="k">\tt</span> Preds<span class="nb">}</span> is a spy specification, or a list of such
</div><div id="l172" class="code_block">    specifications, and must be instantiated at the time of call.  What
</div><div id="l173" class="code_block">    constitutes a spy specification is described above under <span class="nb">{</span><span class="k">\tt</span> spy<span class="nb">}</span>.
</div><div id="l174" class="code_block">    <span class="nb">{</span><span class="k">\tt</span> nospy<span class="nb">}</span> removes spy points on the specified predicates. If a
</div><div id="l175" class="code_block">    specification is given in the form of a fact, all conditional spy points
</div><div id="l176" class="code_block">    whose heads match that fact are removed.
</div><div id="l177" class="code_block">
</div><div id="l178" class="code_block"><span class="k">\standarditem</span><span class="nb">{</span>debug<span class="nb">}{</span>debug/0<span class="nb">}</span>
</div><div id="l179" class="code_block">    Turns on debugging mode.
</div><div id="l180" class="code_block">    This causes subsequent execution of predicates with trace or spy
</div><div id="l181" class="code_block">    points to be traced, and is a no-op if there are no such predicates.
</div><div id="l182" class="code_block">    The predicates <span class="nb">{</span><span class="k">\tt</span> trace/0<span class="nb">}</span>, <span class="nb">{</span><span class="k">\tt</span> trace/1<span class="nb">}</span>, <span class="k">\texttt</span><span class="nb">{</span>trace/2<span class="nb">}</span>,  and <span class="nb">{</span><span class="k">\tt</span> spy/1<span class="nb">}</span> cause debugging mode
</div><div id="l183" class="code_block">    to be turned on automatically.
</div><div id="l184" class="code_block">
</div><div id="l185" class="code_block"><span class="k">\standarditem</span><span class="nb">{</span>nodebug<span class="nb">}{</span>nodebug/0<span class="nb">}</span>
</div><div id="l186" class="code_block">    Turns off debugging mode.  This causes trace and spy points to be ignored.
</div><div id="l187" class="code_block">
</div><div id="l188" class="code_block"><span class="k">\standarditem</span><span class="nb">{</span>debugging<span class="nb">}{</span>debugging/0<span class="nb">}</span>
</div><div id="l189" class="code_block">    Displays information about whether debug mode is on or not, and lists
</div><div id="l190" class="code_block">    predicates that have trace points or spy points set on them.
</div><div id="l191" class="code_block">
</div><div id="l192" class="code_block"><span class="k">\standarditem</span><span class="nb">{</span>debug<span class="k">\_ctl</span>(option,value)<span class="nb">}{</span>debug<span class="k">\_ctl</span>/2<span class="nb">}</span>
</div><div id="l193" class="code_block">   <span class="nb">{</span><span class="k">\tt</span> debug<span class="k">\_ctl</span>/2<span class="nb">}</span> performs debugger control functions as described below.
</div><div id="l194" class="code_block">   These commands can be entered before starting a trace or inside the trace.
</div><div id="l195" class="code_block">   The latter can be done by responding with ``<span class="nb">{</span><span class="k">\tt</span> b<span class="nb">}</span>&#39;&#39; at the prompt,
</div><div id="l196" class="code_block">   which recursively invokes an XSB sub-session. At this point, you can
</div><div id="l197" class="code_block">   enter the debugger control commands and type <span class="k">\verb</span>|end<span class="nb">_</span>of<span class="nb">_</span>file.| This
</div><div id="l198" class="code_block">   returns XSB back to the debugger prompt, but with new settings.
</div><div id="l199" class="code_block">   <span class="c">%%</span>
</div><div id="l200" class="code_block">   <span class="k">\begin</span><span class="nb">{</span>enumerate<span class="nb">}</span>
</div><div id="l201" class="code_block">   <span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> debug<span class="k">\_ctl</span>(prompt, off)<span class="nb">}</span> Set non-interactive mode globally.
</div><div id="l202" class="code_block">     This means that trace will be printed from start to end, and the user
</div><div id="l203" class="code_block">     will never be prompted during the trace.
</div><div id="l204" class="code_block">    <span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> debug<span class="k">\_ctl</span>(prompt, on)<span class="nb">}</span> 
</div><div id="l205" class="code_block">      Make tracing/spying interactive.
</div><div id="l206" class="code_block">    <span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> debug<span class="k">\_ctl</span>(profile, on)<span class="nb">}</span>  
</div><div id="l207" class="code_block">      Turns profiling on. This means that each time a call execution
</div><div id="l208" class="code_block">      reaches the <span class="nb">{</span><span class="k">\tt</span> Fail<span class="nb">}</span> or <span class="nb">{</span><span class="k">\tt</span> Exit<span class="nb">}</span> port, CPU time spent in that
</div><div id="l209" class="code_block">      call will be printed. The actual call can be identified by locating a
</div><div id="l210" class="code_block">      <span class="nb">{</span><span class="k">\tt</span> Call<span class="nb">}</span>  prompt that has the same number as the ``cpu time&#39;&#39;
</div><div id="l211" class="code_block">      message.
</div><div id="l212" class="code_block">    <span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> debug<span class="k">\_ctl</span>(profile, off)<span class="nb">}</span>  
</div><div id="l213" class="code_block">      Turns profiling off.
</div><div id="l214" class="code_block">    <span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> debug<span class="k">\_ctl</span>(redirect, +File)<span class="nb">}</span> 
</div><div id="l215" class="code_block">      Redirects debugging output to a file. This also includes program output,
</div><div id="l216" class="code_block">      errors and warnings.
</div><div id="l217" class="code_block">      Note that usually you cannot see the contents of <span class="nb">{</span><span class="k">\tt</span> +File<span class="nb">}</span> until it
</div><div id="l218" class="code_block">      is closed, <span class="nb">{</span><span class="k">\it</span> i.e.<span class="nb">}</span>, until another redirect operation is performed
</div><div id="l219" class="code_block">      (usually <span class="nb">{</span><span class="k">\tt</span> debug<span class="k">\_ctl</span>(redirect, tty)<span class="nb">}</span>, see next).
</div><div id="l220" class="code_block">    <span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> debug<span class="k">\_ctl</span>(redirect, tty)<span class="nb">}</span>     
</div><div id="l221" class="code_block">      Attaches the previously redirected debugging, error, program output,
</div><div id="l222" class="code_block">      and warning streams back to the user terminal.
</div><div id="l223" class="code_block">    <span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> debug<span class="k">\_ctl</span>(show, +PortList)<span class="nb">}</span>  
</div><div id="l224" class="code_block">      Allows the user to specify at which ports should trace messages be
</div><div id="l225" class="code_block">      printed. <span class="nb">{</span><span class="k">\tt</span> PortList<span class="nb">}</span> must be a list of port names, i.e., a sublist
</div><div id="l226" class="code_block">      of [&#39;Call&#39;, &#39;Exit&#39;, &#39;Redo&#39;, &#39;Fail&#39;]. 
</div><div id="l227" class="code_block">    <span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> debug<span class="k">\_ctl</span>(leash, +PortList)<span class="nb">}</span>  
</div><div id="l228" class="code_block">      Allows the user to specify at which ports the tracer should stop
</div><div id="l229" class="code_block">      and prompt the user for direction.  <span class="nb">{</span><span class="k">\tt</span> PortList<span class="nb">}</span> must be a list of
</div><div id="l230" class="code_block">      port names, i.e., a sublist of [&#39;Call&#39;, &#39;Exit&#39;, &#39;Redo&#39;, &#39;Fail&#39;].  Only
</div><div id="l231" class="code_block">      ports that are <span class="nb">{</span><span class="k">\tt</span> show<span class="nb">}</span>-n can be <span class="nb">{</span><span class="k">\tt</span> leash<span class="nb">}</span>-ed. 
</div><div id="l232" class="code_block">    <span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> debug<span class="k">\_ctl</span>(hide, +PredArityPairList)<span class="nb">}</span>  
</div><div id="l233" class="code_block">      The list must be of the form <span class="nb">{</span><span class="k">\tt</span> [P1/A1, P2/A2, ...]<span class="nb">}</span>, <span class="nb">{</span><span class="k">\it</span> i.e.<span class="nb">}</span>,
</div><div id="l234" class="code_block">      each either must specify a predicate-arity pair. Each predicate on
</div><div id="l235" class="code_block">      the list will become non-traceable. That is, during the trace, each
</div><div id="l236" class="code_block">      such predicate will be treated as an black-box procedure, and trace
</div><div id="l237" class="code_block">      will not go into it.
</div><div id="l238" class="code_block">    <span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> debug<span class="k">\_ctl</span>(unhide, ?PredArityPairList)<span class="nb">}</span> If the list is a
</div><div id="l239" class="code_block">      predicate-arity list, every predicate on that list will become
</div><div id="l240" class="code_block">      traceable again. Items in the list can contain variables. For
</div><div id="l241" class="code_block">      instance, <span class="nb">{</span><span class="k">\tt</span> debug<span class="k">\_ctl</span>(unhide, [<span class="k">\_</span>/2])<span class="nb">}</span> will make all 2-ary that
</div><div id="l242" class="code_block">      were previously made untraceable traceable again.  As a special case,
</div><div id="l243" class="code_block">      if <span class="nb">{</span><span class="k">\tt</span> PredArityPairList<span class="nb">}</span> is a variable, all predicates previously
</div><div id="l244" class="code_block">      placed on the ``untraceable&#39;&#39;-list will be taken off.
</div><div id="l245" class="code_block">    <span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> debug<span class="k">\_ctl</span>(hidden, -List)<span class="nb">}</span>
</div><div id="l246" class="code_block">      This returns the list of predicates that the user said should not be
</div><div id="l247" class="code_block">      traced.
</div><div id="l248" class="code_block">   <span class="k">\end</span><span class="nb">{</span>enumerate<span class="nb">}</span>
</div><div id="l249" class="code_block">   <span class="c">%%</span>
</div><div id="l250" class="code_block"><span class="k">\end</span><span class="nb">{</span>description<span class="nb">}</span>
</div><div id="l251" class="code_block">
</div><div id="l252" class="code_block">
</div><div id="l253" class="code_block"><span class="k">\section</span><span class="nb">{</span>Low-Level Tracing<span class="nb">}</span>
</div><div id="l254" class="code_block"><span class="c">%--------------------------------------------------</span>
</div><div id="l255" class="code_block"><span class="k">\index</span><span class="nb">{</span>low-level tracing<span class="nb">}</span> <span class="k">\index</span><span class="nb">{</span>tracing!low-level<span class="nb">}</span>
</div><div id="l256" class="code_block">
</div><div id="l257" class="code_block">XSB also provides a facility for low-level tracing of execution.  This
</div><div id="l258" class="code_block">can be activated by invoking the emulator with the <span class="nb">{</span><span class="k">\tt</span> -T<span class="nb">}</span> option
</div><div id="l259" class="code_block">(see Section~<span class="k">\ref</span><span class="nb">{</span>sec:EmuOptions<span class="nb">}</span>), or through the predicate <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l260" class="code_block">  trace/0<span class="nb">}</span>.  <span class="k">\stdrefindex</span><span class="nb">{</span><span class="k">\$</span>trace/0<span class="nb">}</span> It causes trace information to
</div><div id="l261" class="code_block">be printed out at every call (including those to system trap
</div><div id="l262" class="code_block">handlers).  The volume of such trace information can very become large
</div><div id="l263" class="code_block">very quickly, so this method of tracing is not recommended in general.
</div><div id="l264" class="code_block">
</div><div id="l265" class="code_block"><span class="k">\bigskip</span>
</div><div id="l266" class="code_block">
</div><div id="l267" class="code_block">XSB debugger also provides means for the low-level control of what
</div><div id="l268" class="code_block">must be traced. Normally, various standard predicates are masked out
</div><div id="l269" class="code_block">from the trace, since these predicates do not make sense to the
</div><div id="l270" class="code_block">application programmer.  However, if tracing below the application
</div><div id="l271" class="code_block">level is needed, you can retract some of the facts specified in the
</div><div id="l272" class="code_block">file <span class="nb">{</span><span class="k">\tt</span> syslib/debugger<span class="k">\_data</span>.P<span class="nb">}</span> (and in some cases assert into
</div><div id="l273" class="code_block">them). All these predicates are documented in the header of that
</div><div id="l274" class="code_block">file. Here we only mention the four predicates that an XSB developer
</div><div id="l275" class="code_block">is more likely to need. To get more trace, you should retract from the
</div><div id="l276" class="code_block">first three predicates and assert into the last one.
</div><div id="l277" class="code_block"><span class="c">%%</span>
</div><div id="l278" class="code_block"><span class="k">\begin</span><span class="nb">{</span>itemize<span class="nb">}</span>
</div><div id="l279" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> hide<span class="k">\_this\_show</span>(Pred,Arity)<span class="nb">}</span>: specifies calls (predicate name and
</div><div id="l280" class="code_block">  arity) that the debugger should <span class="nb">{</span><span class="k">\tt</span> not<span class="nb">}</span> show at the prompt. However,
</div><div id="l281" class="code_block">  the evaluation of this hidden call <span class="nb">{</span><span class="k">\tt</span> is<span class="nb">}</span> traced.
</div><div id="l282" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> hide<span class="k">\_this\_hide</span>(Pred,Arity)<span class="nb">}</span>: specifies calls to hide. Trace
</div><div id="l283" class="code_block">  remains off while evaluating those predicates. Once trace is off, there
</div><div id="l284" class="code_block">  is no way to resume it until the hidden predicate exits or fails.
</div><div id="l285" class="code_block"><span class="k">\item</span>  <span class="nb">{</span><span class="k">\tt</span> show<span class="k">\_this\_hide</span>(Pred,Arity)<span class="nb">}</span>: calls to show at the
</div><div id="l286" class="code_block">  prompt. However, trace is switched off right after that.
</div><div id="l287" class="code_block"><span class="k">\item</span>  <span class="nb">{</span><span class="k">\tt</span> trace<span class="k">\_standard\_predicate</span>(Pred,Arity)<span class="nb">}</span>: Normally trace doesn&#39;t
</div><div id="l288" class="code_block">  go inside standard predicates (<span class="nb">{</span><span class="k">\it</span> i.e.<span class="nb">}</span>, those specified in
</div><div id="l289" class="code_block">  <span class="nb">{</span><span class="k">\tt</span> syslib/std<span class="k">\_xsb</span>.P<span class="nb">}</span>. If you need to trace some of those, you must
</div><div id="l290" class="code_block">  <span class="nb">{</span><span class="k">\tt</span> assert<span class="nb">}</span> into this predicate.
</div><div id="l291" class="code_block"><span class="k">\end</span><span class="nb">{</span>itemize<span class="nb">}</span>
</div><div id="l292" class="code_block"><span class="c">%%</span>
</div><div id="l293" class="code_block">In principle, by retracting all facts from the first three predicates and
</div><div id="l294" class="code_block">asserting enough facts into the last one, it is possible to achieve the
</div><div id="l295" class="code_block">behavior that approximates the <span class="nb">{</span><span class="k">\tt</span> -T<span class="nb">}</span> option. However, unlike <span class="nb">{</span><span class="k">\tt</span> -T<span class="nb">}</span>,
</div><div id="l296" class="code_block">debugging can be done interactively. This does not obviate <span class="nb">{</span><span class="k">\tt</span> -T<span class="nb">}</span>,
</div><div id="l297" class="code_block">however. First, it is easier to use <span class="nb">{</span><span class="k">\tt</span> -T<span class="nb">}</span> than to issue multiple asserts
</div><div id="l298" class="code_block">and retracts. Second, <span class="nb">{</span><span class="k">\tt</span> -T<span class="nb">}</span> can be used when the error occurs early on,
</div><div id="l299" class="code_block">before the moment when XSB shows its first prompt.
</div><div id="l300" class="code_block">
</div><div id="l301" class="code_block"><span class="c">%-----------------------------------------------------------------------------</span>
</div><div id="l302" class="code_block"><span class="k">\newcommand</span><span class="nb">{</span><span class="k">\ctrace</span><span class="nb">}{{</span><span class="k">\tt</span> logforest<span class="nb">}}</span>
</div><div id="l303" class="code_block">
</div><div id="l304" class="code_block"><span class="k">\section</span><span class="nb">{</span>Analyzing the Execution of Tabled Programs<span class="nb">}</span> <span class="k">\label</span><span class="nb">{</span>sec:forest-trace<span class="nb">}</span>
</div><div id="l305" class="code_block"><span class="c">%</span>
</div><div id="l306" class="code_block">The tracing and debugging described in previous sections has proven
</div><div id="l307" class="code_block">useful for Prolog programs for 30 or more years.  However, when
</div><div id="l308" class="code_block">tabling is added to Prolog, things change.  First, as described in
</div><div id="l309" class="code_block">Chapter~<span class="k">\ref</span><span class="nb">{</span>chap:TablingOverview<span class="nb">}</span>, tabling can be used to find the
</div><div id="l310" class="code_block">least fixed point of mutually recursive predicates.  Operationally,
</div><div id="l311" class="code_block">this requires the ability to suspend one computation path and to
</div><div id="l312" class="code_block">resume another.  Second, the addition of tabled negation for the
</div><div id="l313" class="code_block">well-founded semantics requires the ability to delay negative goals
</div><div id="l314" class="code_block">whose only proof may be involved in a loop through negation and to
</div><div id="l315" class="code_block">simplify these goals once their truth value has become
</div><div id="l316" class="code_block">known. Furthermore, a tabled subgoal has different states: it may be
</div><div id="l317" class="code_block"><span class="nb">{</span><span class="k">\em</span> new<span class="nb">}</span>; it may be <span class="nb">{</span><span class="k">\em</span> incomplete<span class="nb">}</span> so that new answers might be
</div><div id="l318" class="code_block">derived for it; or <span class="nb">{</span><span class="k">\em</span> completed<span class="nb">}</span> (completely evaluated) so that the
</div><div id="l319" class="code_block">answers may simply be read from the table.  In short, tabling, which
</div><div id="l320" class="code_block">can execute much more general programs than Prolog and which can use
</div><div id="l321" class="code_block">the stronger well-founded semantics, requires a more complex set of
</div><div id="l322" class="code_block">operations than Prolog&#39;s SLDNF.  Accordingsly, debugging and tracing
</div><div id="l323" class="code_block">is correspondingly more complex.  Thus, while Prolog&#39;s 4-port debugger
</div><div id="l324" class="code_block">may be useful for programs that involve just a few tabled predicates,
</div><div id="l325" class="code_block">it may not be useful for programs that heavily use tabling for complex
</div><div id="l326" class="code_block">recursions, non-monotinic reasoning or other purposes.
</div><div id="l327" class="code_block">
</div><div id="l328" class="code_block">There is currently no standard approach to debugging tabled programs.
</div><div id="l329" class="code_block">One possible approach would be to extend the 4-port debugger to
</div><div id="l330" class="code_block">include other ports for tabling operations.  Such extensions have not
</div><div id="l331" class="code_block">yet been explored, and whether the paradigm of n-port debugging can be
</div><div id="l332" class="code_block">extended to full tabling so that it can be useful to programmers is an
</div><div id="l333" class="code_block">open question.  Another approach would be use the declarative approach
</div><div id="l334" class="code_block">of <span class="nb">{</span><span class="k">\em</span> justification<span class="nb">}</span> <span class="k">\cite</span><span class="nb">{</span>GuRR01,PGDRR04<span class="nb">}</span> to explain why
</div><div id="l335" class="code_block">derivations were or were not made.  XSB does in fact have a
</div><div id="l336" class="code_block">justification package but it is not currently robust enough to be
</div><div id="l337" class="code_block">recommended for general use.  Below we present the <span class="nb">{</span><span class="k">\tt</span> <span class="k">\ctrace</span><span class="nb">}</span>
</div><div id="l338" class="code_block">approach.
</div><div id="l339" class="code_block">
</div><div id="l340" class="code_block"><span class="k">\subsection</span><span class="nb">{</span>Tracing a tabled evaluation through forest logging<span class="nb">}</span>
</div><div id="l341" class="code_block"><span class="c">%</span>
</div><div id="l342" class="code_block">While the operations used for tabling are more complex than those of
</div><div id="l343" class="code_block">SLDNF, they have a clear formal operational semantics through SLG and
</div><div id="l344" class="code_block">the forest-of-trees model.  We recall this model briefly below for a
</div><div id="l345" class="code_block">definite program but assume a background knowledge of tabled logic
</div><div id="l346" class="code_block">programming (see, for instance~<span class="k">\cite</span><span class="nb">{</span>SwiW12<span class="nb">}</span>).
</div><div id="l347" class="code_block">
</div><div id="l348" class="code_block"><span class="k">\begin</span><span class="nb">{</span>example<span class="nb">}</span> <span class="k">\rm</span> 
</div><div id="l349" class="code_block">Figure~<span class="k">\ref</span><span class="nb">{</span>fig:local<span class="nb">}</span> shows a program fragment along with an SLG
</div><div id="l350" class="code_block">forest for the query <span class="nb">{</span><span class="k">\tt</span> ?- reach(1,Y)<span class="nb">}</span> to the the right-recursive
</div><div id="l351" class="code_block">tabled predicate <span class="nb">{</span><span class="k">\tt</span> reach/1<span class="nb">}</span>.  An SLG forest consists of an SLG tree
</div><div id="l352" class="code_block">for each tabled subgoal <span class="s">$</span><span class="nb">S</span><span class="s">$</span>: this tree has root <span class="s">$</span><span class="nb">S </span><span class="nv">\mif</span><span class="nb">{} S</span><span class="s">$</span>.  In a
</div><div id="l353" class="code_block">definite program an SLG tree represents resolution of program clauses
</div><div id="l354" class="code_block">and answers to prove <span class="s">$</span><span class="nb">S</span><span class="s">$</span>.  In Figure~<span class="k">\ref</span><span class="nb">{</span>fig:local<span class="nb">}</span> each non-root
</div><div id="l355" class="code_block">node of the form <span class="s">$</span><span class="nb">K. N</span><span class="s">$</span> where <span class="s">$</span><span class="nb">N </span><span class="o">=</span><span class="nb"> </span><span class="o">(</span><span class="nb">S </span><span class="nv">\mif</span><span class="nb">{} Goals</span><span class="o">)</span><span class="nv">\theta</span><span class="s">$</span> is a clause
</div><div id="l356" class="code_block">in which the bindings to a subgoal <span class="s">$</span><span class="nb">S</span><span class="s">$</span> are maintained in <span class="s">$</span><span class="nb">S</span><span class="nv">\theta</span><span class="s">$</span>,
</div><div id="l357" class="code_block">the goals remaining to prove <span class="s">$</span><span class="nb">S</span><span class="s">$</span> are in <span class="s">$</span><span class="nb">Goals</span><span class="nv">\theta</span><span class="s">$</span>, and the order
</div><div id="l358" class="code_block">of creation of <span class="s">$</span><span class="nb">N</span><span class="s">$</span> within the tabled evaluation is represented by a
</div><div id="l359" class="code_block">number, <span class="s">$</span><span class="nb">K</span><span class="s">$</span> (local scheduling is used in this example).  Children of a
</div><div id="l360" class="code_block">root node are obtained through resolution of a tabled subgoal against
</div><div id="l361" class="code_block">program clauses.  Children of non-root nodes are obtained through
</div><div id="l362" class="code_block">answer clause resolution, if the left most selected literal is tabled
</div><div id="l363" class="code_block">(e.g. children of node 3 or 11 in the tree for <span class="nb">{</span><span class="k">\tt</span> reach(1,Y)<span class="nb">}</span>), or
</div><div id="l364" class="code_block">through program clause resolution if the leftmost selected literal is
</div><div id="l365" class="code_block">not tabled (e.g. children of nodes 2 and 18 in the tree for <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l366" class="code_block">  reach(1,Y)<span class="nb">}</span>).  Nodes that have empty <span class="nb">{</span><span class="k">\em</span> Goals<span class="nb">}</span> are termed <span class="nb">{</span><span class="k">\em</span>
</div><div id="l367" class="code_block">  answers<span class="nb">}</span>.
</div><div id="l368" class="code_block"><span class="c">%</span>
</div><div id="l369" class="code_block"><span class="k">\begin</span><span class="nb">{</span>figure<span class="nb">}</span>[htbp]
</div><div id="l370" class="code_block"><span class="k">\centering</span>
</div><div id="l371" class="code_block"><span class="k">\includegraphics</span><span class="na">[width=.99\textwidth]</span><span class="nb">{</span>slg-forest-local<span class="nb">}</span>
</div><div id="l372" class="code_block"><span class="c">%%\mbox{</span>
</div><div id="l373" class="code_block"><span class="c">%%{\epsfig{file=slg-forest-local,width=.99\textwidth}}}</span>
</div><div id="l374" class="code_block"><span class="k">\caption</span><span class="nb">{</span>A program <span class="s">$</span><span class="nb">P_{Rrec}</span><span class="s">$</span> and SLG forest for (local) evaluation of
</div><div id="l375" class="code_block">  <span class="nb">{</span><span class="k">\tt</span> ?- reach(1,Y)<span class="nb">}}</span> <span class="k">\label</span><span class="nb">{</span>fig:local<span class="nb">}</span>
</div><div id="l376" class="code_block"><span class="k">\end</span><span class="nb">{</span>figure<span class="nb">}</span>
</div><div id="l377" class="code_block"><span class="c">%</span>
</div><div id="l378" class="code_block">Note that the evaluation keeps track of each tabled subgoal <span class="s">$</span><span class="nb">S</span><span class="s">$</span> that
</div><div id="l379" class="code_block">it encounters.  Later if <span class="s">$</span><span class="nb">S</span><span class="s">$</span> is selected again, resolution will use
</div><div id="l380" class="code_block">answers rather than program clauses; if no answers are available, the
</div><div id="l381" class="code_block">computation will <span class="nb">{</span><span class="k">\em</span> suspend<span class="nb">}</span> at that point and the evaluation will
</div><div id="l382" class="code_block">backtrack to try to derive answers using some other computation path.
</div><div id="l383" class="code_block">Once more answers have been derived, the evaluation <span class="nb">{</span><span class="k">\em</span> resumes<span class="nb">}</span> the
</div><div id="l384" class="code_block">suspended computation.  Similarly, once the computation has
</div><div id="l385" class="code_block">backtracked through all answers available for <span class="s">$</span><span class="nb">S</span><span class="s">$</span> in the current
</div><div id="l386" class="code_block">state, the computation path will suspend, and resume after further
</div><div id="l387" class="code_block">answers are found.  Thus a tabled evaluation is a fixed point
</div><div id="l388" class="code_block">computation for a set of interdependent subgoals.  When it is
</div><div id="l389" class="code_block">etermined that a (perhaps singleton) set of subgoals can produce no
</div><div id="l390" class="code_block">more answers, the subgoals are completed.
</div><div id="l391" class="code_block"><span class="k">\end</span><span class="nb">{</span>example<span class="nb">}</span>
</div><div id="l392" class="code_block">
</div><div id="l393" class="code_block"><span class="c">%\vspace{0.1in}</span>
</div><div id="l394" class="code_block">
</div><div id="l395" class="code_block">The forest logging approach (<span class="nb">{</span><span class="k">\tt</span> <span class="k">\ctrace</span><span class="nb">}</span>) allows one to run a tabled
</div><div id="l396" class="code_block">query and produce a log that can be interpreted as (a partial image
</div><div id="l397" class="code_block">of) an SLG forest.  The log can then used to analyze program
</div><div id="l398" class="code_block">correctness, to optimize performance and so on.  Because <span class="k">\ctrace</span><span class="nb">{}</span>
</div><div id="l399" class="code_block">  produces a log, it superficially resembles the non-interactive trace
</div><div id="l400" class="code_block">  described earlier in this chapter.  However,
</div><div id="l401" class="code_block"><span class="k">\begin</span><span class="nb">{</span>itemize<span class="nb">}</span>
</div><div id="l402" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> trace/1<span class="nb">}</span> produces a Prolog-style trace that takes little
</div><div id="l403" class="code_block">  account of tabling.  <span class="k">\ctrace</span><span class="nb">{}</span> structures its output according to
</div><div id="l404" class="code_block">  the forest-of-trees model, and takes little account of program
</div><div id="l405" class="code_block">  clause resolution.
</div><div id="l406" class="code_block">
</div><div id="l407" class="code_block"><span class="k">\item</span> <span class="k">\ctrace</span><span class="nb">{}</span> is implemented in C for efficiency, while <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l408" class="code_block">  trace/1<span class="nb">}</span> is built on top of XSBs interactive debugger.  Unlike <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l409" class="code_block">  trace/1<span class="nb">}</span>, <span class="k">\ctrace</span><span class="nb">{}</span> can therefore to produce logs for very large
</div><div id="l410" class="code_block">  evaluations with little overhead.
</div><div id="l411" class="code_block"><span class="k">\end</span><span class="nb">{</span>itemize<span class="nb">}</span>
</div><div id="l412" class="code_block">
</div><div id="l413" class="code_block">Currently, <span class="k">\ctrace</span><span class="nb">{}</span> captures the following actions.
</div><div id="l414" class="code_block">
</div><div id="l415" class="code_block"><span class="k">\bi</span>
</div><div id="l416" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\em</span> A call to a tabled subgoal<span class="nb">}</span>~ If a positive call to a tabled
</div><div id="l417" class="code_block">  subgoal <span class="s">$</span><span class="nb">S_</span><span class="m">1</span><span class="s">$</span> is made from a tree for <span class="s">$</span><span class="nb">S_</span><span class="m">2</span><span class="s">$</span> a Prolog-readable fact
</div><div id="l418" class="code_block">  of the form <span class="nb">{</span><span class="k">\tt</span> tc(S1,S2,Stage,Counter)<span class="nb">}</span> is logged, where <span class="nb">{</span><span class="k">\em</span>
</div><div id="l419" class="code_block">    Counter<span class="nb">}</span> is the ordinal number of the fact, and <span class="nb">{</span><span class="k">\tt</span> Stage<span class="nb">}</span> is
</div><div id="l420" class="code_block"><span class="k">\bi</span>
</div><div id="l421" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> new<span class="nb">}</span> if <span class="s">$</span><span class="nb">S_</span><span class="m">1</span><span class="s">$</span> is a new subgoal
</div><div id="l422" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> cmp<span class="nb">}</span> if <span class="s">$</span><span class="nb">S_</span><span class="m">1</span><span class="s">$</span> is not a new subgoal and has been completed
</div><div id="l423" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> incmp<span class="nb">}</span> if <span class="s">$</span><span class="nb">S_</span><span class="m">1</span><span class="s">$</span> is not a new subgoal but has <span class="nb">{</span><span class="k">\em</span> not<span class="nb">}</span> been
</div><div id="l424" class="code_block">  completed 
</div><div id="l425" class="code_block"><span class="k">\ei</span> 
</div><div id="l426" class="code_block"><span class="c">%</span>
</div><div id="l427" class="code_block">If the call is negative a fact of the form <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l428" class="code_block">  nc(S1,S2,Stage,Counter)<span class="nb">}</span> is logged, where all arguments are as
</div><div id="l429" class="code_block">above.
</div><div id="l430" class="code_block">
</div><div id="l431" class="code_block">  For instance, in the above example, node 3 would be represented as
</div><div id="l432" class="code_block">  <span class="nb">{</span><span class="k">\tt</span> tc(reach(2,Y),reach(1,Y),2)<span class="nb">}</span> (the reason for using the counter
</div><div id="l433" class="code_block">  value of 2 rather than 3 is explained below).  If <span class="s">$</span><span class="nb">S_</span><span class="m">1</span><span class="s">$</span> is the first
</div><div id="l434" class="code_block">  tabled subgoal in an evaluation, <span class="s">$</span><span class="nb">S_</span><span class="m">2</span><span class="s">$</span> is the atom <span class="nb">{</span><span class="k">\em</span> null<span class="nb">}</span>.
</div><div id="l435" class="code_block">
</div><div id="l436" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\em</span> Derivation of a new answer<span class="nb">}</span>~ When a new <span class="nb">{</span><span class="k">\em</span> unconditional<span class="nb">}</span>
</div><div id="l437" class="code_block">  answer <span class="s">$</span><span class="nb">A</span><span class="s">$</span> is derived for subgoal <span class="s">$</span><span class="nb">S</span><span class="s">$</span> and added to the table
</div><div id="l438" class="code_block">  (i.e. <span class="s">$</span><span class="nb">A</span><span class="s">$</span> is not already an answer for <span class="s">$</span><span class="nb">S</span><span class="s">$</span>) a fact of the form <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l439" class="code_block">    na(A,S,Counter)<span class="nb">}</span> is logged.  In the above example, the answer node
</div><div id="l440" class="code_block">  9 would be represented as <span class="nb">{</span><span class="k">\tt</span> na([2],reach(2,<span class="k">\_v</span>1),4)<span class="nb">}</span> where the
</div><div id="l441" class="code_block">  first argument is a list of substitutions for the variables <span class="nb">{</span><span class="k">\em</span>
</div><div id="l442" class="code_block">    <span class="k">\_v</span>1,...,<span class="k">\_vn</span><span class="nb">}</span> in <span class="s">$</span><span class="nb">S</span><span class="s">$</span>.
</div><div id="l443" class="code_block">
</div><div id="l444" class="code_block">  When a new <span class="nb">{</span><span class="k">\em</span> conditional<span class="nb">}</span> answer <span class="s">$</span><span class="nb">A </span><span class="nv">\mif</span><span class="nb"> D|</span><span class="s">$</span>, with substitution
</div><div id="l445" class="code_block">  <span class="s">$</span><span class="nb">A</span><span class="s">$</span> and delayed literals <span class="s">$</span><span class="nb">D</span><span class="s">$</span>. is derived for subgoal <span class="s">$</span><span class="nb">S</span><span class="s">$</span> and added
</div><div id="l446" class="code_block">  to the table a fact of the form <span class="nb">{</span><span class="k">\tt</span> nda(A,S,D,Counter)<span class="nb">}</span> is logged.
</div><div id="l447" class="code_block">
</div><div id="l448" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\em</span> Return of an answer to a consuming subgoal<span class="nb">}</span>~When an
</div><div id="l449" class="code_block">  unconditional answer <span class="s">$</span><span class="nb">A</span><span class="s">$</span> is returned to a consuming subgoal <span class="s">$</span><span class="nb">S</span><span class="s">$</span> in a
</div><div id="l450" class="code_block">  tree for <span class="s">$</span><span class="nb">S_T</span><span class="s">$</span>, a fact of the form <span class="nb">{</span><span class="k">\tt</span> ar(A,S,ST,Counter)<span class="nb">}</span> is
</div><div id="l451" class="code_block">  logged.  A log entry is made only if the table for <span class="s">$</span><span class="nb">S</span><span class="s">$</span> is incomplete
</div><div id="l452" class="code_block">  (see the explanation below).
</div><div id="l453" class="code_block">
</div><div id="l454" class="code_block">  If the answer <span class="s">$</span><span class="nb">A</span><span class="s">$</span> is conditional, the fact has the form <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l455" class="code_block">    dar(A,S,ST,Counter)<span class="nb">}</span>, where each argument is as above.
</div><div id="l456" class="code_block">
</div><div id="l457" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\em</span> Delaying a selected negative literal<span class="nb">}</span>.  If a selected
</div><div id="l458" class="code_block">  negative literal <span class="s">$</span><span class="nb">L</span><span class="s">$</span> of a node <span class="s">$</span><span class="nb">N</span><span class="s">$</span> is delayed, because it is
</div><div id="l459" class="code_block">  involved in a loop through negation, and <span class="s">$</span><span class="nb">N</span><span class="s">$</span> is in a tree for <span class="s">$</span><span class="nb">S_T</span><span class="s">$</span>,
</div><div id="l460" class="code_block">  a fact of the form <span class="nb">{</span><span class="k">\tt</span> dly(L,<span class="s">$</span><span class="nb">S_T</span><span class="s">$</span>,Counter)<span class="nb">}</span> is logged.
</div><div id="l461" class="code_block">
</div><div id="l462" class="code_block"><span class="k">\index</span><span class="nb">{</span>strongly connected components (SCCs)<span class="nb">}</span>
</div><div id="l463" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\em</span> Subgoal completion<span class="nb">}</span>
</div><div id="l464" class="code_block"><span class="k">\bi</span>
</div><div id="l465" class="code_block"><span class="k">\item</span> When a set <span class="s">$</span><span class="nv">\cS</span><span class="s">$</span> of subgoals is determined to be completely
</div><div id="l466" class="code_block">  evaluated and is completed, a fact of the form <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l467" class="code_block">    cmp(S,SCCNum,Counter)<span class="nb">}</span> is logged for each <span class="s">$</span><span class="nb">S </span><span class="nv">\in</span><span class="nb"> </span><span class="nv">\cS</span><span class="s">$</span>.  Here
</div><div id="l468" class="code_block">  <span class="s">$</span><span class="nb">SCCNum</span><span class="s">$</span> is simply a number giving an ordinal value that can be used
</div><div id="l469" class="code_block">  to group subgoals into mutually dependent sets of subgoals (here
</div><div id="l470" class="code_block">  called <span class="nb">{</span><span class="k">\em</span> Strongly Conneced Components<span class="nb">}</span> or <span class="nb">{</span><span class="k">\em</span> SCCs<span class="nb">}</span>), i.e. the
</div><div id="l471" class="code_block">  <span class="nb">{</span><span class="k">\em</span> SCCNum<span class="nb">}</span> of each <span class="s">$</span><span class="nb">S </span><span class="nv">\in</span><span class="nb"> </span><span class="nv">\cS</span><span class="s">$</span> has the same value, but that value
</div><div id="l472" class="code_block">  is not used for a completion fact of any subgoal not in <span class="s">$</span><span class="nv">\cS</span><span class="s">$</span>.
</div><div id="l473" class="code_block"><span class="c">%</span>
</div><div id="l474" class="code_block"><span class="k">\index</span><span class="nb">{</span>tabling!early completion of subgoals<span class="nb">}</span>
</div><div id="l475" class="code_block"><span class="k">\item</span> When a subgoal <span class="s">$</span><span class="nv">\cS</span><span class="s">$</span> is <span class="nb">{</span><span class="k">\em</span> early completed<span class="nb">}</span>, i.e. it is
</div><div id="l476" class="code_block">  determined that no more answers for <span class="s">$</span><span class="nb">S</span><span class="s">$</span> are possile or are desired a
</div><div id="l477" class="code_block">  fact of the form <span class="nb">{</span><span class="k">\tt</span> cmp(S,ec,Counter)<span class="nb">}</span> is logged.  If <span class="s">$</span><span class="nb">S</span><span class="s">$</span> belonged
</div><div id="l478" class="code_block">  to a larger mutually dependent set <span class="s">$</span><span class="nv">\cS</span><span class="s">$</span> when it was early
</div><div id="l479" class="code_block">  completed, <span class="s">$</span><span class="nb">S</span><span class="s">$</span> will also be included in the completion facts for
</div><div id="l480" class="code_block">  <span class="s">$</span><span class="nv">\cS</span><span class="s">$</span>.
</div><div id="l481" class="code_block"><span class="k">\ei</span>
</div><div id="l482" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\em</span> Table Abolishes<span class="nb">}</span>
</div><div id="l483" class="code_block"><span class="k">\bi</span>
</div><div id="l484" class="code_block"><span class="k">\item</span> When a tabled subgoal <span class="s">$</span><span class="nb">S</span><span class="s">$</span> is abolished, a fact of the form <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l485" class="code_block">  ta(subg(S),Counter)<span class="nb">}</span> is logged.
</div><div id="l486" class="code_block"><span class="k">\item</span> When all tables for a predicate <span class="s">$</span><span class="nb">p</span><span class="o">/</span><span class="nb">n</span><span class="s">$</span> are abolished, a fact of
</div><div id="l487" class="code_block">  the form <span class="nb">{</span><span class="k">\tt</span> ta(pred(p/n),Counter)<span class="nb">}</span> is logged.
</div><div id="l488" class="code_block"><span class="k">\item</span> When all tables are abolished, a fact of the form <span class="nb">{</span><span class="k">\tt</span> ta(all,Counter)<span class="nb">}</span> is logged.
</div><div id="l489" class="code_block"><span class="k">\ei</span>
</div><div id="l490" class="code_block"><span class="c">%</span>
</div><div id="l491" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\em</span> Location of errors<span class="nb">}</span> Whenever an error is thrown and the
</div><div id="l492" class="code_block">  execution is in a tree for a subgoal <span class="s">$</span><span class="nb">S</span><span class="s">$</span>, a Prolog-readable fact of
</div><div id="l493" class="code_block">  the form <span class="nb">{</span><span class="k">\tt</span> err(S,Counter)<span class="nb">}</span> is logged, where <span class="nb">{</span><span class="k">\em</span> Counter<span class="nb">}</span> is the
</div><div id="l494" class="code_block">  ordinal number of the fact.  The primary purpose of this fact is to
</div><div id="l495" class="code_block">  indicate the nearest tabled call that gave rise to an uncaughterror.  <span class="k">\ei</span>
</div><div id="l496" class="code_block">
</div><div id="l497" class="code_block"><span class="nb">{</span><span class="k">\tt</span> logforest<span class="nb">}</span> does <span class="nb">{</span><span class="k">\em</span> not<span class="nb">}</span> contain
</div><div id="l498" class="code_block">
</div><div id="l499" class="code_block"><span class="k">\bi</span>
</div><div id="l500" class="code_block"><span class="k">\item</span> Information about the occurrence of program clause resolution
</div><div id="l501" class="code_block">  either when used to produce children of tabled predicates, or when
</div><div id="l502" class="code_block">  it is used to produce children whose nodes have a selected literal
</div><div id="l503" class="code_block">  that is non-tabled.
</div><div id="l504" class="code_block">
</div><div id="l505" class="code_block"><span class="k">\item</span> Information about the return of answers from completed tables.
</div><div id="l506" class="code_block">  XSB uses a so-called <span class="nb">{</span><span class="k">\em</span> completed table optimization<span class="nb">}</span> which treats
</div><div id="l507" class="code_block">  answer return from completed tables in a manner akin to program
</div><div id="l508" class="code_block">  clause resolution.  
</div><div id="l509" class="code_block"> <span class="k">\ei</span>
</div><div id="l510" class="code_block">
</div><div id="l511" class="code_block"><span class="k">\index</span><span class="nb">{</span>attributed variables<span class="nb">}</span>
</div><div id="l512" class="code_block"><span class="k">\noindent</span>
</div><div id="l513" class="code_block">The inclusion of the above two features in <span class="nb">{</span><span class="k">\tt</span> logforest<span class="nb">}</span> would
</div><div id="l514" class="code_block">significantly slow down execution of XSB.  However, future versions of
</div><div id="l515" class="code_block"><span class="nb">{</span><span class="k">\tt</span> logforest<span class="nb">}</span> may include expanded logging features for negation,
</div><div id="l516" class="code_block">for call and answer subsumption and for incremental
</div><div id="l517" class="code_block">tabling~<span class="k">\footnote</span><span class="nb">{</span>Currently, attributes of attributed variables are
</div><div id="l518" class="code_block">  not printed out.<span class="nb">}</span>.
</div><div id="l519" class="code_block">
</div><div id="l520" class="code_block"><span class="k">\begin</span><span class="nb">{</span>example<span class="nb">}</span>
</div><div id="l521" class="code_block">The forest for <span class="nb">{</span><span class="k">\tt</span> reach(1,Y)<span class="nb">}</span> in the foregoing example has the log
</div><div id="l522" class="code_block">file as shown in Table~<span class="k">\ref</span><span class="nb">{</span>tab:fview<span class="nb">}</span>.
</div><div id="l523" class="code_block">
</div><div id="l524" class="code_block"><span class="k">\begin</span><span class="nb">{</span>table<span class="nb">}</span>[htbp]
</div><div id="l525" class="code_block"><span class="k">\begin</span><span class="nb">{</span>tabular<span class="nb">}{</span>lll<span class="nb">}</span>               <span class="k">\\</span> <span class="k">\hline</span>  
</div><div id="l526" class="code_block">Log File                                     <span class="nb">&amp;</span> Forest <span class="nb">&amp;</span> Explanation<span class="k">\\</span> <span class="k">\hline</span> 
</div><div id="l527" class="code_block">tc(reach( 1,<span class="k">\_v</span>0),null,new,0)                <span class="nb">&amp;</span> node 1 <span class="nb">&amp;</span> <span class="k">\\</span>
</div><div id="l528" class="code_block">                                             <span class="nb">&amp;</span> node 2 <span class="nb">&amp;</span> created by program clause resol. <span class="k">\\</span>
</div><div id="l529" class="code_block">                                             <span class="nb">&amp;</span> node 3 <span class="nb">&amp;</span> created by program clause resol. <span class="k">\\</span>
</div><div id="l530" class="code_block">tc(reach( 2,<span class="k">\_v</span>0),reach( 1,<span class="k">\_v</span>0),new,1)      <span class="nb">&amp;</span> node 4 <span class="nb">&amp;</span> <span class="k">\\</span>
</div><div id="l531" class="code_block">                                             <span class="nb">&amp;</span> node 5 <span class="nb">&amp;</span> created by program clause resol.<span class="k">\\</span>
</div><div id="l532" class="code_block">                                             <span class="nb">&amp;</span> node 6 <span class="nb">&amp;</span> created by program clause resol. <span class="k">\\</span>
</div><div id="l533" class="code_block">tc(reach( 2,<span class="k">\_v</span>0),reach( 2,<span class="k">\_v</span>0),incmp,2)    <span class="nb">&amp;</span>        <span class="nb">&amp;</span> repeated subgoal registered<span class="k">\\</span>
</div><div id="l534" class="code_block">                                             <span class="nb">&amp;</span> node 7 <span class="nb">&amp;</span> created by program clause resol. <span class="k">\\</span>
</div><div id="l535" class="code_block">                                             <span class="nb">&amp;</span> node 8 <span class="nb">&amp;</span> created by program clause resol. <span class="k">\\</span>
</div><div id="l536" class="code_block">na([ 2],reach( 2,<span class="k">\_v</span>0),3)                    <span class="nb">&amp;</span> node 8 <span class="nb">&amp;</span> registered as answer<span class="k">\\</span>
</div><div id="l537" class="code_block">ar([ 2],reach( 2,<span class="k">\_v</span>0),reach( 2,<span class="k">\_v</span>0),4)     <span class="nb">&amp;</span> node 9 <span class="nb">&amp;</span> created by answer resol.<span class="k">\\</span>
</div><div id="l538" class="code_block">cmp(reach( 2,<span class="k">\_v</span>0),2,5)                      <span class="nb">&amp;</span>    9a   <span class="nb">&amp;</span> <span class="nb">{</span><span class="k">\tt</span> reach(2,<span class="k">\_v</span>0)<span class="nb">}</span> completed <span class="k">\\</span>
</div><div id="l539" class="code_block">                                             <span class="nb">&amp;</span> node 10 <span class="nb">&amp;</span> created by return from completed table <span class="k">\\</span>
</div><div id="l540" class="code_block">na([ 2],reach( 1,<span class="k">\_v</span>0),6)                    <span class="nb">&amp;</span> node 10 <span class="nb">&amp;</span> registered as an answer<span class="k">\\</span>
</div><div id="l541" class="code_block">                                             <span class="nb">&amp;</span> node 11 <span class="nb">&amp;</span> created by program clause resol. <span class="k">\\</span>
</div><div id="l542" class="code_block">tc(reach( 3,<span class="k">\_v</span>0),reach( 1,<span class="k">\_v</span>0),new,7)      <span class="nb">&amp;</span> node 12 <span class="nb">&amp;</span> <span class="k">\\</span>
</div><div id="l543" class="code_block">                                             <span class="nb">&amp;</span> node 13 <span class="nb">&amp;</span> created by program clause resol. <span class="k">\\</span>
</div><div id="l544" class="code_block">                                             <span class="nb">&amp;</span> node 14 <span class="nb">&amp;</span> created by program clause resol. <span class="k">\\</span>
</div><div id="l545" class="code_block">tc(reach( 1,<span class="k">\_v</span>0),reach( 3,<span class="k">\_v</span>0),incmp,8)    <span class="nb">&amp;</span> node 14 <span class="nb">&amp;</span> repeated subgoal registered <span class="k">\\</span>
</div><div id="l546" class="code_block">ar([ 2],reach( 1,<span class="k">\_v</span>0),reach( 3,<span class="k">\_v</span>0),9)     <span class="nb">&amp;</span> node 15 <span class="nb">&amp;</span> created by answer resol. <span class="k">\\</span>
</div><div id="l547" class="code_block">na([ 2],reach( 3,<span class="k">\_v</span>0),10)                   <span class="nb">&amp;</span> node 15 <span class="nb">&amp;</span> registered as an answer <span class="k">\\</span>
</div><div id="l548" class="code_block">                                             <span class="nb">&amp;</span> node 16 <span class="nb">&amp;</span> created by program clause resol. <span class="k">\\</span>
</div><div id="l549" class="code_block">                                             <span class="nb">&amp;</span> node 17 <span class="nb">&amp;</span> created by program clause resol. <span class="k">\\</span>
</div><div id="l550" class="code_block">na([ 1],reach( 3,<span class="k">\_v</span>0),11)                   <span class="nb">&amp;</span> node 17 <span class="nb">&amp;</span> registered as an answer <span class="k">\\</span>
</div><div id="l551" class="code_block">                                             <span class="nb">&amp;</span> node 18 <span class="nb">&amp;</span> created by program clause resol. <span class="k">\\</span>
</div><div id="l552" class="code_block">                                             <span class="nb">&amp;</span> node 19 <span class="nb">&amp;</span> created by program clause resol. (repeated answer)<span class="k">\\</span>
</div><div id="l553" class="code_block">                                             <span class="nb">&amp;</span> node 20 <span class="nb">&amp;</span> created by program clause resol.<span class="k">\\</span>
</div><div id="l554" class="code_block">na([ 3],reach( 1,<span class="k">\_v</span>0),12)                   <span class="nb">&amp;</span> node 20 <span class="nb">&amp;</span> registered as an answer<span class="k">\\</span>
</div><div id="l555" class="code_block">ar([ 3],reach( 1,<span class="k">\_v</span>0),reach( 3,<span class="k">\_v</span>0),13)    <span class="nb">&amp;</span> node 21 <span class="nb">&amp;</span> created by answer return<span class="k">\\</span>
</div><div id="l556" class="code_block">na([ 3],reach( 3,<span class="k">\_v</span>0),14)                   <span class="nb">&amp;</span> node 21 <span class="nb">&amp;</span> registered as an answer<span class="k">\\</span>
</div><div id="l557" class="code_block">ar([ 2],reach( 3,<span class="k">\_v</span>0),reach( 1,<span class="k">\_v</span>0),15)    <span class="nb">&amp;</span> node 22 <span class="nb">&amp;</span> created by answer resol.<span class="k">\\</span>
</div><div id="l558" class="code_block">ar([ 1],reach( 3,<span class="k">\_v</span>0),reach( 1,<span class="k">\_v</span>0),16)    <span class="nb">&amp;</span> node 23 <span class="nb">&amp;</span> created by answer resol.<span class="k">\\</span>
</div><div id="l559" class="code_block">na([ 1],reach( 1,<span class="k">\_v</span>0),17)                   <span class="nb">&amp;</span> node 23 <span class="nb">&amp;</span> registered as an answer <span class="k">\\</span>
</div><div id="l560" class="code_block">ar([ 3],reach( 3,<span class="k">\_v</span>0),reach( 1,<span class="k">\_v</span>0),18)    <span class="nb">&amp;</span> node 24 <span class="nb">&amp;</span> created by answer resol. <span class="k">\\</span>
</div><div id="l561" class="code_block">ar([ 1],reach( 1,<span class="k">\_v</span>0),reach( 3,<span class="k">\_v</span>0),19)    <span class="nb">&amp;</span> node 25 <span class="nb">&amp;</span> created by answer resol.v <span class="k">\\</span>
</div><div id="l562" class="code_block">cmp(reach( 1,<span class="k">\_v</span>0),1,20)                     <span class="nb">&amp;</span>  <span class="nb">&amp;</span> <span class="k">\\</span>
</div><div id="l563" class="code_block">cmp(reach( 3,<span class="k">\_v</span>0),1,21)   <span class="nb">&amp;</span> <span class="nb">&amp;</span> <span class="k">\\</span> <span class="k">\hline</span>
</div><div id="l564" class="code_block"><span class="k">\end</span><span class="nb">{</span>tabular<span class="nb">}</span>
</div><div id="l565" class="code_block"><span class="k">\caption</span><span class="nb">{</span>Log file for computation in Figure~<span class="k">\ref</span><span class="nb">{</span>fig:local<span class="nb">}}</span><span class="k">\label</span><span class="nb">{</span>tab:fview<span class="nb">}</span>
</div><div id="l566" class="code_block"><span class="k">\end</span><span class="nb">{</span>table<span class="nb">}</span>
</div><div id="l567" class="code_block"><span class="k">\end</span><span class="nb">{</span>example<span class="nb">}</span>
</div><div id="l568" class="code_block">
</div><div id="l569" class="code_block"><span class="k">\begin</span><span class="nb">{</span>description<span class="nb">}</span>
</div><div id="l570" class="code_block"><span class="k">\ourrepeatmoditem</span><span class="nb">{</span>log<span class="k">\_forest</span>(+Call)<span class="nb">}{</span>log<span class="k">\_forest</span>/2<span class="nb">}{</span>tables<span class="nb">}</span>
</div><div id="l571" class="code_block"><span class="k">\ourmoditem</span><span class="nb">{</span>log<span class="k">\_forest</span>(+Call,+Options)<span class="nb">}{</span>log<span class="k">\_forest</span>/2<span class="nb">}{</span>tables<span class="nb">}</span>
</div><div id="l572" class="code_block"><span class="c">%</span>
</div><div id="l573" class="code_block">These predicates turn on forest logging, call <span class="nb">{</span><span class="k">\tt</span> Call<span class="nb">}</span>, then turn
</div><div id="l574" class="code_block">logging off when <span class="nb">{</span><span class="k">\tt</span> Call<span class="nb">}</span> is finished.  <span class="nb">{</span><span class="k">\tt</span> Options<span class="nb">}</span> is a list of
</div><div id="l575" class="code_block">possible options.
</div><div id="l576" class="code_block"><span class="c">%</span>
</div><div id="l577" class="code_block"><span class="k">\bi</span>
</div><div id="l578" class="code_block"><span class="k">\item</span> If <span class="nb">{</span><span class="k">\tt</span> Options<span class="nb">}</span> contains the term <span class="nb">{</span><span class="k">\tt</span> file(File)<span class="nb">}</span> then direct
</div><div id="l579" class="code_block">  the logging to <span class="nb">{</span><span class="k">\tt</span> File<span class="nb">}</span>; otherwise the log will be sent to
</div><div id="l580" class="code_block">  standard output.
</div><div id="l581" class="code_block"><span class="k">\item</span> If <span class="nb">{</span><span class="k">\tt</span> Options<span class="nb">}</span> contains the term <span class="nb">{</span><span class="k">\tt</span> level(Level)<span class="nb">}</span> where <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l582" class="code_block">  Level<span class="nb">}</span> = <span class="nb">{</span><span class="k">\tt</span> full<span class="nb">}</span> or <span class="nb">{</span><span class="k">\tt</span> partial<span class="nb">}</span> then the level of forest
</div><div id="l583" class="code_block">  logging is set to the respective value.  The default level is <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l584" class="code_block">    full<span class="nb">}</span>.  The level <span class="nb">{</span><span class="k">\tt</span> partial<span class="nb">}</span> does not output answer return
</div><div id="l585" class="code_block">  operations, and so can reduce the size of the log for certain
</div><div id="l586" class="code_block">  computations.  The actions of partial logging and full logging are
</div><div id="l587" class="code_block">  otherwise the same.  <span class="k">\ei</span>
</div><div id="l588" class="code_block"><span class="c">%  Currently, the only option is</span>
</div><div id="l589" class="code_block"><span class="c">%   {\tt file(File)}, which directs the logging to the file {\tt File}.</span>
</div><div id="l590" class="code_block"><span class="c">%   If {\tt Options} is an empty list or if {\tt log\_forest/1} is</span>
</div><div id="l591" class="code_block"><span class="c">%   called, the log will be sent to standard output~\footnote{Future</span>
</div><div id="l592" class="code_block"><span class="c">%     options will be able to turn on and off the logging of various</span>
</div><div id="l593" class="code_block"><span class="c">%     types of facts.}.</span>
</div><div id="l594" class="code_block">
</div><div id="l595" class="code_block"><span class="nb">{</span><span class="k">\bf</span> Error Cases<span class="nb">}</span> 
</div><div id="l596" class="code_block"><span class="k">\bi</span>
</div><div id="l597" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> Options<span class="nb">}</span> is a variable, or contains a variable as an element
</div><div id="l598" class="code_block"><span class="k">\bi</span>
</div><div id="l599" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> instantiation<span class="k">\_error</span><span class="nb">}</span>
</div><div id="l600" class="code_block"><span class="k">\ei</span>
</div><div id="l601" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> Options<span class="nb">}</span> is not a list
</div><div id="l602" class="code_block"><span class="k">\bi</span>
</div><div id="l603" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> type<span class="k">\_error</span>(list,Options)<span class="nb">}</span>
</div><div id="l604" class="code_block"><span class="k">\ei</span>
</div><div id="l605" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> Options<span class="nb">}</span> contains an option <span class="nb">{</span><span class="k">\tt</span> O<span class="nb">}</span> that is not a forest
</div><div id="l606" class="code_block">  logging option.  
</div><div id="l607" class="code_block"><span class="k">\bi</span>
</div><div id="l608" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> domain<span class="k">\_error</span>(forest<span class="k">\_logging\_option</span>,O)<span class="nb">}</span>
</div><div id="l609" class="code_block"><span class="k">\ei</span>
</div><div id="l610" class="code_block"><span class="k">\ei</span>
</div><div id="l611" class="code_block">
</div><div id="l612" class="code_block">
</div><div id="l613" class="code_block"><span class="k">\index</span><span class="nb">{</span>indexing<span class="nb">}</span>
</div><div id="l614" class="code_block"><span class="k">\ourmoditem</span><span class="nb">{</span>load<span class="k">\_forest\_log</span>(+File)<span class="nb">}{</span>load<span class="k">\_forest\_log</span>/1<span class="nb">}{</span>tables<span class="nb">}</span>
</div><div id="l615" class="code_block"><span class="c">%</span>
</div><div id="l616" class="code_block">The log produced by <span class="nb">{</span><span class="k">\tt</span> log<span class="k">\_forest</span>/[1,2]<span class="nb">}</span> is a Prolog file that can
</div><div id="l617" class="code_block">be compiled and/or loaded dynamically just as any other Prolog file.
</div><div id="l618" class="code_block">However, for large logs (i.e. those of many megabytes) use of <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l619" class="code_block">  load<span class="k">\_dync</span>/[1,2]<span class="nb">}</span> XSB commands can drastically reduce the time
</div><div id="l620" class="code_block">needed to load the file, while use of the proper <span class="nb">{</span><span class="k">\tt</span> index/2<span class="nb">}</span>
</div><div id="l621" class="code_block">declarations can greately improve query time.  The simple predicate,
</div><div id="l622" class="code_block"><span class="nb">{</span><span class="k">\tt</span> load<span class="k">\_forest\_log</span>/1<span class="nb">}</span> loads a log file and indexes needed arguments.
</div><div id="l623" class="code_block"><span class="k">\end</span><span class="nb">{</span>description<span class="nb">}</span>
</div><div id="l624" class="code_block">
</div><div id="l625" class="code_block"><span class="k">\index</span><span class="nb">{</span>tracing|)<span class="nb">}</span>
</div><div id="l626" class="code_block">
</div><div id="l627" class="code_block"><span class="k">\subsection</span><span class="nb">{</span>Analyzing the log; seeing the forest through the trees<span class="nb">}</span> <span class="k">\label</span><span class="nb">{</span>sec:forest-log-anal<span class="nb">}</span>
</div><div id="l628" class="code_block"><span class="c">%</span>
</div><div id="l629" class="code_block">As previously described, forest logging is based on the formal
</div><div id="l630" class="code_block">operational semantics of SLG, and as a result the log can be analyzed
</div><div id="l631" class="code_block">to query any result that can be modelled by the theory.  But despite
</div><div id="l632" class="code_block">the power of forest logging, it can be difficult to use.  Not all
</div><div id="l633" class="code_block">users have the background to fully understand the operational
</div><div id="l634" class="code_block">semantics of SLG.  Even those users with a formal background may find
</div><div id="l635" class="code_block">it difficult to write efficient analysis routines for logs of large
</div><div id="l636" class="code_block">computations~<span class="k">\footnote</span><span class="nb">{</span>I find it difficult myself!<span class="nb">}</span>.  Accordingly, XSB
</div><div id="l637" class="code_block">provides routines that analyze logs and display information about a
</div><div id="l638" class="code_block">computation.  These routines can answer many questions about a
</div><div id="l639" class="code_block">computation and can provide the starting point for further
</div><div id="l640" class="code_block">exploration.  We introduce these routines via an extended example.
</div><div id="l641" class="code_block">
</div><div id="l642" class="code_block"><span class="k">\begin</span><span class="nb">{</span>example<span class="nb">}</span> <span class="k">\rm</span> <span class="k">\label</span><span class="nb">{</span>ex:scc-anal<span class="nb">}</span>
</div><div id="l643" class="code_block"><span class="c">%</span>
</div><div id="l644" class="code_block">This example arises from the actual use of forest logging to
</div><div id="l645" class="code_block">understand a Flora-2 computation~<span class="k">\cite</span><span class="nb">{</span>YaKZ05<span class="nb">}</span>, in which the Cyc
</div><div id="l646" class="code_block">reasoner (cf. http://www.cyc.com) was translated into Silk
</div><div id="l647" class="code_block">(cf. http://silk.semwebcentral.org) and used to answer various
</div><div id="l648" class="code_block">questions in biology.  Silk itself compiles into Flora-2 which in turn
</div><div id="l649" class="code_block">compiles into XSB~<span class="k">\footnote</span><span class="nb">{</span>This example was run in 2012 using a
</div><div id="l650" class="code_block">  64-bit server with a large amount of RAM.<span class="nb">}</span>.  After translation,
</div><div id="l651" class="code_block">query answering took more resources than expected, and users wanted to
</div><div id="l652" class="code_block">determine why.  Using the features of <span class="k">\version</span><span class="nb">{}</span>, the first step is to
</div><div id="l653" class="code_block">call <span class="nb">{</span><span class="k">\tt</span> statistics/0<span class="nb">}</span> at the end of the computation.  The statistics
</div><div id="l654" class="code_block">indicated that the computation took about 30 seconds of CPU time and
</div><div id="l655" class="code_block">300 megabytes of table space, while XSB&#39;s trail had allocated over 1
</div><div id="l656" class="code_block">gigabyte of space.  The call to <span class="nb">{</span><span class="k">\tt</span> statistics/0<span class="nb">}</span> also showed the
</div><div id="l657" class="code_block">following information:
</div><div id="l658" class="code_block"><span class="c">%</span>
</div><div id="l659" class="code_block"><span class="k">\begin</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l660" class="code_block">  8678944 variant call check/insert ops: 615067 producers, 8063877 variants.
</div><div id="l661" class="code_block">  317346 answer check/insert ops: 304899 unique inserts, 12447 redundant.
</div><div id="l662" class="code_block"><span class="k">\end</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l663" class="code_block">In other words, there were nearly 10 million tabled subgoals that were
</div><div id="l664" class="code_block">called, indicating that this computation was heavily tabled (a
</div><div id="l665" class="code_block">characteristic of most Flora-2 computations), It also shows that the
</div><div id="l666" class="code_block">average number of answers per tabled subgoal is rather small.
</div><div id="l667" class="code_block">
</div><div id="l668" class="code_block">This basic information leads to several questions.  Why were there so
</div><div id="l669" class="code_block">many tabled subgoals?  Did the tabling have anything to do with the
</div><div id="l670" class="code_block">large amount of choice-point/trail space that was allocated?  Which
</div><div id="l671" class="code_block">tabled subgoals had answers?  How many times did a given tabled
</div><div id="l672" class="code_block">predicate call another tabled predicate?
</div><div id="l673" class="code_block">
</div><div id="l674" class="code_block"><span class="k">\index</span><span class="nb">{</span><span class="k">\texttt</span><span class="nb">{</span>table<span class="k">\_dump</span>/2<span class="nb">}}</span><span class="k">\index</span><span class="nb">{</span><span class="k">\texttt</span><span class="nb">{</span>table<span class="k">\_dump</span>/3<span class="nb">}}</span> Some of
</div><div id="l675" class="code_block">these questions can be answered by <span class="nb">{</span><span class="k">\tt</span> table<span class="k">\_dump</span>/[2,3]<span class="nb">}</span>:
</div><div id="l676" class="code_block">particularly, what tabled subgoals were called, and which had answers.
</div><div id="l677" class="code_block">However <span class="nb">{</span><span class="k">\tt</span> table<span class="k">\_dump</span>/[2,3]<span class="nb">}</span> cannot provide other information, such
</div><div id="l678" class="code_block">as the dependencies of given tabled subgoals on other tabled subgoals
</div><div id="l679" class="code_block">or the order in which operations occurred.  From a formal perspective,
</div><div id="l680" class="code_block"><span class="nb">{</span><span class="k">\tt</span> table<span class="k">\_dump</span>/[2,3]<span class="nb">}</span> does not allow a user to analyze an entire SLG
</div><div id="l681" class="code_block">forest: only the ``table&#39;&#39;, i.e., the subgoals in the forest and the
</div><div id="l682" class="code_block">unordered set of its answers.  The table omits any information about
</div><div id="l683" class="code_block">interior nodes or completion information, both of which are used to
</div><div id="l684" class="code_block">compute dependency information.  Dependencies are useful in analyzing
</div><div id="l685" class="code_block">most computations, but is especially important in Flora-2 computations
</div><div id="l686" class="code_block">such as this one, that make heavy use of HiLog.  This use of HiLog
</div><div id="l687" class="code_block">means that the dependencies of tabled predicates on one another is not
</div><div id="l688" class="code_block">at all obvious, and may not easily be determined by static analysis.
</div><div id="l689" class="code_block">
</div><div id="l690" class="code_block">The next step, therefore, in analyzing this computation is to rerun it
</div><div id="l691" class="code_block">with forest logging.  For this computation forest logging has no
</div><div id="l692" class="code_block">impact on memory usage, but increases the time of the computation from
</div><div id="l693" class="code_block">about 30 seconds to about 52 seconds --- around 73<span class="k">\%</span> in this case.  It
</div><div id="l694" class="code_block">is worthwhile noting that the actual overhead of forest logging varies
</div><div id="l695" class="code_block">depending on how heavily the computation is tabled.  The log itself
</div><div id="l696" class="code_block">had slightly over 14 million entries which were loaded into XSB via
</div><div id="l697" class="code_block"><span class="nb">{</span><span class="k">\tt</span> load<span class="k">\_forest\_log</span>/1<span class="nb">}</span>.  The log took about 140 seconds to load and
</div><div id="l698" class="code_block">about 7.8 Gbytes of space for the log facts and their multiple and
</div><div id="l699" class="code_block">trie indexes~<span class="k">\footnote</span><span class="nb">{</span>The load time for this example, about 100,000
</div><div id="l700" class="code_block">  facts/second is typical for 2012 CPUs; the size of the loaded code
</div><div id="l701" class="code_block">  is larger than usual, due in part to the expansion in the size of
</div><div id="l702" class="code_block">  terms caused by the HiLog encoding.<span class="nb">}</span>.
</div><div id="l703" class="code_block">
</div><div id="l704" class="code_block">The easiest way to start the analysis is to ask the query <span class="nb">{</span><span class="k">\tt</span> ?-
</div><div id="l705" class="code_block">  forest<span class="k">\_log\_overview</span><span class="nb">}</span>, which for this example gives:
</div><div id="l706" class="code_block"><span class="c">%</span>
</div><div id="l707" class="code_block"><span class="k">\begin</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l708" class="code_block">There were 613496 subgoals in 463330 (completed) SCCs.  
</div><div id="l709" class="code_block">93918 subgoals were early-completed.  
</div><div id="l710" class="code_block">0 subgoals were not completed in the log.
</div><div id="l711" class="code_block">There were a total of 8670043 tabled subgoal calls:
</div><div id="l712" class="code_block">    613496 were calls to new subgoals
</div><div id="l713" class="code_block">    4467747 were calls to incomplete subgoals
</div><div id="l714" class="code_block">    3588800 were calls to complete subgoals
</div><div id="l715" class="code_block">
</div><div id="l716" class="code_block">Number of SCCs with 1 subgoals is 463322
</div><div id="l717" class="code_block">Number of SCCs with 4 subgoals is 1
</div><div id="l718" class="code_block">Number of SCCs with 7 subgoals is 1
</div><div id="l719" class="code_block">Number of SCCs with 52 subgoals is 1
</div><div id="l720" class="code_block">Number of SCCs with 110 subgoals is 4
</div><div id="l721" class="code_block">Number of SCCs with 149671 subgoals is 1
</div><div id="l722" class="code_block"><span class="k">\end</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l723" class="code_block"><span class="c">%</span>
</div><div id="l724" class="code_block"><span class="k">\index</span><span class="nb">{</span>tabling!complete evaluation<span class="nb">}</span>
</div><div id="l725" class="code_block"><span class="k">\index</span><span class="nb">{</span>tabling!early completion of subgoals<span class="nb">}</span> 
</div><div id="l726" class="code_block"><span class="c">%</span>
</div><div id="l727" class="code_block">The overview extends the information shown by <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l728" class="code_block">  statistics/0<span class="nb">}</span>.  First, the total number of completed and
</div><div id="l729" class="code_block">non-completed SCCs is given along with a count of how many of the
</div><div id="l730" class="code_block">completed subgoals were early completed.  Information about
</div><div id="l731" class="code_block">non-completed SCCs is useful, since the forest log may be analyzed for
</div><div id="l732" class="code_block">a computation that does not terminate.  Since this computation did
</div><div id="l733" class="code_block">terminate, all subgoals in the log were completed~<span class="k">\footnote</span><span class="nb">{</span>The slight
</div><div id="l734" class="code_block">  difference between the number of subgoals shown here and the number
</div><div id="l735" class="code_block">  shown by <span class="nb">{</span><span class="k">\tt</span> statistics/0<span class="nb">}</span> is due to the use of tabling in the
</div><div id="l736" class="code_block">  Flora compiler.<span class="nb">}</span>.  Note that there is also a breakdown of calls to
</div><div id="l737" class="code_block">tabled subgoals that distinguishes whether the tabled subgoal was new,
</div><div id="l738" class="code_block">completed, or incomplete.  Recall that calls to completed tabled
</div><div id="l739" class="code_block">subgoals essentialy treat the answers in the table as facts, so that
</div><div id="l740" class="code_block">these calls are efficient.  Making a call to an incomplete subgoals on
</div><div id="l741" class="code_block">the other hand means that the calling and called subgoals are mutually
</div><div id="l742" class="code_block">recursive~<span class="k">\footnote</span><span class="nb">{</span>This statement is true in local evaluation but not
</div><div id="l743" class="code_block">  in batched evaluation.<span class="nb">}</span> and execution of recursive sets of subgoals
</div><div id="l744" class="code_block">can be expensive, especially in terms of space.
</div><div id="l745" class="code_block">
</div><div id="l746" class="code_block">Finally, the overview report provides the distributions of tabled
</div><div id="l747" class="code_block">subgoals across SCCs.  While most of the SCCs were small there was a
</div><div id="l748" class="code_block">large one, with nearly 150,000 mutually dependent subgoals.  Clearly
</div><div id="l749" class="code_block">the large SCC should be examimed.  The first step is to obtain its
</div><div id="l750" class="code_block">index.  The query
</div><div id="l751" class="code_block"><span class="c">%</span>
</div><div id="l752" class="code_block"><span class="k">\begin</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l753" class="code_block">get<span class="nb">_</span>scc<span class="nb">_</span>size(SCC,Index)), Index &gt; 1000.
</div><div id="l754" class="code_block"><span class="k">\end</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l755" class="code_block"><span class="c">%</span>
</div><div id="l756" class="code_block">returns the information that the index of the large SCC was 39.  The
</div><div id="l757" class="code_block">query <span class="nb">{</span><span class="k">\tt</span> analyze<span class="k">\_an\_scc</span>(39,userout)<span class="nb">}</span> then provides the following
</div><div id="l758" class="code_block">information.
</div><div id="l759" class="code_block"><span class="c">%</span>
</div><div id="l760" class="code_block"><span class="k">\begin</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l761" class="code_block">There are 149671 subgoals and 4461290 links (average of 30.8073 edges per subgoal) 
</div><div id="l762" class="code_block">      within the SCC
</div><div id="l763" class="code_block">
</div><div id="l764" class="code_block">There are 2 subgoals in the SCC for the predicate backchainForbidden / 0
</div><div id="l765" class="code_block">There are 2 subgoals in the SCC for the predicate 
</div><div id="l766" class="code_block">                   http://www.cyc.com/silk/implementation/transformationPredicate / 0
</div><div id="l767" class="code_block">:
</div><div id="l768" class="code_block">There are 15613 subgoals in the SCC for the predicate gpLookupSentence / 3
</div><div id="l769" class="code_block">There are 15613 subgoals in the SCC for the predicate removalSentence / 3
</div><div id="l770" class="code_block">There are 18770 subgoals in the SCC for the predicate forwardSentence / 3
</div><div id="l771" class="code_block">There are 18771 subgoals in the SCC for the predicate lookupSentence / 3
</div><div id="l772" class="code_block">
</div><div id="l773" class="code_block">Calls from assertedSentence/3 to lookupSentence/3 : 32
</div><div id="l774" class="code_block">Calls from backchainForbidden/0 to &#39;http://www.cyc.com/silk/implementation/transformationPredicate&#39;/0 : 2
</div><div id="l775" class="code_block">:
</div><div id="l776" class="code_block">Calls from transformationSentence/2 to sbhlSentence/3 : 5479
</div><div id="l777" class="code_block">Calls from tvaSentence/3 to removalSentence/3 : 7695
</div><div id="l778" class="code_block"><span class="k">\end</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l779" class="code_block"><span class="c">%</span>
</div><div id="l780" class="code_block">It is evident from the first line in this report that the vast
</div><div id="l781" class="code_block">majority of the calls to incomplete tables during this computation
</div><div id="l782" class="code_block">occur in the SCC under investigation.  Since information on incomplete
</div><div id="l783" class="code_block">tables is kept in XSB&#39;s choice point stack (cf. <span class="k">\cite</span><span class="nb">{</span>SaSw98<span class="nb">}</span>), the
</div><div id="l784" class="code_block">evaluation of SCC 39 is the likely culprit behind the large amount of
</div><div id="l785" class="code_block">stack space required.  The subgoals in the SCC are first broken out by
</div><div id="l786" class="code_block">their predicate name and arity, then the edges within the SCC are
</div><div id="l787" class="code_block">broken out by the predicates of their caller and called subgoals.  At
</div><div id="l788" class="code_block">this point a programmer can review the various rules for <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l789" class="code_block">  lookupSentence/3<span class="nb">}</span>, <span class="nb">{</span><span class="k">\tt</span> forwardSentence/3<span class="nb">}</span> and other predicates to
</div><div id="l790" class="code_block">determine whether the recursion is intended and if so, whether it can
</div><div id="l791" class="code_block">be simplified.
</div><div id="l792" class="code_block"><span class="c">%</span>
</div><div id="l793" class="code_block"><span class="k">\end</span><span class="nb">{</span>example<span class="nb">}</span>
</div><div id="l794" class="code_block">
</div><div id="l795" class="code_block"><span class="k">\subsubsection</span><span class="nb">{</span>Using abstraction in the analysis<span class="nb">}</span>
</div><div id="l796" class="code_block"><span class="c">%</span>
</div><div id="l797" class="code_block">Within the SCC analysis, information about a given tabled subgoal <span class="s">$</span><span class="nb">S</span><span class="s">$</span>
</div><div id="l798" class="code_block">was abstracted to the functor and arity of <span class="s">$</span><span class="nb">S</span><span class="s">$</span>.  For this example,
</div><div id="l799" class="code_block">abstraction was necessary, as reporting 150,000 subgoals or 4,000,000+
</div><div id="l800" class="code_block">would not provide useful information for a human being.  However, it
</div><div id="l801" class="code_block">could be the case that seeing the tabled subgoals themselves would be
</div><div id="l802" class="code_block">useful for a smaller SCC.  Even for an SCC of this size, different
</div><div id="l803" class="code_block">levels of abstraction could be useful: mode information or type
</div><div id="l804" class="code_block">information might be useful in a given circumstance.  
</div><div id="l805" class="code_block">
</div><div id="l806" class="code_block"><span class="k">\begin</span><span class="nb">{</span>example<span class="nb">}</span> <span class="k">\label</span><span class="nb">{</span>ex:moded-scc-anal<span class="nb">}</span> <span class="k">\rm</span>
</div><div id="l807" class="code_block"><span class="c">%</span>
</div><div id="l808" class="code_block">Making the call <span class="nb">{</span><span class="k">\tt</span> ?-
</div><div id="l809" class="code_block">  analyze<span class="k">\_an\_scc</span>(39,userout,abstract<span class="k">\_modes</span>(<span class="k">\_</span>,<span class="k">\_</span>))<span class="nb">}</span> applies the
</div><div id="l810" class="code_block">predicate <span class="nb">{</span><span class="k">\tt</span> abstract<span class="k">\_modes</span>/2<span class="nb">}</span> to each term, producing an output of
</div><div id="l811" class="code_block">the form:
</div><div id="l812" class="code_block"><span class="c">%</span>
</div><div id="l813" class="code_block"><span class="k">\begin</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l814" class="code_block">There are 149671 subgoals and 4461290 links (average of 30.8073 edges per subgoal) 
</div><div id="l815" class="code_block">           within the SCC
</div><div id="l816" class="code_block">
</div><div id="l817" class="code_block">There are 3 subgoals in the SCC for the predicate backchainRequired(g,g)
</div><div id="l818" class="code_block">There are 2 subgoals in the SCC for the predicate backchainForbidden(g,g)
</div><div id="l819" class="code_block">:
</div><div id="l820" class="code_block">There are 29254 subgoals in the SCC for the predicate gpLookupSentence(g,g)
</div><div id="l821" class="code_block">There are 29254 subgoals in the SCC for the predicate removalSentence(g,g)
</div><div id="l822" class="code_block">
</div><div id="l823" class="code_block">Calls from assertedSentence(g,g) to lookupSentence(g,g) : 10
</div><div id="l824" class="code_block">Calls from assertedSentence(m,g) to lookupSentence(m,g) : 22
</div><div id="l825" class="code_block">:
</div><div id="l826" class="code_block">Calls from transformationSentence(m,g) to sbhlSentence(m,g) : 741
</div><div id="l827" class="code_block">Calls from tvaSentence(g,g) to removalSentence(g,g) : 7695
</div><div id="l828" class="code_block"><span class="k">\end</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l829" class="code_block"><span class="c">%</span>
</div><div id="l830" class="code_block"><span class="nb">{</span><span class="k">\tt</span> abstract<span class="k">\_modes</span>(In,Out)<span class="nb">}</span> simply goes through each argument of
</div><div id="l831" class="code_block"><span class="nb">{</span><span class="k">\tt</span> In<span class="nb">}</span> and unifies the corresponding argument of <span class="nb">{</span><span class="k">\tt</span> Out<span class="nb">}</span> with a
</div><div id="l832" class="code_block"><span class="nb">{</span><span class="k">\tt</span> v<span class="nb">}</span> if the argument is a variable, a <span class="nb">{</span><span class="k">\tt</span> g<span class="nb">}</span> if the argument is
</div><div id="l833" class="code_block">ground, and <span class="nb">{</span><span class="k">\tt</span> m<span class="nb">}</span> otherwise.  
</div><div id="l834" class="code_block"><span class="k">\end</span><span class="nb">{</span>example<span class="nb">}</span>
</div><div id="l835" class="code_block"><span class="c">%</span>
</div><div id="l836" class="code_block"><span class="nb">{</span><span class="k">\tt</span> abstract<span class="k">\_modes</span>/2<span class="nb">}</span> is simply an example: any term-abstraction
</div><div id="l837" class="code_block">predicate may be passed into the last argument of <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l838" class="code_block">  analyze<span class="k">\_an\_scc</span>/3<span class="nb">}</span>~<span class="k">\footnote</span><span class="nb">{</span>Because of the special representation
</div><div id="l839" class="code_block">  of Flora-2 terms, abstraction was used to produce the output of
</div><div id="l840" class="code_block">  Example~<span class="k">\ref</span><span class="nb">{</span>ex:moded-scc-anal<span class="nb">}</span>, while a more sophisticated version
</div><div id="l841" class="code_block">  of <span class="nb">{</span><span class="k">\tt</span> abstract<span class="k">\_modes</span>/2<span class="nb">}</span> was used in
</div><div id="l842" class="code_block">  Example~<span class="k">\ref</span><span class="nb">{</span>ex:moded-scc-anal<span class="nb">}</span>.<span class="nb">}</span>.
</div><div id="l843" class="code_block">
</div><div id="l844" class="code_block"><span class="k">\subsubsection</span><span class="nb">{</span>Analyzing Negation<span class="nb">}</span>
</div><div id="l845" class="code_block"><span class="c">%</span>
</div><div id="l846" class="code_block">Many programs that use negation are stratified in such a way that they
</div><div id="l847" class="code_block">do not require the use of <span class="nb">{</span><span class="k">\sc</span> Delaying<span class="nb">}</span> and <span class="nb">{</span><span class="k">\sc</span> Simplification<span class="nb">}</span>
</div><div id="l848" class="code_block">operations, and the routines described in the previous section are
</div><div id="l849" class="code_block">sufficient for these programs.  However if a program does not have a
</div><div id="l850" class="code_block">two-valued well-founded model, a user would often like to understand
</div><div id="l851" class="code_block">why.  Even in a program that is two-valued, the heavy use of <span class="nb">{</span><span class="k">\sc</span>
</div><div id="l852" class="code_block">  Delaying<span class="nb">}</span> and <span class="nb">{</span><span class="k">\sc</span> Simplification<span class="nb">}</span> can indicate that some rules may
</div><div id="l853" class="code_block">need to be optimized by having their literals reordered.
</div><div id="l854" class="code_block">
</div><div id="l855" class="code_block"><span class="k">\begin</span><span class="nb">{</span>example<span class="nb">}</span> <span class="k">\label</span><span class="nb">{</span>ex:neg<span class="nb">}</span> <span class="k">\rm</span>
</div><div id="l856" class="code_block">Figure~<span class="k">\ref</span><span class="nb">{</span>fig:neg<span class="nb">}</span> shows a program with negation and illustrates SLG
</div><div id="l857" class="code_block">resolution for the query <span class="nb">{</span><span class="k">\em</span> p(c)<span class="nb">}</span> to the program.  The nodes in
</div><div id="l858" class="code_block">Figure~<span class="k">\ref</span><span class="nb">{</span>fig:neg<span class="nb">}</span> have been annotated with the order in which they
</div><div id="l859" class="code_block">were created under local scheduling. In the formalism used by
</div><div id="l860" class="code_block">Figure~<span class="k">\ref</span><span class="nb">{</span>fig:neg<span class="nb">}</span>, the symbol <span class="s">$</span><span class="nb">|</span><span class="s">$</span> in a node separates the
</div><div id="l861" class="code_block">unresolved goals to the right from the delayed goals to the left.  In
</div><div id="l862" class="code_block">the evaluation state where nodes 1 through 10 have been created, <span class="nb">{</span><span class="k">\em</span>
</div><div id="l863" class="code_block">  p(b)<span class="nb">}</span> has been completed, and <span class="nb">{</span><span class="k">\em</span> p(a)<span class="nb">}</span> and <span class="nb">{</span><span class="k">\em</span> p(c)<span class="nb">}</span> are in the
</div><div id="l864" class="code_block">same SCC.  There are no more clauses or answers to resolve, but <span class="nb">{</span><span class="k">\em</span>
</div><div id="l865" class="code_block">  p(a)<span class="nb">}</span> is involved in a loop through negation in node 5, and nodes 2
</div><div id="l866" class="code_block">and 10 involve <span class="nb">{</span><span class="k">\em</span> p(a)<span class="nb">}</span> and <span class="nb">{</span><span class="k">\em</span> p(c)<span class="nb">}</span> in a negative
</div><div id="l867" class="code_block">loop~<span class="k">\footnote</span><span class="nb">{</span>In this example, we ignore the effects of early
</div><div id="l868" class="code_block">  completion which would complete <span class="nb">{</span><span class="k">\em</span> p(b)<span class="nb">}</span> immediately upon creation
</div><div id="l869" class="code_block">  of node 8, obviating the need to create node 9.<span class="nb">}</span>.
</div><div id="l870" class="code_block">
</div><div id="l871" class="code_block">In situations such as this, where all resolution has been performed
</div><div id="l872" class="code_block">for nodes in an SCC, an evaluation may have to apply a <span class="nb">{</span><span class="k">\sc</span> Delaying<span class="nb">}</span>
</div><div id="l873" class="code_block">operation to a negative literal such as <span class="nb">{</span><span class="k">\em</span> not(p(a))<span class="nb">}</span>, in order to
</div><div id="l874" class="code_block">explore whether other literals to its right might fail. 
</div><div id="l875" class="code_block"><span class="c">% In cases such as this, </span>
</div><div id="l876" class="code_block">When multiple literals can be delayed, an arbitrary one is chosen to
</div><div id="l877" class="code_block">be delayed first.  So the evaluation delays the selected literal of
</div><div id="l878" class="code_block">node 2 to generate node 12 producing a <span class="nb">{</span><span class="k">\em</span> conditional answer<span class="nb">}</span> -- an
</div><div id="l879" class="code_block">answer with a non-empty delay list
</div><div id="l880" class="code_block">(cf. Section~<span class="k">\ref</span><span class="nb">{</span>sec:conditional-answers<span class="nb">}</span> for an overview of how XSB
</div><div id="l881" class="code_block">computes and allows inspection of delayed literals).  Next, <span class="nb">{</span><span class="k">\em</span> not
</div><div id="l882" class="code_block">  p(a)<span class="nb">}</span> in node 5 is delayed, failing that computation path, and <span class="nb">{</span><span class="k">\em</span>
</div><div id="l883" class="code_block">  not p(c)<span class="nb">}</span> in node 10 is delayed to produce node 15 and failing the
</div><div id="l884" class="code_block">final computation path for <span class="nb">{</span><span class="k">\em</span> p(a)<span class="nb">}</span>.  At this stage the SCC
</div><div id="l885" class="code_block"><span class="s">$</span><span class="nv">\{</span><span class="nb">p</span><span class="o">(</span><span class="nb">a</span><span class="o">)</span><span class="nb">,p</span><span class="o">(</span><span class="nb">c</span><span class="o">)</span><span class="nv">\}</span><span class="s">$</span> is <span class="nb">{</span><span class="k">\em</span> completely evaluated<span class="nb">}</span> meaning that there are
</div><div id="l886" class="code_block">no more operations applicable for goal literals (as opposed to delay
</div><div id="l887" class="code_block">literals).  Since <span class="nb">{</span><span class="k">\em</span> p(a)<span class="nb">}</span> is completely evaluated with no answers,
</div><div id="l888" class="code_block">conditional or otherwise, the evaluation determines it to be <span class="nb">{</span><span class="k">\em</span>
</div><div id="l889" class="code_block">  failed<span class="nb">}</span> and a <span class="nb">{</span><span class="k">\sc</span> Simplification<span class="nb">}</span> operation can be applied to the
</div><div id="l890" class="code_block">conditional answer of node 12, leading to the <span class="nb">{</span><span class="k">\em</span> unconditional<span class="nb">}</span>
</div><div id="l891" class="code_block">answer in node 17 and <span class="nb">{</span><span class="k">\em</span> success<span class="nb">}</span> of the literal <span class="nb">{</span><span class="k">\em</span> p(c)<span class="nb">}</span>.
</div><div id="l892" class="code_block"><span class="k">\end</span><span class="nb">{</span>example<span class="nb">}</span>
</div><div id="l893" class="code_block">
</div><div id="l894" class="code_block"><span class="k">\begin</span><span class="nb">{</span>figure*<span class="nb">}</span>[tbp] 
</div><div id="l895" class="code_block"><span class="k">\begin</span><span class="nb">{</span>center<span class="nb">}</span>
</div><div id="l896" class="code_block"><span class="c">%\fbox{\epsfig{file=Figures/del-simpl3.eps,width=\textwidth}}</span>
</div><div id="l897" class="code_block"><span class="k">\epsfig</span><span class="nb">{</span>file=del-simpl3.eps,width=<span class="k">\textwidth</span><span class="nb">}</span>
</div><div id="l898" class="code_block"><span class="k">\end</span><span class="nb">{</span>center<span class="nb">}</span>
</div><div id="l899" class="code_block"><span class="k">\caption</span><span class="nb">{</span>A Normal Program and SLG Forest for Evaluation of the Query <span class="nb">{</span><span class="k">\em</span> p(c)<span class="nb">}}</span>
</div><div id="l900" class="code_block"><span class="k">\label</span><span class="nb">{</span>fig:neg<span class="nb">}</span>
</div><div id="l901" class="code_block"><span class="k">\end</span><span class="nb">{</span>figure*<span class="nb">}</span>
</div><div id="l902" class="code_block">
</div><div id="l903" class="code_block">
</div><div id="l904" class="code_block">As indicated previously, the forest log overview includes a total
</div><div id="l905" class="code_block">count of <span class="nb">{</span><span class="k">\sc</span> Delaying<span class="nb">}</span> and <span class="nb">{</span><span class="k">\sc</span> Simplification<span class="nb">}</span> operations, as well
</div><div id="l906" class="code_block">as a count of conditional answers.  In addition, SCC analysis counts
</div><div id="l907" class="code_block">negative as well as positive links within the SCC.  The current
</div><div id="l908" class="code_block">version of forest logging also provides a means to examine the causes
</div><div id="l909" class="code_block">of answers that have an undefined truth value.  Recall from
</div><div id="l910" class="code_block">Example~<span class="k">\ref</span><span class="nb">{</span>ex:neg<span class="nb">}</span> that there are two types of causes of an
</div><div id="l911" class="code_block">undefined truth value: either 1) a negative literal explicitly
</div><div id="l912" class="code_block">undergoes a <span class="nb">{</span><span class="k">\sc</span> Delaying<span class="nb">}</span> operation; or 2) a conditional answer may
</div><div id="l913" class="code_block">be used to resolve a literal.  It can be shown that in local
</div><div id="l914" class="code_block">evaluation, a conditional answer <span class="s">$</span><span class="nb">A</span><span class="s">$</span> will never be returned out of an
</div><div id="l915" class="code_block">SCC if <span class="s">$</span><span class="nb">A</span><span class="s">$</span> is successful or failed in the well-founded model of a
</div><div id="l916" class="code_block">program.  This means that if an answer for <span class="s">$</span><span class="nb">S</span><span class="s">$</span> is undefined, then it
</div><div id="l917" class="code_block">would be caused operationally by a <span class="nb">{</span><span class="k">\sc</span> Delaying<span class="nb">}</span> operation within the
</div><div id="l918" class="code_block">SCC of <span class="s">$</span><span class="nb">S</span><span class="s">$</span> or within some other SCC on which <span class="s">$</span><span class="nb">S</span><span class="s">$</span> depends.  So to
</div><div id="l919" class="code_block">understand why an atom is undefined it can be useful understand the
</div><div id="l920" class="code_block">``root causes&#39;&#39; of the delay: to examine SCCs in which <span class="nb">{</span><span class="k">\sc</span> Delaying<span class="nb">}</span>
</div><div id="l921" class="code_block">operations were executed and conditional answers were derived, but the
</div><div id="l922" class="code_block">answers could not be simplified.
</div><div id="l923" class="code_block"><span class="c">% into unconditional answers.</span>
</div><div id="l924" class="code_block">
</div><div id="l925" class="code_block"><span class="k">\begin</span><span class="nb">{</span>example<span class="nb">}</span>
</div><div id="l926" class="code_block">As a use case, logging was made of execution of a Flora-2 program that
</div><div id="l927" class="code_block">tested out a new defeasibility theory.  The forest log overview
</div><div id="l928" class="code_block">indicated that the top-level query was undefined: 
</div><div id="l929" class="code_block"><span class="c">%</span>
</div><div id="l930" class="code_block"><span class="k">\begin</span><span class="nb">{</span>small<span class="nb">}</span>
</div><div id="l931" class="code_block"><span class="k">\begin</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l932" class="code_block">:
</div><div id="l933" class="code_block">There were a total of 55 negative delays
</div><div id="l934" class="code_block">There were a total of 0 simplifications
</div><div id="l935" class="code_block">There were a total of 695 unconditional answers derived:
</div><div id="l936" class="code_block">There were a total of 66 conditional answers derived:
</div><div id="l937" class="code_block"><span class="k">\end</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l938" class="code_block"><span class="k">\end</span><span class="nb">{</span>small<span class="nb">}</span>
</div><div id="l939" class="code_block"><span class="c">%</span>
</div><div id="l940" class="code_block">The analysis predicate <span class="nb">{</span><span class="k">\tt</span> three<span class="k">\_valued\_scc</span>(List)<span class="nb">}</span> produces a list
</div><div id="l941" class="code_block">of all SCC indices in which <span class="nb">{</span><span class="k">\sc</span> Delaying<span class="nb">}</span> caused the derivation of
</div><div id="l942" class="code_block">conditional answers.  These SCCs can then be analyzed as discussed in
</div><div id="l943" class="code_block">the previous section.
</div><div id="l944" class="code_block"><span class="k">\end</span><span class="nb">{</span>example<span class="nb">}</span>
</div><div id="l945" class="code_block">
</div><div id="l946" class="code_block"><span class="k">\subsection</span><span class="nb">{</span>Discussion<span class="nb">}</span>
</div><div id="l947" class="code_block"><span class="c">%</span>
</div><div id="l948" class="code_block">Using log forest imposes a relatively minimal overhead on most
</div><div id="l949" class="code_block">computations, considering the information it can provide, and loading
</div><div id="l950" class="code_block">and analysis is relatively quick.  For this example, the top level
</div><div id="l951" class="code_block">analysis took around 10 seconds, and analysing SCC 39 took about 20
</div><div id="l952" class="code_block">seconds in Example~<span class="k">\ref</span><span class="nb">{</span>ex:scc-anal<span class="nb">}</span> and about 60 seconds in
</div><div id="l953" class="code_block">Example~<span class="k">\ref</span><span class="nb">{</span>ex:moded-scc-anal<span class="nb">}</span>.  For more information,
</div><div id="l954" class="code_block">see~<span class="k">\cite</span><span class="nb">{</span>Swif14b<span class="nb">}</span>.
</div><div id="l955" class="code_block">
</div><div id="l956" class="code_block"><span class="k">\subsection</span><span class="nb">{</span>Predicates for Forest Logging<span class="nb">}</span>
</div><div id="l957" class="code_block">
</div><div id="l958" class="code_block"><span class="k">\begin</span><span class="nb">{</span>description<span class="nb">}</span>
</div><div id="l959" class="code_block"><span class="k">\ourmoditem</span><span class="nb">{</span>forest<span class="k">\_log\_overview</span><span class="nb">}{</span>forest<span class="k">\_log\_overview</span>/0<span class="nb">}{</span>tables<span class="nb">}</span>
</div><div id="l960" class="code_block"><span class="c">%</span>
</div><div id="l961" class="code_block">Provides an overview of subgoals, calls, and SCCs in the forest log as
</div><div id="l962" class="code_block">indicated in Section~<span class="k">\ref</span><span class="nb">{</span>sec:forest-log-anal<span class="nb">}</span>.
</div><div id="l963" class="code_block">
</div><div id="l964" class="code_block"><span class="k">\ourmoditem</span><span class="nb">{</span>get<span class="k">\_scc\_size</span>(?Index,?Size)<span class="nb">}{</span>get<span class="k">\_scc\_size</span>/3<span class="nb">}{</span>tables<span class="nb">}</span>
</div><div id="l965" class="code_block"><span class="c">%</span>
</div><div id="l966" class="code_block">This simple predicate determines the indices of SCCs whose size is
</div><div id="l967" class="code_block"><span class="nb">{</span><span class="k">\tt</span> Size<span class="nb">}</span>, for use with <span class="nb">{</span><span class="k">\tt</span> analyze<span class="k">\_an\_scc</span>/[2,3]<span class="nb">}</span>.
</div><div id="l968" class="code_block">
</div><div id="l969" class="code_block"><span class="k">\ourmoditem</span><span class="nb">{</span>three<span class="k">\_valued\_sccs</span>(List)<span class="nb">}{</span>three<span class="k">\_valued\_scc</span>/1<span class="nb">}{</span>tables<span class="nb">}</span>
</div><div id="l970" class="code_block"><span class="c">%</span>
</div><div id="l971" class="code_block">If there are any SCCs in the log where delay is performed, causing
</div><div id="l972" class="code_block">conditional answers to be added that were not simplified into
</div><div id="l973" class="code_block">unconditional answers, unifies <span class="nb">{</span><span class="k">\tt</span> List<span class="nb">}</span> with the index of all such
</div><div id="l974" class="code_block">SCCs.
</div><div id="l975" class="code_block">
</div><div id="l976" class="code_block"><span class="k">\ourrepeatmoditem</span><span class="nb">{</span>analyze<span class="k">\_an\_scc</span>(+Index,+File)<span class="nb">}{</span>analyze<span class="k">\_an\_scc</span>/2<span class="nb">}{</span>tables<span class="nb">}</span>
</div><div id="l977" class="code_block"><span class="k">\ourmoditem</span><span class="nb">{</span>analyze<span class="k">\_an\_scc</span>(+Index,+File,+Abstraction)<span class="nb">}{</span>analyze<span class="k">\_an\_scc</span>/3<span class="nb">}{</span>tables<span class="nb">}</span>
</div><div id="l978" class="code_block"><span class="c">%</span>
</div><div id="l979" class="code_block">These predicates can be used to analyze the SCC indexed by <span class="nb">{</span><span class="k">\tt</span> Index<span class="nb">}</span>
</div><div id="l980" class="code_block">in a forest log, as explained in Section~<span class="k">\ref</span><span class="nb">{</span>sec:forest-log-anal<span class="nb">}</span>.
</div><div id="l981" class="code_block">The output is written to <span class="nb">{</span><span class="k">\tt</span> File<span class="nb">}</span>; calling the predicate with <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l982" class="code_block">  File<span class="nb">}</span> set to <span class="nb">{</span><span class="k">\tt</span> userout<span class="nb">}</span> causes the output to be written to the
</div><div id="l983" class="code_block">console.  In <span class="nb">{</span><span class="k">\tt</span> analyze<span class="k">\_an\_scc</span>/2<span class="nb">}</span>, tabled subgoals are abstracted
</div><div id="l984" class="code_block">to predicate indicators, in <span class="nb">{</span><span class="k">\tt</span> analyze<span class="k">\_an\_scc</span>/3<span class="nb">}</span>, a two-ary
</div><div id="l985" class="code_block">abstraction predicate in <span class="nb">{</span><span class="k">\tt</span> usermod<span class="nb">}</span> is called.
</div><div id="l986" class="code_block">
</div><div id="l987" class="code_block">Error conditions on <span class="nb">{</span><span class="k">\tt</span> File<span class="nb">}</span> are the same as <span class="nb">{</span><span class="k">\tt</span> tell/1<span class="nb">}</span>.
</div><div id="l988" class="code_block">
</div><div id="l989" class="code_block"><span class="k">\ourmoditem</span><span class="nb">{</span>abstract<span class="k">\_modes</span>(Term,AbstractedTerm)<span class="nb">}{</span>abstract<span class="k">\_modes</span>/2<span class="nb">}{</span>usermod<span class="nb">}</span>
</div><div id="l990" class="code_block"><span class="c">%</span>
</div><div id="l991" class="code_block"><span class="nb">{</span><span class="k">\tt</span> abstract<span class="k">\_modes</span>(In,Out)<span class="nb">}</span> simply goes through each argument of
</div><div id="l992" class="code_block"><span class="nb">{</span><span class="k">\tt</span> Term<span class="nb">}</span> and unifies the corresponding argument of <span class="nb">{</span><span class="k">\tt</span> Abstracted<span class="nb">}</span>
</div><div id="l993" class="code_block">with a <span class="nb">{</span><span class="k">\tt</span> v<span class="nb">}</span> if the argument is a variable, a <span class="nb">{</span><span class="k">\tt</span> g<span class="nb">}</span> if the
</div><div id="l994" class="code_block">argument is ground, and <span class="nb">{</span><span class="k">\tt</span> m<span class="nb">}</span> otherwise.
</div><div id="l995" class="code_block">
</div><div id="l996" class="code_block"><span class="k">\ourmoditem</span><span class="nb">{</span>set<span class="k">\_forest\_logging\_for\_pred</span>(+PredSpec,+Mode)<span class="nb">}{</span>set<span class="k">\_forest\_logging\_for\_pred</span>/2<span class="nb">}{</span>tables<span class="nb">}</span>
</div><div id="l997" class="code_block">If forest logging is active, this predicate allows any logging
</div><div id="l998" class="code_block">specific to the predicate or term indicater, <span class="nb">{</span><span class="k">\tt</span> PredSpec<span class="nb">}</span>, to be
</div><div id="l999" class="code_block">turned on or off.  Thus, for instance, tabled predicates in a
</div><div id="l1000" class="code_block">pre-existing library need not clutter up the log.
</div><div id="l1001" class="code_block">
</div><div id="l1002" class="code_block"><span class="nb">{</span><span class="k">\bf</span> Error Cases<span class="nb">}</span>
</div><div id="l1003" class="code_block"><span class="k">\bi</span>
</div><div id="l1004" class="code_block"><span class="k">\item</span> 	<span class="nb">{</span><span class="k">\tt</span> PredSpec<span class="nb">}</span> is not a predicate or term indicator.
</div><div id="l1005" class="code_block"><span class="k">\bi</span>
</div><div id="l1006" class="code_block"><span class="k">\item</span> 	<span class="nb">{</span><span class="k">\tt</span> type<span class="k">\_error</span><span class="nb">}</span>
</div><div id="l1007" class="code_block"><span class="k">\ei</span>
</div><div id="l1008" class="code_block"><span class="c">%</span>
</div><div id="l1009" class="code_block"><span class="k">\item</span> 	<span class="nb">{</span><span class="k">\tt</span> Mode<span class="nb">}</span> is not in the set <span class="k">\{</span><span class="nb">{</span><span class="k">\tt</span> on<span class="nb">}</span>,<span class="nb">{</span><span class="k">\tt</span> off<span class="nb">}</span><span class="k">\}</span>
</div><div id="l1010" class="code_block"><span class="k">\bi</span>
</div><div id="l1011" class="code_block"><span class="k">\item</span> 	<span class="nb">{</span><span class="k">\tt</span> domain<span class="k">\_error</span><span class="nb">}</span>
</div><div id="l1012" class="code_block"><span class="k">\ei</span>
</div><div id="l1013" class="code_block"><span class="k">\ei</span>
</div><div id="l1014" class="code_block"><span class="k">\end</span><span class="nb">{</span>description<span class="nb">}</span>
</div><div id="l1015" class="code_block">
</div><div id="l1016" class="code_block"><span class="c">%%% Local Variables: </span>
</div><div id="l1017" class="code_block"><span class="c">%%% mode: latex</span>
</div><div id="l1018" class="code_block"><span class="c">%%% TeX-master: &quot;manual1&quot;</span>
</div><div id="l1019" class="code_block"><span class="c">%%% End: </span>
</div><div id="l1020" class="code_block">
</div><div id="l1021" class="code_block"><span class="c">%-----------------------------------------------------------------------------</span>
</div><div id="l1022" class="code_block">
</div><div id="l1023" class="code_block"><span class="k">\section</span><span class="nb">{</span>Understanding the State of a Tabled Computation<span class="nb">}</span> <span class="k">\label</span><span class="nb">{</span>sec:suspend-analyze<span class="nb">}</span>
</div><div id="l1024" class="code_block">
</div><div id="l1025" class="code_block">These calls should be made while the current computation is suspended.
</div><div id="l1026" class="code_block">
</div><div id="l1027" class="code_block"><span class="k">\index</span><span class="nb">{</span>Subgoal Dependency Graph (SDG)<span class="nb">}</span>
</div><div id="l1028" class="code_block"><span class="k">\index</span><span class="nb">{</span>affects relation<span class="nb">}</span>
</div><div id="l1029" class="code_block"><span class="k">\begin</span><span class="nb">{</span>description<span class="nb">}</span>
</div><div id="l1030" class="code_block"><span class="k">\ourmoditem</span><span class="nb">{</span>get<span class="k">\_sdg\_info</span>(-SDG)<span class="nb">}{</span>get<span class="k">\_sdg\_info</span>/1<span class="nb">}{</span>tables<span class="nb">}</span>
</div><div id="l1031" class="code_block"><span class="k">\index</span><span class="nb">{</span>Subgoal Dependency Graph (SDG)<span class="nb">}</span> 
</div><div id="l1032" class="code_block"><span class="c">%</span>
</div><div id="l1033" class="code_block">For a suspended computation, returns information about the <span class="nb">{</span><span class="k">\em</span>
</div><div id="l1034" class="code_block">  Subgoal Dependency Graph<span class="nb">}</span> (SDG)~(cf. e.g. <span class="k">\cite</span><span class="nb">{</span>Swif99b,SwiW12<span class="nb">}</span>).
</div><div id="l1035" class="code_block">The vertices of the SDG are the tabled subgoals that are incomplete,
</div><div id="l1036" class="code_block">and a directed edge <span class="s">$</span><span class="o">(</span><span class="nb">S_</span><span class="m">1</span><span class="nb">,S_</span><span class="m">2</span><span class="o">)</span><span class="s">$</span> indicates that answers to <span class="s">$</span><span class="nb">S_</span><span class="m">1</span><span class="s">$</span> are
</div><div id="l1037" class="code_block">directly called in evaluation of <span class="s">$</span><span class="nb">S_</span><span class="m">2</span><span class="s">$</span> (i.e., <span class="s">$</span><span class="nb">S_</span><span class="m">1</span><span class="s">$</span> directly affects
</div><div id="l1038" class="code_block"><span class="s">$</span><span class="nb">S_</span><span class="m">2</span><span class="s">$</span>).  The SDG is represented using an adjacency list that contains annotated
</div><div id="l1039" class="code_block">information about each subgoal.  Specifically, on success <span class="nb">{</span><span class="k">\tt</span> SDG<span class="nb">}</span>
</div><div id="l1040" class="code_block">will be instantiated to a list of terms of the form:
</div><div id="l1041" class="code_block">
</div><div id="l1042" class="code_block"><span class="nb">{</span><span class="k">\tt</span> subgoal(Subgoal,SCCIndex,TableEntryHandle,CallsTo,Answers,Edges)<span class="nb">}</span> 
</div><div id="l1043" class="code_block">
</div><div id="l1044" class="code_block">such that:
</div><div id="l1045" class="code_block">
</div><div id="l1046" class="code_block"><span class="k">\bi</span>
</div><div id="l1047" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> Subgoal<span class="nb">}</span> is an incomplete subgoal in the suspended computation
</div><div id="l1048" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> SCCIndex<span class="nb">}</span> is the index of the SCC to which the subgoal
</div><div id="l1049" class="code_block">  belongs.  For local evaluation, if <span class="s">$</span><span class="nb">SCCIndex_</span><span class="m">1</span><span class="nb"> &lt; SCCIndex_</span><span class="m">2</span><span class="s">$</span>, then
</div><div id="l1050" class="code_block">  subgoals in <span class="s">$</span><span class="nb">SCCIndxex_</span><span class="m">2</span><span class="s">$</span> affect subgoals in <span class="s">$</span><span class="nb">SCCIndex_</span><span class="m">1</span><span class="s">$</span> (although
</div><div id="l1051" class="code_block">  the affects relation may not be direct).
</div><div id="l1052" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> TableEntryHandle<span class="nb">}</span> is the handle to the table entry, and
</div><div id="l1053" class="code_block">  uniquely identifies <span class="nb">{</span><span class="k">\tt</span> Subgoal<span class="nb">}</span> 
</div><div id="l1054" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> CallsTo<span class="nb">}</span> is the number of calls that have been made to the
</div><div id="l1055" class="code_block">  subgoal so far.  
</div><div id="l1056" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> Answers<span class="nb">}</span> is the number of distinct answers that <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l1057" class="code_block">  Subgoal<span class="nb">}</span> has so far.~<span class="k">\footnote</span><span class="nb">{</span>If the same answer was derived more
</div><div id="l1058" class="code_block">  than once, it is counted only one time.<span class="nb">}</span>
</div><div id="l1059" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> Edges<span class="nb">}</span> is the atom <span class="nb">{</span><span class="k">\tt</span> unavailable<span class="nb">}</span> if <span class="nb">{</span><span class="k">\tt</span> Subgoal<span class="nb">}</span> is
</div><div id="l1060" class="code_block">  not incrementally tabled, otherwise it is a list of
</div><div id="l1061" class="code_block">  table entry handles for incomplete subgoals that <span class="nb">{</span><span class="k">\tt</span> Subgoal<span class="nb">}</span>
</div><div id="l1062" class="code_block">  directly affects.<span class="k">\footnote</span><span class="nb">{</span>This predicate is currently being
</div><div id="l1063" class="code_block">    extended to return this information for non-incremental tables as
</div><div id="l1064" class="code_block">    well, and to separate out positive from negative edges.<span class="nb">}</span>
</div><div id="l1065" class="code_block"><span class="k">\ei</span>
</div><div id="l1066" class="code_block">
</div><div id="l1067" class="code_block">This predicate has no error conditions.
</div><div id="l1068" class="code_block">
</div><div id="l1069" class="code_block"><span class="k">\begin</span><span class="nb">{</span>example<span class="nb">}</span> <span class="k">\rm</span> <span class="k">\label</span><span class="nb">{</span>ex:get-sdg<span class="nb">}</span>
</div><div id="l1070" class="code_block">Consider the goal <span class="nb">{</span><span class="k">\tt</span> ?- q(3,3)<span class="nb">}</span> to the program:
</div><div id="l1071" class="code_block">
</div><div id="l1072" class="code_block"><span class="k">\begin</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l1073" class="code_block">:- import get<span class="nb">_</span>sdg<span class="nb">_</span>info/1 from tables.
</div><div id="l1074" class="code_block">:- import between/3 from basics.
</div><div id="l1075" class="code_block">
</div><div id="l1076" class="code_block">:- table q/2 as incremental.
</div><div id="l1077" class="code_block">q(M,N):- between(1,N,X),
</div><div id="l1078" class="code_block">         (M = N,N = X -&gt; break ; true),q(X,N).
</div><div id="l1079" class="code_block"><span class="k">\end</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l1080" class="code_block">Execution of this query creates a number of tabled subgoals, but
</div><div id="l1081" class="code_block">breaks before the initial goal is completely evaluated.  The SDG at
</div><div id="l1082" class="code_block">the time of the break is shown in Figure~<span class="k">\ref</span><span class="nb">{</span>fig:sdg-break-1<span class="nb">}</span>
</div><div id="l1083" class="code_block">
</div><div id="l1084" class="code_block"><span class="k">\begin</span><span class="nb">{</span>figure<span class="nb">}</span>[htbp]
</div><div id="l1085" class="code_block"><span class="k">\centering</span>
</div><div id="l1086" class="code_block"><span class="k">\includegraphics</span><span class="na">[width=.4\textwidth]</span><span class="nb">{</span>sdg-q-2<span class="nb">}</span>
</div><div id="l1087" class="code_block"><span class="c">%%\mbox{</span>
</div><div id="l1088" class="code_block"><span class="c">%%{\epsfig{file=slg-forest-local,width=.99\textwidth}}}</span>
</div><div id="l1089" class="code_block"><span class="k">\caption</span><span class="nb">{</span>SDG for <span class="nb">{</span><span class="k">\tt</span> ?- q(3,3)<span class="nb">}</span> when the computation is suspended by <span class="nb">{</span><span class="k">\tt</span> break/0<span class="nb">}}</span> <span class="k">\label</span><span class="nb">{</span>fig:sdg-break-1<span class="nb">}</span>
</div><div id="l1090" class="code_block"><span class="k">\end</span><span class="nb">{</span>figure<span class="nb">}</span>
</div><div id="l1091" class="code_block"><span class="c">%</span>
</div><div id="l1092" class="code_block">This SDG can be produced as follows:
</div><div id="l1093" class="code_block"><span class="k">\begin</span><span class="nb">{</span>small<span class="nb">}</span>
</div><div id="l1094" class="code_block"><span class="k">\begin</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l1095" class="code_block">| ?- q(3,3).
</div><div id="l1096" class="code_block">[ Break (level 1) ]
</div><div id="l1097" class="code_block">
</div><div id="l1098" class="code_block">1: ?- get<span class="nb">_</span>sdg<span class="nb">_</span>info(F).
</div><div id="l1099" class="code_block">
</div><div id="l1100" class="code_block">F = [subgoal(q(2,3),1,140253373671912,3,0,
</div><div id="l1101" class="code_block">             [140253373671672,140253373671792,140253373671912]),
</div><div id="l1102" class="code_block">     subgoal(q(1,3),1,140253373671792,3,0,
</div><div id="l1103" class="code_block">             [140253373671792,140253373671672,140253373671912]),
</div><div id="l1104" class="code_block">     subgoal(q(3,3),1,140253373671672,3,0,
</div><div id="l1105" class="code_block">             [140253373671912,140253373671792])]
</div><div id="l1106" class="code_block"><span class="k">\end</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l1107" class="code_block"><span class="k">\end</span><span class="nb">{</span>small<span class="nb">}</span>
</div><div id="l1108" class="code_block">
</div><div id="l1109" class="code_block"><span class="k">\end</span><span class="nb">{</span>example<span class="nb">}</span>
</div><div id="l1110" class="code_block">
</div><div id="l1111" class="code_block"><span class="k">\item</span>  <span class="k">\ourmoditem</span><span class="nb">{</span>morph<span class="k">\_sdg</span>(+SDGIn,+Morph,-SDGOut)<span class="nb">}{</span>morph<span class="k">\_sdg</span>/3<span class="nb">}{</span>tables<span class="nb">}</span>
</div><div id="l1112" class="code_block"><span class="c">%</span>
</div><div id="l1113" class="code_block">This predicate takes as input <span class="nb">{</span><span class="k">\tt</span> SDGIn<span class="nb">}</span>, an SDG in adjacency list
</div><div id="l1114" class="code_block">format and returns its image, <span class="nb">{</span><span class="k">\tt</span> SDGOut<span class="nb">}</span>, under the graph
</div><div id="l1115" class="code_block">homomorphism <span class="nb">{</span><span class="k">\tt</span> Morph<span class="nb">}</span>.  <span class="nb">{</span><span class="k">\tt</span> Morph<span class="nb">}</span> is a predicate symbol that
</div><div id="l1116" class="code_block">identifies a 2-ary predicate, <span class="nb">{</span><span class="k">\tt</span> Morph(+In,-Out)<span class="nb">}</span> that is functional
</div><div id="l1117" class="code_block">on <span class="nb">{</span><span class="k">\tt</span> In<span class="nb">}</span> and maps the Herbrand Base of the current program into
</div><div id="l1118" class="code_block">itself.  The syntax of <span class="nb">{</span><span class="k">\tt</span> SDGIn<span class="nb">}</span> and <span class="nb">{</span><span class="k">\tt</span> SDGOut<span class="nb">}</span> are the same, so
</div><div id="l1119" class="code_block"><span class="nb">{</span><span class="k">\tt</span> SDGOut<span class="nb">}</span> may be used for further morphisms; and accordingly <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l1120" class="code_block">  SDGIn<span class="nb">}</span> may have been produced by <span class="nb">{</span><span class="k">\tt</span> get<span class="k">\_sdg\_info</span>/1<span class="nb">}</span> and zero or
</div><div id="l1121" class="code_block">more applications of <span class="nb">{</span><span class="k">\tt</span> morph<span class="k">\_sdg</span>/3<span class="nb">}</span>.
</div><div id="l1122" class="code_block">
</div><div id="l1123" class="code_block">To recall the definition of a graph homomorphism (cf. e.g.,
</div><div id="l1124" class="code_block">~<span class="k">\cite</span><span class="nb">{</span>Hara69<span class="nb">}</span>) a functional notation is used for <span class="nb">{</span><span class="k">\tt</span> Morph/2<span class="nb">}</span>.  <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l1125" class="code_block">  SdgOut<span class="nb">}</span> is a graph such that the vertices of <span class="nb">{</span><span class="k">\tt</span> SDGOut<span class="nb">}</span>,
</div><div id="l1126" class="code_block"><span class="s">$</span><span class="nb">vertices</span><span class="o">(</span><span class="nb">{</span><span class="nv">\tt</span><span class="nb"> SDGOut}</span><span class="o">)</span><span class="s">$</span> is the set:
</div><div id="l1127" class="code_block"><span class="sb">\[</span>
</div><div id="l1128" class="code_block"><span class="nv">\{</span><span class="nb"> morph</span><span class="o">(</span><span class="nb">Subgoal</span><span class="o">)</span><span class="nb"> | Subgoal </span><span class="nv">\in</span><span class="nb"> vertices</span><span class="o">(</span><span class="nb">{</span><span class="nv">\tt</span><span class="nb"> SDGIn}</span><span class="o">)</span><span class="nb"> </span><span class="nv">\}</span>
</div><div id="l1129" class="code_block"><span class="s">\]</span>
</div><div id="l1130" class="code_block">while the edges of <span class="nb">{</span><span class="k">\tt</span> SDGOut<span class="nb">}</span>, <span class="s">$</span><span class="nb">edges</span><span class="o">(</span><span class="nb">{</span><span class="nv">\tt</span><span class="nb"> SDGOut}</span><span class="o">)</span><span class="s">$</span> is the set
</div><div id="l1131" class="code_block"><span class="sb">\[</span>
</div><div id="l1132" class="code_block"><span class="nv">\{</span><span class="nb"> &lt;morph</span><span class="o">(</span><span class="nb">Subgoal_</span><span class="m">1</span><span class="o">)</span><span class="nb">,morph</span><span class="o">(</span><span class="nb">Subgoal_</span><span class="m">2</span><span class="o">)</span><span class="nb">&gt; | &lt;Subgoal_</span><span class="m">1</span><span class="nb">,Subgoal_</span><span class="m">2</span><span class="nb">&gt; </span><span class="nv">\in</span><span class="nb"> edges</span><span class="o">(</span><span class="nb">{</span><span class="nv">\tt</span><span class="nb"> SDGIn}</span><span class="o">)</span><span class="nb"> </span><span class="nv">\}</span>
</div><div id="l1133" class="code_block"><span class="s">\]</span>
</div><div id="l1134" class="code_block">
</div><div id="l1135" class="code_block">The power of <span class="nb">{</span><span class="k">\tt</span> morph<span class="k">\_sdg</span>/3<span class="nb">}</span> arises when the numbers of vertices
</div><div id="l1136" class="code_block">and edges of <span class="nb">{</span><span class="k">\tt</span> SdgIn<span class="nb">}</span> is large, and <span class="nb">{</span><span class="k">\tt</span> morph/2<span class="nb">}</span> ensures that
</div><div id="l1137" class="code_block">numbers for <span class="nb">{</span><span class="k">\tt</span> SDG<span class="nb">}</span> are much smaller -- thus allowing recognizable
</div><div id="l1138" class="code_block">patterns to emerge.  
</div><div id="l1139" class="code_block">
</div><div id="l1140" class="code_block">For efficiency reasons, a specual condition is assumed about <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l1141" class="code_block">  morph/2<span class="nb">}</span>: that if two elements of its range unify, then they must be
</div><div id="l1142" class="code_block">identical.  For instance, a morphism <span class="s">$</span><span class="nb">M_</span><span class="m">1</span><span class="s">$</span> that reduced the maximum
</div><div id="l1143" class="code_block">depth of each non-variable argument of a term by 1 would not fit this
</div><div id="l1144" class="code_block">condition.  For instance <span class="s">$</span><span class="nb">M_</span><span class="m">1</span><span class="o">(</span><span class="nb">f</span><span class="o">(</span><span class="nb">a,g</span><span class="o">(</span><span class="nb">h</span><span class="o">(</span><span class="nb">b</span><span class="o">))))</span><span class="nb"> </span><span class="o">=</span><span class="nb"> f</span><span class="o">(</span><span class="nb">X_</span><span class="m">1</span><span class="nb">,g</span><span class="o">(</span><span class="nb">h</span><span class="o">(</span><span class="nb">X_</span><span class="m">2</span><span class="o">)))</span><span class="s">$</span> while
</div><div id="l1145" class="code_block"><span class="s">$</span><span class="nb">M_</span><span class="m">1</span><span class="o">(</span><span class="nb">f</span><span class="o">(</span><span class="nb">a,g</span><span class="o">(</span><span class="nb">b</span><span class="o">)))</span><span class="nb"> </span><span class="o">=</span><span class="nb"> f</span><span class="o">(</span><span class="nb">X_</span><span class="m">1</span><span class="nb">,g</span><span class="o">(</span><span class="nb">X_</span><span class="m">2</span><span class="o">))</span><span class="s">$</span>, which unify.  On the other hand, a
</div><div id="l1146" class="code_block">morphism that abstracts each argument to have a maximal fixed depth
</div><div id="l1147" class="code_block">would fulfill the condition.  As long as this condition is observed,
</div><div id="l1148" class="code_block"><span class="nb">{</span><span class="k">\tt</span> morph/2<span class="nb">}</span> may instantiated by an abstraction function as used
</div><div id="l1149" class="code_block">elsewhere in this manual: i.e., a function such that <span class="s">$</span><span class="nb">morph</span><span class="o">(</span><span class="nb">Term</span><span class="o">)</span><span class="s">$</span>
</div><div id="l1150" class="code_block">subsumes <span class="s">$</span><span class="nb">Term</span><span class="s">$</span>.  However, other morphisms may also be useful as
</div><div id="l1151" class="code_block">demonstrated in Example~<span class="k">\ref</span><span class="nb">{</span>ex:morph-sdg<span class="nb">}</span> below.
</div><div id="l1152" class="code_block">
</div><div id="l1153" class="code_block">While the syntax of <span class="nb">{</span><span class="k">\tt</span> SdgOut<span class="nb">}</span> is the same as that of <span class="nb">{</span><span class="k">\tt</span> SDGIn<span class="nb">}</span>,
</div><div id="l1154" class="code_block">the meaning of the arguments differs slightly.  <span class="nb">{</span><span class="k">\tt</span> SdgOut<span class="nb">}</span> is a
</div><div id="l1155" class="code_block">list of terms of the form:
</div><div id="l1156" class="code_block">
</div><div id="l1157" class="code_block"><span class="nb">{</span><span class="k">\tt</span> subgoal(MorphSubg,null,Key,CallsTo,Answers,KeyList)<span class="nb">}</span> 
</div><div id="l1158" class="code_block">
</div><div id="l1159" class="code_block">such that 
</div><div id="l1160" class="code_block">
</div><div id="l1161" class="code_block"><span class="k">\bi</span>
</div><div id="l1162" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> MorphSubg<span class="nb">}</span> is <span class="s">$</span><span class="nb">morph</span><span class="o">(</span><span class="nb">{</span><span class="nv">\tt</span><span class="nb"> Subgoal}</span><span class="o">)</span><span class="s">$</span> for one or more subgoals
</div><div id="l1163" class="code_block">  that are vertices of <span class="nb">{</span><span class="k">\tt</span> SDGIn<span class="nb">}</span>
</div><div id="l1164" class="code_block"><span class="k">\item</span> The second argument, which represents SCC information in the
</div><div id="l1165" class="code_block">  original SDG, is the atom <span class="nb">{</span><span class="k">\tt</span> null<span class="nb">}</span> when a morphism is applied, since SCC
</div><div id="l1166" class="code_block">  information is not preserved in general.
</div><div id="l1167" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> Key<span class="nb">}</span> is an atom identifying <span class="nb">{</span><span class="k">\tt</span> MorphSubg<span class="nb">}</span>.  Note that
</div><div id="l1168" class="code_block">  while each subgoal in <span class="nb">{</span><span class="k">\tt</span> SDGIn<span class="nb">}</span> corresponds to a tabled call, a
</div><div id="l1169" class="code_block">  given subgoal image in <span class="nb">{</span><span class="k">\tt</span> SDGOut<span class="nb">}</span> may not correspond to a tabled
</div><div id="l1170" class="code_block">  call in the current state.  Thus a table entry handle may not be
</div><div id="l1171" class="code_block">  available, so generated keys are used in <span class="nb">{</span><span class="k">\tt</span> SDGOut<span class="nb">}</span>.
</div><div id="l1172" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> CallsTo<span class="nb">}</span> is the sum of calls to every subgoal <span class="s">$</span><span class="nb">S </span><span class="nv">\in</span><span class="s">$</span> <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l1173" class="code_block">  SubgIn<span class="nb">}</span> such that <span class="s">$</span><span class="nb">morph</span><span class="o">(</span><span class="nb">S</span><span class="o">)</span><span class="nb"> </span><span class="o">=</span><span class="nb"> {</span><span class="nv">\tt</span><span class="nb"> MorphSubg}</span><span class="s">$</span>.
</div><div id="l1174" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> Answers<span class="nb">}</span> is the sum of the number of answers for every
</div><div id="l1175" class="code_block">  subgoal <span class="s">$</span><span class="nb">S </span><span class="nv">\in</span><span class="s">$</span> <span class="nb">{</span><span class="k">\tt</span> SubgIn<span class="nb">}</span> such that <span class="s">$</span><span class="nb">morph</span><span class="o">(</span><span class="nb">S</span><span class="o">)</span><span class="nb"> </span><span class="o">=</span><span class="nb"> {</span><span class="nv">\tt</span><span class="nb"> MorphSubg}</span><span class="s">$</span>.
</div><div id="l1176" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> KeyList<span class="nb">}</span> is a list of the keys to those vertices adjacent
</div><div id="l1177" class="code_block">  to <span class="nb">{</span><span class="k">\tt</span> MorphSubg<span class="nb">}</span> as described above.
</div><div id="l1178" class="code_block"><span class="k">\ei</span>
</div><div id="l1179" class="code_block">
</div><div id="l1180" class="code_block">If there are no incomplete tables in the current state, an empty list is returned.
</div><div id="l1181" class="code_block">
</div><div id="l1182" class="code_block"><span class="k">\begin</span><span class="nb">{</span>example<span class="nb">}</span> <span class="k">\rm</span> <span class="k">\label</span><span class="nb">{</span>ex:morph-sdg<span class="nb">}</span>
</div><div id="l1183" class="code_block">Continuing Example~<span class="k">\ref</span><span class="nb">{</span>ex:get-sdg<span class="nb">}</span>, let <span class="nb">{</span><span class="k">\tt</span> mymorph<span class="nb">}</span> identify the
</div><div id="l1184" class="code_block">predicate
</div><div id="l1185" class="code_block">
</div><div id="l1186" class="code_block"><span class="k">\begin</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l1187" class="code_block">mymorph(Term,NewTerm):-
</div><div id="l1188" class="code_block">        Term =.. [F,A1,A2],
</div><div id="l1189" class="code_block">        map<span class="nb">_</span>arg<span class="nb">_</span>1(A1,NewA1),
</div><div id="l1190" class="code_block">        NewTerm =.. [F,NewA1,A2].
</div><div id="l1191" class="code_block">
</div><div id="l1192" class="code_block">map<span class="nb">_</span>arg<span class="nb">_</span>1(2,1):- !.
</div><div id="l1193" class="code_block">map<span class="nb">_</span>arg<span class="nb">_</span>1(X,X).
</div><div id="l1194" class="code_block"><span class="k">\end</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l1195" class="code_block">Thus <span class="nb">{</span><span class="k">\tt</span> mymorph/2<span class="nb">}</span> maps <span class="nb">{</span><span class="k">\tt</span> q(2,1)<span class="nb">}</span> to <span class="nb">{</span><span class="k">\tt</span> q(1,1)<span class="nb">}</span> and maps
</div><div id="l1196" class="code_block">both <span class="nb">{</span><span class="k">\tt</span> q(1,1)<span class="nb">}</span> and <span class="nb">{</span><span class="k">\tt</span> q(3,1)<span class="nb">}</span> to themselves.  Then if <span class="nb">{</span><span class="k">\tt</span> SdgIn<span class="nb">}</span>
</div><div id="l1197" class="code_block">is instantiated to the SDG produced in Example~<span class="k">\ref</span><span class="nb">{</span>ex:get-sdg<span class="nb">}</span>, the
</div><div id="l1198" class="code_block">goal <span class="nb">{</span><span class="k">\tt</span> ?- morph<span class="k">\_sdg</span>(SdgIn,mymorph,SdgOut<span class="nb">}</span> would produce:
</div><div id="l1199" class="code_block">
</div><div id="l1200" class="code_block"><span class="k">\begin</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l1201" class="code_block">SdgOut = [subgoal(morph80,q(1,3),6,0,[morph80,morph81]),
</div><div id="l1202" class="code_block">          subgoal(morph81,q(3,3),3,0,[morph80])
</div><div id="l1203" class="code_block"><span class="k">\end</span><span class="nb">{</span>verbatim<span class="nb">}</span>
</div><div id="l1204" class="code_block"><span class="k">\end</span><span class="nb">{</span>example<span class="nb">}</span>
</div><div id="l1205" class="code_block">
</div><div id="l1206" class="code_block"><span class="nb">{</span><span class="k">\bf</span> Error Cases<span class="nb">}</span>  Need to figure out.
</div><div id="l1207" class="code_block">
</div><div id="l1208" class="code_block"><span class="k">\item</span> <span class="k">\ourmoditem</span><span class="nb">{</span>get<span class="k">\_sdg\_scc\_info</span>(+SDG,-ListOut)<span class="nb">}{</span>get<span class="k">\_sdg\_scc\_info</span>/2<span class="nb">}{</span>tables<span class="nb">}</span>
</div><div id="l1209" class="code_block">
</div><div id="l1210" class="code_block">Given the SDG representation produced by <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l1211" class="code_block">  get<span class="k">\_sdg\_info</span>/1<span class="nb">}</span> this predicate returns information
</div><div id="l1212" class="code_block">about the SCCs that are currently under evaluation.  Upon success <span class="nb">{</span><span class="k">\tt</span>
</div><div id="l1213" class="code_block">  ListOut<span class="nb">}</span> will contain a term
</div><div id="l1214" class="code_block">
</div><div id="l1215" class="code_block"><span class="nb">{</span><span class="k">\tt</span> scc(SCCIndex,NumSubgoals,NumAnswers,NumEdges)<span class="nb">}</span>
</div><div id="l1216" class="code_block">
</div><div id="l1217" class="code_block">for each SCC under evaluation, such that:
</div><div id="l1218" class="code_block">
</div><div id="l1219" class="code_block"><span class="k">\bi</span>
</div><div id="l1220" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> SCCIndex<span class="nb">}</span> is the index of the SCC
</div><div id="l1221" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> NumSubgoals<span class="nb">}</span> is the number of subgoals in the SCC
</div><div id="l1222" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> NumAnswers<span class="nb">}</span> is the total number of answers for all subgoals in the SCC
</div><div id="l1223" class="code_block"><span class="k">\item</span> <span class="nb">{</span><span class="k">\tt</span> NumEdges<span class="nb">}</span> is the total number of edges within the SCC.
</div><div id="l1224" class="code_block">  <span class="k">\ei</span>
</div><div id="l1225" class="code_block">
</div><div id="l1226" class="code_block">
</div><div id="l1227" class="code_block"><span class="k">\end</span><span class="nb">{</span>description<span class="nb">}</span>
</div></pre></div></td></tr></table></div>

      
    </div>
  

                    </div>
                    
                    
                </div>
            



        </div>
    </section>
      

    <footer class="sandiego">
    <div class="as-row">
        <div class="footer-wrapper">
            <nav aria-label="Site Links" role="navigation">
                <section>
                    <div class="as-h2">SourceForge</div>
                    <ul>
                    
                        <li><a href="/create/" title="Create a Project">Create a Project</a></li>
                    
                        <li><a href="/directory/" title="Open Source Software Directory">Open Source Software</a></li>
                        <li><a href="/software/" title="Business Software Directory">Business Software</a></li>
                        
                            
                            <li><a href="/top" title="Top Open Source Projects">Top Downloaded Projects</a></li>
                        

                    </ul>
                </section>
            </nav>
            <nav aria-label="Company Links" role="navigation">
                <section>
                    <div class="as-h2">Company</div>
                    <ul>
                        <li><a href="/about">About</a></li>
                        <li><a href="/about/leadership" title="Open Source Software Directory">Team</a></li>
                        <li class="h-card">
                            <address>
                                <span class="p-name p-org">SourceForge Headquarters</span><br>
                                <span class="p-street-address">225 Broadway Suite 1600</span><br>
                                <span class="p-locality">San Diego, CA <span class="p-postal-code">92101</span></span><br>
                                <span class="p-tel">+1 (858) 422-6466</span><br>
                            </address>
                        </li>
                        <li id="social">
                            
<span></span>
<a href="https://twitter.com/sourceforge" class="twitter" rel="nofollow" target="_blank" title="SourceForge on X">


<svg  class="vertical-icon-fix" data-name="twitter" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1684 408q-67 98-162 167 1 14 1 42 0 130-38 259.5t-115.5 248.5-184.5 210.5-258 146-323 54.5q-271 0-496-145 35 4 78 4 225 0 401-138-105-2-188-64.5t-114-159.5q33 5 61 5 43 0 85-11-112-23-185.5-111.5t-73.5-205.5v-4q68 38 146 41-66-44-105-115t-39-154q0-88 44-163 121 149 294.5 238.5t371.5 99.5q-8-38-8-74 0-134 94.5-228.5t228.5-94.5q140 0 236 102 109-21 205-78-37 115-142 178 93-10 186-50z"/></svg></a>
<a href="https://fosstodon.org/@sourceforge" rel="me nofollow" target="_blank" title="SourceForge on Mastodon">


<svg  class="vertical-icon-fix" data-name="mastodon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M433 179.11c0-97.2-63.71-125.7-63.71-125.7-62.52-28.7-228.56-28.4-290.48 0 0 0-63.72 28.5-63.72 125.7 0 115.7-6.6 259.4 105.63 289.1 40.51 10.7 75.32 13 103.33 11.4 50.81-2.8 79.32-18.1 79.32-18.1l-1.7-36.9s-36.31 11.4-77.12 10.1c-40.41-1.4-83-4.4-89.63-54a102.54 102.54 0 0 1-.9-13.9c85.63 20.9 158.65 9.1 178.75 6.7 56.12-6.7 105-41.3 111.23-72.9 9.8-49.8 9-121.5 9-121.5zm-75.12 125.2h-46.63v-114.2c0-49.7-64-51.6-64 6.9v62.5h-46.33V197c0-58.5-64-56.6-64-6.9v114.2H90.19c0-122.1-5.2-147.9 18.41-175 25.9-28.9 79.82-30.8 103.83 6.1l11.6 19.5 11.6-19.5c24.11-37.1 78.12-34.8 103.83-6.1 23.71 27.3 18.4 53 18.4 175z"/></svg></a>
<a href="https://www.facebook.com/sourceforgenet/" class="facebook" rel="nofollow" target="_blank" title="SourceForge on Facebook">


<svg  data-name="facebook" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1343 12v264h-157q-86 0-116 36t-30 108v189h293l-39 296h-254v759h-306v-759h-255v-296h255v-218q0-186 104-288.5t277-102.5q147 0 228 12z"/></svg></a>
<a href="https://www.linkedin.com/company/sourceforge.net" class="linkedin" rel="nofollow" target="_blank" title="SourceForge on LinkedIn">


<svg  data-name="linkedin" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M477 625v991h-330v-991h330zm21-306q1 73-50.5 122t-135.5 49h-2q-82 0-132-49t-50-122q0-74 51.5-122.5t134.5-48.5 133 48.5 51 122.5zm1166 729v568h-329v-530q0-105-40.5-164.5t-126.5-59.5q-63 0-105.5 34.5t-63.5 85.5q-11 30-11 81v553h-329q2-399 2-647t-1-296l-1-48h329v144h-2q20-32 41-56t56.5-52 87-43.5 114.5-15.5q171 0 275 113.5t104 332.5z"/></svg></a>

<a href="/user/newsletters" rel=nofollow class="newsletter" title="Subscribe to our newsletter">


<svg  class="vertical-icon-fix" data-name="mmSF_11mail" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 42 42" enable-background="new 0 0 42 42" xml:space="preserve"><path fill="#FFFFFF" d="M0,6v30h42V6H0z M24.2,21.2c-0.8,0.8-2.3,2-3.2,2c-0.9,0-2.4-1.2-3.2-2L5.8,9.7h30.3L24.2,21.2z M13.7,21l-9.9,9.4V11.6L13.7,21z M15.7,23L15.7,23c0.5,0.5,2.9,2.9,5.3,2.9c2.4,0,4.8-2.4,5.2-2.8l0.1-0.1l9.8,9.4H5.8L15.7,23z M28.3,21l9.9-9.5v18.9L28.3,21z"/></svg></a>

<span></span>
                        </li>
                    </ul>
                </section>
            </nav>
             <nav aria-label="Resources Links" role="navigation">
                <section>
                    <div class="as-h2">Resources</div>
                    <ul>
                        
                            <li><a href="/support" title="Support Section">Support</a></li>
                            <li><a href="/p/forge/documentation/Docs%20Home/" title="Site Documentation">Site Documentation</a></li>
                        
                        <li><a href="https://fosstodon.org/@sourceforgestatus" title="Site Status" rel="me nofollow">Site Status</a></li>
                        <li><a href="/reviews" title="Reviews" rel="me nofollow">SourceForge Reviews</a></li>

                    </ul>
                </section>
            </nav>
            <section class="footer-logo">
                <a href="/" title="Home" class="sf-logo">
                    
    
    <img src="https://a.fsdn.com/con/images/sandiego/sf-logo-full.svg"  alt="SourceForge logo" class="sf-logo-full"/>
                </a>
            </section>
        </div>
    </div>
    <section class="l-nav-bottom">
        <nav class="row">
            
                
            
        
    <div class="columns small-12 large-6 copyright-notice">
        &copy; 2025 Slashdot Media. All Rights Reserved.
    </div>
    <div class="columns large-6 links links-right">
        

    
    

    <a href="https://slashdotmedia.com/terms-of-use" target="_blank" title="Terms" rel="nofollow">Terms</a>
    <a href="https://slashdotmedia.com/privacy-statement/" target="_blank" title="Privacy" rel="nofollow">Privacy</a>

    
    
    

    
        <a href="https://slashdotmedia.com/opt-out-choices/" target="_blank" title="Opt Out" rel="nofollow">Opt Out</a>
    

    
        <a href="https://slashdotmedia.com/contact/" target="_blank" title="Advertise" rel="nofollow">Advertise</a>
    
    </div>
        </nav>
    </section>

    </footer>
    





    
    
    <div id="newsletter-floating" class="sandiego newsletter-floating-new">
        <a class="close-button btn-closer" data-close aria-label="Close modal">
            <span aria-hidden="true">&times;</span>
        </a>
        <div class="as-h2">Want the latest updates on software, tech news, and AI?</div>
        <div class="row">
            <div class="column small-2 medium-2 large-2" style="padding-left: 0px; padding-right: 0px;"><img src="/images/sandiego/sf_email_icon.svg"  alt="" /></div>
            <div class="as-h3 column small-10 medium-10 large-10">Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.</div>
        </div>
        <form action="/user/newsletters/" method="post">
            <div class="row">
              <input class="newsletter-input" type="email" placeholder="Enter your email address" autocomplete="off" name="newsletter_email"
                     value="">
              <input type="hidden" name="source" value="floating">
              <button type="submit" class="button blue newsletter-button">Submit</button>
            </div>
        </form>
    </div>
    






</div>


<div id="messages">
    
</div>


    <!-- ew:body_js -->


    <script type="text/javascript" src="https://a.fsdn.com/allura/nf/1753456284/_ew_/_slim/js?href=allura%2Fjs%2Fjquery.notify.js%3Ballura%2Fjs%2Fjquery.tooltipster.js%3Ballura%2Fjs%2Fallura-base.js%3Ballura%2Fjs%2Fchecklist.js%3Ballura%2Fjs%2Fadmin_modal.js%3Bjs%2Fjquery.lightbox_me.js%3Ballura%2Fjs%2Fmemorable.js%3Btheme%2Fsftheme%2Fjs%2Fsftheme%2Fshared.js%3Btheme%2Fsftheme%2Fjs%2Fsftheme%2Fsticky.js%3Btheme%2Fsftheme%2Fjs%2Fsftheme%2Fsandiego%2Fchrome.js%3Btheme%2Fsftheme%2Fjs%2Fsftheme%2Fsandiego%2Futilities.js%3Btheme%2Fsftheme%2Fjs%2Fsftheme%2Fvendor%2Ffoundation6%2Fplugins%2Ffoundation.core.min.js%3Btheme%2Fsftheme%2Fjs%2Fsftheme%2Fvendor%2Ffoundation6%2Fplugins%2Ffoundation.util.mediaQuery.min.js%3Btheme%2Fsftheme%2Fjs%2Fsftheme%2Fvendor%2Ffoundation6%2Fplugins%2Ffoundation.util.keyboard.min.js%3Btheme%2Fsftheme%2Fjs%2Fsftheme%2Fvendor%2Ffoundation6%2Fplugins%2Ffoundation.util.box.min.js%3Btheme%2Fsftheme%2Fjs%2Fsftheme%2Fvendor%2Ffoundation6%2Fplugins%2Ffoundation.util.nest.min.js%3Btheme%2Fsftheme%2Fjs%2Fsftheme%2Fvendor%2Ffoundation6%2Fplugins%2Ffoundation.dropdownMenu.min.js%3Btheme%2Fsftheme%2Fjs%2Fsftheme%2Fvendor%2Ffoundation6%2Fplugins%2Ffoundation.offcanvas.min.js%3Btheme%2Fsftheme%2Fjs%2Fsftheme%2Fvendor%2Ffoundation6%2Fplugins%2Ffoundation.toggler.min.js%3Btheme%2Fsftheme%2Fjs%2Fsftheme%2Fsandiego%2Fproject.js%3Btheme%2Fsftheme%2Fjs%2Fsftheme%2Fvendor%2Fjquery.typeahead.min.js%3Ballura%2Fjs%2Fmaximize-content.js"></script>

    
<!-- /ew:body_js -->



    <!-- ew:body_js_tail -->


    <script type="text/javascript" src="https://a.fsdn.com/allura/nf/1753456284/_ew_/_slim/js?href=theme%2Fsftheme%2Fjs%2Fsftheme%2Fvendor%2Ffoundation6%2Fplugins%2Ffoundation.util.triggers.min.js%3Btheme%2Fsftheme%2Fjs%2Fsftheme%2Fvendor%2Ffoundation6%2Fplugins%2Ffoundation.reveal.min.js"></script>

    
<!-- /ew:body_js_tail -->




<script type="text/javascript">(function() {
  $('#access_urls .btn').click(function(evt){
    evt.preventDefault();
    var parent = $(this).parents('.btn-bar');
    var checkout_cmd = $(this).attr('data-url');
    $(parent).find('input').val(checkout_cmd);
    $(parent).find('span').text($(this).attr('title')+' access');
    $(this).parent().children('.btn').removeClass('active');
    $(this).addClass('active');
    if (checkout_cmd.indexOf(' http://') !== -1 || checkout_cmd.indexOf(' https://') !== -1 ) {
      $('#http-2fa-msg').show();
    } else {
      $('#http-2fa-msg').hide();
    }
  });
  $('#access_urls .btn').first().click();

  
  var repo_status = document.getElementById('repo_status');
  // The repo_status div will only be present if repo.status != 'ready'
  if (repo_status) {
    $('.spinner').show()
    var delay = 500;
    function check_status() {
        $.get('/p/xsb/src/status', function(data) {
            if (data.status === 'ready') {
                $('.spinner').hide()
                $('#repo_status h2').html('Repo status: ready. <a href="." rel="nofollow">Click here to refresh this page.</a>');
            }
            else {
                $('#repo_status h2 span').html(data.status);
                if (delay < 60000){
                    delay = delay * 2;
                }
                window.setTimeout(check_status, delay);
            }
        });
    }
    var status_checker = window.setTimeout(check_status, delay);
    
  }
}());
</script>

<script type="text/javascript">(function() {
  $(window).on('hashchange', function(e) {
    var hash = window.location.hash.substring(1);
    if ('originalEvent' in e && 'oldURL' in e.originalEvent) {
      $('#' + e.originalEvent.oldURL.split('#')[1]).css('background-color', 'transparent');
    }
    if (hash !== '' && hash.substring(0, 1) === 'l' && !isNaN(hash.substring(1))) {
      $('#' + hash).css('background-color', '#ffff99');
    }
  }).trigger('hashchange');

  var clicks = 0;
  $('.code_block').each(function(index, element) {
    $(element).on('click', function() {
      // Trick to ignore double and triple clicks
      clicks++;
      if (clicks === 1) {
        setTimeout(function() {
          if (clicks === 1) {
            var hash = window.location.hash.substring(1);
            if (hash !== '' && hash.substring(0, 1) === 'l' && !isNaN(hash.substring(1))) {
              $('#' + hash).css('background-color', 'transparent');
            }
            $(element).css('background-color', '#ffff99');
            window.history.pushState({}, document.title, window.location.pathname + window.location.search + '#' + $(element).attr('id'));
          }
          clicks = 0;
        }, 500);
      }
    });
  });
}());
</script>


    


    
    
    <noscript><p><img src="https://analytics.slashdotmedia.com/index.php?idsite=39" style="border:0;position:absolute;top:0;" alt="" /></p></noscript>
    
    <script>
        $(document).foundation();
    </script>
    








    

<script>
    (function () {
        function load_bombora() {
            /*global _ml:true, window */
            _ml = window._ml || {};
            
            _ml.eid = '771';
            _ml.fp = '40425d16-b155-40c1-a775-0b52becd008c';  
            var s = document.getElementsByTagName('script')[0], cd = new Date(), mltag = document.createElement('script');
            mltag.type = 'text/javascript';
            mltag.async = true;
            mltag.defer = true;
            mltag.src = '//ml314.com/tag.aspx?' + cd.getDate() + cd.getMonth() + cd.getFullYear();
            s.parentNode.insertBefore(mltag, s);
        }
        bizx.cmp.ifConsent({ purposes: 'all', vendors: 'bombora'}, load_bombora);
    })();
</script>




<script>
    $(document).ready(function () {
        $(".tooltip, .m-tooltip").each(function(){
            let $el = $(this);
            $el.tooltipster({
                animation: 'fade',
                delay: 200,
                theme: 'tooltipster-light',
                trigger: 'hover',
                position: $el.data('position') || 'right',
                iconCloning: false,
                maxWidth: 300,
                contentAsHTML: true,
                interactive: true
            }).focus(function () {
                $(this).tooltipster('show');
            }).blur(function () {
                $(this).tooltipster('hide');
            });
        });
    });
</script>

    



<script type="text/javascript">
    bizx.cmp.ifConsent({ purposes: ['storage', 'measurement'], vendors: 'google-analytics'}, function () {
        /* jshint ignore:start */
        (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
                (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
        })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
        /* jshint ignore:end */

        window.dataLayer = window.dataLayer || [];
        function gtag(){ window.dataLayer.push(arguments); }
        window.gtag = window.gtag || gtag;
        bizx.cmp.embedScript("https://www.googletagmanager.com/gtag/js");
        gtag('js', new Date());
        gtag('set', {
            'page_location': 'https://sourceforge.net/p/xsb/src/8472/tree/trunk/XSB/docs/userman/debugging.tex',
        });
    });
</script>










<script>
        function gam(id){
            bizx.cmp.ifConsent({ purposes: 'all' }, function () {
                bizx.cmp.embedScript(`https://pagead2.googlesyndication.com/pagead/js/pcd.js?${id}`,
                    true,  // async
                    'head', // location
                    null, // callback
                    false, // defer
                    {id: `google-pcd-tag-${id}`, 'data-audience-pixel': 'dc_iu=/41014381/DFPAudiencePixel;dc_seg=' + id});
            });
        }

        
            gam("8901705213");gam("8901712041");</script>

<script type="text/javascript">
    /*global ga, gtag */

    
        
        bizx.cmp.ifConsent({ purposes: ['storage', 'measurement'], vendors: 'google-analytics'}, function () {
            gtag('config', 'G-1H226E4E4L', {
                
                send_page_view: false,
                'SF_Page_Type': '', 
                user_properties: {
                    'SF_Logged_in': 'Logged Out', 
                },
                'devicePixelRatio': SF.devicePixelRatio, 
            });
            gtag('event', 'page_view', { send_to: 'G-1H226E4E4L' });
        });
    
    
    
        
</script>

</body>
</html>