File: ppl_prolog_common_defs.hh

package info (click to toggle)
ppl 1%3A1.2-8.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 44,328 kB
  • sloc: cpp: 212,085; sh: 12,176; makefile: 7,192; perl: 6,333; java: 2,220; ansic: 1,842; ml: 1,132; sed: 80
file content (1081 lines) | stat: -rw-r--r-- 30,238 bytes parent folder | download | duplicates (3)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
/* Common part of the Prolog interfaces: declarations.
   Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
   Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)

This file is part of the Parma Polyhedra Library (PPL).

The PPL 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.

The PPL 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 this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.

For the most up-to-date information see the Parma Polyhedra Library
site: http://bugseng.com/products/ppl/ . */

#ifndef PPL_ppl_prolog_common_defs_hh
#define PPL_ppl_prolog_common_defs_hh 1

#define PPL_NO_AUTOMATIC_INITIALIZATION
#include "ppl.hh"
#include "ppl_prolog_sysdep.hh"
#include "interfaced_boxes.hh"
#include <set>
#include <vector>
#include <exception>
#include <stdexcept>
#include <iostream>

#ifndef PROLOG_TRACK_ALLOCATION
#define PROLOG_TRACK_ALLOCATION 0
#endif
#ifndef NOISY_PROLOG_TRACK_ALLOCATION
#define NOISY_PROLOG_TRACK_ALLOCATION 0
#endif

namespace Parma_Polyhedra_Library {

namespace Interfaces {

namespace Prolog {

#if PROLOG_TRACK_ALLOCATION || NOISY_PROLOG_TRACK_ALLOCATION

class Allocation_Tracker {
public:
  //! Construct an allocation tracker with no registered objects.
  Allocation_Tracker();

  /*! \brief
    Register an object whose deletion is under the Prolog programmer
    responsibility.
  */
  template <typename T>
  void insert(const T* p);

  /*! \brief
    Register an object whose deletion is under the PPL library
    responsibility.
  */
  template <typename T>
  void weak_insert(const T* p);

  //! Check whether the object was correctly registered.
  template <typename T>
  void check(const T* p) const;

  /*! \brief
    Unregister an object whose deletion is under the Prolog programmer
    responsibility.
  */
  template <typename T>
  void remove(const T* p);

  /*! \brief
    Destroy the allocation tracker: an error message will be output
    if there still are registered objects whose deletion was under
    the Prolog programmer responsibility.
  */
  ~Allocation_Tracker();

private:
  //! The type for recording a set of pointers to PPL library objects.
  typedef std::set<const void*, std::less<const void*> > Set;

  /*! \brief
    A set of pointers to objects whose deallocation is under the
    rensponsibility of the Prolog programmer: they should be deallocated
    before the termination of the program.
  */
  Set s;

  /*! \brief
    A set of pointers to objects whose deallocation is under the
    rensponsibility of the PPL library: they should not be deallocated
    by the Prolog programmer.
  */
  Set weak_s;
};

extern Allocation_Tracker allocation_tracker;

#define PPL_REGISTER(x)                       \
  Parma_Polyhedra_Library::Interfaces::Prolog \
  ::allocation_tracker.insert(x)
#define PPL_WEAK_REGISTER(x)                    \
  Parma_Polyhedra_Library::Interfaces::Prolog   \
  ::allocation_tracker.weak_insert(x)
#define PPL_UNREGISTER(x)                       \
  Parma_Polyhedra_Library::Interfaces::Prolog   \
  ::allocation_tracker.remove(x)
#define PPL_CHECK(x)                            \
  Parma_Polyhedra_Library::Interfaces::Prolog   \
  ::allocation_tracker.check(x)

#else // !PROLOG_TRACK_ALLOCATION && !NOISY_PROLOG_TRACK_ALLOCATION

#define PPL_REGISTER(x)
#define PPL_WEAK_REGISTER(x)
#define PPL_UNREGISTER(x)
#define PPL_CHECK(x)

#endif // !PROLOG_TRACK_ALLOCATION && !NOISY_PROLOG_TRACK_ALLOCATION

class internal_exception {
private:
  Prolog_term_ref t;
  const char* w;

public:
  internal_exception(Prolog_term_ref term, const char* where)
    : t(term),
      w(where) {
  }

  virtual ~internal_exception() {
  }

  virtual Prolog_term_ref term() const {
    return t;
  }

  virtual const char* where() const {
    return w;
  }
};

class Prolog_unsigned_out_of_range : public internal_exception {
private:
  unsigned long m;

public:
  Prolog_unsigned_out_of_range(Prolog_term_ref term,
                               const char* where,
                               unsigned long max)
    : internal_exception(term, where),
      m(max) {
  }

  unsigned long max() const {
    return m;
  }
};

class non_linear : public internal_exception {
public:
  non_linear(Prolog_term_ref term, const char* where)
    : internal_exception(term, where) {
  }
};

class not_an_integer : public internal_exception {
public:
  not_an_integer(Prolog_term_ref term, const char* where)
    : internal_exception(term, where) {
  }
};

class not_unsigned_integer : public internal_exception {
public:
  not_unsigned_integer(Prolog_term_ref term, const char* where)
    : internal_exception(term, where) {
  }
};

class not_a_boolean : public internal_exception {
public:
  not_a_boolean(Prolog_term_ref term, const char* where)
    : internal_exception(term, where) {
  }
};

class not_a_variable : public internal_exception {
public:
  not_a_variable(Prolog_term_ref term, const char* where)
    : internal_exception(term, where) {
  }
};

class not_an_optimization_mode : public internal_exception {
public:
  not_an_optimization_mode(Prolog_term_ref term, const char* where)
    : internal_exception(term, where) {
  }
};

class not_a_bounded_integer_type_width : public internal_exception {
public:
  not_a_bounded_integer_type_width(Prolog_term_ref term, const char* where)
    : internal_exception(term, where) {
  }
};

class not_a_bounded_integer_type_representation : public internal_exception {
public:
  not_a_bounded_integer_type_representation(Prolog_term_ref term,
                                            const char* where)
    : internal_exception(term, where) {
  }
};

class not_a_bounded_integer_type_overflow : public internal_exception {
public:
  not_a_bounded_integer_type_overflow(Prolog_term_ref term, const char* where)
    : internal_exception(term, where) {
  }
};

class not_a_complexity_class : public internal_exception {
public:
  not_a_complexity_class(Prolog_term_ref term, const char* where)
    : internal_exception(term, where) {
  }
};

class not_a_control_parameter_name : public internal_exception {
public:
  not_a_control_parameter_name(Prolog_term_ref term, const char* where)
    : internal_exception(term, where) {
  }
};

class not_a_control_parameter_value : public internal_exception {
public:
  not_a_control_parameter_value(Prolog_term_ref term, const char* where)
    : internal_exception(term, where) {
  }
};

class not_a_pip_problem_control_parameter_name : public internal_exception {
public:
  not_a_pip_problem_control_parameter_name(Prolog_term_ref term, const char* where)
    : internal_exception(term, where) {
  }
};

class not_a_pip_problem_control_parameter_value : public internal_exception {
public:
  not_a_pip_problem_control_parameter_value(Prolog_term_ref term, const char* where)
    : internal_exception(term, where) {
  }
};

class not_universe_or_empty : public internal_exception {
public:
  not_universe_or_empty(Prolog_term_ref term, const char* where)
    : internal_exception(term, where) {
  }
};

class not_a_relation : public internal_exception {
public:
  not_a_relation(Prolog_term_ref term, const char* where)
    : internal_exception(term, where) {
  }
};

class not_a_nil_terminated_list : public internal_exception {
public:
  not_a_nil_terminated_list(Prolog_term_ref term, const char* where)
    : internal_exception(term, where) {
  }
};

class PPL_integer_out_of_range {
private:
  Parma_Polyhedra_Library::Coefficient n;

public:
  PPL_integer_out_of_range(const Parma_Polyhedra_Library::Coefficient& value)
    : n(value) {
  }

  const Parma_Polyhedra_Library::Coefficient value() const {
    return n;
  }
};

class ppl_handle_mismatch : public internal_exception {
public:
  ppl_handle_mismatch(Prolog_term_ref term, const char* where)
    : internal_exception(term, where) {
  }
};

class unknown_interface_error {
private:
  const char* w;

public:
  unknown_interface_error(const char* s)
    : w(s) {
  }

  const char* where() const {
    return w;
  }
};

// For variables.
extern Prolog_atom a_dollar_VAR;

// For linear expressions.
extern Prolog_atom a_plus;
extern Prolog_atom a_minus;
extern Prolog_atom a_asterisk;

// To represent rational numbers as fractions.
extern Prolog_atom a_slash;

// For constraints.
extern Prolog_atom a_less_than;
extern Prolog_atom a_equal_less_than;
extern Prolog_atom a_equal;
extern Prolog_atom a_greater_than_equal;
extern Prolog_atom a_greater_than;

// For congruences.
extern Prolog_atom a_is_congruent_to;
extern Prolog_atom a_modulo;

// For generators.
extern Prolog_atom a_line;
extern Prolog_atom a_ray;
extern Prolog_atom a_point;
extern Prolog_atom a_closure_point;

// For grid_generators.
extern Prolog_atom a_grid_line;
extern Prolog_atom a_parameter;
extern Prolog_atom a_grid_point;

// For the relation between a polyhedron and a constraint.
extern Prolog_atom a_is_disjoint;
extern Prolog_atom a_strictly_intersects;
extern Prolog_atom a_is_included;
extern Prolog_atom a_saturates;

// For the relation between a polyhedron and a generator.
extern Prolog_atom a_subsumes;

// Denotes a closed interval boundary.
extern Prolog_atom a_c;

// Denotes the empty set such as the empty interval or polyhedron.
extern Prolog_atom a_empty;

// Denotes an open interval boundary.
extern Prolog_atom a_o;

// Denotes the constructor that turns two boundaries into a proper interval.
extern Prolog_atom a_i;

// Denote the -infinity and +infinity interval boundaries.
extern Prolog_atom a_minf;
extern Prolog_atom a_pinf;

// Denote complexity classes.
extern Prolog_atom a_polynomial;
extern Prolog_atom a_simplex;
extern Prolog_atom a_any;

// Denote possible widths of bounded integer types.
extern Prolog_atom a_bits_8;
extern Prolog_atom a_bits_16;
extern Prolog_atom a_bits_32;
extern Prolog_atom a_bits_64;
extern Prolog_atom a_bits_128;

// Denote possible representations of bounded integer types.
extern Prolog_atom a_unsigned;
extern Prolog_atom a_signed_2_complement;

// Denote possible overflow behavior of bounded integer types.
extern Prolog_atom a_overflow_wraps;
extern Prolog_atom a_overflow_undefined;
extern Prolog_atom a_overflow_impossible;

// Boolean constants.
extern Prolog_atom a_true;
extern Prolog_atom a_false;


struct Prolog_Interface_Atom {
  Prolog_atom* p_atom;
  const char* name;
};

extern const Prolog_Interface_Atom prolog_interface_atoms[];

void
handle_exception(const Prolog_unsigned_out_of_range& e);

void
handle_exception(const not_unsigned_integer& e);

void
handle_exception(const not_a_boolean& e);

void
handle_exception(const non_linear& e);

void
handle_exception(const not_a_variable& e);

void
handle_exception(const not_an_integer& e);

void
handle_exception(const ppl_handle_mismatch& e);

void
handle_exception(const not_an_optimization_mode& e);

void
handle_exception(const not_a_complexity_class& e);

void
handle_exception(const not_a_bounded_integer_type_width& e);

void
handle_exception(const not_a_bounded_integer_type_representation& e);

void
handle_exception(const not_a_bounded_integer_type_overflow& e);

void
handle_exception(const not_a_control_parameter_name& e);

void
handle_exception(const not_a_control_parameter_value& e);

void
handle_exception(const not_a_pip_problem_control_parameter_name& e);

void
handle_exception(const not_a_pip_problem_control_parameter_value& e);

void
handle_exception(const not_universe_or_empty& e);

void
handle_exception(const not_a_relation& e);

void
handle_exception(const not_a_nil_terminated_list& e);

void
handle_exception(const PPL_integer_out_of_range& e);

void
handle_exception(const unknown_interface_error& e);

void
handle_exception(const std::overflow_error& e);

void
handle_exception(const std::domain_error& e);

void
handle_exception(const std::length_error& e);

void
handle_exception(const std::invalid_argument& e);

void
handle_exception(const std::logic_error& e);

void
handle_exception(const std::bad_alloc&);

void
handle_exception(const std::exception& e);

void
handle_exception();

class timeout_exception
  : public Parma_Polyhedra_Library::Throwable {
public:
  void throw_me() const {
    throw *this;
  }
  int priority() const {
    return 0;
  }
};

void
handle_exception(const timeout_exception&);

class deterministic_timeout_exception
  : public Parma_Polyhedra_Library::Throwable {
public:
  void throw_me() const {
    throw *this;
  }
  int priority() const {
    return 0;
  }
};

void
handle_exception(const deterministic_timeout_exception&);

#define CATCH_ALL \
  catch (const Prolog_unsigned_out_of_range& e) { \
    handle_exception(e); \
  } \
  catch (const not_unsigned_integer& e) { \
    handle_exception(e); \
  } \
  catch (const non_linear& e) { \
    handle_exception(e); \
  } \
  catch (const not_a_variable& e) { \
    handle_exception(e); \
  } \
  catch (const not_an_integer& e) { \
    handle_exception(e); \
  } \
  catch (const ppl_handle_mismatch& e) { \
    handle_exception(e); \
  } \
  catch (const not_an_optimization_mode& e) {   \
    handle_exception(e); \
  } \
  catch (const not_a_complexity_class& e) { \
    handle_exception(e); \
  } \
  catch (const not_a_bounded_integer_type_width& e) { \
    handle_exception(e); \
  } \
  catch (const not_a_bounded_integer_type_representation& e) { \
    handle_exception(e); \
  } \
  catch (const not_a_bounded_integer_type_overflow& e) { \
    handle_exception(e); \
  } \
  catch (const not_a_control_parameter_name& e) { \
    handle_exception(e); \
  } \
  catch (const not_a_control_parameter_value& e) { \
    handle_exception(e); \
  } \
  catch (const not_a_pip_problem_control_parameter_name& e) { \
    handle_exception(e); \
  } \
  catch (const not_a_pip_problem_control_parameter_value& e) { \
    handle_exception(e); \
  } \
  catch (const not_universe_or_empty& e) { \
    handle_exception(e); \
  } \
  catch (const not_a_relation& e) { \
    handle_exception(e); \
  } \
  catch (const not_a_nil_terminated_list& e) { \
    handle_exception(e); \
  } \
  catch (const PPL_integer_out_of_range& e) { \
    handle_exception(e); \
  } \
  catch (const unknown_interface_error& e) { \
    handle_exception(e); \
  } \
  catch (const timeout_exception& e) { \
    handle_exception(e); \
  } \
  catch (const deterministic_timeout_exception& e) { \
    handle_exception(e); \
  } \
  catch(const std::overflow_error& e) { \
    handle_exception(e); \
  } \
  catch(const std::domain_error& e) { \
    handle_exception(e); \
  } \
  catch(const std::length_error& e) { \
    handle_exception(e); \
  } \
  catch(const std::invalid_argument& e) { \
    handle_exception(e); \
  } \
  catch (const std::logic_error& e) { \
    handle_exception(e); \
  } \
  catch (const std::bad_alloc& e) { \
    handle_exception(e); \
  } \
  catch (const std::exception& e) { \
    handle_exception(e); \
  } \
  catch (...) { \
    handle_exception(); \
  } \
  return PROLOG_FAILURE


Prolog_term_ref
variable_term(dimension_type varid);

template <typename U>
U
term_to_unsigned(Prolog_term_ref t, const char* where) {
  using namespace Parma_Polyhedra_Library;
  using namespace Parma_Polyhedra_Library::Interfaces::Prolog;
  if (!Prolog_is_integer(t))
    throw not_unsigned_integer(t, where);

  U d = 0;
  long l;
  if (Prolog_get_long(t, &l))
    if (l < 0)
      throw not_unsigned_integer(t, where);
    else if (static_cast<unsigned long>(l) > std::numeric_limits<U>::max())
      throw Prolog_unsigned_out_of_range(t, where,
                                         std::numeric_limits<U>::max());
    else
      d = l;
  else {
    PPL_DIRTY_TEMP_COEFFICIENT(v);
    Prolog_get_Coefficient(t, v);
    if (v < 0)
      throw not_unsigned_integer(t, where);
    Result r = assign_r(d, raw_value(v), ROUND_IGNORE);
    if (result_overflow(r))
      throw Prolog_unsigned_out_of_range(t, where,
                                         std::numeric_limits<U>::max());
  }
  return d;
}

Prolog_atom
term_to_boolean(Prolog_term_ref t, const char* where);

Prolog_atom
term_to_universe_or_empty(Prolog_term_ref t, const char* where);

Prolog_term_ref
interval_term(const Parma_Polyhedra_Library::Rational_Box::interval_type& i);

Prolog_atom
term_to_complexity_class(Prolog_term_ref t, const char* where);

Prolog_atom
term_to_bounded_integer_type_width(Prolog_term_ref t, const char* where);

Prolog_atom
term_to_bounded_integer_type_representation(Prolog_term_ref t,
                                            const char* where);

Prolog_atom
term_to_bounded_integer_type_overflow(Prolog_term_ref t, const char* where);

template <typename T>
T*
term_to_handle(Prolog_term_ref t, const char* where) {
  if (Prolog_is_address(t)) {
    void* p;
    if (Prolog_get_address(t, &p))
      return static_cast<T*>(p);
  }
  throw ppl_handle_mismatch(t, where);
}

enum Boundary_Kind {
  LOWER_BOUNDARY,
  UPPER_BOUNDARY
};

bool
term_to_boundary(Prolog_term_ref t_b, Boundary_Kind kind,
                 bool& finite, bool& closed,
                 Parma_Polyhedra_Library::Coefficient& n, Parma_Polyhedra_Library::Coefficient& d);

Parma_Polyhedra_Library::Relation_Symbol
term_to_relation_symbol(Prolog_term_ref t_r, const char* where);

Parma_Polyhedra_Library::Coefficient
integer_term_to_Coefficient(Prolog_term_ref t);

Prolog_term_ref
Coefficient_to_integer_term(const Parma_Polyhedra_Library::Coefficient& n);

bool
unify_long(Prolog_term_ref t, long l);

bool
unify_ulong(Prolog_term_ref t, unsigned long l);

Parma_Polyhedra_Library::Linear_Expression
build_linear_expression(Prolog_term_ref t, const char* where);

Parma_Polyhedra_Library::Constraint
build_constraint(Prolog_term_ref t, const char* where);

Parma_Polyhedra_Library::Congruence
build_congruence(Prolog_term_ref t, const char* where);

Parma_Polyhedra_Library::Generator
build_generator(Prolog_term_ref t, const char* where);

Parma_Polyhedra_Library::Grid_Generator
build_grid_generator(Prolog_term_ref t, const char* where);

Prolog_term_ref
get_linear_expression(const Parma_Polyhedra_Library::Linear_Expression& le);

Prolog_term_ref
constraint_term(const Parma_Polyhedra_Library::Constraint& c);

Prolog_term_ref
congruence_term(const Parma_Polyhedra_Library::Congruence& cg);

Prolog_term_ref
generator_term(const Parma_Polyhedra_Library::Generator& g);

Prolog_term_ref
grid_generator_term(const Parma_Polyhedra_Library::Grid_Generator& g);

Parma_Polyhedra_Library::Variable
term_to_Variable(Prolog_term_ref t, const char* where);

Parma_Polyhedra_Library::Coefficient
term_to_Coefficient(Prolog_term_ref t, const char* where);

Prolog_atom
term_to_optimization_mode(Prolog_term_ref t, const char* where);

Prolog_atom
term_to_control_parameter_name(Prolog_term_ref t, const char* where);

Prolog_atom
term_to_control_parameter_value(Prolog_term_ref t, const char* where);

Prolog_atom
term_to_pip_problem_control_parameter_name(Prolog_term_ref t, const char* where);

Prolog_atom
term_to_pip_problem_control_parameter_value(Prolog_term_ref t, const char* where);

void
check_nil_terminating(Prolog_term_ref t, const char* where);

} // namespace Prolog

} // namespace Interfaces

} // namespace Parma_Polyhedra_Library

extern "C" Prolog_foreign_return_type
ppl_version_major(Prolog_term_ref t_v);

extern "C" Prolog_foreign_return_type
ppl_version_minor(Prolog_term_ref t_v);

extern "C" Prolog_foreign_return_type
ppl_version_revision(Prolog_term_ref t_v);

extern "C" Prolog_foreign_return_type
ppl_version_beta(Prolog_term_ref t_v);

extern "C" Prolog_foreign_return_type
ppl_version(Prolog_term_ref t_v);

extern "C" Prolog_foreign_return_type
ppl_banner(Prolog_term_ref t_b);

extern "C" Prolog_foreign_return_type
ppl_max_space_dimension(Prolog_term_ref t_msd);

extern "C" Prolog_foreign_return_type
ppl_initialize();

extern "C" Prolog_foreign_return_type
ppl_finalize();

extern "C" Prolog_foreign_return_type
ppl_set_rounding_for_PPL();

extern "C" Prolog_foreign_return_type
ppl_restore_pre_PPL_rounding();

extern "C" Prolog_foreign_return_type
ppl_irrational_precision(Prolog_term_ref t_p);

extern "C" Prolog_foreign_return_type
ppl_set_irrational_precision(Prolog_term_ref t_p);

extern "C" Prolog_foreign_return_type
ppl_set_timeout_exception_atom(Prolog_term_ref t_tea);

extern "C" Prolog_foreign_return_type
ppl_timeout_exception_atom(Prolog_term_ref t);

extern "C" Prolog_foreign_return_type
ppl_set_timeout(Prolog_term_ref t_csecs);

extern "C" Prolog_foreign_return_type
ppl_reset_timeout();

extern "C" Prolog_foreign_return_type
ppl_set_deterministic_timeout(Prolog_term_ref t_unscaled_weight,
                              Prolog_term_ref t_scale);

extern "C" Prolog_foreign_return_type
ppl_reset_deterministic_timeout();

extern "C" Prolog_foreign_return_type
ppl_Coefficient_bits(Prolog_term_ref t_bits);

extern "C" Prolog_foreign_return_type
ppl_Coefficient_is_bounded();

extern "C" Prolog_foreign_return_type
ppl_Coefficient_min(Prolog_term_ref t_min);

extern "C" Prolog_foreign_return_type
ppl_Coefficient_max(Prolog_term_ref t_max);

extern "C" Prolog_foreign_return_type
ppl_new_MIP_Problem_from_space_dimension
(Prolog_term_ref t_nd, Prolog_term_ref t_mip);

extern "C" Prolog_foreign_return_type
ppl_new_MIP_Problem(Prolog_term_ref t_nd,
                    Prolog_term_ref t_clist,
                    Prolog_term_ref t_le_expr,
                    Prolog_term_ref t_opt,
                    Prolog_term_ref t_mip);

extern "C" Prolog_foreign_return_type
ppl_new_MIP_Problem_from_MIP_Problem(Prolog_term_ref t_mip_source,
                                     Prolog_term_ref t_mip);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_swap(Prolog_term_ref t_lhs, Prolog_term_ref t_rhs);

extern "C" Prolog_foreign_return_type
ppl_delete_MIP_Problem(Prolog_term_ref t_mip);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_space_dimension(Prolog_term_ref t_mip, Prolog_term_ref t_sd);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_integer_space_dimensions(Prolog_term_ref t_mip,
                                         Prolog_term_ref t_vlist);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_constraints(Prolog_term_ref t_mip,
                            Prolog_term_ref t_clist);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_objective_function(Prolog_term_ref t_mip,
                                   Prolog_term_ref t_le_expr);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_optimization_mode(Prolog_term_ref t_mip,
                                  Prolog_term_ref t_opt);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_get_control_parameter(Prolog_term_ref t_mip,
                                      Prolog_term_ref t_cp_name,
                                      Prolog_term_ref t_cp_value);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_clear(Prolog_term_ref t_mip);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_add_space_dimensions_and_embed
(Prolog_term_ref t_mip, Prolog_term_ref t_nnd);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_add_to_integer_space_dimensions(Prolog_term_ref t_mip,
                                                Prolog_term_ref t_vlist);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_add_constraint(Prolog_term_ref t_mip, Prolog_term_ref t_c);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_add_constraints(Prolog_term_ref t_mip,
                                Prolog_term_ref t_clist);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_set_objective_function(Prolog_term_ref t_mip,
                                       Prolog_term_ref t_le_expr);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_set_optimization_mode(Prolog_term_ref t_mip,
                                      Prolog_term_ref t_opt);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_set_control_parameter(Prolog_term_ref t_mip,
                                      Prolog_term_ref t_cp_value);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_is_satisfiable(Prolog_term_ref t_mip);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_solve(Prolog_term_ref t_mip, Prolog_term_ref t_status);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_feasible_point(Prolog_term_ref t_mip,
                               Prolog_term_ref t_g);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_optimizing_point(Prolog_term_ref t_mip,
                                 Prolog_term_ref t_g);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_optimal_value(Prolog_term_ref t_mip,
                              Prolog_term_ref t_n,
                              Prolog_term_ref t_d);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_evaluate_objective_function(Prolog_term_ref t_mip,
                                            Prolog_term_ref t_g,
                                            Prolog_term_ref t_n,
                                            Prolog_term_ref t_d);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_OK(Prolog_term_ref t_mip);

extern "C" Prolog_foreign_return_type
ppl_MIP_Problem_ascii_dump(Prolog_term_ref t_mip);


extern "C" Prolog_foreign_return_type
ppl_new_PIP_Problem_from_space_dimension(Prolog_term_ref t_nd,
                                         Prolog_term_ref t_pip);

extern "C" Prolog_foreign_return_type
ppl_new_PIP_Problem_from_PIP_Problem(Prolog_term_ref t_pip_source,
                                     Prolog_term_ref t_pip);

extern "C" Prolog_foreign_return_type
ppl_new_PIP_Problem(Prolog_term_ref t_dim,
                    Prolog_term_ref t_cs,
                    Prolog_term_ref t_params,
                    Prolog_term_ref t_pip);

extern "C" Prolog_foreign_return_type
ppl_PIP_Problem_swap(Prolog_term_ref t_lhs, Prolog_term_ref t_rhs);

extern "C" Prolog_foreign_return_type
ppl_delete_PIP_Problem(Prolog_term_ref t_pip);

extern "C" Prolog_foreign_return_type
ppl_PIP_Problem_space_dimension(Prolog_term_ref t_pip, Prolog_term_ref t_sd);

extern "C" Prolog_foreign_return_type
ppl_PIP_Problem_parameter_space_dimensions(Prolog_term_ref t_pip,
                                           Prolog_term_ref t_vlist);

extern "C" Prolog_foreign_return_type
ppl_PIP_Problem_constraints(Prolog_term_ref t_pip, Prolog_term_ref t_cs);

extern "C" Prolog_foreign_return_type
ppl_PIP_Problem_get_control_parameter(Prolog_term_ref t_pip,
                                      Prolog_term_ref t_cp_name,
                                      Prolog_term_ref t_cp_value);

extern "C" Prolog_foreign_return_type
ppl_PIP_Problem_clear(Prolog_term_ref t_pip);

extern "C" Prolog_foreign_return_type
ppl_PIP_Problem_add_space_dimensions_and_embed
(Prolog_term_ref t_pip,
 Prolog_term_ref t_num_vars,
 Prolog_term_ref t_num_params);

extern "C" Prolog_foreign_return_type
ppl_PIP_Problem_add_to_parameter_space_dimensions(Prolog_term_ref t_pip,
                                                  Prolog_term_ref t_vlist);

extern "C" Prolog_foreign_return_type
ppl_PIP_Problem_add_constraint(Prolog_term_ref t_pip, Prolog_term_ref t_c);

extern "C" Prolog_foreign_return_type
ppl_PIP_Problem_add_constraints(Prolog_term_ref t_pip,
                                Prolog_term_ref t_clist);

extern "C" Prolog_foreign_return_type
ppl_PIP_Problem_set_control_parameter(Prolog_term_ref t_pip,
                                      Prolog_term_ref t_cp_value);

extern "C" Prolog_foreign_return_type
ppl_PIP_Problem_is_satisfiable(Prolog_term_ref t_pip);

extern "C" Prolog_foreign_return_type
ppl_PIP_Problem_solve(Prolog_term_ref t_pip, Prolog_term_ref t_status);

extern "C" Prolog_foreign_return_type
ppl_PIP_Problem_solution(Prolog_term_ref t_pip,
                         Prolog_term_ref t_pip_tree);

extern "C" Prolog_foreign_return_type
ppl_PIP_Problem_optimizing_solution(Prolog_term_ref t_pip,
                                    Prolog_term_ref t_pip_tree);

extern "C" Prolog_foreign_return_type
ppl_PIP_Problem_has_big_parameter_dimension(Prolog_term_ref t_pip,
                                            Prolog_term_ref t_d);

extern "C" Prolog_foreign_return_type
ppl_PIP_Problem_set_big_parameter_dimension(Prolog_term_ref t_pip,
                                            Prolog_term_ref t_d);

extern "C" Prolog_foreign_return_type
ppl_PIP_Problem_OK(Prolog_term_ref t_pip);

extern "C" Prolog_foreign_return_type
ppl_PIP_Problem_ascii_dump(Prolog_term_ref t_pip);

extern "C" Prolog_foreign_return_type
ppl_PIP_Tree_Node_constraints(Prolog_term_ref t_tree_node,
                              Prolog_term_ref t_clist);

extern "C" Prolog_foreign_return_type
ppl_PIP_Tree_Node_is_solution(Prolog_term_ref t_tree_node);

extern "C" Prolog_foreign_return_type
ppl_PIP_Tree_Node_is_decision(Prolog_term_ref t_tree_node);

extern "C" Prolog_foreign_return_type
ppl_PIP_Tree_Node_is_bottom(Prolog_term_ref t_tree_node);

extern "C" Prolog_foreign_return_type
ppl_PIP_Tree_Node_artificials(Prolog_term_ref t_tree_node,
                              Prolog_term_ref t_artlist);

extern "C" Prolog_foreign_return_type
ppl_PIP_Tree_Node_OK(Prolog_term_ref t_pip_tree);

extern "C" Prolog_foreign_return_type
ppl_PIP_Tree_Node_parametric_values(Prolog_term_ref t_pip_sol,
                                    Prolog_term_ref t_var,
                                    Prolog_term_ref t_pvalue_list);

extern "C" Prolog_foreign_return_type
ppl_PIP_Tree_Node_true_child(Prolog_term_ref t_pip_dec,
                             Prolog_term_ref t_pip_tree);

extern "C" Prolog_foreign_return_type
ppl_PIP_Tree_Node_false_child(Prolog_term_ref t_pip_dec,
                              Prolog_term_ref t_pip_tree);

using namespace Parma_Polyhedra_Library;
using namespace Parma_Polyhedra_Library::Interfaces::Prolog;

#include "ppl_prolog_common_inlines.hh"

#endif // !defined(PPL_ppl_prolog_common_defs_hh)