This document is a description of promise ex declarations,
which are currently unfinished and as such are undocumented
in the reference manual.
Syntax
There are currently three promise ex declarations: promise_exclusive,
promise_exhaustive, and promise_exclusive_exhaustive. They are used to
denote determinism properties of a disjunction, and denote either exclusivity
exhaustiveness or both. The examples of each, given below, also show
the different ways that existential quantification can be handled.
Mutual exclusivity:
:- all [X, Y] promise_exclusive
some [Z] (
p(X, Y, Z)
;
q(X, Y, Z)
).
:- all [X] promise_exclusive_exhaustive
some [Y] (
p(X, Y)
;
q(X, Y, Z)
).
All three declarations are restricted in the following ways:
Any variable that occurs in more than one disjunct must be
explicitly quantified.
Any variable occuring in only one disjunct is existentially quantified.
This is similarly applicable when an underscore is used in place of a
variable.
Development
This tracks the use of promise ex declarations through the compiler, and
may be useful as a quick summary of the current state of development. Items
marked with an asterisk (*) are not yet implemented. Places where data
structures etc. have been defined are in italics.
the declarations enter the parse tree
the operators are defined (library/ops.m)
the structure for promise ex declarations in the parse tree
is defined (prog_data.m)
they are parsed and entered into the parse tree (prog_io.m)
they may be pretty printed (mercury_to_mercury.m, prog_out.m).
they are error checked, and entered in to the HLDS as
dummy predicates
error checking (make_hlds.m)
entering of declarations into the HLDS as dummy predicates
(make_hlds.m)
go through typechecking as predicates; after typechecking they
are removed from processing as predicates and entered into the
appropriate table in the HLDS
post typechecking processing initiated for promise ex
declarations (purity.m)
promise_exlusive and promise_exhaustive declarations are
indexed by the predicate calls made in them in the exclusive
table (post_typecheck.m)
definition of exclusive table as part of HLDS, and
operations on the table
(hlds_module.m)
(*) where a promise_exhaustive declaration is paired with a
promise_exclusive declaration, they are merged into a
promise_exclusive_exhaustive declaration; otherwise the
promise_exhaustive declartion is entered in the exhaustive
table of the HLDS (post_typecheck.m)
(*) definition of exhaustive table as part of HLDS, and
operations on the table
(hlds_module.m)
(*) exclusivity information is used during switch detection, and
where it leads to a full switch being made, applicable exhaustiveness
information is also used (switch_detection.m)
(*) exhaustiveness information is used during determinism analysis
(det_analysis.m) or as an add-on to switch detection
(switch_detection.m)