This module contains the basic definitions for an AIG (And Inverter Graph) in the style of AIGNET, as described in https://arxiv.org/pdf/1304.7861.pdf section 3. It consists of an AIG definition, a description of its semantics and basic operations to construct nodes in the AIG.
This datatype is isomorphic to a pair of a Nat
and a Bool
, however the Bool
is stored in the
lowest bit of the Nat
in order to save memory. It is used to describe an input to an AIG
circuit
node which consists of a Nat
describing the input node and a Bool
saying whether there is an inverter
on the input.
- of :: (
- val : Nat
- )
Equations
- Std.Sat.AIG.instHashableFanin = { hash := Std.Sat.AIG.hashFanin✝ }
Equations
- Std.Sat.AIG.instReprFanin = { reprPrec := Std.Sat.AIG.reprFanin✝ }
Equations
- Std.Sat.AIG.instInhabitedFanin = { default := { val := default } }
Flip the inverter bit according to val
.
Equations
- f.flip val = { val := Std.Sat.AIG.Fanin.val✝ f ^^^ val.toNat }
A circuit node. These are not recursive but instead contain indices into an AIG
, with inputs indexed by α
.
Equations
- Std.Sat.AIG.instHashableDecl = { hash := Std.Sat.AIG.hashDecl✝ }
Equations
- Std.Sat.AIG.instReprDecl = { reprPrec := Std.Sat.AIG.reprDecl✝ }
Equations
- Std.Sat.AIG.instInhabitedDecl = { default := Std.Sat.AIG.Decl.false }
Cache.WF xs
is a predicate asserting that a cache : HashMap (Decl α) Nat
is a valid lookup
cache for xs : Array (Decl α)
, that is, whenever cache.find? decl
returns an index into
xs : Array Decl
, xs[index] = decl
. Note that this predicate does not force the cache to be
complete, if there is no entry in the cache for some node, it can still exist in the AIG.
- empty {α : Type} [Hashable α] [DecidableEq α] {decls : Array (Decl α)} : WF decls ∅
- push_id {α : Type} [Hashable α] [DecidableEq α] {decls : Array (Decl α)} {cache : HashMap (Decl α) Nat} {decl : Decl α} (h : WF decls cache) : WF (decls.push decl) cache
- push_cache {α : Type} [Hashable α] [DecidableEq α] {decls : Array (Decl α)} {cache : HashMap (Decl α) Nat} {decl : Decl α} (h : WF decls cache) : WF (decls.push decl) (cache.insert decl decls.size)
A cache for reusing elements from decls
if they are available.
Equations
- Std.Sat.AIG.Cache α decls = { map : Std.HashMap (Std.Sat.AIG.Decl α) Nat // Std.Sat.AIG.Cache.WF decls map }
Create an empty Cache
, valid with respect to any Array Decl
.
Equations
- Std.Sat.AIG.Cache.empty = ⟨∅, ⋯⟩
Given a cache
, valid with respect to some decls
, we can extend the decls
and the cache
at the same time with the same values and remain valid.
Equations
- Std.Sat.AIG.Cache.insert decls cache decl = ⟨cache.val.insert decl decls.size, ⋯⟩
For a c : Cache α decls
, any index idx
that is a cache hit for some decl
is within bounds of decls
(i.e. idx < decls.size
).
An AIG
with an empty AIG and cache.
Equations
- Std.Sat.AIG.empty = { decls := #[Std.Sat.AIG.Decl.false], cache := Std.Sat.AIG.Cache.empty, hdag := ⋯, hzero := ⋯, hconst := ⋯ }
Equations
- Std.Sat.AIG.instMembership = { mem := Std.Sat.AIG.Mem }
A reference to a node within an AIG.
Instances For
A pair of Ref
s, useful for LawfulOperator
s that act on two Ref
s at a time.
Instances For
- Std.Sat.AIG.instLawfulOperatorBinaryInputMkAndCached
- Std.Sat.AIG.instLawfulOperatorBinaryInputMkBEqCached
- Std.Sat.AIG.instLawfulOperatorBinaryInputMkGate
- Std.Sat.AIG.instLawfulOperatorBinaryInputMkGateCached
- Std.Sat.AIG.instLawfulOperatorBinaryInputMkImpCached
- Std.Sat.AIG.instLawfulOperatorBinaryInputMkOrCached
- Std.Sat.AIG.instLawfulOperatorBinaryInputMkXorCached
The Ref.cast
equivalent for BinaryInput
.
Flip the current inverter settings of the BinaryInput
if linv
or rinv
is set respectively.
The Ref.cast
equivalent for TernaryInput
.
An entrypoint into an AIG
. This can be used to evaluate a circuit, starting at a certain node,
with AIG.denote
or to construct bigger circuits on top of this specific node.
- aig : AIG α
The AIG that we are in.
The reference to the node in
aig
that thisEntrypoint
targets.
Transform an Entrypoint
into a graphviz string. Useful for debugging purposes.
Equations
- One or more equations did not get rendered due to their size.
A sequence of references bundled with their AIG.
- aig : AIG α
A RefVec
bundled with constant distance to be shifted by.
Instances For
- Std.Tactic.BVDecide.BVExpr.bitblast.instLawfulVecOperatorShiftTargetBlastArithShiftRightConst
- Std.Tactic.BVDecide.BVExpr.bitblast.instLawfulVecOperatorShiftTargetBlastRotateLeft
- Std.Tactic.BVDecide.BVExpr.bitblast.instLawfulVecOperatorShiftTargetBlastRotateRight
- Std.Tactic.BVDecide.BVExpr.bitblast.instLawfulVecOperatorShiftTargetBlastShiftLeftConst
- Std.Tactic.BVDecide.BVExpr.bitblast.instLawfulVecOperatorShiftTargetBlastShiftRightConst
A RefVec
bundled with a RefVec
as distance to be shifted by.
A RefVec
to be extended to newWidth
.
- w : Nat
Evaluate an AIG.Entrypoint
using some assignment for atoms.
Denotation of an AIG
at a specific Entrypoint
.
Equations
- One or more equations did not get rendered due to their size.
Denotation of an AIG
at a specific Entrypoint
with the Entrypoint
being constructed on the fly.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
The denotation of the Entrypoint
is false for all assignments.
Add a new and inverter gate to the AIG in aig
. Note that this version is only meant for proving,
for production purposes use AIG.mkGateCached
and equality theorems to this one.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Add a new input node to the AIG in aig
. Note that this version is only meant for proving,
for production purposes use AIG.mkAtomCached
and equality theorems to this one.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Add a new constant node to aig
. Note that this version is only meant for proving,
for production purposes use AIG.mkConstCached
and equality theorems to this one.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Determine whether ref
is a Decl.const
with value b
.
Equations
- aig.isConstant { gate := gate, invert := invert, hgate := hgate } b = match aig.decls[gate] with | Std.Sat.AIG.Decl.false => decide (invert = b) | x => false
Get the value of ref
if it is constant.
Equations
- aig.getConstant { gate := gate, invert := invert, hgate := hgate } = match aig.decls[gate] with | Std.Sat.AIG.Decl.false => some invert | x => none