Generating Documents with ProB and Latex: Difference between revisions - ProB Documentation

Generating Documents with ProB and Latex: Difference between revisions

Created page with "ProB can (as of version 1.6.1) be used to process Latex files, i.e., the command-line tool probcli scans a given Latex file and replaces certain commands by processed results...."
 
 
(15 intermediate revisions by the same user not shown)
Line 10: Line 10:
Note: the FILE and -init commands are optional; they are required in case you want to
Note: the FILE and -init commands are optional; they are required in case you want to
process the commands in the context of a certain model.
process the commands in the context of a certain model.
Currently the probcli Latex commands mainly support B and Event-B models,  
Currently the probcli Latex commands mainly support B and Event-B models, TLA+ and Z models can also be processed but all commands below expect B syntax.
TLA+ and Z models can also be processed but all commands below expect B syntax.
You can add more commands if you wish, e.g., set preferences using <tt>-p PREF VAL</tt> or run model checking <tt>--model-check</tt>.
You can add more commands if you wish, e.g., set preferences using <tt>-p PREF VAL</tt> or run model checking <tt>--model-check</tt>.
The Latex processing will take place after most other commands, such as model checking.
The Latex processing will take place after most other commands, such as model checking.


You will probably want to put the probcli call into a Makefile, in particular when you want to generate dot graphics using ProB (see below).
You will probably want to put the probcli call into a Makefile, in particular when you want to generate dot graphics using ProB.
 
The distribution folder of ProB contains an example with a Makefile, producing the following file, which at the same time documents the core features:
 
[[File:prob_latex_doc.pdf]]
 
== Commands ==
 
The commands are described in the PDF document above.
Here is a short summary of some of the commands:
* <tt>\probexpr{EXRP}</tt> command takes a B expression <tt>EXPR</tt>as argument and evaluates it. By default it shows the B expression and the value of the expression. Example: <tt>\probexpr{{1}\/{2**10}}</tt> will be replaced by <tt>{1,1024}</tt>
** <tt>ascii</tt> to print the result as ASCII rather than using Latex math symbols
** <tt>time</tt> to display the time taken for the command
** <tt>string</tt> the result value is a string, and do not print the quotes around the string
** <tt>value</tt> to just print the value, not the expression
 
* <tt>\probrepl{CMD}</tt> command takes a probcli REPL command <tt>CMD</tt> as argument and executes it. By default it shows only the output of the execution, e.g., in case it is a predicate TRUE or FALSE. Example: <tt>\probrepl{let DOM = 1..3}</tt>. A variation of the latter is the new command <tt>\problet{DOM}{1..3}</tt> which shows the let construct itself within the generated Latex. Optional arguments for <tt>\probrepl</tt> are :
**<tt>solution</tt> to display the solution bindings (for existential variables) found by ProB
**<tt>store</tt> to store the solution bindings as local variables (similar to let)
** <tt>ascii</tt> to print the result as ASCII rather than using Latex math symbols
** <tt>time</tt> to display the time taken for the command
** <tt>print</tt> to print the expression/predicate being evaluated (automatically set by <tt>\problet</tt>
** <tt>silent</tt> to not print the result of the evaluation
 
* <tt>\probtable{EXRP}</tt> command takes a B expression <tt>EXPR</tt>as argument, evaluates it and shows it as a Latex table. Optional arguments are <tt>no-tabular</tt>, <tt>no-hline</tt>, <tt>no-headings</tt>, <tt>no-row-numbers</tt>, <tt>max-table-size=NR</tt>.
 
* <tt>\probdot{DOT}{File1}</tt> command takes a B expression <tt>EXPR</tt>as argument, evaluates it as a graph and writes a dot file <tt>File1</tt>. You can provide a second File as argument, in which case <tt>dot</tt> is called to generate a PDF document. You can also set <tt>sfdp</tt> as third argument, in which case the <tt>sfdp</tt> tool will be used instead of <tt>dot</tt>.
 
* <tt>\probprint{EXRP}</tt> command takes a B expression or predicate <tt>EXPR</tt>as argument and pretty prints it. Optional arguments are:
**<tt>pred</tt> only try to parse first argument as predicate
**<tt>expr</tt> only try to parse first argument as expression
**<tt>ascii</tt>  to print the result as ASCII rather than using Latex math symbols
 
* <tt>\probif{EXPR}{Then}{Else}</tt> command takes an expression or predicate <tt>EXPR</tt> and two Latex texts. If the expression evaluates to TRUE the first branch <tt>Then</tt> is processed, otherwise the other one <tt>Else</tt> is processed.
 
* <tt>\probfor{ID}{Set}{Body}</tt> command takes an identifier <tt>ID</tt>, a set expression <tt>Set</tt> and a Latex text <tt>Body</tt>, and processes the Latex text for every element of the set expression, setting the identifier to a value of the set.
 
== Some Examples ==
 
* Presentation held in Grenoble in September 2016 about "Constraint Programming Puzzles in B" [[File:puzzle_latex_presentation.pdf]]
* SBMF'2016 keynote article "Formal Model-Based Constraint Solving and Document Generation" [[File:sbmf_2016_latex.pdf]]

Latest revision as of 05:57, 25 October 2016

ProB can (as of version 1.6.1) be used to process Latex files, i.e., the command-line tool probcli scans a given Latex file and replaces certain commands by processed results.

Usage

A typical usage would be as follows:

   probcli FILE -init -latex Raw.tex Final.tex

Note: the FILE and -init commands are optional; they are required in case you want to process the commands in the context of a certain model. Currently the probcli Latex commands mainly support B and Event-B models, TLA+ and Z models can also be processed but all commands below expect B syntax. You can add more commands if you wish, e.g., set preferences using -p PREF VAL or run model checking --model-check. The Latex processing will take place after most other commands, such as model checking.

You will probably want to put the probcli call into a Makefile, in particular when you want to generate dot graphics using ProB.

The distribution folder of ProB contains an example with a Makefile, producing the following file, which at the same time documents the core features:

File:Prob latex doc.pdf

Commands

The commands are described in the PDF document above. Here is a short summary of some of the commands:

  • \probexpr{EXRP} command takes a B expression EXPRas argument and evaluates it. By default it shows the B expression and the value of the expression. Example: \probexpr{{1}\/{2**10}} will be replaced by {1,1024}
    • ascii to print the result as ASCII rather than using Latex math symbols
    • time to display the time taken for the command
    • string the result value is a string, and do not print the quotes around the string
    • value to just print the value, not the expression
  • \probrepl{CMD} command takes a probcli REPL command CMD as argument and executes it. By default it shows only the output of the execution, e.g., in case it is a predicate TRUE or FALSE. Example: \probrepl{let DOM = 1..3}. A variation of the latter is the new command \problet{DOM}{1..3} which shows the let construct itself within the generated Latex. Optional arguments for \probrepl are :
    • solution to display the solution bindings (for existential variables) found by ProB
    • store to store the solution bindings as local variables (similar to let)
    • ascii to print the result as ASCII rather than using Latex math symbols
    • time to display the time taken for the command
    • print to print the expression/predicate being evaluated (automatically set by \problet
    • silent to not print the result of the evaluation
  • \probtable{EXRP} command takes a B expression EXPRas argument, evaluates it and shows it as a Latex table. Optional arguments are no-tabular, no-hline, no-headings, no-row-numbers, max-table-size=NR.
  • \probdot{DOT}{File1} command takes a B expression EXPRas argument, evaluates it as a graph and writes a dot file File1. You can provide a second File as argument, in which case dot is called to generate a PDF document. You can also set sfdp as third argument, in which case the sfdp tool will be used instead of dot.
  • \probprint{EXRP} command takes a B expression or predicate EXPRas argument and pretty prints it. Optional arguments are:
    • pred only try to parse first argument as predicate
    • expr only try to parse first argument as expression
    • ascii to print the result as ASCII rather than using Latex math symbols
  • \probif{EXPR}{Then}{Else} command takes an expression or predicate EXPR and two Latex texts. If the expression evaluates to TRUE the first branch Then is processed, otherwise the other one Else is processed.
  • \probfor{ID}{Set}{Body} command takes an identifier ID, a set expression Set and a Latex text Body, and processes the Latex text for every element of the set expression, setting the identifier to a value of the set.

Some Examples