Integrating high-level constructs into programming languages Language extensions to make programming more productive Underspecified programs –give assertions,

Slides:



Advertisements
Similar presentations
Model Checking Lecture 4. Outline 1 Specifications: logic vs. automata, linear vs. branching, safety vs. liveness 2 Graph algorithms for model checking.
Advertisements

Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Representing Boolean Functions for Symbolic Model Checking Supratik Chakraborty IIT Bombay.
Semantics Static semantics Dynamic semantics attribute grammars
An Introduction to the Model Verifier verds Wenhui Zhang September 15 th, 2010.
Linked List Implementation class List { private List next; private Object data; private static List root; private static int size; public static void addNew(Object.
Propositional and First Order Reasoning. Terminology Propositional variable: boolean variable (p) Literal: propositional variable or its negation p 
On Solving Presburger and Linear Arithmetic with SAT Ofer Strichman Carnegie Mellon University.
Computability and Complexity 8-1 Computability and Complexity Andrei Bulatov Logic Reminder.
© 2011 Carnegie Mellon University Binary Decision Diagrams Part Bug Catching: Automated Program Verification and Testing Sagar Chaki September.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Nikolaj Bjørner Microsoft Research Lecture 3. DayTopicsLab 1Overview of SMT and applications. SAT solving, Z3 Encoding combinatorial problems with Z3.
Decision Procedures for Presburger Arithmetic Presented by Constantinos Bartzis.
Graphs 4/16/2017 8:41 PM NP-Completeness.
Equivalence Checking Using Cuts and Heaps Andreas Kuehlmann Florian Krohm IBM Thomas J. Watson Research Center Presented by: Zhenghua Qi.
Interpolants [Craig 1957] G(y,z) F(x,y)
1 Boolean Satisfiability in Electronic Design Automation (EDA ) By Kunal P. Ganeshpure.
Combining Theories Sharing Set Operations Thomas Wies joint work with Ruzica Piskac and Viktor Kuncak TexPoint fonts used in EMF. Read the TexPoint manual.
1 Polynomial Church-Turing thesis A decision problem can be solved in polynomial time by using a reasonable sequential model of computation if and only.
ECE Synthesis & Verification1 ECE 667 Spring 2011 Synthesis and Verification of Digital Systems Verification Introduction.
ECE Synthesis & Verification - Lecture 18 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Word-level.
ECE Synthesis & Verification - L211 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Verification Equivalence checking.
Taylor Expansion Diagrams (TED): Verification EC667: Synthesis and Verification of Digital Systems Spring 2011 Presented by: Sudhan.
On Solving Presburger and Linear Arithmetic with SAT Ofer Strichman Carnegie Mellon University.
Propositional Calculus Math Foundations of Computer Science.
SAT Solver Math Foundations of Computer Science. 2 Boolean Expressions  A Boolean expression is a Boolean function  Any Boolean function can be written.
Systems Architecture I1 Propositional Calculus Objective: To provide students with the concepts and techniques from propositional calculus so that they.
Binary Decision Diagrams (BDDs)
Model Checking Lecture 4 Tom Henzinger. Model-Checking Problem I |= S System modelSystem property.
1 A Combination Method for Generating Interpolants Greta Yorsh Madan Musuvathi Tel Aviv University, Israel Microsoft Research, Redmond, US CAV’05.
DECIDABILITY OF PRESBURGER ARITHMETIC USING FINITE AUTOMATA Presented by : Shubha Jain Reference : Paper by Alexandre Boudet and Hubert Comon.
The Complexity of Optimization Problems. Summary -Complexity of algorithms and problems -Complexity classes: P and NP -Reducibility -Karp reducibility.
CS 267: Automated Verification Lecture 6: Binary Decision Diagrams Instructor: Tevfik Bultan.
Synthesis using Variable Elimination Viktor Kuncak EPF Lausanne
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
CS 363 Comparative Programming Languages Semantics.
Testing Testing Techniques to Design Tests. Testing:Example Problem: Find a mode and its frequency given an ordered list (array) of with one or more integer.
CSCI 2670 Introduction to Theory of Computing November 29, 2005.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
CSC401 – Analysis of Algorithms Chapter 13 NP-Completeness Objectives: Introduce the definitions of P and NP problems Introduce the definitions of NP-hard.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View BDDs.
Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
Ruzica Piskac Max Planck Institute for Software Systems, Germany.
Symbolic Execution with Abstract Subsumption Checking Saswat Anand College of Computing, Georgia Institute of Technology Corina Păsăreanu QSS, NASA Ames.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
PhD Projects Rahul Santhanam University of Edinburgh.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View BDDs.
Examples and Sets. Synthesize each of These choose((x,y) =>10 x + 14 y == a) choose((x,y) =>10 x + 14 y == a&& x < y) choose((x,y) =>10 x + 14 y == a.
Verifying Programs with BDDs Topics Representing Boolean functions with Binary Decision Diagrams Application to program verification class-bdd.ppt
1 First order theories (Chapter 1, Sections 1.4 – 1.5) From the slides for the book “Decision procedures” by D.Kroening and O.Strichman.
1 A Simple Syntax-Directed Translator CS308 Compiler Theory.
Synthesis, Analysis, and Verification Lecture 08 Lectures: Viktor Kuncak BAPA: Quantifier Elimination and Decision Procedures WS1S: Automata-Based Decision.
Strings Basic data type in computational biology A string is an ordered succession of characters or symbols from a finite set called an alphabet Sequence.
Daniel Kroening and Ofer Strichman Decision Procedures An Algorithmic Point of View Deciding Combined Theories.
NPC.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View Basic Concepts and Background.
Selected Decision Procedures and Techniques for SMT More on combination – theories sharing sets – convex theory Un-interpreted function symbols (quantifier-free.
Section 1.4. Propositional Functions Propositional functions become propositions (and have truth values) when their variables are each replaced by a value.
2009/6/30 CAV Quantifier Elimination via Functional Composition Jie-Hong Roland Jiang Dept. of Electrical Eng. / Grad. Inst. of Electronics Eng.
Computability Examples. Reducibility. NP completeness. Homework: Find other examples of NP complete problems.
TU/e Algorithms (2IL15) – Lecture 10 1 NP-Completeness, II.
Quick Course Overview Quick review of logic and computational problems
Lifting Propositional Interpolants to the Word-Level
Propositional Calculus: Boolean Algebra and Simplification
Complete Program Synthesis for Linear Arithmetics
Predicates and Quantifiers
Dichotomies in CSP Karl Lieberherr inspired by the paper:
Verifying Programs with BDDs Sept. 22, 2006
Sharing Set Operations
Presentation transcript:

Integrating high-level constructs into programming languages Language extensions to make programming more productive Underspecified programs –give assertions, get code that enforces them –simplify programming, reasoning, testing Pattern matching –widely used construct in functional programs –synthesis can make it more expressive

Synthesis as Scala-compiler plugin Warning: solution not unique for: totsec=60 Given number of seconds, break it into hours, minutes, leftover our synthesis procedure choose:(A => Boolean) => A

Synthesis for Pattern Matching Our Scala compiler plugin: generates code that does division and testing of reminder checks that all cases are covered can use any integer linear arithmetic expressions

F’(x,y) formula is valid (true for all x,y) formula has a counterexample (x1, y1) for which it is false formula (bool-valued expression) Starting point: counterexample-generating decision procedures (validity) Decision Procedure Effective in verification: counterexample  error Can we use it in synthesis? Take negation of F’…

F(x,y) formula is unsatisfiable (false for all x,y) formula is true for (x1, y1) formula (bool-valued expression) Starting point: counterexample-generating decision procedures (satisfiability) Decision Procedure

10 < y Æ x < 6 Æ y < 3*x true for x=4, y=11 formula F with integer variables Example: integer linear arithmetic Decision Procedure No a-priori bounds on integers (add e.g. 0 <= y < 2 64 if needed)

function g on integers g x (y)=(y+1) div 3 formula F with integer variables Synthesis procedure for integers Synthesis Procedure Two kinds of variables: inputs – here y outputs – here x precondition P on y 10 < y < 14 - P describes precisely when solution exists. - (g x (y),y) is solution whenever P(y) 10 < y Æ x < 6 Æ y < 3*x

How does it work?

Quantifier elimination Take formula of the form 9 x. F(x,y) replace it with an equivalent formula G(y) without introducing new variables Repeat this process to eliminate all variables Algorithms for quantifier elimination (QE) exist for: –Presburger arithmetic (integer linear arithmetic) –set algebra –algebraic data types (term algebras) –polynomials over real/complex numbers –sequences of elements from structures with QE

Example: test-set method for QE (e.g. Weispfenning’97) Take formula of the form 9 x. F(x,y) replace it with an equivalent formula Ç i=1 n F i (t i (y),y) We can use it to generate a program: x = if F 1 (t 1 (y),y) then t 1 (y) else if F 2 (t 2 (y),y) then t 2 (y) … else if F n (t n (y),y) then t n (y) else throw new Exception(“No solution exists”) Can do it more efficiently – generalizing decision procedures and quantifier-elimination algorithms (use div, %, …) Example: Omega-test for Presburger arithmetic – Pugh’92

Presburger Arithmetic T ::= k | C | T 1 + T 2 | T 1 – T 2 | C ¢ T A ::= T 1 = T 2 | T 1 < T 2 F ::= A | F 1 Æ F 2 | F 1 Ç F 2 | : F | 9 k.F Presburger showed quantifier elimination for PA in 1929 requires introducing divisibility predicates Tarski said this was not enough for a PhD thesis Normal form for quantifier elimination step:

Parameterized Presburger arithmetic Given a base, and number convert a number into this base val base = read(…) val x = read(…) val (d2,d1,d0) = choose((x2,x1,x0) => x0 + base * (x1 + base * x2) == x && 0 <= x0 < base && 0 <= x1 < base) This also works, using a similar algorithm This time essential to have ‘for’ loops ‘for’ loops are useful even for simple PA case reduce code size, preserve efficiency

Beyond numbers

Synthesizing sets val s = … val (a1,a2) = choose((a1:Set[O],a2:Set[O]) ⇒ a1 union a2 == s && a1 intersect a2 == empty && abs(a1.size − a2.size) ≤ 1) Partition a set into two parts of almost-equal size

Boolean Algebra with Presburger Arithmetic Our results related to BAPA –complexity for full BAPA (like PA, has QE) –polynomial-time fragments –complexity for Q.F.BAPA –generalized to multisets –combined with function images –used as a glue to combine expressive logics –synthesize sets of objects from specifications S ::= V | S 1 [ S 2 | S 1 Å S 2 | S 1 n S 2 T ::= k | C | T 1 + T 2 | T 1 – T 2 | C ¢ T | card(S) A ::= S 1 = S 2 | S 1 µ S 2 | T 1 = T 2 | T 1 < T 2 F ::= A | F 1 Æ F 2 | F 1 Ç F 2 | : F | 9 S.F | 9 k.F

Computational benefits of synthesis Example: propositional formula F var p = read(…); var q = read(…) val (p0,q0) = choose((p,q) => F(p,q,u,v)) –SAT is NP-hard –generate BDD circuit over input variables for leaf nodes compute one output, if exists –running through this BDD is polynomial Reduced NP problem to polynomial one Also works for linear rational arithmetic (build decision tree with comparisons)

new decision procedures  new synthesis algorithms

 next0*(root0,n1)  x  {data0(n) | next0*(root0,n)}  next=next0[n1:=root0]  data=data0[n1:=x]  |{data(n) | next*(n1,n)}| = |{data0(n) | next0*(root0,n)}| + 1 formula is valid formula has a counterexample formula in an expressive decidable logic Combining decision procedures decision procedure A decision procedure B decision procedure C

Combining formulas with disjoint signatures (current tools) decision procedure for integer arithmetic decision procedure for function symbols x < y+1 & y < x+1 & x’=f(x) & y’=f(y) & x’=y’+1 x < y+1 y < x+1 x’=y’+1 x’=f(x) y’=f(y) x=y x’=y’ 0=1

Some research directions of LARA (Lab for Automated Reasoning & Analysis) Program verification and analysis tools both language-independent techniques, and translations from Scala, Java, PHP to logical models Decision procedures for reasoning about: algebraic data types, multisets, sets, graphs Techniques to combine decision procedures Program synthesis from specifications Dynamically deployed analysis, synthesis Specification-based systematic testing Collaboration on such activities within Europe