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} → Bool → Std.Sat.AIG.Decl α
A node with a constant output value.
- atom: {α : Type} → α → Std.Sat.AIG.Decl α
An input node to the circuit.
- gate: {α : Type} → Nat → Nat → Bool → Bool → Std.Sat.AIG.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.
Instances For
Equations
- Std.Sat.AIG.instHashableDecl = { hash := Std.Sat.AIG.hashDecl✝ }
Equations
- Std.Sat.AIG.instReprDecl = { reprPrec := Std.Sat.AIG.reprDecl✝ }
Equations
- Std.Sat.AIG.instDecidableEqDecl = Std.Sat.AIG.decEqDecl✝
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} [inst : Hashable α] [inst_1 : DecidableEq α] {decls : Array (Std.Sat.AIG.Decl α)}, Std.Sat.AIG.Cache.WF decls ∅
- push_id: ∀ {α : Type} [inst : Hashable α] [inst_1 : DecidableEq α] {decls : Array (Std.Sat.AIG.Decl α)} {cache : Std.HashMap (Std.Sat.AIG.Decl α) Nat} {decl : Std.Sat.AIG.Decl α}, Std.Sat.AIG.Cache.WF decls cache → Std.Sat.AIG.Cache.WF (decls.push decl) cache
- push_cache: ∀ {α : Type} [inst : Hashable α] [inst_1 : DecidableEq α] {decls : Array (Std.Sat.AIG.Decl α)} {cache : Std.HashMap (Std.Sat.AIG.Decl α) Nat} {decl : Std.Sat.AIG.Decl α}, Std.Sat.AIG.Cache.WF decls cache → Std.Sat.AIG.Cache.WF (decls.push decl) (cache.insert decl decls.size)
Instances For
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 }
Instances For
Create an empty Cache
, valid with respect to any Array Decl
.
Equations
- Std.Sat.AIG.Cache.empty decls = ⟨∅, ⋯⟩
Instances For
Given a cache
, valid with respect to some decls
, we can extend the decls
without
extending the cache and remain valid.
Equations
- cache.noUpdate = ⟨cache.val, ⋯⟩
Instances For
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, ⋯⟩
Instances For
Contains the index of decl
in decls
along with a proof that the index is indeed correct.
Instances For
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
).
If Cache.get? decl
returns some i
then decls[i] = decl
holds.
An And Inverter Graph together with a cache for subterm sharing.
- decls : Array (Std.Sat.AIG.Decl α)
- cache : Std.Sat.AIG.Cache α self.decls
- invariant : Std.Sat.AIG.IsDAG α self.decls
In order to be a valid AIG,
decls
must form a DAG.
Instances For
In order to be a valid AIG, decls
must form a DAG.
An AIG
with an empty AIG and cache.
Equations
- Std.Sat.AIG.empty = { decls := #[], cache := Std.Sat.AIG.Cache.empty #[], invariant := ⋯ }
Instances For
Equations
- Std.Sat.AIG.instMembership = { mem := Std.Sat.AIG.Mem }
A Ref
into aig1
is also valid for aig2
if aig1
is smaller than aig2
.
Equations
- ref.cast h = { gate := ref.gate, hgate := ⋯ }
Instances For
A pair of Ref
s, useful for LawfulOperator
s that act on two Ref
s at a time.
- lhs : aig.Ref
- rhs : aig.Ref
Instances For
The Ref.cast
equivalent for BinaryInput
.
Equations
- input.cast h = { lhs := input.lhs.cast h, rhs := input.rhs.cast h }
Instances For
A collection of 3 of Ref
s, useful for LawfulOperator
s that act on three Ref
s at a time,
in particular multiplexer style functions.
- discr : aig.Ref
- lhs : aig.Ref
- rhs : aig.Ref
Instances For
The Ref.cast
equivalent for TernaryInput
.
Equations
- input.cast h = { discr := input.discr.cast h, lhs := input.lhs.cast h, rhs := input.rhs.cast h }
Instances For
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 : Std.Sat.AIG α
The AIG that we are in.
- ref : self.aig.Ref
The reference to the node in
aig
that thisEntrypoint
targets.
Instances For
Transform an Entrypoint
into a graphviz string. Useful for debugging purposes.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Std.Sat.AIG.toGraphviz.invEdgeStyle isInv = if isInv = true then " [color=red]" else " [color=blue]"
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
A sequence of references bundled with their AIG.
- aig : Std.Sat.AIG α
- vec : self.aig.RefVec w
Instances For
A RefVec
bundled with constant distance to be shifted by.
- vec : aig.RefVec w
- distance : Nat
Instances For
A RefVec
bundled with a RefVec
as distance to be shifted by.
- n : Nat
- target : aig.RefVec m
- distance : aig.RefVec self.n
Instances For
A RefVec
to be extended to newWidth
.
- w : Nat
- vec : aig.RefVec self.w
Instances For
Evaluate an AIG.Entrypoint
using some assignment for atoms.
Equations
- ⟦assign, entry⟧ = Std.Sat.AIG.denote.go entry.ref.gate entry.aig.decls assign ⋯ ⋯
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Denotation of an AIG
at a specific Entrypoint
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
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.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
The denotation of the sub-DAG in the aig
at node start
is false for all assignments.
Equations
Instances For
The denotation of the Entrypoint
is false for all assignments.
Equations
- entry.Unsat = entry.aig.UnsatAt entry.ref.gate ⋯
Instances For
An input to an AIG gate.
- ref : aig.Ref
The node we are referring to.
- inv : Bool
Whether the node is inverted
Instances For
The Ref.cast
equivalent for Fanin
.
Equations
- fanin.cast h = { ref := fanin.ref.cast h, inv := fanin.inv }
Instances For
The input type for creating AIG and gates.
- lhs : aig.Fanin
- rhs : aig.Fanin
Instances For
The Ref.cast
equivalent for GateInput
.
Equations
- input.cast h = { lhs := input.lhs.cast h, rhs := input.rhs.cast h }
Instances For
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
- aig.mkAtom n = { aig := { decls := aig.decls.push (Std.Sat.AIG.Decl.atom n), cache := aig.cache.noUpdate, invariant := ⋯ }, ref := { gate := aig.decls.size, hgate := ⋯ } }
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
- aig.mkConst val = { aig := { decls := aig.decls.push (Std.Sat.AIG.Decl.const val), cache := aig.cache.noUpdate, invariant := ⋯ }, ref := { gate := aig.decls.size, hgate := ⋯ } }