4 #include <symengine/symengine_casts.h>
10 Interval::Interval(
const RCP<const Number> &start,
const RCP<const Number> &end,
11 const bool left_open,
const bool right_open)
12 : start_(start), end_(
end), left_open_(left_open), right_open_(right_open)
14 SYMENGINE_ASSIGN_TYPEID()
16 Interval::is_canonical(start_, end_, left_open_, right_open_));
19 bool Interval::is_canonical(const RCP<const Number> &s,
20 const RCP<const Number> &e,
bool left_open,
23 if (is_a<Complex>(*s) or is_a<Complex>(*e))
24 throw NotImplementedError(
"Complex set not implemented");
27 }
else if (
eq(*
min({s, e}), *e)) {
33 hash_t Interval::__hash__()
const
35 hash_t seed = SYMENGINE_INTERVAL;
36 hash_combine<Basic>(seed, *start_);
37 hash_combine<Basic>(seed, *end_);
38 hash_combine<bool>(seed, left_open_);
39 hash_combine<bool>(seed, right_open_);
43 bool Interval::__eq__(
const Basic &o)
const
45 if (is_a<Interval>(o)) {
46 const Interval &s = down_cast<const Interval &>(o);
47 return ((this->left_open_ == s.left_open_)
48 and (this->right_open_ == s.right_open_)
49 and
eq(*this->start_, *s.start_) and
eq(*this->end_, *s.end_));
54 int Interval::compare(
const Basic &s)
const
57 SYMENGINE_ASSERT(is_a<Interval>(s))
58 const Interval &o = down_cast<const Interval &>(s);
59 if (left_open_ and not o.left_open_) {
61 }
else if (not left_open_ and o.left_open_) {
63 }
else if (right_open_ and not o.right_open_) {
65 }
else if (not right_open_ and o.right_open_) {
68 auto temp = start_->__cmp__(*(o.start_));
72 return end_->__cmp__(*(o.end_));
77 RCP<const Set> Interval::open()
const
79 return interval(start_, end_,
true,
true);
82 RCP<const Set> Interval::Lopen()
const
84 return interval(start_, end_,
true,
false);
87 RCP<const Set> Interval::Ropen()
const
89 return interval(start_, end_,
false,
true);
92 RCP<const Set> Interval::close()
const
94 return interval(start_, end_,
false,
false);
97 RCP<const Boolean> Interval::contains(
const RCP<const Basic> &a)
const
101 return boolean(
false);
103 return make_rcp<Contains>(a, rcp_from_this_cast<const Set>());
107 return boolean(not left_open_);
109 return boolean(not right_open_);
110 if (
eq(*
min({end_, a}), *end_) or
eq(*
max({start_, a}), *start_))
111 return boolean(
false);
112 return boolean(
true);
115 static RCP<const Set> make_set_union(
const set_set &in)
118 return make_rcp<const Union>(in);
123 static RCP<const Set> make_set_intersection(
const set_set &in)
126 return make_rcp<const Intersection>(in);
131 RCP<const Set> Interval::set_intersection(
const RCP<const Set> &o)
const
133 if (is_a<Interval>(*o)) {
134 const Interval &other = down_cast<const Interval &>(*o);
135 RCP<const Number> start,
end;
136 bool left_open, right_open;
137 RCP<const Basic> start_end, end_start;
138 start_end =
min({this->start_, other.end_});
139 end_start =
min({this->end_, other.start_});
141 if (
eq(*this->start_, *start_end) and
eq(*other.start_, *end_start)) {
142 RCP<const Basic> start_start, end_end;
143 start_start =
min({this->start_, other.start_});
144 end_end =
min({this->end_, other.end_});
145 if (
neq(*this->start_, *other.start_)) {
146 if (
eq(*this->start_, *start_start)) {
147 start = other.start_;
148 left_open = other.left_open_;
150 start = this->start_;
151 left_open = this->left_open_;
154 start = this->start_;
155 left_open = this->left_open_ or other.left_open_;
158 if (
neq(*this->end_, *other.end_)) {
159 if (
eq(*this->end_, *end_end)) {
161 right_open = this->right_open_;
164 right_open = other.right_open_;
168 right_open = this->right_open_ or other.right_open_;
170 return interval(start, end, left_open, right_open);
175 if (is_a<Integers>(*o) or is_a<Naturals>(*o) or is_a<Naturals0>(*o)) {
179 if (is_a<Naturals>(*o)
180 and not down_cast<const Integer &>(*first).is_positive()) {
182 }
else if (is_a<Naturals0>(*o)
183 and down_cast<const Integer &>(*first).is_negative()) {
186 if (
eq(*first, *start_) and left_open_) {
189 if (
eq(*last, *end_) and right_open_) {
192 if (
eq(*
Lt(last, first), *boolTrue)) {
196 while (
eq(*
Ge(last, first), *boolTrue)) {
202 return SymEngine::set_intersection(
203 {rcp_from_this_cast<const Set>(), o});
206 if (is_a<UniversalSet>(*o) or is_a<EmptySet>(*o) or is_a<FiniteSet>(*o)
207 or is_a<Union>(*o) or is_a<Rationals>(*o) or is_a<Reals>(*o)
208 or is_a<Complexes>(*o)) {
209 return (*o).set_intersection(rcp_from_this_cast<const Set>());
211 return make_set_intersection({rcp_from_this_cast<const Set>(), o});
214 RCP<const Set> Interval::set_union(
const RCP<const Set> &o)
const
216 if (is_a<Interval>(*o)) {
217 const Interval &other = down_cast<const Interval &>(*o);
218 RCP<const Basic> start_start, end_end, m;
219 RCP<const Number> start,
end;
220 bool left_open, right_open;
221 start_start =
max({this->start_, other.start_});
222 end_end =
min({this->end_, other.end_});
223 m =
min({start_start, end_end});
224 if ((
eq(*end_end, *start_start) and
eq(*end_end, *m)
225 and ((
eq(*end_end, *this->end_) and this->right_open_)
226 or (
eq(*end_end, *other.end_) and other.right_open_)))
227 or (
eq(*end_end, *m) and not
eq(*end_end, *start_start))) {
228 return SymEngine::make_set_union(
229 {rcp_from_this_cast<const Set>(), o});
231 if (
eq(*
min({this->start_, other.start_}), *this->start_)) {
232 start = this->start_;
234 start = other.start_;
236 if (
eq(*
max({this->end_, other.end_}), *this->end_)) {
241 left_open = ((
neq(*this->start_, *start) or this->left_open_)
242 and (
neq(*other.start_, *start) or other.left_open_));
243 right_open = ((
neq(*this->end_, *end) or this->right_open_)
244 and (
neq(*other.end_, *end) or other.right_open_));
245 return interval(start, end, left_open, right_open);
248 if (is_a<UniversalSet>(*o) or is_a<EmptySet>(*o) or is_a<FiniteSet>(*o)
249 or is_a<Union>(*o) or is_a<Complexes>(*o) or is_a<Reals>(*o)
250 or is_a<Rationals>(*o) or is_a<Integers>(*o) or is_a<Naturals>(*o)
251 or is_a<Naturals0>(*o)) {
252 return (*o).set_union(rcp_from_this_cast<const Set>());
254 return SymEngine::make_set_union({rcp_from_this_cast<const Set>(), o});
257 RCP<const Set> Interval::set_complement(
const RCP<const Set> &o)
const
259 if (is_a<Interval>(*o)) {
261 const Interval &other = down_cast<const Interval &>(*o);
262 if (
eq(*
max({start_, other.start_}), *start_)) {
263 cont.insert(
interval(other.get_start(), start_,
264 other.get_left_open(), not left_open_));
266 if (
eq(*
min({end_, other.end_}), *end_)) {
267 cont.insert(
interval(end_, other.get_end(), not right_open_,
268 other.get_right_open()));
270 return SymEngine::set_union(cont);
272 return SymEngine::set_complement_helper(rcp_from_this_cast<const Set>(), o);
277 return {start_, end_, boolean(left_open_), boolean(right_open_)};
280 RCP<const Set> Complexes::set_intersection(
const RCP<const Set> &o)
const
282 if (is_a<Interval>(*o) or is_a<EmptySet>(*o) or is_a<Complexes>(*o)
283 or is_a<Reals>(*o) or is_a<Rationals>(*o) or is_a<Integers>(*o)
284 or is_a<Naturals>(*o) or is_a<Naturals0>(*o)) {
286 }
else if (is_a<FiniteSet>(*o)) {
287 return (*o).set_intersection(rcp_from_this_cast<const Set>());
289 return SymEngine::set_intersection(
290 {rcp_from_this_cast<const Set>(), o});
294 RCP<const Set> Complexes::set_union(
const RCP<const Set> &o)
const
296 if (is_a<Interval>(*o) or is_a<EmptySet>(*o) or is_a<Complexes>(*o)
297 or is_a<Reals>(*o) or is_a<Integers>(*o) or is_a<Rationals>(*o)
298 or is_a<Naturals>(*o) or is_a<Naturals0>(*o)) {
300 }
else if (is_a<FiniteSet>(*o)) {
301 return (*o).set_union(rcp_from_this_cast<const Set>());
303 return SymEngine::set_union({rcp_from_this_cast<const Set>(), o});
307 RCP<const Set> Complexes::set_complement(
const RCP<const Set> &o)
const
309 if (is_a<EmptySet>(*o) or is_a<Complexes>(*o) or is_a<Reals>(*o)
310 or is_a<Rationals>(*o) or is_a<Integers>(*o) or is_a<Interval>(*o)
311 or is_a<Naturals>(*o) or is_a<Naturals0>(*o)) {
314 if (is_a<UniversalSet>(*o)) {
315 return make_rcp<const Complement>(o,
complexes());
317 return SymEngine::set_complement_helper(rcp_from_this_cast<const Set>(), o);
320 RCP<const Boolean> Complexes::contains(
const RCP<const Basic> &a)
const
324 return boolean(
false);
326 return make_rcp<Contains>(a, rcp_from_this_cast<const Set>());
329 return boolean(
true);
332 hash_t Complexes::__hash__()
const
334 hash_t seed = SYMENGINE_COMPLEXES;
338 bool Complexes::__eq__(
const Basic &o)
const
340 if (is_a<Complexes>(o))
345 int Complexes::compare(
const Basic &o)
const
347 SYMENGINE_ASSERT(is_a<Complexes>(o))
351 const RCP<const Complexes> &Complexes::getInstance()
353 const static auto a = make_rcp<const Complexes>();
357 RCP<const Set> Reals::set_intersection(
const RCP<const Set> &o)
const
359 if (is_a<Interval>(*o) or is_a<EmptySet>(*o) or is_a<Reals>(*o)
360 or is_a<Rationals>(*o) or is_a<Integers>(*o) or is_a<Naturals>(*o)
361 or is_a<Naturals0>(*o)) {
363 }
else if (is_a<FiniteSet>(*o) or is_a<Complexes>(*o)) {
364 return (*o).set_intersection(rcp_from_this_cast<const Set>());
366 return SymEngine::set_intersection(
367 {rcp_from_this_cast<const Set>(), o});
371 RCP<const Set> Reals::set_union(
const RCP<const Set> &o)
const
373 if (is_a<Interval>(*o) or is_a<EmptySet>(*o) or is_a<Reals>(*o)
374 or is_a<Integers>(*o) or is_a<Rationals>(*o) or is_a<Naturals>(*o)
375 or is_a<Naturals0>(*o)) {
377 }
else if (is_a<FiniteSet>(*o) or is_a<Complexes>(*o)) {
378 return (*o).set_union(rcp_from_this_cast<const Set>());
380 return SymEngine::set_union({rcp_from_this_cast<const Set>(), o});
384 RCP<const Set> Reals::set_complement(
const RCP<const Set> &o)
const
386 if (is_a<EmptySet>(*o) or is_a<Reals>(*o) or is_a<Rationals>(*o)
387 or is_a<Integers>(*o) or is_a<Interval>(*o) or is_a<Naturals>(*o)
388 or is_a<Naturals0>(*o)) {
391 if (is_a<UniversalSet>(*o) or is_a<Complexes>(*o)) {
392 return make_rcp<const Complement>(o,
reals());
394 return SymEngine::set_complement_helper(rcp_from_this_cast<const Set>(), o);
397 RCP<const Boolean> Reals::contains(
const RCP<const Basic> &a)
const
401 return boolean(
false);
403 return make_rcp<Contains>(a, rcp_from_this_cast<const Set>());
406 if (is_a<Complex>(*a)) {
407 return boolean(
false);
409 return boolean(
true);
412 hash_t Reals::__hash__()
const
414 hash_t seed = SYMENGINE_REALS;
418 bool Reals::__eq__(
const Basic &o)
const
425 int Reals::compare(
const Basic &o)
const
427 SYMENGINE_ASSERT(is_a<Reals>(o))
431 const RCP<const Reals> &Reals::getInstance()
433 const static auto a = make_rcp<const Reals>();
437 RCP<const Set> Rationals::set_intersection(
const RCP<const Set> &o)
const
439 if (is_a<EmptySet>(*o) or is_a<Rationals>(*o) or is_a<Integers>(*o)
440 or is_a<Naturals>(*o) or is_a<Naturals0>(*o)) {
442 }
else if (is_a<FiniteSet>(*o) or is_a<Reals>(*o) or is_a<Complexes>(*o)) {
443 return (*o).set_intersection(rcp_from_this_cast<const Set>());
445 return SymEngine::set_intersection(
446 {rcp_from_this_cast<const Set>(), o});
450 RCP<const Set> Rationals::set_union(
const RCP<const Set> &o)
const
452 if (is_a<EmptySet>(*o) or is_a<Integers>(*o) or is_a<Rationals>(*o)
453 or is_a<Naturals>(*o) or is_a<Naturals0>(*o)) {
455 }
else if (is_a<FiniteSet>(*o) or is_a<Reals>(*o) or is_a<Complexes>(*o)) {
456 return (*o).set_union(rcp_from_this_cast<const Set>());
458 return SymEngine::set_union({rcp_from_this_cast<const Set>(), o});
462 RCP<const Set> Rationals::set_complement(
const RCP<const Set> &o)
const
464 if (is_a<EmptySet>(*o) or is_a<Rationals>(*o) or is_a<Integers>(*o)
465 or is_a<Naturals>(*o) or is_a<Naturals0>(*o)) {
468 if (is_a<UniversalSet>(*o) or is_a<Complexes>(*o) or is_a<Reals>(*o)
469 or is_a<Interval>(*o)) {
470 return make_rcp<const Complement>(o,
rationals());
472 return SymEngine::set_complement_helper(rcp_from_this_cast<const Set>(), o);
475 RCP<const Boolean> Rationals::contains(
const RCP<const Basic> &a)
const
479 return boolean(
false);
481 return make_rcp<Contains>(a, rcp_from_this_cast<const Set>());
484 if (is_a<Complex>(*a) or not down_cast<const Number &>(*a).is_exact()) {
485 return boolean(
false);
487 return boolean(
true);
490 hash_t Rationals::__hash__()
const
492 hash_t seed = SYMENGINE_RATIONALS;
496 bool Rationals::__eq__(
const Basic &o)
const
498 return (is_a<Rationals>(o));
501 int Rationals::compare(
const Basic &o)
const
503 SYMENGINE_ASSERT(is_a<Rationals>(o))
507 const RCP<const Rationals> &Rationals::getInstance()
509 const static auto a = make_rcp<const Rationals>();
513 RCP<const Set> Integers::set_intersection(
const RCP<const Set> &o)
const
515 if (is_a<EmptySet>(*o) or is_a<Integers>(*o) or is_a<Naturals>(*o)
516 or is_a<Naturals0>(*o)) {
518 }
else if (is_a<Complexes>(*o) or is_a<Reals>(*o) or is_a<Rationals>(*o)) {
520 }
else if (is_a<FiniteSet>(*o) or is_a<Interval>(*o)) {
521 return (*o).set_intersection(rcp_from_this_cast<const Set>());
523 return SymEngine::set_intersection(
524 {rcp_from_this_cast<const Set>(), o});
528 RCP<const Set> Integers::set_union(
const RCP<const Set> &o)
const
530 if (is_a<Integers>(*o) or is_a<EmptySet>(*o) or is_a<Naturals>(*o)
531 or is_a<Naturals0>(*o)) {
533 }
else if (is_a<Complexes>(*o)) {
535 }
else if (is_a<Reals>(*o)) {
537 }
else if (is_a<Rationals>(*o)) {
539 }
else if (is_a<FiniteSet>(*o)) {
540 return (*o).set_union(rcp_from_this_cast<const Set>());
541 }
else if (is_a<UniversalSet>(*o)) {
544 return SymEngine::make_set_union({rcp_from_this_cast<const Set>(), o});
548 RCP<const Set> Integers::set_complement(
const RCP<const Set> &o)
const
550 if (is_a<EmptySet>(*o) or is_a<Integers>(*o) or is_a<Naturals>(*o)
551 or is_a<Naturals0>(*o)) {
554 if (is_a<UniversalSet>(*o) or is_a<Rationals>(*o) or is_a<Reals>(*o)
555 or is_a<Complexes>(*o)) {
556 return make_rcp<const Complement>(o,
integers());
558 return SymEngine::set_complement_helper(rcp_from_this_cast<const Set>(), o);
561 RCP<const Boolean> Integers::contains(
const RCP<const Basic> &a)
const
565 return boolean(
false);
567 return make_rcp<Contains>(a, rcp_from_this_cast<const Set>());
570 if (is_a<Integer>(*a)) {
571 return boolean(
true);
573 return boolean(
false);
576 hash_t Integers::__hash__()
const
578 hash_t seed = SYMENGINE_INTEGERS;
582 bool Integers::__eq__(
const Basic &o)
const
584 if (is_a<Integers>(o))
589 int Integers::compare(
const Basic &o)
const
591 SYMENGINE_ASSERT(is_a<Integers>(o))
595 const RCP<const Integers> &Integers::getInstance()
597 const static auto a = make_rcp<const Integers>();
601 RCP<const Set> Naturals::set_intersection(
const RCP<const Set> &o)
const
603 if (is_a<EmptySet>(*o) or is_a<Naturals>(*o)) {
605 }
else if (is_a<Naturals0>(*o) or is_a<Integers>(*o) or is_a<Complexes>(*o)
606 or is_a<Reals>(*o) or is_a<Rationals>(*o)) {
608 }
else if (is_a<FiniteSet>(*o) or is_a<Interval>(*o)) {
609 return (*o).set_intersection(rcp_from_this_cast<const Set>());
611 return SymEngine::set_intersection(
612 {rcp_from_this_cast<const Set>(), o});
616 RCP<const Set> Naturals::set_union(
const RCP<const Set> &o)
const
618 if (is_a<EmptySet>(*o)) {
620 }
else if (is_a<Naturals>(*o) or is_a<Naturals0>(*o) or is_a<Integers>(*o)
621 or is_a<Complexes>(*o) or is_a<Reals>(*o) or is_a<Rationals>(*o)
622 or is_a<UniversalSet>(*o)) {
624 }
else if (is_a<FiniteSet>(*o)) {
625 return (*o).set_union(rcp_from_this_cast<const Set>());
627 return SymEngine::make_set_union({rcp_from_this_cast<const Set>(), o});
631 RCP<const Set> Naturals::set_complement(
const RCP<const Set> &o)
const
633 if (is_a<EmptySet>(*o) or is_a<Naturals>(*o)) {
636 if (is_a<Naturals0>(*o)) {
639 if (is_a<UniversalSet>(*o) or is_a<Integers>(*o) or is_a<Rationals>(*o)
640 or is_a<Reals>(*o) or is_a<Complexes>(*o)) {
641 return make_rcp<const Complement>(o,
naturals());
643 return SymEngine::set_complement_helper(rcp_from_this_cast<const Set>(), o);
646 RCP<const Boolean> Naturals::contains(
const RCP<const Basic> &a)
const
650 return boolean(
false);
652 return make_rcp<Contains>(a, rcp_from_this_cast<const Set>());
654 }
else if (is_a<Integer>(*a)
655 and down_cast<const Integer &>(*a).is_positive()) {
656 return boolean(
true);
658 return boolean(
false);
662 hash_t Naturals::__hash__()
const
664 hash_t seed = SYMENGINE_NATURALS;
668 bool Naturals::__eq__(
const Basic &o)
const
670 if (is_a<Naturals>(o))
675 int Naturals::compare(
const Basic &o)
const
677 SYMENGINE_ASSERT(is_a<Naturals>(o))
681 const RCP<const Naturals> &Naturals::getInstance()
683 const static auto a = make_rcp<const Naturals>();
687 RCP<const Set> Naturals0::set_intersection(
const RCP<const Set> &o)
const
689 if (is_a<EmptySet>(*o) or is_a<Naturals>(*o) or is_a<Naturals0>(*o)) {
691 }
else if (is_a<Integers>(*o) or is_a<Complexes>(*o) or is_a<Reals>(*o)
692 or is_a<Rationals>(*o)) {
694 }
else if (is_a<FiniteSet>(*o) or is_a<Interval>(*o)) {
695 return (*o).set_intersection(rcp_from_this_cast<const Set>());
697 return SymEngine::set_intersection(
698 {rcp_from_this_cast<const Set>(), o});
702 RCP<const Set> Naturals0::set_union(
const RCP<const Set> &o)
const
704 if (is_a<EmptySet>(*o) or is_a<Naturals>(*o)) {
706 }
else if (is_a<Naturals0>(*o) or is_a<Integers>(*o) or is_a<Complexes>(*o)
707 or is_a<Reals>(*o) or is_a<Rationals>(*o)
708 or is_a<UniversalSet>(*o)) {
710 }
else if (is_a<FiniteSet>(*o)) {
711 return (*o).set_union(rcp_from_this_cast<const Set>());
713 return SymEngine::make_set_union({rcp_from_this_cast<const Set>(), o});
717 RCP<const Set> Naturals0::set_complement(
const RCP<const Set> &o)
const
719 if (is_a<EmptySet>(*o) or is_a<Naturals0>(*o) or is_a<Naturals>(*o)) {
722 if (is_a<UniversalSet>(*o) or is_a<Integers>(*o) or is_a<Rationals>(*o)
723 or is_a<Reals>(*o) or is_a<Complexes>(*o)) {
724 return make_rcp<const Complement>(o,
naturals());
726 return SymEngine::set_complement_helper(rcp_from_this_cast<const Set>(), o);
729 RCP<const Boolean> Naturals0::contains(
const RCP<const Basic> &a)
const
733 return boolean(
false);
735 return make_rcp<Contains>(a, rcp_from_this_cast<const Set>());
737 }
else if (is_a<Integer>(*a)
738 and (not down_cast<const Integer &>(*a).is_negative())) {
739 return boolean(
true);
741 return boolean(
false);
745 hash_t Naturals0::__hash__()
const
747 hash_t seed = SYMENGINE_NATURALS0;
751 bool Naturals0::__eq__(
const Basic &o)
const
753 if (is_a<Naturals0>(o))
758 int Naturals0::compare(
const Basic &o)
const
760 SYMENGINE_ASSERT(is_a<Naturals0>(o))
764 const RCP<const Naturals0> &Naturals0::getInstance()
766 const static auto a = make_rcp<const Naturals0>();
770 RCP<const Set> EmptySet::set_intersection(
const RCP<const Set> &o)
const
775 RCP<const Set> EmptySet::set_union(
const RCP<const Set> &o)
const
780 RCP<const Set> EmptySet::set_complement(
const RCP<const Set> &o)
const
785 hash_t EmptySet::__hash__()
const
787 hash_t seed = SYMENGINE_EMPTYSET;
791 bool EmptySet::__eq__(
const Basic &o)
const
793 if (is_a<EmptySet>(o))
798 int EmptySet::compare(
const Basic &o)
const
800 SYMENGINE_ASSERT(is_a<EmptySet>(o))
804 const RCP<const EmptySet> &EmptySet::getInstance()
806 const static auto a = make_rcp<const EmptySet>();
810 RCP<const Set> UniversalSet::set_intersection(
const RCP<const Set> &o)
const
815 RCP<const Set> UniversalSet::set_union(
const RCP<const Set> &o)
const
820 RCP<const Set> UniversalSet::set_complement(
const RCP<const Set> &o)
const
825 hash_t UniversalSet::__hash__()
const
827 hash_t seed = SYMENGINE_UNIVERSALSET;
831 bool UniversalSet::__eq__(
const Basic &o)
const
833 if (is_a<UniversalSet>(o))
838 int UniversalSet::compare(
const Basic &o)
const
840 SYMENGINE_ASSERT(is_a<UniversalSet>(o))
844 const RCP<const UniversalSet> &UniversalSet::getInstance()
846 const static auto a = make_rcp<const UniversalSet>();
850 FiniteSet::FiniteSet(
const set_basic &container) : container_(container)
852 SYMENGINE_ASSIGN_TYPEID()
853 SYMENGINE_ASSERT(FiniteSet::is_canonical(container_));
856 bool FiniteSet::is_canonical(const set_basic &container)
858 return container.size() != 0;
863 hash_t seed = SYMENGINE_FINITESET;
864 for (
const auto &a : container_)
865 hash_combine<Basic>(seed, *a);
871 if (is_a<FiniteSet>(o)) {
872 const FiniteSet &other = down_cast<const FiniteSet &>(o);
873 return unified_eq(container_, other.container_);
881 SYMENGINE_ASSERT(is_a<FiniteSet>(o))
882 const FiniteSet &other = down_cast<const FiniteSet &>(o);
886 RCP<const Boolean> FiniteSet::contains(
const RCP<const Basic> &a)
const
889 for (
const auto &elem : container_) {
890 auto cont =
Eq(elem, a);
891 if (
eq(*cont, *boolTrue))
893 if (not
eq(*cont, *boolFalse))
899 return make_rcp<Contains>(a,
finiteset(rest));
903 RCP<const Set> FiniteSet::set_union(
const RCP<const Set> &o)
const
905 if (is_a<FiniteSet>(*o)) {
906 const FiniteSet &other = down_cast<const FiniteSet &>(*o);
909 other.container_.begin(), other.container_.end(),
914 if (is_a<Interval>(*o)) {
916 const Interval &other = down_cast<const Interval &>(*o);
917 bool left = other.get_left_open(),
right = other.get_right_open();
918 for (
const auto &a : container_) {
919 auto contain = o->contains(a);
920 if (
eq(*contain, *boolFalse)) {
922 if (
eq(*other.get_start(), *a)) {
927 if (
eq(*other.get_end(), *a)) {
932 }
else if (is_a<Contains>(*contain)) {
936 if (not container.empty()) {
937 if (left == other.get_left_open()
938 and right == other.get_right_open()) {
939 return SymEngine::make_set_union({
finiteset(container), o});
941 return SymEngine::make_set_union(
943 interval(other.get_start(), other.get_end(), left,
947 if (left == other.get_left_open()
948 and right == other.get_right_open()) {
951 return interval(other.get_start(), other.get_end(), left,
956 if (is_a<Complexes>(*o)) {
958 for (
const auto &elem : container_) {
963 if (container.empty()) {
966 return SymEngine::make_set_union(
970 if (is_a<Reals>(*o)) {
972 for (
const auto &elem : container_) {
974 || down_cast<const Number &>(*elem).is_complex()) {
978 if (container.empty()) {
981 return SymEngine::make_set_union({
reals(),
finiteset(container)});
984 if (is_a<Rationals>(*o)) {
986 for (
const auto &elem : container_) {
988 || down_cast<const Number &>(*elem).is_complex()) {
992 if (container.empty()) {
995 return SymEngine::make_set_union(
999 if (is_a<Integers>(*o) or is_a<Naturals>(*o) or is_a<Naturals0>(*o)) {
1000 set_basic container;
1001 for (
const auto &elem : container_) {
1002 if (is_a<Integers>(*o)) {
1003 if (not is_a<Integer>(*elem)) {
1006 }
else if (is_a<Naturals>(*o)) {
1007 if (not(is_a<Integer>(*elem)
1008 and down_cast<const Integer &>(*elem).is_positive())) {
1009 container.insert(elem);
1012 if (not(is_a<Integer>(*elem)
1013 and not down_cast<const Integer &>(*elem)
1015 container.insert(elem);
1019 if (container.empty()) {
1022 return SymEngine::make_set_union({o,
finiteset(container)});
1025 if (is_a<UniversalSet>(*o) or is_a<EmptySet>(*o) or is_a<Union>(*o)) {
1026 return (*o).set_union(rcp_from_this_cast<const Set>());
1028 return SymEngine::make_set_union({rcp_from_this_cast<const Set>(), o});
1031 RCP<const Set> FiniteSet::set_intersection(
const RCP<const Set> &o)
const
1033 if (is_a<FiniteSet>(*o)) {
1034 return SymEngine::set_intersection(
1035 {rcp_from_this_cast<const Set>(), o});
1037 if (is_a<Interval>(*o)) {
1038 set_basic container;
1039 for (
const auto &a : container_) {
1040 auto contain = o->contains(a);
1041 if (
eq(*contain, *boolTrue))
1043 if (is_a<Contains>(*contain))
1044 return make_set_intersection(
1045 {rcp_from_this_cast<const Set>(), o});
1049 if (is_a<Complexes>(*o) or is_a<Reals>(*o) or is_a<Rationals>(*o)) {
1052 for (
const auto &elem : container_) {
1054 if (!down_cast<const Number &>(*elem).is_complex()) {
1055 if (!is_a<Rationals>(*o)
1056 or down_cast<const Number &>(*elem).is_exact()) {
1060 if (is_a<Complexes>(*o)) {
1065 others.insert(elem);
1069 if (others.empty()) {
1072 return SymEngine::make_set_intersection({o,
finiteset(others)});
1075 if (others.empty()) {
1078 others.insert(kept.begin(), kept.end());
1079 return SymEngine::make_set_intersection({o,
finiteset(others)});
1083 if (is_a<Integers>(*o) or is_a<Naturals>(*o) or is_a<Naturals0>(*o)) {
1084 set_basic kept_integers;
1086 for (
const auto &elem : container_) {
1088 if (is_a<Integers>(*o) and is_a<Integer>(*elem)) {
1089 kept_integers.
insert(elem);
1090 }
else if (is_a<Naturals>(*o) and is_a<Integer>(*elem)
1091 and down_cast<const Integer &>(*elem)
1093 kept_integers.insert(elem);
1094 }
else if (is_a<Naturals0>(*o) and is_a<Integer>(*elem)
1095 and (not down_cast<const Integer &>(*elem)
1097 kept_integers.insert(elem);
1100 others.insert(elem);
1103 if (kept_integers.empty()) {
1104 if (others.empty()) {
1107 return SymEngine::make_set_intersection(
1111 if (others.empty()) {
1114 others.insert(kept_integers.begin(), kept_integers.end());
1115 return SymEngine::make_set_intersection(
1120 if (is_a<UniversalSet>(*o) or is_a<EmptySet>(*o) or is_a<Union>(*o)) {
1121 return (*o).set_intersection(rcp_from_this_cast<const Set>());
1123 return make_set_intersection({rcp_from_this_cast<const Set>(), o});
1126 RCP<const Set> FiniteSet::set_complement(
const RCP<const Set> &o)
const
1128 if (is_a<FiniteSet>(*o)) {
1129 const FiniteSet &other = down_cast<const FiniteSet &>(*o);
1130 set_basic container;
1132 container_.begin(), container_.end(),
1138 if (is_a<Interval>(*o)) {
1140 auto &other = down_cast<const Interval &>(*o);
1141 RCP<const Number> last = other.get_start();
1142 RCP<const Number> a_num;
1144 bool left_open = other.get_left_open(),
1145 right_open = other.get_right_open();
1146 for (
auto it = container_.begin(); it != container_.end(); it++) {
1147 if (
eq(*
max({*it, other.get_start()}), *other.get_start())) {
1148 if (
eq(**it, *other.get_start()))
1152 if (
eq(*
max({*it, other.get_end()}), **it)) {
1153 if (
eq(**it, *other.get_end()))
1158 a_num = rcp_static_cast<const Number>(*it);
1159 intervals.insert(
interval(last, a_num, left_open,
true));
1167 if (
eq(*
max({last, other.get_end()}), *other.get_end())) {
1169 interval(last, other.get_end(), left_open, right_open));
1172 return SymEngine::make_set_union(intervals);
1174 return make_rcp<const Complement>(
1175 SymEngine::make_set_union(intervals),
finiteset(rest));
1179 return SymEngine::set_complement_helper(rcp_from_this_cast<const Set>(), o);
1182 RCP<const Set> FiniteSet::create(
const set_basic &container)
const
1187 Union::Union(
const set_set &in)
1188 : container_(in){SYMENGINE_ASSIGN_TYPEID()
1189 SYMENGINE_ASSERT(Union::is_canonical(in))}
1193 hash_t seed = SYMENGINE_UNION;
1194 for (
const auto &a : container_)
1195 hash_combine<Basic>(seed, *a);
1201 if (is_a<Union>(o)) {
1202 const Union &other = down_cast<const Union &>(o);
1203 return unified_eq(container_, other.container_);
1208 bool Union::is_canonical(
const set_set &in)
1213 for (
const auto &s : in) {
1214 if (is_a<FiniteSet>(*s)) {
1225 SYMENGINE_ASSERT(is_a<Union>(o))
1226 const Union &other = down_cast<const Union &>(o);
1230 RCP<const Set> Union::set_union(
const RCP<const Set> &o)
const
1232 set_set container(container_);
1233 for (
auto iter = container.begin(); iter != container.end(); ++iter) {
1234 auto temp = o->set_union(*iter);
1237 auto un = SymEngine::make_set_union({o, *iter});
1238 if (not
eq(*temp, *un)) {
1239 iter = container.erase(iter);
1240 container.insert(temp);
1241 return SymEngine::set_union(container);
1244 container.insert(o);
1245 return SymEngine::make_set_union(container);
1248 RCP<const Set> Union::set_intersection(
const RCP<const Set> &o)
const
1251 for (
auto &a : container_) {
1252 container.
insert(a->set_intersection(o));
1254 return SymEngine::set_union(container);
1257 RCP<const Set> Union::set_complement(
const RCP<const Set> &o)
const
1260 for (
auto &a : container_) {
1261 container.
insert(a->set_complement(o));
1263 return SymEngine::set_intersection(container);
1266 RCP<const Boolean> Union::contains(
const RCP<const Basic> &o)
const
1268 for (
auto &a : container_) {
1269 auto contain = a->contains(o);
1270 if (
eq(*contain, *boolTrue)) {
1271 return boolean(
true);
1273 if (is_a<Contains>(*contain))
1274 throw NotImplementedError(
"Not implemented");
1276 return boolean(
false);
1279 RCP<const Set> Union::create(
const set_set &in)
const
1281 return SymEngine::set_union(in);
1286 vec_basic v(container_.begin(), container_.end());
1290 Intersection::Intersection(
const set_set &in)
1291 : container_(in){SYMENGINE_ASSIGN_TYPEID()
1296 hash_t seed = SYMENGINE_INTERSECTION;
1297 for (
const auto &a : container_)
1298 hash_combine<Basic>(seed, *a);
1304 if (is_a<Intersection>(o)) {
1305 const Intersection &other = down_cast<const Intersection &>(o);
1306 return unified_eq(container_, other.container_);
1311 bool Intersection::is_canonical(
const set_set &in)
1320 SYMENGINE_ASSERT(is_a<Intersection>(o))
1321 const Intersection &other = down_cast<const Intersection &>(o);
1325 RCP<const Set> Intersection::set_union(
const RCP<const Set> &o)
const
1328 for (
auto &a : container_) {
1329 container.
insert(a->set_union(o));
1331 return SymEngine::set_intersection(container);
1334 RCP<const Set> Intersection::set_intersection(
const RCP<const Set> &o)
const
1336 set_set container(container_);
1337 for (
auto iter = container.
begin(); iter != container.
end(); ++iter) {
1338 auto temp = o->set_intersection(*iter);
1341 auto un = SymEngine::make_set_intersection({o, *iter});
1342 if (not
eq(*temp, *un)) {
1343 iter = container.
erase(iter);
1345 return SymEngine::set_intersection(container);
1349 return SymEngine::make_set_intersection(container);
1352 RCP<const Set> Intersection::set_complement(
const RCP<const Set> &o)
const
1355 for (
auto &a : container_) {
1356 container.
insert(a->set_complement(o));
1358 return SymEngine::set_intersection(container);
1361 RCP<const Boolean> Intersection::contains(
const RCP<const Basic> &o)
const
1363 for (
auto &a : container_) {
1364 auto contain = a->contains(o);
1365 if (
eq(*contain, *boolTrue)) {
1366 return boolean(
true);
1368 if (is_a<Contains>(*contain))
1369 throw NotImplementedError(
"Not implemented");
1371 return boolean(
false);
1374 RCP<const Set> Intersection::create(
const set_set &in)
const
1376 return SymEngine::set_intersection(in);
1381 vec_basic v(container_.begin(), container_.end());
1385 Complement::Complement(
const RCP<const Set> &universe,
1386 const RCP<const Set> &container)
1387 : universe_(universe), container_(container){SYMENGINE_ASSIGN_TYPEID()}
1391 hash_t seed = SYMENGINE_COMPLEMENT;
1392 hash_combine<Basic>(seed, *universe_);
1393 hash_combine<Basic>(seed, *container_);
1399 if (is_a<Complement>(o)) {
1400 const Complement &other = down_cast<const Complement &>(o);
1401 return unified_eq(universe_, other.universe_)
1402 and unified_eq(container_, other.container_);
1409 SYMENGINE_ASSERT(is_a<Complement>(o))
1410 const Complement &other = down_cast<const Complement &>(o);
1419 RCP<const Boolean> Complement::contains(
const RCP<const Basic> &a)
const
1422 {universe_->contains(a), logical_not(container_->contains(a))});
1425 RCP<const Set> Complement::set_union(
const RCP<const Set> &o)
const
1428 RCP<const Set> ocomplement = o->set_complement(universe_);
1429 RCP<const Set> intersect
1430 = SymEngine::set_intersection({container_, ocomplement});
1431 return intersect->set_complement(universe_);
1434 RCP<const Set> Complement::set_intersection(
const RCP<const Set> &o)
const
1436 return SymEngine::set_intersection({rcp_from_this_cast<const Set>(), o});
1439 RCP<const Set> Complement::set_complement(
const RCP<const Set> &o)
const
1441 auto newuniv = SymEngine::set_union({o, universe_});
1442 return container_->set_complement(newuniv);
1445 ConditionSet::ConditionSet(
const RCP<const Basic> &sym,
1446 const RCP<const Boolean> &condition)
1447 : sym(sym), condition_(condition)
1449 SYMENGINE_ASSIGN_TYPEID()
1450 SYMENGINE_ASSERT(ConditionSet::is_canonical(sym, condition))
1453 bool ConditionSet::is_canonical(const RCP<const
Basic> &sym,
1454 const RCP<const Boolean> &condition)
1456 if (
eq(*condition, *boolFalse) or
eq(*condition, *boolTrue)
1457 or not is_a_sub<Symbol>(*sym)) {
1459 }
else if (is_a<Contains>(*condition)) {
1467 hash_t seed = SYMENGINE_CONDITIONSET;
1468 hash_combine<Basic>(seed, *sym);
1469 hash_combine<Basic>(seed, *condition_);
1475 if (is_a<ConditionSet>(o)) {
1476 const ConditionSet &other = down_cast<const ConditionSet &>(o);
1477 return unified_eq(sym, other.get_symbol())
1478 and unified_eq(condition_, other.get_condition());
1485 SYMENGINE_ASSERT(is_a<ConditionSet>(o))
1486 const ConditionSet &other = down_cast<const ConditionSet &>(o);
1495 RCP<const Set> ConditionSet::set_union(
const RCP<const Set> &o)
const
1497 return SymEngine::make_set_union({o, rcp_from_this_cast<const Set>()});
1500 RCP<const Set> ConditionSet::set_intersection(
const RCP<const Set> &o)
const
1502 if (not is_a<ConditionSet>(*o)) {
1503 return conditionset(sym, logical_and({condition_, o->contains(sym)}));
1505 return make_set_intersection({rcp_from_this_cast<const Set>(), o});
1508 RCP<const Set> ConditionSet::set_complement(
const RCP<const Set> &o)
const
1510 return make_rcp<const Complement>(o, rcp_from_this_cast<const Set>());
1513 RCP<const Boolean> ConditionSet::contains(
const RCP<const Basic> &o)
const
1517 auto cond = condition_->subs(d);
1518 if (not is_a_Boolean(*cond)) {
1519 throw SymEngineException(
"expected an object of type Boolean");
1521 return rcp_static_cast<const Boolean>(cond);
1524 ImageSet::ImageSet(
const RCP<const Basic> &sym,
const RCP<const Basic> &expr,
1525 const RCP<const Set> &base)
1526 : sym_(sym), expr_(expr), base_(base)
1528 SYMENGINE_ASSIGN_TYPEID()
1529 SYMENGINE_ASSERT(ImageSet::is_canonical(sym, expr, base));
1534 hash_t seed = SYMENGINE_IMAGESET;
1535 hash_combine<Basic>(seed, *sym_);
1536 hash_combine<Basic>(seed, *expr_);
1537 hash_combine<Basic>(seed, *base_);
1543 if (is_a<ImageSet>(o)) {
1544 const ImageSet &other = down_cast<const ImageSet &>(o);
1545 return unified_eq(sym_, other.sym_) and unified_eq(expr_, other.expr_)
1546 and unified_eq(base_, other.base_);
1553 SYMENGINE_ASSERT(is_a<ImageSet>(o))
1554 const ImageSet &other = down_cast<const ImageSet &>(o);
1568 bool ImageSet::is_canonical(
const RCP<const Basic> &sym,
1569 const RCP<const Basic> &expr,
1570 const RCP<const Set> &base)
1572 if (not is_a_sub<Symbol>(*sym) or
eq(*expr, *sym) or
is_a_Number(*expr)
1578 RCP<const Boolean> ImageSet::contains(
const RCP<const Basic> &a)
const
1580 throw SymEngineException(
"Not implemented");
1583 RCP<const Set> ImageSet::set_union(
const RCP<const Set> &o)
const
1585 return make_set_union({rcp_from_this_cast<const Set>(), o});
1588 RCP<const Set> ImageSet::set_intersection(
const RCP<const Set> &o)
const
1590 return SymEngine::set_intersection({rcp_from_this_cast<const Set>(), o});
1593 RCP<const Set> ImageSet::set_complement(
const RCP<const Set> &o)
const
1595 return SymEngine::set_complement(rcp_from_this_cast<const Set>(), o);
1598 RCP<const Set> ImageSet::create(
const RCP<const Basic> &sym,
1599 const RCP<const Basic> &expr,
1600 const RCP<const Set> &base)
const
1602 return imageset(sym, expr, base);
1605 RCP<const Set> set_union(
const set_set &in)
1608 set_basic combined_FiniteSet;
1609 for (
auto it = in.begin(); it != in.end(); ++it) {
1610 if (is_a<FiniteSet>(**it)) {
1611 const FiniteSet &other = down_cast<const FiniteSet &>(**it);
1612 combined_FiniteSet.insert(other.get_container().begin(),
1613 other.get_container().end());
1614 }
else if (is_a<UniversalSet>(**it)) {
1616 }
else if (not is_a<EmptySet>(**it)) {
1620 if (input.empty()) {
1622 }
else if (input.size() == 1 && combined_FiniteSet.empty()) {
1623 return *input.begin();
1627 RCP<const Set> combined_Rest =
finiteset(combined_FiniteSet);
1628 for (
auto it = input.begin(); it != input.end(); ++it) {
1629 combined_Rest = combined_Rest->set_union(*it);
1631 return combined_Rest;
1634 RCP<const Set> set_intersection(
const set_set &in)
1643 for (
const auto &input : in) {
1644 if (is_a<EmptySet>(*input)) {
1646 }
else if (not is_a<UniversalSet>(*input)) {
1647 incopy.insert(input);
1653 if (incopy.size() == 1)
1654 return *incopy.begin();
1658 for (
const auto &input : incopy) {
1659 if (is_a<FiniteSet>(*input)) {
1665 if (fsets.
size() != 0) {
1666 const FiniteSet &fs = down_cast<const FiniteSet &>(**fsets.
begin());
1667 auto cont = fs.get_container();
1670 for (
const auto &fselement : cont) {
1671 bool present =
true;
1672 for (
const auto &fset : fsets) {
1673 auto contain = fset->contains(fselement);
1674 if (not(
eq(*contain, *boolTrue) or
eq(*contain, *boolFalse))) {
1675 return make_set_intersection(incopy);
1677 present = present and
eq(*contain, *boolTrue);
1681 for (
const auto &oset : othersets) {
1682 auto contain = oset->contains(fselement);
1683 if (not(
eq(*contain, *boolTrue) or
eq(*contain, *boolFalse))) {
1684 return make_set_intersection(incopy);
1686 present = present and
eq(*contain, *boolTrue);
1689 finalfs.insert(fselement);
1695 for (
auto it = incopy.begin(); it != incopy.end(); ++it) {
1696 if (is_a<Union>(**it)) {
1697 auto container = down_cast<const Union &>(**it).get_container();
1699 auto other = SymEngine::set_intersection(incopy);
1701 for (
const auto &c : container) {
1702 usets.
insert(SymEngine::set_intersection({c, other}));
1704 return SymEngine::set_union(usets);
1709 for (
auto it = incopy.begin(); it != incopy.end(); ++it) {
1710 if (is_a<Complement>(**it)) {
1712 = down_cast<const Complement &>(**it).get_container();
1713 auto universe = down_cast<const Complement &>(**it).get_universe();
1715 incopy.insert(universe);
1716 auto other = SymEngine::set_intersection(incopy);
1717 return SymEngine::set_complement(other, container);
1726 if (incopy.size() > 1) {
1727 auto temp = *incopy.begin();
1729 for (; it != incopy.end(); ++it) {
1730 temp = temp->set_intersection(*it);
1735 return make_set_intersection(incopy);
1739 RCP<const Set> set_complement_helper(
const RCP<const Set> &container,
1740 const RCP<const Set> &universe)
1742 if (is_a<Union>(*universe)) {
1743 auto univ = down_cast<const Union &>(*universe).get_container();
1745 for (
auto &a : univ) {
1746 container_.
insert(container->set_complement(a));
1748 return SymEngine::set_union(container_);
1749 }
else if (is_a<EmptySet>(*universe)) {
1751 }
else if (is_a<FiniteSet>(*universe)) {
1752 const FiniteSet &other = down_cast<const FiniteSet &>(*universe);
1753 set_basic container_;
1755 for (
const auto &a : other.get_container()) {
1756 auto contain = container->contains(a);
1757 if (
eq(*contain, *boolFalse)) {
1759 }
else if (is_a<Contains>(*contain)) {
1766 return SymEngine::set_union(
1768 make_rcp<const Complement>(
finiteset(rest), container)});
1771 return make_rcp<const Complement>(universe, container);
1774 RCP<const Set> set_complement(
const RCP<const Set> &universe,
1775 const RCP<const Set> &container)
1778 return container->set_complement(universe);
1782 const RCP<const Boolean> &condition)
1784 if (
eq(*condition, *
boolean(
false))) {
1786 }
else if (
eq(*condition, *
boolean(
true))) {
1789 if (is_a<And>(*condition)) {
1790 auto cont = down_cast<const And &>(*condition).get_container();
1793 for (
auto it = cont.begin(); it != cont.end(); it++) {
1794 if (is_a<Contains>(**it)
1795 and
eq(*down_cast<const Contains &>(**it).get_expr(), *sym)
1796 and is_a<FiniteSet>(
1797 *down_cast<const Contains &>(**it).get_set())) {
1798 auto fset = down_cast<const Contains &>(**it).get_set();
1800 = down_cast<const FiniteSet &>(*fset).get_container();
1802 for (
const auto &elem : fcont) {
1803 if (not(
is_a_Number(*elem) or is_a<Constant>(*elem))) {
1812 auto restCont = cont;
1813 restCont.erase(*it);
1814 auto restCond = logical_and(restCont);
1817 auto contain = restCond->subs(d);
1818 if (
eq(*contain, *
boolean(
true))) {
1820 }
else if (not
eq(*contain, *
boolean(
false))) {
1823 throw SymEngineException(
"element should have "
1824 "been removed within "
1833 if (not present.
empty()) {
1835 return SymEngine::set_union(
1839 if (is_a<Contains>(*condition)) {
1840 return down_cast<const Contains &>(*condition).get_set();
1842 return make_rcp<const ConditionSet>(sym, condition);
Classes and functions relating to the binary operation of addition.
RCP< const Basic > add(const RCP< const Basic > &a, const RCP< const Basic > &b)
Adds two objects (safely).
The lowest unit of symbolic representation.
int compare(const Basic &o) const override
bool __eq__(const Basic &o) const override
Test equality.
hash_t __hash__() const override
int compare(const Basic &o) const override
bool __eq__(const Basic &o) const override
Test equality.
hash_t __hash__() const override
bool __eq__(const Basic &o) const override
Test equality.
int compare(const Basic &o) const override
hash_t __hash__() const override
bool __eq__(const Basic &o) const override
Test equality.
int compare(const Basic &o) const override
bool __eq__(const Basic &o) const override
Test equality.
vec_basic get_args() const override
Returns the list of arguments.
int compare(const Basic &o) const override
hash_t __hash__() const override
int compare(const Basic &o) const override
vec_basic get_args() const override
Returns the list of arguments.
bool __eq__(const Basic &o) const override
Test equality.
Main namespace for SymEngine package.
bool is_a_Number(const Basic &b)
RCP< const Set > interval(const RCP< const Number > &start, const RCP< const Number > &end, const bool left_open=false, const bool right_open=false)
RCP< const Boolean > Ge(const RCP< const Basic > &lhs, const RCP< const Basic > &rhs)
Convenience function returning LessThan object.
RCP< const Complexes > complexes()
std::enable_if< std::is_integral< T >::value, RCP< const Integer > >::type integer(T i)
RCP< const Reals > reals()
RCP< const Basic > max(const vec_basic &arg)
Canonicalize Max:
bool eq(const Basic &a, const Basic &b)
Checks equality for a and b
RCP< const Boolean > Lt(const RCP< const Basic > &lhs, const RCP< const Basic > &rhs)
Returns the canonicalized StrictLessThan object from the arguments.
RCP< const Naturals > naturals()
RCP< const EmptySet > emptyset()
RCP< const Basic > ceiling(const RCP< const Basic > &arg)
Canonicalize Ceiling:
RCP< const Integers > integers()
RCP< const UniversalSet > universalset()
RCP< const Basic > floor(const RCP< const Basic > &arg)
Canonicalize Floor:
RCP< const Set > conditionset(const RCP< const Basic > &sym, const RCP< const Boolean > &condition)
RCP< const Boolean > Eq(const RCP< const Basic > &lhs)
Returns the canonicalized Equality object from a single argument.
RCP< const Set > finiteset(const set_basic &container)
int unified_compare(const T &a, const T &b)
bool neq(const Basic &a, const Basic &b)
Checks inequality for a and b
RCP< const Naturals0 > naturals0()
RCP< const Rationals > rationals()
T set_difference(T... args)