You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: paper.tex
+15-24Lines changed: 15 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -434,13 +434,13 @@ \subsection{Symbolic Bit Representations}\label{subsec:bitexpr}
434
434
\[
435
435
\begin{array}{r@{\;}c@{\;}l@{\qquad}l}
436
436
\multicolumn{4}{l}{%
437
-
b \in Var \qquad
437
+
b \in\texttt{Var}\qquad
438
438
\circledast\in\{\wedge,\vee,\oplus\}}\\[2pt]
439
-
\BitExpr\ni c &::=& b_n\mid 0 \mid 1 \mid\neg c \mid c \circledast c &
439
+
\BitExpr\ni c &::=& b\mid 0 \mid 1 \mid\neg c \mid c \circledast c &
440
440
\end{array}
441
441
\]
442
442
To evaluate a \BitExpr, we need to assign values to all the variables in the \BitExpr.
443
-
These are supplied by a bit environment $(\sigma : Var \to\mathbb B)$,
443
+
These are supplied by a bit environment $(\sigma : \texttt{Var}\to\mathbb B)$,
444
444
which maps each bit variable to its Boolean value.
445
445
The evaluation function $\csem{\cdot} : \BitExpr\to\mathbb B$ evaluates a \BitExpr under a bit environment $\sigma$,
446
446
producing a concrete boolean value. It is defined by recursion.
@@ -573,39 +573,30 @@ \subsection{Bit Heap Data Structure}\label{subsec:bitheap}
573
573
574
574
\subsection{From Word-Level Arithmetic to Bit Heaps}\label{subsec:to_bitheap}
575
575
So far, we have defined the bit heap data structure and its operations, and proved that they preserve the semantics of bit heap evaluation.
576
-
To synthesize efficient and provably correct circuits for word-level arithmetic, we require a verified translation from arithmetic to a bit heap.
576
+
To use the bit heap to synthesize efficient and provably correct circuits for word-level arithmetic, we require a verified translation from arithmetic to a bit heap.
577
577
We represent such arithmetic expressions as \Arith, a minimal symbolic
578
578
representation of word-level arithmetic.
579
579
We will define a function $\mathsf{toBitHeap}$ that converts an \Arith expression into a bit heap.
580
580
This conversion then allows us to apply compression techniques that reduce the delay of the circuit (\autoref{subsec:compression}).
581
581
First, we define the syntax and semantics of \Arith,
582
582
and then we prove that the semantics of the resulting bit heap are equal to the semantics of the original \Arith expression.
583
583
584
-
An \Arith is a word-level expression, which can be a variable,
585
-
a variadic addition of \Arith expressions,
586
-
or a multiplication of two \Arith expressions.
587
-
This allows us to represent nested arithmetic expressions, such as multiply-accumulate.
588
-
An \Arith variable $\mathsf{var}(i)$ represents the $i$-th input word.
589
-
We also support zero-extension and sign-extension of the variables, that allows us to fit narrow operands into a wider datapath,
590
-
as this is commonly needed in multiplication to preserve the full precision of the result:
584
+
\Arith is a word-level representation supporting variables,
585
+
variadic addition and two-input multiplication.
586
+
This allows us to represent nested arithmetic expressions, like $a\times b + c$.
587
+
We also support zero/sign-extension of variables, as this lets our multiplication preserve the full precision of the result.
591
588
\begin{align*}
592
-
&i\in\mathbb{N} \qquad v, w \in\mathbb{N}^{+}\\
589
+
&b\in\texttt{Var}_{\texttt{Arith}} \qquad v, w \in\mathbb{N}^{+}\\
593
590
&\mathtt{ArithCircuit}_w \ni a ::= \\
594
-
&\quad\mid\mathsf{var}(i)\mid\mathsf{zext}(i, b) \mid\mathsf{sext}(i, b) \mid\mathsf{add}[a_0,\dots,a_{n-1}] \mid\mathsf{mul}[a, a]
591
+
&\quad\midb\mid\mathsf{zext}(i, b) \mid\mathsf{sext}(i, b) \mid\mathsf{add}[a_0,\dots,a_{n-1}] \mid\mathsf{mul}[a_0, a_1]
595
592
\end{align*}
596
593
597
-
The \Arith variables are assigned a value by a variable environment $\rho : \mathbb{N}\to\mathtt{BitVec}\ w$, mapping each variable to a $w$-bit word,
598
-
where $\mathtt{BitVec}\ w$ is Lean's type of bitvectors of width $w$.
594
+
The \Arith variables are assigned a value by a variable environment $\rho : \texttt{Var}_{\texttt{Arith}}\to\mathtt{BitVec}\ w$, mapping each variable to Lean's built-in bitvector type of width $w$.
595
+
\sam{We should make it clear that everything gets assigned to $w$-bits?}
599
596
A variable evaluates to the word the environment assigns it.
600
-
A zero-extended variable $\mathsf{zext}(i,b)$ evaluates by truncating that word to its lowest $b$ bits and zero-extending the result back to the width of the \Arith expression.
601
-
A sign-extended variable $\mathsf{sext}(i,b)$, where $0 < b \leq w$, truncates in the same way, but extends the result back to width $w$ by replicating the sign bit, i.e. bit $b-1$ of the word.
602
-
The addition and multiplication operations in \Arith are interpreted as the corresponding word-level operations:
603
-
\begin{align*}
604
-
&\bvsem{\mathsf{var}(i)} = \rho\, i \qquad\bvsem{\mathsf{zext}(i,b)} = \mathsf{zext}_{w}\big((\rho\,i)_{[0,b)}\big)\\
A zero-extended variable $\mathsf{zext}(b,w')$, where $w'\leq w$, evaluates by truncating that word to its lowest $w'$-bits and zero-extending the result back to the width of the \Arith expression.
598
+
A sign-extended variable $\mathsf{sext}(b,w')$, where $w' \leq w$, truncates in the same way, but extends the result back to width $w$ by replicating the sign bit, i.e. bit $b-1$ of the word.
599
+
The addition and multiplication operations in \Arith are interpreted following standard bitvector arithmetic.
609
600
610
601
\paragraph{Bit Heap Construction from Arithmetic Expressions}
0 commit comments