QuickCheck: A Lightweight Tool for Random Testing of Haskell Programs By Koen Claessen, Juhn Hughes ME: Mike Izbicki.

Slides:



Advertisements
Similar presentations
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Advertisements

A System to Generate Test Data and Symbolically Execute Programs Lori A. Clarke September 1976.
1 Regression-Verification Benny Godlin Ofer Strichman Technion.
Timed Automata.
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
1 Chapter Six Algorithms. 2 Algorithms An algorithm is an abstract strategy for solving a problem and is often expressed in English A function is the.
David Evans CS655: Programming Languages University of Virginia Computer Science Lecture 19: Minding Ps & Qs: Axiomatic.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
ISBN Chapter 3 Describing Syntax and Semantics.
1 Semantic Description of Programming languages. 2 Static versus Dynamic Semantics n Static Semantics represents legal forms of programs that cannot be.
CS 355 – Programming Languages
Software Reliability CIS 640 Adapted from the lecture notes by Doron Pelel (
An Integration of Program Analysis and Automated Theorem Proving Bill J. Ellis & Andrew Ireland School of Mathematical & Computer Sciences Heriot-Watt.
Leveraging Assertion Based Verification by using Magellan Michal Cayzer.
1 Basic Definitions: Testing What is software testing? Running a program In order to find faults a.k.a. defects a.k.a. errors a.k.a. flaws a.k.a. faults.
CPSC 411, Fall 2008: Set 12 1 CPSC 411 Design and Analysis of Algorithms Set 12: Undecidability Prof. Jennifer Welch Fall 2008.
ECE Synthesis & Verification1 ECE 667 Spring 2011 Synthesis and Verification of Digital Systems Verification Introduction.
Recursion.
Analysis of Algorithms CS 477/677
1 Advanced Material The following slides contain advanced material and are optional.
Describing Syntax and Semantics
EE694v-Verification-Lect5-1- Lecture 5 - Verification Tools Automation improves the efficiency and reliability of the verification process Some tools,
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
School of Computer ScienceG53FSP Formal Specification1 Dr. Rong Qu Introduction to Formal Specification
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Code Generation CS 480. Can be complex To do a good job of teaching about code generation I could easily spend ten weeks But, don’t have ten weeks, so.
Introduction to Software Testing
Writing algorithms using the while-statement. Previously discussed Syntax of while-statement:
Fruitful functions. Return values The built-in functions we have used, such as abs, pow, int, max, and range, have produced results. Calling each of these.
Remaining Topics Decidability Concept 4.1 The Halting Problem 4.2
Algorithms Describing what you know. Contents What are they and were do we find them? Why show the algorithm? What formalisms are used for presenting.
Balancing Practices: Inspections, Testing, and Others JAXA scenario (formal method) Masa Katahira Japanese Space Agency.
Erlang/QuickCheck Thomas Arts, IT University John Hughes, Chalmers University Gothenburg.
Software Engineering DKT 311 Lecture 11 Verification and critical system validation.
Speaking Bluntly about SharpHDL: Some Old Stuff and Some Other Proposed Future Extensions Gordon J. Pace & Christine Vella Synchron’05 Malta, November.
Chapter 5: Control Structures II (Repetition)
Mathematical Modeling and Formal Specification Languages CIS 376 Bruce R. Maxim UM-Dearborn.
CSE 219 Computer Science III Testing. Testing vs. Debugging Testing: Create and use scenarios which reveal incorrect behaviors –Design of test cases:
CSC-682 Cryptography & Computer Security Sound and Precise Analysis of Web Applications for Injection Vulnerabilities Pompi Rotaru Based on an article.
Testing in Erlang. Different testing tools EUnit (standard lightweight xUnit solution for Erlang) Common Test (OTP based distributed testing tool) Qucik.
B. Fernández, D. Darvas, E. Blanco Formal methods appliedto PLC code verification Automation seminar CERN – IFAC (CEA) 02/06/2014.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
CS 363 Comparative Programming Languages Semantics.
Introduction to Problem Solving. Steps in Programming A Very Simplified Picture –Problem Definition & Analysis – High Level Strategy for a solution –Arriving.
Data Structures R e c u r s i o n. Recursive Thinking Recursion is a problem-solving approach that can be used to generate simple solutions to certain.
What is Testing? Testing is the process of finding errors in the system implementation. –The intent of testing is to find problems with the system.
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
Chapter 3 Part II Describing Syntax and Semantics.
Semantics In Text: Chapter 3.
COP4020 Programming Languages Introduction to Axiomatic Semantics Prof. Robert van Engelen.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Verification & Validation By: Amir Masoud Gharehbaghi
Function Definition by Cases and Recursion Lecture 2, Programmeringsteknik del A.
CSCI1600: Embedded and Real Time Software Lecture 33: Worst Case Execution Time Steven Reiss, Fall 2015.
New Random Test Strategies for Automated Discovery of Faults & Fault Domains Mian Asbat Ahmad
Properties Incompleteness Evaluation by Functional Verification IEEE TRANSACTIONS ON COMPUTERS, VOL. 56, NO. 4, APRIL
Automated Formal Verification of PLC (Programmable Logic Controller) Programs
FORMAL METHOD. Formal Method Formal methods are system design techniques that use rigorously specified mathematical models to build software and hardware.
Pseudo-random generators Talk for Amnon ’ s seminar.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
CS 5150 Software Engineering Lecture 22 Reliability 3.
서울대한양대 ( 안 산 ) 충남대 1년1년 컴퓨터기초 (C) 컴퓨터프로그래밍 (C, Java) 컴퓨터프로그래밍 (C) 2. 봄 프로그래밍 원리 (Scheme, ML) Structure & Interpretation of Computer Programs 프로그래밍 방법론.
Debugging and Testing Hussein Suleman March 2007 UCT Department of Computer Science Computer Science 1015F.
Functional Programming
Types for Programs and Proofs
Semantics In Text: Chapter 3.
Combining Compile-Time and Run-Time Components
Normal Forms for Context-free Grammars
Presentation transcript:

QuickCheck: A Lightweight Tool for Random Testing of Haskell Programs By Koen Claessen, Juhn Hughes ME: Mike Izbicki

Mike Izbicki / QuickCheck2 About Haskell Purely functional language Same function, same inputs -> same outputs  Functions can have no side effects Variables cannot vary Lazy evaluation -> infinite data structures Popular uses Language research High frequency trading  handles billions of dollars, so programs must be correct

Mike Izbicki / QuickCheck3 Testing in Haskell Many tests are not applicable or require significant reinterpretation Ex: What would control flow mean? Possible solutions: Small, obviously correct code Strong static typing Proofs of correctness Functional testing

Mike Izbicki / QuickCheck4 QuickCheck's goals Every function has invariants These are the specification Combine specification directly into source code  Formal method that is very expressive  Easily learned  Programmer MUST pay attention Automatically create tests from the specification

Mike Izbicki / QuickCheck5 Specification example: primes Prime sieves generate prime numbers Sieve of EratosthenesO ( N ) Sieve of AtkinO ( N / (log log N) ) Wheel sievesO ( N / (log log N) ) Difficult computations to understand, but there is a trivial verification algorithm That is our invariant It is much slower, but we only test it on some inputs

Mike Izbicki / QuickCheck6 Unconditional invariants Always easy to compute Ex: Code:

Mike Izbicki / QuickCheck7 Conditional invariants Sometimes easy to compute Ex: Sometimes hard to compute Ex:

Mike Izbicki / QuickCheck8 Generating the tests Testing simple data types, like ints, is easy Testing complex data types is hard What does a random list mean?  Size / contents / member data types Context free grammars?  Has been used before, but not powerful enough Attribute grammars?  Can define any distribution over any data type  By embedding in Haskell, we get this for free

Mike Izbicki / QuickCheck9 Special cases QuickCheck can create random, infinitely large data types Must be very careful to avoid infinite loops QuickCheck can create randomly generated functions Many functions in Haskell take other functions as arguments  Ex: map :: (a -> b) -> [a] -> [b]

Mike Izbicki / QuickCheck10 Test Adequacy By simply using enough random tests, we can make our test suite arbitrarily adequate for any coverage criteria

Mike Izbicki / QuickCheck11 Case studies Unification problem Theorem proving Edison, a data structure library Lava, a tool to simulate and formally verify hardware

Mike Izbicki / QuickCheck12 Results: Edison Every data structure, and every function was tested Maintainer of the Edison library reports: Testing requires 25% of the effort without QuickCheck QuickCheck still found more errors QuickCheck not only finds errors in the code, but also errors in the specification  Approximately a 50 / 50 split

Mike Izbicki / QuickCheck13 Results: Lava Previously proven correct QuickCheck did not find any errors QuickCheck was useful for speeding up the program Lava is an embedded language in Haskell  QuickCheck also works on Lava Very slow process to verify circuits  Can “QuickCheck” a circuit to rapidly to find trivial bugs

Mike Izbicki / QuickCheck14 QuickCheck in summary Random testing works well in functional programming languages QuickCheck forces programmers to write specifications

Mike Izbicki / QuickCheck15 QuickCheck in summary Random testing works well in functional programming languages QuickCheck forces programmers to write specifications Questions?

Mike Izbicki / QuickCheck16