Formulas on bit vectors #
The vocabulary in which the describer of the succinct Cook–Levin theorem is written
(planning/succinct-cook-levin.md, S3): a field is a list of formulas read as a binary
number, least significant bit first (Fml.val); the fields of an index are slices of the
input bits (Fml.field); and the tests on fields are conjunctions and disjunctions
(andList, orList), equality with a constant or another field (eqConst, eqFields),
comparison (ltConst, ltFields), addition of a constant with its carry (addBits,
addConstRel), subtraction of a constant by the two's complement (subConstBits), padding
(padTo) and a multiplexer (mux). Every test is defined by a fold or a structural
recursion whose program is the same fold (FmlProg.lean), and every semantics lemma is an
equation on val.
Values of bit strings #
Equal-length bit strings with equal values are equal.
The bits of a number, padded to W bits with zeros (least significant bit first).
Equations
- MIPRE.SAT.padBits W l = l ++ List.replicate (W - List.length l) false
Instances For
The two's complement of a W-bit string: 2^W - v modulo 2^W.
Equations
- MIPRE.SAT.twosComp c = List.take (List.length c) (MIPRE.Cost.incBits (List.map not c))
Instances For
Basic connectives #
Conjunction of a list, as a fold.
Equations
Instances For
Disjunction of a list, as a fold.
Equations
Instances For
Fields #
The bits of a field: the values of its formulas, least significant first.
Equations
- MIPRE.SAT.Fml.bitsOf fs x = List.map (fun (x_1 : MIPRE.SAT.Fml) => MIPRE.SAT.Fml.eval x x_1) fs
Instances For
The value of a field.
Equations
- MIPRE.SAT.Fml.val fs x = MIPRE.Cost.bitsVal (MIPRE.SAT.Fml.bitsOf fs x)
Instances For
The field of W input bits starting at bit a.
Equations
- MIPRE.SAT.Fml.field a W = List.map MIPRE.SAT.Fml.inp (List.range' a W)
Instances For
Constant bits as formulas.
Equations
Instances For
Padding a field to W bits with zeros.
Equations
- MIPRE.SAT.Fml.padTo W fs = fs ++ List.replicate (W - fs.length) (MIPRE.SAT.Fml.const false)
Instances For
Equality #
The field fs equals the constant c (of the same length).
Equations
- MIPRE.SAT.Fml.eqConst fs c = List.foldl MIPRE.SAT.Fml.eqStep (MIPRE.SAT.Fml.const true) (fs.zip c)
Instances For
The fields fs and gs (of the same length) are equal.
Equations
- MIPRE.SAT.Fml.eqFields fs gs = List.foldl MIPRE.SAT.Fml.eqFStep (MIPRE.SAT.Fml.const true) (fs.zip gs)
Instances For
Comparison #
The step of the comparison with a constant, least significant bit first: the prefix is below the constant's prefix iff this bit is below, or equal with the lower bits below.
Equations
- lt.ltStep p = (p.1.not.and (MIPRE.SAT.Fml.const p.2)).or ((p.1.xnor (MIPRE.SAT.Fml.const p.2)).and lt)
Instances For
The field fs is below the constant c (of the same length).
Equations
- MIPRE.SAT.Fml.ltConst fs c = List.foldl MIPRE.SAT.Fml.ltStep (MIPRE.SAT.Fml.const false) (fs.zip c)
Instances For
The field fs is below the field gs (of the same length).
Equations
- MIPRE.SAT.Fml.ltFields fs gs = List.foldl MIPRE.SAT.Fml.ltFStep (MIPRE.SAT.Fml.const false) (fs.zip gs)
Instances For
Addition of a constant #
The sum of a field and a constant (of the same length) with a carry in: the sum bits and the carry out.
Equations
Instances For
The adder identity: sum + 2^W · carry = fs + c + cin.
The sum bits of a field and a constant.
Equations
- MIPRE.SAT.Fml.addConstBits fs c = (MIPRE.SAT.Fml.addBits fs c (MIPRE.SAT.Fml.const false)).1
Instances For
The carry out of the sum of a field and a constant.
Equations
- MIPRE.SAT.Fml.addConstCarry fs c = (MIPRE.SAT.Fml.addBits fs c (MIPRE.SAT.Fml.const false)).2
Instances For
gs = fs + c, exactly: the sum bits agree and there is no carry out.
Equations
- MIPRE.SAT.Fml.addConstRel fs gs c = (MIPRE.SAT.Fml.eqFields gs (MIPRE.SAT.Fml.addConstBits fs c)).and (MIPRE.SAT.Fml.addConstCarry fs c).not
Instances For
Subtraction of a constant #
The difference fs - c by the two's complement, correct when c ≤ fs.