Skip to documentation
SLOP

tiny.smt.Literal

Reference tiny.smt Literal

Defined in sat.types.

A variable or its negation, packed into one 32-bit number.

API (10)

Actions

Public operations.

Fields and members

Public fields and members.

No direct callersNo direct callssat.typesLiteral
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/smt/src/sat/types.zig:117

zig
/// A variable or its negation, packed into one 32-bit number. A caller builds every clause and/// every assumption from literals. Variables are numbered from 0 in the order `Solver.addVariable`/// returns them.pub const Literal = struct {    /// The packed number: twice the variable index, plus one for a negated literal. Two literals    /// are equal when their `raw` values are equal, and callers compare literals that way.    raw: u32,    /// Returns the literal of variable `variable_index`, unnegated when `polarity` is true and    /// negated when it is false. Code that picks the sign at run time calls it. An index of    /// 2147483648 or more overflows the packed number, which panics in safe builds.    pub fn init(variable_index: u32, polarity: bool) Literal {        return .{ .raw = variable_index * 2 + if (polarity) @as(u32, 0) else @as(u32, 1) };    }    /// Returns the unnegated literal of variable `variable_index`. A caller writes a clause whose    /// signs it knows in its source.    pub fn positive(variable_index: u32) Literal {        return init(variable_index, true);    }    /// Returns the negated literal of variable `variable_index`. A caller writes a clause whose    /// signs it knows in its source.    pub fn negative(variable_index: u32) Literal {        return init(variable_index, false);    }    /// Returns the variable index of the literal. A caller finds which variable a literal names,    /// for example to check it against a variable count.    pub fn variable(self: Literal) u32 {        return self.raw >> 1;    }    /// Returns true for an unnegated literal. A caller reads a literal's sign to evaluate it under    /// an assignment.    pub fn isPositive(self: Literal) bool {        return self.raw & 1 == 0;    }    /// Returns the literal of the same variable with the opposite sign. An encoder calls it to    /// state the negation of a condition.    pub fn negated(self: Literal) Literal {        return .{ .raw = self.raw ^ 1 };    }    /// Returns the packed number as a `usize`. The solver indexes its per-literal lists of watching    /// clauses by it, two entries per variable.    pub fn index(self: Literal) usize {        return @intCast(self.raw);    }    /// Returns the literal a DIMACS number stands for: variable `|value| - 1`, negated when `value`    /// is negative. The DIMACS and proof readers call it on each number of a clause. The call    /// returns `error.InvalidDimacsLiteral` for 0, the number that ends a clause in that format.    /// The value -2147483648 makes it panic, because its negation does not fit in 32 bits.    pub fn fromDimacs(value: i32) !Literal {        if (value == 0) return error.InvalidDimacsLiteral;        const magnitude: u32 = @intCast(if (value < 0) -value else value);        return init(magnitude - 1, value > 0);    }    /// Returns the DIMACS number of the literal: the variable index plus one, negative for a    /// negated literal. The DIMACS and proof writers call it on each literal they print. Variable    /// index 2147483647 makes it panic, because its number does not fit in `i32`.    pub fn toDimacs(self: Literal) i32 {        const one_based: i32 = @intCast(self.variable() + 1);        return if (self.isPositive()) one_based else -one_based;    }};

Source: lib/smt/src/root.zig:105

zig
pub const Literal = sat.Literal;
Called byCallsNo direct callersLiteralinitLiteralfromDimacs
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.smt.src.profiling.satbuildRandomFormulaprivate sourcelib.smt.src.profiling.satincrementalAssumptionsprivate sourcelib.smt.src.properties.modeldrawAssumptionsprivate sourcelib.smt.src.properties.modeldrawClauseprivate sourcelib.smt.src.properties.modelretainedPremiseFixture+4 moreLiteralinit
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsLiteraltoDimacsLiteralisPositive
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.smt.src.properties.sat.ArtifactSoundnessP...propertyLiteralnegated
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsprivate sourcelib.smt.src.profiling.satbuildPigeonholeFormulaprivate sourcelib.smt.src.properties.modelredundantFormulatest sourcelib.smt.src.properties.modeltest: semantic proof oracle rejects a...private sourcelib.smt.src.properties.sat.BoundedStoreExerci...propertytest sourcelib.smt.src.sat.prooftest: proof artifact assumptions are ...+35 moreLiteralinitLiteralnegative
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsprivate sourcelib.smt.src.profiling.satbuildPigeonholeFormulaprivate sourcelib.smt.src.properties.modelredundantFormulatest sourcelib.smt.src.properties.modeltest: semantic proof oracle rejects a...test sourcelib.smt.src.sat.prooftest: proof artifact assumptions are ...test sourcelib.smt.src.sat.prooftest: proof artifact rejects a first ...+37 moreLiteralinitLiteralpositive
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersLiteralisPositiveLiteralvariableLiteraltoDimacs
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsLiteraltoDimacsLiteralvariable
Static calls · unresolved targets: 0 · external targets: 0.

Also reachable as

sat.Literal, sat.solver.Literal.

Complete caller list for Literal.init

9 direct callers.

Complete caller list for Literal.negative

40 direct callers.

Complete caller list for Literal.positive

42 direct callers.

Audit

Definitions10
Public names40
Members1
Version26.7.0
Revisiondaab053ee433