-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipafair.h
228 lines (208 loc) · 7.65 KB
/
ipafair.h
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
/* This file is part of IPAFAIR, an incremental API for AF solvers.
*
* This C version of IPAFAIR is based on the incremental SAT API IPASIR:
* https://github.com/biotomas/ipasir
*
* See LICENSE.md for rights to use this software.
*/
#ifndef ipafair_h_INCLUDED
#define ipafair_h_INCLUDED
#include <stdint.h>
/*
* In this header, the macro IPAFAIR_API is defined as follows:
* - if IPAFAIR_SHARED_LIB is not defined, then IPAFAIR_API is defined, but empty.
* - if IPAFAIR_SHARED_LIB is defined...
* - ...and if BUILDING_IPAFAIR_SHARED_LIB is not defined, IPAFAIR_API is
* defined to contain symbol visibility attributes for importing symbols
* of a DSO (including the __declspec rsp. __attribute__ keywords).
* - ...and if BUILDING_IPAFAIR_SHARED_LIB is defined, IPAFAIR_API is defined
* to contain symbol visibility attributes for exporting symbols from a
* DSO (including the __declspec rsp. __attribute__ keywords).
*/
#if defined(IPAFAIR_SHARED_LIB)
#if defined(_WIN32) || defined(__CYGWIN__)
#if defined(BUILDING_IPAFAIR_SHARED_LIB)
#if defined(__GNUC__)
#define IPAFAIR_API __attribute__((dllexport))
#elif defined(_MSC_VER)
#define IPAFAIR_API __declspec(dllexport)
#endif
#else
#if defined(__GNUC__)
#define IPAFAIR_API __attribute__((dllimport))
#elif defined(_MSC_VER)
#define IPAFAIR_API __declspec(dllimport)
#endif
#endif
#elif defined(__GNUC__)
#define IPAFAIR_API __attribute__((visibility("default")))
#endif
#if !defined(IPAFAIR_API)
#if !defined(IPAFAIR_SUPPRESS_WARNINGS)
#warning "Unknown compiler. Not adding visibility information to IPAFAIR symbols."
#warning "Define IPAFAIR_SUPPRESS_WARNINGS to suppress this warning."
#endif
#define IPAFAIR_API
#endif
#else
#define IPAFAIR_API
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
admissible,
complete,
preferred,
stable,
semistable,
stage,
ideal
} semantics;
/**
* Return the name and the version of the dynamic AF solver.
*/
IPAFAIR_API const char * ipafair_signature ();
/**
* Construct a new solver and return a pointer to it. Use the returned pointer
* as the first parameter in each of the following functions.
*
* Required state: N/A
* State after: INPUT
*/
IPAFAIR_API void * ipafair_init ();
/**
* Release the solver, i.e., all its resources and allocated memory. The solver
* pointer cannot be used for any purposes after this call.
*
* Required state: INPUT or SAT or UNSAT or ERROR
* State after: undefined
*/
IPAFAIR_API void ipafair_release (void * solver);
/**
* Set the argumentation semantics for the next calls of 'ipafair_solve'.
*
* If the semantics is not supported by the solver, enter state ERROR.
*
* Required state: INPUT or SAT or UNSAT
* State after: INPUT or ERROR
*/
IPAFAIR_API void ipafair_set_semantics (void * solver, semantics sem);
/**
* Add the given argument to the current argumentation framework.
*
* If the argument already exists, enter state ERROR.
*
* Arguments are encoded as positive integers. They have to be smaller or equal
* to INT32_MAX. This applies to all the literal arguments in API functions.
*
* Required state: INPUT or SAT or UNSAT
* State after: INPUT or ERROR
*/
IPAFAIR_API void ipafair_add_argument (void * solver, int32_t arg);
/**
* Delete the given argument from the current argumentation framework.
*
* If the argument does not exist, enter state ERROR.
*
* Required state: INPUT or SAT or UNSAT
* State after: INPUT or ERROR
*/
IPAFAIR_API void ipafair_del_argument (void * solver, int32_t arg);
/**
* Add the given attack (s,t) to the current argumentation framework.
*
* If the attack already exists, or if s or t is not an existing argument
* added via 'ipafair_add_argument', enter state ERROR.
*
* Required state: INPUT or SAT or UNSAT
* State after: INPUT or ERROR
*/
IPAFAIR_API void ipafair_add_attack (void * solver, int32_t s, int32_t t);
/**
* Delete the given attack (s,t) from the current argumentation framework.
*
* If the attack does not exist, enter state ERROR.
*
* Required state: INPUT or SAT or UNSAT
* State after: INPUT or ERROR
*/
IPAFAIR_API void ipafair_del_attack (void * solver, int32_t s, int32_t t);
/**
* Add an assumption for the next call of 'ipafair_solve'. After calling
* 'ipafair_solve' all previously added assumptions are cleared.
*
* The assumption is provided as a positive integer whose value is an argument
* previously added via 'ipafair_add_argument'.
*
* If such an argument does not exist, enter state ERROR.
*
* Required state: INPUT or SAT or UNSAT
* State after: INPUT or ERROR
*/
IPAFAIR_API void ipafair_assume (void * solver, int32_t arg);
/**
* Solve the current instance, as defined by previous calls to
* 'ipafair_set_semantics', 'ipafair_add_argument', 'ipafair_del_argument',
* 'ipafair_add_attack', 'ipafair_del_attack', and 'ipafair_assume'
* in the credulous reasoning mode.
*
* That is, decide whether arguments assumed via 'ipafair_assume' are contained
* in *an extension* under semantics specified by 'ipafair_set_semantics' in
* the current argumentation framework constructed by calls to
* 'ipafair_add_argument', 'ipafair_del_argument', 'ipafair_add_attack', and
* 'ipafair_del_attack'.
*
* If the answer is 'yes', return 10 and change the state of the solver to SAT.
* If the answer is 'no', return 20 and change the state of the solver to UNSAT.
* If the solver does not support the sequence of API calls performed, return -1
* and change the state of the solver to ERROR.
*
* This function can be called in any defined state of the solver. Note that
* the state of the solver _during_ execution of 'ipafair_solve' is undefined.
*
* Required state: INPUT or SAT or UNSAT
* State after: SAT or UNSAT or ERROR
*/
IPAFAIR_API int ipafair_solve_cred (void * solver);
/**
* Solve the current instance, as defined by previous calls to
* 'ipafair_set_semantics', 'ipafair_add_argument', 'ipafair_del_argument',
* 'ipafair_add_attack', 'ipafair_del_attack', and 'ipafair_assume'
* in the skeptical reasoning mode.
*
* That is, decide whether arguments assumed via 'ipafair_assume' are contained
* in *all extensions* under semantics specified by 'ipafair_set_semantics' in
* the current argumentation framework constructed by calls to
* 'ipafair_add_argument', 'ipafair_del_argument', 'ipafair_add_attack', and
* 'ipafair_del_attack'.
*
* If the answer is 'yes', return 10 and change the state of the solver to SAT.
* If the answer is 'no', return 20 and change the state of the solver to UNSAT.
* If the solver does not support the sequence of API calls performed, return -1
* and change the state of the solver to ERROR.
*
* This function can be called in any defined state of the solver. Note that
* the state of the solver _during_ execution of 'ipafair_solve' is undefined.
*
* Required state: INPUT or SAT or UNSAT
* State after: SAT or UNSAT or ERROR
*/
IPAFAIR_API int ipafair_solve_skept (void * solver);
/**
* Determine whether the given argument is contained in a solution or
* counterexample extension. Return 'arg' if the answer is 'yes', and '-arg'
* if the answer is 'no'.
*
* This function can only be used if 'ipafair_solve_cred' has returned 10, or
* 'ipafair_solve_skept' has returned 20, and the state of the solver has not
* changed.
*
* Required state: SAT or UNSAT
* State after: SAT or UNSAT (unchanged)
*/
IPAFAIR_API int32_t ipafair_val (void * solver, int32_t arg);
#ifdef __cplusplus
} // closing extern "C"
#endif
#endif