Accurate ICP-based Floating-Point Reasoning - - PowerPoint PPT Presentation

accurate icp based floating point reasoning
SMART_READER_LITE
LIVE PREVIEW

Accurate ICP-based Floating-Point Reasoning - - PowerPoint PPT Presentation

Accurate ICP-based Floating-Point Reasoning Albert-Ludwigs-Universitt Freiburg Karsten Scheibler, Felix Neubauer, Ahmed Mahdi, Martin Frnzle, Tino Teige, Tom Bienmller, Detlef Fehrer, Bernd Becker Chair of Computer Architecture FMCAD


slide-1
SLIDE 1

Accurate ICP-based Floating-Point Reasoning

Albert-Ludwigs-Universität Freiburg

Karsten Scheibler, Felix Neubauer, Ahmed Mahdi, Martin Fränzle, Tino Teige, Tom Bienmüller, Detlef Fehrer, Bernd Becker

Chair of Computer Architecture FMCAD 2016

slide-2
SLIDE 2

Context of this Work

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 2 / 67

slide-3
SLIDE 3

Context of this Work (1)

Cooperation with Industrypartners (AVACS Transfer Project 1): “Accurate Dead Code Detection in Embedded C Code by Arithmetic Constraint Solving” University of Oldenburg: BTC-ES (Oldenburg): Ahmed Mahdi Tino Teige Martin Fränzle Tom Bienmüller University of Freiburg: SICK (Waldkirch): Felix Neubauer Detlef Fehrer Karsten Scheibler Bernd Becker

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 3 / 67

slide-4
SLIDE 4

Context of this Work (2)

C BTC-Toolchain SMI SMI2iSAT HYS iSAT3 Scripts

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 4 / 67

slide-5
SLIDE 5

Context of this Work (3)

C BTC-Toolchain SMI SMI2iSAT HYS iSAT3 Scripts annotate with coverage goal cone of influence reduction resolve loops and functions flatten data types static single assignment form BMC problem

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 5 / 67

slide-6
SLIDE 6

Context of this Work (4)

C BTC-Toolchain SMI SMI2iSAT HYS iSAT3 Scripts This presentation: accurate reasoning for floating-point arithmetic support for bitwise integer

  • perations

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 6 / 67

slide-7
SLIDE 7

How does iSAT3 Work

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 7 / 67

slide-8
SLIDE 8

iSAT3 = CDCL + ICP

CDCL: conflict-driven clause learning ICP: interval constaint propagation

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 8 / 67

slide-9
SLIDE 9

CDCL (1)

CNF (¬b∨¬h1) ∧ (c ∨¬h1) ∧ (b∨¬c ∨h1) ∧ (a∨h1 ∨¬h2) ∧ (a∨¬h1 ∨h2) ∧ (¬a∨h1 ∨h2) ∧ (¬a∨¬h1 ∨¬h2) ∧ (h2)

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 9 / 67

slide-10
SLIDE 10

CDCL (1)

CNF (¬b∨¬h1) ∧ (c ∨¬h1) ∧ (b∨¬c ∨h1) ∧ (a∨h1 ∨¬h2) ∧ (a∨¬h1 ∨h2) ∧ (¬a∨h1 ∨h2) ∧ (¬a∨¬h1 ∨¬h2) ∧ (h2) Tseitin- Transformation (h1 ⇔ (¬b∧c)) (h2 ⇔ (a⊕h1)) Boolean Formula (a⊕(¬b∧c))

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 10 / 67

slide-11
SLIDE 11

CDCL (2)

CNF (¬b∨¬h1) ∧ (c ∨¬h1) ∧ (b∨¬c ∨h1) ∧ (a∨h1 ∨¬h2) ∧ (a∨¬h1 ∨h2) ∧ (¬a∨h1 ∨h2) ∧ (¬a∨¬h1 ∨¬h2) ∧ (h2)

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 11 / 67

slide-12
SLIDE 12

CDCL (3)

CNF (¬b∨¬h1) ∧ (c ∨¬h1) ∧ (b∨¬c ∨h1) ∧ (a∨h1 ∨¬h2) ∧ (a∨¬h1 ∨h2) ∧ (¬a∨h1 ∨h2) ∧ (¬a∨¬h1 ∨¬h2) ∧ (h2) BCP

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 12 / 67

slide-13
SLIDE 13

CDCL (4)

CNF (¬b∨¬h1) ∧ (c ∨¬h1) ∧ (b∨¬c ∨h1) ∧ (a∨h1 ∨¬h2) ∧ (a∨¬h1 ∨h2) ∧ (¬a∨h1 ∨h2) ∧ (¬a∨¬h1 ∨¬h2) ∧ (h2) BCP

no conflict

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 13 / 67

slide-14
SLIDE 14

CDCL (4)

CNF (¬b∨¬h1) ∧ (c ∨¬h1) ∧ (b∨¬c ∨h1) ∧ (a∨h1 ∨¬h2) ∧ (a∨¬h1 ∨h2) ∧ (¬a∨h1 ∨h2) ∧ (¬a∨¬h1 ∨¬h2) ∧ (h2) BCP

no conflict

Decision

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 14 / 67

slide-15
SLIDE 15

CDCL (4)

CNF (¬b∨¬h1) ∧ (c ∨¬h1) ∧ (b∨¬c ∨h1) ∧ (a∨h1 ∨¬h2) ∧ (a∨¬h1 ∨h2) ∧ (¬a∨h1 ∨h2) ∧ (¬a∨¬h1 ∨¬h2) ∧ (h2) BCP

no conflict

Decision (or SAT)

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 15 / 67

slide-16
SLIDE 16

CDCL (5)

CNF (¬b∨¬h1) ∧ (c ∨¬h1) ∧ (b∨¬c ∨h1) ∧ (a∨h1 ∨¬h2) ∧ (a∨¬h1 ∨h2) ∧ (¬a∨h1 ∨h2) ∧ (¬a∨¬h1 ∨¬h2) ∧ (h2) BCP

no conflict

Decision (or SAT)

conflict

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 16 / 67

slide-17
SLIDE 17

CDCL (5)

CNF (¬b∨¬h1) ∧ (c ∨¬h1) ∧ (b∨¬c ∨h1) ∧ (a∨h1 ∨¬h2) ∧ (a∨¬h1 ∨h2) ∧ (¬a∨h1 ∨h2) ∧ (¬a∨¬h1 ∨¬h2) ∧ (h2) BCP

no conflict

Decision (or SAT)

conflict

Conflict Analysis and Backtrack

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 17 / 67

slide-18
SLIDE 18

CDCL (5)

CNF (¬b∨¬h1) ∧ (c ∨¬h1) ∧ (b∨¬c ∨h1) ∧ (a∨h1 ∨¬h2) ∧ (a∨¬h1 ∨h2) ∧ (¬a∨h1 ∨h2) ∧ (¬a∨¬h1 ∨¬h2) ∧ (h2) BCP

no conflict

Decision (SAT)

conflict

Conflict Analysis and Backtrack (or UNSAT)

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 18 / 67

slide-19
SLIDE 19

iSAT3 (1)

PC + MAP + CNF (h1 = y2) ∧ (h2 = x +h1) ∧ (h3 ⇔ (h2 < 5)) ∧ (a∨h3 ∨¬h4) ∧ (a∨¬h3 ∨h4) ∧ (¬a∨h3 ∨h4) ∧ (¬a∨¬h3 ∨¬h4) ∧ (h4)

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 19 / 67

slide-20
SLIDE 20

iSAT3 (1)

PC + MAP + CNF (h1 = y2) ∧ (h2 = x +h1) ∧ (h3 ⇔ (h2 < 5)) ∧ (a∨h3 ∨¬h4) ∧ (a∨¬h3 ∨h4) ∧ (¬a∨h3 ∨h4) ∧ (¬a∨¬h3 ∨¬h4) ∧ (h4) Tseitin-like Transformation (h1 = y2) (h2 = x +h1) (h3 ⇔ (h2 < 5)) (h4 ⇔ (a⊕h3)) SMT Formula (a⊕(x +y2 < 5))

linear and nonlinear real arithmetic with transcendental functions

  • maintain interval for every real- or integer-valued variable
  • PC: primitive constraints: (h1 = y2), (h2 = x +h1)
  • MAP: map literals to simple bounds: (h3 ⇔ (h2 < 5))

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 20 / 67

slide-21
SLIDE 21

iSAT3 (1)

PC + MAP + CNF (h1 = y2) ∧ (h2 = x +h1) ∧ (h3 ⇔ (h2 < 5)) ∧ (a∨h3 ∨¬h4) ∧ (a∨¬h3 ∨h4) ∧ (¬a∨h3 ∨h4) ∧ (¬a∨¬h3 ∨¬h4) ∧ (h4) Tseitin-like Transformation (h1 = y2) (h2 = x +h1) (h3 ⇔ (h2 < 5)) (h4 ⇔ (a⊕h3)) SMT Formula (a⊕(x +y2 < 5))

linear and nonlinear real arithmetic with transcendental functions

  • maintain interval for every real- or integer-valued variable
  • PC: primitive constraints: (h1 = y2), (h2 = x +h1)
  • MAP: map literals to simple bounds: (h3 ⇔ (h2 < 5))

Assignment Variable Type Value a bool false x real ... y real ... h1 real ... h2 real h3 h3 bool true simple bound (h2 < 5) h4 bool true

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 21 / 67

slide-22
SLIDE 22

iSAT3 (2)

PC + MAP + CNF (h1 = y2) ∧ (h2 = x +h1) ∧ (h3 ⇔ (h2 < 5)) ∧ (a∨h3 ∨¬h4) ∧ (a∨¬h3 ∨h4) ∧ (¬a∨h3 ∨h4) ∧ (¬a∨¬h3 ∨¬h4) ∧ (h4)

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 22 / 67

slide-23
SLIDE 23

iSAT3 (3)

PC + MAP + CNF (h1 = y2) ∧ (h2 = x +h1) ∧ (h3 ⇔ (h2 < 5)) ∧ (a∨h3 ∨¬h4) ∧ (a∨¬h3 ∨h4) ∧ (¬a∨h3 ∨h4) ∧ (¬a∨¬h3 ∨¬h4) ∧ (h4) BCP, ICP

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 23 / 67

slide-24
SLIDE 24

iSAT3 (4)

PC + MAP + CNF (h1 = y2) ∧ (h2 = x +h1) ∧ (h3 ⇔ (h2 < 5)) ∧ (a∨h3 ∨¬h4) ∧ (a∨¬h3 ∨h4) ∧ (¬a∨h3 ∨h4) ∧ (¬a∨¬h3 ∨¬h4) ∧ (h4) BCP, ICP

no conflict

Decision, Split (or SAT)

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 24 / 67

slide-25
SLIDE 25

iSAT3 (5)

PC + MAP + CNF (h1 = y2) ∧ (h2 = x +h1) ∧ (h3 ⇔ (h2 < 5)) ∧ (a∨h3 ∨¬h4) ∧ (a∨¬h3 ∨h4) ∧ (¬a∨h3 ∨h4) ∧ (¬a∨¬h3 ∨¬h4) ∧ (h4) BCP, ICP

no conflict

Decision, Split (or SAT)

conflict

Conflict Analysis and Backtrack (or UNSAT)

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 25 / 67

slide-26
SLIDE 26

iSAT3 (6)

SAT iSAT3 Deductions

  • BCP for clauses
  • BCP for clauses

evaluate simple bound literals implication clauses

  • ICP for PC

arithmetic clauses Decisions

  • decide literals
  • decide literals
  • generate new simple

bound literals and decide them Conflict Analyses

  • traverse implication
  • traverse implication

graph (1UIP) graph (1UIP) conflict clauses conflict clauses

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 26 / 67

slide-27
SLIDE 27

iSAT3 (6)

SAT iSAT3 Deductions

  • BCP for clauses
  • BCP for clauses

evaluate simple bound literals implication clauses

  • ICP for PC

arithmetic clauses Decisions

  • decide literals
  • decide literals
  • generate new simple

bound literals and decide them Conflict Analyses

  • traverse implication
  • traverse implication

graph (1UIP) graph (1UIP) conflict clauses conflict clauses

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 27 / 67

slide-28
SLIDE 28

iSAT3 (7)

Implication Clauses: unassigned simple bound literals are evaluated lazily therefore implications possible: (h2 < 5) ⇒ (h2 < 7) Arithmetic Clauses: result of interval constraint propagation (ICP) e.g. h2 = x +h1: ((x ≤ 3)∧(h1 < 2)) ⇒ (h2 < 5) redirect, e.g. x = h2 −h1: ((h2 < 10)∧(h1 ≥ 1)) ⇒ (x < 9) using floating-point numbers for interval bounds always round outwards for safe enclosing intervals generate new simple bound literals

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 28 / 67

slide-29
SLIDE 29

iSAT3 Summarized

iSAT3 = CDCL + ICP, goes beyond CDCL(T): Boolean abstraction contains CDCL(T) iSAT3 combinations of truth values interval bounds of theory

  • f the theory atoms

variables and sub-expressions

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 29 / 67

slide-30
SLIDE 30

iSAT3 Summarized

iSAT3 = CDCL + ICP, goes beyond CDCL(T): Boolean abstraction contains CDCL(T) iSAT3 combinations of truth values interval bounds of theory

  • f the theory atoms

variables and sub-expressions iSAT3 is the 3rd implementation of the iSAT

  • algorithm. Abstract CDCL with interval abstrac-

tion has similarities to the iSAT algorithm

iSAT algorithm: “Efficient Solving of Large Non-linear Arithmetic Constraint Systems with Complex Boolean Structure”, JSAT 2007 Abstract CDCL: “Deciding Floating-Point Logic with Systematic Abstraction”, FMCAD 2012 FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 30 / 67

slide-31
SLIDE 31

iSAT3 Summarized

iSAT3 = CDCL + ICP, goes beyond CDCL(T): Boolean abstraction contains CDCL(T) iSAT3 combinations of truth values interval bounds of theory

  • f the theory atoms

variables and sub-expressions

1 new arithmetic operations add ICP-contractors 2 need to adapt Boolean abstraction for floating-point

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 31 / 67

slide-32
SLIDE 32

Accurate Reasoning for Floating-Point Arithmetic

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 32 / 67

slide-33
SLIDE 33

Accurate Reasoning for FP (1)

IEEE-754 Specification (float, 32 bits) Bitpos → 31 30 ...23 22 ...0 sign exponent fraction / mantissa

1 normal numbers:

mantissa bitpos 23 assumed to be 1 exponent 1 −126 ... 254 +127 sign 0 positive 1 negative

2 special numbers:

signed zeros (−0, +0) −∞,+∞ (-inf, +inf) subnormal numbers (leading zeros in mantissa) not a number (NaN)

3 rounding modes (up, down, nearest)

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 33 / 67

slide-34
SLIDE 34

Accurate Reasoning for FP (2)

32 bit floating-point values and their ordering

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 34 / 67

slide-35
SLIDE 35

Accurate Reasoning for FP (2)

32 bit floating-point values and their ordering

  • inf
  • 0x0.000002p-126

+0x0.000002p-126 +inf

  • 0x1.fffffep+127

+0 +0x1.fffffep+127

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 35 / 67

slide-36
SLIDE 36

Accurate Reasoning for FP (2)

32 bit floating-point values and their ordering

  • inf
  • 0x0.000002p-126

+0x0.000002p-126 +inf

  • 0x1.fffffep+127

+0 +0x1.fffffep+127 hexadecimal floating-point notation

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 36 / 67

slide-37
SLIDE 37

Accurate Reasoning for FP (3)

simple bound ordering:

  • inf < -0x1.fffffep+127 < ...

...< -0x0.000002p-126 < -0 < +0 < +0x0.000002p-126 < ... ...< +0x1.fffffep+127 < +inf no strict bounds needed: reals: (x ≤ 5) ⇔ ¬(x > 5) floating-point: (x ≤-0x0.000002p-126) ⇔ ¬(x ≥-0) floating-point comparison operators and signed zeros:

(x <= 0) (x ≤+0) (x >= 0) (x ≥-0) (x == 0) (x ≥-0)∧(x ≤+0)

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 37 / 67

slide-38
SLIDE 38

Accurate Reasoning for FP (3)

32 bit floating-point values and their ordering

  • inf
  • 0x0.000002p-126

+0x0.000002p-126 +inf

  • 0x1.fffffep+127

+0 +0x1.fffffep+127

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 38 / 67

slide-39
SLIDE 39

Accurate Reasoning for FP (3)

32 bit floating-point values and their ordering

  • inf
  • 0x0.000002p-126

+0x0.000002p-126 +inf

  • 0x1.fffffep+127

+0 +0x1.fffffep+127 NaN ?

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 39 / 67

slide-40
SLIDE 40

Accurate Reasoning for FP (4)

#include <math.h> #include <stdio.h> int main(void) { double a = sqrt(-1); printf("%1.2f\n", a); if (a < 0) printf("if\n"); else printf("else\n"); if (a >= 0) printf("if\n"); else printf("else\n"); return (0); }

  • nan

else else

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 40 / 67

slide-41
SLIDE 41

Accurate Reasoning for FP (4)

#include <math.h> #include <stdio.h> int main(void) { double a = sqrt(-1); printf("%1.2f\n", a); if (a <= 0) printf("if\n"); else printf("else\n"); if (a > 0) printf("if\n"); else printf("else\n"); return (0); }

  • nan

else else

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 41 / 67

slide-42
SLIDE 42

Accurate Reasoning for FP (4)

#include <math.h> #include <stdio.h> int main(void) { double a = sqrt(-1); printf("%1.2f\n", a); if (a == 0) printf("if\n"); else printf("else\n"); if (a != 0) printf("if\n"); else printf("else\n"); return (0); }

  • nan

else if

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 42 / 67

slide-43
SLIDE 43

Accurate Reasoning for FP (5)

SAT iSAT3 Deductions

  • BCP for clauses
  • BCP for clauses

evaluate simple bound literals implication clauses

  • ICP for PC

arithmetic clauses Decisions

  • decide literals
  • decide literals
  • generate new simple

bound literals and decide them Conflict Analyses

  • traverse implication
  • traverse implication

graph (1UIP) graph (1UIP) conflict clauses conflict clauses

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 43 / 67

slide-44
SLIDE 44

Accurate Reasoning for FP (5)

NaN incomparable against all other values: (x ∼ NaN), ∼∈ {<,≤,=,≥,>} is always false adapt Boolean encoding: special literal xNaN xNaN x is NaN ¬xNaN x is determined by simple bound literals (x ≤-inf) ...(x ≤-0) ...

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 44 / 67

slide-45
SLIDE 45

Accurate Reasoning for FP (5)

implication clauses: (¬xNaN ∧(x ≤ 5)) ⇒ (x ≤ 7) arithmetic clauses: h = x +y (¬xNaN ∧¬yNaN ∧¬hNaN ∧(x ≤ 3)∧(y ≤ 2)) ⇒ (h ≤ 5) not shown here, but xNaN also relevant during Tseitin-like transformation besides <,≤,=,≥,> operators, further operator to mimic behaviour of assignments: x = y vs. x == y

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 45 / 67

slide-46
SLIDE 46

Accurate Reasoning for FP (6)

New ICP-Contractors for +,−,∗,/ (round-to-nearest):

1 NaN cases: handled outside with separate clauses 2 forward deduction: execute operation with round-to-nearest 3 backward deduction: only redirecting the primitive

constraint is not enough

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 46 / 67

slide-47
SLIDE 47

Accurate Reasoning for FP (6)

New ICP-Contractors for +,−,∗,/ (round-to-nearest):

1 NaN cases: handled outside with separate clauses 2 forward deduction: execute operation with round-to-nearest 3 backward deduction: only redirecting the primitive

constraint is not enough ICP-contractors called when NaN-literals of operands false (otherwise the created arithmetic clauses not unit)

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 46 / 67

slide-48
SLIDE 48

Accurate Reasoning for FP (6)

1 Separate clauses for primitive constraint (h = x +y):

x or y is NaN ⇒ h is NaN x and y are infinities with opposite signs ⇒ h is NaN x and y are not NaN and x is never -inf or +inf ⇒ h is not NaN x and y are not NaN and y is never -inf or +inf ⇒ h is not NaN x and y are not NaN and x and y are never -inf ⇒ h is not NaN x and y are not NaN and x and y are never +inf ⇒ h is not NaN (¬xNaN ∨hNaN) ∧ (¬yNaN ∨hNaN) ∧ (xNaN ∨yNaN ∨¬(x ≤-inf)∨¬(y ≥+inf)∨hNaN) ∧ (xNaN ∨yNaN ∨¬(x ≥+inf)∨¬(y ≤-inf)∨hNaN) ∧ (xNaN ∨yNaN ∨(x ≤-inf)∨(x ≥+inf)∨¬hNaN) ∧ (xNaN ∨yNaN ∨(y ≤-inf)∨(y ≥+inf)∨¬hNaN) ∧ (xNaN ∨yNaN ∨(x ≤-inf)∨(y ≤-inf)∨¬hNaN) ∧ (xNaN ∨yNaN ∨(x ≥+inf)∨(y ≥+inf)∨¬hNaN)

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 47 / 67

slide-49
SLIDE 49

Accurate Reasoning for FP (6)

2 Forward deduction primitive constraint (h = x +y):

h ∈ [-inf, +inf], x ∈ [0x1.1p+100, 0x1.1p+100], y ∈ [-0x1.1p+11, -0x1.1p+10] hlb = xlb +ylb =0x1.1p+100+-0x1.1p+11=0x1.1p+100 hub = xub +yub =0x1.1p+100+-0x1.1p+10=0x1.1p+100 apply operation with round-to-nearest

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 48 / 67

slide-50
SLIDE 50

Accurate Reasoning for FP (6)

3 Backward deduction primitive constraint (h = x +y):

h ∈ [0x1.1p+100, 0x1.1p+100], x ∈ [0x1.1p+100, 0x1.1p+100], y ∈ [-0x1.1p+11, -0x1.1p+10] ylb = hlb −xub = 0x1.1p+100−0x1.1p+100 = yub = hub −xlb = 0x1.1p+100−0x1.1p+100 = [-0x1.1p+11, -0x1.1p+10]∩[0,0] = / simply redirecting and rounding outward is WRONG!

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 49 / 67

slide-51
SLIDE 51

Accurate Reasoning for FP (6)

3 Backward deduction primitive constraint (h = x +y):

h ∈ [0x1.1p+100, 0x1.1p+100], x ∈ [0x1.1p+100, 0x1.1p+100], y ∈ [-0x1.1p+11, -0x1.1p+10] ylb = hlb −xub = prev(0x1.1p+100)−next(0x1.1p+100) = 0x1.0ffffep+100 - 0x1.100002p+100 =

  • 0x1.000000p+78

yub = hub −xlb = next(0x1.1p+100)−prev(0x1.1p+100) = 0x1.100002p+100 - 0x1.0ffffep+100 = 0x1.000000p+78

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 50 / 67

slide-52
SLIDE 52

Accurate Reasoning for FP Summarized

floating-point arithmetic contains special values

  • rdering possible, except NaN

unordered NaN adapted Boolean encoding

implication clauses arithmetic clauses

new ICP-contractors for floating-point operations

NaN-cases handled with BCP

  • utward rounding not enough in backward deduction

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 51 / 67

slide-53
SLIDE 53

ICP-Contractors for Bitwise Integer Operations

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 52 / 67

slide-54
SLIDE 54

ICP-Contractors for Bitwise Operations (1)

  • perating on intervals

a bit-pattern can be interpreted as signed or unsigned

00010001 10000001 signed char 17

  • 127

unsigned char 17 129

need to know bitwidth and signedness of each operation s_not(arg,bitwidth), u_not(arg,bitwidth) s_and(arg1,arg2,bitwidth), u_and(arg1,arg2,bitwidth) s_or(arg1,arg2,bitwidth), u_or(arg1,arg2,bitwidth) s_xor(arg1,arg2,bitwidth), u_xor(arg1,arg2,bitwidth) s_cast(arg,bitwidth), u_cast(arg,bitwidth)

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 53 / 67

slide-55
SLIDE 55

ICP-Contractors for Bitwise Operations (2)

(h = x +y), x ∈ [1,7], y ∈ [1,8]: hlb = xlb +ylb = 1+1 = 2 hub = xub +yub = 7+8 = 15

  • perating on bounds OK

(h = u_and(x,y,8)), x ∈ [1,7], y ∈ [1,8]: hlb = xlb & ylb = 1 & 1 = 1 (1 & 2 = 0) hub = xub & yub = 7 & 8 = (7 & 7 = 7)

  • perating on bounds WRONG

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 54 / 67

slide-56
SLIDE 56

ICP-Contractors for Bitwise Operations (3)

1 use addition, subtraction, minimum and maximum to get

safe overapproximations of the lower and upper bounds,

e.g. (h = u_and(x,y,8)), x ∈ [1,7], y ∈ [1,8]: hub = min(xub,yub) = min(7,8) = 7

2 exploit common bit-prefixes,

e.g. (h = u_and(x,y,8)), x ∈ [18,30], y ∈ [89,92]: xlb = 18 = 00010010 xub = 30 = 00011110 0001 common bit-prefix for values in x ylb = 89 = 01011001 yub = 92 = 01011100 01011 common bit-prefix for values in y hlb = 00010000 & 01011000 = 00010000 = 16 trailing bits are 0 hub = 00011111 & 01011111 = 00011111 = 31 trailing bits are 1

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 55 / 67

slide-57
SLIDE 57

ICP-Contractors for Bitwise Operations (3)

1 use addition, subtraction, minimum and maximum to get

safe overapproximations of the lower and upper bounds,

e.g. (h = u_and(x,y,8)), x ∈ [1,7], y ∈ [1,8]: hub = min(xub,yub) = min(7,8) = 7

2 exploit common bit-prefixes,

e.g. (h = u_and(x,y,8)), x ∈ [18,30], y ∈ [89,92]: xlb = 18 = 00010010 xub = 30 = 00011110 0001 common bit-prefix for values in x ylb = 89 = 01011001 yub = 92 = 01011100 01011 common bit-prefix for values in y hlb = 00010000 & 01011000 = 00010000 = 16 trailing bits are 0 hub = 00011111 & 01011111 = 00011111 = 31 trailing bits are 1

A detailed description of all operations can be found in AVACS Technical Report 116: “Extending iSAT3 with ICP-Contractors for Bitwise In- teger Operations”

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 56 / 67

slide-58
SLIDE 58

Optimizations

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 57 / 67

slide-59
SLIDE 59

Intermediate Point-Splits

decomposition into PCs might lead to coarser intervals, e.g. ((x +y)−x ≤ 7) (h1 = x +y)∧(h2 = h1 −x) x,y ∈ [0,10] : h1 ∈ [0,20],h2 ∈ [−10,30] ⊃ [0,10] tighter intervals if x is point interval change decision heuristic, every k-th interval split will assign a point interval (k = 4) might help to find a solution, BUT: detrimental for conflict clauses

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 58 / 67

slide-60
SLIDE 60

Global-ICP (1)

... ∧ (a → (i1 −i2 = 0)) ∧ (i1 = s_cast(ite(b,i2,0),32))∧...

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 59 / 67

slide-61
SLIDE 61

Global-ICP (1)

... ∧ (a → (i1 −i2 = 0)) ∧ (i1 = s_cast(ite(b,i2,0),32))∧... with a = 1: ... ∧ (i1 −i2 = 0) ∧ (i1 = s_cast(ite(b,i2,0),32))∧... ... ∧ (i1 = i2) ∧ (i1 = s_cast(ite(b,i2,0),32))∧... ... ∧ (i1 = s_cast(ite(b,i1,0),32))∧...

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 59 / 67

slide-62
SLIDE 62

Global-ICP (1)

... ∧ (a → (i1 −i2 = 0)) ∧ (i1 = s_cast(ite(b,i2,0),32))∧... with a = 1: ... ∧ (i1 −i2 = 0) ∧ (i1 = s_cast(ite(b,i2,0),32))∧... ... ∧ (i1 = i2) ∧ (i1 = s_cast(ite(b,i2,0),32))∧... ... ∧ (i1 = s_cast(ite(b,i1,0),32))∧... with b = 1: ... ∧ (i1 = s_cast(i1,32))∧...

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 59 / 67

slide-63
SLIDE 63

Global-ICP (1)

... ∧ (a → (i1 −i2 = 0)) ∧ (i1 = s_cast(ite(b,i2,0),32))∧... with a = 1: ... ∧ (i1 −i2 = 0) ∧ (i1 = s_cast(ite(b,i2,0),32))∧... ... ∧ (i1 = i2) ∧ (i1 = s_cast(ite(b,i2,0),32))∧... ... ∧ (i1 = s_cast(ite(b,i1,0),32))∧... with b = 1: ... ∧ (i1 = s_cast(i1,32))∧... with i1 ∈ [0,231 −1]: ... ∧ (i1 = i1)∧...

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 59 / 67

slide-64
SLIDE 64

Global-ICP (1)

... ∧ (a → (i1 −i2 = 0)) ∧ (i1 = s_cast(ite(b,i2,0),32))∧... with a = 1: ... ∧ (i1 −i2 = 0) ∧ (i1 = s_cast(ite(b,i2,0),32))∧... ... ∧ (i1 = i2) ∧ (i1 = s_cast(ite(b,i2,0),32))∧... ... ∧ (i1 = s_cast(ite(b,i1,0),32))∧... with b = 1: ... ∧ (i1 = s_cast(i1,32))∧... with i1 ∈ [0,231 −1]: ... ∧ (i1 = i1)∧... but this symbolic dependency is not visible for ICP (h1 = i1 −i2)∧ (h2 = ite(b,i2,0))∧ just looking at these (h3 = s_scast(h2,32))∧ primitive constraints (h4 = i1 −h3)

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 59 / 67

slide-65
SLIDE 65

Global-ICP (1)

... ∧ (a → (i1 −i2 = 0)) ∧ (i1 = s_cast(ite(b,i2,0),32))∧... with a = 1: ... ∧ (i1 −i2 = 0) ∧ (i1 = s_cast(ite(b,i2,0),32))∧... ... ∧ (i1 = i2) ∧ (i1 = s_cast(ite(b,i2,0),32))∧... ... ∧ (i1 = s_cast(ite(b,i1,0),32))∧... with b = 1: ... ∧ (i1 = s_cast(i1,32))∧... with i1 ∈ [0,231 −1]: ... ∧ (i1 = i1)∧... but this symbolic dependency is not visible for ICP (h1 = i1 −i2)∧ (h2 = ite(b,i2,0))∧ just looking at these (h3 = s_scast(h2,32))∧ primitive constraints (h4 = i1 −h3) ICP with smallest possible bound improvement for i1: [1,231 −1] [2,231 −1] [2,231 −2] ...

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 59 / 67

slide-66
SLIDE 66

Global-ICP (2)

ICP with smallest possible bound improvement for i1: [1,231 −1] [2,231 −1] [2,231 −2] ... more than 64 deductions per variable per decision level:

1 no further deductions for this variable 2 analyze implication graph, collect involved primitive

constraints (the 4 PCs from previous slide)

analyze primitive constraints semi-symbolically conflicting clause which spans more than one PC, e.g. (b∧(h1 ≥ 0)∧(h1 ≤ 0)∧(i2 ≥ 0)∧(i2 ≤ 231 −1)) ⇒ (h4 ≤ 0)

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 60 / 67

slide-67
SLIDE 67

Results

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 61 / 67

slide-68
SLIDE 68

Results (1)

213 pure floating-point benchmarks from the FP-ACDCL paper Comparison between FP-ACDCL (ICP-based), Mathsat (bit-blasting) and iSAT3 (ICP-based) Timeout: 900 seconds, Memout: 2 GB Solver S+U SAT UNSAT TO MO FP-ACDCL 173 97 76 40 Mathsat 5.3.11 182 101 81 23 8 iSAT3 164 90 74 47 2 iSAT3 + psplits 186 111 75 27 iSAT3 + psplits + gicp 193 111 82 20

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 62 / 67

slide-69
SLIDE 69

Results (1)

900s 600s 300s 0s 50 100 150 200 Number of solved benchmarks Time FP-ACDCL Mathsat 5.3.11 iSAT3 + psplits + gicp

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 63 / 67

slide-70
SLIDE 70

Results (2)

8778 BMC benchmarks generated by BTC toolchain, containing floating-point and bitwise integer operations Comparison between CBMC (bit-blasting, k-induction) and iSAT3 (ICP-based, Craig interpolation)

both with on-the-fly translation from SMI to their input language

Timeout: 60 seconds Solver S+U SAT U51 U∞ TO SMI-CBMC 8099 7424 44 631 679 SMI-iSAT3 7647 6671 153 823 1131 SMI-iSAT3 + psplits 8169 7192 156 821 609 SMI-iSAT3 + psplits + gicp 8430 7427 172 831 348

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 64 / 67

slide-71
SLIDE 71

Results (2)

60s 40s 20s 0s 2 100 4 200 6 300 8 400 Number of solved benchmarks Time SMI-CBMC SMI-iSAT3 + psplits + gicp

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 65 / 67

slide-72
SLIDE 72

Conclusion

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 66 / 67

slide-73
SLIDE 73

Conclusion

dead-code detection in C programs = accurate floating-point reasoning + bitwise integer operations iSAT3: first non-bit-blasting SMT solver supporting the full range of basic data types and operations in C programs promising results:

  • utperforms bit-blasting solvers (MathSAT, CBMC)
  • utperforms other ICP-based solver (FP-ACDCL)

Outlook: also integrate ICP-contractors for floating-point sine, cosine

FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 67 / 67