COMP4161: Advanced Topics in Software Verification. fun. Gerwin Klein, June Andronick, Ramana Kumar S2/2016. data61.csiro.au

Size: px
Start display at page:

Download "COMP4161: Advanced Topics in Software Verification. fun. Gerwin Klein, June Andronick, Ramana Kumar S2/2016. data61.csiro.au"

Transcription

1 COMP4161: Advanced Topics in Software Verification fun Gerwin Klein, June Andronick, Ramana Kumar S2/2016 data61.csiro.au

2 Content Intro & motivation, getting started [1] Foundations & Principles Lambda Calculus, natural deduction [1,2] Higher Order Logic [3 a ] Term rewriting [4] Proof & Specification Techniques Inductively defined sets, rule induction [5] Datatypes, recursion, induction [6, 7] Hoare logic, proofs about programs, C verification [8 b,9] (mid-semester break) Writing Automated Proof Methods [10] Isar, codegen, typeclasses, locales [11 c,12] a a1 due; b a2 due; c a3 due 2 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

3 General Recursion The Choice 3 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

4 General Recursion The Choice Limited expressiveness, automatic termination primrec 3 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

5 General Recursion The Choice Limited expressiveness, automatic termination primrec High expressiveness, termination proof may fail fun 3 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

6 General Recursion The Choice Limited expressiveness, automatic termination primrec High expressiveness, termination proof may fail fun High expressiveness, tweakable, termination proof manual function 3 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

7 fun examples fun sep :: a a list a list where sep a (x # y # zs) = x # a # sep a (y # zs) sep a xs = xs 4 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

8 fun examples fun sep :: a a list a list where sep a (x # y # zs) = x # a # sep a (y # zs) sep a xs = xs fun ack :: nat nat nat where ack 0 n = Suc n ack (Suc m) 0 = ack m 1 ack (Suc m) (Suc n) = ack m (ack (Suc m) n) 4 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

9 fun The definiton: pattern matching in all parameters arbitrary, linear constructor patterns reads equations sequentially like in Haskell (top to bottom) proves termination automatically in many cases (tries lexicographic order) 5 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

10 fun The definiton: pattern matching in all parameters arbitrary, linear constructor patterns reads equations sequentially like in Haskell (top to bottom) proves termination automatically in many cases (tries lexicographic order) Generates own induction principle 5 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

11 fun The definiton: pattern matching in all parameters arbitrary, linear constructor patterns reads equations sequentially like in Haskell (top to bottom) proves termination automatically in many cases (tries lexicographic order) Generates own induction principle May fail to prove termination: use function (sequential) instead allows you to prove termination manually 5 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

12 fun induction principle Each fun definition induces an induction principle 6 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

13 fun induction principle Each fun definition induces an induction principle For each equation: show P holds for lhs, provided P holds for each recursive call on rhs 6 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

14 fun induction principle Each fun definition induces an induction principle For each equation: show P holds for lhs, provided P holds for each recursive call on rhs Example sep.induct: [[ a. P a []; a w. P a [w] a x y zs. P a (y#zs) = P a (x#y#zs); ]] = P a xs 6 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

15 Termination Isabelle tries to prove termination automatically For most functions this works with a lexicographic termination relation. 7 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

16 Termination Isabelle tries to prove termination automatically For most functions this works with a lexicographic termination relation. Sometimes not 7 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

17 Termination Isabelle tries to prove termination automatically For most functions this works with a lexicographic termination relation. Sometimes not error message with unsolved subgoal 7 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

18 Termination Isabelle tries to prove termination automatically For most functions this works with a lexicographic termination relation. Sometimes not error message with unsolved subgoal You can prove automation separately. function (sequential) quicksort where quicksort [] = [] quicksort (x#xs) = quicksort [y xs.y x]@[x]@ quicksort [y xs.x < y] by pat completeness auto termination by (relation measure length ) (auto simp: less Suc eq le) 7 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

19 Termination Isabelle tries to prove termination automatically For most functions this works with a lexicographic termination relation. Sometimes not error message with unsolved subgoal You can prove automation separately. function (sequential) quicksort where quicksort [] = [] quicksort (x#xs) = quicksort [y xs.y x]@[x]@ quicksort [y xs.x < y] by pat completeness auto termination by (relation measure length ) (auto simp: less Suc eq le) function is the fully tweakable, manual version of fun 7 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

20 Demo

21 How does fun/function work? Recall primrec: defined one recursion operator per datatype D 9 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

22 How does fun/function work? Recall primrec: defined one recursion operator per datatype D inductive definition of its graph (x, f x) D rel 9 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

23 How does fun/function work? Recall primrec: defined one recursion operator per datatype D inductive definition of its graph (x, f x) D rel prove totality: x. y. (x, y) D rel 9 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

24 How does fun/function work? Recall primrec: defined one recursion operator per datatype D inductive definition of its graph (x, f x) D rel prove totality: x. y. (x, y) D rel prove uniqueness: (x, y) D rel (x, z) D rel y = z 9 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

25 How does fun/function work? Recall primrec: defined one recursion operator per datatype D inductive definition of its graph (x, f x) D rel prove totality: x. y. (x, y) D rel prove uniqueness: (x, y) D rel (x, z) D rel y = z recursion operator for datatype D rec, defined via THE. 9 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

26 How does fun/function work? Recall primrec: defined one recursion operator per datatype D inductive definition of its graph (x, f x) D rel prove totality: x. y. (x, y) D rel prove uniqueness: (x, y) D rel (x, z) D rel y = z recursion operator for datatype D rec, defined via THE. primrec: apply datatype recursion operator 9 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

27 How does fun/function work? Similar strategy for fun: a new inductive definition for each fun f 10 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

28 How does fun/function work? Similar strategy for fun: a new inductive definition for each fun f extract recursion scheme for equations in f define graph f rel inductively, encoding recursion scheme 10 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

29 How does fun/function work? Similar strategy for fun: a new inductive definition for each fun f extract recursion scheme for equations in f define graph f rel inductively, encoding recursion scheme prove totality (= termination) prove uniqueness (automatic) 10 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

30 How does fun/function work? Similar strategy for fun: a new inductive definition for each fun f extract recursion scheme for equations in f define graph f rel inductively, encoding recursion scheme prove totality (= termination) prove uniqueness (automatic) derive original equations from f rel export induction scheme from f rel 10 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

31 How does fun/function work? Can separate and defer termination proof: skip proof of totality 11 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

32 How does fun/function work? Can separate and defer termination proof: skip proof of totality instead derive equations of the form: x f dom f x =... similarly, conditional induction principle 11 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

33 How does fun/function work? Can separate and defer termination proof: skip proof of totality instead derive equations of the form: x f dom f x =... similarly, conditional induction principle f dom = acc f rel acc = accessible part of f rel the part that can be reached in finitely many steps 11 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

34 How does fun/function work? Can separate and defer termination proof: skip proof of totality instead derive equations of the form: x f dom f x =... similarly, conditional induction principle f dom = acc f rel acc = accessible part of f rel the part that can be reached in finitely many steps termination = x. x f dom still have conditional equations for partial functions 11 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

35 Proving Termination Command termination fun name sets up termination goal x. x fun name dom Three main proof methods: 12 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

36 Proving Termination Command termination fun name sets up termination goal x. x fun name dom Three main proof methods: lexicographic order (default tried by fun) 12 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

37 Proving Termination Command termination fun name sets up termination goal x. x fun name dom Three main proof methods: lexicographic order (default tried by fun) size change (different automated technique) 12 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

38 Proving Termination Command termination fun name sets up termination goal x. x fun name dom Three main proof methods: lexicographic order (default tried by fun) size change (different automated technique) relation R (manual proof via well-founded relation) 12 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

39 Well Founded Orders Definition < r is well founded if well founded induction holds wf r P. ( x. ( y < r x.p y) P x) ( x. P x) 13 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

40 Well Founded Orders Definition < r is well founded if well founded induction holds wf r P. ( x. ( y < r x.p y) P x) ( x. P x) Well founded induction rule: wf r x. ( y <r x. P y) = P x P a 13 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

41 Well Founded Orders Definition < r is well founded if well founded induction holds wf r P. ( x. ( y < r x.p y) P x) ( x. P x) Well founded induction rule: wf r x. ( y <r x. P y) = P x P a Alternative definition (equivalent): there are no infinite descending chains, or (equivalent): every nonempty set has a minimal element wrt < r min r Q x y Q. y r x wf r = ( Q {}. m Q. min r Q m) 13 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

42 Well Founded Orders: Examples < on IN is well founded well founded induction = complete induction 14 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

43 Well Founded Orders: Examples < on IN is well founded well founded induction = complete induction > and on IN are not well founded 14 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

44 Well Founded Orders: Examples < on IN is well founded well founded induction = complete induction > and on IN are not well founded x < r y = x dvd y x 1 on IN is well founded the minimal elements are the prime numbers 14 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

45 Well Founded Orders: Examples < on IN is well founded well founded induction = complete induction > and on IN are not well founded x < r y = x dvd y x 1 on IN is well founded the minimal elements are the prime numbers (a, b) < r (x, y) = a < 1 x a = x b < 2 y is well founded if < 1 and < 2 are 14 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

46 Well Founded Orders: Examples < on IN is well founded well founded induction = complete induction > and on IN are not well founded x < r y = x dvd y x 1 on IN is well founded the minimal elements are the prime numbers (a, b) < r (x, y) = a < 1 x a = x b < 2 y is well founded if < 1 and < 2 are A < r B = A B finite B is well founded 14 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

47 Well Founded Orders: Examples < on IN is well founded well founded induction = complete induction > and on IN are not well founded x < r y = x dvd y x 1 on IN is well founded the minimal elements are the prime numbers (a, b) < r (x, y) = a < 1 x a = x b < 2 y is well founded if < 1 and < 2 are A < r B = A B finite B is well founded and in general are not well founded More about well founded relations: Term Rewriting and All That 14 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

48 Extracting the Recursion Scheme So far for termination. What about the recursion scheme? 15 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

49 Extracting the Recursion Scheme Examples: So far for termination. What about the recursion scheme? Not fixed anymore as in primrec. fun fib where fib 0 = 1 fib (Suc 0) = 1 fib (Suc (Suc n)) = fib n + fib (Suc n) 15 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

50 Extracting the Recursion Scheme Examples: So far for termination. What about the recursion scheme? Not fixed anymore as in primrec. fun fib where fib 0 = 1 fib (Suc 0) = 1 fib (Suc (Suc n)) = fib n + fib (Suc n) Recursion: Suc (Suc n) n, Suc (Suc n) Suc n 15 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

51 Extracting the Recursion Scheme Examples: So far for termination. What about the recursion scheme? Not fixed anymore as in primrec. fun fib where fib 0 = 1 fib (Suc 0) = 1 fib (Suc (Suc n)) = fib n + fib (Suc n) Recursion: Suc (Suc n) n, Suc (Suc n) Suc n fun f where f x = (if x = 0 then 0 else f (x - 1) * 2) 15 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

52 Extracting the Recursion Scheme Examples: So far for termination. What about the recursion scheme? Not fixed anymore as in primrec. fun fib where fib 0 = 1 fib (Suc 0) = 1 fib (Suc (Suc n)) = fib n + fib (Suc n) Recursion: Suc (Suc n) n, Suc (Suc n) Suc n fun f where f x = (if x = 0 then 0 else f (x - 1) * 2) Recursion: x 0 = x x COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

53 Extracting the Recursion Scheme Higher Oder: datatype a tree = Leaf a Branch a tree list fun treemap :: ( a a) a tree a tree where treemap fn (Leaf n) = Leaf (fn n) treemap fn (Branch l) = Branch (map (treemap fn) l) 16 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

54 Extracting the Recursion Scheme Higher Oder: datatype a tree = Leaf a Branch a tree list fun treemap :: ( a a) a tree a tree where treemap fn (Leaf n) = Leaf (fn n) treemap fn (Branch l) = Branch (map (treemap fn) l) Recursion: x set l = (fn, Branch l) (fn, x) 16 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

55 Extracting the Recursion Scheme Higher Oder: datatype a tree = Leaf a Branch a tree list fun treemap :: ( a a) a tree a tree where treemap fn (Leaf n) = Leaf (fn n) treemap fn (Branch l) = Branch (map (treemap fn) l) Recursion: x set l = (fn, Branch l) (fn, x) How to extract the context information for the call? 16 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

56 Extracting the Recursion Scheme Extracting context for equations 17 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

57 Extracting the Recursion Scheme Extracting context for equations Congruence Rules! 17 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

58 Extracting the Recursion Scheme Recall rule if cong: Extracting context for equations Congruence Rules! [ b = c; c = x = u; c = y = v ] = (if b then x else y) = (if c then u else v) 17 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

59 Extracting the Recursion Scheme Recall rule if cong: Extracting context for equations Congruence Rules! [ b = c; c = x = u; c = y = v ] = (if b then x else y) = (if c then u else v) Read: for transforming x, use b as context information, for y use b. 17 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

60 Extracting the Recursion Scheme Recall rule if cong: Extracting context for equations Congruence Rules! [ b = c; c = x = u; c = y = v ] = (if b then x else y) = (if c then u else v) Read: for transforming x, use b as context information, for y use b. In fun def: for recursion in x, use b as context, for y use b. 17 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

61 Congruence Rules for fun defs The same works for function definitions. declare my rule[fundef cong] 18 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

62 Congruence Rules for fun defs The same works for function definitions. declare my rule[fundef cong] (if cong already added by default) Another example (higher-order): [ xs = ys; x. x set ys = f x = g x ] = map f xs = map g ys 18 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

63 Congruence Rules for fun defs The same works for function definitions. declare my rule[fundef cong] (if cong already added by default) Another example (higher-order): [ xs = ys; x. x set ys = f x = g x ] = map f xs = map g ys Read: for recursive calls in f, f is called with elements of xs 18 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

64 Demo

65 Further Reading Alexander Krauss, Automating Recursive Definitions and Termination Proofs in Higher-Order Log PhD thesis, TU Munich, COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

66 We have seen today... General recursion with fun/function 21 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

67 We have seen today... General recursion with fun/function Induction over recursive functions 21 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

68 We have seen today... General recursion with fun/function Induction over recursive functions How fun works 21 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

69 We have seen today... General recursion with fun/function Induction over recursive functions How fun works Termination, partial functions, congruence rules 21 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution License

Theorem Proving Principles, Techniques, Applications Recursion

Theorem Proving Principles, Techniques, Applications Recursion NICTA Advanced Course Theorem Proving Principles, Techniques, Applications Recursion 1 CONTENT Intro & motivation, getting started with Isabelle Foundations & Principles Lambda Calculus Higher Order Logic,

More information

Isabelle s meta-logic. p.1

Isabelle s meta-logic. p.1 Isabelle s meta-logic p.1 Basic constructs Implication = (==>) For separating premises and conclusion of theorems p.2 Basic constructs Implication = (==>) For separating premises and conclusion of theorems

More information

type classes & locales

type classes & locales Content Rough timeline Intro & motivation, getting started [1] COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Gerwin Klein, June Andronick, Toby Murray type classes & locales

More information

COMP 4161 NICTA Advanced Course. Advanced Topics in Software Verification. Toby Murray, June Andronick, Gerwin Klein

COMP 4161 NICTA Advanced Course. Advanced Topics in Software Verification. Toby Murray, June Andronick, Gerwin Klein COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Toby Murray, June Andronick, Gerwin Klein λ 1 Last time... λ calculus syntax free variables, substitution β reduction α and η conversion

More information

λ calculus is inconsistent

λ calculus is inconsistent Content Rough timeline COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Gerwin Klein, June Andronick, Toby Murray λ Intro & motivation, getting started [1] Foundations & Principles

More information

A CRASH COURSE IN SEMANTICS

A CRASH COURSE IN SEMANTICS LAST TIME Recdef More induction NICTA Advanced Course Well founded orders Slide 1 Theorem Proving Principles, Techniques, Applications Slide 3 Well founded recursion Calculations: also/finally {P}... {Q}

More information

COMP 4161 Data61 Advanced Course. Advanced Topics in Software Verification. Gerwin Klein, June Andronick, Christine Rizkallah, Miki Tanaka

COMP 4161 Data61 Advanced Course. Advanced Topics in Software Verification. Gerwin Klein, June Andronick, Christine Rizkallah, Miki Tanaka COMP 4161 Data61 Advanced Course Advanced Topics in Software Verification Gerwin Klein, June Andronick, Christine Rizkallah, Miki Tanaka 1 COMP4161 c Data61, CSIRO: provided under Creative Commons Attribution

More information

Efficient Mergesort. Christian Sternagel. October 11, 2017

Efficient Mergesort. Christian Sternagel. October 11, 2017 Efficient Mergesort Christian Sternagel October 11, 2017 Abstract We provide a formalization of the mergesort algorithm as used in GHC s Data.List module, proving correctness and stability. Furthermore,

More information

10 Years of Partiality and General Recursion in Type Theory

10 Years of Partiality and General Recursion in Type Theory 10 Years of Partiality and General Recursion in Type Theory Ana Bove Chalmers University of Technology DTP 10 July 9th 2010 Claims and Disclaims I know that I know nothing Socrates Ana Bove DTP 10 July

More information

Overview. A Compact Introduction to Isabelle/HOL. Tobias Nipkow. System Architecture. Overview of Isabelle/HOL

Overview. A Compact Introduction to Isabelle/HOL. Tobias Nipkow. System Architecture. Overview of Isabelle/HOL Overview A Compact Introduction to Isabelle/HOL Tobias Nipkow TU München 1. Introduction 2. Datatypes 3. Logic 4. Sets p.1 p.2 System Architecture Overview of Isabelle/HOL ProofGeneral Isabelle/HOL Isabelle

More information

Functional Programming with Isabelle/HOL

Functional Programming with Isabelle/HOL Functional Programming with Isabelle/HOL = Isabelle λ β HOL α Florian Haftmann Technische Universität München January 2009 Overview Viewing Isabelle/HOL as a functional programming language: 1. Isabelle/HOL

More information

Efficient Mergesort. Christian Sternagel. August 28, 2014

Efficient Mergesort. Christian Sternagel. August 28, 2014 Efficient Mergesort Christian Sternagel August 28, 2014 Abstract We provide a formalization of the mergesort algorithm as used in GHC s Data.List module, proving correctness and stability. Furthermore,

More information

Functional Programming and Modeling

Functional Programming and Modeling Chapter 2 2. Functional Programming and Modeling 2.0 2. Functional Programming and Modeling 2.0 Overview of Chapter Functional Programming and Modeling 2. Functional Programming and Modeling 2.1 Overview

More information

Programming and Proving in

Programming and Proving in Programming and Proving in = λ β Isabelle HOL α Tobias Nipkow Fakultät für Informatik Technische Universität München 1 Notation Implication associates to the right: A = B = C means A = (B = C) Similarly

More information

HOL DEFINING HIGHER ORDER LOGIC LAST TIME ON HOL CONTENT. Slide 3. Slide 1. Slide 4. Slide 2 WHAT IS HIGHER ORDER LOGIC? 2 LAST TIME ON HOL 1

HOL DEFINING HIGHER ORDER LOGIC LAST TIME ON HOL CONTENT. Slide 3. Slide 1. Slide 4. Slide 2 WHAT IS HIGHER ORDER LOGIC? 2 LAST TIME ON HOL 1 LAST TIME ON HOL Proof rules for propositional and predicate logic Safe and unsafe rules NICTA Advanced Course Forward Proof Slide 1 Theorem Proving Principles, Techniques, Applications Slide 3 The Epsilon

More information

locales ISAR IS BASED ON CONTEXTS CONTENT Slide 3 Slide 1 proof - fix x assume Ass: A. x and Ass are visible Slide 2 Slide 4 inside this context

locales ISAR IS BASED ON CONTEXTS CONTENT Slide 3 Slide 1 proof - fix x assume Ass: A. x and Ass are visible Slide 2 Slide 4 inside this context LAST TIME Syntax and semantics of IMP Hoare logic rules NICTA Advanced Course Soundness of Hoare logic Slide 1 Theorem Proving Principles, Techniques, Applications Slide 3 Verification conditions Example

More information

Reasoning about programs. Chapter 9 of Thompson

Reasoning about programs. Chapter 9 of Thompson Reasoning about programs Chapter 9 of Thompson Proof versus testing A proof will state some property of a program that holds for all inputs. Testing shows only that a property holds for a particular set

More information

Functional Logic Programming: From Theory to Curry

Functional Logic Programming: From Theory to Curry Functional Logic Programming: From Theory to Curry Michael Hanus Institut für Informatik, CAU Kiel, D-24098 Kiel, Germany. mh@informatik.uni-kiel.de Abstract. Functional logic programming languages combine

More information

Programming with Universes, Generically

Programming with Universes, Generically Programming with Universes, Generically Andres Löh Well-Typed LLP 24 January 2012 An introduction to Agda Agda Functional programming language Static types Dependent types Pure (explicit effects) Total

More information

Programming Languages 3. Definition and Proof by Induction

Programming Languages 3. Definition and Proof by Induction Programming Languages 3. Definition and Proof by Induction Shin-Cheng Mu Oct. 22, 2015 Total Functional Programming The next few lectures concerns inductive definitions and proofs of datatypes and programs.

More information

Defining Recursive Functions in Isabelle/HOL

Defining Recursive Functions in Isabelle/HOL Defining Recursive Functions in Isabelle/HOL Alexander Krauss Abstract This tutorial describes the use of the function package, which provides general recursive function definitions for Isabelle/HOL. We

More information

Programming and Proving in Isabelle/HOL

Programming and Proving in Isabelle/HOL Programming and Proving in Isabelle/HOL Tobias Nipkow Fakultät für Informatik Technische Universität München 2013 MOD Summer School 1 Notation Implication associates to the right: A = B = C means A = (B

More information

The Worker/Wrapper Transformation

The Worker/Wrapper Transformation The Worker/Wrapper Transformation Andy Gill 1 Graham Hutton 2 1 The University of Kansas 2 The University of Nottingham March 26th, 2009 Andy Gill, Graham Hutton The Worker/Wrapper Transformation March

More information

Typed Scheme: Scheme with Static Types

Typed Scheme: Scheme with Static Types Typed Scheme: Scheme with Static Types Version 4.1.1 Sam Tobin-Hochstadt October 5, 2008 Typed Scheme is a Scheme-like language, with a type system that supports common Scheme programming idioms. Explicit

More information

Programming with (co-)inductive types in Coq

Programming with (co-)inductive types in Coq Programming with (co-)inductive types in Coq Matthieu Sozeau February 3rd 2014 Programming with (co-)inductive types in Coq Matthieu Sozeau February 3rd 2014 Last time 1. Record Types 2. Mathematical Structures

More information

Organisatorials. About us. Binary Search (java.util.arrays) When Tue 9:00 10:30 Thu 9:00 10:30. COMP 4161 NICTA Advanced Course

Organisatorials. About us. Binary Search (java.util.arrays) When Tue 9:00 10:30 Thu 9:00 10:30. COMP 4161 NICTA Advanced Course Organisatorials COMP 4161 NICTA Advanced Course When Tue 9:00 10:30 Thu 9:00 10:30 Where Tue: Law 163 (F8-163) Thu: Australian School Business 205 (E12-205) Advanced Topics in Software Verification Rafal

More information

Concrete Semantics. A Proof Assistant Approach. Tobias Nipkow Fakultät für Informatik Technische Universität München

Concrete Semantics. A Proof Assistant Approach. Tobias Nipkow Fakultät für Informatik Technische Universität München Concrete Semantics A Proof Assistant Approach Tobias Nipkow Fakultät für Informatik Technische Universität München 2014-1-26 1 Part I Isabelle 2 Chapter 2 Programming and Proving 3 1 Overview of Isabelle/HOL

More information

Exercise 1 ( = 24 points)

Exercise 1 ( = 24 points) 1 Exercise 1 (4 + 5 + 4 + 6 + 5 = 24 points) The following data structure represents polymorphic binary trees that contain values only in special Value nodes that have a single successor: data Tree a =

More information

Functional Programming. Overview. Topics. Recall λ-terms. Examples

Functional Programming. Overview. Topics. Recall λ-terms. Examples Topics Functional Programming Christian Sternagel Harald Zankl Evgeny Zuenko Department of Computer Science University of Innsbruck WS 2017/2018 abstract data types, algebraic data types, binary search

More information

An Introduction to Isabelle/HOL 2008

An Introduction to Isabelle/HOL 2008 An Introduction to Isabelle/HOL 2008 Tobias Nipkow TU München p.1 Overview of Isabelle/HOL p.2 System Architecture ProofGeneral Isabelle/HOL Isabelle Standard ML (X)Emacs based interface Isabelle instance

More information

The Worker/Wrapper Transformation

The Worker/Wrapper Transformation The Worker/Wrapper Transformation Andy Gill 1 Graham Hutton 2 1 Galois, Inc. 2 University of Nottingham February 6, 2008 Andy Gill, Graham Hutton The Worker/Wrapper Transformation February 6, 2008 1 /

More information

Induction in Coq. Nate Foster Spring 2018

Induction in Coq. Nate Foster Spring 2018 Induction in Coq Nate Foster Spring 2018 Review Previously in 3110: Functional programming in Coq Logic in Coq Curry-Howard correspondence (proofs are programs) Today: Induction in Coq REVIEW: INDUCTION

More information

Week 5 Tutorial Structural Induction

Week 5 Tutorial Structural Induction Department of Computer Science, Australian National University COMP2600 / COMP6260 Formal Methods in Software Engineering Semester 2, 2016 Week 5 Tutorial Structural Induction You should hand in attempts

More information

Overview. A normal-order language. Strictness. Recursion. Infinite data structures. Direct denotational semantics. Transition semantics

Overview. A normal-order language. Strictness. Recursion. Infinite data structures. Direct denotational semantics. Transition semantics Overview A normal-order language Strictness Recursion Infinite data structures Direct denotational semantics Transition semantics Lazy (call-by-need) evaluation and its semantics A Normal-Order Language

More information

Functional Programming. Overview. Topics. Definition n-th Fibonacci Number. Graph

Functional Programming. Overview. Topics. Definition n-th Fibonacci Number. Graph Topics Functional Programming Christian Sternagel Harald Zankl Evgeny Zuenko Department of Computer Science University of Innsbruck WS 2017/2018 abstract data types, algebraic data types, binary search

More information

Recursion. Tjark Weber. Functional Programming 1. Based on notes by Sven-Olof Nyström. Tjark Weber (UU) Recursion 1 / 37

Recursion. Tjark Weber. Functional Programming 1. Based on notes by Sven-Olof Nyström. Tjark Weber (UU) Recursion 1 / 37 Tjark Weber Functional Programming 1 Based on notes by Sven-Olof Nyström Tjark Weber (UU) Recursion 1 / 37 Background FP I / Advanced FP FP I / Advanced FP This course (Functional Programming I) (5 hp,

More information

Induction and Semantics in Dafny

Induction and Semantics in Dafny 15-414 Lecture 11 1 Instructor: Matt Fredrikson Induction and Semantics in Dafny TA: Ryan Wagner Encoding the syntax of Imp Recall the abstract syntax of Imp: a AExp ::= n Z x Var a 1 + a 2 b BExp ::=

More information

COMPUTER SCIENCE TRIPOS

COMPUTER SCIENCE TRIPOS CST.0.. COMPUTER SCIENCE TRIPOS Part IA NATURAL SCIENCES TRIPOS Part IA (Paper CS/) POLITICS, PSYCHOLOGY, AND SOCIOLOGY TRIPOS Part I (Paper 9) Monday June 0.0 to 4.0 COMPUTER SCIENCE Paper Answer five

More information

Basic Foundations of Isabelle/HOL

Basic Foundations of Isabelle/HOL Basic Foundations of Isabelle/HOL Peter Wullinger May 16th 2007 1 / 29 1 Introduction into Isabelle s HOL Why Type Theory Basic Type Syntax 2 More HOL Typed λ Calculus HOL Rules 3 Example proof 2 / 29

More information

Inductive datatypes in HOL. lessons learned in Formal-Logic Engineering

Inductive datatypes in HOL. lessons learned in Formal-Logic Engineering Inductive datatypes in HOL lessons learned in Formal-Logic Engineering Stefan Berghofer and Markus Wenzel Institut für Informatik TU München = Isabelle λ β HOL α 1 Introduction Applications of inductive

More information

Verification of Selection and Heap Sort Using Locales

Verification of Selection and Heap Sort Using Locales Verification of Selection and Heap Sort Using Locales Danijela Petrović September 19, 2015 Abstract Stepwise program refinement techniques can be used to simplify program verification. Programs are better

More information

Coq with Classes. Matthieu Sozeau. Journées PPS 2011 September 5th 2011 Trouville, France. Project Team πr 2 INRIA Paris

Coq with Classes. Matthieu Sozeau. Journées PPS 2011 September 5th 2011 Trouville, France. Project Team πr 2 INRIA Paris Coq with Classes Matthieu Sozeau Project Team πr 2 INRIA Paris Journées PPS 2011 September 5th 2011 Trouville, France This talk A quick overview of Coq Elaboration Type Classes Matthieu Sozeau - Coq with

More information

Shell CSCE 314 TAMU. Haskell Functions

Shell CSCE 314 TAMU. Haskell Functions 1 CSCE 314: Programming Languages Dr. Dylan Shell Haskell Functions 2 Outline Defining Functions List Comprehensions Recursion 3 Conditional Expressions As in most programming languages, functions can

More information

Infinite Objects and Proofs 1

Infinite Objects and Proofs 1 Infinite Objects and Proofs 1 Pierre Castéran Beijing, August 2009 1 This lecture corresponds to the chapter 13 : Infinite Objects and Proofs of the book. In this lecture, we shall see how to represent

More information

2 Programming and Proving

2 Programming and Proving 2 Programming and Proving This chapter introduces HOL as a functional programming language and shows how to prove properties of functional programs by induction. 2.1 Basics 2.1.1 Types, Terms and Formulas

More information

Haske k ll An introduction to Functional functional programming using Haskell Purely Lazy Example: QuickSort in Java Example: QuickSort in Haskell

Haske k ll An introduction to Functional functional programming using Haskell Purely Lazy Example: QuickSort in Java Example: QuickSort in Haskell Haskell An introduction to functional programming using Haskell Anders Møller amoeller@cs.au.dk The most popular purely functional, lazy programming language Functional programming language : a program

More information

Fall 2018 Lecture N

Fall 2018 Lecture N 15-150 Fall 2018 Lecture N Tuesday, 20 November I m too lazy to figure out the correct number Stephen Brookes midterm2 Mean: 79.5 Std Dev: 18.4 Median: 84 today or, we could procrastinate lazy functional

More information

CS 4110 Programming Languages & Logics. Lecture 28 Recursive Types

CS 4110 Programming Languages & Logics. Lecture 28 Recursive Types CS 4110 Programming Languages & Logics Lecture 28 Recursive Types 7 November 2014 Announcements 2 Foster office hours 11-12pm Guest lecture by Fran on Monday Recursive Types 3 Many languages support recursive

More information

Multi-paradigm Declarative Languages

Multi-paradigm Declarative Languages c Springer-Verlag In Proc. of the International Conference on Logic Programming, ICLP 2007. Springer LNCS 4670, pp. 45-75, 2007 Multi-paradigm Declarative Languages Michael Hanus Institut für Informatik,

More information

An introduction introduction to functional functional programming programming using usin Haskell

An introduction introduction to functional functional programming programming using usin Haskell An introduction to functional programming using Haskell Anders Møller amoeller@cs.au.dkau Haskell The most popular p purely functional, lazy programming g language Functional programming language : a program

More information

CS 320 Midterm Exam. Fall 2018

CS 320 Midterm Exam. Fall 2018 Name: BU ID: CS 320 Midterm Exam Fall 2018 Write here the number of the problem you are skipping: You must complete 5 of the 6 problems on this exam for full credit. Each problem is of equal weight. Please

More information

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27 CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter 2.1-2.7 p. 1/27 CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer

More information

Hoare Logic. COMP2600 Formal Methods for Software Engineering. Rajeev Goré

Hoare Logic. COMP2600 Formal Methods for Software Engineering. Rajeev Goré Hoare Logic COMP2600 Formal Methods for Software Engineering Rajeev Goré Australian National University Semester 2, 2016 (Slides courtesy of Ranald Clouston) COMP 2600 Hoare Logic 1 Australian Capital

More information

Declaring Numbers. Bernd Braßel, Frank Huch and Sebastian Fischer. Department of Computer Science, University of Kiel, Germany

Declaring Numbers. Bernd Braßel, Frank Huch and Sebastian Fischer. Department of Computer Science, University of Kiel, Germany Declaring Numbers Bernd Braßel, Frank Huch and Sebastian Fischer Department of Computer Science, University of Kiel, Germany WFLP 2007, Paris, France I m going to present joint work with my colleagues

More information

Typed Racket: Racket with Static Types

Typed Racket: Racket with Static Types Typed Racket: Racket with Static Types Version 5.0.2 Sam Tobin-Hochstadt November 6, 2010 Typed Racket is a family of languages, each of which enforce that programs written in the language obey a type

More information

Lecture 19: Functions, Types and Data Structures in Haskell

Lecture 19: Functions, Types and Data Structures in Haskell The University of North Carolina at Chapel Hill Spring 2002 Lecture 19: Functions, Types and Data Structures in Haskell Feb 25 1 Functions Functions are the most important kind of value in functional programming

More information

Exercise 1 ( = 18 points)

Exercise 1 ( = 18 points) 1 Exercise 1 (4 + 5 + 4 + 5 = 18 points) The following data structure represents polymorphic binary trees that contain values only in special Value nodes that have a single successor: data Tree a = Leaf

More information

Induction for Data Types

Induction for Data Types Induction for Data Types COMP1600 / COMP6260 Dirk Pattinson Australian National University Semester 2, 2017 Catch Up / Drop in Lab When Fridays, 15.00-17.00 Where N335, CSIT Building (bldg 108) Until the

More information

Lambda calculus. Wouter Swierstra and Alejandro Serrano. Advanced functional programming - Lecture 6

Lambda calculus. Wouter Swierstra and Alejandro Serrano. Advanced functional programming - Lecture 6 Lambda calculus Advanced functional programming - Lecture 6 Wouter Swierstra and Alejandro Serrano 1 Today Lambda calculus the foundation of functional programming What makes lambda calculus such a universal

More information

CS 4110 Programming Languages & Logics. Lecture 27 Recursive Types

CS 4110 Programming Languages & Logics. Lecture 27 Recursive Types CS 4110 Programming Languages & Logics Lecture 27 Recursive Types 4 November 2016 Announcements 2 My office hours are at the normal time today but canceled on Monday Guest lecture by Seung Hee Han on Monday

More information

CS 440: Programming Languages and Translators, Spring 2019 Mon

CS 440: Programming Languages and Translators, Spring 2019 Mon Haskell, Part 4 CS 440: Programming Languages and Translators, Spring 2019 Mon 2019-01-28 More Haskell Review definition by cases Chapter 6: Higher-order functions Revisit currying map, filter Unnamed

More information

Mathematics for Computer Scientists 2 (G52MC2)

Mathematics for Computer Scientists 2 (G52MC2) Mathematics for Computer Scientists 2 (G52MC2) L03 : More Coq, Classical Logic School of Computer Science University of Nottingham October 8, 2009 The cut rule Sometimes we want to prove a goal Q via an

More information

Proving Properties of Recursive Functions and Data Structures. CS 270 Math Foundations of CS Jeremy Johnson

Proving Properties of Recursive Functions and Data Structures. CS 270 Math Foundations of CS Jeremy Johnson Proving Properties of Recursive Functions and Data Structures CS 270 Math Foundations of CS Jeremy Johnson 1 Objective To implement and verify recursive functions for processing recursive data structures.

More information

Exercise 1 ( = 22 points)

Exercise 1 ( = 22 points) 1 Exercise 1 (4 + 3 + 4 + 5 + 6 = 22 points) The following data structure represents polymorphic lists that can contain values of two types in arbitrary order: data DuoList a b = C a (DuoList a b) D b

More information

Proving Properties on Programs From the Coq Tutorial at ITP 2015

Proving Properties on Programs From the Coq Tutorial at ITP 2015 Proving Properties on Programs From the Coq Tutorial at ITP 2015 Reynald Affeldt August 29, 2015 Hoare logic is a proof system to verify imperative programs. It consists of a language of Hoare triples

More information

Course year Typeclasses and their instances

Course year Typeclasses and their instances Course year 2016-2017 Typeclasses and their instances Doaitse Swierstra and Atze Dijkstra with extra s Utrecht University September 29, 2016 1. The basics 2 Overloading versus parametric polymorphism 1

More information

Theory Exploration on Infinite Structures. Master s thesis in Computer Science Algorithms, Languages, and Logic SÓLRÚN HALLA EINARSDÓTTIR

Theory Exploration on Infinite Structures. Master s thesis in Computer Science Algorithms, Languages, and Logic SÓLRÚN HALLA EINARSDÓTTIR Theory Exploration on Infinite Structures Master s thesis in Computer Science Algorithms, Languages, and Logic SÓLRÚN HALLA EINARSDÓTTIR Department of Computer Science and Engineering CHALMERS UNIVERSITY

More information

Verification of an LCF-Style First-Order Prover with Equality

Verification of an LCF-Style First-Order Prover with Equality Verification of an LCF-Style First-Order Prover with Equality Alexander Birch Jensen, Anders Schlichtkrull, and Jørgen Villadsen DTU Compute, Technical University of Denmark, 2800 Kongens Lyngby, Denmark

More information

Combining Static and Dynamic Contract Checking for Curry

Combining Static and Dynamic Contract Checking for Curry Michael Hanus (CAU Kiel) Combining Static and Dynamic Contract Checking for Curry LOPSTR 2017 1 Combining Static and Dynamic Contract Checking for Curry Michael Hanus University of Kiel Programming Languages

More information

Multi-paradigm Declarative Languages

Multi-paradigm Declarative Languages Michael Hanus (CAU Kiel) Multi-paradigm Declarative Languages ICLP 2007 1 Multi-paradigm Declarative Languages Michael Hanus Christian-Albrechts-University of Kiel Programming Languages and Compiler Construction

More information

The design of a programming language for provably correct programs: success and failure

The design of a programming language for provably correct programs: success and failure The design of a programming language for provably correct programs: success and failure Don Sannella Laboratory for Foundations of Computer Science School of Informatics, University of Edinburgh http://homepages.inf.ed.ac.uk/dts

More information

Processadors de Llenguatge II. Functional Paradigm. Pratt A.7 Robert Harper s SML tutorial (Sec II)

Processadors de Llenguatge II. Functional Paradigm. Pratt A.7 Robert Harper s SML tutorial (Sec II) Processadors de Llenguatge II Functional Paradigm Pratt A.7 Robert Harper s SML tutorial (Sec II) Rafael Ramirez Dep Tecnologia Universitat Pompeu Fabra Paradigm Shift Imperative Paradigm State Machine

More information

1. M,M sequential composition: try tactic M; if it succeeds try tactic M. sequential composition (, )

1. M,M sequential composition: try tactic M; if it succeeds try tactic M. sequential composition (, ) Dipl.-Inf. Achim D. Brucker Dr. Burkhart Wolff Computer-supported Modeling and Reasoning http://www.infsec.ethz.ch/ education/permanent/csmr/ (rev. 16802) Submission date: FOL with Equality: Equational

More information

Declarative Programming with Function Patterns

Declarative Programming with Function Patterns LOPSTR 2005 Declarative Programming with Function Patterns Michael Hanus Christian-Albrechts-Universität Kiel (joint work with Sergio Antoy, Portland State University) FUNCTIONAL LOGIC LANGUAGES Approach

More information

CSCE 314 TAMU Fall CSCE 314: Programming Languages Dr. Flemming Andersen. Haskell Functions

CSCE 314 TAMU Fall CSCE 314: Programming Languages Dr. Flemming Andersen. Haskell Functions 1 CSCE 314: Programming Languages Dr. Flemming Andersen Haskell Functions 2 Outline Defining Functions List Comprehensions Recursion 3 Conditional Expressions As in most programming languages, functions

More information

Isabelle Tutorial: System, HOL and Proofs

Isabelle Tutorial: System, HOL and Proofs Isabelle Tutorial: System, HOL and Proofs Burkhart Wolff Université Paris-Sud What we will talk about What we will talk about Isabelle with: Brief Revision Advanced Automated Proof Techniques Structured

More information

Foundations of Computation

Foundations of Computation The Australian National University Semester 2, 2018 Research School of Computer Science Tutorial 5 Dirk Pattinson Foundations of Computation The tutorial contains a number of exercises designed for the

More information

Advanced features of Functional Programming (Haskell)

Advanced features of Functional Programming (Haskell) Advanced features of Functional Programming (Haskell) Polymorphism and overloading January 10, 2017 Monomorphic and polymorphic types A (data) type specifies a set of values. Examples: Bool: the type of

More information

Isabelle/HOL:Selected Features and Recent Improvements

Isabelle/HOL:Selected Features and Recent Improvements /: Selected Features and Recent Improvements webertj@in.tum.de Security of Systems Group, Radboud University Nijmegen February 20, 2007 /:Selected Features and Recent Improvements 1 2 Logic User Interface

More information

Functional Programming and Haskell

Functional Programming and Haskell Functional Programming and Haskell Tim Dawborn University of Sydney, Australia School of Information Technologies Tim Dawborn Functional Programming and Haskell 1/22 What are Programming Paradigms? A programming

More information

PROGRAMMING IN HASKELL. CS Chapter 6 - Recursive Functions

PROGRAMMING IN HASKELL. CS Chapter 6 - Recursive Functions PROGRAMMING IN HASKELL CS-205 - Chapter 6 - Recursive Functions 0 Introduction As we have seen, many functions can naturally be defined in terms of other functions. factorial :: Int Int factorial n product

More information

QIR Specification. Romain Vernoux. January 6, Notations 2

QIR Specification. Romain Vernoux. January 6, Notations 2 QIR Specification Romain Vernoux January 6, 2017 Contents 1 Notations 2 2 Architecture 3 3 QIR data model, expressions and operators 4 3.1 QIR data model.................................... 4 3.2 QIR operators.....................................

More information

Foundations of Dataflow Analysis

Foundations of Dataflow Analysis Foundations of Dataflow Analysis 15-745 Optimizing Compilers Spring 2006 Peter Lee Ingredients of a dataflow analysis direction: forward or backward flow/transfer function combining ( meet ) operator dataflow

More information

Recursion. Lars-Henrik Eriksson. Functional Programming 1. Based on a presentation by Tjark Weber and notes by Sven-Olof Nyström

Recursion. Lars-Henrik Eriksson. Functional Programming 1. Based on a presentation by Tjark Weber and notes by Sven-Olof Nyström Lars-Henrik Eriksson Functional Programming 1 Based on a presentation by Tjark Weber and notes by Sven-Olof Nyström Tjark Weber (UU) Recursion 1 / 41 Comparison: Imperative/Functional Programming Comparison:

More information

Lambda Calculus and Type Inference

Lambda Calculus and Type Inference Lambda Calculus and Type Inference Björn Lisper Dept. of Computer Science and Engineering Mälardalen University bjorn.lisper@mdh.se http://www.idt.mdh.se/ blr/ October 13, 2004 Lambda Calculus and Type

More information

COMP 382: Reasoning about algorithms

COMP 382: Reasoning about algorithms Spring 2015 Unit 2: Models of computation What is an algorithm? So far... An inductively defined function Limitation Doesn t capture mutation of data Imperative models of computation Computation = sequence

More information

Getting Started with AutoCorres

Getting Started with AutoCorres Getting Started with AutoCorres Japheth Lim Rohan Jacob-Rao David Greenaway September 10, 2018 Contents 1 Introduction 2 2 A First Proof with AutoCorres 2 2.1 Two simple functions: min and max...............

More information

A heuristic method for formally verifying real inequalities

A heuristic method for formally verifying real inequalities A heuristic method for formally verifying real inequalities Robert Y. Lewis Vrije Universiteit Amsterdam June 22, 2018 Motivation Specific topic for today: verifying systems of nonlinear inequalities over

More information

Lecture 5: Lazy Evaluation and Infinite Data Structures

Lecture 5: Lazy Evaluation and Infinite Data Structures Lecture 5: Lazy Evaluation and Infinite Data Structures Søren Haagerup Department of Mathematics and Computer Science University of Southern Denmark, Odense October 3, 2017 How does Haskell evaluate a

More information

Formalization of First-Order Syntactic Unification

Formalization of First-Order Syntactic Unification Downloaded from orbit.dtu.dk on: Jan 04, 2019 Formalization of First-Order Syntactic Unification Brandt, Kasper Fabæch; Schlichtkrull, Anders; Villadsen, Jørgen Published in: 32nd International Workshop

More information

Higher Order Functions in Haskell

Higher Order Functions in Haskell Higher Order Functions in Haskell Evan Misshula 2018-09-10 Outline Curried Functions Curried comparison Example partial application partial application of a string function Returned functions ZipWith flip

More information

Lecture 4: Higher Order Functions

Lecture 4: Higher Order Functions Lecture 4: Higher Order Functions Søren Haagerup Department of Mathematics and Computer Science University of Southern Denmark, Odense September 26, 2017 HIGHER ORDER FUNCTIONS The order of a function

More information

Functional Programming in Haskell Part I : Basics

Functional Programming in Haskell Part I : Basics Functional Programming in Haskell Part I : Basics Madhavan Mukund Chennai Mathematical Institute 92 G N Chetty Rd, Chennai 600 017, India madhavan@cmi.ac.in http://www.cmi.ac.in/ madhavan Madras Christian

More information

The Prototype Verification System PVS

The Prototype Verification System PVS The Prototype Verification System PVS Wolfgang Schreiner Wolfgang.Schreiner@risc.uni-linz.ac.at Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria http://www.risc.uni-linz.ac.at

More information

Inference rule for Induction

Inference rule for Induction Inference rule for Induction Let P( ) be a predicate with domain the positive integers BASE CASE INDUCTIVE STEP INDUCTIVE Step: Usually a direct proof Assume P(x) for arbitrary x (Inductive Hypothesis),

More information

Exercise 1 (2+2+2 points)

Exercise 1 (2+2+2 points) 1 Exercise 1 (2+2+2 points) The following data structure represents binary trees only containing values in the inner nodes: data Tree a = Leaf Node (Tree a) a (Tree a) 1 Consider the tree t of integers

More information

Lecture 8: Summary of Haskell course + Type Level Programming

Lecture 8: Summary of Haskell course + Type Level Programming Lecture 8: Summary of Haskell course + Type Level Programming Søren Haagerup Department of Mathematics and Computer Science University of Southern Denmark, Odense October 31, 2017 Principles from Haskell

More information

A Verified Compiler from Isabelle/HOL to CakeML

A Verified Compiler from Isabelle/HOL to CakeML A Verified Compiler from Isabelle/HOL to CakeML Lars Hupel and Tobias Nipkow Technische Universität München lars.hupel@tum.de, nipkow@in.tum.de Abstract. Many theorem provers can generate functional programs

More information

Programs and Proofs in Isabelle/HOL

Programs and Proofs in Isabelle/HOL Programs and Proofs in Isabelle/HOL Makarius Wenzel http://sketis.net March 2016 = Isabelle λ β α Introduction What is Isabelle? Hanabusa Itcho : Blind monks examining an elephant Introduction 2 History:

More information

MLW. Henk Barendregt and Freek Wiedijk assisted by Andrew Polonsky. March 26, Radboud University Nijmegen

MLW. Henk Barendregt and Freek Wiedijk assisted by Andrew Polonsky. March 26, Radboud University Nijmegen 1 MLW Henk Barendregt and Freek Wiedijk assisted by Andrew Polonsky Radboud University Nijmegen March 26, 2012 inductive types 2 3 inductive types = types consisting of closed terms built from constructors

More information