1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
.TH LIBNORMALFORM_ANY 3 LIBNORMALFORM
.SH NAME
libnormalform_any \- Existential qualifier
.SH SYNOPSIS
.nf
#include <libnormalform.h>
struct libnormalform_mapping {
void *\fIkey\fP;
void *\fIvalue\fP;
};
struct libnormalform_map {
struct libnormalform_mapping *\fImappings\fP;
size_t \fInmappings\fP;
void *\fIuser_data\fP;
const char *\fIidentifier\fP;
struct libnormalform_map *\fIcopy_for_clone\fP;
};
LIBNORMALFORM_SENTENCE *
libnormalform_any(struct libnormalform_map *\fId\fP, LIBNORMALFORM_SENTENCE *\fIk\fP, LIBNORMALFORM_SENTENCE *\fIv\fP);
LIBNORMALFORM_SENTENCE *
libnormalform_exists(struct libnormalform_map *\fId\fP, LIBNORMALFORM_SENTENCE *\fIk\fP);
LIBNORMALFORM_SENTENCE *
libnormalform_nexists(struct libnormalform_map *\fId\fP, LIBNORMALFORM_SENTENCE *\fIk\fP);
LIBNORMALFORM_SENTENCE *
libnormalform_existentially(struct libnormalform_map *\fId\fP, LIBNORMALFORM_SENTENCE *\fIv\fP);
LIBNORMALFORM_SENTENCE *
libnormalform_empty(struct libnormalform_map *\fId\fP);
LIBNORMALFORM_SENTENCE *
libnormalform_nonempty(struct libnormalform_map *\fId\fP);
.fi
.PP
Link with
.IR -lnormalform .
.SH DESCRIPTION
The
.BR libnormalform_any ()
function creates a sentence that is true
when and only when the sentence
.I v
is true for the
.I .value
for at least one element in
.I d
for which
.I k
is also true for the
.I .key
of the element.
.PP
The
.BR libnormalform_exists ()
function creates a sentence that is true
when and only when the sentence
.I k
is true for the
.I .key
of at least one element in
.IR d .
.PP
The
.BR libnormalform_nexists ()
function creates a sentence that is true
when and only when the sentence
.I k
is false for the
.I .key
of every element in
.IR d .
.PP
The
.BR libnormalform_existentially ()
function creates a sentence that is true
when and only when the sentence
.I v
is true for the
.I .value
of at least one element in
.IR d .
.PP
The
.BR libnormalform_empty ()
function creates a sentence that is true
when and only when
.IR d
contains no elements.
.PP
The
.BR libnormalform_nonempty ()
function creates a sentence that is true
when and only when
.IR d
contains at least one element.
.PP
.I d->mappings
and
.I d->nmappings
is used only be the
.BR libnormalform_evaluate (3)
function and must be set before
.BR libnormalform_evaluate (3)
is called, but need not be set
earlier.
.I d->nmappings
shall be set to number of elements in
the qualifers domain of interest, and
.I d->mappings
shall be set to the list of elements
in the domain. Each element shall have its
.I .key
set to the value the antecedent formula
.RI ( k )
is tested on, and
.I .value
set to the value the predicate formula
.RI ( v )
is tested on; these fields may be
.IR NULL ,
and are ultimately evaluated via
arguments passed to the
.BR libnormalform_function (3)
function but may undergo transformation
via arguments passed to the
.BR libnormalform_transformation (3)
function on the way.
.PP
The values
.I d->mappings
and
.I d->nmappings
may be set differently every time the
.BR libnormalform_evaluate (3)
is called.
.PP
Although unused, the
.BR libnormalform_empty ()
and
.BR libnormalform_nonempty ()
functions require that
.I d->mappings
is properly set up (although the values
in it can all be
.IR NULL )
before the
.BR libnormalform_evaluate (3)
function is called.
.PP
See
.BR libnormalform_to_string (3)
for the purpose of
.IR d->identifier ,
it need not be set before the
.BR libnormalform_to_string (3)
function is called.
.PP
See
.BR libnormalform_clone (3)
for the purpose of
.IR d->copy_for_clone ,
it need not be set before the
.BR libnormalform_clone (3)
function is called.
.PP
The application can set
.I d->user_data
set freely, and can opt to leave it
unset. It is never used or reference
by the library, but it could be used
by the application to identify the
domain.
.PP
.I d
must not be
.IR NULL .
.PP
The returned pointer shall either be
deallocated with the
.BR libnormalform_free (3)
function or be relinquished by being
used as part of another sentence.
.PP
These functions adopt the ownership of any
.I LIBNORMALFORM_SENTENCE *
passed into it. Therefore, the user shall
not attempt to deallocate input sentences.
This holds even on failure: if the function
fails, input sentences are deallocated.
.SH RETURN VALUE
Upon successful completion, the
.BR libnormalform_any (),
.BR libnormalform_exists (),
.BR libnormalform_nexists (),
.BR libnormalform_existentially (),
.BR libnormalform_empty (),
and
.BR libnormalform_nonempty (),
functions return an object representing
the sentence; otherwise, the functions
return
.I NULL
and set
.I errno
to indicate the error.
.SH ERRORS
The
.BR libnormalform_any (),
.BR libnormalform_exists (),
.BR libnormalform_nexists (),
.BR libnormalform_existentially (),
.BR libnormalform_empty (),
and
.BR libnormalform_nonempty (),
functions fail if:
.TP
.B ENOMEM
Insufficient memory was available to
create the sentence object.
.PP
These functions will also fail without setting
.I errno
if
.I k
or
.I v
is
.IR NULL .
.SH ATTRIBUTES
For an explanation of the terms used in this
section, see
.BR attributes (7)
and
.IR "info \(dq(libc)POSIX Safety Concepts\(dq" .
.TS
allbox;
lb lb lb
l l l.
Interface Attribute Value
T{
.BR libnormalform_any (),
.br
.BR libnormalform_exists (),
.br
.BR libnormalform_nexists (),
.br
.BR libnormalform_existentially ()
T} Thread safety MT-Safe race:\fIk\fP,\fIv\fP
T{
.BR libnormalform_empty (),
.br
.BR libnormalform_nonempty ()
T} Thread safety MT-Safe
T{
.BR libnormalform_any (),
.br
.BR libnormalform_exists (),
.br
.BR libnormalform_nexists (),
.br
.BR libnormalform_existentially (),
.br
.BR libnormalform_empty (),
.br
.BR libnormalform_nonempty ()
T} Async-signal safety AS-Unsafe heap
T{
.BR libnormalform_any (),
.br
.BR libnormalform_exists (),
.br
.BR libnormalform_nexists (),
.br
.BR libnormalform_existentially (),
.br
.BR libnormalform_empty (),
.br
.BR libnormalform_nonempty ()
T} Async-cancel safety AC-Safe mem, AC-Unsafe heap
.TE
.SH SEE ALSO
.BR libnormalform (7),
.BR libnormalform_function (3)
|