abCROWN integration API
See the complete-verification guide for a wrapper-based example and backend settings.
The shared evaluation guide explains screening, ONNX/VNNLIB export, saved result identity and continuation. Use the pinned dependencies from CTRAIN's installer rather than an unrelated auto_LiRPA installation. Bundled verifier source retains its upstream provenance and license.
Execute alpha-beta-CROWN queries and preserve certified, falsified and unresolved outcomes.
abcrown_eval(*args, **kwargs)
Run one alpha-beta-CROWN query with isolated temporary artifacts.
The arguments follow _abcrown_eval. Returns elapsed time and solver status; exceptions become unknown and explicit timeouts remain timeout outcomes.
Source code in CTRAIN/complete_verification/abCROWN/verify.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
limited_abcrown_eval(work_dir=None, runner_path=None, *args, **kwargs)
Run alpha-beta-CROWN in a subprocess using the active Python interpreter.
Arguments are exchanged through isolated temporary files. An outer wall-time limit terminates the process group; process failures remain unknown rather than being interpreted as certificates. Returns elapsed time and status.
Source code in CTRAIN/complete_verification/abCROWN/verify.py
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 | |
Configure alpha-beta-CROWN and express local robustness queries in VNNLIB.
get_abcrown_standard_conf(timeout=600, no_cores=28)
Construct the default alpha-beta-CROWN configuration.
The bundled configuration is parsed into a fresh dictionary and updated with the available device, branch-and-bound timeout and MIP worker count.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
int
|
The timeout value for the BAB solver in seconds. |
600
|
no_cores
|
int
|
The number of parallel solvers to use. |
28
|
Returns:
| Type | Description |
|---|---|
dict
|
The updated standard configuration dictionary. |
Source code in CTRAIN/complete_verification/abCROWN/util.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | |
instances_to_vnnlib(indices, data, vnnlib_path, experiment_name, eps, eps_temp, data_min, data_max, no_classes)
Write one VNNLIB robustness query for each selected dataset input.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
list of int
|
List of indices of the data instances to be converted. |
required |
data
|
Dataset
|
Dataset containing the data instances. |
required |
vnnlib_path
|
str
|
Path where the VNN-LIB files will be saved. |
required |
experiment_name
|
str
|
Name of the experiment for documentation purposes. |
required |
eps
|
float
|
Epsilon value for the adversarial robustness property. |
required |
eps_temp
|
float
|
Temporary epsilon value used for domain calculation. |
required |
data_min
|
float
|
Minimum value for data normalisation/clamping. |
required |
data_max
|
float
|
Maximum value for data normalisation/clamping. |
required |
no_classes
|
int
|
Number of classes in the classification task. |
required |
Returns:
| Type | Description |
|---|---|
list of str
|
List of file paths to the generated VNN-LIB files. |
Source code in CTRAIN/complete_verification/abCROWN/util.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | |
write_adversarial_robustness_vnnlib(filename, initial_comment, input_domain, ground_truth, n_classes=10)
Write a clipped input box and a classification counterexample query as VNNLIB.
The output assertion asks whether any competing class can match or exceed the ground-truth score. An unsatisfiable query therefore certifies strict classification margins throughout the supplied box.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The name of the file to write the vnnlib specification to. |
required |
initial_comment
|
str
|
A comment to include at the top of the vnnlib file. |
required |
input_domain
|
Tensor
|
A tensor representing the input domain, i.e. lower and upper bounds per input, with shape (n, 2), where n is the number of input variables. |
required |
ground_truth
|
int
|
The index of the ground truth class. |
required |
n_classes
|
int
|
The number of output classes. |
10
|
Source code in CTRAIN/complete_verification/abCROWN/util.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |