Skip to content

Commit d143cef

Browse files
committed
Comment tidying
1 parent 5b4da78 commit d143cef

4 files changed

Lines changed: 20 additions & 33 deletions

File tree

Valaig/Aig/BasicNew.lean

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public import Valaig.ForStd
88
namespace Valaig.Aig
99

1010
/--
11-
The metadata of an input in the Aig
11+
The metadata of an input in the Aig.
1212
-/
1313
structure Input where
1414
var : Var
@@ -19,18 +19,6 @@ end Input
1919

2020
/--
2121
The metadata of a latch in the Aig.
22-
23-
We require all latches to have a next state defined to make it easier to define their semantics,
24-
even though sometimes this next state can't be known at latch construction time as they are cyclic.
25-
To accomodate this, the next value should initially be set to a constant, before being subsequently
26-
overwritten.
27-
28-
We differ from Aiger 1.9 by requiring all latches to have a reset, meaning that all sources of
29-
nondeterminism in the circuit are due to inputs so are easier to reason about.
30-
Resets are stratified (acyclic), by requiring that the reset comes before the variable defined by
31-
this latch. Note that this is not compatible with the binary aiger format, so for binary aiger we
32-
need to reorder things to prevent this. We prefer this encoding as it is easier to reason about as
33-
we have an explicit order on variables.
3422
-/
3523
structure Latch where
3624
var : Var
@@ -44,7 +32,6 @@ end Latch
4432
abbrev Inputs := Array Input
4533
abbrev Latches := Array Latch
4634

47-
-- Switch to public by default
4835
end Valaig.Aig
4936
public section pub
5037
namespace Valaig.Aig
@@ -77,7 +64,7 @@ end LatchIdx
7764

7865
/--
7966
An atom in the combinational aig is either an input or a latch, which is just
80-
a reference back to the index in the inputs or latches arrays
67+
a reference back to the index in the inputs or latches arrays.
8168
-/
8269
inductive AtomIdx where
8370
| input (idx : InputIdx)
@@ -90,7 +77,7 @@ end AtomIdx
9077

9178
/--
9279
An output of interest in the circuit - this is also used to represent other
93-
nameable nodes in the Aiger format like bad and constraint nodes
80+
nameable nodes in the Aiger format like bad and constraint nodes.
9481
-/
9582
structure Output where
9683
lit : Lit
@@ -104,7 +91,8 @@ abbrev Outputs := Array Output
10491
end Aig
10592

10693
/--
107-
A sequential Aig without any marked outputs. These should be stored separately
94+
A sequential And-Inverter Graph consisting of inputs, latches and And gates. Outputs should be
95+
stored separately as `Lit`s in the `Aig`.
10896
-/
10997
structure Aig where
11098
-- The underlying AIG
@@ -119,8 +107,8 @@ structure Aig where
119107
namespace Aig
120108

121109
/--
122-
A representation of the node data stored for a particular variable in the Aig. For
123-
inputs and latches this requires a further lookup with InputIdx.get or LatchIdx.get
110+
A representation of the node data stored for a particular variable in an `Aig`. For inputs and
111+
latches this requires a further lookup with `InputIdx.get` or `LatchIdx.get`.
124112
-/
125113
inductive Node where
126114
| false
@@ -133,7 +121,7 @@ deriving instance Hashable, DecidableEq, Repr, Inhabited for Node
133121
end Node
134122

135123
/--
136-
An Aig with just the constant node.
124+
An `Aig` with just the constant node.
137125
-/
138126
def empty : Aig :=
139127
{
@@ -143,7 +131,7 @@ def empty : Aig :=
143131
}
144132

145133
/--
146-
The number of nodes currently allocated in the Aig
134+
The number of nodes currently allocated in aig.
147135
-/
148136
@[local grind]
149137
def size (aig : Aig) : Nat :=
@@ -229,7 +217,8 @@ def LatchIdx.setReset (idx : Aig.LatchIdx) (aig : Aig) (reset : Lit) (valid : id
229217
{ aig with latches := aig.latches.modifyMem idx.idx (by simp_all) ({ ·.val with reset }) }
230218

231219
/-
232-
Generic index type that can be Var, InputIdx or LatchIdx used for proof reasoning.
220+
Generic index type that can be Var, InputIdx or LatchIdx used for proof reasoning, particularly
221+
when operations invalidate no indices.
233222
-/
234223

235224
inductive GenericIdx where
@@ -244,16 +233,14 @@ def GenericIdx.validIn (idx : GenericIdx) (aig : Aig) : Prop :=
244233
| latch idx => idx.validIn aig
245234

246235
namespace GenericIdx
247-
248236
variable {aig : Aig}
249-
attribute [local simp] validIn
250237

251238
/-
252239
Lemmas to convert between specific and generic index forms.
253240
-/
254-
@[simp, grind =, grind =_] theorem iff_node (var : Var) : (node var).validIn aig ↔ var.validIn aig := by simp
255-
@[simp, grind =, grind =_] theorem iff_input (idx : InputIdx) : (input idx).validIn aig ↔ idx.validIn aig := by simp
256-
@[simp, grind =, grind =_] theorem iff_latch (idx : LatchIdx) : (latch idx).validIn aig ↔ idx.validIn aig := by simp
241+
@[simp, grind =, grind =_] theorem iff_node (var : Var) : (node var).validIn aig ↔ var.validIn aig := by rfl
242+
@[simp, grind =, grind =_] theorem iff_input (idx : InputIdx) : (input idx).validIn aig ↔ idx.validIn aig := by rfl
243+
@[simp, grind =, grind =_] theorem iff_latch (idx : LatchIdx) : (latch idx).validIn aig ↔ idx.validIn aig := by rfl
257244

258245
end GenericIdx
259246

Valaig/Aig/Refs.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module
22

33
public import Std.Sat.AIG.Basic
44

5-
public section
5+
public section pub
66
namespace Valaig
77

88
/--
@@ -196,4 +196,4 @@ abbrev toLit (v : Var) (invert : Bool := false) : Lit :=
196196

197197
end Var
198198
end Valaig
199-
end
199+
end pub

Valaig/Aig/RefsLemmas.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module
33
public import Valaig.Aig.Refs
44
import all Valaig.Aig.Refs
55

6-
public section
6+
public section pub
77
namespace Valaig
88
namespace Lit
99

@@ -146,4 +146,4 @@ end
146146

147147
end Lit
148148
end Valaig
149-
end
149+
end pub

Valaig/ForStd.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module
22

3-
public section
3+
public section pub
44
namespace Array
55

66
variable {α : Type}
@@ -126,4 +126,4 @@ theorem getElem_mapMem {i : Nat} (f : (i : Nat) → (h : i < xs.size) → (a :
126126
end
127127

128128
end Array
129-
end
129+
end pub

0 commit comments

Comments
 (0)