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.
A circuit node. These are not recursive but instead contain indices into an AIG
, with inputs indexed by α
.
- const
{α : Type}
(b : Bool)
: Decl α
A node with a constant output value.
- atom
{α : Type}
(idx : α)
: Decl α
An input node to the circuit.
- gate
{α : Type}
(l r : Nat)
(linv rinv : Bool)
: Decl α
An AIG gate with configurable input nodes and polarity.
l
andr
are the input node indices whilelinv
andrinv
say whether there is an inverter on the left and right inputs, respectively.
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.const default }
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 decls = ⟨∅, ⋯⟩
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 And Inverter Graph together with a cache for subterm sharing.
In order to be a valid AIG,
decls
must form a DAG.
Instances For
An AIG
with an empty AIG and cache.
Equations
- Std.Sat.AIG.empty = { decls := #[], cache := Std.Sat.AIG.Cache.empty #[], invariant := ⋯ }
Equations
- Std.Sat.AIG.instMembership = { mem := Std.Sat.AIG.Mem }
The Ref.cast
equivalent for BinaryInput
.
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 sub-DAG in the aig
at node start
is false for all assignments.
The denotation of the Entrypoint
is false for all assignments.
An input to an AIG gate.
The input type for creating AIG and gates.
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
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
Instances For
Determine whether ref
is a Decl.const
with value b
.
Equations
- aig.isConstant { gate := gate, hgate := hgate } b = match aig.decls[gate] with | Std.Sat.AIG.Decl.const val => decide (b = val) | x => false