Skip to content

Add on-demand zero lemmas for MCSAT-supplement nonlinear relaxation#648

Open
ahmed-irfan wants to merge 5 commits into
masterfrom
mcsat-relax-zero-lemmas
Open

Add on-demand zero lemmas for MCSAT-supplement nonlinear relaxation#648
ahmed-irfan wants to merge 5 commits into
masterfrom
mcsat-relax-zero-lemmas

Conversation

@ahmed-irfan

@ahmed-irfan ahmed-irfan commented Jul 2, 2026

Copy link
Copy Markdown
Member

Summary

  • Each nonlinear monomial abstracted for simplex (mcsat_relax_pprod) now also gets on-demand "zero lemma" clauses relating the abstraction variable z to its factors (z=0 <-> some factor=0), checked against live simplex values from propagate/final_check:
    • xi=0 while z≠0not(xi=0) or (z=0)
    • z=0 while every factor is confirmed nonzero → not(z=0) or (x1=0) or ... or (xk=0)
  • Checking is gated by the existing mcsat-supplement-check parameter (both/final-only), same as the expensive nested-MCSAT check it complements — no new config surface.
  • Atoms for the lemma are pre-built once, eagerly, at abstraction time (base decision level), since simplex only supports creating new theory atoms there, not mid-search; the on-demand check only ever looks up and combines those cached literals into new clauses. A per-monomial "done" bitmask prevents re-adding the same clause every round, since these literals are typically fresh/unassigned and nothing else forces the search to move past a repeated violation.
  • The mid-search checking logic lives in a new file, context_mcsat_relax.c, following the existing context_solver.c/context_simplifier.c pattern of sharing context_t internals via context_utils.h. Only the atom/monomial construction logic (mcsat_relax_pprod and friends) stays in context.c, since it's tightly coupled to the rest of the internalization pass there.

Test plan

  • make MODE=debug bin — clean build
  • make mcsat-check — 700/700 pass
  • make check — 1731/1731 pass
  • tests/api/test_cdclt_mcsat_supplement.c — passes
  • Manual probes confirming correct SAT/UNSAT results for monomials with factors referenced nowhere else in the problem (e.g. x²y³z), including under mcsat-supplement-check=final-only

Each nonlinear monomial abstracted for simplex (mcsat_relax_pprod) now also
gets on-demand "zero lemma" clauses relating the abstraction variable to its
factors (z=0 <-> some factor=0), checked against live simplex values from
propagate/final_check and gated by the existing mcsat-supplement-check
parameter. Atoms are pre-built once at abstraction time (base level), since
simplex only supports creating new atoms there, not mid-search; the on-demand
check only ever combines those cached literals into new clauses.
@ahmed-irfan
ahmed-irfan requested a review from disteph July 2, 2026 09:11
The reverse clause (z=0 -> some factor=0) was firing whenever z=0 alone,
without checking the factors, which is sound (the clause is a tautology)
but looser than intended. Only fire it when z=0 and every factor is
confirmed nonzero, matching the documented precondition.
@coveralls

coveralls commented Jul 2, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 69.922% (+0.02%) from 69.901% — mcsat-relax-zero-lemmas into master

ahmed-irfan and others added 3 commits July 2, 2026 02:32
Split the mid-search checking logic (mcsat_relax_check_zero_lemma,
context_check_mcsat_relax_zero_lemmas) out of context.c into its own file,
following the existing context_solver.c/context_simplifier.c pattern of
sharing context_t internals via context_utils.h. Only the atom/monomial
construction logic (mcsat_relax_pprod and friends) stays in context.c, since
it's tightly coupled to the rest of the internalization pass there.

Required exposing three previously-static context.c helpers via
context_utils.h: context_mcsat_relaxation_enabled,
context_get_mcsat_relax_zero_lemma_done, translate_code_to_arith.
Collateral damage from an earlier edit that used this comment's text as an
anchor and never restored it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants