An Automatable Formal Semantics for IEEE-754 Floating-Point - - PowerPoint PPT Presentation

an automatable formal semantics for ieee 754 floating
SMART_READER_LITE
LIVE PREVIEW

An Automatable Formal Semantics for IEEE-754 Floating-Point - - PowerPoint PPT Presentation

SMT SMT-LIB Theory of Floating-Point Conclusions An Automatable Formal Semantics for IEEE-754 Floating-Point Arithmetic Martin Brain , Cesare Tinelli, Philipp R ummer, Thomas Wahl (and the rest of the SMT community) University of Oxford


slide-1
SLIDE 1

SMT SMT-LIB Theory of Floating-Point Conclusions

An Automatable Formal Semantics for IEEE-754 Floating-Point Arithmetic

Martin Brain, Cesare Tinelli, Philipp R¨ ummer, Thomas Wahl

(and the rest of the SMT community) University of Oxford

June 24, 2015

slide-2
SLIDE 2

SMT SMT-LIB Theory of Floating-Point Conclusions

Hasn’t this been done before?

Isabelle A formal model of IEEE floating point arithmetic HOL Interpretation of IEEE-854 floating-point standard and

definition in the HOL system.

HOL Light Floating point verification in HOL light: The exponential

function (Intel)

ACL2 A mechanically checked proof of the AMD5K86TM

floating-point division program (AMD and Centaur)

PVS Defining the IEEE-854 floating-point standard in PVS Coq A generic library for floating-point numbers and its

application to exact computing

Coq Floating-point arithmetic in the Coq system Coq Flocq: A Unified Library for Proving Floating-point

Algorithms in Coq

slide-3
SLIDE 3

SMT SMT-LIB Theory of Floating-Point Conclusions

Hasn’t this been done before?

Isabelle A formal model of IEEE floating point arithmetic HOL Interpretation of IEEE-854 floating-point standard and

definition in the HOL system.

HOL Light Floating point verification in HOL light: The exponential

function (Intel)

ACL2 A mechanically checked proof of the AMD5K86TM

floating-point division program (AMD and Centaur)

PVS Defining the IEEE-854 floating-point standard in PVS Coq A generic library for floating-point numbers and its

application to exact computing

Coq Floating-point arithmetic in the Coq system Coq Flocq: A Unified Library for Proving Floating-point

Algorithms in Coq

... there is another way to think about theorem-proving ...

slide-4
SLIDE 4

SMT SMT-LIB Theory of Floating-Point Conclusions

Is there an x and y such that ...

0 < x 0 < y x + y < x

slide-5
SLIDE 5

SMT SMT-LIB Theory of Floating-Point Conclusions

Is there an x and y such that ...

0 ♣ x 0 ♣ y x♠y ♣ x

slide-6
SLIDE 6

SMT SMT-LIB Theory of Floating-Point Conclusions

Is there an x and y such that ...

♣ x ♣ y x♠y ♣ x It depends on the interpretation (of ♣ and ♠)! D = Z ♣ = <Z ♠ = +Z NO!

slide-7
SLIDE 7

SMT SMT-LIB Theory of Floating-Point Conclusions

Is there an x and y such that ...

♣ x ♣ y x♠y ♣ x It depends on the interpretation (of ♣ and ♠)! D = {00, 01, 10, 11} ♣ = bvult ♠ = bvplus Yes (x = 01, y = 11)

slide-8
SLIDE 8

SMT SMT-LIB Theory of Floating-Point Conclusions

First Order Logic

Syntax Fix a signature Σ (i.e. Σ = {♣, ♠}) Semantics An interpretation is M = (D, . : Σ → (2Dn)) Satisfiability An interpretation M satisfies a formula φ: M | = φ If φ evaluated over D (using .) is true.

slide-9
SLIDE 9

SMT SMT-LIB Theory of Floating-Point Conclusions

How Do We Fix The Meaning of Symbols?

Option 1 – Axiomatic M | = Axioms ⇒ φ Axioms = ∀a, b, c a♣b ∧ b♣c ⇒ a♣c = ∀a ¬a♣a . . .

Formalisation is solver INPUT.

Pros + Easy to implement + Flexible + Can add theorems Cons

  • All formulae quantified
  • Axioms not always simple
  • Hard to solve
slide-10
SLIDE 10

SMT SMT-LIB Theory of Floating-Point Conclusions

How Do We Fix The Meaning of Symbols?

Option 2 – Algebraic Fix signature Σ′ and its interpretation M′ = (D, . : Σ′ → (2Dn)). D = Z ♣ =<Z ♠ = +Z Is there M extension of M′ such that: M | = φ

Formalisation is solver SPECIFICATION.

Pros + Fast decision procedures + Counter-examples + Few quantifiers Cons

  • Theory has to be built

into solver

  • Implementation harder
slide-11
SLIDE 11

SMT SMT-LIB Theory of Floating-Point Conclusions

How Do We Fix The Meaning of Symbols?

Option 2 – Algebraic Fix signature Σ′ and its interpretation M′ = (D, . : Σ′ → (2Dn)). D = Z ♣ =<Z ♠ = +Z Is there M extension of M′ such that: M | = φ

Formalisation is solver SPECIFICATION.

Pros + Fast decision procedures + Counter-examples + Few quantifiers Cons

  • Theory has to be built

into solver

  • Implementation harder
slide-12
SLIDE 12

SMT SMT-LIB Theory of Floating-Point Conclusions

SAT Modulo Theory (SMT)

The major school of algebraic solvers. Theories = specifications of (sets of) interpretations. SMT-LIB : international standard for SMT solvers. Mature implementations : CVC4, Z3, MathSAT, Yices, STP, Boolector, OpenSMT, ... Near ubiquitous in software verification.

slide-13
SLIDE 13

SMT SMT-LIB Theory of Floating-Point Conclusions

1

SMT

2

SMT-LIB Theory of Floating-Point

3

Conclusions

slide-14
SLIDE 14

SMT SMT-LIB Theory of Floating-Point Conclusions

Requirements

Principles Bit-Exact Must do exactly what the hardware does Precise Gives SAT / UNSAT (ideally with model / proof) Automated Ideally fast and “out of the box” Flexible Support different decision procedures Target Applications Path feasibility / test-case generation Generation of special values Numerical instability Undefined behaviour Hardware verification Functional correctness Automated numerical analysis

slide-15
SLIDE 15

SMT SMT-LIB Theory of Floating-Point Conclusions

IEEE-754 2008

slide-16
SLIDE 16

SMT SMT-LIB Theory of Floating-Point Conclusions

Level 1 : Extended Reals R∗ = R ∪ {+∞, −∞, NaN}

(partially ordered, additive and multiplicative commutative monoid with the distributivity property)

u + NaN = NaN + u = NaN −NaN = NaN u · NaN = NaN · u = NaN NaN−1 = NaN NaN u ⇔ u = NaN u NaN ⇔ u = NaN +∞ w ⇔ w = +∞ w −∞ ⇔ w = −∞ −(+∞) = −∞ −(−∞) = +∞ +∞−1 = −∞−1 = 0−1 = +∞ . . .

slide-17
SLIDE 17

SMT SMT-LIB Theory of Floating-Point Conclusions

Level 2(ish) : Domain

Fε,σ = Fε,σ ∪ {NaN} Fε,σ = FZε,σ ∪ FSε,σ ∪ FNε,σ ∪ FIε,σ FZε,σ = {(s, e, m) ∈ Bε,σ | e = 0ε, m = 0σ−1} FSε,σ = {(s, e, m) ∈ Bε,σ | e = 0ε, m = 0σ−1} FNε,σ = {(s, e, m) ∈ Bε,σ | e = 1ε, e = 0ε} FIε,σ = {(s, e, m) ∈ Bε,σ | e = 1ε, m = 0σ−1} vε,σ : Fε,σ → R∗

slide-18
SLIDE 18

SMT SMT-LIB Theory of Floating-Point Conclusions

IEEE-754 2008 again

slide-19
SLIDE 19

SMT SMT-LIB Theory of Floating-Point Conclusions

Upper and Lower Adjoints

+0 −0 +Inf −Inf +∞ −∞

slide-20
SLIDE 20

SMT SMT-LIB Theory of Floating-Point Conclusions

Upper and Lower Adjoints

+0 −0 +Inf −Inf +∞ −∞ v v v v

slide-21
SLIDE 21

SMT SMT-LIB Theory of Floating-Point Conclusions

Upper and Lower Adjoints

+0 −0 +Inf −Inf +∞ −∞ v v v v v v

slide-22
SLIDE 22

SMT SMT-LIB Theory of Floating-Point Conclusions

Rounding is (Just) Selecting Between Adjoints! rnd(v, mode, sz, r) = v(r) or v(r)

This allows us to round to any format of float, bit-vectors, Z, integer valued floats, ...

slide-23
SLIDE 23

SMT SMT-LIB Theory of Floating-Point Conclusions

Operations

addε,σ(rm, f , g) = rnd(v, rm, addSign(rm, f , g), v(f ) + v(g)) subε,σ(rm, f , g) = rnd(v, rm, subSign(rm, f , g), v(f ) − v(g)) mulε,σ(rm, f , g) = rnd(v, rm, xorSign(f , g), v(f ) ∗ v(g)) divǫ,σ(rm, f , g) =

  • negε,σ(rnd(v, rm, ⊤, −(v(f )/v(g))))

xorSign(f , g) rnd(v, rm, ⊥, v(f )/v(g)) ¬xorSign(f , g) fmaε,σ(rm, f , g, h) = rnd(v, rm, fmaSign(rm, f , g, h), (v(f ) ∗ v(g)) + v(h))

slide-24
SLIDE 24

SMT SMT-LIB Theory of Floating-Point Conclusions

Limitations and Omissions

No decimal floats Only one NaN (no signaling / quiet, no payload) No exceptions No attributes No trigonometric functions

slide-25
SLIDE 25

SMT SMT-LIB Theory of Floating-Point Conclusions

Implementations

Bit-blast ACDL Axiomatic CVC4 () () Z3

  • MathSAT
  • Sonolar
  • Alt-Ergo

() CBMC

slide-26
SLIDE 26

SMT SMT-LIB Theory of Floating-Point Conclusions

1

SMT

2

SMT-LIB Theory of Floating-Point

3

Conclusions

slide-27
SLIDE 27

SMT SMT-LIB Theory of Floating-Point Conclusions

Help Needed!

Correctness Examples

(edge cases, tests, challenge problems)

“Diamond free” circuits

(multiply, divide, shift, float add, normalise)

Elementary functions Floating-point remainder

slide-28
SLIDE 28

SMT SMT-LIB Theory of Floating-Point Conclusions

Conclusions

1 Formalisation as input (axiomatic) vs.

formalisation as specification (algebraic)

2 Rounding as choice of adjoints. 3 Have a specification (and implementations) of

an SMT-LIB standard of floating-point.

slide-29
SLIDE 29

SMT SMT-LIB Theory of Floating-Point Conclusions

Conclusions

1 Formalisation as input (axiomatic) vs.

formalisation as specification (algebraic)

2 Rounding as choice of adjoints. 3 Have a specification (and implementations) of

an SMT-LIB standard of floating-point. Thank you for your time and attention.

Made using only Free Software