Upgrade to Pro — share decks privately, control downloads, hide ads and more …

When testing just doesn't cut it (Lambda Days e...

When testing just doesn't cut it (Lambda Days edition)

Writing unit tests is pretty much standard practice these days. Otherwise, how would you make sure that your code does what you expect? Yet, some software is mission-critical and merely testing a few examples – or even randomized testing – is not enough. To reach higher levels of assurance, we need proof: mathematical, formal proof. This session will be based on an example from industry, where we successfully verified the core of a financial application. I will describe the core architecture of the system and the mathematical foundations behind the verification, including the classes of problems that we can (or cannot) discover with this approach.

Lars Hupel

June 05, 2023
Tweet

More Decks by Lars Hupel

Other Decks in Programming

Transcript

  1. 4

  2. “Program testing can be a very effective way to show

    the presence of bugs, but it is hopelessly inadequate for showing their absence”
  3. “Formal Methods refers to mathematically rigorous techniques and tools for

    the specification, design and verification of software and hardware systems”
  4. 15 You have already used Formal Methods! You have already

    used Formal Methods! … without knowing it … without knowing it
  5. 18

  6. Binary search, again! 21 assert low <= high; assert 0

    <= low; int mid = (low + high) / 2; assert low <= mid; assert mid <= high; Specification Specification Implementation
  7. Binary search, again! 22 ∀𝑙𝑜𝑤, ℎ𝑖𝑔ℎ ∈ 𝐼𝑛𝑡32 . 𝑙𝑜𝑤

    ≤ ℎ𝑖𝑔ℎ ⇒ 0 ≤ 𝑙𝑜𝑤 ⇒ 𝑙𝑜𝑤 ≤ 𝑙𝑜𝑤 +32 ℎ𝑖𝑔ℎ 2
  8. 24

  9. Central Bank Digital Currency 25 CBDC Banknotes Bank deposits and

    e-money Issued by the central bank Digital money
  10. 27

  11. 29

  12. 30

  13. 31

  14. Example: Money in circulation lemma graph_balance_eq_value_difference_pos: shows ‹0 ≤ (∑c

    ∈ graph. value_difference c)› shows ‹graph_balance = ¦(∑c ∈ graph. value_difference c)¦› proof (induction) (* ... *) qed 40 It looks like you are trying to do induction. Do you want me to generate a template?
  15. Example: Money in circulation lemma graph_balance_eq_value_difference_pos: shows ‹0 ≤ (∑c

    ∈ graph. value_difference c)› shows ‹graph_balance = ¦(∑c ∈ graph. value_difference c)¦› proof (induction) case empty (* ... *) next (* ... *) qed 41 base case steps
  16. 44

  17. 45

  18. 46

  19. Image sources • Edsger W. Dijskstra: Hamilton Richards, CC-BY-SA 3.0,

    https://commons.wikimedia.org/w/index.php?title=File:Edsger_Wybe_Dijkstra.jpg&oldid=710250 942 • César A. Muñoz: https://shemesh.larc.nasa.gov/people/cam/ • Type error: Limboer, CC-BY-SA, https://stackoverflow.com/q/60000835