Pragmas

REREAD THIS SECTION

A number of pragmas below are termed feature pragmas as they are boolean gates that enable or disable specific language featues. Use of syntax associated with a disabled language feature MAY result in errors.

A conformant DATALOG-TEXT processor in strict mode MUST signal an error, otherwise the processor MAY assume the feature is enabled due to its usage. A conformant DATALOG-TEXT processor MUST signal an error when detecting a feature identifier which they do not recognize, even if it may be valid in some other version of this specification.

As feature pragmas are boolean parameters, the following two pragmas are equivalent

.pragma negation.
.pragma negation=true.

This also implies you can force a feature to be disabled in the following manner.

.pragma negation=false.

Duplicate features listed in the same processing instruction, or multiple processing instructions MUST NOT be treated as an error, they are simply combined and de-duplicated as a set. A DATALOG-TEXT processor MAY signal a WARN_DUPLICATE warning on detection of duplicate values.

Pragma base

If the base pragma is not specified then any references in the subject resource are relative to the resource location if known by the parser, or relative to the process performing the parsing.

Any use of the base pragma MUST include a constant string value that can be interpreted as a valid absolute URI (section 4.3 “Absolute URI” in RFC3986).

Default Value: "", see § URI References.

Errors

Examples

In the following example the base IRI is implicit and is determined by the resolver to dereference the relative value “data/humans.csv”.

.assert human(string).
.input(human, "data/humans.csv", "csv").

In the following example the base IRI is explicitly declared and so the input for human is clearly “https://example.com/datalog/data/humans.csv”.

.pragma base="https://example.com/datalog/".
.assert human(string).
.input(human, "data/humans.csv", "csv").

The following are invalid.

.pragma base.
%% ==> ERR_MISSING_VALUE
.pragma base="/resources".
%% ==> ERR_INVALID_URI
3M.pragma base=true.
%% ==> ERR_INVALID_TYPE

Pragma constraints (feature)

Enable rules to omit the head and become a constraint, as describe in § Rule Body & Constraints.

Default Value: false

Errors

Pragma disjunction (feature)

Enable multiple atoms in a rule head, as describe in § Rule Head & Disjunction.

Default Value: false

Errors

Pragma extended_numerics (feature)

Enable the types float and decimal, as describe in § Numbers.

Default Value: false

Errors

Pragma functional_dependencies (feature)

Enable the fd processing instruction, as describe in § Processing Instruction fd

Default Value: false

Errors

Pragma negation (feature)

Enable negated literals within a rule, as describe in § Negation.

Default Value: false

Errors

Pragma results

Determines whether query results are displayed in DATALOG-TEXT or tabular form. The following are valid values for the results pragma. This specification does not define the default form; however, it is RECOMMENDED to use tabular form in interactive tools.

The following are valid values for the result pragma. The details of each supported results form is described in the appendix § Result Formats.

  • native – results are returned as constant values or facts; this format MUST be supported by a conforming DATALOG-TEXT processor that displays results in human-readable form.
  • tabular – results are returned in a tabular form; this format is optional but RECOMMENDED.

Default Value: undefined.

Errors

Pragma strict

This enables the strict processing mode as described in § Strict vs Lax Processing in Conformance and § Strict Processing in Processing Instructions. This pragma MUST BE supported by a conforming DATALOG-TEXT processor.

Default Value: undefined.

Errors

Examples

The following program will signal an error as it is required that all relations be explicitly declared before use when in strict processing mode.

.pragma strict.

human(socrates).
%% ==> ERR_PREDICATE_NOT_AN_EXTENSIONAL_RELATION

A similar error is signaled for intensional relations.

.pragma strict.
.assert human(string).

human(socrates).
mortal(X) :- human(X) AND NOT home(olympus).
%% ==> ERR_PREDICATE_NOT_AN_INTENSIONAL_RELATION

Finally, errors are signaled for undeclared use of features.

.pragma strict.
.assert human(string).
.assert home(string).
.infer mortal from human.

mortal(X) :- human(X) AND NOT home(olympus).
%% ==> ERR_FEATURE_NOT_ENABLED

The following is invalid.

.pragma strict="yes".
%% ==> ERR_INVALID_TYPE