aboutsummaryrefslogtreecommitdiffstats
path: root/man3/libnormalform_nor.3
blob: 164e8c59c5558053f62a1937f8c02d8ed7454da2 (plain) (blame)
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
.TH LIBNORMALFORM_NOR 3 LIBNORMALFORM
.SH NAME
libnormalform_nor \- Alternative denial

.SH SYNOPSIS
.nf
#include <libnormalform.h>

LIBNORMALFORM_SENTENCE *libnormalform_nor(LIBNORMALFORM_SENTENCE **\fIxs\fP);
LIBNORMALFORM_SENTENCE *libnormalform_norl(LIBNORMALFORM_SENTENCE *\fIa\fP, ... /*, NULL */);
LIBNORMALFORM_SENTENCE *libnormalform_vnor(LIBNORMALFORM_SENTENCE *\fIa\fP, va_list \fPargs\fP);
LIBNORMALFORM_SENTENCE *libnormalform_nor_checked(size_t \fIn\fP, LIBNORMALFORM_SENTENCE **\fIxs\fP);
LIBNORMALFORM_SENTENCE *libnormalform_norl_checked(size_t \fIn\fP, LIBNORMALFORM_SENTENCE *\fIa\fP, ... /*, NULL */);
LIBNORMALFORM_SENTENCE *libnormalform_vnor_checked(size_t \fIn\fP, LIBNORMALFORM_SENTENCE *\fIa\fP, va_list \fPargs\fP);
LIBNORMALFORM_SENTENCE *libnormalform_nor2(LIBNORMALFORM_SENTENCE *\fIp\fP, LIBNORMALFORM_SENTENCE *\fIq\fP);
#define LIBNORMALFORM_NOR(...) /* ... */
.fi
.PP
Link with
.IR -lnormalform .

.SH DESCRIPTION
The
.BR libnormalform_nor ()
function creates a sentence where each subsentence
is connected with a NOR (alternative denial) operator.
In the case that exactly two subsentences are given,
this creates a clause that is true when and only when
at least one is false. There is no generally meaningful
interpretation if a NOR-clause containing more than
two terms.
.PP
The value of the
.I xs
parameter shall be a null-pointer terminated list
of subsentences.
.PP
The
.BR libnormalform_norl ()
function is a variant of
.BR libnormalform_nor ()
which uses variadic arguments instead of an array.
.PP
The
.BR libnormalform_vnor ()
function is a variant of
.BR libnormalform_norl ()
which takes an
.I va_list
in place of variadic arguments.
.PP
The
.BR libnormalform_nor_checked (),
.BR libnormalform_norl_checked (),
and
.BR libnormalform_vnor_checked ()
functions are variants of the
.BR libnormalform_nor (),
.BR libnormalform_norl (),
and
.BR libnormalform_vnor ()
functions respectively which assumes
that it is given
.I n
subsentances, and checks that all are
.RI non- NULL .
However, these functions still require
the list of subsentences to be terminated
using a null-pointer.
.PP
.I "libnormalform_nor2(p, q)"
is equivalent to
.IR "libnormalform_norl_checked(2, p, q, NULL)" .
.PP
The
.BR LIBNORMALFORM_NOR
macro is a wrapper for the
.BR libnormalform_nor_checked ()
but is more similar to
.BR libnormalform_norl ().
Unlike
.BR libnormalform_norl (),
the argument list
.I must not
be terminated by a null-pointer, instead
the macro automatically as the null-pointer.
The macro will count the number of arguments
it is given, therefore it will fail it the
argument list is has an extra null-pointer.
.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_nor ()
function and its variants return an object
representing  the sentence; otherwise, the
functions return
.I NULL
and set
.I errno
to indicate the error.

.SH ERRORS
These functions fails if:
.TP
.I ENOMEM
Insufficient memory was available to
create the sentence object.
.TP
.I EDOM
The function was not given any subsentences.
.PP
The
.BR libnormalform_nor_checked (),
.BR libnormalform_norl_checked (),
and
.BR libnormalform_vnor_checked ()
functions will also fail without setting
.I errno
if any of the first
.I n
.IR "LIBNORMALFORM_SENTENCE *" 's
are
.IR NULL .
Likewise, the
.BR libnormalform_nor2 ()
function will fail without setting
.I errno
if
.I p
or
.I q
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_nor (),
.br
.BR libnormalform_nor_checked ()
T}	Thread safety	MT-Safe race:\fIxs\fP and elements in \fIxs\fP
T{
.BR libnormalform_norl (),
.br
.BR libnormalform_norl_checked (),
.br
.BR libnormalform_nor2 (),
.br
.BR LIBNORMALFORM_NOR ()
T}	Thread safety	MT-Safe race:parameters
T{
.BR libnormalform_vnor (),
.br
.BR libnormalform_vnor_checked ()
T}	Thread safety	MT-Safe race:parameters and arguments in \fIargs\fP
T{
.BR libnormalform_nor (),
.br
.BR libnormalform_norl (),
.br
.BR libnormalform_vnor (),
.br
.BR libnormalform_nor_checked (),
.br
.BR libnormalform_norl_checked (),
.br
.BR libnormalform_vnor_checked (),
.br
.BR libnormalform_vnor2 (),
.br
.BR LIBNORMALFORM_NOR ()
T}	Async-signal safety	AS-Unsafe heap
T{
.BR libnormalform_nor (),
.br
.BR libnormalform_norl (),
.br
.BR libnormalform_vnor (),
.br
.BR libnormalform_nor_checked (),
.br
.BR libnormalform_norl_checked (),
.br
.BR libnormalform_vnor_checked (),
.br
.BR libnormalform_vnor2 (),
.br
.BR LIBNORMALFORM_NOR ()
T}	Async-cancel safety	AC-Safe mem, AC-Unsafe heap
.TE

.SH NOTES
The connective is commutative and left-associative. It's truthtable is (1000).
.PP
The
.BR LIBNORMALFORM_NOR ()
macro requires ISO C23 support.
.PP
The
.BR libnormalform_nor ()
is primary function, the other functions are
just wrappers for the
.BR libnormalform_nor ()
function.
.PP
These functions creates a clause where each term is
connected with the NOR connective. Unlike what the
names Joint denial and Negated OR imply, this does
.I not
create a sentence that is true when all subsentences
are false. There is unfortunately no generally
meaningful interpretation: adding true term on the
right always create a contradiction, while adding a
false term on the right inverts the original clause.
.PP
Side-effects in the arguments of the macro
.BR LIBNORMALFORM_NOR ()
are guaranteed to be applied exactly once.
The side-effects in each macro are applied
in no particular order.

.SH SEE ALSO
.BR libnormalform (7)