Logicalc Documentation


Logicalc can be used with virtually any HTML web page. Just follow the steps below. The examples here illustrate how the Constraints documentation page is implemented.

(1) Load Logicalc code in the head. To do this, place the following lines in the head of the web page.

<script type='text/javascript' src='http://logic.stanford.edu/epilog/javascript/epilog.js'> </script> <script type='text/javascript' src='http://logic.stanford.edu/infoserver/javascript/dataserver.js'> </script>

(2) Place an "id" attribute and an "arity" attribute on every table that you want Logicalc to manage. The tables should be left empty as show here. See below for an example.

<table id='p' arity='2'></table> <table id='q' arity='3'></table>

(3) Supply any initial data for managed tables. This is done by writing information into a "div" with id "repository" and with data written in standard mathematical notation. For example, we would specify three rows for the p table as shown below. (When the page is loaded, this data will automatically be formatted into the tables declared as shown above.) This div may be made invisible to user (and probably should be).

<div id='repository'> p(a,b) p(b,c) p(c,d) q(1,2,3) q(2,3,4) </div>

(4) Enter any rules in a div with id "library". This may be made invisible to user (and probably should be).

<div style='font-family:courier;display:none'> illegal :- p(X,Y) & p(Y,X) illegal :- p(X,Y) & p(Y,Z) & p(X,Z) q(X,Y,Z) :- p(X,Y) & p(Y,Z) </div>

(5) If you wish to allow the user to control import, export, upload, download, publish, and subscribe, add appropriate buttons to your page. Here are some examples.

<input type='button' value='Import Data' style='width:100' onClick='importdata()'/> <input type='button' value='Export Data' style='width:100' onClick='exportdata()'/> <input id='upload' type='button' value='Upload' style='width:100' onClick='upload()'/> <input id='download' type='button' value='Download' style='width:100' onClick='download()'/> <input type='button' value='Publish' style='width:100' onClick='publish(this)'/> <input type='button' value='Subscribe' style='width:100' onClick='subscribe(this)'/>

Note that these do not have to be buttons. What is important is to provide the user with a way of getting the onClick methods to run.

(6) Register all tables to be managed and initialize in a script at end of page.

<script type="text/javascript" language="javascript"> register('p'); register('q'); initialize(); </script>

Note that the loading script must be in the head and the initialization script must be at the end of the document. However, the tables being managed and the repository and library divs can appear anywhere; and they can be made visible or invisible (using the "display:none" style directive).


Comments and complaints to genesereth@stanford.edu.