Chaofan Shou's Blog 2022-08-24T06:22:20+00:00 shouc.github.io shou shou@ucsb.edu Note on Interesting HotNet '21 Papers 2021-11-23T00:00:00+00:00 shouc.github.io/2021/11/23/hotnet21 <p><img src="/assets/tcp.svg" alt="tcp" /></p> <p><img src="/assets/dns.svg" alt="dns" /></p> Note on Digfuzz Hybrid Fuzzing Scheduling 2021-07-30T00:00:00+00:00 shouc.github.io/2021/07/30/digfuzz <p>My Presentation @ CS595C: <a href="https://docs.google.com/presentation/d/1pLNF2bv3qeoVjwXr8IM8nYGxXhHVDCKLm_HRuLixA8Q/edit?usp=sharing">https://docs.google.com/presentation/d/1pLNF2bv3qeoVjwXr8IM8nYGxXhHVDCKLm_HRuLixA8Q/edit?usp=sharing</a></p> Note on Neural Network Verification / Reluplex Paper 2020-11-14T00:00:00+00:00 shouc.github.io/2020/11/14/reluplex <h3 id="problem-to-solve">Problem to Solve</h3> <p>Given bound of input and output, whether the neural network model is satisfiable.</p> <p>By directly applying existing solver on neural networks, the activation functions, which are encoded as disjunctions could lead to state explosion (suppose there are n activation function, solver has to explore $2^n$ states).</p> <h3 id="background">Background</h3> <p><strong>Theory in SMT</strong>: A theory is $T = (\Sigma, I)$ where $\Sigma$ is called signature and $I$ is a list of closed interpretation. A $\tau$ is said to be $T$ satisfiable if it is satisfiable by $i \in I$.</p> <p><strong>DPLL(T)</strong>: Embedding theories into DPLL algorithms (Details: <a href="https://www.cs.utexas.edu/~isil/cs389L/lecture16-6up.pdf">https://www.cs.utexas.edu/~isil/cs389L/lecture16-6up.pdf</a>)</p> <p><strong>Linear Real Arithmetic (LRA) Theory</strong>: $\Sigma = \{+,-,\cdot,\le, \ge,R\}$. And $\tau$ can be written as $\sum_{x_i} c_ix_i \square d$, $\square \in \{=,\le, \ge\}$.</p> <p><strong>ReLU</strong>: $ReLU(x) = max(0,x)$</p> <p><strong>Simplex for LRA</strong>: The Simplex algorithm proposed here is different from standard version. It is here for being a decision procedure for LRA theory. A configuration of can either be $&lt;SAT, UNSAT&gt;$ or $&lt;\Beta, T, l,u,\alpha&gt;$. $\Beta \sube X$ is called basic variables. $T$ is called tableau, which are a set of equations, $x_i = c_jx_j$, $x_i \in \Beta \wedge x_j \notin \Beta$. $x_j$ is known as non-basic variables. $l, u, \alpha$ are lower bound, upper bound, and real value assignment for each basic and non-basic variables.</p> <p><em>Init</em>: for each $\sum_{x_i} c_ix_i \square d$, make it $b =\sum_{x_i} c_i x_i$ where b is basic variable. Then $d$ is then applied to $l, u$. Make $\alpha$ with all zero.</p> <p><em>Iteration</em>:</p> <ul> <li> <p>Case 1 (A basic variable violates bound): a basic variable becomes non-basic and a non-basic becomes basic (update $\Beta$ and pivot corresponding equation in $T$) selected based on Slack rules (intuition: select a non-basic variable that can be changed in its bound such that could make the basic variable no longer violating its bound).</p> </li> <li> <p>Case 2 (A non-basic variable violates bound): update $\alpha$ of the non-basic variable that violates the bound: $\alpha'(x_j) = \alpha(x_j) + \delta$ , where $x_j$ is the non-basic variable, and $a'(x_i) = a(x_i) + \delta T_{i,j}$ (intuition: the change on non-basic variable should be reflected on itself and propagate to all basic variables depending on it).</p> </li> </ul> <p><em>Termination</em>: If no bound is violated, SAT. When there is no non-basic variable can be selected to exchange with the basic variable, UNSAT.</p> <h3 id="implementation">Implementation</h3> <ul> <li> <p>Append R to configuration: $ReLU(x,y)\iff &lt;x,y&gt;\in R$.</p> </li> <li> <p>Termination: Add check for ReLU constraints</p> </li> <li> <p>Add ReLU pivoting</p> </li> <li> <p>Add ReLU update</p> </li> <li> <p>Add ReLU splitting. Only happens if # of other derivation rules applied to a ReLU exceeds a threshold. ~$30\%$ of ReLU has to be splitted for real-world examples if threshold is set to 5.</p> </li> </ul> <p>Simplex derivation rules:</p> <p><img src="https://i.loli.net/2020/11/15/7mIUSG8EZHiv5CR.png" alt="Screen Shot 2020-11-14 at 7.13.39 PM" /></p> <p><img src="https://i.loli.net/2020/11/15/Ww2vJFhA61Vg4X5.png" alt="Screen Shot 2020-11-14 at 7.13.48 PM" /></p> <p>Reluplex new derivation rules for ReLU:</p> <p><img src="https://i.loli.net/2020/11/15/qEv87Tnmi1pxVQ3.png" alt="Screen Shot 2020-11-14 at 7.13.56 PM" /></p> <h3 id="optimization">Optimization</h3> <ul> <li> <p>Bound tightening</p> <p><img src="https://i.loli.net/2020/11/15/1pkFtnYwXmcVa4O.png" alt="Screen Shot 2020-11-14 at 7.15.00 PM" /></p> </li> <li> <p>Conflict Analysis</p> </li> <li> <p>Floating Point Arithmetic</p> <ul> <li>Measure the accumulated roundoff error after a certain number of pivot steps. Restore the coefficients of the current tableau T using the initial tableau $T_0$, if the error exceeded a threshold M.</li> </ul> </li> </ul> <h3 id="application">Application</h3> <p><strong>ACAS Xu Verification</strong>: ACAS Xu is the unmanned variant of Airborne Collision Avoidance System X. Previous certification methodologies included exhaustively testing the system in 1.5 million simulated encounters, but this is insufficient for proving that faulty behaviors do not exist within the continuous DNNs.</p> <p><strong>Adversarial attack</strong>: Let $\delta$ be the fluctuation. $||x - x'|| = \delta \implies \forall y_i, y_i^{'} \ge y_i$ , where $\xi^{'}$ signifies input and output after applying fluctuation. Intuitively, such a constraint asserts that for a threshold of fluctuation $\delta$ , the output would not be affected negatively. If this statement is valid, then the fluctuation applied would not affect the result, meaning that the adversarial attack has failed. With this in mind, we could then leverage the concept of binary search to find the maximal threshold of fluctuation efficiently.</p> <h3 id="example">Example</h3> <p>Simplex for LRA:</p> <p><img src="https://i.loli.net/2020/11/15/EtiX9YjKgVMZIRe.jpg" alt="PXL_20201114_215142680_2" /></p> <p><img src="https://i.loli.net/2020/11/15/kv7TheMjZ8wKH3q.jpg" alt="PXL_20201114_215238047_2" /></p> <p>Reluplex:</p> <p><img src="https://i.loli.net/2020/11/15/oVFR5qXOmNYwy1d.jpg" alt="PXL_20201115_000657924_2" /></p> <p><img src="https://i.loli.net/2020/11/15/5FVz8gbGrcyCYsm.jpg" alt="PXL_20201115_000708668_2" /></p> Notes on Convex Optimizatioon 2020-07-22T00:00:00+00:00 shouc.github.io/2020/07/22/convex <h3 id="norm">Norm</h3> <p>$||x|| \in R^+$</p> <ul> <li>zero: $||x||=0 \to x =0$</li> <li>scaling: $||ax||=|a|||x||$</li> <li>$||x+y||\le ||x||+||y||$</li> </ul> <p>$||x||_2 = \sqrt{\Sigma x_i^2}$</p> <h3 id="euclidean-ball">Euclidean Ball</h3> <p>c = center vector, r = radius</p> <p>$B(c,r) = \{x|\ \ ||x-c||_2 \le r\}$</p> <p>$=\{c+ru | \ \ ||u||_2 \le 1\}$</p> <h3 id="ellipsoid">Ellipsoid</h3> <p>PSD: $S_+ \to x^TAx\ge 0, \forall x\in R^n, A\in S_+$</p> <p>PD: $S_{++} \to x^TAx\gt 0, \forall x\in R^n, A\in S_{++}$</p> <p>$A&lt;B \to B-A \in S_{++}$</p> <p>$\ell(c,P) = \{x | \ \ (x-c)^TP^{-1}(x-c)\le 1\}\ \ (P \in S_{++})$</p> <h3 id="psd-cone">PSD Cone</h3> <p>$S^n = \{X\in R^{n\times n} | X^T=X\}$</p> <p>$S_+^n = \{X\in S^n | z^TXz \ge 0\ \forall z\}$</p> <p>$S_{++}^n = \{X\in S^n | z^TXz \gt 0\ \forall z\}$</p> <h3 id="convex-closed-operations">Convex-closed Operations</h3> <p>Intersection: $\bigcap C_k \in C$</p> <p>Affine transformation: $f(S) = \{Ax+b, x\in S\} \in C$</p> <p>Perspective transformation: $f(S)=\{[x_1/x_n,....x_{n-1}/x_n]| x\in S\}$</p> <p>Linear fractional transformation: $f(S)=\{\frac{Ax+b}{c^Tx+d} | x\in S\}$</p> <h3 id="generalized-inequality">Generalized Inequality</h3> <p>$x \le_S y \to y-x\in S$</p> <p>$x \lt_S y \to y-x\in int(S)$</p> <p>Minimum element: $\forall x \in C \to x_{min} \le_S x$</p> <p>Minimal element: $\{y | y \le_S x_{mil}\} \cap C = \{x_{mil}\}$</p> <ul> <li>Preserve addition</li> <li>Transitive</li> <li>Non-negative scaling</li> <li>Reflexivity</li> <li>Sequential limits</li> </ul> <h3 id="dual-cone">Dual Cone</h3> <p>$K^* = \{y | x^Ty \ge 0, \forall x \in K\}$</p> <p>Dual inequality: using generalized inequality over $K^*$</p> <p>$x \le_K y \iff \lambda^T x \le \lambda ^T y, \forall \lambda \ge _{K^*} 0$</p> <h3 id="convex-function">Convex Function</h3> <ul> <li>$dom(f)$ is convex set</li> <li>$\forall x,y \in dom(f), \forall 0 \le \theta \le 1, f(\theta x, (1-\theta)y)\le \theta f(x) + (1-\theta)f(y)$</li> </ul> <p>Example</p> <ul> <li>$f(x) = a^Tx+b$</li> <li>$f(x) =e^{\alpha x}$</li> <li>$f(x) =x\log x$</li> </ul> <p><strong>First Order Condition</strong></p> <p>If a function is differentiable and $\forall x, f(x)\ge \nabla^Tf(x_0)(x-x_0)$ , it is convex function</p> <p><strong>Second Order Condition</strong></p> <p>If a function is differentiable and $\nabla^2f\ge0$ (PSD) , it is convex function</p> <h3 id="epigraph">Epigraph</h3> <p>$epi(f) = \{(x,t)\in R^{n+1} | x\in dom (A) \and f(x\le t\}$</p> <p>$epi(f)$ is convex $\iff$ $f(x)$ is convex</p> <p><strong>Jensen's Inequality</strong></p> <p>if $f(x)$ is convex and Z is any RV, then $f(E(Z)) \le E(f(Z))$</p> <h3 id="convex-closed-transformation">Convex-closed Transformation</h3> <ul> <li>$cf(x)$</li> <li>$\sum^N_{i=1}f_i(x), f_i$ is convex</li> <li>Pointwise maximum</li> </ul> <h3 id="conjugate-convex-function">Conjugate Convex Function</h3> <p>$f^*(y) = \sup_{x\in dom{f}}(y^Tx - f(x))$</p> <h3 id="quasi-convex">Quasi Convex</h3> <ul> <li>dom(f) is convex</li> <li>$\forall \alpha, S_\alpha = \{x\in dom(f) | f(x)\le\alpha\}$ is convex</li> </ul> <p>$\forall x,y\in dom(f), \forall 0\le \theta\le 1 \implies f(\theta x+(1-\theta)y)\le \max(f(x), f(y))$</p> <p>then $f$ is quasi convex</p> <p><strong>1st order conditions</strong></p> <ul> <li>$f(y)\le f(x) \implies \nabla f^T(x)(y-x) \le 0$</li> </ul> <h3 id="log-convex-function">Log Convex Function</h3> <p>$\log(f)$ is convex</p> <p>Proof: $\log f(\theta x + (1-\theta)y) \le \log(f^\theta(x) f^{1-\theta}(y))$</p> <h3 id="standard-form">Standard Form</h3> <p>Minimize $f(x)$</p> <p>Subject to $f_i(x) \le 0, i = 1...m \and h_j(x)=0, j=1...p$</p> <h3 id="convex-optimization">Convex Optimization</h3> <p>Minimize (quasi) convex $f(x)$</p> <p>Subject to convex $f_i(x) \le 0, i = 1...m\ \and$ affine $h_j(x)=0, j=1...p$</p> <p>Feasible set of convex opt problem is convex</p> <p>$\nabla f(x_{opt})^Tx_{opt} \le \nabla f^T(x_{opt})y$</p> <p><strong>Supporting Hyperplane</strong></p> <ul> <li>X is entirely contained in one of the 2 closed half spaces bounded by hyperplane</li> <li>X has at one bounding pt on hyperplane</li> </ul> <h3 id="linear-programming">Linear Programming</h3> <p>minimize $f(x) = c^Tx + d$</p> <p>subject to $f_i(x)=g_i^Tx-h_i \le 0 \and h_j(x) = a_j^Tx-b_i = 0$ (polyhedron)</p>