|
259 | 259 | </section>
|
260 | 260 | <section id="module-pynever.strategies.verification.algorithms">
|
261 | 261 | <span id="algorithms"></span><h2>Algorithms<a class="headerlink" href="#module-pynever.strategies.verification.algorithms" title="Link to this heading"></a></h2>
|
| 262 | +<p>This module contains the classes used to implement the different verification strategies. Following the strategy pattern, |
| 263 | +the class <code class="docutils literal notranslate"><span class="pre">VerificationStrategy</span></code> is the abstract class providing a <code class="docutils literal notranslate"><span class="pre">verify</span></code> method that requires a neural network and |
| 264 | +a property. The concrete classes <code class="docutils literal notranslate"><span class="pre">SSLPVerification</span></code> and <code class="docutils literal notranslate"><span class="pre">SSBPVerification</span></code> implement the verification strategies based |
| 265 | +on starsets and symbolic bounds propagation, respectively.</p> |
262 | 266 | <dl class="py class">
|
263 | 267 | <dt class="sig sig-object py" id="pynever.strategies.verification.algorithms.VerificationStrategy">
|
264 | 268 | <em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pynever.strategies.verification.algorithms.</span></span><span class="sig-name descname"><span class="pre">VerificationStrategy</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">parameters</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/NeverTools/pynever/blob/main/pynever/strategies/verification/algorithms.py"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pynever.strategies.verification.algorithms.VerificationStrategy" title="Link to this definition"></a></dt>
|
|
289 | 293 | <dl class="py method">
|
290 | 294 | <dt class="sig sig-object py" id="pynever.strategies.verification.algorithms.VerificationStrategy.verify">
|
291 | 295 | <em class="property"><span class="k"><span class="pre">abstractmethod</span></span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">verify</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">network</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prop</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/NeverTools/pynever/blob/main/pynever/strategies/verification/algorithms.py"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pynever.strategies.verification.algorithms.VerificationStrategy.verify" title="Link to this definition"></a></dt>
|
292 |
| -<dd><p>Verify that the neural network of interest satisfy the property given as argument |
| 296 | +<dd><p>Verify that the neural network of interest satisfies the property given as argument |
293 | 297 | using a verification strategy determined in the concrete children.</p>
|
294 | 298 | <dl class="field-list simple">
|
295 | 299 | <dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
296 | 300 | <dd class="field-odd"><ul class="simple">
|
297 | 301 | <li><p><strong>network</strong> (<a class="reference internal" href="0_Networks.html#pynever.networks.NeuralNetwork" title="pynever.networks.NeuralNetwork"><em>NeuralNetwork</em></a>) – The neural network to train.</p></li>
|
298 |
| -<li><p><strong>prop</strong> (<em>Dataset</em>) – The property which the neural network must satisfy.</p></li> |
| 302 | +<li><p><strong>prop</strong> (<a class="reference internal" href="#pynever.strategies.verification.properties.NeverProperty" title="pynever.strategies.verification.properties.NeverProperty"><em>NeverProperty</em></a>) – The property which the neural network must satisfy.</p></li> |
299 | 303 | </ul>
|
300 | 304 | </dd>
|
301 | 305 | <dt class="field-even">Returns<span class="colon">:</span></dt>
|
302 |
| -<dd class="field-even"><p>True is the neural network satisfy the property, False otherwise.</p> |
| 306 | +<dd class="field-even"><p>True is the neural network satisfies the property, False otherwise.</p> |
303 | 307 | </dd>
|
304 | 308 | <dt class="field-odd">Return type<span class="colon">:</span></dt>
|
305 | 309 | <dd class="field-odd"><p>bool</p>
|
|
313 | 317 | <dt class="sig sig-object py" id="pynever.strategies.verification.algorithms.SSLPVerification">
|
314 | 318 | <em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pynever.strategies.verification.algorithms.</span></span><span class="sig-name descname"><span class="pre">SSLPVerification</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">params</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/NeverTools/pynever/blob/main/pynever/strategies/verification/algorithms.py"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pynever.strategies.verification.algorithms.SSLPVerification" title="Link to this definition"></a></dt>
|
315 | 319 | <dd><p>Bases: <a class="reference internal" href="#pynever.strategies.verification.algorithms.VerificationStrategy" title="pynever.strategies.verification.algorithms.VerificationStrategy"><code class="xref py py-class docutils literal notranslate"><span class="pre">VerificationStrategy</span></code></a></p>
|
316 |
| -<p>Class used to represent the SSLP verification strategy.</p> |
| 320 | +<p>Class used to represent the SSLP (Star Sets with Linear Programming) verification strategy.</p> |
317 | 321 | <dl class="py attribute">
|
318 | 322 | <dt class="sig sig-object py" id="pynever.strategies.verification.algorithms.SSLPVerification.counterexample_stars">
|
319 | 323 | <span class="sig-name descname"><span class="pre">counterexample_stars</span></span><a class="reference external" href="https://github.com/NeverTools/pynever/blob/main/pynever/strategies/verification/algorithms.py"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pynever.strategies.verification.algorithms.SSLPVerification.counterexample_stars" title="Link to this definition"></a></dt>
|
320 |
| -<dd><p>List of Star objects containing a counterexample</p> |
| 324 | +<dd><p>List of <code class="xref py py-class docutils literal notranslate"><span class="pre">Star</span></code> objects containing a counterexample</p> |
321 | 325 | <dl class="field-list simple">
|
322 | 326 | <dt class="field-odd">Type<span class="colon">:</span></dt>
|
323 | 327 | <dd class="field-odd"><p>list[Star]</p>
|
|
362 | 366 | <dt class="sig sig-object py" id="pynever.strategies.verification.algorithms.SSBPVerification">
|
363 | 367 | <em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pynever.strategies.verification.algorithms.</span></span><span class="sig-name descname"><span class="pre">SSBPVerification</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">parameters</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/NeverTools/pynever/blob/main/pynever/strategies/verification/algorithms.py"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pynever.strategies.verification.algorithms.SSBPVerification" title="Link to this definition"></a></dt>
|
364 | 368 | <dd><p>Bases: <a class="reference internal" href="#pynever.strategies.verification.algorithms.VerificationStrategy" title="pynever.strategies.verification.algorithms.VerificationStrategy"><code class="xref py py-class docutils literal notranslate"><span class="pre">VerificationStrategy</span></code></a></p>
|
365 |
| -<p>Class used to represent the search-based verification strategy. It uses |
366 |
| -star propagation with Symbolic Bounds Propagation and an abstraction-refinement |
367 |
| -loop for better readability, structure and functionality</p> |
| 369 | +<p>Class used to represent the SSBP (Star Sets with Bounds Propagation) verification strategy. |
| 370 | +It uses star propagation with Symbolic Bounds Propagation and an abstraction-refinement |
| 371 | +loop for better readability, structure and functionality.</p> |
368 | 372 | <dl class="py attribute">
|
369 | 373 | <dt class="sig sig-object py" id="pynever.strategies.verification.algorithms.SSBPVerification.network">
|
370 | 374 | <span class="sig-name descname"><span class="pre">network</span></span><a class="reference external" href="https://github.com/NeverTools/pynever/blob/main/pynever/strategies/verification/algorithms.py"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pynever.strategies.verification.algorithms.SSBPVerification.network" title="Link to this definition"></a></dt>
|
371 | 375 | <dd><p>The neural network to verify</p>
|
372 | 376 | <dl class="field-list simple">
|
373 | 377 | <dt class="field-odd">Type<span class="colon">:</span></dt>
|
374 |
| -<dd class="field-odd"><p><a class="reference internal" href="0_Networks.html#pynever.networks.SequentialNetwork" title="pynever.networks.SequentialNetwork">networks.SequentialNetwork</a></p> |
| 378 | +<dd class="field-odd"><p><a class="reference internal" href="0_Networks.html#pynever.networks.NeuralNetwork" title="pynever.networks.NeuralNetwork">NeuralNetwork</a></p> |
375 | 379 | </dd>
|
376 | 380 | </dl>
|
377 | 381 | </dd></dl>
|
|
390 | 394 | <dl class="py method">
|
391 | 395 | <dt class="sig sig-object py" id="pynever.strategies.verification.algorithms.SSBPVerification.init_search">
|
392 | 396 | <span class="sig-name descname"><span class="pre">init_search</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">network</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prop</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/NeverTools/pynever/blob/main/pynever/strategies/verification/algorithms.py"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pynever.strategies.verification.algorithms.SSBPVerification.init_search" title="Link to this definition"></a></dt>
|
393 |
| -<dd><p>Initialize the search algorithm and compute the |
394 |
| -starting values for the bounds, the star and the target</p> |
| 397 | +<dd><p>Initialize the search algorithm and compute the starting values for the bounds and the star.</p> |
395 | 398 | <dl class="field-list simple">
|
| 399 | +<dt class="field-odd">Parameters<span class="colon">:</span></dt> |
| 400 | +<dd class="field-odd"><ul class="simple"> |
| 401 | +<li><p><strong>network</strong> (<a class="reference internal" href="0_Networks.html#pynever.networks.NeuralNetwork" title="pynever.networks.NeuralNetwork"><em>NeuralNetwork</em></a>) – The neural network in use</p></li> |
| 402 | +<li><p><strong>prop</strong> (<a class="reference internal" href="#pynever.strategies.verification.properties.NeverProperty" title="pynever.strategies.verification.properties.NeverProperty"><em>NeverProperty</em></a>) – The property specification</p></li> |
| 403 | +</ul> |
| 404 | +</dd> |
| 405 | +<dt class="field-even">Returns<span class="colon">:</span></dt> |
| 406 | +<dd class="field-even"><p>The starting values for the star and the bounds.</p> |
| 407 | +</dd> |
396 | 408 | <dt class="field-odd">Return type<span class="colon">:</span></dt>
|
397 |
| -<dd class="field-odd"><p><span class="sphinx_autodoc_typehints-type"><code class="xref py py-class docutils literal notranslate"><span class="pre">tuple</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">ExtendedStar</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">HyperRectangleBounds</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">VerboseBounds</span></code>]</span></p> |
| 409 | +<dd class="field-odd"><p>ExtendedStar, HyperRectangleBounds, VerboseBounds</p> |
398 | 410 | </dd>
|
399 | 411 | </dl>
|
400 | 412 | </dd></dl>
|
|
421 | 433 | <dd><p>This method computes the intersection between a star and the output property
|
422 | 434 | using the intersection algorithm specified by the parameters</p>
|
423 | 435 | <dl class="field-list simple">
|
| 436 | +<dt class="field-odd">Parameters<span class="colon">:</span></dt> |
| 437 | +<dd class="field-odd"><ul class="simple"> |
| 438 | +<li><p><strong>star</strong> (<em>ExtendedStar</em>) – The <code class="xref py py-class docutils literal notranslate"><span class="pre">ExtendedStar</span></code> object containing the star to intersect</p></li> |
| 439 | +<li><p><strong>nn_bounds</strong> (<em>VerboseBounds</em>) – The bounds obtained through bounds propagation</p></li> |
| 440 | +</ul> |
| 441 | +</dd> |
| 442 | +<dt class="field-even">Returns<span class="colon">:</span></dt> |
| 443 | +<dd class="field-even"><p>The result of the intersection. If True, a counterexample is returned too.</p> |
| 444 | +</dd> |
424 | 445 | <dt class="field-odd">Return type<span class="colon">:</span></dt>
|
425 |
| -<dd class="field-odd"><p><span class="sphinx_autodoc_typehints-type"><code class="xref py py-class docutils literal notranslate"><span class="pre">tuple</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">Tensor</span></code>]</span></p> |
| 446 | +<dd class="field-odd"><p>bool, torch.Tensor</p> |
426 | 447 | </dd>
|
427 | 448 | </dl>
|
428 | 449 | </dd></dl>
|
|
431 | 452 | <dt class="sig sig-object py" id="pynever.strategies.verification.algorithms.SSBPVerification.get_next_target">
|
432 | 453 | <span class="sig-name descname"><span class="pre">get_next_target</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">star</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nn_bounds</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/NeverTools/pynever/blob/main/pynever/strategies/verification/algorithms.py"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pynever.strategies.verification.algorithms.SSBPVerification.get_next_target" title="Link to this definition"></a></dt>
|
433 | 454 | <dd><p>This method computes the next refinement target for the verification algorithm
|
434 |
| -based on the strategy specified by the parameters</p> |
| 455 | +based on the strategy specified by the parameters.</p> |
435 | 456 | <dl class="field-list simple">
|
| 457 | +<dt class="field-odd">Parameters<span class="colon">:</span></dt> |
| 458 | +<dd class="field-odd"><ul class="simple"> |
| 459 | +<li><p><strong>star</strong> (<em>ExtendedStar</em>) – The <code class="xref py py-class docutils literal notranslate"><span class="pre">ExtendedStar</span></code> object containing the star to refine</p></li> |
| 460 | +<li><p><strong>nn_bounds</strong> (<em>VerboseBounds</em>) – The bounds obtained through bounds propagation.</p></li> |
| 461 | +</ul> |
| 462 | +</dd> |
| 463 | +<dt class="field-even">Returns<span class="colon">:</span></dt> |
| 464 | +<dd class="field-even"><p>The next refinement target and the extended star to refine. If no more refinement is needed, None is returned.</p> |
| 465 | +</dd> |
436 | 466 | <dt class="field-odd">Return type<span class="colon">:</span></dt>
|
437 |
| -<dd class="field-odd"><p><span class="sphinx_autodoc_typehints-type"><code class="xref py py-class docutils literal notranslate"><span class="pre">tuple</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">RefinementTarget</span></code> | <code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">ExtendedStar</span></code>]</span></p> |
| 467 | +<dd class="field-odd"><p>RefinementTarget | None, ExtendedStar</p> |
438 | 468 | </dd>
|
439 | 469 | </dl>
|
440 | 470 | </dd></dl>
|
|
447 | 477 | <dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
448 | 478 | <dd class="field-odd"><ul class="simple">
|
449 | 479 | <li><p><strong>network</strong> (<a class="reference internal" href="0_Networks.html#pynever.networks.NeuralNetwork" title="pynever.networks.NeuralNetwork"><em>NeuralNetwork</em></a>) – The network model in the internal representation</p></li>
|
450 |
| -<li><p><strong>prop</strong> (<em>Property</em>) – The property specification</p></li> |
| 480 | +<li><p><strong>prop</strong> (<a class="reference internal" href="#pynever.strategies.verification.properties.NeverProperty" title="pynever.strategies.verification.properties.NeverProperty"><em>NeverProperty</em></a>) – The property specification</p></li> |
451 | 481 | </ul>
|
452 | 482 | </dd>
|
453 | 483 | <dt class="field-even">Returns<span class="colon">:</span></dt>
|
454 | 484 | <dd class="field-even"><p>True if the network is safe, False otherwise. If the result is False and the
|
455 | 485 | search is complete it also returns a counterexample</p>
|
456 | 486 | </dd>
|
457 | 487 | <dt class="field-odd">Return type<span class="colon">:</span></dt>
|
458 |
| -<dd class="field-odd"><p>bool, Optional[torch.Tensor]</p> |
| 488 | +<dd class="field-odd"><p>bool, torch.tensor | None</p> |
459 | 489 | </dd>
|
460 | 490 | </dl>
|
461 | 491 | </dd></dl>
|
|
0 commit comments