Accurate ICP-Based Floating-Point Reasoning
Total Page:16
File Type:pdf, Size:1020Kb
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 Context of this Work FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 2 / 67 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 Context of this Work (2) C SMI HYS BTC-Toolchain SMI2iSAT iSAT3 Scripts FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 4 / 67 Context of this Work (3) C SMI HYS BTC-Toolchain SMI2iSAT iSAT3 annotate with coverage goal cone of influenceScripts 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 Context of this Work (4) C SMI HYS BTC-Toolchain SMI2iSAT iSAT3 This presentation: Scripts accurate reasoning for floating-point arithmetic support for bitwise integer operations FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 6 / 67 How does iSAT3 Work FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 7 / 67 iSAT3 = CDCL + ICP CDCL: conflict-driven clause learning ICP: interval constaint propagation FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 8 / 67 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 CDCL (1) CNF (:b _:h1) ^ (c _:h1) ^ Tseitin- (b _:c _ h1) ^ Transformation Boolean Formula (a _ h1 _:h2) ^ (h1 , (:b ^ c)) (a ⊕ (:b ^ c)) (a _:h1 _ h2) ^ (h2 , (a ⊕ h1)) (:a _ h1 _ h2) ^ (:a _:h1 _:h2) ^ (h2) FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 10 / 67 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 CDCL (3) CNF BCP (: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 12 / 67 CDCL (4) CNF BCP (:b _:h1) ^ (c _:h1) ^ no conflict (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 13 / 67 CDCL (4) CNF BCP (:b _:h1) ^ (c _:h1) ^ no conflict (b _:c _ h1) ^ (a _ h1 _:h2) ^ (a _:h1 _ h2) ^ (:a _ h1 _ h2) ^ (:a _:h _:h ) ^ 1 2 Decision (h2) FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 14 / 67 CDCL (4) CNF BCP (:b _:h1) ^ (c _:h1) ^ no conflict (b _:c _ h1) ^ (a _ h1 _:h2) ^ (a _:h1 _ h2) ^ (:a _ h1 _ h2) ^ (:a _:h _:h ) ^ 1 2 Decision (h ) 2 (or SAT) FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 15 / 67 CDCL (5) CNF BCP (:b _:h1) ^ (c _:h1) ^ no conflict conflict (b _:c _ h1) ^ (a _ h1 _:h2) ^ (a _:h1 _ h2) ^ (:a _ h1 _ h2) ^ (:a _:h _:h ) ^ 1 2 Decision (h ) 2 (or SAT) FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 16 / 67 CDCL (5) CNF BCP (:b _:h1) ^ (c _:h1) ^ no conflict conflict (b _:c _ h1) ^ (a _ h1 _:h2) ^ (a _:h1 _ h2) ^ (:a _ h1 _ h2) ^ (:a _:h _:h ) ^ 1 2 Decision Conflict Analysis (h ) 2 (or SAT) and Backtrack FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 17 / 67 CDCL (5) CNF BCP (:b _:h1) ^ (c _:h1) ^ no conflict conflict (b _:c _ h1) ^ (a _ h1 _:h2) ^ (a _:h1 _ h2) ^ (:a _ h1 _ h2) ^ (:a _:h _:h ) ^ 1 2 Decision Conflict Analysis (h ) 2 (SAT) and Backtrack (or UNSAT) FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 18 / 67 iSAT3 (1) PC + MAP + CNF 2 (h1 = y ) ^ (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 iSAT3 (1) PC + MAP + CNF (h = y2) ^ 1 SMT Formula (h2 = x + h1) ^ Tseitin-like h , h < ^ Transformation ( 3 ( 2 5)) (a ⊕ (x + y2 < 5)) (a _ h _:h ) ^ 3 4 2 (h1 = y ) (a _:h3 _ h4) ^ linear and nonlinear real arithmetic (h2 = x + h1) (:a _ h3 _ h4) ^ with transcendental functions (h , (h < 5)) (:a _:h3 _:h4) ^ 3 2 (h , (a ⊕ h )) (h4) 4 3 • maintain interval for every real- or integer-valued variable 2 • PC: primitive constraints: (h1 = y ), (h2 = x + h1) • MAP: map literals to simple bounds: (h3 , (h2 < 5)) FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 20 / 67 iSAT3 (1) PC + MAP + CNF Assignment 2 Variable Type Value (h1 = y ) ^ a bool falseSMT Formula (h2 = x + h1) ^ Tseitin-like h , h < x ^ Transformationreal ... ( 3 ( 2 5)) (a ⊕ (x + y2 < 5)) (a _ h _:h )y^ real ... 3 4 2 h (h1 = y ) (a _:h3 _ h4) ^1 real ...linear and nonlinear real arithmetic h (h2 = x + h1) h (:a _ h3 _ h4) ^2 real 3with transcendental functions (h , (h < 5)) (:a _:h3 _:h43) ^ 3bool 2 true (h , (a ⊕ h )) (h4) simple4 bound3 (h2 < 5) • maintain intervalh for everybool real- or integer-valuedtrue variable 4 2 • PC: primitive constraints: (h1 = y ), (h2 = x + h1) • MAP: map literals to simple bounds: (h3 , (h2 < 5)) FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 21 / 67 iSAT3 (2) PC + MAP + CNF 2 (h1 = y ) ^ (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 iSAT3 (3) PC + MAP + CNF 2 BCP, ICP (h1 = y ) ^ (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 23 / 67 iSAT3 (4) PC + MAP + CNF 2 BCP, ICP (h1 = y ) ^ (h2 = x + h1) ^ no conflict (h3 , (h2 < 5)) ^ (a _ h3 _:h4) ^ (a _:h3 _ h4) ^ (:a _ h3 _ h4) ^ (:a _:h _:h ) ^ 3 4 Decision, (h ) 4 Split (or SAT) FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 24 / 67 iSAT3 (5) PC + MAP + CNF 2 BCP, ICP (h1 = y ) ^ (h2 = x + h1) ^ no conflict conflict (h3 , (h2 < 5)) ^ (a _ h3 _:h4) ^ (a _:h3 _ h4) ^ (:a _ h3 _ h4) ^ (:a _:h _:h ) ^ 3 4 Decision, Conflict Analysis (h ) 4 Split and Backtrack (or SAT) (or UNSAT) FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 25 / 67 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 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 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 iSAT3 Summarized iSAT3 = CDCL + ICP, goes beyond CDCL(T): Boolean abstraction contains CDCL(T) iSAT3 combinations of truth values interval bounds of theory of the theory atoms variables and sub-expressions FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 29 / 67 iSAT3 Summarized iSAT3 = CDCL + ICP, goes beyond CDCL(T): Boolean abstraction contains CDCL(T) iSAT3 combinations of truth values interval bounds of theory of 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 iSAT3 Summarized iSAT3 = CDCL + ICP, goes beyond CDCL(T): Boolean abstraction contains CDCL(T) iSAT3 combinations of truth values interval bounds of theory of 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 Accurate Reasoning for Floating-Point Arithmetic FMCAD 2016 Karsten Scheibler – Accurate ICP-based FP Reasoning 32 / 67 Accurate Reasoning for FP (1) IEEE-754 Specification (float, 32 bits) Bitpos ! 31 30 .