-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwrap.jl
2807 lines (2186 loc) · 108 KB
/
wrap.jl
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
typealias Z3_symbol Ptr{Void}
typealias Z3_literals Ptr{Void}
typealias Z3_theory Ptr{Void}
typealias Z3_config Ptr{Void}
typealias Z3_context Ptr{Void}
typealias Z3_sort Ptr{Void}
typealias Z3_func_decl Ptr{Void}
typealias Z3_ast Ptr{Void}
typealias Z3_app Ptr{Void}
typealias Z3_pattern Ptr{Void}
typealias Z3_model Ptr{Void}
typealias Z3_constructor Ptr{Void}
typealias Z3_constructor_list Ptr{Void}
typealias Z3_params Ptr{Void}
typealias Z3_param_descrs Ptr{Void}
typealias Z3_goal Ptr{Void}
typealias Z3_tactic Ptr{Void}
typealias Z3_probe Ptr{Void}
typealias Z3_stats Ptr{Void}
typealias Z3_solver Ptr{Void}
typealias Z3_ast_vector Ptr{Void}
typealias Z3_ast_map Ptr{Void}
typealias Z3_apply_result Ptr{Void}
typealias Z3_func_interp Ptr{Void}
typealias Z3_func_entry Ptr{Void}
typealias Z3_fixedpoint Ptr{Void}
typealias Z3_rcf_num Ptr{Void}
typealias Z3_theory_data Ptr{Void} #Is actually a void ptr
## Function Typedefs
typealias Z3_reduce_eq_callback_fptr Ptr{Void}
typealias Z3_reduce_app_callback_fptr Ptr{Void}
typealias Z3_reduce_distinct_callback_fptr Ptr{Void}
typealias Z3_theory_callback_fptr Ptr{Void}
typealias Z3_theory_final_check_callback_fptr Ptr{Void}
typealias Z3_theory_ast_bool_callback_fptr Ptr{Void}
typealias Z3_theory_ast_ast_callback_fptr Ptr{Void}
typealias Z3_theory_ast_callback_fptr Ptr{Void}
# FIXME: Handle error handlers correctly
typealias Z3_error_handler Ptr{Void}
typealias Z3_fixedpoint_reduce_assign_callback_fptr Ptr{Void}
typealias Z3_fixedpoint_reduce_app_callback_fptr Ptr{Void}
typealias Z3_string Ptr{UInt8}
typealias Z3_string_ptr Ptr{Ptr{UInt8}}
typealias Z3_bool Cint
typealias Z3Bool Cint
## Wrapper Julia types
## ===================
## Pointer Types
typealias Z3SymbolPtr Ptr{Void}
typealias LiteralsPtr Ptr{Void}
typealias TheoryPtr Ptr{Void}
typealias ConfigPtr Ptr{Void}
typealias ContextPtr Ptr{Void}
typealias SortPtr Ptr{Void}
typealias FuncDeclPtr Ptr{Void}
typealias AstPtr Ptr{Void}
typealias AppPtr Ptr{Void}
typealias PatternPtr Ptr{Void}
typealias ModelPtr Ptr{Void}
typealias ConstructorPtr Ptr{Void}
typealias ConstructorListPtr Ptr{Void}
typealias ParamsPtr Ptr{Void}
typealias ParamDescrsPtr Ptr{Void}
typealias GoalPtr Ptr{Void}
typealias TacticPtr Ptr{Void}
typealias ProbePtr Ptr{Void}
typealias StatsPtr Ptr{Void}
typealias SolverPtr Ptr{Void}
typealias AstVectorPtr Ptr{Void}
typealias AstMapPtr Ptr{Void}
typealias ApplyResultPtr Ptr{Void}
typealias FuncInterpPtr Ptr{Void}
typealias FuncEntryPtr Ptr{Void}
typealias FixedpointPtr Ptr{Void}
typealias RcfNumPtr Ptr{Void}
typealias TheoryDataPtr Ptr{Void}
typealias ReduceEqCallbackFptrPtr Ptr{Void}
typealias ReduceAppCallbackFptrPtr Ptr{Void}
typealias ReduceDistinctCallbackFptrPtr Ptr{Void}
typealias TheoryCallbackFptrPtr Ptr{Void}
typealias TheoryFinalCheckCallbackFptrPtr Ptr{Void}
typealias TheoryAstBoolCallbackFptrPtr Ptr{Void}
typealias TheoryAstAstCallbackFptrPtr Ptr{Void}
typealias TheoryAstCallbackFptrPtr Ptr{Void}
typealias FixedpointReduceAssignCallbackFptrPtr Ptr{Void}
typealias FixedpointReduceAppCallbackFptrPtr Ptr{Void}
## Types from Z3
## =============
abstract Z3CType
## Sort types
## =========
abstract Sort <: Z3CType
convert(::Type{Sort}, x::Ptr{Void}) = UnknownSort(x)
type UnknownSort <: Sort
ptr::SortPtr
UnknownSort(ptr::SortPtr) = new(ptr)
end
type UninterpretedSort <: Sort
ptr::SortPtr
UninterpretedSort(ptr::SortPtr) = new(ptr)
end
type BoolSort <: Sort
ptr::SortPtr
BoolSort(ptr::SortPtr) = new(ptr)
end
type IntSort <: Sort
ptr::SortPtr
IntSort(ptr::SortPtr) = new(ptr)
end
type RealSort <: Sort
ptr::SortPtr
RealSort(ptr::SortPtr) = new(ptr)
end
type BitVectorSort{SZ} <: Sort
ptr::SortPtr
BitVectorSort() = new{SZ}(ptr)
end
type FiniteDomainSort <: Sort
ptr::SortPtr
FiniteDomainSort(ptr::SortPtr) = new(ptr)
end
type ArraySort <: Sort
ptr::SortPtr
ArraySort(ptr::SortPtr) = new(ptr)
end
type TupleSort <: Sort
ptr::SortPtr
TupleSort(ptr::SortPtr) = new(ptr)
end
type EnumerationSort <: Sort
ptr::SortPtr
EnumerationSort(ptr::SortPtr) = new(ptr)
end
type ListSort <: Sort
ptr::SortPtr
ListSort(ptr::SortPtr) = new(ptr)
end
type Z3Symbol <: Z3CType
ptr::Z3SymbolPtr
Z3Symbol(ptr::Z3SymbolPtr) = new(ptr)
end
type Literals <: Z3CType
ptr::LiteralsPtr
Literals(ptr::LiteralsPtr) = new(ptr)
end
type Theory <: Z3CType
ptr::TheoryPtr
Theory(ptr::TheoryPtr) = new(ptr)
end
type Config <: Z3CType
ptr::ConfigPtr
Config(ptr::ConfigPtr) = new(ptr)
end
type Context <: Z3CType
ptr::ContextPtr
Context(ptr::ContextPtr) = new(ptr)
end
type FuncDecl <: Z3CType
ptr::FuncDeclPtr
FuncDecl(ptr::FuncDeclPtr) = new(ptr)
end
## Ast types
# The issues with ASTS:
# We want ASTs to be interoperable with existing functions, such that
# if someone has written f(x::Number) they can use f with a variable of numerical type
# OTOH we like f(x::ArrayAst) to cause an error
# On the other hand we would like some functions, in particular these low level
# wrapperst to accept only ASTS (and not numbers).
# Also for asts which represent variables we have a sort/type that we want
# represented in the type of the variable.
# Lastly there are expressions of different type that we would like to be
# subtypes of different types of real, e.g an Integer is not a type of Floating.
# Solution
# - CCall AST files return (UnknownAst / Ast)
# - VarAst{T <: MathNumber}, e.g. Var{Real} is not right because you can make a variable of any sort, including tuple and array nad mayve defined ine there
# VarAst{T <: Sort} <: .. Then we can't write functions
# NumericalVarAst{T <: MathNumber} <: Real -- What about Integer
## AST Solution
# 1. Make them all subset of the Real
# 2. Make them subset of individual type and use unions to group them
typealias MathNumber Union{Real, Integer, Bool}
type Ast <: Z3CType ptr::AstPtr end
"numeral constants"
type NumeralAst{T <: MathNumber} <: Real
ptr::Z3_ast
end
"(fuction?) application"
type AppAst{T} <: Real
ptr::Z3_ast
end
"(fuction?) application resulting in real valued variable"
type RealAppAst{T <: MathNumber} <: Real
ptr::Z3_ast
end
"bound variables of type `T`"
type VarAst{T}
ptr::Z3_ast
end
"Real Valued Variable of numeric type `T`"
type RealVarAst{T <: MathNumber} <: Real
ptr::Z3_ast
end
"quantifiers"
type QuantifierAst
ptr::Z3_ast
end
"sort"
type SortAst
ptr::Z3_ast
end
"function declaration"
type FuncDeclAst
ptr::Z3_ast
end
"internal"
type UnknownAst
ptr::Z3_ast
end
## ArrayAst
"Array{DomainSort, RangeSort}"
type ArrayAst{D, R}
ptr::Z3_ast
ArrayAst(ptr::Z3_ast) = new{R,D}(ptr)
ArrayAst(ast::Ast) = new{R,D}(ast.ptr)
end
AbstractAst = Union{Ast, AppAst, VarAst, RealVarAst, QuantifierAst, SortAst, FuncDeclAst, NumeralAst, UnknownAst}
convert(::Type{AbstractAst}, x::Ptr{Void}) = Ast(x)
convert{T <: AbstractAst}(::Type{Ptr{Void}}, x::T) = x.ptr
convert{T <: AbstractAst}(::Type{T}, x::AbstractAst) = T(x.ptr)
type App <: Z3CType ptr::AppPtr end
type Pattern <: Z3CType ptr::PatternPtr end
type Model <: Z3CType ptr::ModelPtr end
type Constructor <: Z3CType ptr::ConstructorPtr end
type ConstructorList <: Z3CType ptr::ConstructorListPtr end
type Params <: Z3CType ptr::ParamsPtr end
type ParamDescrs <: Z3CType ptr::ParamDescrsPtr end
type Goal <: Z3CType ptr::GoalPtr end
type Tactic <: Z3CType ptr::TacticPtr end
type Probe <: Z3CType ptr::ProbePtr end
type Stats <: Z3CType ptr::StatsPtr end
type Solver <: Z3CType ptr::SolverPtr end
type AstVector <: Z3CType ptr::AstVectorPtr end
type AstMap <: Z3CType ptr::AstMapPtr end
type ApplyResult <: Z3CType ptr::ApplyResultPtr end
type FuncInterp <: Z3CType ptr::FuncInterpPtr end
type FuncEntry <: Z3CType ptr::FuncEntryPtr end
type Fixedpoint <: Z3CType ptr::FixedpointPtr end
type RcfNum <: Z3CType ptr::RcfNumPtr end
type TheoryData <: Z3CType ptr::TheoryDataPtr end #Is actually a void ptr
## Function Typedefs
type ReduceEqCallbackFptr <: Z3CType ptr::ReduceEqCallbackFptrPtr end
type ReduceAppCallbackFptr <: Z3CType ptr::ReduceAppCallbackFptrPtr end
type ReduceDistinctCallbackFptr <: Z3CType ptr::ReduceDistinctCallbackFptrPtr end
type TheoryCallbackFptr <: Z3CType ptr::TheoryCallbackFptrPtr end
type TheoryFinalCheckCallbackFptr <: Z3CType ptr::TheoryFinalCheckCallbackFptrPtr end
type TheoryAstBoolCallbackFptr <: Z3CType ptr::TheoryAstBoolCallbackFptrPtr end
type TheoryAstAstCallbackFptr <: Z3CType ptr::TheoryAstAstCallbackFptrPtr end
type TheoryAstCallbackFptr <: Z3CType ptr::TheoryAstCallbackFptrPtr end
type FixedpointReduceAssignCallbackFptr <: Z3CType ptr::FixedpointReduceAssignCallbackFptrPtr end
type FixedpointReduceAppCallbackFptr <: Z3CType ptr::FixedpointReduceAppCallbackFptrPtr end
## arg/return type Conversion
## ==========================
convert(::Type{Ptr{Void}}, x::Z3CType) = x.ptr
convert(::Type{Z3_string}, x::ASCIIString) = pointer(x)
#FIME: Vector is too loose of a type, should be Vector{T<:AbstractAst}
convert(::Type{Ptr{Z3_ast}}, x::Vector) = pointer(Ptr{Void}[a.ptr for a in x])
convert{T<:Z3CType}(::Type{T}, x::Ptr{Void}) = T(x)
convert(::Type{ASCIIString}, x::Z3_string) = bytestring(x)
## Enums
## =====
# "Lifted Boolean type: \c false, \c undefined, \c true."
@enum Z3_lbool Z3_L_FALSE = -1 Z3_L_UNDEF Z3_L_TRUE
# """The different kinds of symbol.
# In Z3, a symbol can be represented using integers and strings"""
@enum Z3_symbol_kind Z3_INT_SYMBOL Z3_STRING_SYMBOL
@enum Z3_parameter_kind Z3_PARAMETER_INT Z3_PARAMETER_DOUBLE Z3_PARAMETER_RATIONAL Z3_PARAMETER_SYMBOL Z3_PARAMETER_SORT Z3_PARAMETER_AST Z3_PARAMETER_FUNC_DECL
# "The different kinds of Z3 types"
@enum Z3_sort_kind Z3_UNINTERPRETED_SORT Z3_BOOL_SORT Z3_INT_SORT Z3_REAL_SORT Z3_BV_SORT Z3_ARRAY_SORT Z3_DATATYPE_SORT Z3_RELATION_SORT Z3_FINITE_DOMAIN_SORT Z3_UNKNOWN_SORT = 1000
# "The different kinds of Z3 AST (abstract syntax trees). That is, terms, formulas and types."
@enum Z3_ast_kind Z3_NUMERAL_AST Z3_APP_AST Z3_VAR_AST Z3_QUANTIFIER_AST Z3_SORT_AST Z3_FUNC_DECL_AST Z3_UNKNOWN_AST = 1000
# "The different kinds of interpreted function kinds."
@enum(Z3_decl_kind,
# Basic
Z3_OP_TRUE = 0x100,
Z3_OP_FALSE,
Z3_OP_EQ,
Z3_OP_DISTINCT,
Z3_OP_ITE,
Z3_OP_AND,
Z3_OP_OR,
Z3_OP_IFF,
Z3_OP_XOR,
Z3_OP_NOT,
Z3_OP_IMPLIES,
Z3_OP_OEQ,
Z3_OP_INTERP,
# Arithmetic
Z3_OP_ANUM = 0x200,
Z3_OP_AGNUM,
Z3_OP_LE,
Z3_OP_GE,
Z3_OP_LT,
Z3_OP_GT,
Z3_OP_ADD,
Z3_OP_SUB,
Z3_OP_UMINUS,
Z3_OP_MUL,
Z3_OP_DIV,
Z3_OP_IDIV,
Z3_OP_REM,
Z3_OP_MOD,
Z3_OP_TO_REAL,
Z3_OP_TO_INT,
Z3_OP_IS_INT,
Z3_OP_POWER,
# Arrays & Sets
Z3_OP_STORE = 0x300,
Z3_OP_SELECT,
Z3_OP_CONST_ARRAY,
Z3_OP_ARRAY_MAP,
Z3_OP_ARRAY_DEFAULT,
Z3_OP_SET_UNION,
Z3_OP_SET_INTERSECT,
Z3_OP_SET_DIFFERENCE,
Z3_OP_SET_COMPLEMENT,
Z3_OP_SET_SUBSET,
Z3_OP_AS_ARRAY,
# Bit-vectors
Z3_OP_BNUM = 0x400,
Z3_OP_BIT1,
Z3_OP_BIT0,
Z3_OP_BNEG,
Z3_OP_BADD,
Z3_OP_BSUB,
Z3_OP_BMUL,
Z3_OP_BSDIV,
Z3_OP_BUDIV,
Z3_OP_BSREM,
Z3_OP_BUREM,
Z3_OP_BSMOD,
# special functions to record the division by 0 cases
# these are internal functions
Z3_OP_BSDIV0,
Z3_OP_BUDIV0,
Z3_OP_BSREM0,
Z3_OP_BUREM0,
Z3_OP_BSMOD0,
Z3_OP_ULEQ,
Z3_OP_SLEQ,
Z3_OP_UGEQ,
Z3_OP_SGEQ,
Z3_OP_ULT,
Z3_OP_SLT,
Z3_OP_UGT,
Z3_OP_SGT,
Z3_OP_BAND,
Z3_OP_BOR,
Z3_OP_BNOT,
Z3_OP_BXOR,
Z3_OP_BNAND,
Z3_OP_BNOR,
Z3_OP_BXNOR,
Z3_OP_CONCAT,
Z3_OP_SIGN_EXT,
Z3_OP_ZERO_EXT,
Z3_OP_EXTRACT,
Z3_OP_REPEAT,
Z3_OP_BREDOR,
Z3_OP_BREDAND,
Z3_OP_BCOMP,
Z3_OP_BSHL,
Z3_OP_BLSHR,
Z3_OP_BASHR,
Z3_OP_ROTATE_LEFT,
Z3_OP_ROTATE_RIGHT,
Z3_OP_EXT_ROTATE_LEFT,
Z3_OP_EXT_ROTATE_RIGHT,
Z3_OP_INT2BV,
Z3_OP_BV2INT,
Z3_OP_CARRY,
Z3_OP_XOR3,
# Proofs
Z3_OP_PR_UNDEF = 0x500,
Z3_OP_PR_TRUE,
Z3_OP_PR_ASSERTED,
Z3_OP_PR_GOAL,
Z3_OP_PR_MODUS_PONENS,
Z3_OP_PR_REFLEXIVITY,
Z3_OP_PR_SYMMETRY,
Z3_OP_PR_TRANSITIVITY,
Z3_OP_PR_TRANSITIVITY_STAR,
Z3_OP_PR_MONOTONICITY,
Z3_OP_PR_QUANT_INTRO,
Z3_OP_PR_DISTRIBUTIVITY,
Z3_OP_PR_AND_ELIM,
Z3_OP_PR_NOT_OR_ELIM,
Z3_OP_PR_REWRITE,
Z3_OP_PR_REWRITE_STAR,
Z3_OP_PR_PULL_QUANT,
Z3_OP_PR_PULL_QUANT_STAR,
Z3_OP_PR_PUSH_QUANT,
Z3_OP_PR_ELIM_UNUSED_VARS,
Z3_OP_PR_DER,
Z3_OP_PR_QUANT_INST,
Z3_OP_PR_HYPOTHESIS,
Z3_OP_PR_LEMMA,
Z3_OP_PR_UNIT_RESOLUTION,
Z3_OP_PR_IFF_TRUE,
Z3_OP_PR_IFF_FALSE,
Z3_OP_PR_COMMUTATIVITY,
Z3_OP_PR_DEF_AXIOM,
Z3_OP_PR_DEF_INTRO,
Z3_OP_PR_APPLY_DEF,
Z3_OP_PR_IFF_OEQ,
Z3_OP_PR_NNF_POS,
Z3_OP_PR_NNF_NEG,
Z3_OP_PR_NNF_STAR,
Z3_OP_PR_CNF_STAR,
Z3_OP_PR_SKOLEMIZE,
Z3_OP_PR_MODUS_PONENS_OEQ,
Z3_OP_PR_TH_LEMMA,
Z3_OP_PR_HYPER_RESOLVE,
# Sequences
Z3_OP_RA_STORE = 0x600,
Z3_OP_RA_EMPTY,
Z3_OP_RA_IS_EMPTY,
Z3_OP_RA_JOIN,
Z3_OP_RA_UNION,
Z3_OP_RA_WIDEN,
Z3_OP_RA_PROJECT,
Z3_OP_RA_FILTER,
Z3_OP_RA_NEGATION_FILTER,
Z3_OP_RA_RENAME,
Z3_OP_RA_COMPLEMENT,
Z3_OP_RA_SELECT,
Z3_OP_RA_CLONE,
Z3_OP_FD_LT,
# Auxiliary
Z3_OP_LABEL = 0x700,
Z3_OP_LABEL_LIT,
# Datatypes
Z3_OP_DT_CONSTRUCTOR=0x800,
Z3_OP_DT_RECOGNISER,
Z3_OP_DT_ACCESSOR,
Z3_OP_UNINTERPRETED)
# "The different kinds of parameters that can be associated with parameter sets."
@enum(Z3_param_kind,
Z3_PK_UINT,
Z3_PK_BOOL,
Z3_PK_DOUBLE,
Z3_PK_SYMBOL,
Z3_PK_STRING,
Z3_PK_OTHER,
Z3_PK_INVALID)
# "The different kinds of search failure types."
@enum(Z3_search_failure,
Z3_NO_FAILURE,
Z3_UNKNOWN,
Z3_TIMEOUT,
Z3_MEMOUT_WATERMARK,
Z3_CANCELED,
Z3_NUM_CONFLICTS,
Z3_THEORY,
Z3_QUANTIFIERS)
# "Z3 pretty printing modes (See #Z3_set_ast_print_mode)."
@enum(Z3_ast_print_mode,
Z3_PRINT_SMTLIB_FULL,
Z3_PRINT_LOW_LEVEL,
Z3_PRINT_SMTLIB_COMPLIANT,
Z3_PRINT_SMTLIB2_COMPLIANT)
@enum(Z3_ast_print_mode,
Z3_PRINT_SMTLIB_FULL,
Z3_PRINT_LOW_LEVEL,
Z3_PRINT_SMTLIB_COMPLIANT,
Z3_PRINT_SMTLIB2_COMPLIANT)
@enum(Z3_error_code,
Z3_OK,
Z3_SORT_ERROR,
Z3_IOB,
Z3_INVALID_ARG,
Z3_PARSER_ERROR,
Z3_NO_PARSER,
Z3_INVALID_PATTERN,
Z3_MEMOUT_FAIL,
Z3_FILE_ACCESS_ERROR,
Z3_INTERNAL_FATAL,
Z3_INVALID_USAGE,
Z3_DEC_REF_ERROR,
Z3_EXCEPTION)
@enum(Z3_goal_prec,
Z3_GOAL_PRECISE,
Z3_GOAL_UNDER,
Z3_GOAL_OVER,
Z3_GOAL_UNDER_OVER)
## Enum Conversion
#FIXME, make this more general
# convert(::)
## Macros
## ======
z3tojulia = Dict{Symbol, Symbol}(:Z3_symbol => :Z3Symbol,
:Z3_literals => :Literals,
:Z3_theory => :Theory,
:Z3_config => :Config,
:Z3_context => :Context,
:Z3_sort => :Sort, #Assume we don't known what sort it is
:Z3_func_decl => :FuncDecl,
:Z3_ast => :AbstractAst, # Many kinds of Ast
:Z3_app => :App,
:Z3_pattern => :Pattern,
:Z3_model => :Model,
:Z3_constructor => :Constructor,
:Z3_constructor_list => :ConstructorList,
:Z3_params => :Params,
:Z3_param_descrs => :ParamDescrs,
:Z3_goal => :Goal,
:Z3_tactic => :Tactic,
:Z3_probe => :Probe,
:Z3_stats => :Stats,
:Z3_solver => :Solver,
:Z3_ast_vector => :AstVector,
:Z3_ast_map => :AstMap,
:Z3_apply_result => :ApplyResult,
:Z3_func_interp => :FuncInterp,
:Z3_func_entry => :FuncEntry,
:Z3_fixedpoint => :Fixedpoint,
:Z3_rcf_num => :RcfNum,
:Z3_theory_data => :TheoryData,
:Z3_reduce_eq_callback_fptr => :ReduceEqCallbackFptr,
:Z3_reduce_app_callback_fptr => :ReduceAppCallbackFptr,
:Z3_reduce_distinct_callback_fptr => :ReduceDistinctCallbackFptr,
:Z3_theory_callback_fptr => :TheoryCallbackFptr,
:Z3_theory_final_check_callback_fptr => :TheoryFinalCheckCallbackFptr,
:Z3_theory_ast_bool_callback_fptr => :TheoryAstBoolCallbackFptr,
:Z3_theory_ast_ast_callback_fptr => :TheoryAstAstCallbackFptr,
:Z3_theory_ast_callback_fptr => :TheoryAstCallbackFptr,
:Z3_bool => :Z3Bool,
:Z3_error_handler => :FixedpointReduceAssignCallbackFptr,
:Z3_fixedpoint_reduce_assign_callback_fptr => :FixedpointReduceAssignCallbackFptr,
:Z3_fixedpoint_reduce_app_callback_fptr => :FixedpointReduceAppCallbackFptr)
arg_name(arg::Expr) = arg.args[1]::Symbol
arg_type(arg::Expr) = arg.args[2]
"Maps Z3 typealias symbols to corresponding Julia types"
function convert_typ(typ::Union{Symbol, Expr})
if typ == :(Z3_string)
:ASCIIString
elseif typ == :(Ptr{Z3_ast})
:(Vector)
elseif haskey(z3tojulia, typ)
z3tojulia[typ]
else
typ
end
end
"Maps Z3 typealias symbols to corresponding Julia types"
function convert_arg(arg::Expr)
typ = arg_type(arg)
name = arg_name(arg)
new_typ = convert_typ(typ)
Expr(:(::), arg_name(arg), new_typ)
end
function handle_call(arg::Expr)
typ = arg_type(arg)
name = arg_name(arg)
:(convert($typ, $name))
end
"""For a z3 ccall wrapper function (below), `wrap` creates an additional function
which accepts the Julia wrapper types and does necessary conversions"""
macro wrap(func_def)
# FIXME: finding return_type in this way is very brittle
return_type = func_def.args[2].args[2].args[2]
name = func_def.args[1].args[1]
@compat short_name = Symbol(string(name)[4:end])
func_args = func_def.args[1].args[2:end]
new_return_typ = convert_typ(return_type)
converted_args = [convert_arg(arg) for arg in func_args]
params = Expr(:call, short_name, converted_args...)
api_call = Expr(:call, name, [handle_call(arg) for arg in func_args]...)
wrapped_call = Expr(:call, :convert, new_return_typ, api_call)
func_decl = Expr(:function, params, wrapped_call)
# If first arg is ctx, make a kwarg version of the function
if length(func_args) > 0 && arg_type(func_args[1]) == :(Z3_context)
kw_params = Expr(:parameters, Expr(:kw, Expr(:(::), :ctx, :Context), Expr(:call, :global_ctx)))
kw_params2 = Expr(:call, short_name, kw_params, converted_args[2:end]...)
kw_decl = Expr(:function, kw_params2, wrapped_call)
esc(func_def)
:(begin
$(esc(func_def))
$(esc(func_decl))
$(esc(kw_decl))
export $short_name
end)
else
esc(func_def)
:(begin
$(esc(func_def))
$(esc(func_decl))
export $short_name
end)
end
end
## functions
## =========
function Z3_global_param_set(param_id::Z3_string,param_value::Z3_string)
ccall((:Z3_global_param_set,"libz3"),Void,(Z3_string,Z3_string),param_id,param_value)
end
@wrap function Z3_global_param_reset_all()
ccall((:Z3_global_param_reset_all,"libz3"),Void,())
end
@wrap function Z3_global_param_get(param_id::Z3_string,param_value::Z3_string_ptr)
ccall((:Z3_global_param_get,"libz3"),Z3_bool,(Z3_string,Z3_string_ptr),param_id,param_value)
end
@wrap function Z3_mk_config()
ccall((:Z3_mk_config,"libz3"),Z3_config,())
end
@wrap function Z3_del_config(c::Z3_config)
ccall((:Z3_del_config,"libz3"),Void,(Z3_config,),c)
end
@wrap function Z3_set_param_value(c::Z3_config,param_id::Z3_string,param_value::Z3_string)
ccall((:Z3_set_param_value,"libz3"),Void,(Z3_config,Z3_string,Z3_string),c,param_id,param_value)
end
@wrap function Z3_mk_context(c::Z3_config)
ccall((:Z3_mk_context,"libz3"),Z3_context,(Z3_config,),c)
end
@wrap function Z3_mk_context_rc(c::Z3_config)
ccall((:Z3_mk_context_rc,"libz3"),Z3_context,(Z3_config,),c)
end
@wrap function Z3_del_context(ctx::Z3_context)
ccall((:Z3_del_context,"libz3"),Void,(Z3_context,),ctx)
end
@wrap function Z3_inc_ref(ctx::Z3_context,a::Z3_ast)
ccall((:Z3_inc_ref,"libz3"),Void,(Z3_context,Z3_ast),ctx,a)
end
@wrap function Z3_dec_ref(ctx::Z3_context,a::Z3_ast)
ccall((:Z3_dec_ref,"libz3"),Void,(Z3_context,Z3_ast),ctx,a)
end
@wrap function Z3_update_param_value(ctx::Z3_context,param_id::Z3_string,param_value::Z3_string)
ccall((:Z3_update_param_value,"libz3"),Void,(Z3_context,Z3_string,Z3_string),ctx,param_id,param_value)
end
@wrap function Z3_interrupt(ctx::Z3_context)
ccall((:Z3_interrupt,"libz3"),Void,(Z3_context,),ctx)
end
@wrap function Z3_mk_params(ctx::Z3_context)
ccall((:Z3_mk_params,"libz3"),Z3_params,(Z3_context,),ctx)
end
@wrap function Z3_params_inc_ref(ctx::Z3_context,p::Z3_params)
ccall((:Z3_params_inc_ref,"libz3"),Void,(Z3_context,Z3_params),ctx,p)
end
@wrap function Z3_params_dec_ref(ctx::Z3_context,p::Z3_params)
ccall((:Z3_params_dec_ref,"libz3"),Void,(Z3_context,Z3_params),ctx,p)
end
@wrap function Z3_params_set_bool(ctx::Z3_context,p::Z3_params,k::Z3_symbol,v::Z3_bool)
ccall((:Z3_params_set_bool,"libz3"),Void,(Z3_context,Z3_params,Z3_symbol,Z3_bool),ctx,p,k,v)
end
@wrap function Z3_params_set_uint(ctx::Z3_context,p::Z3_params,k::Z3_symbol,v::UInt32)
ccall((:Z3_params_set_uint,"libz3"),Void,(Z3_context,Z3_params,Z3_symbol,UInt32),ctx,p,k,v)
end
@wrap function Z3_params_set_double(ctx::Z3_context,p::Z3_params,k::Z3_symbol,v::Cdouble)
ccall((:Z3_params_set_double,"libz3"),Void,(Z3_context,Z3_params,Z3_symbol,Cdouble),ctx,p,k,v)
end
@wrap function Z3_params_set_symbol(ctx::Z3_context,p::Z3_params,k::Z3_symbol,v::Z3_symbol)
ccall((:Z3_params_set_symbol,"libz3"),Void,(Z3_context,Z3_params,Z3_symbol,Z3_symbol),ctx,p,k,v)
end
@wrap function Z3_params_to_string(ctx::Z3_context,p::Z3_params)
ccall((:Z3_params_to_string,"libz3"),Z3_string,(Z3_context,Z3_params),ctx,p)
end
@wrap function Z3_params_validate(ctx::Z3_context,p::Z3_params,d::Z3_param_descrs)
ccall((:Z3_params_validate,"libz3"),Void,(Z3_context,Z3_params,Z3_param_descrs),ctx,p,d)
end
@wrap function Z3_param_descrs_inc_ref(ctx::Z3_context,p::Z3_param_descrs)
ccall((:Z3_param_descrs_inc_ref,"libz3"),Void,(Z3_context,Z3_param_descrs),ctx,p)
end
@wrap function Z3_param_descrs_dec_ref(ctx::Z3_context,p::Z3_param_descrs)
ccall((:Z3_param_descrs_dec_ref,"libz3"),Void,(Z3_context,Z3_param_descrs),ctx,p)
end
@wrap function Z3_param_descrs_get_kind(ctx::Z3_context,p::Z3_param_descrs,n::Z3_symbol)
ccall((:Z3_param_descrs_get_kind,"libz3"),Z3_param_kind,(Z3_context,Z3_param_descrs,Z3_symbol),ctx,p,n)
end
@wrap function Z3_param_descrs_size(ctx::Z3_context,p::Z3_param_descrs)
ccall((:Z3_param_descrs_size,"libz3"),UInt32,(Z3_context,Z3_param_descrs),ctx,p)
end
@wrap function Z3_param_descrs_get_name(ctx::Z3_context,p::Z3_param_descrs,i::UInt32)
ccall((:Z3_param_descrs_get_name,"libz3"),Z3_symbol,(Z3_context,Z3_param_descrs,UInt32),ctx,p,i)
end
@wrap function Z3_param_descrs_to_string(ctx::Z3_context,p::Z3_param_descrs)
ccall((:Z3_param_descrs_to_string,"libz3"),Z3_string,(Z3_context,Z3_param_descrs),ctx,p)
end
@wrap function Z3_mk_int_symbol(ctx::Z3_context,i::Cint)
ccall((:Z3_mk_int_symbol,"libz3"),Z3_symbol,(Z3_context,Cint),ctx,i)
end
@wrap function Z3_mk_string_symbol(ctx::Z3_context,s::Z3_string)
ccall((:Z3_mk_string_symbol,"libz3"),Z3_symbol,(Z3_context,Z3_string),ctx,s)
end
@wrap function Z3_mk_uninterpreted_sort(ctx::Z3_context,s::Z3_symbol)
ccall((:Z3_mk_uninterpreted_sort,"libz3"),Z3_sort,(Z3_context,Z3_symbol),ctx,s)
end
@wrap function Z3_mk_bool_sort(ctx::Z3_context)
ccall((:Z3_mk_bool_sort,"libz3"),Z3_sort,(Z3_context,),ctx)
end
@wrap function Z3_mk_int_sort(ctx::Z3_context)
ccall((:Z3_mk_int_sort,"libz3"),Z3_sort,(Z3_context,),ctx)
end
@wrap function Z3_mk_real_sort(ctx::Z3_context)
ccall((:Z3_mk_real_sort,"libz3"),Z3_sort,(Z3_context,),ctx)
end
@wrap function Z3_mk_bv_sort(ctx::Z3_context,sz::UInt32)
ccall((:Z3_mk_bv_sort,"libz3"),Z3_sort,(Z3_context,UInt32),ctx,sz)
end
@wrap function Z3_mk_finite_domain_sort(ctx::Z3_context,name::Z3_symbol,size::Culonglong)
ccall((:Z3_mk_finite_domain_sort,"libz3"),Z3_sort,(Z3_context,Z3_symbol,Culonglong),ctx,name,size)
end
@wrap function Z3_mk_array_sort(ctx::Z3_context,domain::Z3_sort,range::Z3_sort)
ccall((:Z3_mk_array_sort,"libz3"),Z3_sort,(Z3_context,Z3_sort,Z3_sort),ctx,domain,range)
end
@wrap function Z3_mk_tuple_sort(ctx::Z3_context,mk_tuple_name::Z3_symbol,num_fields::UInt32,field_names::Ptr{Z3_symbol},field_sorts::Ptr{Z3_sort},mk_tuple_decl::Ptr{Z3_func_decl},proj_decl::Ptr{Z3_func_decl})
ccall((:Z3_mk_tuple_sort,"libz3"),Z3_sort,(Z3_context,Z3_symbol,UInt32,Ptr{Z3_symbol},Ptr{Z3_sort},Ptr{Z3_func_decl},Ptr{Z3_func_decl}),ctx,mk_tuple_name,num_fields,field_names,field_sorts,mk_tuple_decl,proj_decl)
end
@wrap function Z3_mk_enumeration_sort(ctx::Z3_context,name::Z3_symbol,n::UInt32,enum_names::Ptr{Z3_symbol},enum_consts::Ptr{Z3_func_decl},enum_testers::Ptr{Z3_func_decl})
ccall((:Z3_mk_enumeration_sort,"libz3"),Z3_sort,(Z3_context,Z3_symbol,UInt32,Ptr{Z3_symbol},Ptr{Z3_func_decl},Ptr{Z3_func_decl}),ctx,name,n,enum_names,enum_consts,enum_testers)
end
@wrap function Z3_mk_list_sort(ctx::Z3_context,name::Z3_symbol,elem_sort::Z3_sort,nil_decl::Ptr{Z3_func_decl},is_nil_decl::Ptr{Z3_func_decl},ctxons_decl::Ptr{Z3_func_decl},is_cons_decl::Ptr{Z3_func_decl},head_decl::Ptr{Z3_func_decl},tail_decl::Ptr{Z3_func_decl})
ccall((:Z3_mk_list_sort,"libz3"),Z3_sort,(Z3_context,Z3_symbol,Z3_sort,Ptr{Z3_func_decl},Ptr{Z3_func_decl},Ptr{Z3_func_decl},Ptr{Z3_func_decl},Ptr{Z3_func_decl},Ptr{Z3_func_decl}),ctx,name,elem_sort,nil_decl,is_nil_decl,ctxons_decl,is_cons_decl,head_decl,tail_decl)
end
@wrap function Z3_mk_constructor(ctx::Z3_context,name::Z3_symbol,recognizer::Z3_symbol,num_fields::UInt32,field_names::Ptr{Z3_symbol},sorts::Ptr{Z3_sort},sort_refs::Ref{UInt32})
ccall((:Z3_mk_constructor,"libz3"),Z3_constructor,(Z3_context,Z3_symbol,Z3_symbol,UInt32,Ptr{Z3_symbol},Ptr{Z3_sort},Ref{UInt32}),ctx,name,recognizer,num_fields,field_names,sorts,sort_refs)
end
@wrap function Z3_del_constructor(ctx::Z3_context,ctxonstr::Z3_constructor)
ccall((:Z3_del_constructor,"libz3"),Void,(Z3_context,Z3_constructor),ctx,ctxonstr)
end
@wrap function Z3_mk_datatype(ctx::Z3_context,name::Z3_symbol,num_constructors::UInt32,ctxonstructors::Ptr{Z3_constructor})
ccall((:Z3_mk_datatype,"libz3"),Z3_sort,(Z3_context,Z3_symbol,UInt32,Ptr{Z3_constructor}),ctx,name,num_constructors,ctxonstructors)
end
@wrap function Z3_mk_constructor_list(ctx::Z3_context,num_constructors::UInt32,ctxonstructors::Ptr{Z3_constructor})
ccall((:Z3_mk_constructor_list,"libz3"),Z3_constructor_list,(Z3_context,UInt32,Ptr{Z3_constructor}),ctx,num_constructors,ctxonstructors)
end
@wrap function Z3_del_constructor_list(ctx::Z3_context,ctxlist::Z3_constructor_list)
ccall((:Z3_del_constructor_list,"libz3"),Void,(Z3_context,Z3_constructor_list),ctx,ctxlist)
end
@wrap function Z3_mk_datatypes(ctx::Z3_context,num_sorts::UInt32,sort_names::Ptr{Z3_symbol},sorts::Ptr{Z3_sort},ctxonstructor_lists::Ptr{Z3_constructor_list})
ccall((:Z3_mk_datatypes,"libz3"),Void,(Z3_context,UInt32,Ptr{Z3_symbol},Ptr{Z3_sort},Ptr{Z3_constructor_list}),ctx,num_sorts,sort_names,sorts,ctxonstructor_lists)
end
@wrap function Z3_query_constructor(ctx::Z3_context,ctxonstr::Z3_constructor,num_fields::UInt32,ctxonstructor::Ptr{Z3_func_decl},tester::Ptr{Z3_func_decl},accessors::Ptr{Z3_func_decl})
ccall((:Z3_query_constructor,"libz3"),Void,(Z3_context,Z3_constructor,UInt32,Ptr{Z3_func_decl},Ptr{Z3_func_decl},Ptr{Z3_func_decl}),ctx,ctxonstr,num_fields,ctxonstructor,tester,accessors)
end
@wrap function Z3_mk_func_decl(ctx::Z3_context,s::Z3_symbol,domain_size::UInt32,domain::Ptr{Z3_sort},range::Z3_sort)
ccall((:Z3_mk_func_decl,"libz3"),Z3_func_decl,(Z3_context,Z3_symbol,UInt32,Ptr{Z3_sort},Z3_sort),ctx,s,domain_size,domain,range)
end
@wrap function Z3_mk_app(ctx::Z3_context,d::Z3_func_decl,num_args::UInt32,args::Ptr{Z3_ast})
ccall((:Z3_mk_app,"libz3"),Z3_ast,(Z3_context,Z3_func_decl,UInt32,Ptr{Z3_ast}),ctx,d,num_args,args)
end
@wrap function Z3_mk_const(ctx::Z3_context,s::Z3_symbol,ty::Z3_sort)
ccall((:Z3_mk_const,"libz3"),Z3_ast,(Z3_context,Z3_symbol,Z3_sort),ctx,s,ty)
end
@wrap function Z3_mk_fresh_func_decl(ctx::Z3_context,prefix::Z3_string,domain_size::UInt32,domain::Ptr{Z3_sort},range::Z3_sort)
ccall((:Z3_mk_fresh_func_decl,"libz3"),Z3_func_decl,(Z3_context,Z3_string,UInt32,Ptr{Z3_sort},Z3_sort),ctx,prefix,domain_size,domain,range)
end
@wrap function Z3_mk_fresh_const(ctx::Z3_context,prefix::Z3_string,ty::Z3_sort)
ccall((:Z3_mk_fresh_const,"libz3"),Z3_ast,(Z3_context,Z3_string,Z3_sort),ctx,prefix,ty)
end
@wrap function Z3_mk_true(ctx::Z3_context)
ccall((:Z3_mk_true,"libz3"),Z3_ast,(Z3_context,),ctx)
end
@wrap function Z3_mk_false(ctx::Z3_context)
ccall((:Z3_mk_false,"libz3"),Z3_ast,(Z3_context,),ctx)
end
@wrap function Z3_mk_eq(ctx::Z3_context,l::Z3_ast,r::Z3_ast)
ccall((:Z3_mk_eq,"libz3"),Z3_ast,(Z3_context,Z3_ast,Z3_ast),ctx,l,r)
end
@wrap function Z3_mk_distinct(ctx::Z3_context,num_args::UInt32,args::Ptr{Z3_ast})
ccall((:Z3_mk_distinct,"libz3"),Z3_ast,(Z3_context,UInt32,Ptr{Z3_ast}),ctx,num_args,args)
end
@wrap function Z3_mk_not(ctx::Z3_context,a::Z3_ast)
ccall((:Z3_mk_not,"libz3"),Z3_ast,(Z3_context,Z3_ast),ctx,a)
end
@wrap function Z3_mk_ite(ctx::Z3_context,t1::Z3_ast,t2::Z3_ast,t3::Z3_ast)
ccall((:Z3_mk_ite,"libz3"),Z3_ast,(Z3_context,Z3_ast,Z3_ast,Z3_ast),ctx,t1,t2,t3)
end
@wrap function Z3_mk_iff(ctx::Z3_context,t1::Z3_ast,t2::Z3_ast)
ccall((:Z3_mk_iff,"libz3"),Z3_ast,(Z3_context,Z3_ast,Z3_ast),ctx,t1,t2)
end
@wrap function Z3_mk_implies(ctx::Z3_context,t1::Z3_ast,t2::Z3_ast)
ccall((:Z3_mk_implies,"libz3"),Z3_ast,(Z3_context,Z3_ast,Z3_ast),ctx,t1,t2)
end
@wrap function Z3_mk_xor(ctx::Z3_context,t1::Z3_ast,t2::Z3_ast)
ccall((:Z3_mk_xor,"libz3"),Z3_ast,(Z3_context,Z3_ast,Z3_ast),ctx,t1,t2)
end
@wrap function Z3_mk_and(ctx::Z3_context,num_args::UInt32,args::Ptr{Z3_ast})
ccall((:Z3_mk_and,"libz3"),Z3_ast,(Z3_context,UInt32,Ptr{Z3_ast}),ctx,num_args,args)
end
@wrap function Z3_mk_or(ctx::Z3_context,num_args::UInt32,args::Ptr{Z3_ast})
ccall((:Z3_mk_or,"libz3"),Z3_ast,(Z3_context,UInt32,Ptr{Z3_ast}),ctx,num_args,args)
end
@wrap function Z3_mk_add(ctx::Z3_context,num_args::UInt32,args::Ptr{Z3_ast})
ccall((:Z3_mk_add,"libz3"),Z3_ast,(Z3_context,UInt32,Ptr{Z3_ast}),ctx,num_args,args)
end
@wrap function Z3_mk_mul(ctx::Z3_context,num_args::UInt32,args::Ptr{Z3_ast})
ccall((:Z3_mk_mul,"libz3"),Z3_ast,(Z3_context,UInt32,Ptr{Z3_ast}),ctx,num_args,args)
end
@wrap function Z3_mk_sub(ctx::Z3_context,num_args::UInt32,args::Ptr{Z3_ast})
ccall((:Z3_mk_sub,"libz3"),Z3_ast,(Z3_context,UInt32,Ptr{Z3_ast}),ctx,num_args,args)
end
@wrap function Z3_mk_unary_minus(ctx::Z3_context,arg::Z3_ast)
ccall((:Z3_mk_unary_minus,"libz3"),Z3_ast,(Z3_context,Z3_ast),ctx,arg)
end
@wrap function Z3_mk_div(ctx::Z3_context,arg1::Z3_ast,arg2::Z3_ast)
ccall((:Z3_mk_div,"libz3"),Z3_ast,(Z3_context,Z3_ast,Z3_ast),ctx,arg1,arg2)
end
@wrap function Z3_mk_mod(ctx::Z3_context,arg1::Z3_ast,arg2::Z3_ast)
ccall((:Z3_mk_mod,"libz3"),Z3_ast,(Z3_context,Z3_ast,Z3_ast),ctx,arg1,arg2)
end
@wrap function Z3_mk_rem(ctx::Z3_context,arg1::Z3_ast,arg2::Z3_ast)
ccall((:Z3_mk_rem,"libz3"),Z3_ast,(Z3_context,Z3_ast,Z3_ast),ctx,arg1,arg2)
end
@wrap function Z3_mk_power(ctx::Z3_context,arg1::Z3_ast,arg2::Z3_ast)
ccall((:Z3_mk_power,"libz3"),Z3_ast,(Z3_context,Z3_ast,Z3_ast),ctx,arg1,arg2)
end
@wrap function Z3_mk_lt(ctx::Z3_context,t1::Z3_ast,t2::Z3_ast)
ccall((:Z3_mk_lt,"libz3"),Z3_ast,(Z3_context,Z3_ast,Z3_ast),ctx,t1,t2)
end
@wrap function Z3_mk_le(ctx::Z3_context,t1::Z3_ast,t2::Z3_ast)
ccall((:Z3_mk_le,"libz3"),Z3_ast,(Z3_context,Z3_ast,Z3_ast),ctx,t1,t2)
end
@wrap function Z3_mk_gt(ctx::Z3_context,t1::Z3_ast,t2::Z3_ast)
ccall((:Z3_mk_gt,"libz3"),Z3_ast,(Z3_context,Z3_ast,Z3_ast),ctx,t1,t2)
end
@wrap function Z3_mk_ge(ctx::Z3_context,t1::Z3_ast,t2::Z3_ast)
ccall((:Z3_mk_ge,"libz3"),Z3_ast,(Z3_context,Z3_ast,Z3_ast),ctx,t1,t2)
end
@wrap function Z3_mk_int2real(ctx::Z3_context,t1::Z3_ast)
ccall((:Z3_mk_int2real,"libz3"),Z3_ast,(Z3_context,Z3_ast),ctx,t1)
end