Home
Add Document
Sign In
Create An Account
Formal Proofs for Computer Arithmetics Computer arithmetics ...
Recommend Documents
No documents
Formal Proofs for Computer Arithmetics Computer arithmetics ...
Download PDF
1 downloads
43 Views
836KB Size
Report
Comment
Formal Proofs for. Computer Arithmetics. Laurent Théry. Marelle Project INRIA Sophia Antipolis. Computer Arithmetics – p.1. Computer arithmetics. Numbers are ...
Computer arithmetics Formal Proofs for Computer Arithmetics Laurent Théry Marelle Project INRIA SophiaAntipolis
Numbers are everywhere: Billing system Weather forecast Computer vision Cryptography ...
Computer Arithmetics – p.1
Computer arithmetics
Computer Arithmetics – p.2
Formal Proofs Therac25:
Different flavours:
Arithmetic overflows could cause the software to bypass safety checks.
Integer Arithmetic: a ∈ N
Rational Arithmetic: a ∈ Q
FloatingPoint Arithmetic: a ∈ F
Interval Arithmetic: [a, b] ∈ F × F Exact Arithmetic: a ∈ R
Patriot Missile: The calculation of the time since boot was inacurate.
Pentium FDIV Some division operations were wrong by a very small amount.
Ariane 5: A conversion 64 bit floatingpoint number to 16 bit signed integer failed.
...
Computer Arithmetics – p.3
Computer Arithmetics – p.4
An Example
Outline •
A simple example that illustrates various aspects of formal verification.
•
An overview of the formalisation of floatingpoint arithmetic.
Take a program that given a parameter n returns the list of the first n prime numbers Prove it correct Knuth: The Art of Computer Programming
Computer Arithmetics – p.5
Computer Arithmetics – p.6
Natural Numbers
Addition
Inductive N: Set := O : N | S : N→N.
Fixpoint + [a,b:N] : match a with O => b | S a0 => S(a0 + b) end.
O, S(O), S(S(O)), ...
N :=
P (O) ∧
∀n, P (n) ⇒ P (S(n))
⇒ ∀n, P (n)
Computer Arithmetics – p.7
Computer Arithmetics – p.8
Multiplication
Divisibility Definition a|b := ∃c, b = c * a.
Fixpoint * [a,b:N] : N := match a with O => O | S a0 => b + (a0 * b) end.
Computer Arithmetics – p.9
Primality
Computer Arithmetics – p.10
Program Correctness Verification Condition Generator
Definition prime(p) := ∀n, n|p ⇒ n = 1 ∨ n = p ∧ p 6= 1.
Program
+ Annotations ⇒ Conditions
Krakatoa: Java −→ Coq Computer Arithmetics – p.11
Computer Arithmetics – p.12
Program Correctness
Program Correctness Loop:
{ Pre-conditions } P { Post-conditions }
while (C) { { invariant I variant V } P
Example { odd(x) } x = x + 2; { odd(x) }
}
Generated condition: ∀x, odd(x) ⇒ odd(x + 2) Computer Arithmetics – p.13
Computer Arithmetics – p.14
Program Correctness Example:
Knuth Algorithm int[] firstPrimes(int n) { int[] res = new int[n];
while (0 < i--) { { invariant odd(x) variant i } x = x + 2 }
{
∧ ∧
∀k, j. 0 ≤ k < j < n ⇒ res[k] < res[j] ∀k. ∧
Generated conditions: ∀x. odd(x) ⇒ odd(x + 2) ∀i. 0 ≤ i − 1 < i
∀k. 0 ≤ k < n ⇒ prime(res[k])
0 ≤ k ≤ res[n − 1] prime(k)
⇒ ∃j. ∧
res[j] = k
} return res; }
Computer Arithmetics – p.15
Knuth Algorithm
0≤j
×
Report "Formal Proofs for Computer Arithmetics Computer arithmetics ..."
Your name
Email
Reason
-Select Reason-
Pornographic
Defamatory
Illegal/Unlawful
Spam
Other Terms Of Service Violation
File a copyright complaint
Description
×
Sign In
Email
Password
Remember me
Forgot password?
Sign In
Our partners will collect data and use cookies for ad personalization and measurement.
Learn how we and our ad partner Google, collect and use data
.
Agree & close