smt techniques and solvers in automated termination

SMT Techniques and Solvers in Automated Termination Analysis - PowerPoint PPT Presentation

SMT Techniques and Solvers in Automated Termination Analysis Carsten Fuhs Birkbeck, University of London 2 nd July 2016 14 th Workshop on SAT Modulo Theories (SMT) Coimbra, Portugal Why analyze termination? 2/25 Why analyze termination? 1


  1. Example (Division) ο£± minus ( x, 0 ) β†’ x   minus ( s ( x ) , s ( y )) β†’ minus ( x, y ) ο£² R = quot ( 0 , s ( y )) β†’ 0   quot ( s ( x ) , s ( y )) β†’ s ( quot ( minus ( x, y ) , s ( y ))) ο£³ minus β™― ( s ( x ) , s ( y )) minus β™― ( x, y ) ο£± β†’ ο£² minus β™― ( x, y ) quot β™― ( s ( x ) , s ( y )) DP = β†’ quot β™― ( s ( x ) , s ( y )) quot β™― ( minus ( x, y ) , s ( y )) β†’ ο£³ Dependency Pairs [Arts, Giesl, TCS ’00 ] For TRS R build dependency pairs DP ( ∼ function calls) Show: No ∞ call sequence with DP (eval of DP ’s args via R ) Dependency Pair Framework [Giesl et al, JAR ’06 ] (simplified): while DP οΏ½ = βˆ… : 10/25

  2. Example (Division) ο£± minus ( x, 0 ) οΏ½ x   minus ( s ( x ) , s ( y )) οΏ½ minus ( x, y ) ο£² R = quot ( 0 , s ( y )) οΏ½ 0   quot ( s ( x ) , s ( y )) οΏ½ s ( quot ( minus ( x, y ) , s ( y ))) ο£³ minus β™― ( s ( x ) , s ( y )) minus β™― ( x, y ) ο£± οΏ½ ο£² minus β™― ( x, y ) quot β™― ( s ( x ) , s ( y )) DP = οΏ½ quot β™― ( s ( x ) , s ( y )) quot β™― ( minus ( x, y ) , s ( y )) οΏ½ ο£³ Dependency Pairs [Arts, Giesl, TCS ’00 ] For TRS R build dependency pairs DP ( ∼ function calls) Show: No ∞ call sequence with DP (eval of DP ’s args via R ) Dependency Pair Framework [Giesl et al, JAR ’06 ] (simplified): while DP οΏ½ = βˆ… : find well-founded order ≻ with DP βˆͺ R βŠ† οΏ½ 10/25

  3. Example (Division) ο£± minus ( x, 0 ) οΏ½ x   minus ( s ( x ) , s ( y )) οΏ½ minus ( x, y ) ο£² R = quot ( 0 , s ( y )) οΏ½ 0   quot ( s ( x ) , s ( y )) οΏ½ s ( quot ( minus ( x, y ) , s ( y ))) ο£³ ο£± minus β™― ( s ( x ) , s ( y )) minus β™― ( x, y ) ( οΏ½ )  ο£² quot β™― ( s ( x ) , s ( y )) minus β™― ( x, y ) DP = ( οΏ½ ) quot β™― ( s ( x ) , s ( y )) quot β™― ( minus ( x, y ) , s ( y )) ( οΏ½ )  ο£³ Dependency Pairs [Arts, Giesl, TCS ’00 ] For TRS R build dependency pairs DP ( ∼ function calls) Show: No ∞ call sequence with DP (eval of DP ’s args via R ) Dependency Pair Framework [Giesl et al, JAR ’06 ] (simplified): while DP οΏ½ = βˆ… : find well-founded order ≻ with DP βˆͺ R βŠ† οΏ½ delete s β†’ t with s ≻ t from DP 10/25

  4. Example (Division) ο£± minus ( x, 0 ) οΏ½ x   minus ( s ( x ) , s ( y )) οΏ½ minus ( x, y ) ο£² R = quot ( 0 , s ( y )) οΏ½ 0   quot ( s ( x ) , s ( y )) οΏ½ s ( quot ( minus ( x, y ) , s ( y ))) ο£³ ο£± minus β™― ( s ( x ) , s ( y )) minus β™― ( x, y ) ( οΏ½ )  ο£² quot β™― ( s ( x ) , s ( y )) minus β™― ( x, y ) DP = ( οΏ½ ) quot β™― ( s ( x ) , s ( y )) quot β™― ( minus ( x, y ) , s ( y )) ( οΏ½ )  ο£³ Dependency Pairs [Arts, Giesl, TCS ’00 ] For TRS R build dependency pairs DP ( ∼ function calls) Show: No ∞ call sequence with DP (eval of DP ’s args via R ) Dependency Pair Framework [Giesl et al, JAR ’06 ] (simplified): while DP οΏ½ = βˆ… : find well-founded order ≻ with DP βˆͺ R βŠ† οΏ½ delete s β†’ t with s ≻ t from DP Find ≻ automatically and efficiently 10/25

  5. Polynomial interpretations Get ≻ via polynomial interpretations [ Β· ] over N [Lankford ’79] β†’ ranking functions for rewriting Example minus ( s ( x ) , s ( y )) οΏ½ minus ( x, y ) 11/25

  6. Polynomial interpretations Get ≻ via polynomial interpretations [ Β· ] over N [Lankford ’79] β†’ ranking functions for rewriting Example minus ( s ( x ) , s ( y )) οΏ½ minus ( x, y ) Use [ Β· ] with [ minus ] ( x 1 , x 2 ) = x 1 [ s ] ( x 1 ) = x 1 + 1 11/25

  7. Polynomial interpretations Get ≻ via polynomial interpretations [ Β· ] over N [Lankford ’79] β†’ ranking functions for rewriting Example βˆ€ x, y. x + 1 = [ minus ( s ( x ) , s ( y )) ] β‰₯ [ minus ( x, y ) ] = x Use [ Β· ] with [ minus ] ( x 1 , x 2 ) = x 1 [ s ] ( x 1 ) = x 1 + 1 Extend to terms: [ x ] = x [ f ( t 1 , . . . , t n ) ] = [ f ] ( [ t 1 ] , . . . , [ t n ] ) ≻ boils down to > over N 11/25

  8. Example (Constraints for Division) ο£± minus ( x, 0 ) οΏ½ x   minus ( s ( x ) , s ( y )) minus ( x, y ) οΏ½ ο£² R = quot ( 0 , s ( y )) οΏ½ 0   quot ( s ( x ) , s ( y )) οΏ½ s ( quot ( minus ( x, y ) , s ( y ))) ο£³ ο£± minus β™― ( s ( x ) , s ( y )) minus β™― ( x, y ) ( οΏ½ )  ο£² quot β™― ( s ( x ) , s ( y )) minus β™― ( x, y ) DP = ( οΏ½ ) quot β™― ( s ( x ) , s ( y )) quot β™― ( minus ( x, y ) , s ( y )) ( οΏ½ )  ο£³ 12/25

  9. Example (Constraints for Division) ο£± minus ( x, 0 ) οΏ½ x   minus ( s ( x ) , s ( y )) οΏ½ minus ( x, y ) ο£² R = quot ( 0 , s ( y )) οΏ½ 0   quot ( s ( x ) , s ( y )) οΏ½ s ( quot ( minus ( x, y ) , s ( y ))) ο£³ minus β™― ( s ( x ) , s ( y )) minus β™― ( x, y ) ο£± ≻ ο£² quot β™― ( s ( x ) , s ( y )) minus β™― ( x, y ) DP = ≻ quot β™― ( s ( x ) , s ( y )) quot β™― ( minus ( x, y ) , s ( y )) ≻ ο£³ Use interpretation [ Β· ] over N with [ quot β™― ] ( x 1 , x 2 ) = x 1 + x 2 . [ quot ] ( x 1 , x 2 ) = x 1 + x 2 [ minus β™― ] ( x 1 , x 2 ) = x 1 [ minus ] ( x 1 , x 2 ) = x 1 [ 0 ] = 0 [ s ] ( x 1 ) = x 1 + 1 οΏ½ order solves all constraints 12/25

  10. Example (Constraints for Division) ο£± minus ( x, 0 ) οΏ½ x   minus ( s ( x ) , s ( y )) οΏ½ minus ( x, y ) ο£² R = quot ( 0 , s ( y )) οΏ½ 0   quot ( s ( x ) , s ( y )) οΏ½ s ( quot ( minus ( x, y ) , s ( y ))) ο£³ ο£± ο£² DP = ο£³ Use interpretation [ Β· ] over N with [ quot β™― ] ( x 1 , x 2 ) = x 1 + x 2 . [ quot ] ( x 1 , x 2 ) = x 1 + x 2 [ minus β™― ] ( x 1 , x 2 ) = x 1 [ minus ] ( x 1 , x 2 ) = x 1 [ 0 ] = 0 [ s ] ( x 1 ) = x 1 + 1 οΏ½ order solves all constraints οΏ½ DP = βˆ… οΏ½ termination of division algorithm proved οΏ½ 12/25

  11. Automation Task: Solve minus ( s ( x ) , s ( y )) οΏ½ minus ( x, y ) 13/25

  12. Automation Task: Solve minus ( s ( x ) , s ( y )) οΏ½ minus ( x, y ) 1 Fix a degree, use pol. interpretation with parametric coefficients: [ minus ] ( x, y ) = a m + b m x + c m y, [ s ] ( x ) = a s + b s x 13/25

  13. Automation Task: Solve minus ( s ( x ) , s ( y )) οΏ½ minus ( x, y ) 1 Fix a degree, use pol. interpretation with parametric coefficients: [ minus ] ( x, y ) = a m + b m x + c m y, [ s ] ( x ) = a s + b s x 2 From term constraint to polynomial constraint: s οΏ½ t οΏ½ [ s ] β‰₯ [ t ] Here: βˆ€ x, y. ( a s b m + a s c m ) + ( b s b m βˆ’ b m ) x + ( b s c m βˆ’ c m ) y β‰₯ 0 13/25

  14. Automation Task: Solve minus ( s ( x ) , s ( y )) οΏ½ minus ( x, y ) 1 Fix a degree, use pol. interpretation with parametric coefficients: [ minus ] ( x, y ) = a m + b m x + c m y, [ s ] ( x ) = a s + b s x 2 From term constraint to polynomial constraint: s οΏ½ t οΏ½ [ s ] β‰₯ [ t ] Here: βˆ€ x, y. ( a s b m + a s c m ) + ( b s b m βˆ’ b m ) x + ( b s c m βˆ’ c m ) y β‰₯ 0 3 Eliminate βˆ€ x, y by absolute positiveness criterion [Hong, JakuΕ‘, JAR ’98 ] : a s b m + a s c m β‰₯ 0 ∧ b s b m βˆ’ b m β‰₯ 0 ∧ b s c m βˆ’ c m β‰₯ 0 Here: 13/25

  15. Automation Task: Solve minus ( s ( x ) , s ( y )) οΏ½ minus ( x, y ) 1 Fix a degree, use pol. interpretation with parametric coefficients: [ minus ] ( x, y ) = a m + b m x + c m y, [ s ] ( x ) = a s + b s x 2 From term constraint to polynomial constraint: s οΏ½ t οΏ½ [ s ] β‰₯ [ t ] Here: βˆ€ x, y. ( a s b m + a s c m ) + ( b s b m βˆ’ b m ) x + ( b s c m βˆ’ c m ) y β‰₯ 0 3 Eliminate βˆ€ x, y by absolute positiveness criterion [Hong, JakuΕ‘, JAR ’98 ] : a s b m + a s c m β‰₯ 0 ∧ b s b m βˆ’ b m β‰₯ 0 ∧ b s c m βˆ’ c m β‰₯ 0 Here: 13/25

  16. Automation Task: Solve minus ( s ( x ) , s ( y )) οΏ½ minus ( x, y ) 1 Fix a degree, use pol. interpretation with parametric coefficients: [ minus ] ( x, y ) = a m + b m x + c m y, [ s ] ( x ) = a s + b s x 2 From term constraint to polynomial constraint: s οΏ½ t οΏ½ [ s ] β‰₯ [ t ] Here: βˆ€ x, y. ( a s b m + a s c m ) + ( b s b m βˆ’ b m ) x + ( b s c m βˆ’ c m ) y β‰₯ 0 3 Eliminate βˆ€ x, y by absolute positiveness criterion [Hong, JakuΕ‘, JAR ’98 ] : a s b m + a s c m β‰₯ 0 ∧ b s b m βˆ’ b m β‰₯ 0 ∧ b s c m βˆ’ c m β‰₯ 0 Here: 13/25

  17. Automation Task: Solve minus ( s ( x ) , s ( y )) οΏ½ minus ( x, y ) 1 Fix a degree, use pol. interpretation with parametric coefficients: [ minus ] ( x, y ) = a m + b m x + c m y, [ s ] ( x ) = a s + b s x 2 From term constraint to polynomial constraint: s οΏ½ t οΏ½ [ s ] β‰₯ [ t ] Here: βˆ€ x, y. ( a s b m + a s c m ) + ( b s b m βˆ’ b m ) x + ( b s c m βˆ’ c m ) y β‰₯ 0 3 Eliminate βˆ€ x, y by absolute positiveness criterion [Hong, JakuΕ‘, JAR ’98 ] : a s b m + a s c m β‰₯ 0 ∧ b s b m βˆ’ b m β‰₯ 0 ∧ b s c m βˆ’ c m β‰₯ 0 Here: Non-linear constraints (QF_NIA), even for linear interpretations 13/25

  18. Automation Task: Solve minus ( s ( x ) , s ( y )) οΏ½ minus ( x, y ) 1 Fix a degree, use pol. interpretation with parametric coefficients: [ minus ] ( x, y ) = a m + b m x + c m y, [ s ] ( x ) = a s + b s x 2 From term constraint to polynomial constraint: s οΏ½ t οΏ½ [ s ] β‰₯ [ t ] Here: βˆ€ x, y. ( a s b m + a s c m ) + ( b s b m βˆ’ b m ) x + ( b s c m βˆ’ c m ) y β‰₯ 0 3 Eliminate βˆ€ x, y by absolute positiveness criterion [Hong, JakuΕ‘, JAR ’98 ] : a s b m + a s c m β‰₯ 0 ∧ b s b m βˆ’ b m β‰₯ 0 ∧ b s c m βˆ’ c m β‰₯ 0 Here: Non-linear constraints (QF_NIA), even for linear interpretations Task: Show satisfiability of non-linear constraints over N οΏ½ Prove termination of given term rewrite system 13/25

  19. Extensions Polynomials with negative coefficients and max-operator [Hirokawa, Middeldorp, IC ’07 ; Fuhs et al, SAT ’07, RTA ’08 ] models behavior of functions more closely automation via SMT for QF_NIA, more complex Boolean structure 14/25

  20. Extensions Polynomials with negative coefficients and max-operator [Hirokawa, Middeldorp, IC ’07 ; Fuhs et al, SAT ’07, RTA ’08 ] models behavior of functions more closely automation via SMT for QF_NIA, more complex Boolean structure Polynomials over Q + and R + [Lucas, RAIRO ’05 ] non-integer coefficients increase proving power SMT-based automation [Fuhs et al, AISC ’08 ; Zankl, Middeldorp, LPAR ’10 ; Borralleras et al, JAR ’12 ] 14/25

  21. Extensions Polynomials with negative coefficients and max-operator [Hirokawa, Middeldorp, IC ’07 ; Fuhs et al, SAT ’07, RTA ’08 ] models behavior of functions more closely automation via SMT for QF_NIA, more complex Boolean structure Polynomials over Q + and R + [Lucas, RAIRO ’05 ] non-integer coefficients increase proving power SMT-based automation [Fuhs et al, AISC ’08 ; Zankl, Middeldorp, LPAR ’10 ; Borralleras et al, JAR ’12 ] Matrix interpretations [Endrullis, Waldmann, Zantema, JAR ’08 ] interpretation to vectors over N k , coefficients are matrices useful for deeply nested terms QF_NIA instances with more complex atoms 14/25

  22. Extensions Polynomials with negative coefficients and max-operator [Hirokawa, Middeldorp, IC ’07 ; Fuhs et al, SAT ’07, RTA ’08 ] models behavior of functions more closely automation via SMT for QF_NIA, more complex Boolean structure Polynomials over Q + and R + [Lucas, RAIRO ’05 ] non-integer coefficients increase proving power SMT-based automation [Fuhs et al, AISC ’08 ; Zankl, Middeldorp, LPAR ’10 ; Borralleras et al, JAR ’12 ] Matrix interpretations [Endrullis, Waldmann, Zantema, JAR ’08 ] interpretation to vectors over N k , coefficients are matrices useful for deeply nested terms QF_NIA instances with more complex atoms β€œArctic” matrices on the max-plus semiring on N or Z (instead of plus-times) [Koprowski, Waldmann, Acta Cyb. ’09 ] very useful for deeply nested terms can be encoded to QF_ L IA, but (unary!) bit-blasting seems to be faster in practice [Codish, Fekete, Fuhs, Giesl, Waldmann, SMT ’12 ] 14/25

  23. Extensions Polynomials with negative coefficients and max-operator [Hirokawa, Middeldorp, IC ’07 ; Fuhs et al, SAT ’07, RTA ’08 ] models behavior of functions more closely automation via SMT for QF_NIA, more complex Boolean structure Polynomials over Q + and R + [Lucas, RAIRO ’05 ] non-integer coefficients increase proving power SMT-based automation [Fuhs et al, AISC ’08 ; Zankl, Middeldorp, LPAR ’10 ; Borralleras et al, JAR ’12 ] Matrix interpretations [Endrullis, Waldmann, Zantema, JAR ’08 ] interpretation to vectors over N k , coefficients are matrices useful for deeply nested terms QF_NIA instances with more complex atoms β€œArctic” matrices on the max-plus semiring on N or Z (instead of plus-times) [Koprowski, Waldmann, Acta Cyb. ’09 ] very useful for deeply nested terms can be encoded to QF_ L IA, but (unary!) bit-blasting seems to be faster in practice [Codish, Fekete, Fuhs, Giesl, Waldmann, SMT ’12 ] 14/25

  24. Example (bits) ο£± half ( 0 ) β†’ 0 bits ( 0 ) β†’ 0 ο£² R = half ( s ( 0 )) β†’ 0 bits ( s ( x )) β†’ s ( bits ( half ( s ( x )))) half ( s ( s ( x ))) β†’ s ( half ( x )) ο£³ 15/25

  25. Example (bits) ο£± half ( 0 ) β†’ 0 bits ( 0 ) β†’ 0 ο£² R = half ( s ( 0 )) β†’ 0 bits ( s ( x )) β†’ s ( bits ( half ( s ( x )))) half ( s ( s ( x ))) β†’ s ( half ( x )) ο£³ half β™― ( s ( s ( x ))) half β™― ( x ) ο£± β†’ ο£² bits β™― ( s ( x )) half β™― ( s ( x )) DP = β†’ bits β™― ( s ( x )) bits β™― ( half ( s ( x ))) β†’ ο£³ 15/25

  26. Example (bits) ο£± half ( 0 ) οΏ½ 0 bits ( 0 ) οΏ½ 0 ο£² R = half ( s ( 0 )) οΏ½ 0 bits ( s ( x )) οΏ½ s ( bits ( half ( s ( x )))) half ( s ( s ( x ))) οΏ½ s ( half ( x )) ο£³ ο£± half β™― ( s ( s ( x ))) half β™― ( x ) ( οΏ½ )  ο£² bits β™― ( s ( x )) half β™― ( s ( x )) DP = ( οΏ½ ) bits β™― ( s ( x )) bits β™― ( half ( s ( x ))) ( οΏ½ )  ο£³ 15/25

  27. Example (bits) ο£± half ( 0 ) οΏ½ 0 bits ( 0 ) οΏ½ 0 ο£² R = half ( s ( 0 )) οΏ½ 0 bits ( s ( x )) οΏ½ s ( bits ( half ( s ( x )))) half ( s ( s ( x ))) οΏ½ s ( half ( x )) ο£³ ο£± ο£² DP = bits β™― ( s ( x )) bits β™― ( half ( s ( x ))) ≻ ο£³ 15/25

  28. Example (bits) ο£± half ( 0 ) οΏ½ 0 bits ( 0 ) οΏ½ 0 ο£² R = half ( s ( 0 )) οΏ½ 0 bits ( s ( x )) οΏ½ s ( bits ( half ( s ( x )))) half ( s ( s ( x ))) οΏ½ s ( half ( x )) ο£³ ο£± ο£² DP = bits β™― ( s ( x )) bits β™― ( half ( s ( x ))) ≻ ο£³ Classic polynomials cannot solve bits β™― ( s ( x )) ≻ bits β™― ( half ( s ( x ))) 15/25

  29. Example (bits) ο£± half ( 0 ) οΏ½ 0 bits ( 0 ) οΏ½ 0 ο£² R = half ( s ( 0 )) οΏ½ 0 bits ( s ( x )) οΏ½ s ( bits ( half ( s ( x )))) half ( s ( s ( x ))) οΏ½ s ( half ( x )) ο£³ ο£± ο£² DP = bits β™― ( s ( x )) bits β™― ( half ( s ( x ))) ≻ ο£³ Classic polynomials cannot solve bits β™― ( s ( x )) ≻ bits β™― ( half ( s ( x ))) [ bits β™― ] ( x ) = x, [ half ] ( x ) = x βˆ’ 1 Remedy: [ s ] ( x ) = x + 1 , 15/25

  30. Example (bits) ο£± half ( 0 ) οΏ½ 0 bits ( 0 ) οΏ½ 0 ο£² R = half ( s ( 0 )) οΏ½ 0 bits ( s ( x )) οΏ½ s ( bits ( half ( s ( x )))) half ( s ( s ( x ))) οΏ½ s ( half ( x )) ο£³ ο£± ο£² DP = bits β™― ( s ( x )) bits β™― ( half ( s ( x ))) ≻ ο£³ Classic polynomials cannot solve bits β™― ( s ( x )) ≻ bits β™― ( half ( s ( x ))) [ bits β™― ] ( x ) = x, [ half ] ( x ) = x βˆ’ 1 Remedy: [ s ] ( x ) = x + 1 , But: Then ≻ not well founded any more: 0 ≻ half ( 0 ) ≻ half ( half ( 0 )) ≻ . . . 15/25

  31. Example (bits) ο£± half ( 0 ) οΏ½ 0 bits ( 0 ) οΏ½ 0 ο£² R = half ( s ( 0 )) οΏ½ 0 bits ( s ( x )) οΏ½ s ( bits ( half ( s ( x )))) half ( s ( s ( x ))) οΏ½ s ( half ( x )) ο£³ ο£± ο£² DP = bits β™― ( s ( x )) bits β™― ( half ( s ( x ))) ≻ ο£³ Classic polynomials cannot solve bits β™― ( s ( x )) ≻ bits β™― ( half ( s ( x ))) [ bits β™― ] ( x ) = x, [ half ] ( x ) = x βˆ’ 1 Remedy: [ s ] ( x ) = x + 1 , But: Then ≻ not well founded any more: 0 ≻ half ( 0 ) ≻ half ( half ( 0 )) ≻ . . . β‡’ Solution [Hirokawa, Middeldorp, IC ’07 ] : [ half ] ( x 1 ) = max( x 1 βˆ’ 1 , 0) β‡’ [ half ( s ( x )) ] = max(( x + 1) βˆ’ 1 , 0) = x 15/25

  32. Example (bits) ο£± half ( 0 ) οΏ½ 0 bits ( 0 ) οΏ½ 0 ο£² R = half ( s ( 0 )) οΏ½ 0 bits ( s ( x )) οΏ½ s ( bits ( half ( s ( x )))) half ( s ( s ( x ))) οΏ½ s ( half ( x )) ο£³ ο£± ο£² DP = ο£³ Classic polynomials cannot solve bits β™― ( s ( x )) ≻ bits β™― ( half ( s ( x ))) [ bits β™― ] ( x ) = x, [ half ] ( x ) = x βˆ’ 1 Remedy: [ s ] ( x ) = x + 1 , But: Then ≻ not well founded any more: 0 ≻ half ( 0 ) ≻ half ( half ( 0 )) ≻ . . . β‡’ Solution [Hirokawa, Middeldorp, IC ’07 ] : [ half ] ( x 1 ) = max( x 1 βˆ’ 1 , 0) β‡’ [ half ( s ( x )) ] = max(( x + 1) βˆ’ 1 , 0) = x 15/25

  33. Problem: Expressions like max( x 1 βˆ’ 1 , 0) are no polynomials For [ s ] > [ t ], show 16/25

  34. Problem: Expressions like max( x 1 βˆ’ 1 , 0) are no polynomials For [ s ] > [ t ], show [ s ] left > [ t ] right [ s ] left under-approximation of [ s ] [ t ] right over-approximation of [ t ] [ s ] left , [ t ] right polynomials 16/25

  35. Problem: Expressions like max( x 1 βˆ’ 1 , 0) are no polynomials For [ s ] > [ t ], show [ s ] left > [ t ] right [ s ] left under-approximation of [ s ] [ t ] right over-approximation of [ t ] [ s ] left , [ t ] right polynomials Automation initially: Generate-and-test Approx. for max( p, 0) depend on signum of constant addend of p [ s ( x ) ] right β‡’ [ s ( x ) ] = max( x + 1 , 0) = x + 1 [ half ( x ) ] right [ half ( x ) ] = max( x βˆ’ 1 , 0) β‡’ = x 16/25

  36. Problem: Expressions like max( x 1 βˆ’ 1 , 0) are no polynomials For [ s ] > [ t ], show [ s ] left > [ t ] right [ s ] left under-approximation of [ s ] [ t ] right over-approximation of [ t ] [ s ] left , [ t ] right polynomials Automation initially: Generate-and-test Approx. for max( p, 0) depend on signum of constant addend of p [ s ( x ) ] right β‡’ [ s ( x ) ] = max( x + 1 , 0) = x + 1 [ half ( x ) ] right [ half ( x ) ] = max( x βˆ’ 1 , 0) β‡’ = x Solution [Fuhs et al, SAT ’07 ] : Encode case analysis . . . [ f ( x ) ] right = a f x 1 + c f ( x ) [ f ( x ) ] = max( a f x 1 + b f , 0) β‡’ . . . using side constraints ( b f β‰₯ 0 β†’ c f ( x ) = b f ) ∧ ( b f < 0 β†’ c f ( x ) = 0) Boolean structure in SMT quite handy! 16/25

  37. (SAT and) SMT solving for path orders Path orders: based on precedences of function symbols Recursive Path Order [Dershowitz, TCS ’82 ; Codish et al, JAR ’11 ] Weighted Path Order [Yamada, Kusakari, Sakabe, SCP ’15 ] 17/25

  38. (SAT and) SMT solving for path orders Path orders: based on precedences of function symbols Recursive Path Order [Dershowitz, TCS ’82 ; Codish et al, JAR ’11 ] Weighted Path Order [Yamada, Kusakari, Sakabe, SCP ’15 ] Knuth-Bendix Order [Knuth, Bendix, CPAA ’70 ] β†’ SMT-Encoding to QF_LIA [Zankl, Hirokawa, Middeldorp, JAR ’09 ] outperformed polynomial time algorithm [Korovin, Voronkov, IC ’03 ] in experiments 17/25

  39. (SAT and) SMT solving for path orders Path orders: based on precedences of function symbols Recursive Path Order [Dershowitz, TCS ’82 ; Codish et al, JAR ’11 ] Weighted Path Order [Yamada, Kusakari, Sakabe, SCP ’15 ] Knuth-Bendix Order [Knuth, Bendix, CPAA ’70 ] β†’ SMT-Encoding to QF_LIA [Zankl, Hirokawa, Middeldorp, JAR ’09 ] outperformed polynomial time algorithm [Korovin, Voronkov, IC ’03 ] in experiments Analogy: Exponential-time simplex vs. polynomial-time interior-point methods for QF_LRA? 17/25

  40. Further extensions Constrained term rewriting [Fuhs et al, RTA ’09 ; Kop, Nishida, FroCoS ’13 ; Rocha, Meseguer, MuΓ±oz, WRLA ’14 ] term rewriting with predefined operations from SMT theories, e.g. integer arithmetic, . . . target language for translations from programming languages 18/25

  41. Further extensions Constrained term rewriting [Fuhs et al, RTA ’09 ; Kop, Nishida, FroCoS ’13 ; Rocha, Meseguer, MuΓ±oz, WRLA ’14 ] term rewriting with predefined operations from SMT theories, e.g. integer arithmetic, . . . target language for translations from programming languages Complexity analysis [Hirokawa, Moser, IJCAR ’08 ; Noschinski, Emmes, Giesl, JAR ’13 ] Can re-use termination machinery to infer and prove statements like β€œruntime complexity of this TRS is in O ( n 3 ) ” 18/25

  42. SMT solvers from termination analysis Annual SMT-COMP, division QF_NIA Year Winner 2009 Barcelogic-QF_NIA 2010 MiniSmt 2011 AProVE 2012 no QF_NIA 2013 no SMT-COMP 2014 AProVE 2015 AProVE 2016 β†’ today, 4 pm 19/25

  43. SMT solvers from termination analysis Annual SMT-COMP, division QF_NIA Year Winner 2009 Barcelogic-QF_NIA 2010 MiniSmt (spin-off of T T 2) T 2011 AProVE 2012 no QF_NIA 2013 no SMT-COMP 2014 AProVE 2015 AProVE 2016 β†’ today, 4 pm β‡’ Termination provers can also be successful SMT solvers! 19/25

  44. SMT solvers from termination analysis Annual SMT-COMP, division QF_NIA Year Winner 2009 Barcelogic-QF_NIA 2010 MiniSmt (spin-off of T T 2) T 2011 AProVE 2012 no QF_NIA 2013 no SMT-COMP 2014 AProVE 2015 AProVE 2016 β†’ today, 4 pm β‡’ Termination provers can also be successful SMT solvers! (disclaimer: Z3 participated only hors concours in the last years) 19/25

  45. Term Rewrite Systems (TRSs) 1 Imperative Programs 2 20/25

  46. Papers on termination of imperative programs often about integers as data 21/25

  47. Papers on termination of imperative programs often about integers as data Example (Imperative program) if x β‰₯ 0: while x οΏ½ = 0: x = x βˆ’ 1 Does this program terminate? 21/25

  48. Papers on termination of imperative programs often about integers as data Example (Imperative program) if x β‰₯ 0: β„“ 0 : β„“ 1 : while x οΏ½ = 0: β„“ 2 : x = x βˆ’ 1 Does this program terminate? Example (Equivalent translation to transition system) β†’ [ x β‰₯ 0] β„“ 0 ( x ) β„“ 1 ( x ) β„“ 1 ( x ) β†’ β„“ 2 ( x ) [ x οΏ½ = 0] β„“ 2 ( x ) β†’ β„“ 1 ( x βˆ’ 1) β„“ 1 ( x ) β†’ β„“ 3 ( x ) [ x == 0] 21/25

  49. Papers on termination of imperative programs often about integers as data Example (Imperative program) if x β‰₯ 0: β„“ 0 : β„“ 1 : while x οΏ½ = 0: β„“ 2 : x = x βˆ’ 1 Does this program terminate? Example (Equivalent translation to transition system) β†’ [ x β‰₯ 0] β„“ 0 ( x ) β„“ 1 ( x ) β„“ 1 ( x ) β†’ β„“ 2 ( x ) [ x οΏ½ = 0] β„“ 2 ( x ) β†’ β„“ 1 ( x βˆ’ 1) β„“ 1 ( x ) β†’ β„“ 3 ( x ) [ x == 0] Oh no! β„“ 1 ( βˆ’ 1) β†’ β„“ 2 ( βˆ’ 1) β†’ β„“ 1 ( βˆ’ 2) β†’ β„“ 2 ( βˆ’ 2) β†’ β„“ 1 ( βˆ’ 3) β†’ Β· Β· Β· 21/25

  50. Papers on termination of imperative programs often about integers as data Example (Imperative program) if x β‰₯ 0: β„“ 0 : β„“ 1 : while x οΏ½ = 0: β„“ 2 : x = x βˆ’ 1 Does this program terminate? Example (Equivalent translation to transition system) β†’ [ x β‰₯ 0] β„“ 0 ( x ) β„“ 1 ( x ) β„“ 1 ( x ) β†’ β„“ 2 ( x ) [ x οΏ½ = 0] β„“ 2 ( x ) β†’ β„“ 1 ( x βˆ’ 1) β„“ 1 ( x ) β†’ β„“ 3 ( x ) [ x == 0] Oh no! β„“ 1 ( βˆ’ 1) β†’ β„“ 2 ( βˆ’ 1) β†’ β„“ 1 ( βˆ’ 2) β†’ β„“ 2 ( βˆ’ 2) β†’ β„“ 1 ( βˆ’ 3) β†’ Β· Β· Β· β‡’ Restrict initial states to β„“ 0 ( z ) for z ∈ Z 21/25

  51. Papers on termination of imperative programs often about integers as data Example (Imperative program) if x β‰₯ 0: β„“ 0 : β„“ 1 : while x οΏ½ = 0: β„“ 2 : x = x βˆ’ 1 Does this program terminate? Example (Equivalent translation to transition system) β†’ [ x β‰₯ 0] β„“ 0 ( x ) β„“ 1 ( x ) β„“ 1 ( x ) β†’ β„“ 2 ( x ) [ x οΏ½ = 0] β„“ 2 ( x ) β†’ β„“ 1 ( x βˆ’ 1) β„“ 1 ( x ) β†’ β„“ 3 ( x ) [ x == 0] Oh no! β„“ 1 ( βˆ’ 1) β†’ β„“ 2 ( βˆ’ 1) β†’ β„“ 1 ( βˆ’ 2) β†’ β„“ 2 ( βˆ’ 2) β†’ β„“ 1 ( βˆ’ 3) β†’ Β· Β· Β· β‡’ Restrict initial states to β„“ 0 ( z ) for z ∈ Z β‡’ Find invariant x β‰₯ 0 at β„“ 1 , β„“ 2 21/25

  52. Papers on termination of imperative programs often about integers as data Example (Imperative program) if x β‰₯ 0: β„“ 0 : β„“ 1 : while x οΏ½ = 0: β„“ 2 : x = x βˆ’ 1 Does this program terminate? Example (Equivalent translation to transition system) β†’ [ x β‰₯ 0] β„“ 0 ( x ) β„“ 1 ( x ) β„“ 1 ( x ) β†’ β„“ 2 ( x ) [ x οΏ½ = 0 ∧ x β‰₯ 0] β„“ 2 ( x ) β†’ β„“ 1 ( x βˆ’ 1) [ x β‰₯ 0] β„“ 1 ( x ) β†’ β„“ 3 ( x ) [ x == 0 ∧ x β‰₯ 0] Oh no! β„“ 1 ( βˆ’ 1) β†’ β„“ 2 ( βˆ’ 1) β†’ β„“ 1 ( βˆ’ 2) β†’ β„“ 2 ( βˆ’ 2) β†’ β„“ 1 ( βˆ’ 3) β†’ Β· Β· Β· β‡’ Restrict initial states to β„“ 0 ( z ) for z ∈ Z β‡’ Find invariant x β‰₯ 0 at β„“ 1 , β„“ 2 21/25

  53. Proving termination with invariants Example (Transition system with invariants) β„“ 0 ( x ) β†’ β„“ 1 ( x ) [ x β‰₯ 0] β„“ 1 ( x ) β†’ β„“ 2 ( x ) [ x οΏ½ = 0 ∧ x β‰₯ 0] β„“ 2 ( x ) β†’ β„“ 1 ( x βˆ’ 1) [ x β‰₯ 0] β„“ 1 ( x ) β†’ β„“ 3 ( x ) [ x == 0 ∧ x β‰₯ 0] Prove termination by ranking function [ Β· ] with [ β„“ 0 ] ( x ) = [ β„“ 1 ] ( x ) = Β· Β· Β· = x 22/25

  54. Proving termination with invariants Example (Transition system with invariants) β„“ 0 ( x ) β„“ 1 ( x ) [ x β‰₯ 0] οΏ½ β„“ 1 ( x ) οΏ½ β„“ 2 ( x ) [ x οΏ½ = 0 ∧ x β‰₯ 0] β„“ 2 ( x ) ≻ β„“ 1 ( x βˆ’ 1) [ x β‰₯ 0] β„“ 1 ( x ) οΏ½ β„“ 3 ( x ) [ x == 0 ∧ x β‰₯ 0] Prove termination by ranking function [ Β· ] with [ β„“ 0 ] ( x ) = [ β„“ 1 ] ( x ) = Β· Β· Β· = x 22/25

  55. Proving termination with invariants Example (Transition system with invariants) β„“ 0 ( x ) β„“ 1 ( x ) [ x β‰₯ 0] οΏ½ β„“ 1 ( x ) οΏ½ β„“ 2 ( x ) [ x οΏ½ = 0 ∧ x β‰₯ 0] β„“ 2 ( x ) ≻ β„“ 1 ( x βˆ’ 1) [ x β‰₯ 0] β„“ 1 ( x ) οΏ½ β„“ 3 ( x ) [ x == 0 ∧ x β‰₯ 0] Prove termination by ranking function [ Β· ] with [ β„“ 0 ] ( x ) = [ β„“ 1 ] ( x ) = Β· Β· Β· = x Automate search using parametric ranking function: [ β„“ 0 ] ( x ) = a 0 + b 0 Β· x, [ β„“ 1 ] ( x ) = a 1 + b 1 Β· x, . . . 22/25

  56. Proving termination with invariants Example (Transition system with invariants) β„“ 0 ( x ) β„“ 1 ( x ) [ x β‰₯ 0] οΏ½ β„“ 1 ( x ) οΏ½ β„“ 2 ( x ) [ x οΏ½ = 0 ∧ x β‰₯ 0] β„“ 2 ( x ) ≻ β„“ 1 ( x βˆ’ 1) [ x β‰₯ 0] β„“ 1 ( x ) οΏ½ β„“ 3 ( x ) [ x == 0 ∧ x β‰₯ 0] Prove termination by ranking function [ Β· ] with [ β„“ 0 ] ( x ) = [ β„“ 1 ] ( x ) = Β· Β· Β· = x Automate search using parametric ranking function: [ β„“ 0 ] ( x ) = a 0 + b 0 Β· x, [ β„“ 1 ] ( x ) = a 1 + b 1 Β· x, . . . Constraints e.g.: x β‰₯ 0 β‡’ a 2 + b 2 Β· x > a 1 + b 1 Β· ( x βˆ’ 1) β€œdecrease . . . ” x β‰₯ 0 β‡’ a 2 + b 2 Β· x β‰₯ 0 β€œ. . . against a bound” 22/25

  57. Proving termination with invariants Example (Transition system with invariants) β„“ 0 ( x ) β„“ 1 ( x ) [ x β‰₯ 0] οΏ½ β„“ 1 ( x ) οΏ½ β„“ 2 ( x ) [ x οΏ½ = 0 ∧ x β‰₯ 0] β„“ 2 ( x ) ≻ β„“ 1 ( x βˆ’ 1) [ x β‰₯ 0] β„“ 1 ( x ) οΏ½ β„“ 3 ( x ) [ x == 0 ∧ x β‰₯ 0] Prove termination by ranking function [ Β· ] with [ β„“ 0 ] ( x ) = [ β„“ 1 ] ( x ) = Β· Β· Β· = x Automate search using parametric ranking function: [ β„“ 0 ] ( x ) = a 0 + b 0 Β· x, [ β„“ 1 ] ( x ) = a 1 + b 1 Β· x, . . . Constraints e.g.: x β‰₯ 0 β‡’ a 2 + b 2 Β· x > a 1 + b 1 Β· ( x βˆ’ 1) β€œdecrease . . . ” x β‰₯ 0 β‡’ a 2 + b 2 Β· x β‰₯ 0 β€œ. . . against a bound” Use Farkas’ Lemma to eliminate βˆ€ x , QF_LRA solver gives model for a i , b i . 22/25

  58. Proving termination with invariants Example (Transition system with invariants) β„“ 0 ( x ) β„“ 1 ( x ) [ x β‰₯ 0] οΏ½ β„“ 1 ( x ) οΏ½ β„“ 2 ( x ) [ x οΏ½ = 0 ∧ x β‰₯ 0] β„“ 2 ( x ) ≻ β„“ 1 ( x βˆ’ 1) [ x β‰₯ 0] β„“ 1 ( x ) οΏ½ β„“ 3 ( x ) [ x == 0 ∧ x β‰₯ 0] Prove termination by ranking function [ Β· ] with [ β„“ 0 ] ( x ) = [ β„“ 1 ] ( x ) = Β· Β· Β· = x Automate search using parametric ranking function: [ β„“ 0 ] ( x ) = a 0 + b 0 Β· x, [ β„“ 1 ] ( x ) = a 1 + b 1 Β· x, . . . Constraints e.g.: x β‰₯ 0 β‡’ a 2 + b 2 Β· x > a 1 + b 1 Β· ( x βˆ’ 1) β€œdecrease . . . ” x β‰₯ 0 β‡’ a 2 + b 2 Β· x β‰₯ 0 β€œ. . . against a bound” Use Farkas’ Lemma to eliminate βˆ€ x , QF_LRA solver gives model for a i , b i . More: [Podelski, Rybalchenko, VMCAI ’04 , Alias et al, SAS ’10 ] 22/25

  59. Searching for invariants using SMT Termination prover needs to find invariants for programs on integers Statically before the translation [StrΓΆder et al, IJCAR ’14 ] In cooperation with a safety prover [Brockschmidt, Cook, Fuhs, CAV ’13 ] Using Max-SMT [Larraz, Oliveras, RodrΓ­guez-Carbonell, Rubio, FMCAD ’13 ] Nowadays all SMT-based! 23/25

  60. Extensions Proving non -termination (infinite run from initial states is possible) [Gupta et al, POPL ’08 , Brockschmidt et al, FoVeOOS ’11 , Chen et al, TACAS ’14 , Larraz et al, CAV ’14 , Cook et al, FMCAD ’14 ] CTL βˆ— model checking for infinite state systems based on termination and non-termination provers [Cook, Khlaaf, Piterman, CAV ’15 ] Complexity bounds [Alias et al, SAS ’10 , Hoffmann, Shao, JFP ’15 , Brockschmidt et al, TOPLAS ’16 ] 24/25

  61. Conclusion Automated termination analysis for term rewriting and for imperative programs developed in parallel over the last ∼ 15 years 25/25

  62. Conclusion Automated termination analysis for term rewriting and for imperative programs developed in parallel over the last ∼ 15 years Term rewriting: need to encode how to represent data structures 25/25

  63. Conclusion Automated termination analysis for term rewriting and for imperative programs developed in parallel over the last ∼ 15 years Term rewriting: need to encode how to represent data structures Imperative programs on integers: need to consider reachability and invariants 25/25

  64. Conclusion Automated termination analysis for term rewriting and for imperative programs developed in parallel over the last ∼ 15 years Term rewriting: need to encode how to represent data structures Imperative programs on integers: need to consider reachability and invariants Since a few years cross-fertilization 25/25

Recommend


More recommend