/// (solver-backed expansion wins decisively), so use a deliberately coarse power-of-two boundary.
/// Dependent or otherwise unresolved domains deliberately return `None`: native expansion already
/// handles them one binding at a time, whereas guessing a solver-backed path risks changing which
/// Detect the supported dependent-generator shape where native expansion repeatedly duplicates a
/// nested comprehension. The solver expander binds the outer assignment first and then expands the
/// This remains a narrow syntactic check: expression generators and missing domains stay native.
/// A fully quantified return can be passed to the temporary solver without dummy variables. For
/// mixed returns, require a quantified-only conjunction: this recognises selective filters such as
/// the Pythagorean antecedent while rejecting single weak comparisons and pairwise representation
/// Look only where an `and` can filter AC identities: at the return root or in an implication's
/// antecedent. A conjunction in the consequent describes the emitted constraint; treating it as a
/// evaluation) so huge `and([x > k_i, ...])` expansions collapse before rule-trace snapshots and
fn simplify_expanded_ac_results(results: Vec<Expr>, ac_operator: ACOperatorKind) -> Vec<Expr> {
let simplified = simplify_expression(ac_operator.as_expression(into_matrix_expr!(results)));
fn expand_ac_comprehension_native(expr: &Expr, symbols: &SymbolTable) -> ApplicationResult {
/// 6. Solve the rewritten temporary model with Minion and keep only quantified assignments from
fn expand_comprehension_via_solver(expr: &Expr, symbols: &SymbolTable) -> ApplicationResult {
/// 4. Materialise quantified declarations as temporary `find` declarations in the temporary model.
fn expand_comprehension_via_solver_ac(expr: &Expr, symbols: &SymbolTable) -> ApplicationResult {
debug!(why=%e, "via-solver-ac comprehension expansion failed, falling back to native expansion");
/// Such a guard cannot be evaluated during expansion, however the quantified variables are bound.
fn quantified_declarations(comprehension: &Comprehension) -> Option<Vec<DeclarationPtr>> {
rewrite_int_ranges_in_domain_ptr(&mut rewritten, replacements_by_id, replacements_by_name);