Software testing consist of checking whether a given system meets some prior specification. Without knowing which specifications a system *should meet* it is impossible to test the system. An informal description of demands is not enough for this. The specification has to be (more or less) formal.

This is the reason why we start the course with a training in writing specifications in the language of predicate logic.

Actual code can be tested, given a formal specification, with the help of a **random test generator**. We will illustrate this test method for a number of example programs written in the functional programming language Haskell.

We assume you all have managed to install a working Haskell system on your laptop. The easiest way to get a working system is by downloading *Stack* or the *Haskell Platform* from here.

Stack is a tool for Haskell project development that offers a functional approach to package management in Haskell. See here.

Jan van Eijck (lectures, workshop sessions).

Kai Li (workshop sessions)

Malvin Gattinger (workshop sessions)

Ana Oprescu (homework assessment, computer lab supervision)

Bert Lisser (homework assessment, computer lab supervision)

Sept 7 -- Oct 26, 2016

For details of the schedule, consult datanose

The course consists of three components:

Lectures: every Wednesday, 9.00 - 10.45

Workshops using pen, paper, brains: every Wednesday, 11.00 -- 12.45.

Computer Lab (using your own laptop): Wednesdays after 13.00 and Thursday throughout the day.

**Note**: starting in the second week, each lecture will be preceded by a *lab feedback session* conducted by Ana (Ana's Corner). Make sure to be in time for this. The feedback sessions begin at 9.00 sharp.

Wednesday October 26, 9--13. Two kinds of questions:

Theory (questions as in the workshop sessions)

Lab (problems as in the lab sessions)

Grading: Let \(E\) is your grade for the exam, and let \(L\) be your lab grade. Your grade \(E\) should should be at least \(6\). If this is the case, your final grade is given by \(\frac{E + L}{2}\).

Make sure you acquire

**individual skills**, by spending time on the lab exercises on your own.

Learn how to understand and write specifications in the language of predicate logic.

Learn the basics of functional programming in Haskell.

Learn how to use type-specification and abstraction to make programs more easily testable.

Learn how to write formal specifications for testing Haskell code.

Learn how to use random test generation for automating the test process.

Learn how the functional programming paradigm relates to imperative programming.

We will treat the following, roughly in this order

Basics of functional programming, in relation to imperative programming

Using (predicate) logic as a specification language

Pre- and postconditions, invariants, and their relation to testing

Formal specification and random testing

Specification of algorithms with functional programming

Bryan O'Sullivan, John Goerzen, Don Stewart,

*Real World Haskell*.

Sign up on github and send an email to Ana (see above for the address) with your github name, so we can invite you to the github repository for the course.

Lecture: Informal Introduction to Haskell. Lecture notes week 1 Code for the lecture: Lecture1.hs.

Workshop 1: Induction and Recursion. Here is a version with answers.

Lab 1: Functional Programming and (Some) Logic. Code for lab: Lab1.hs. Lab Solutions with code.

Reading: Chapters 1 and 2 of The Haskell Road. There is an opportunity for asking questions at the beginning of the next lecture.

Lecture: Use of pre- and postconditions for testing. Lecture notes week 2 Code for the lecture: Lecture2.hs.

Workshop 2: reasoning with pre- and postconditions. Here is a version with answers. These slides of Kai Li give further explanation.

Lab 2: triangle recognition, permutations, derangements, ROT13 encoding, IBAN validation. Code: Lab2.hs. Lab Solutions with code.

Reading: Chapter 4 of The Haskell Road. There is an opportunity for asking questions at the beginning of the next lecture.

Lecture: More on Hoare Logic and Propositional Logic Lecture notes week 3 Code for the lecture: Lecture3.hs.

Workshop 3: The Logic of Boolean Conditions. These slides of Kai Li give further explanation.

Lab 3: Working with the logic of Boolean conditions. Code for the Lab. Lab Solutions with code.

Reading: Chapter 5 of The Haskell Road. There is an opportunity for asking questions at the beginning of the next lecture.

Lecture: Functional Programming and Imperative Programming Lecture notes week 4. Code for the lecture: Lecture4.hs.

Workshop 4: Working With Sets and Relations. Solutions are in Workshop4Answers.pdf.

Lab 4: Working With Sets and Relations. Code for the Lab. Lab Solutions with code.

Reading: Reread Chapters 4 and 5 of The Haskell Road. There is an opportunity for asking questions at the beginning of the next lecture.

Lecture: Constraint Solving with Sudokus. Lecture notes week 5. Code for the lecture: Lecture5.hs.

Workshop 5: Further Exercises with Induction. Solutions are in Workshop5Answers.pdf.

Lab 5: Solving Sudoku Puzzles. Code for the Lab. Lab Solutions with code.

Reading: Study Chapter 7 of The Haskell Road. There is an opportunity for asking questions at the beginning of the next lecture.

Lecture: Modular Arithmetic and Cryptography Lecture notes week 6. Code for the lecture: Lecture6.hs.

Workshop 6: Working with Trees. Answers. Code.

Lab 6: Modular Arithmetic and Cryptography. Code for the Lab. Lab Solutions with code.

Reading: left to you.

During Lecture time: Exam preparation ... Example Exam (Jan 2016).

Instead of Workshop 11-13: Plenary session in Room F2.04. We discussed the answers to the example exam, with code in ResitExamAnswers.hs.

Exam on Wednesday October 26, 9-13 am.

**Please note that the exam is not at Science Park but at Roeterseilandcomplex (REC), in room C1.03.**

The exam problems with worked solutions are here. And the code is in ExamOct2016Answers.hs.

Anonymised lab, exam and final results are here.