@@ -431,6 +431,9 @@ namespace ratio
431
431
else if (auto lhs_xpr = dynamic_cast <riddle::atom_term *>(&lhs))
432
432
{ // we are dealing with atoms..
433
433
auto rhs_xpr = static_cast <riddle::atom_term *>(&rhs);
434
+ if (&lhs_xpr->get_type ().get_scope () != &rhs_xpr->get_type ().get_scope ().get_core () && !match (*lhs_xpr->get (riddle::this_kw), *rhs_xpr->get (riddle::this_kw)))
435
+ return false ; // the atoms are not in the same scope, so they cannot match..
436
+ // we check if the atoms' fields match..
434
437
std::queue<riddle::predicate *> q;
435
438
q.push (static_cast <riddle::predicate *>(&lhs_xpr->get_type ()));
436
439
while (!q.empty ())
@@ -444,29 +447,15 @@ namespace ratio
444
447
}
445
448
return true ;
446
449
}
447
- else if (auto lhs_xpr = dynamic_cast <riddle::component *>(&lhs))
448
- { // we are dealing with components..
449
- auto rhs_xpr = static_cast <riddle::component *>(&rhs);
450
- std::queue<riddle::component_type *> q;
451
- q.push (static_cast <riddle::component_type *>(&lhs_xpr->get_type ()));
452
- while (!q.empty ())
453
- {
454
- for (const auto &[f_name, f] : q.front ()->get_fields ())
455
- if (!f->is_synthetic () && !match (*lhs_xpr->get (f_name), *rhs_xpr->get (f_name)))
456
- return false ;
457
- for (const auto &pp : q.front ()->get_parents ())
458
- q.push (&*pp);
459
- q.pop ();
460
- }
461
- return true ;
462
- }
463
- else // should not happen..
464
- throw std::runtime_error (" Invalid type" );
450
+ else // we are dealing with components (and we have already checked their are not the same)..
451
+ return false ;
465
452
}
466
453
467
454
void solver::make_eq (riddle::term &lhs, riddle::term &rhs, const utils::lit &p)
468
455
{
469
- if (&lhs.get_type () != &rhs.get_type ()) // the types are different, so the constraint is always false..
456
+ if (&lhs == &rhs) // the terms are the same, so they are equal..
457
+ return ;
458
+ else if (&lhs.get_type () != &rhs.get_type ()) // the types are different, so the constraint is always false..
470
459
add_clause ({!p});
471
460
else if (auto lhs_xpr = dynamic_cast <riddle::arith_item *>(&lhs)) // we are dealing with an arithmetic constraint..
472
461
add_eq (lhs_xpr->get_lin (), static_cast <riddle::arith_item *>(&rhs)->get_lin (), p);
@@ -536,23 +525,8 @@ namespace ratio
536
525
q.pop ();
537
526
}
538
527
}
539
- else if (auto lhs_xpr = dynamic_cast <riddle::component *>(&lhs))
540
- { // we are dealing with components..
541
- auto rhs_xpr = static_cast <riddle::component *>(&rhs);
542
- std::queue<riddle::component_type *> q;
543
- q.push (static_cast <riddle::component_type *>(&lhs_xpr->get_type ()));
544
- while (!q.empty ())
545
- {
546
- for (const auto &[f_name, f] : q.front ()->get_fields ())
547
- if (!f->is_synthetic ())
548
- make_eq (*lhs_xpr->get (f_name), *rhs_xpr->get (f_name), p);
549
- for (const auto &pp : q.front ()->get_parents ())
550
- q.push (&*pp);
551
- q.pop ();
552
- }
553
- }
554
- else
555
- throw std::runtime_error (" Invalid type" );
528
+ else // we are dealing with components (and we have already checked their are not the same)..
529
+ add_clause ({!p});
556
530
}
557
531
558
532
void solver::make_neq (riddle::term &lhs, riddle::term &rhs, const utils::lit &p)
0 commit comments