Skip to main content

XorEngine

Struct XorEngine 

Source
pub struct XorEngine { /* private fields */ }
Expand description

A GF(2) constraint system with Gaussian reasoning under a partial assignment.

Implementations§

Source§

impl XorEngine

Source

pub fn new(num_vars: usize, eqs: &[XorEquation]) -> Self

Build the engine from recovered XOR equations over num_vars variables. Equations with a variable out of range are dropped (defensive; callers pass in-range systems).

Source

pub fn is_active(&self) -> bool

Is this system non-trivial enough to be worth running (≥1 equation)?

Source

pub fn analyze(&self, assign: &[Option<bool>]) -> XorStep

The core query: under partial assignment assign (None = unassigned), return the first XOR-forced literal or a conflict, each with an implied, correctly-shaped clause. Complete — it finds every linear consequence, not just per-equation ones — via Gaussian elimination over the unassigned variables with provenance tracking.

Source

pub fn all_consequences( &self, assign: &[Option<bool>], ) -> Result<Vec<(Lit, Vec<Lit>)>, Vec<Lit>>

Every XOR-forced literal under assign (with implied unit reasons), or Err(conflict clause) if the system is contradicted. This is the complete, oracle-checkable consequence set.

Trait Implementations§

Source§

impl Theory for XorEngine

DPLL(XOR): the engine plugs into CDCL’s theory hook. At each Boolean fixpoint it hands back the first XOR-forced unit clause, or a conflict clause, or nothing — every clause implied by the formula, so the solver stays sound while gaining Gaussian reasoning resolution cannot do.

Source§

fn propagate(&mut self, trail: &[Lit]) -> Vec<Vec<Lit>>

Given the solver’s current trail (assigned literals in assignment order), return a clause that is theory-entailed and currently unit or falsified (so the core will propagate or conflict on it), or None at a theory fixpoint. The trail is passed in order — and shrinks on backtrack — so an incremental theory can sync forward/undo against it (LIFO). The returned clauses MUST each be a sound consequence of the theory. Returning the whole batch of forced clauses at once (rather than one per call) lets an incremental theory amortise its work over one pass instead of rescanning per implication. An empty vec means “theory fixpoint”.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.