Lars Hupel
June 05, 2023
27

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.

June 05, 2023

Transcript

2023-06-05

+ high) / 2

+ high) / 2

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

the presence of bugs, but it is hopelessly inadequate for showing their absence”

13. “Formal Methods refers to mathematically rigorous techniques and tools for

the specification, design and verification of software and hardware systems”

used Formal Methods! … without knowing it … without knowing it

/ 2;
20. Binary search, again! 21 assert low <= high; assert 0

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

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

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

e-money Issued by the central bank Digital money
25. Our customers • central banks • commercial/retail banks • payment

service providers 26

Proof

36. Example: Money in circulation definition graph_balance :: nat where ‹graph_balance

= (∑N ∈ unspent. value N)› 37

38. Example: Money in circulation lemma graph_balance_eq_value_difference: ‹graph_balance = ¦(∑c ∈

graph. value_difference c)¦› 39
39. 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?
40. 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