SMT Techniques and Solvers in Automated Termination Analysis

SMT Techniques and Solvers in Automated Termination Analysis

SMT Techniques and Solvers in Automated Termination Analysis Carsten Fuhs Birkbeck, University of London 2nd July 2016 14th Workshop on SAT Modulo Theories (SMT) Coimbra, Portugal 1 Program: produces result 2 Input handler: system reacts 3 Mathematical proof: the induction is valid 4 Biological process: reaches a stable state Variations of the same problem: 2 special case of 1 3 can be interpreted as 1 4 probabilistic version of 1 Why analyze termination? 2/25 2 Input handler: system reacts 3 Mathematical proof: the induction is valid 4 Biological process: reaches a stable state Variations of the same problem: 2 special case of 1 3 can be interpreted as 1 4 probabilistic version of 1 Why analyze termination? 1 Program: produces result 2/25 3 Mathematical proof: the induction is valid 4 Biological process: reaches a stable state Variations of the same problem: 2 special case of 1 3 can be interpreted as 1 4 probabilistic version of 1 Why analyze termination? 1 Program: produces result 2 Input handler: system reacts 2/25 4 Biological process: reaches a stable state Variations of the same problem: 2 special case of 1 3 can be interpreted as 1 4 probabilistic version of 1 Why analyze termination? 1 Program: produces result 2 Input handler: system reacts 3 Mathematical proof: the induction is valid 2/25 Variations of the same problem: 2 special case of 1 3 can be interpreted as 1 4 probabilistic version of 1 Why analyze termination? 1 Program: produces result 2 Input handler: system reacts 3 Mathematical proof: the induction is valid 4 Biological process: reaches a stable state 2/25 Why analyze termination? 1 Program: produces result 2 Input handler: system reacts 3 Mathematical proof: the induction is valid 4 Biological process: reaches a stable state Variations of the same problem: 2 special case of 1 3 can be interpreted as 1 4 probabilistic version of 1 2/25 We want to solve the (harder) question if a given program terminates on all inputs. That’s not even semi-decidable! But, fear not . The bad news Theorem (Turing 1936) The question if a given program terminates on a fixed input is undecidable. 3/25 That’s not even semi-decidable! But, fear not . The bad news Theorem (Turing 1936) The question if a given program terminates on a fixed input is undecidable. We want to solve the (harder) question if a given program terminates on all inputs. 3/25 But, fear not . The bad news Theorem (Turing 1936) The question if a given program terminates on a fixed input is undecidable. We want to solve the (harder) question if a given program terminates on all inputs. That’s not even semi-decidable! 3/25 The bad news Theorem (Turing 1936) The question if a given program terminates on a fixed input is undecidable. We want to solve the (harder) question if a given program terminates on all inputs. That’s not even semi-decidable! But, fear not . 3/25 1 Find ranking function f (“quantity”) 2 Prove f to have a lower bound (“vanish when the machine stops”) 3 Prove that f decreases over time Example (Termination can be simple) while x > 0: x = x − 1 Termination analysis, classically Turing 1949 “Finally the checker has to verify that the process comes to an end. [...] This may take the form of a quantity which is asserted to decrease continually and vanish when the machine stops.” 4/25 2 Prove f to have a lower bound (“vanish when the machine stops”) 3 Prove that f decreases over time Example (Termination can be simple) while x > 0: x = x − 1 Termination analysis, classically Turing 1949 “Finally the checker has to verify that the process comes to an end. [...] This may take the form of a quantity which is asserted to decrease continually and vanish when the machine stops.” 1 Find ranking function f (“quantity”) 4/25 3 Prove that f decreases over time Example (Termination can be simple) while x > 0: x = x − 1 Termination analysis, classically Turing 1949 “Finally the checker has to verify that the process comes to an end. [...] This may take the form of a quantity which is asserted to decrease continually and vanish when the machine stops.” 1 Find ranking function f (“quantity”) 2 Prove f to have a lower bound (“vanish when the machine stops”) 4/25 Example (Termination can be simple) while x > 0: x = x − 1 Termination analysis, classically Turing 1949 “Finally the checker has to verify that the process comes to an end. [...] This may take the form of a quantity which is asserted to decrease continually and vanish when the machine stops.” 1 Find ranking function f (“quantity”) 2 Prove f to have a lower bound (“vanish when the machine stops”) 3 Prove that f decreases over time 4/25 Termination analysis, classically Turing 1949 “Finally the checker has to verify that the process comes to an end. [...] This may take the form of a quantity which is asserted to decrease continually and vanish when the machine stops.” 1 Find ranking function f (“quantity”) 2 Prove f to have a lower bound (“vanish when the machine stops”) 3 Prove that f decreases over time Example (Termination can be simple) while x > 0: x = x − 1 4/25 Approach: Encode termination proof template to SMT formula ', ask SMT solver Answer: 1 ' satisfiable, model M: ) P terminating, M fills in the gaps in the termination proof 2 ' unsatisfiable: ) termination status of P unknown ) try a different template (proof technique) In practice: Encode only a proof step at a time ! try to prove only part of the program terminating Repeat until the whole program is proved terminating Termination analysis, in the era of SMT solvers Question: Does program P terminate? 5/25 Answer: 1 ' satisfiable, model M: ) P terminating, M fills in the gaps in the termination proof 2 ' unsatisfiable: ) termination status of P unknown ) try a different template (proof technique) In practice: Encode only a proof step at a time ! try to prove only part of the program terminating Repeat until the whole program is proved terminating Termination analysis, in the era of SMT solvers Question: Does program P terminate? Approach: Encode termination proof template to SMT formula ', ask SMT solver 5/25 1 ' satisfiable, model M: ) P terminating, M fills in the gaps in the termination proof 2 ' unsatisfiable: ) termination status of P unknown ) try a different template (proof technique) In practice: Encode only a proof step at a time ! try to prove only part of the program terminating Repeat until the whole program is proved terminating Termination analysis, in the era of SMT solvers Question: Does program P terminate? Approach: Encode termination proof template to SMT formula ', ask SMT solver Answer: 5/25 2 ' unsatisfiable: ) termination status of P unknown ) try a different template (proof technique) In practice: Encode only a proof step at a time ! try to prove only part of the program terminating Repeat until the whole program is proved terminating Termination analysis, in the era of SMT solvers Question: Does program P terminate? Approach: Encode termination proof template to SMT formula ', ask SMT solver Answer: 1 ' satisfiable, model M: ) P terminating, M fills in the gaps in the termination proof 5/25 In practice: Encode only a proof step at a time ! try to prove only part of the program terminating Repeat until the whole program is proved terminating Termination analysis, in the era of SMT solvers Question: Does program P terminate? Approach: Encode termination proof template to SMT formula ', ask SMT solver Answer: 1 ' satisfiable, model M: ) P terminating, M fills in the gaps in the termination proof 2 ' unsatisfiable: ) termination status of P unknown ) try a different template (proof technique) 5/25 Termination analysis, in the era of SMT solvers Question: Does program P terminate? Approach: Encode termination proof template to SMT formula ', ask SMT solver Answer: 1 ' satisfiable, model M: ) P terminating, M fills in the gaps in the termination proof 2 ' unsatisfiable: ) termination status of P unknown ) try a different template (proof technique) In practice: Encode only a proof step at a time ! try to prove only part of the program terminating Repeat until the whole program is proved terminating 5/25 The rest of this talk Termination proving in two parallel worlds 1 Term Rewrite Systems (TRSs) 2 Imperative Programs 6/25 1 Term Rewrite Systems (TRSs) 2 Imperative Programs 7/25 Syntactic approach for reasoning in equational first-order logic Core functional programming language without many restrictions (and features) of “real” FP: first-order (usually) no fixed evaluation strategy no fixed order of rules to apply (Haskell: top to bottom) untyped no pre-defined data structures (integers, arrays, :::) What’s Term Rewriting? 8/25 Core functional programming language without many restrictions (and features) of “real” FP: first-order (usually) no fixed evaluation strategy no fixed order of rules to apply (Haskell: top to bottom) untyped no pre-defined data structures (integers, arrays, :::) What’s Term Rewriting? Syntactic approach for reasoning in equational first-order logic 8/25 first-order (usually) no fixed evaluation strategy no fixed order of rules to apply (Haskell: top to bottom) untyped no pre-defined data structures (integers, arrays, :::) What’s Term Rewriting? Syntactic approach for reasoning in equational first-order logic Core functional programming language without many restrictions (and features) of “real” FP: 8/25 What’s Term Rewriting? Syntactic approach for reasoning in equational first-order logic Core functional programming language without many restrictions (and features) of “real” FP: first-order (usually) no fixed evaluation strategy no fixed

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    113 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us