@@ -100,12 +100,12 @@ As a consequence, ``A != B`` has a very different meaning to the :ref:`negation
100
100
- ``1 = [1 .. 2] `` holds, because ``1 = 1 ``.
101
101
- ``not 1 = [1 .. 2] `` doesn't hold, because there is a common value (``1 ``).
102
102
103
- #. Compare ``1 `` and ``none() `` (the " empty set" ):
104
- - ``1 != none () `` doesn't hold, because there are no values in ``none () ``, so no values
103
+ #. Compare ``1 `` and ``int empty() { none() } `` (a predicate defining the empty set of integers ):
104
+ - ``1 != empty () `` doesn't hold, because there are no values in ``empty () ``, so no values
105
105
that are not equal to ``1 ``.
106
- - ``1 = none () `` also doesn't hold, because there are no values in ``none () ``, so no values
106
+ - ``1 = empty () `` also doesn't hold, because there are no values in ``empty () ``, so no values
107
107
that are equal to ``1 ``.
108
- - ``not 1 = none () `` holds, because there are no common values.
108
+ - ``not 1 = empty () `` holds, because there are no common values.
109
109
110
110
.. index :: instanceof
111
111
.. _type-checks :
@@ -295,9 +295,48 @@ necessary, since they highlight the default precedence. You usually only add par
295
295
override the default precedence, but you can also add them to make your code easier to read
296
296
(even if they aren't required).
297
297
298
+ QL also has two nullary connectives indicating the always true formula,
299
+ ``any() ``, and the always false formula, ``none() ``.
300
+
298
301
The logical connectives in QL work similarly to Boolean connectives in other programming
299
302
languages. Here is a brief overview:
300
303
304
+ .. index :: any, true
305
+ .. _true :
306
+
307
+ ``any() ``
308
+ =========
309
+
310
+ The built-in predicate ``any() `` is a formula that always holds.
311
+
312
+ **Example **
313
+
314
+ The following predicate defines the set of all expressions.
315
+
316
+ .. code-block :: ql
317
+
318
+ Expr allExpressions() {
319
+ any()
320
+ }
321
+
322
+ .. index :: none, false
323
+ .. _false :
324
+
325
+ ``none() ``
326
+ ==========
327
+
328
+ The built-in predicate ``none() `` is a formula that never holds.
329
+
330
+ **Example **
331
+
332
+ The following predicate defines the empty set of integers.
333
+
334
+ .. code-block :: ql
335
+
336
+ int emptySet() {
337
+ none()
338
+ }
339
+
301
340
.. index :: not, negation
302
341
.. _negation :
303
342
0 commit comments