4 .. _sec.proverdetectiondata:
9 The data configuration for the automatic detection of installed provers
10 is stored in the file :file:`provers-detection-data.conf` typically located
11 in directory :file:`/usr/local/share/why3` after installation.
15 The :file:`why3.conf` Configuration File
16 ----------------------------------------
18 One can use a custom configuration file. The Why3 tools look for it in
21 #. the file specified by the :option:`why3 --config` option,
23 #. the file specified by the environment variable :envvar:`WHY3CONFIG` if set,
25 #. the file :file:`$HOME/.why3.conf` (:file:`$USERPROFILE/.why3.conf` under
26 Windows) or, in the case of local installation, :file:`why3.conf` in the
27 top directory of Why3 sources.
29 If none of these files exist, a built-in default configuration is used.
31 A section begins with a header inside square brackets and ends at the
32 beginning of the next section. The header of a section can be a single
33 identifier, e.g., ``[main]``, or it can be composed by a family name and a
34 single family argument, e.g., ``[prover alt-ergo]``.
36 Sections contain associations ``key=value``. A value is either an
37 integer (e.g., ``-555``), a boolean (``true``, ``false``), or a string
38 (e.g., ``"emacs"``). Some specific keys can be attributed multiple values and
39 are thus allowed to occur several times inside a given section. In that
40 case, the relative order of these associations matters.
42 Extra configuration files
43 ~~~~~~~~~~~~~~~~~~~~~~~~~
45 In addition to the main configuration file, Why3 commands accept the
46 option :option:`why3 --extra-config` to read one or more files
47 containing additional configuration option. It allows the user to pass
48 extra declarations in prover drivers, as illustrated in
49 :numref:`sec.userdrivers`, including declarations for
50 realizations, as illustrated in :numref:`sec.realizations`.
55 Drivers for External Provers
56 ----------------------------
58 Drivers for external provers are readable files from directory
59 ``drivers``. They describe how Why3 should interact
60 with external provers.
62 Files with :file:`.drv` extension represent drivers that might be
63 associated to a specific solver in the :file:`why3.conf`
64 configuration file (see :numref:`sec.whyconffile` for more information);
65 files with :file:`.gen` extension are intended to be imported by
66 other drivers; finally, files with :file:`.aux` extension are
67 automatically generated from the main :file:`Makefile`.
69 .. graphviz:: generated/drivers-smt.dot
70 :caption: Driver dependencies for SMT solvers
73 .. graphviz:: generated/drivers-tptp.dot
74 :caption: Driver dependencies for TPTP solvers
77 .. graphviz:: generated/drivers-coq.dot
78 :caption: Driver dependencies for Coq
81 .. graphviz:: generated/drivers-isabelle.dot
82 :caption: Driver dependencies for Isabelle/HOL
83 :name: fig.drv.isabelle
85 .. graphviz:: generated/drivers-pvs.dot
86 :caption: Driver dependencies for PVS
89 The most important drivers dependencies are shown in the following
90 figures: :numref:`fig.drv.smt` shows the drivers files for SMT
91 solvers, :numref:`fig.drv.tptp` for TPTP solvers, :numref:`fig.drv.coq`
92 for Coq, :numref:`fig.drv.isabelle` for Isabelle/HOL,
93 and :numref:`fig.drv.pvs` for PVS.
97 Drivers for User Theories
98 -------------------------
100 It is possible for the users to augment the system drivers with extra
101 information for their own declared theories. The process is
102 described by the following example.
104 First, we define a new theory in a file :file:`bvmisc.mlw`, containing
106 .. code-block:: whyml
111 function lsb BV16.t : BV8.t (** least significant bits *)
112 function msb BV16.t : BV8.t (** most significant bits *)
115 For such a theory, it is a good idea to declare specific translation
116 rules for provers that have a built-in bit-vector support, such as Z3
117 and CVC4 in this example. To do so, we write a extension driver file,
118 :file:`my.drv`, containing
120 .. code-block:: whyml
123 syntax function lsb "((_ extract 7 0) %1)"
124 syntax function msb "((_ extract 15 8) %1)"
127 Now to tell Why3 that we would like this driver extension when calling
128 Z3 or CVC4, we write an extra configuration file, :file:`my.conf`,
141 Finally, to make the whole thing work, we have to call any Why3 command
142 with the additional option :option:`why3 --extra-config`, such as
146 why3 --extra-config=my.conf prove myfile.mlw
148 .. _sec.transformations:
153 This section documents the available transformations. Note that the set
154 of available transformations in your own installation is given
155 by :why3:tool:`why3 show transformations`.
157 .. why3:transform:: apply
159 Apply an hypothesis to the goal of the task using a *modus ponens*
160 rule. The hypothesis should be an implication whose conclusion can be
161 matched with the goal. The intuitive behavior
162 of :why3:transform:`apply` can be translated as follows.
163 Given :math:`\Gamma, h: f_1 \rightarrow f_2 \vdash G: f_2`, ``apply h``
164 generates a new task :math:`\Gamma, h: f_1 \rightarrow f_2 \vdash G: f_1`.
166 In practice, the transformation also manages to instantiate some variables
167 with the appropriate terms.
169 For example, applying the transformation ``apply zero_is_even`` on the
172 .. code-block:: whyml
174 predicate is_even int
175 predicate is_zero int
176 axiom zero_is_even: forall x: int. is_zero x -> is_even x
179 produces the following goal:
181 .. code-block:: whyml
183 predicate is_even int
184 predicate is_zero int
185 axiom zero_is_even: forall x:int. is_zero x -> is_even x
188 The transformation first matched the goal against the hypothesis and
189 instantiated ``x`` with ``0``. It then applied the *modus ponens* rule
190 to generate the new goal.
192 This transformation helps automated provers when they do not know
193 which hypothesis to use in order to prove a goal.
195 .. why3:transform:: apply with
197 Variant of :why3:transform:`apply` intended to be used in contexts
198 where the latter cannot infer what terms to use for variables given in
199 the applied hypothesis.
201 For example, applying the transformation ``apply transitivity`` on the
204 .. code-block:: whyml
208 axiom transitivity : forall x y z:int. x = y -> y = z -> x = z
211 raises the following error:
215 apply: Unable to infer arguments (try using "with") for: y
217 It means that the tool is not able to infer the right term to
218 instantiate symbol ``y``. In our case, the user knows that the term
219 ``c`` should work. So, it can be specified as follows:
220 ``apply transitivity with c``
222 This generates two goals which are easily provable with hypotheses
225 When multiple variables are needed, they should be provided as a list
226 in the transformation. For the sake of the example, we complicate
227 the ``transitivity`` hypothesis:
229 .. code-block:: whyml
231 axiom t : forall x y z k:int. k = k -> x = y -> y = z -> x = z
233 A value can be provided for ``k`` as follows: ``apply t with c,0``.
235 .. why3:transform:: assert
237 Create an intermediate subgoal. This is comparable to ``assert``
238 written in WhyML code. Here, the intent is only to help provers by
239 specifying one key argument of the reasoning they should use.
241 Example: From a goal of the form :math:`\Gamma \vdash G`, the
242 transformation ``assert (n = 0)`` produces the following two
243 tasks: :math:`\Gamma \vdash h: n = 0` and :math:`\Gamma, h: n =
244 0 \vdash G`. This effectively adds ``h`` as an intermediate goal to prove.
246 .. why3:transform:: assert as
248 Same as :why3:transform:`assert`, except that a name can be given to
249 the new hypothesis. Example: ``assert (x = 0) as x0``.
251 .. why3:transform:: case
253 Split a goal into two subgoals, using the *excluded middle* on a given
254 formula. On the task :math:`\Gamma \vdash G`, the transformation
255 ``case f`` produces two tasks: :math:`\Gamma, h: f \vdash G` and
256 :math:`\Gamma, h: \neg f \vdash G`.
258 For example, applying ``case (x = 0)`` on the following goals
260 .. code-block:: whyml
264 goal G: if x = 0 then y = 2 else y = 3
266 produces the following goals:
268 .. code-block:: whyml
273 goal G : if x = 0 then y = 2 else y = 3
275 .. code-block:: whyml
280 goal G : if x = 0 then y = 2 else y = 3
282 The intent is again to simplify the job of automated provers by giving
283 them a key argument of the reasoning behind the proof of a subgoal.
285 .. why3:transform:: case as
287 Same as :why3:transform:`case`, except that a name can be given to
288 the new hypothesis. Example: ``case (x = 0) as x0``.
290 .. why3:transform:: clear_but
292 Remove all the hypotheses except those specified in the arguments.
293 This is useful when a prover fails to find relevant hypotheses in
294 a very large context. Example: ``clear_but h23,h25``.
296 .. why3:transform:: compute_hyp
298 Apply the transformation :why3:transform:`compute_in_goal` on the given
301 .. why3:transform:: compute_hyp_specified
303 Apply the transformation :why3:transform:`compute_specified` on the
306 .. why3:transform:: compute_in_goal
308 Aggressively apply all known computation/simplification rules.
310 The kinds of simplification are as follows.
312 - Computations with built-in symbols, e.g., operations on integers, when
313 applied to explicit constants, are evaluated. This includes
314 evaluation of equality when a decision can be made (on integer
315 constants, on constructors of algebraic data types), Boolean
316 evaluation, simplification of pattern-matching/conditional
317 expression, extraction of record fields, and beta-reduction. At best,
318 these computations reduce the goal to ``true`` and the
319 transformations thus does not produce any sub-goal. For example, a
320 goal like ``6*7=42`` is solved by those transformations.
322 - Unfolding of definitions, as done by :why3:transform:`inline_goal`. Transformation
323 :why3:transform:`compute_in_goal` unfolds all definitions, including recursive
324 ones. For :why3:transform:`compute_specified`, the user can enable unfolding of a
325 specific logic symbol by attaching the meta :why3:meta:`rewrite_def` to the
328 .. code-block:: whyml
330 function sqr (x:int) : int = x * x
331 meta "rewrite_def" function sqr
333 - Rewriting using axioms or lemmas declared as rewrite rules. When an
334 axiom (or a lemma) has one of the forms
336 .. code-block:: whyml
338 axiom a: forall ... t1 = t2
342 .. code-block:: whyml
344 axiom a: forall ... f1 <-> f2
346 then the user can declare
348 .. code-block:: whyml
350 meta "rewrite" prop a
352 to turn this axiom into a rewrite rule. Rewriting is always done from
353 left to right. Beware that there is no check for termination nor for
354 confluence of the set of rewrite rules declared.
356 Instead of using a meta, it is possible to declare an axiom as a rewrite
357 rule by adding the :why3:attribute:`[@rewrite]` attribute on the axiom name or on the
360 .. code-block:: whyml
362 axiom a [@rewrite]: forall ... t1 = t2
363 lemma b: [@rewrite] forall ... f1 <-> f2
365 The second form allows some form of local rewriting, e.g.,
367 .. code-block:: whyml
369 lemma l: forall x y. ([@rewrite] x = y) -> f x = f y
371 can be proved by :why3:transform:`introduce_premises` followed by
372 :why3:transform:`compute_specified`.
374 The computations performed by this transformation can take an
375 arbitrarily large number of steps, or even not terminate. For this
376 reason, the number of steps is bounded by a maximal value, which is set
377 by default to 1000. This value can be increased by another meta, e.g.,
379 .. code-block:: whyml
381 meta "compute_max_steps" 1_000_000
383 When this upper limit is reached, a warning is issued, and the
384 partly-reduced goal is returned as the result of the transformation.
386 .. why3:transform:: compute_specified
388 Same as :why3:transform:`compute_in_goal`, but perform rewriting using
389 only built-in operators and user-provided rules.
391 .. why3:transform:: cut
393 Same as :why3:transform:`assert`, but the order of the generated subgoals
396 .. why3:transform:: destruct
398 Eliminate the head symbol of a hypothesis.
400 For example, applying ``destruct h`` on the following goal
402 .. code-block:: whyml
406 axiom h : p1 = True /\ (forall x:int. p2 x)
409 removes the logical connective ``/\`` and produces
411 .. code-block:: whyml
416 axiom h : forall x:int. p2 x
419 :why3:transform:`destruct` can be applied on the following constructions:
421 - ``false``, ``true``,
422 - ``/\``, ``\/``, ``->``, ``not``,
424 - ``if ... then ... else ...``,
425 - ``match ... with ... end``,
426 - (in)equality on constructors of the same type.
428 .. why3:transform:: destruct_rec
430 Recursively call :why3:transform:`destruct` on the generated
431 hypotheses. The recursion on implication and ``match`` stops after the
432 first occurrence of a different symbol.
434 For example, applying ``destruct_rec H`` on the following goal
436 .. code-block:: whyml
441 axiom H : (a -> b) /\ (b /\ c)
444 does not destruct the implication symbol because it occurs as
445 a subterm of an already destructed symbol. This restriction applies
446 only to implication and ``match`` Other symbols are destructed
447 recursively. Thus, in the generated task, the second ``/\`` is
450 .. code-block:: whyml
460 .. why3:transform:: destruct_term
462 Destruct an expression according to the type of the expression. The
463 transformation produces all possible outcomes of a destruction of the
466 For example, applying ``destruct_term a`` on the following goal
468 .. code-block:: whyml
474 produces the following two goals:
476 .. code-block:: whyml
484 .. code-block:: whyml
491 The term was destructed according to all the possible outcomes in the
492 type. Note that, during destruction, a new constant ``x`` has been
493 introduced for the argument of constructor ``B``.
495 .. why3:transform:: destruct_term using
497 Same as :why3:transform:`destruct_term`, except that names can be given to
498 the constants that were generated.
500 .. why3:transform:: destruct_term_subst
502 Same as :why3:transform:`destruct_term`, except that it also
503 substitutes the created term.
505 .. why3:transform:: eliminate_algebraic
507 Replace algebraic data types by first-order definitions :cite:`paskevich09rr`.
509 .. why3:transform:: eliminate_builtin
511 Remove definitions of symbols that are declared as builtin in the
512 driver, with a “syntax” rule.
514 .. why3:transform:: eliminate_definition_func
516 Replace all function definitions with axioms.
518 .. why3:transform:: eliminate_definition_pred
520 Replace all predicate definitions with axioms.
522 .. why3:transform:: eliminate_definition
524 Apply both :why3:transform:`eliminate_definition_func` and
525 :why3:transform:`eliminate_definition_pred`.
527 .. why3:transform:: eliminate_if
529 Apply both :why3:transform:`eliminate_if_term` and :why3:transform:`eliminate_if_fmla`.
531 .. why3:transform:: eliminate_if_fmla
533 Replace formulas of the form ``if f1 then f2 else f3`` by an
534 equivalent formula using implications and other connectives.
536 .. why3:transform:: eliminate_if_term
538 Replace terms of the form ``if formula then t2 else t3`` by lifting
539 them at the level of formulas. This may introduce ``if then else``
542 .. why3:transform:: eliminate_inductive
544 Replace inductive predicates by (incomplete) axiomatic definitions,
545 construction axioms and an inversion axiom.
547 .. why3:transform:: eliminate_let
549 Apply both :why3:transform:`eliminate_let_fmla` and :why3:transform:`eliminate_let_term`.
551 .. why3:transform:: eliminate_let_fmla
553 Eliminate ``let`` by substitution, at the predicate level.
555 .. why3:transform:: eliminate_let_term
557 Eliminate ``let`` by substitution, at the term level.
559 .. why3:transform:: eliminate_literal
561 .. why3:transform:: eliminate_mutual_recursion
563 Replace mutually recursive definitions with axioms.
565 .. why3:transform:: eliminate_recursion
567 Replace all recursive definitions with axioms.
569 .. why3:transform:: encoding_smt
571 Encode polymorphic types into monomorphic types :cite:`conchon08smt`.
573 .. why3:transform:: encoding_tptp
575 Encode theories into unsorted logic.
577 .. why3:transform:: exists
579 Instantiate an existential quantification with a witness.
581 For example, applying ``exists 0`` on the following goal
583 .. code-block:: whyml
585 goal G : exists x:int. x = 0
587 instantiates the symbol ``x`` with ``0``. Thus, the goal becomes
589 .. code-block:: whyml
593 .. why3:transform:: hide
595 Hide a given term, by creating a new constant equal to the term and
596 then replacing all occurrences of the term in the context by this
599 For example, applying ``hide t (1 + 1)`` on the goal
601 .. code-block:: whyml
604 axiom h : forall x:int. x = (1 + 1)
605 goal G : (y - (1 + 1)) = ((1 + 1) - (1 + 1))
607 replaces all the occurrences of ``(1 + 1)`` with ``t``, which gives
610 .. code-block:: whyml
614 axiom H : t = (1 + 1)
615 axiom h : forall x:int. x = t
616 goal G : (y - t) = (t - t)
618 .. why3:transform:: hide_and_clear
620 First apply :why3:transform:`hide` and then remove the equality
621 between the hidden term and the introduced constant. This means that
622 the hidden term completely disappears and cannot be recovered.
624 .. why3:transform:: induction
626 Perform a reasoning by induction for the current goal.
628 For example, applying ``induction n`` on the following goal
630 .. code-block:: whyml
638 performs an induction on ``n`` starting at ``0``. The goal for the
641 .. code-block:: whyml
650 while the recursive case is
652 .. code-block:: whyml
659 axiom Hrec : forall n1:int. n1 < n -> p1 n1 -> p n1
662 .. why3:transform:: induction from
664 Same as :why3:transform:`induction`, but it starts the induction from
665 a given integer instead of ``0``.
667 .. why3:transform:: induction_arg_pr
669 Apply :why3:transform:`induction_pr` on the given hypothesis/goal symbol.
671 .. why3:transform:: induction_arg_ty_lex
673 Apply :why3:transform:`induction_ty_lex` on the given symbol.
675 .. why3:transform:: induction_pr
677 .. why3:transform:: induction_ty_lex
679 Perform structural, lexicographic induction on goals involving
680 universally quantified variables of algebraic data types, such as
681 lists, trees, etc. For instance, it transforms the following goal
683 .. code-block:: whyml
685 goal G: forall l: list 'a. length l >= 0
689 .. code-block:: whyml
694 | Nil -> length l >= 0
695 | Cons a l1 -> length l1 >= 0 -> length l >= 0
698 When induction can be applied to several variables, the
699 transformation picks one heuristically. The :why3:attribute:`[@induction]`
700 attribute can be used to force induction over one particular
703 .. code-block:: whyml
705 goal G: forall l1 [@induction] l2 l3: list 'a.
706 l1 ++ (l2 ++ l3) = (l1 ++ l2) ++ l3
708 induction will be applied on ``l1``. If this attribute is attached
709 to several variables, a lexicographic induction is performed on
710 these variables, from left to right.
712 .. why3:transform:: inline_trivial
714 Expand and remove definitions of the form
716 .. code-block:: whyml
718 function f x1 ... xn = g e1 ... ek
719 predicate p x1 ... xn = q e1 ... ek
721 when each :samp:`e{i}` is either a ground term or one of the
722 :samp:`x{j}`, and each ``x1 ... xn`` occurs at most once in
723 all the :samp:`e{i}`.
725 The attribute :why3:attribute:`[@inline:trivial]` can be used to tag functions, so
726 that the transformation forcefully expands them (not using the
727 conditions above). This can be used to ensure that some specific
728 functions are inlined for automatic provers
729 (:why3:transform:`inline_trivial` is used in many drivers).
731 .. why3:transform:: inline_goal
733 Expand all outermost symbols of the goal that have a non-recursive
736 .. why3:transform:: inline_all
738 Expand all non-recursive definitions.
740 .. why3:transform:: instantiate
742 Generate a new hypothesis with quantified variables
743 replaced by the given terms.
745 For example, applying ``instantiate h 0, 1`` on the following goal
747 .. code-block:: whyml
750 axiom h : forall x:int, y:int. x <= y -> p x /\ p y
753 generates a new hypothesis:
755 .. code-block:: whyml
758 axiom h : forall x:int, y:int. x <= y -> p x /\ p y
759 axiom Hinst : 0 <= 1 -> p 0 /\ p 1
762 This is used to help automatic provers that are generally better at
763 working on instantiated hypothesis.
765 .. why3:transform:: inst_rem
767 Apply :why3:transform:`instantiate` then remove the original
768 instantiated hypothesis.
770 .. why3:transform:: introduce_premises
772 Move antecedents of implications and universal quantifications of
773 the goal into the premises of the task.
775 .. why3:transform:: intros
777 Introduce universal quantifiers in the context.
779 For example, applying ``intros n, m`` on the following goal
781 .. code-block:: whyml
783 predicate p int int int
784 goal G : forall x:int, y:int, z:int. p x y z
786 produces the following goal:
788 .. code-block:: whyml
790 predicate p int int int
793 goal G : forall z:int. p n m z
795 .. why3:transform:: intros_n
797 Same as :why3:transform:`intros`, but stops after the nth quantified
800 For example, applying ``intros_n 2`` on the following goal
802 .. code-block:: whyml
804 predicate p int int int
805 goal G : forall x:int, y:int, z:int. p x y z
807 produces the following goal:
809 .. code-block:: whyml
811 predicate p int int int
814 goal G : forall z:int. p x y z
816 .. why3:transform:: inversion_arg_pr
818 Apply :why3:transform:`inversion_pr` on the given hypothesis/goal symbol.
820 .. why3:transform:: inversion_pr
822 .. why3:transform:: left
824 Remove the right part of the head disjunction of the goal.
826 For example, applying ``left`` on the following goal
828 .. code-block:: whyml
831 goal G : x = 0 \/ x = 1
833 produces the following goal:
835 .. code-block:: whyml
840 .. why3:transform:: pose
842 Add a new constant equal to the given term.
844 For example, applying ``pose t (x + 2)`` to the following goal
846 .. code-block:: whyml
851 produces the following goal:
853 .. code-block:: whyml
857 axiom H : t = (x + 2)
860 .. why3:transform:: remove
862 Remove a hypothesis from the context.
864 For example, applying ``remove h`` on the following goal
866 .. code-block:: whyml
871 produces the following goal:
873 .. code-block:: whyml
877 .. why3:transform:: remove_unused
879 Remove from the context all the logic symbols that are not used by the goal or the hypothesis.
881 The effect of that transformation can be expanded by adding dependency metas. Namely, with a declaration of the form
883 .. code-block:: whyml
885 meta "remove_unused:dependency" axiom a, function f
887 then occurrences of `f` in axiom `a` are not counted as occurrences
888 for `f`. The intended meaning is that `a` is a definitional axiom
889 for `f`, so when `f` is not needed in the remainder, both the axiom
890 and the declaration of `f` can be removed.
892 When there are several such definitional axioms for `f`, a meta
893 must be declared for each axiom. When an axiom is definitional for
894 several symbols at the same time, several meta must be declared as
895 well. The rule of thumb is that an axiom is kept as soon as at
896 least one of the symbols it defines is needed in the remainder,
897 otherwise it is discarded.
899 .. why3:transform:: remove_unused_keep_constant
901 A variant of :why3:transform:`remove_unused` above, where the constant, i.e. the nullary function symbols, are always kept.
903 The effect of that transformation is controllable with an additional meta of the form
905 .. code-block:: whyml
907 meta "remove_unused:remove_constant" constant f
909 when in that case `f` is also tried to be removed, as if it was
910 with the full :why3:transform:`remove_unused` transformation.
912 .. why3:transform:: replace
914 Replace a term with another one in a hypothesis or in the goal. This
915 generates a new goal which asks for the proof of the equality.
917 For example, applying ``replace (y + 1) (x + 2) in h`` on the
920 .. code-block:: whyml
924 axiom h : x >= (y + 1)
927 produces the following two goals:
929 .. code-block:: whyml
933 axiom h : x >= (x + 2)
936 .. code-block:: whyml
940 axiom h : x >= (y + 1)
941 goal G : (y + 1) = (x + 2)
943 It can be seen as the combination of :why3:transform:`assert`
944 and :why3:transform:`rewrite`.
946 .. why3:transform:: revert
948 Opposite of :why3:transform:`intros`. It takes hypotheses/constants
949 and quantifies them in the goal.
951 For example, applying ``revert x`` on the following goal
953 .. code-block:: whyml
960 produces the following goal:
962 .. code-block:: whyml
965 goal G : forall x:int. x = y -> true
967 .. why3:transform:: rewrite
969 Rewrite using the given equality hypothesis.
971 For example, applying ``rewrite eq`` on the following goal
973 .. code-block:: whyml
975 function a int : bool
976 function b int : bool
978 axiom eq : forall x:int. not x = 0 -> a x = b x
981 produces the following goal:
983 .. code-block:: whyml
985 function a int : bool
986 function b int : bool
988 axiom eq : forall x:int. not x = 0 -> a x = b x
991 It also produces a goal for the premise of the equality hypothesis (as
992 would :why3:transform:`apply`):
994 .. code-block:: whyml
996 function a int : bool
997 function b int : bool
999 axiom eq : forall x:int. not x = 0 -> a x = b x
1002 .. why3:transform:: rewrite with
1004 Variant of :why3:transform:`rewrite` intended to be used in contexts
1005 where the latter cannot infer what terms to use for the variables of
1006 the given hypotheses (see also :why3:transform:`apply with`).
1008 For example, the transformation ``rewrite eq with 0`` can be applied
1009 to the following goal:
1011 .. code-block:: whyml
1013 function a int : bool
1014 function b int : bool
1016 axiom eq : forall x:int, z:int. z = 0 -> not x = 0 -> a x = b x
1019 Here, a value is provided for the symbol ``z``. This leads to the
1020 following three goals. One is the rewritten one, while the other two
1021 are for the premises of the equality hypothesis.
1023 .. code-block:: whyml
1025 function a int : bool
1026 function b int : bool
1028 axiom eq : forall x:int, z:int. z = 0 -> not x = 0 -> a x = b x
1031 .. code-block:: whyml
1033 function a int : bool
1034 function b int : bool
1036 axiom eq : forall x:int, z:int. z = 0 -> not x = 0 -> a x = b x
1039 .. code-block:: whyml
1041 function a int : bool
1042 function b int : bool
1044 axiom eq : forall x:int, z:int. z = 0 -> not x = 0 -> a x = b x
1047 .. why3:transform:: rewrite_list
1049 Variant of :why3:transform:`rewrite` that allows simultaneous rewriting in
1050 a list of hypothesis/goals.
1052 .. why3:transform:: right
1054 Remove the left part of the head disjunction of the goal.
1056 For example, applying ``right`` on the following goal
1058 .. code-block:: whyml
1061 goal G : x = 0 \/ x = 1
1063 produces the following goal:
1065 .. code-block:: whyml
1070 .. why3:transform:: simplify_array
1072 Automatically rewrite the task using the lemma ``Select_eq`` of
1075 .. why3:transform:: simplify_formula
1077 Reduce trivial equalities ``t=t`` to true and then simplify
1078 propositional structure: removes ``true``, ``false``, simplifies
1079 ``f /\ f`` to ``f``, etc.
1081 .. why3:transform:: simplify_formula_and_task
1083 Apply :why3:transform:`simplify_formula` and remove the goal if
1084 it is equivalent to true.
1086 .. why3:transform:: simplify_recursive_definition
1088 Reduce mutually recursive definitions if they are not really
1089 mutually recursive, e.g.,
1093 function f : ... = ... g ...
1100 function g : ... = e
1101 function f : ... = ... g ...
1103 if ``f`` does not occur in ``e``.
1105 .. why3:transform:: simplify_trivial_quantification
1107 Simplify quantifications of the form
1111 forall x, x = t -> P(x)
1119 when ``x`` does not occur in ``t``. More generally, this
1120 simplification is applied whenever ``x=t`` or ``t=x``
1121 appears in negative position.
1123 .. why3:transform:: simplify_trivial_quantification_in_goal
1125 Apply :why3:transform:`simplify_trivial_quantification`, but only in the goal.
1127 .. why3:transform:: split_all
1129 Perform both :why3:transform:`split_premise` and :why3:transform:`split_goal`.
1131 .. why3:transform:: split_all_full
1133 Perform both :why3:transform:`split_premise` and :why3:transform:`split_goal_full`.
1135 .. why3:transform:: split_goal
1137 Change conjunctive goals into the corresponding set of subgoals. In
1138 absence of case analysis attributes, the number of subgoals
1139 generated is linear in the size of the initial goal.
1141 The transformation treats specially asymmetric and ``by``/``so``
1142 connectives. Asymmetric conjunction ``A && B`` in goal position is
1143 handled as syntactic sugar for ``A /\ (A -> B)``. The conclusion of
1144 the first subgoal can then be used to prove the second one.
1146 Asymmetric disjunction ``A || B`` in hypothesis position is handled
1147 as syntactic sugar for ``A \/ ((not A) /\ B)``. In particular, a
1148 case analysis on such hypothesis would give the negation of the
1149 first hypothesis in the second case.
1151 The ``by`` connective is treated as a proof indication. In
1152 hypothesis position, ``A by B`` is treated as if it were syntactic
1153 sugar for its regular interpretation ``A``. In goal position, it is
1154 treated as if ``B`` was an intermediate step for proving ``A``.
1155 ``A by B`` is then replaced by ``B`` and the transformation also
1156 generates a side-condition subgoal ``B -> A`` representing the
1159 Although splitting stops at disjunctive points like symmetric
1160 disjunction and left-hand sides of implications, the occurrences of
1161 the ``by`` connective are not restricted. For instance:
1167 goal G : (A by B) && C
1169 generates the subgoals
1175 goal G3 : B -> A (* side-condition *)
1181 goal G : (A by B) \/ (C by D)
1188 goal G2 : B -> A (* side-condition *)
1189 goal G3 : D -> C (* side-condition *)
1195 goal G : (A by B) || (C by D)
1202 goal G2 : B -> A (* side-condition *)
1203 goal G3 : B || (D -> C) (* side-condition *)
1205 Note that due to the asymmetric disjunction, the disjunction is
1206 kept in the second side-condition subgoal.
1212 goal G : exists x. P x by x = 42
1218 goal G1 : exists x. x = 42
1219 goal G2 : forall x. x = 42 -> P x (* side-condition *)
1221 Note that in the side-condition subgoal, the context is
1224 The ``so`` connective plays a similar role in hypothesis position,
1225 as it serves as a consequence indication. In goal position,
1226 ``A so B`` is treated as if it were syntactic sugar for its regular
1227 interpretation ``A``. In hypothesis position, it is treated as if
1228 both ``A`` and ``B`` were true because ``B`` is a consequence of
1229 ``A``. ``A so B`` is replaced by ``A /\ B`` and the transformation
1230 also generates a side-condition subgoal ``A -> B`` corresponding to
1231 the consequence relation between formula.
1233 As with the ``by`` connective, occurrences of ``so`` are
1234 unrestricted. Examples:
1240 goal G : (((A so B) \/ C) -> D) && E
1246 goal G1 : ((A /\ B) \/ C) -> D
1247 goal G2 : (A \/ C -> D) -> E
1248 goal G3 : A -> B (* side-condition *)
1254 goal G : A by exists x. P x so Q x so R x by T x
1255 (* reads: A by (exists x. P x so (Q x so (R x by T x))) *)
1261 goal G1 : exists x. P x
1262 goal G2 : forall x. P x -> Q x (* side-condition *)
1263 goal G3 : forall x. P x -> Q x -> T x (* side-condition *)
1264 goal G4 : forall x. P x -> Q x -> T x -> R x (* side-condition *)
1265 goal G5 : (exists x. P x /\ Q x /\ R x) -> A (* side-condition *)
1267 In natural language, this corresponds to the following proof
1268 scheme for ``A``: There exists a ``x`` for which ``P`` holds.
1269 Then, for that witness ``Q`` and ``R`` also holds. The last one
1270 holds because ``T`` holds as well. And from those three
1271 conditions on ``x``, we can deduce ``A``.
1273 The transformations in the “split” family can be controlled by using
1274 attributes on formulas.
1276 The :why3:attribute:`[@stop_split]` attribute can be used to block the splitting
1277 of a formula. The attribute is removed after blocking, so applying
1278 the transformation a second time will split the formula. This is can
1279 be used to decompose the splitting process in several steps. Also,
1280 if a formula with this attribute is found in non-goal position, its
1281 ``by``/``so`` proof indication will be erased by the transformation.
1282 In a sense, formulas tagged by :why3:attribute:`[@stop_split]` are handled as if
1283 they were local lemmas.
1285 The :why3:attribute:`[@case_split]` attribute can be used to force case analysis
1286 on hypotheses. For instance, applying :why3:transform:`split_goal` on
1290 goal G : ([@case_split] A \/ B) -> C
1292 generates the subgoals
1299 Without the attribute, the transformation does nothing because
1300 undesired case analysis may easily lead to an exponential blow-up.
1302 Note that the precise behavior of splitting transformations in
1303 presence of the :why3:attribute:`[@case_split]` attribute is not yet specified and
1304 is likely to change in future versions.
1306 .. why3:transform:: split_goal_full
1308 Behave similarly to :why3:transform:`split_goal`, but also convert the goal
1309 to conjunctive normal form. The number of subgoals generated may be
1310 exponential in the size of the initial goal.
1312 .. why3:transform:: split_intro
1314 Perform both :why3:transform:`split_goal` and :why3:transform:`introduce_premises`.
1316 .. why3:transform:: split_premise
1318 Replace axioms in conjunctive form by an equivalent collection of
1319 axioms. In absence of case analysis attributes (see :why3:transform:`split_goal`
1320 for details), the number of axiom generated per initial axiom is
1321 linear in the size of that initial axiom.
1323 .. why3:transform:: split_premise_full
1325 Behave similarly to :why3:transform:`split_premise`, but also convert the axioms to
1326 conjunctive normal form. The number of axioms generated per initial
1327 axiom may be exponential in the size of the initial axiom.
1329 .. why3:transform:: subst
1331 Substitute a given constant using an equality found in the context.
1332 The constant is removed.
1334 For example, when applying ``subst x`` on the following goal
1336 .. code-block:: whyml
1342 axiom h1 : z = (x + y)
1345 the transformation first finds the hypothesis ``h`` that can be used to
1346 rewrite ``x``. Then, it replaces every occurrences of ``x`` with ``y + 1``.
1347 Finally, it removes ``h`` and ``x``. The resulting goal is as follows:
1349 .. code-block:: whyml
1353 axiom h1 : z = ((y + 1) + y)
1354 goal G : (y + 1) = z
1356 This transformation is used to make the task more easily readable by
1357 a human during debugging. This transformation should not help
1358 automatic provers at all as they generally implement substitution
1359 rules in their logic.
1361 .. why3:transform:: subst_all
1363 Substitute all the variables that can be substituted.
1365 For example, applying ``subst_all`` on the following goal
1367 .. code-block:: whyml
1373 axiom h : x = (y + 1)
1375 axiom h1 : z = (x + y)
1378 produces the following goal, where ``x``, ``x1``, and ``z`` have been
1381 .. code-block:: whyml
1384 goal G : (y + 1) = ((y + 1) + y)
1386 The order in which constants are substituted is not specified.
1388 .. why3:transform:: unfold
1390 Unfold the definition of a logical symbol in the given hypothesis.
1392 For example, applying ``unfold p`` on the following goal
1394 .. code-block:: whyml
1396 predicate p (x:int) = x <= 22
1397 axiom h : forall x:int. p x -> p (x - 1)
1400 produces the following goal:
1402 .. code-block:: whyml
1404 predicate p (x:int) = x <= 22
1405 axiom h : forall x:int. p x -> p (x - 1)
1408 One can also unfold in the hypothesis, using ``unfold p in h``, which
1409 gives the following goal:
1411 .. code-block:: whyml
1413 predicate p (x:int) = x <= 22
1414 axiom h : forall x:int. x <= 22 -> (x - 1) <= 22
1417 .. why3:transform:: use_th
1419 Import a theory inside the current context. This is used, in some rare
1420 case, to reduced the size of the context in other goals, since
1421 importing a theory in the WhyML code would the theory available in all
1422 goals whereas the theory is only needed in one specific goal.
1424 For example, applying ``use_th int.Int`` on the following goal
1426 .. code-block:: whyml
1431 imports the ``Int`` theory. So, one is able to use the addition over
1432 integers, e.g., ``replace 5 (2 + 3)``.
1434 Any lemma appearing in the imported theory can also be used.
1436 Note that axioms are also imported. So, this transformation should be
1437 used with care. We recommend to use only theories that do not contain
1438 any axiom because this transformation could easily make the context
1446 In the context of Why3, proof strategies are mechanisms that automate
1447 the application of transformations and provers on proof tasks. These
1448 strategies are mainly meant to be invoked in the IDE.
1450 Strategies come into two flavours: first the so-called basic
1451 strategies, and second a more complex mechanism allowing one to
1452 program strategies in OCaml. Such strategies are supposed to be
1453 programmed on top of the module `Strategy` of the Why3 API. Such
1454 strategies can also by called goal-oriented, since programming them in
1455 OCaml provides a way to inspect the formulas in the goal or hypothesis of the task, and apply
1456 transformations depending on their shapes.
1458 Below we document one of such strategy: a strategy for error
1459 propagation in floating-point computations.
1464 As seen in :numref:`sec.ideref`, the IDE provides a few buttons that
1465 trigger the run of basic proof strategies on the selected goals. Such proof
1466 strategies can be defined using a basic assembly-style language, and put
1467 into the Why3 configuration file. The commands of this basic language
1470 - :samp:`c {p} {t} {m}` calls the prover *p* with a time limit *t*
1471 and memory limit *m*. On success, the strategy ends, it
1472 continues to next line otherwise.
1474 - :samp:`c {p1} {t1} {m1} | ... | {pk} {tk} {mk}` calls the provers *p1* to *pk* in parallel.
1475 On success on one prover, the other provers are interrupted, and the strategy ends. It
1476 continues to next line if none of the provers succeed.
1478 - :samp:`t {n} {lab}` applies the transformation *n*. On success, the
1479 strategy continues to label *lab*, and is applied to each
1480 generated sub-goals. It continues to next line otherwise.
1482 - :samp:`g {lab}` unconditionally jumps to label *lab*.
1484 - :samp:`{lab}:` declares the label *lab*. The default label ``exit``
1487 To exemplify this basic programming language, we give below the default
1488 strategies that are attached to the default buttons of the IDE, assuming
1489 that the provers Alt-Ergo 2.3.0, CVC4 1.7, and Z3 4.8.4 have been detected by
1490 the :why3:tool:`why3 config` command.
1493 is bound to the 1-line strategy
1505 c Alt-Ergo,2.3.0, 1 1000
1508 The three provers are tried for a time limit of 1 second and memory
1509 limit of 1 Gb, each in turn. This is a perfect strategy for a first
1510 attempt to discharge a new goal.
1517 c Z3,4.8.4, 5 1000 | Alt-Ergo,2.3.0, 5 1000 | CVC4,1.7, 5 1000
1519 Same as Auto_level_0 but with 5 seconds instead of 1, and in parallel.
1528 c Alt-Ergo,2.3.0, 1 1000
1531 c Z3,4.8.4, 10 4000 | Alt-Ergo,2.3.0, 10 4000 | CVC4,1.7, 10 4000
1533 The three provers are first tried for a time limit of 1 second and
1534 memory limit of 1 Gb, each in turn. If none of them succeed, a split
1535 is attempted. If the split works then the same strategy is retried
1536 on each sub-goals. If the split does not succeed, the provers are
1537 tried again with larger limits, and in parallel.
1546 c Eprover,2.0, 1 1000
1548 c Alt-Ergo,2.3.0, 1 1000
1551 c Z3,4.8.4, 5 2000 | Eprover,2.0, 5 2000 | Spass,3.7, 5 2000 | Alt-Ergo,2.3.0, 5 2000 | CVC4,1.7, 5 2000
1552 t introduce_premises afterintro
1554 t inline_goal afterinline
1557 t split_all_full start
1559 c Z3,4.8.4, 30 4000 | Eprover,2.0, 30 4000 | Spass,3.7, 30 4000 | Alt-Ergo,2.3.0, 30 4000 | CVC4,1.7, 30 4000
1561 Notice that now 5 provers are used. The provers are first tried
1562 for a time limit of 1 second and memory limit of 1 Gb, each in
1563 turn. If none of them succeed, a split is attempted. If the split
1564 works then the same strategy is retried on each sub-goals. If the
1565 split does not succeed, the prover are tried again with limits of
1566 5 s and 2 Gb, and in parallel. If all fail, we attempt the
1567 transformation of introduction of premises in the context,
1568 followed by an inlining of the definitions in the goals. We then
1569 attempt a split again. If the split succeeds, we restart from the
1570 beginning. Otherwise, provers are tried again, in parallel, with 30s and 4
1573 Forward propagation in floating-point computations
1574 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1576 The specialized strategy ``forward_propagation`` can be used for
1577 automatically computing and proving a rounding error on a term of type
1578 ``ufloat`` which is the type of unbounded floats as defined in the
1579 theory `ufloat` of the standard library. More background on
1580 forward error propagation will be available soon in an incoming research report.
1582 The only transformations used are :
1584 - ``assert``, to assert the existence of a forward error.
1585 - ``apply``, to apply one of the forward propagation lemmas.
1587 The strategy uses the following process:
1589 1. Look at the form of the goal. If the goal has the form
1590 ``abs (to_real x -. exact_x) <=. C``, it goes to step 2, else it does nothing.
1591 2. Look at term ``x``. There are 2 cases :
1593 * 2.1. : ``x`` is either the result of a supported ufloat operation
1594 (e.g. addition, multiplication) on some arguments or
1595 the result of the application of an approximation of a supported
1596 function (e.g. exponential) to some arguments. Then the strategy
1597 applies recursively step 2 for each argument of the ufloat
1598 operation/function approximation to compute their forward
1599 error. For each forward error computed, the strategy also
1600 generates a proof tree containing the steps to prove it. If at
1601 least one forward error is computed, then the propagation lemma
1602 corresponding to the ufloat operation/approximated function is
1603 used to compute the forward error for ``x`` and ``exact_x``, and a corresponding
1604 proof tree is generated. The root of the proof tree consists of an
1605 assertion of the forward error computed for ``x``, and the child
1606 node will generally be the application of the transformation
1607 ``apply`` with the propagation lemma as an argument. The
1608 propagation lemma contains hypotheses about forward errors for the
1609 arguments, therefore the proof trees computed for them recursively
1610 are attached as nodes to the corresponding nodes of the tree.
1612 * 2.2. : ``x`` is something else. Then no forward error is computed
1613 and no proof tree is generated.
1615 Currently, propagation lemmas exist for the following functions :
1617 * ufloat addition, subtraction, multiplication and negation.
1618 * ufloat approximations of ``log`` and ``exp`` functions.
1619 * ufloat approximations of the iterated sum function (defined in stdlib module ``real.Sum``).
1622 The following excerpt is an example of a program that can be proved using the strategy :
1630 let ghost addition_errors_basic (a b c : usingle)
1632 let exact = to_real a +. to_real b +. to_real c in
1633 let exact_abs = abs (to_real a) +. abs (to_real b) +. abs (to_real c) in
1634 abs (to_real result -. exact) <=. 2. *. eps *. exact_abs
1638 To use the strategy within Why3 IDE in order to prove the program, one
1639 must perform the following steps :
1641 1. Apply the ``split_vc`` transformation to generate the subgoals.
1642 2. Select the proof node of the postcondition and apply the
1643 ``forward_propagation`` strategy, either by typing the name of the
1644 strategy in the command line or by right clicking on the proof node
1645 and selecting the strategy.
1646 3. The strategy will generate a proof tree. The nodes of the tree
1647 should be easily proved using one of the ``auto`` strategies.
1649 Note that the ``forward_propagation`` strategy can also be used when
1650 the user has no specific forward error in mind as a way to propose a
1651 provable bound. For instance in the example above, one could have
1652 replaced the term ``2. *. eps *. exact_abs`` by anything in the
1653 postcondition. The strategy would still have worked and it would have
1654 generated an assertion about a forward error that it can prove. One
1655 could then use this forward error in the postcondition.
1657 For more examples of the use of the strategy, see the directory
1658 ``examples/numeric`` of the examples repository.
1666 .. why3:attribute:: case_split
1668 .. why3:attribute:: cfg:stackify
1670 .. why3:attribute:: cfg:subregion_analysis
1672 .. why3:attribute:: extraction:inline
1674 If the name of a function is labeled with this attribute, its body
1675 will be inlined at every call site during extraction (see
1676 :numref:`sec.extract`). This is especially useful for trivial
1677 wrapper functions whose only purpose is to provide a slightly
1678 different specification from the original function.
1680 .. why3:attribute:: extraction:likely
1682 This attribute can be applied to a Boolean expression to indicate
1683 whether it is likely to be true. This is used at extraction time
1684 (see :numref:`sec.extract`), assuming the target language supports
1685 it. For example, when extracting to C, the extracted expression
1686 will be tagged with ``__builtin_expect``.
1688 .. why3:attribute:: extraction:unlikely
1690 This attribute can be applied to a Boolean expression to indicate
1691 whether it is likely to be false. This is the opposite of
1692 :why3:attribute:`extraction:likely`.
1694 .. why3:attribute:: extraction:preserve_single_field
1696 This attribute is applied to the declaration of a record type. It is used to
1697 disable an optimization made by the preprocessing step that precedes the
1698 invocation of extraction drivers. During this step, record types with a
1701 .. code-block:: whyml
1703 type t = { a : int }
1707 .. code-block:: whyml
1711 If this attribute is applied to ``t``, then this optimization is disabled.
1713 .. why3:attribute:: induction
1715 .. why3:attribute:: infer
1717 .. why3:attribute:: inline:trivial
1719 .. why3:attribute:: java:class_kind:
1721 This attribute annotates a module. Three suffixes are allowed:
1722 :code:`abstract`, :code:`interface` and :code:`class`. This three attributes
1723 specify what kind of class the Java driver has to generate for the module,
1724 either a regular or an abstract class or an interface.
1726 .. why3:attribute:: java:constructor
1728 This attribute is used to mark functions
1730 .. why3:attribute:: java:exception:
1732 If a module is annotated with the attribute
1733 :why3:attribute:`java:exception:` *exn-class*, the Java driver translates it
1734 into a Java exception class. The `exn-class` part of the attribute indicates
1735 the parent class from which the generated class inherits. Actually `exn-class`
1736 is printed out `as-is` after the `extends` specifier of the generated class.
1738 .. why3:attribute:: java:implements:
1740 This attribute is applied to a module. Its suffix is a coma-separated list of
1741 identifiers of Java interfaces. From the driver point of view, the specified
1742 interfaces are just strings of characters and are printed out `as-is` in the
1743 generated Java code. The driver does not check if theses interfaces are
1744 actually implemented by the module; this verification is left to the Java
1747 .. why3:attribute:: java:package:
1749 If the attribute :why3:attribute:`java:package:` *some.package* annotates a module,
1750 the Java driver creates the expected class in the package *some.package*. In
1751 addition to the Java instruction :code:`package`, the driver follows the usual
1752 convention by creating the :code:`.java` file in the directory
1753 :file:`some/package/`. The directory of the package is created
1754 relatively to the output directory specified with the option :code:`-o` (see
1755 :ref:`sec.why3extract`).
1757 .. why3:attribute:: java:visibility:public
1759 .. why3:attribute:: java:visibility:package
1761 .. why3:attribute:: java:visibility:private
1763 By default, in the code generated by the Java driver, classes, instance
1764 variables and methods are declared :code:`public`. The driver allows three
1765 attributes to change this default visibility: :code:`public`,
1766 :code:`private` and :code:`package`. Note that
1767 visibility attributes **are not checked** by the driver.
1769 If :why3:attribute:`java:visibility:private` is used to annotate a module, the
1770 generated class is declared :code:`private`. Even if it is syntactically
1771 allowed, the specification of Java language does not allow private specifier
1772 for top-level classes.
1774 By default, functions and types inherit the visibility attribute of the
1775 module. For instance if a module is declared with
1776 :why3:attribute:`java:visibility:package` then all functions, instance
1777 variables and *Enum*-types will be declared with :code:`package` visibility.
1778 Each element of the module can be annotated with a different visibility
1779 attribute that replaces the default one.
1781 Instance variables actually inherits the visibility attribute of the type that
1782 defines them. Yet, each instance variable may have its own visibility
1786 .. why3:attribute:: model_trace
1788 .. why3:attribute:: rewrite
1790 .. why3:attribute:: stop_split
1792 .. why3:attribute:: vc:annotation
1794 This attribute is added by the VC generator, on the user input
1795 formulas which become goals to prove in the resulting VC. It should
1796 not be added manually.
1798 .. why3:attribute:: vc:divergent
1800 This attribute indicates whether VCs for termination should be
1801 generated. See :numref:`sec.terminationvc` for details.
1803 .. why3:attribute:: vc:keep_precondition
1805 This attribute indicates whether preconditions of calls should be kept
1806 as assumptions for the program after the call. See
1807 :numref:`sec.keeppreconditions` for details.
1810 .. why3:attribute:: vc:sp
1812 This attribute, put on a WhyML expression, locally switches the VC
1813 generator to the SP mode, for that expression. See
1814 :numref:`sec.strongestpostconditions` for details.
1816 .. why3:attribute:: vc:white_box
1818 This attribute is added by the Why3 parser for contract attached to
1819 an expression in WhyML code. Such a contract is indeed encoded by a
1820 local function with this attribute. It is for internal use only
1821 and should never be added manually.
1823 .. why3:attribute:: vc:wp
1825 This attribute, put on a WhyML expression, locally switches the VC
1826 generator to the WP mode, for that expression. See
1827 :numref:`sec.strongestpostconditions` for details.
1835 .. why3:meta:: compute_max_steps
1837 .. why3:meta:: keep:literal
1839 .. why3:meta:: realized_theory
1841 .. why3:meta:: rewrite
1843 .. why3:meta:: rewrite_def
1845 .. why3:meta:: vc:proved_wf
1847 Declare a hypothesis as a proof of well-foundedness of a binary
1848 relation. See :numref:`sec.custom_wf`.
1855 The list of debug flags can be obtained using
1856 :file:`why3 --list-debug-flags`. The following excerpt is the
1857 list of flags mentioned in this manual.
1859 .. why3:debug:: infer:loop
1861 .. why3:debug:: infer:print_ai_result
1863 .. why3:debug:: infer:print_cfg
1865 .. why3:debug:: print:inferred_invs
1867 .. why3:debug:: print:domains_loop
1869 .. why3:debug:: stack_trace
1872 Structure of Session Files
1873 --------------------------
1875 The proof session state is stored in an XML file named
1876 :file:`{dir}/why3session.xml`, where *dir* is the directory of the
1877 project. The XML file follows the DTD given in :file:`share/why3session.dtd`
1878 and reproduced below.
1880 .. literalinclude:: ../share/why3session.dtd
1886 Structure of Counterexamples
1887 ----------------------------
1889 Generated counterexamples can be exported in JSON format.
1890 The JSON output follows the JSON Schema given in :file:`share/ce-models.json`
1891 and reproduced below.
1893 .. literalinclude:: ../share/ce-models.json
1897 Developer Documentation
1898 -----------------------
1900 Updating messages for syntax errors
1901 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1903 Here is the developer's recipe to update a syntax error message. We do
1904 it on the following illustrative example.
1906 .. code-block:: whyml
1908 function let int : int
1910 If such a file is passed to Why3, one obtains:
1914 File "bench/parsing/bad/498_function.mlw", line 1, characters 9-12:
1917 The recipe given here provides a way to produce a more informative
1918 message. It is based on handcrafted error messages provided by the
1919 `Menhir <http://gallium.inria.fr/~fpottier/menhir/>`_ parser generator.
1921 The first step is to call :program:`menhir` with option ``--interpret-error``
1922 while giving as input the erroneous input, under the form of a sequence
1923 of tokens as generated by :file:`src/parser/lexer.mll`.
1925 .. code-block:: console
1927 $ echo "decl_eof: FUNCTION LET" | menhir --base src/parser/parser --interpret-error src/parser/parser_common.mly src/parser/parser.mly
1928 decl_eof: FUNCTION LET
1930 ## Ends in an error in state: 1113.
1932 ## pure_decl -> FUNCTION . function_decl list(with_logic_decl) [ VAL USE TYPE THEORY SCOPE PREDICATE MODULE META LET LEMMA INDUCTIVE IMPORT GOAL FUNCTION EXCEPTION EOF END CONSTANT COINDUCTIVE CLONE AXIOM ]
1934 ## The known suffix of the stack is as follows:
1938 <YOUR SYNTAX ERROR MESSAGE HERE>
1940 The text returned by that command should be appended to
1941 :file:`src/parser/handcrafted.messages`, with of course an appropriate error
1942 message, such as this one:
1946 expected function name must be a non-reserved uncapitalized identifier (token LIDENT_NQ), found "$0"