1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    2% On-line help for Bousi-Prolog shell commands
    3
    4:- module(bplHelp, [
    5		bpl_help/0,             %
    6		command_help/1          % +Topic
    7   ]).    8
    9%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   10
   11:- set_prolog_flag(double_quotes, codes).   12
   13
   14%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   15% Predicates for displaying Bousi-Prolog on-line help
   16%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 bpl_help
Shows a list with all available commands in Bousi-Prolog shell.
   24bpl_help :-
   25	write('----------------------------------------------------------------------------\n'),
   26	write('Available commands:\n'),
   27	write('ld ... (load) reads a source code file containing a program or an ontology,\n'),
   28	write('       or prints the currently loaded files\n'),
   29	write('sv ... (solve) executes a query [\'sv\' can be omitted]\n'),
   30	write('lc ... (lambda-cut) prints or sets the lower bound for the approximation\n'),
   31	write('       degree in weak unifications\n'),
   32	write('fl ... (filtering) prints or sets the state of filtering\n'),
   33	write('pwd .. (print working directory) shows the path of the working directory\n'),
   34	write('cd ... (change directory) changes the working directory\n'),
   35	write('ls ... (list) lists the contents of the working directory\n'),
   36	write('hp ... (help) shows this help text or information about a specific command\n'),
   37	write('sh ... (shell) starts a new interactive shell process\n'),
   38	write('ts ... (test) tests the system\n'),
   39	write('bk ... (break) breaks to the underlying SWI-Prolog\n'),
   40	write('qt ... (quit) quits the system\n'),
   41	write('----------------------------------------------------------------------------\n'),
   42	write('--          Enter \'hp <command>\' to get more help on a <command>          --\n'),
   43	write('----------------------------------------------------------------------------\n').
 command_help(+Command)
Displays help for a specific Bousi-Prolog command.
   51command_help(ld) :-
   52	write('----------------------------------------------------------------------------\n'),
   53	write('LOAD\n'),
   54	nl,
   55	write('Reads, compiles and loads a Bousi~Prolog program or ontology into the\n'),
   56	write('database. The Bousi~Prolog system can have both a program and an ontology\n'),
   57	write('loaded at the same time, but the program must always be loaded first and\n'),
   58	write('the ontology is not allowed to contain clauses.\n'),
   59	nl,
   60	write('The default file extensions are \'.bpl\' for programs and \'.ont\' for onto-\n'),
   61	write('logies. If you want to load a file with a different extension, the full\n'),
   62	write('filename must be provided.\n'),
   63	nl,
   64	write('When used without an argument, this command shows the full path of the\n'),
   65	write('program and ontology which are currently loaded (if any).\n'),
   66	nl,
   67	write('Every Bousi~Prolog source code file is translated into an intermediate\n'),
   68	write('Prolog representation of the original file called \'TPL code\'. This code is\n'),
   69	write('stored in files which have the same name as the original BPL files but with\n'),
   70	write('the \'.tpl\' extension. TPL files are used when BPL files haven\'t been modi-\n'),
   71	write('fied since their corresponding TPL code was created. You can force the\n'),
   72	write('rebuilding of the TPL files using the \'-f\' option.\n'),
   73	nl,
   74	write('Syntax:\n'),
   75	write('ld .............. shows the currently loaded program and ontology\n'),
   76	write('ld <file> ....... loads a Bousi~Prolog program <file>\n'),
   77	write('ld -f <file> .... rebuilds and loads a Bousi~Prolog program <file>\n'),
   78	write('ld -o <file> .... loads a Bousi~Prolog ontology <file>\n'),
   79	write('ld -fo <file> ... rebuilds and loads a Bousi~Prolog ontology <file>\n'),
   80	write('----------------------------------------------------------------------------\n').
   81
   82command_help(sv) :-
   83	write('----------------------------------------------------------------------------\n'),
   84	write('SOLVE\n'),
   85	nl,
   86	write('Executes a query about the currently loaded program using WSLD resolution.\n'),
   87	write('Bousi~Prolog queries can contain any statement that is valid in the body of\n'),
   88	write('a clause, including weak unifications and term comparisons. Queries can also\n'),
   89	write('be executed if no program is loaded.\n'),
   90	nl,
   91	write('When at least one solution is found for a query, the system shows its appro-\n'),
   92	write('ximation degree and the resulting variable values (if any). You can then\n'),
   93	write('type a semicolon (;) to look for more solutions or press RETURN to finish\n'),
   94	write('the current query and return to the Bousi~Prolog shell.\n'),
   95	nl,
   96	write('The \'sv\' command is the default Bousi~Prolog shell command. This means that\n'),
   97	write('you can also enter queries without preceding them with \'sv\'.\n'),
   98	nl,
   99	write('Syntax:\n'),
  100	write('sv <query> ...... solves <query> using WSLD resolution\n'),
  101	write('<query> ......... identical to \'sv <query>\'\n'),
  102	write('----------------------------------------------------------------------------\n').
  103
  104command_help(lc) :-
  105	write('----------------------------------------------------------------------------\n'),
  106	write('LAMBDA-CUT\n'),
  107	nl,
  108	write('Prints or sets the lower bound allowed for the approximation degree in weak\n'),
  109	write('unifications, which is known as the \'lambda-cut\'. When used to set a new\n'),
  110	write('lambda-cut value, this command overrides the lambda_cut/1 directive that may\n'),
  111	write('be present in the already loaded program.\n'),
  112	nl,
  113	write('The lambda-cut can be used to limit the expansion of the search space in a\n'),
  114	write('WSLD resolution. When the lambda-cut value is set to a degree greater than\n'),
  115	write('zero, the weak unification process will fail every time the computed approxi-\n'),
  116	write('mation degree goes below the stored lambda-cut value. Therefore, the computa-\n'),
  117	write('tion will also fail and all branches starting from that choice point will be\n'),
  118	write('discarded.\n'),
  119	nl,
  120	write('Syntax:\n'),
  121	write('lc .............. prints the current lambda-cut value\n'),
  122	write('lc <degree> ..... sets <degree> as the new lambda-cut value, which must be\n'),
  123	write('                  a real number between 0 and 1 (inclusive)\n'),
  124	write('----------------------------------------------------------------------------\n').
  125
  126command_help(fl) :-
  127	write('----------------------------------------------------------------------------\n'),
  128	write('FILTERING\n'),
  129	nl,
  130	write('Prints or sets whether filtering is enabled or not. When used to set a new\n'),
  131	write('filtering value, this command overrides the filtering/1 directive that may\n'),
  132	write('be present in the already loaded program.\n'),
  133	nl,
  134	write('The filtering is enabled by default. When enabled, it removes the proximity\n'),
  135	write('equations that are below the lambda-cut. As a consequence, translated program\n'),
  136	write('rules (in the .tpl file) which are known to not be selected for a lambda-cut\n'),
  137	write('less than the current one are also discarded.\n'),
  138	nl,
  139	write('Syntax:\n'),
  140	write('fl .............. prints whether filtering is enabled or not\n'),
  141	write('fl <boolean> .... sets <boolean> as the new value, which must be\n'),
  142	write('                  a Boolean (either \'true\' or \'false\')\n'),
  143	write('----------------------------------------------------------------------------\n').
  144
  145command_help(hp) :-
  146	write('----------------------------------------------------------------------------\n'),
  147	write('HELP\n'),
  148	nl,
  149	write('Gives a summary of the Bousi~Prolog shell commands or detailed information\n'),
  150	write('about a specific command.\n'),
  151	nl,
  152	write('Syntax:\n'),
  153	write('hp .............. shows a summary of the shell commands\n'),
  154	write('hp <command> .... shows information about the given <command>\n'),
  155	write('----------------------------------------------------------------------------\n').
  156
  157command_help(ls) :-
  158	write('----------------------------------------------------------------------------\n'),
  159	write('LIST\n'),
  160	nl,
  161	write('Lists the files and folders of the current working directory.\n'),
  162	nl,
  163	write('Syntax:\n'),
  164	write('ls .............. list the contents of the working directory\n'),
  165	write('----------------------------------------------------------------------------\n').
  166
  167command_help(pwd) :- 
  168	write('----------------------------------------------------------------------------\n'),
  169	write('PRINT WORKING DIRECTORY\n'),
  170	nl,
  171	write('Shows the absolute path of the current working directory.\n'),
  172	nl,
  173	write('Syntax:\n'),
  174	write('pwd ............. shows the full path of the working directory\n'),
  175	write('----------------------------------------------------------------------------\n').
  176
  177command_help(cd) :- 
  178	write('----------------------------------------------------------------------------\n'),
  179	write('CHANGE DIRECTORY\n'),
  180	nl,
  181	write('Changes the current working directory.\n'),
  182	nl,
  183	write('Syntax:\n'),
  184	write('cd <path> ....... changes the working directory to <path>, which can be\n'),
  185	write('                  either an absolute or a relative path\n'),
  186	write('----------------------------------------------------------------------------\n').
  187
  188command_help(sh) :- 
  189	write('----------------------------------------------------------------------------\n'),
  190	write('SHELL\n'),
  191	nl,
  192	write('Starts a new interactive command-line shell without ending the Bousi~Prolog\n'),
  193	write('system. The default shell is \'/bin/sh\' on Unix/Linux and \'cmd.exe\' on,\n'),
  194	write('Windows, but you can override it entering a different path in the environ-\n'),
  195	write('ment variables SHELL (on Unix/Linux) and COMSPEC (on Windows).\n'),
  196	nl,
  197	write('Syntax:\n'),
  198	write('sh .............. starts a new interactive shell process\n'),
  199	write('----------------------------------------------------------------------------\n').
  200
  201command_help(ts) :-
  202	write('----------------------------------------------------------------------------\n'),
  203	write('TEST\n'),
  204	nl,
  205	write('Test the system with a bundle of test programs.\n'),
  206	nl,
  207	write('Syntax:\n'),
  208	write('ts .............. tests the system\n'),
  209	write('----------------------------------------------------------------------------\n').
  210
  211command_help(bk) :-
  212	write('----------------------------------------------------------------------------\n'),
  213	write('BREAK\n'),
  214	nl,
  215	write('Leaves the Bousi~Prolog system and enter underlying Prolog. Use ?- main. to\n'),
  216	write('restart the system.\n'),
  217	nl,
  218	write('Syntax:\n'),
  219	write('bk .............. breaks to the underlying SWI-Prolog\n'),
  220	write('----------------------------------------------------------------------------\n').
  221
  222command_help(qt) :-
  223	write('----------------------------------------------------------------------------\n'),
  224	write('QUIT\n'),
  225	nl,
  226	write('Quits the Bousi~Prolog system immediately. Always use this command instead\n'),
  227	write('of the predefined predicate halt/0 when you want to end the application.\n'),
  228	nl,
  229	write('Syntax:\n'),
  230	write('qt .............. quits the system\n'),
  231	write('----------------------------------------------------------------------------\n')