-
Notifications
You must be signed in to change notification settings - Fork 47
/
yices.h
4796 lines (4256 loc) · 155 KB
/
yices.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
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
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
395
396
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
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* This file is part of the Yices SMT Solver.
* Copyright (C) 2017 SRI International.
*
* Yices is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Yices is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Yices. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* YICES API
*/
#ifndef __YICES_H
#define __YICES_H
/*
* On windows/cygwin/mingw:
*
* __YICES_DLLSPEC__ is '__declspec(dllimport) by default
*
* This can be overridden as follows:
*
* 1) give -DNOYICES_DLL as a compilation flag (if you want to
* link with libyices.a rather than the DLL)
*
* 2) define __YICES_DLLSPEC__ to '__declspec(dllexport)' before
* #include "yices.h"
* when building yices.
*
* On any system other than Windows: __YICES_DLLSPEC__ is empty.
*/
#if defined(_WIN32) || defined(__CYGWIN__)
#if defined(NOYICES_DLL)
#undef __YICES_DLLSPEC__
#define __YICES_DLLSPEC__
#else
#if ! defined(__YICES_DLLSPEC__)
#define __YICES_DLLSPEC__ __declspec(dllimport)
#endif
#endif
#else
#define __YICES_DLLSPEC__
#endif
/*
* On mingw with the thread-safety option:
* STATUS_INTERRUPTED is a defined symbol in windows.
* We have renamed the symbol in yices_types.h and here
* we redefine the STATUS_INTERRUPTED symbol to be backward compatible.
* This will be removed in the non-backward compatible release (Yices 2.8).
*/
#if !defined(MINGW) || !defined(THREAD_SAFE)
#define STATUS_INTERRUPTED YICES_STATUS_INTERRUPTED
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* WARNING: yices requires the header file <stdint.h>
*
* It's not available in Microsoft Visual Studio (prior to Visual Studio 2010),
* and it's possibly missing from other compilers too.
*
* If necessary, there are open-source 'stdint.h' that can
* be downloaded at
* http://code.google.com/p/msinttypes/ (for MS Visual Studio only)
* or http://www.azillionmonkeys.com/qed/pstdint.h
*/
#include <stdint.h>
#include <stdio.h>
#include "yices_types.h"
#include "yices_limits.h"
/*********************
* VERSION NUMBERS *
********************/
#define __YICES_VERSION 2
#define __YICES_VERSION_MAJOR 6
#define __YICES_VERSION_PATCHLEVEL 5
/*
* The version as a string "x.y.z"
*/
__YICES_DLLSPEC__ extern const char *yices_version;
/*
* More details about the release:
* - build_arch is a string like "x86_64-unknown-linux-gnu"
* - build_mode is "release" or "debug"
* - build_date is the compilation date as in "2014-01-27"
*/
__YICES_DLLSPEC__ extern const char *yices_build_arch;
__YICES_DLLSPEC__ extern const char *yices_build_mode;
__YICES_DLLSPEC__ extern const char *yices_build_date;
/*
* Check whether the library was compiled with MCSAT support (i.e.,
* it can deal with nonlinear arithmetic).
* - return 1 if yes, 0 if no
*/
__YICES_DLLSPEC__ extern int32_t yices_has_mcsat(void);
/*
* Check whether the library was compiled in THREAD_SAFE mode.
* - return 1 if yes, 0 if no
*
* Since 2.6.2.
*/
__YICES_DLLSPEC__ extern int32_t yices_is_thread_safe(void);
/***************************************
* GLOBAL INITIALIZATION AND CLEANUP *
**************************************/
/*
* This function must be called before anything else to initialize
* internal data structures.
*/
__YICES_DLLSPEC__ extern void yices_init(void);
/*
* Delete all internal data structures and objects
* - this must be called to avoid memory leaks
*/
__YICES_DLLSPEC__ extern void yices_exit(void);
/*
* Full reset
* - delete all terms and types and reset the symbol tables
* - delete all contexts, models, configuration descriptors and
* parameter records.
*/
__YICES_DLLSPEC__ extern void yices_reset(void);
/*
* Delete a string returned by yices
*
* Several functions construct and return a string:
* - yices_error_string
* - yices_type_to_string
* - yices_term_to_string
* - yices_model_to_string
*
* The returned string must be freed when it's no longer used by
* calling this function.
*/
__YICES_DLLSPEC__ extern void yices_free_string(char *s);
/***************************
* OUT-OF-MEMORY CALLBACK *
**************************/
/*
* By default, when Yices runs out of memory, it
* first prints an error message on stderr; then it calls
* exit(YICES_EXIT_OUT_OF_MEMORY). This kills the whole process.
*
* The following function allows you to register a callback to invoke
* if Yices runs out of memory. The callback function takes no
* arguments and returns nothing.
*
* Installing an out-of-memory callback allows you to do something a
* bit less brutal than killing the process. If there's a callback,
* yices will call it first when it runs out of memory. The callback
* function should not return. If it does, yices will call exit as
* previously.
*
* In other words, the code that handles out-of-memory is as follows:
*
* if (callback != NULL) {
* callback();
* } else {
* fprintf(stderr, ...);
* }
* exit(YICES_EXIT_OUT_OF_MEMORY);
*
*
* IMPORTANT
* ---------
* After Yices runs out of memory, its internal data structures may be
* left in an inconsistent/corrupted state. The API is effectively
* unusable at this point and nothing can be done to recover cleanly.
* Evan a call to yices_exit() may cause a seg fault. The callback
* should not try to cleanup anything, or call any function from the API.
*
* A plausible use of this callback feature is to implement an
* exception mechanism using setjmp/longjmp.
*/
__YICES_DLLSPEC__ extern void yices_set_out_of_mem_callback(void (*callback)(void));
/*********************
* ERROR REPORTING *
********************/
/*
* Error codes and the error_report data structure are defined in
* yices_types.h. When an API function is called with invalid
* arguments or when some error occurs for whatever reason, then the
* function returns a specific value (typically a negative value) and
* stores information about the error in a global error_report
* structure. This structure can be examined by calling
* yices_error_report(). The most important component of the
* error_report is an error code that is returned by a call to
* yices_error_code().
*/
/*
* Get the last error code
*/
__YICES_DLLSPEC__ extern error_code_t yices_error_code(void);
/*
* Get the last error report
*/
__YICES_DLLSPEC__ extern error_report_t *yices_error_report(void);
/*
* Clear the error report
*/
__YICES_DLLSPEC__ extern void yices_clear_error(void);
/*
* Print an error message on stream f. This converts the current error
* code + error report structure into an error message.
* - f must be a non-NULL open stream (writable)
*
* Return -1 if there's an error while writing to f (as reported by fprintf).
* Return 0 otherwise.
*
* If there's an error, errno, perror, and friends can be used for diagnostic.
*/
__YICES_DLLSPEC__ extern int32_t yices_print_error(FILE *f);
/*
* Print an error message on file descriptor fd. This converts the current error
* code + error report structure into an error message.
* - fd must be an open file descriptor (writable)
*
* Return -1 if there's an error while writing to fd.
* Return 0 otherwise.
*
* If there's an error, errno, perror, and friends can be used for diagnostic.
*/
__YICES_DLLSPEC__ extern int32_t yices_print_error_fd(int fd);
/*
* Build a string from the current error code + error report structure.
*
* The returned string must be freed when no-longer used by calling
* yices_free_string.
*/
__YICES_DLLSPEC__ extern char *yices_error_string(void);
/********************************
* VECTORS OF TERMS AND TYPES *
*******************************/
/*
* Some functions in the API return arrays of terms or types
* in a vector object (i.e., a resizable array). The vector
* structures are defined in yices_types.h:
* - v.size = number of elements in the array
* - v.data = the array proper: the elements are stored in
* v.data[0] .... v.data[n-1] where n = v.size.
*
* Before calling any function that fills in a term_vector or
* type_vector, the vector object must be initialized via
* yices_init_term_vector or yices_init_type_vector. To prevent
* memory leaks, it must be deleted when no longer needed.
*/
/*
* Initialize a term or type vector v
*/
__YICES_DLLSPEC__ extern void yices_init_term_vector(term_vector_t *v);
__YICES_DLLSPEC__ extern void yices_init_type_vector(type_vector_t *v);
/*
* Delete vector v
*/
__YICES_DLLSPEC__ extern void yices_delete_term_vector(term_vector_t *v);
__YICES_DLLSPEC__ extern void yices_delete_type_vector(type_vector_t *v);
/*
* Reset: empty the vector (reset size to 0)
*/
__YICES_DLLSPEC__ extern void yices_reset_term_vector(term_vector_t *v);
__YICES_DLLSPEC__ extern void yices_reset_type_vector(type_vector_t *v);
/***********************
* TYPE CONSTRUCTORS *
**********************/
/*
* All constructors return NULL_TYPE (-1) if the type definition is wrong.
*/
/*
* Built-in types bool, int, real.
*/
__YICES_DLLSPEC__ extern type_t yices_bool_type(void);
__YICES_DLLSPEC__ extern type_t yices_int_type(void);
__YICES_DLLSPEC__ extern type_t yices_real_type(void);
/*
* Bitvectors of given size (number of bits)
* Requires size > 0
*
* If size = 0, the error report is set
* code = POS_INT_REQUIRED
* badval = size
* If size > YICES_MAX_BVSIZE
* code = MAX_BVSIZE_EXCEEDED
* badval = size
*/
__YICES_DLLSPEC__ extern type_t yices_bv_type(uint32_t size);
/*
* New scalar type of given cardinality.
* Requires card > 0
*
* If card = 0, set error report to
* code = POS_INT_REQUIRED
* badval = size
*/
__YICES_DLLSPEC__ extern type_t yices_new_scalar_type(uint32_t card);
/*
* New uninterpreted type. No error report.
*/
__YICES_DLLSPEC__ extern type_t yices_new_uninterpreted_type(void);
/*
* Tuple type tau[0] x ... x tau[n-1].
* Requires n>0 and tau[0] ... tau[n-1] to be well defined types.
*
* Error report
* if n == 0,
* code = POS_INT_REQUIRED
* badval = n
* if n > YICES_MAX_ARITY
* code = TOO_MANY_ARGUMENTS
* badval = n
* if tau[i] is not well defined (and tau[0] .. tau[i-1] are)
* code = INVALID_TYPE
* type1 = tau[i]
*/
__YICES_DLLSPEC__ extern type_t yices_tuple_type(uint32_t n, const type_t tau[]);
/*
* Variants: for small arity
*
* These variants build types:
* (tuple tau1)
* (tuple tau1 tau2)
* (tuple tau1 tau2 tau3)
*
* Error report: same as yices_tuple_type if one of the type is invalid
*/
__YICES_DLLSPEC__ extern type_t yices_tuple_type1(type_t tau1);
__YICES_DLLSPEC__ extern type_t yices_tuple_type2(type_t tau1, type_t tau2);
__YICES_DLLSPEC__ extern type_t yices_tuple_type3(type_t tau1, type_t tau2, type_t tau3);
/*
* Function type: dom[0] ... dom[n-1] -> range
* Requires n>0, and dom[0] ... dom[n-1] and range to be well defined
*
* Error report
* if n == 0,
* code = POS_INT_REQUIRED
* badval = n
* if n > YICES_MAX_ARITY
* code = TOO_MANY_ARGUMENTS
* badval = n
* if range undefined
* code = INVALID_TYPE
* type1 = range
* if dom[i] is undefined (and dom[0] ... dom[i-1] are)
* code = INVALID_TYPE
* type1 = dom[i]
*/
__YICES_DLLSPEC__ extern type_t yices_function_type(uint32_t n, const type_t dom[], type_t range);
/*
* Variants for small arity:
* [tau1 -> range]
* [tau1, tau2 -> range]
* [tau1, tau2. tau3 -> range]
*
* Same error reports are yices_function_type if one of the type is invalid
*/
__YICES_DLLSPEC__ extern type_t yices_function_type1(type_t tau1, type_t range);
__YICES_DLLSPEC__ extern type_t yices_function_type2(type_t tau1, type_t tau2, type_t range);
__YICES_DLLSPEC__ extern type_t yices_function_type3(type_t tau1, type_t tau2, type_t tau3, type_t range);
/*************************
* TYPE EXPLORATION *
************************/
/*
* Checks on a type tau:
* - all functions return 0 for false, 1 for true
*
* yices_type_is_arithmetic(tau) returns true if tau is either int or real.
*
* if tau not a valid type, the functions return false
* and set the error report:
* code = INVALID_TYPE
* type1 = tau
*/
__YICES_DLLSPEC__ extern int32_t yices_type_is_bool(type_t tau);
__YICES_DLLSPEC__ extern int32_t yices_type_is_int(type_t tau);
__YICES_DLLSPEC__ extern int32_t yices_type_is_real(type_t tau);
__YICES_DLLSPEC__ extern int32_t yices_type_is_arithmetic(type_t tau);
__YICES_DLLSPEC__ extern int32_t yices_type_is_bitvector(type_t tau);
__YICES_DLLSPEC__ extern int32_t yices_type_is_tuple(type_t tau);
__YICES_DLLSPEC__ extern int32_t yices_type_is_function(type_t tau);
__YICES_DLLSPEC__ extern int32_t yices_type_is_scalar(type_t tau);
__YICES_DLLSPEC__ extern int32_t yices_type_is_uninterpreted(type_t tau);
/*
* Check whether tau is a subtype of sigma
* - returns 0 for false, 1 for true
*
* If tau or sigma is not a valid type, the function returns false
* and sets the error report:
* code = INVALID_TYPE
* type1 = tau or sigma
*/
__YICES_DLLSPEC__ extern int32_t yices_test_subtype(type_t tau, type_t sigma);
/*
* Check whether tau and sigma are compatible
* - return 0 for false, 1 for true
*
* If tau or sigma is not a valid type, the function returns 0 and
* sets the error report:
* code = INVALID_TYPE
* type1 = tau or sigma
*/
__YICES_DLLSPEC__ extern int32_t yices_compatible_types(type_t tau, type_t sigma);
/*
* Number of bits for type tau
* - returns 0 if there's an error
*
* Error report:
* if tau is not a valid type
* code = INVALID_TYPE
* type1 = tau
* if tau is not a bitvector type
* code = BVTYPE_REQUIRED
* type1 = tau
*/
__YICES_DLLSPEC__ extern uint32_t yices_bvtype_size(type_t tau);
/*
* Cardinality of a scalar type
* - returns 0 if there's an error
*
* Error report:
* if tau is not a valid type
* code = INVALID_TYPE
* type1 = tau
* if tau is not a scalar type
* code = INVALID_TYPE_OP
*/
__YICES_DLLSPEC__ extern uint32_t yices_scalar_type_card(type_t tau);
/*
* Number of children of type tau
* - if tau is a tuple type (tuple tau_1 ... tau_n), returns n
* - if tau is a function type (-> tau_1 ... tau_n sigma), returns n+1
* - if tau is any other type, returns 0
*
* - returns -1 if tau is not a valid type
*
* Error report:
* if tau is not a valid type
* code = INVALID_TYPE
* type1 = tau
*/
__YICES_DLLSPEC__ extern int32_t yices_type_num_children(type_t tau);
/*
* i-th child of type tau.
* - i must be in 0 and n-1 where n = yices_type_num_children(tau)
* - returns NULL_TYPE if there's an error
*
* For a function type (-> tau_1 ... tau_n sigma), the first n
* children are tau_1 ... tau_n (indexed from 0 to n-1) and the last
* child is sigma (with index i=n).
*
* Error report:
* if tau is not a valid type
* code = INVALID_TYPE
* type1 = tau
* if is is negative or larger than n
* code = INVALID_TYPE_OP
*/
__YICES_DLLSPEC__ extern type_t yices_type_child(type_t tau, int32_t i);
/*
* Collect all the children of type tau in vector *v
* - v must be initialized by calling yices_init_type_vector
* - if tau is not valid, the function returns -1 and leaves *v unchanged
* - otherwise, the children are stored in *v:
* v->size = number of children
* v->data[0 ... v->size-1] = the children
*
* The children are stored in the same order as given by yices_type_child:
* v->data[i] = child of index i.
*
* Error report:
* if tau is not a valid type
* code = INVALID_TYPE
* type1 = tau
*/
__YICES_DLLSPEC__ extern int32_t yices_type_children(type_t tau, type_vector_t *v);
/***********************
* TERM CONSTRUCTORS *
**********************/
/*
* Constructors do type checking and simplification.
* They return NULL_TERM (< 0) if there's a type error.
*
* Type checking rules for function applications:
* - if f has type [tau_1 ... tau_n -> u]
* x_1 has type sigma_1, ..., x_n has type sigma_n
* - then (f x1 ... xn) is type correct if sigma_i
* is a subtype of tau_i for i=1,...,n.
* Examples:
* - x_i has type int and tau_i is real: OK
* - x_i has type real and tau_i is int: type error
*/
/*
* Boolean constants: no error report
*/
__YICES_DLLSPEC__ extern term_t yices_true(void);
__YICES_DLLSPEC__ extern term_t yices_false(void);
/*
* Constant of type tau and id = index
* - tau must be a scalar type or an uninterpreted type
* - index must be non-negative, and, if tau is scalar,
* index must be less than tau's cardinality.
*
* Each constant is identified by its index. Two constants
* of type tau that have different indices are distinct.
*
* Error report:
* if tau is undefined
* code = INVALID_TYPE
* type1 = tau
* if tau is not scalar or uninterpreted,
* code = SCALAR_OR_UTYPE_REQUIRED
* type1 = tau
* if the index is negative or too large
* code = INVALID_CONSTANT_INDEX
* type1 = tau
* badval = index
*/
__YICES_DLLSPEC__ extern term_t yices_constant(type_t tau, int32_t index);
/*
* Uninterpreted term of type tau
*
* An uninterpreted term is like a global variable of type tau. But, we
* don't call it a variable, because variables have a different meaning
* in Yices (see next function).
*
* If tau is a function type, then this creates an uninterpreted
* function (see yices_application).
*
* Error report:
* if tau is undefined
* code = INVALID_TYPE
* type1 = tau
*/
__YICES_DLLSPEC__ extern term_t yices_new_uninterpreted_term(type_t tau);
/*
* Variable of type tau. This creates a new variable.
*
* Variables are different form uninterpreted terms. They are used
* in quantifiers and to support substitutions.
*
* Error report:
* if tau is undefined
* code = INVALID_TYPE
* type1 = tau
*/
__YICES_DLLSPEC__ extern term_t yices_new_variable(type_t tau);
/*
* Application of an uninterpreted function to n arguments.
*
* Error report:
* if n == 0,
* code = POS_INT_REQUIRED
* badval = n
* if fun or arg[i] is not defined
* code = INVALID_TERM
* term1 = fun or arg[i]
* if fun is not a function
* code = FUNCTION_REQUIRED
* term1 = fun
* if n != number of arguments required for fun
* code = WRONG_NUMBER_OF_ARGUMENTS
* type1 = type of fun
* badval = n
* if arg[i] has a wrong type
* code = TYPE_MISMATCH
* term1 = arg[i]
* type1 = expected type
*/
__YICES_DLLSPEC__ extern term_t yices_application(term_t fun, uint32_t n, const term_t arg[]);
/*
* Variants for small arity:
* - the arguments are given as arg1, arg2, arg3 instead of an array of n terms
* - fun must be an uninterpreted function of arity 1, 2, or 3
*
* Same error reports are yices_application
*/
__YICES_DLLSPEC__ extern term_t yices_application1(term_t fun, term_t arg1);
__YICES_DLLSPEC__ extern term_t yices_application2(term_t fun, term_t arg1, term_t arg2);
__YICES_DLLSPEC__ extern term_t yices_application3(term_t fun, term_t arg1, term_t arg2, term_t arg3);
/*
* if-then-else
*
* Error report:
* if cond, then_term, or else_term is not a valid term
* code = INVALID_TERM
* term1 = whichever of cond, then_term, or else_term is invalid
* if cond is not boolean
* code = TYPE_MISMATCH
* term1 = cond
* type1 = bool (expected type)
* if then_term and else_term have incompatible types
* code = INCOMPATIBLE_TYPES
* term1 = then_term
* type1 = term1's type
* term2 = else_term
* type2 = term2's type
*/
__YICES_DLLSPEC__ extern term_t yices_ite(term_t cond, term_t then_term, term_t else_term);
/*
* Equality (= left right)
* Disequality (/= left right)
*
* Error report:
* if left or right is not a valid term
* code = INVALID_TERM
* term1 = left or right
* if left and right do not have compatible types
* code = INCOMPATIBLE_TYPES
* term1 = left
* type1 = term1's type
* term2 = right
* type2 = term2's type
*/
__YICES_DLLSPEC__ extern term_t yices_eq(term_t left, term_t right);
__YICES_DLLSPEC__ extern term_t yices_neq(term_t left, term_t right);
/*
* (not arg)
*
* Error report:
* if arg is invalid
* code = INVALID_TERM
* term1 = arg
* if arg is not boolean
* code = TYPE_MISMATCH
* term1 = arg
* type1 = bool (expected type)
*/
__YICES_DLLSPEC__ extern term_t yices_not(term_t arg);
/*
* (or arg[0] ... arg[n-1])
* (and arg[0] ... arg[n-1])
* (xor arg[0] ... arg[n-1])
*
* NOTE: ARRAY ARG MAY BE MODIFIED.
*
* Error report:
* if n > YICES_MAX_ARITY
* code = TOO_MANY_ARGUMENTS
* badval = n
* if arg[i] is not a valid term
* code = INVALID_TERM
* term1 = arg[i]
* if arg[i] is not boolean
* code = TYPE_MISMATCH
* term1 = arg[i]
* type1 = bool (expected type)
*/
__YICES_DLLSPEC__ extern term_t yices_or(uint32_t n, term_t arg[]);
__YICES_DLLSPEC__ extern term_t yices_and(uint32_t n, term_t arg[]);
__YICES_DLLSPEC__ extern term_t yices_xor(uint32_t n, term_t arg[]);
/*
* Variants of or/and/xor with 2 or 3 arguments
*/
__YICES_DLLSPEC__ extern term_t yices_or2(term_t t1, term_t t2);
__YICES_DLLSPEC__ extern term_t yices_and2(term_t t1, term_t t2);
__YICES_DLLSPEC__ extern term_t yices_xor2(term_t t1, term_t t2);
__YICES_DLLSPEC__ extern term_t yices_or3(term_t t1, term_t t2, term_t t3);
__YICES_DLLSPEC__ extern term_t yices_and3(term_t t1, term_t t2, term_t t3);
__YICES_DLLSPEC__ extern term_t yices_xor3(term_t t1, term_t t2, term_t t3);
/*
* (iff left right)
* (implies left right)
*
* Error report:
* if left or right is invalid
* code = INVALID_TERM
* term1 = left/right
* if left or right is not boolean
* code = TYPE_MISMATCH
* term1 = left/right
* type1 = bool (expected type)
*/
__YICES_DLLSPEC__ extern term_t yices_iff(term_t left, term_t right);
__YICES_DLLSPEC__ extern term_t yices_implies(term_t left, term_t right);
/*
* Tuple constructor
*
* Error report:
* if n == 0
* code = POS_INT_REQUIRED
* badval = n
* if n > YICES_MAX_ARITY
* code = TOO_MANY_ARGUMENTS
* badval = n
* if one arg[i] is invalid
* code = INVALID_TERM
* term1 = arg[i]
*/
__YICES_DLLSPEC__ extern term_t yices_tuple(uint32_t n, const term_t arg[]);
/*
* Variants for n=2 or n=3
* - same error reports as yices_tuple if arg1, arg2, or arg3 is invalid
*/
__YICES_DLLSPEC__ extern term_t yices_pair(term_t arg1, term_t arg2);
__YICES_DLLSPEC__ extern term_t yices_triple(term_t arg1, term_t arg2, term_t arg3);
/*
* Tuple projection
*
* The index must be between 1 and n (where n = number of components in tuple)
*
* Error report:
* if tuple is invalid
* code = INVALID_TERM
* term1 = tuple
* if tuple does not have a tuple type
* code = TUPLE_REQUIRED
* term1 = tuple
* if index = 0 or index > number of components in tuple
* code = INVALID_TUPLE_INDEX
* type1 = type of tuple
* badval = index
*/
__YICES_DLLSPEC__ extern term_t yices_select(uint32_t index, term_t tuple);
/*
* Tuple update: replace component i of tuple by new_v
*
* The index must be between 1 and n (where n = number of components in tuple)
*
* Error report
* if tuple or new_v is invalid
* code = INVALID_TERM
* term1 = tuple/new_v
* if tuple doesn't have a tuple type
* code = TUPLE_REQUIRED
* term1 = tuple
* if index = 0 or index > number of components in tuple
* code = INVALID_TUPLE_INDEX
* type1 = tuple's type
* badval = index
* if new_v has a wrong type
* code = TYPE_MISMATCH
* term1 = new_v
* type1 = expected type (i-th component type in tuple)
*/
__YICES_DLLSPEC__ extern term_t yices_tuple_update(term_t tuple, uint32_t index, term_t new_v);
/*
* Function update
*
* Error report:
* if n = 0
* code = POS_INT_REQUIRED
* badval = n
* if fun or new_v, or one of arg[i] is invalid
* code = INVALID_TERM
* term1 = fun, new_v, or arg[i]
* if fun does not have a function type
* code = FUNCTION_REQUIRED
* term1 = fun
* if n != number of arguments for fun
* code = WRONG_NUMBER_OF_ARGUMENTS
* type1 = type of fun
* badval = n
* if new_v has a wrong type (not a subtype of fun's range)
* code = TYPE_MISMATCH
* term1 = new_v
* type1 = fun's range (expected type)
* if arg[i] has a wrong type for i-th arg of fun
* code = TYPE_MISMATCH
* term1 = arg[i]
* type1 = expected type
*/
__YICES_DLLSPEC__ extern term_t yices_update(term_t fun, uint32_t n, const term_t arg[], term_t new_v);
/*
* Variants of yices_update for small n
* - fun must be a function of arity 1, 2, or 3
* - the arguments are given as arg1, arg2, arg3 instead of an array arg[]
*/
__YICES_DLLSPEC__ extern term_t yices_update1(term_t fun, term_t arg1, term_t new_v);
__YICES_DLLSPEC__ extern term_t yices_update2(term_t fun, term_t arg1, term_t arg2, term_t new_v);
__YICES_DLLSPEC__ extern term_t yices_update3(term_t fun, term_t arg1, term_t arg2, term_t arg3, term_t new_v);
/*
* Distinct
*
* NOTE: ARG MANY BE MODIFIED
*
* Error report:
* if n == 0
* code = POS_INT_REQUIRED
* badval = n
* if n > YICES_MAX_ARITY
* code = TOO_MANY_ARGUMENTS
* badval = n
* if arg[i] is not a valid term
* code = INVALID_TERM
* term1 = arg[i]
* if two terms arg[i] and arg[j] don't have compatible types
* code = INCOMPATIBLE_TYPES
* term1 = arg[i]
* type1 = term1's type
* term2 = arg[j]
* type2 = term2's type
*/
__YICES_DLLSPEC__ extern term_t yices_distinct(uint32_t n, term_t arg[]);
/*
* Quantified terms
* (forall (var[0] ... var[n-1]) body)
* (exists (var[0] ... var[n-1]) body)
*
* NOTE: ARRAY VAR MAY BE MODIFIED
*
* Error report:
* if n == 0
* code = POS_INT_REQUIRED
* badval = n
* if n > YICES_MAX_VARS
* code = TOO_MANY_VARS
* badval = n
* if body or one of var[i] is invalid
* code = INVALID_TERM
* term1 = body or var[i]
* if body is not boolean
* code = TYPE_MISMATCH
* term1 = body
* type1 = bool (expected type)
* if one of var[i] is not a variable
* code = VARIABLE_REQUIRED
* term1 = var[i]
* if one variable occurs twice in var
* code = DUPLICATE_VARIABLE
* term1 = var[i]
*/
__YICES_DLLSPEC__ extern term_t yices_forall(uint32_t n, term_t var[], term_t body);
__YICES_DLLSPEC__ extern term_t yices_exists(uint32_t n, term_t var[], term_t body);
/*
* Lambda terms
*
* Error report:
* if n == 0
* code = POS_INT_REQUIRED
* badval = n
* if n > YICES_MAX_VARS
* code = TOO_MANY_VARS
* badval = n
* if body or one of var[i] is invalid
* code = INVALID_TERM
* term1 = body or var[i]
* if one of var[i] is not a variable
* code = VARIABLE_REQUIRED
* term1 = var[i]
* if one variable occurs twice in var
* code = DUPLICATE_VARIABLE
* term1 = var[i]
*
*/
__YICES_DLLSPEC__ extern term_t yices_lambda(uint32_t n, const term_t var[], term_t body);
/**********************************
* ARITHMETIC TERM CONSTRUCTORS *
*********************************/