Focus rules for segments. Focus and defocus rules for concatenation. Mlength with a while loop. Mlength with a while loop.

Size: px
Start display at page:

Download "Focus rules for segments. Focus and defocus rules for concatenation. Mlength with a while loop. Mlength with a while loop."

Transcription

1 The function nth-cell Separation Logic Part 2 Returns the i-th cell of a list: Arthur Charguéraud February 2015 let rec nth_cell (i:int) (p: a cell) = if i = 0 then p else nth_cell (i-1) (p.tl) Why is the heap predicate p Mlist L not sufficient to specify nth_cell? 1 / 59 2 / 59 Representation predicate for list segments Specification of nth-cell Recall the definition of Mlist: p Mlist L match L with nil ñ rp nulls x :: L 1 ñ Dp 1. p ÞÑ t hd=x; tl=p 1 u p 1 Mlist L 1 Definition of MlistSeg: p MlistSeg q L match L with nil ñ rp qs x :: L 1 ñ Dp 1. p ÞÑ t hd=x; tl=p 1 u p 1 MlistSeg q L 1 Exercise: specify the function nth_cell using p MlistSeg q L tp Mlist L r0 ď i ă length Lsu pnth_cell i pq tλq. DL 1 L 2. p MlistSeg q L 1 q Mlist L 2 rl L 1``L 2 ^ length L 1 isu Lists as null-terminated list segments: p Mlist L p MlistSeg null L 3 / 59 4 / 59

2 Focus rules for segments Focus and defocus rules for concatenation p MlistSeg q px :: L 1 q Dp 1. p ÞÑ t hd=x; tl=p 1 u p 1 MlistSeg q L 1 p MlistSeg q pl 1``L 2 q Dp 1. p MlistSeg p 1 L 1 p 1 MlistSeg q L 2 p MlistSeg q nil rp qs 5 / 59 6 / 59 Mlength with a while loop Mlength with a while loop let rec mlength (p: a cell) = let f = ref p in let t = ref 0 in while!f!= null do incr t; f := (!f).tl; Exercise: 1. Specify the state before and after the loop. 2. Specify the loop invariant. 3. Prove the transitions. tp Mlist Lu pmlength pq tλn. rn length Ls p Mlist Lu Before the loop: After the loop: Loop invariant: DL 1 L 2 q. Entering the loop: pp Mlist Lq pf ãñ pq pt ãñ 0q pp Mlist Lq pf ãñ nullq pt ãñ length Lq pf ãñ qq pt ãñ length L 1 q rl L 1``L 2 s pp MlistSeg q L 1 q pq Mlist L 2 q L 1 nil ^ L 2 L ^ q p and r s Ź pp MlistSeg p nilq Exiting the loop: L 1 L ^ L 2 nil ^ q null and pp MlistSeg null Lq Ź pp Mlist Lq 7 / 59 8 / 59

3 Mutable queues implementation Mutable queues interface Queue interface: Represent a queue as a list segment, with the last cell storing no item. type a queue = { mutable front : a cell; mutable back : a cell; } Exercise: define the representation predicate p Queue L. create : unit -> a queue is_empty : a queue -> bool push : a -> a queue -> unit pop : a queue -> a transfer : a queue -> a queue -> unit Exercise: specify the functions on queues in terms of p Queue L. p Queue L Dfb. p ÞÑ t front=f; back=b u f MlistSeg b L Dyq. b ÞÑ t hd=y; tl=q u 9 / / 59 Mutable queues interface Summary tr su pcreate()q tλq. q Queue nilu tq Queue Lu pis_empty qq tλb. rb true ô L nils q Queue Lu tq Queue Lu ppush x qq tλtt. q Queue pl&xqu where L&x L``x :: nil. tq Queue px :: Lqu ppop qq tλr. rr xs q Queue Lu tq Queue L rl nilsu ppop qq tλx. DL 1. rl x :: L 1 s q Queue L 1 u tq 1 Queue L 1 q 2 Queue L 2 u ptransfer q1 q2q tλtt. q 1 Queue nil q 2 Queue pl 1``L 2 qu Representation predicates: Null-terminated list p Mlist L pi.e. p MlistSeg null Lq List segment p MlistSeg q L Queue p Queue L Focus and defocus rules for list segments: p MlistSeg q nil rp qs p MlistSeg q px :: L 1 q Dp 1. p ÞÑ t hd=x; tl=p 1 u p 1 MlistSeg q L 1 p MlistSeg q pl 1``L 2 q Dp 1. p MlistSeg p 1 L 1 p 1 MlistSeg q L 2 11 / / 59

4 Implementation of a mutable binary trees Representation of pure trees Pure trees in Caml: type tree = Leaf Node of int * tree * tree Empty trees represented as null pointers. Nodes represented as records. type node = { mutable item : int; mutable left : node; mutable right : node; } Pure trees in Coq: Inductive tree : Type := Leaf : tree Node : int Ñ tree Ñ tree Ñ tree. Example: Node 3 (Node 2 Leaf Leaf) (Node 4 (Node 5 Leaf Leaf) (Node 6 Leaf Leaf)) 13 / / 59 Representation of a binary tree Representation predicate for binary trees T p Mlist L match L with nil ñ rp nulls x :: L 1 ñ Dp 1. p ÞÑ t hd=x; tl=p 1 u p 1 Mlist L 1 Exercise: define p Mtree T. p Mtree T p Mtree T match T with Leaf ñ rp nulls Node x T 1 T 2 ñ Dp 1 p 2. p ÞÑ t item=x; left=p 1 ; right=p 2 u p 1 Mtree T 1 p 2 Mtree T 2 15 / / 59

5 Specification of tree copy let rec copy (p:node) : node = if p == null then null else let p1 = copy p.left in let p2 = copy p.right in { item = t.item; left = p1 ; right = p2 } Exercise: specify the tree copy tp Mtree T u pcopy pq tλp 1. p Mtree T p 1 Mtree T u Verification of tree copy From the pre-condition p Mtree T, apply the focus rule: p ÞÑ t item=x; left=p 1 ; right=p 2 u p 1 Mtree T 1 p 2 Mtree T 2 Left recursive call: p 1 Mtree T to p 1 Mtree T 1 p 1 1 Mtree T 1 Right recursive call: p 2 Mtree T to p 2 Mtree T 2 p 1 2 Mtree T 2 Construction of the node: p 1 ÞÑ t item=x; left=p 1 1; right=p 1 2 u Defocus on both trees to get the post-condition: p Mtree T p 1 Mtree T 17 / / 59 Invariants on binary trees Enforcing zero or two children Tree with 0 or 2 children Complete binary tree Exercise: define p Mtree2 T to enforce that every node has exactly zero or two non-null children. p Mtree2 T match T with Leaf ñ rp nulls Node x T 1 T 2 ñ Dp 1 p 2. p ÞÑ t item=x; left=p 1 ; right=p 2 u p 1 Mtree2 T 1 p 2 Mtree2 T 2 rp 1 null ô p 2 nulls Binary search tree Red-black tree Remark: last condition could also be rt 1 Leaf ô T 2 Leafs. 19 / / 59

6 Problem with modified representation predicate Invariants expressed on the pure representation Specification of copy: tp Mtree T u pcopy pq tλp 1. p Mtree T p 1 Mtree T u How to derive a specification for trees with zero or two children? tp Mtree2 T u pcopy pq tλp 1. p Mtree2 T p 1 Mtree2 T u We have: p Mtree2 T Ź p Mtree T but not the reciprocal. Better to resuse the existing representation predicate: where: p Mtree2 T p Mtree T rnounary T s Inductive nounary : tree Ñ Prop := nounary_leaf : nounary Leaf nounary_node x T1 T2, nounary T1 Ñ nounary T2 Ñ (T1 = Leaf Ø T2 = Leaf) Ñ nounary (Node x T1 T2) 21 / / 59 Copy of a tree with invariants Complete binary trees Specification of copy: tp Mtree T u pcopy pq tλp 1. p Mtree T p 1 Mtree T u Add rnounary T s both to the pre-condition and the post-condition: t p Mtree T rnounary T s Derived specification: u pcopy pq tλp 1. p Mtree T rnounary T s p 1 Mtree T rnounary T s tp Mtree2 T u pcopy pq tλp 1. p Mtree2 T p 1 Mtree2 T u u Exercise: define p MtreeDepth n T (reusing Mtree) to describe a binary tree whose leaves are all at depth n. p MtreeDepth n T p Mtree T rdepth n T s Inductive depth : int Ñ tree Ñ Prop := depth_leaf : depth 0 Leaf depth_node n x T1 T2, depth n T1 Ñ depth n T2 Ñ depth (n+1) (Node x T1 T2). 23 / / 59

7 Constructors for complete binary trees Binary search trees A node constructor: let mk_node x p1 p2 = { item = x; left = p1; right = p2 } Specification of the node 1 p 2 T 1 T 2 n. tp 1 MtreeDepth n T 1 p 2 MtreeDepth n T 2 u pmk_node x p1 p2q tλp. p MtreeDepth pn ` 1q pnode x T 1 T 2 qu Specification of the leaf constructor: tr su pnullq tλp. p MtreeDepth 0 Leafu A binary search tree that represents a set E: p Msearchtree E DT. p Mtree T rsearch T Es Inductive search : tree Ñ set int Ñ Prop := search_leaf : search Leaf H search_node x T1 T2, search T1 E1 Ñ search T2 E2 Ñ foreach (is_lt x) E1 Ñ foreach (is_gt x) E2 Ñ search (Node x T1 T2) (txu Y E1 Y E2). 25 / / 59 Operations on binary search trees Complete binary trees of unspecified depth Specification: tp Msearchtree Eu padd x pq tλtt. p Msearchtree pe Y txuqu By the pre-condition, there exists T such that the state is: p Mtree T rsearch T Es To prove the post-condition, we have to exhibit a tree T 1 such that: Previous definition: p MtreeDepth n T pp Mtree T q rdepth n T s More abstract definition: p MtreeComplete T pp Mtree T q rdn. depth n T s Dn. pp Mtree T q rdepth n T s p Mtree T 1 rsearch T 1 pe Y txuqs 27 / / 59

8 Red-black trees Colored trees In Caml: Invariants on red-black-trees: Every node has color either red or black. The root must be black. Empty subtrees are considered to be black. Every red node must have two black children. Every path from a given node to any of its descendant leaves contains the same number of black nodes. type color = Red Black type node = { mutable color : color;... } In Coq: Inductive tree : Type := Leaf : tree Node : color Ñ int Ñ tree Ñ tree Ñ tree. Definition color T := match T with Leaf ñ Black Node c x T1 T2 ñ c end 29 / / 59 Representation of red-black trees Representation predicate: p Mrbtree E DT. p Mtree T r search T E ^ color T Black ^ Dn. rbtree n T where rbtree n T formalizes the remaining red-black tree invariants. s Red-black trees The predicate rbtree n T asserts that T is a binary tree such that: (1) every red node has black children, and (2) there are n black non-leaf nodes in every path. Definition: Inductive rbtree : int Ñ tree Ñ Prop := rbtree_leaf : rbtree 0 Leaf rbtree_node n m c x T1 T2, (c = Red Ñ color T1 = Black ^ color T2 = Black) Ñ (m = if (c = Black) then n 1 else n) Ñ rbtree m T1 Ñ rbtree m T2 Ñ rbtree n (Node c x T1 T2) 31 / / 59

9 Summary Towards a frame rule Implementation of sets as mutable binary trees with pure invariants: p Mrbtree E DT. p Mtree T r search T E ^ color T Black ^ Dn. rbtree n T Separation Logic representation predicate for binary trees: p Mtree T match T with Leaf ñ rp nulls Node x T 1 T 2 ñ Dp 1 p 2. p ÞÑ t item=x; left=p 1 ; right=p 2 u p 1 Mtree T 1 p 2 Mtree T 2 s Example: tr ãñ nu pincr rq tλtt. r ãñ pn ` 1qu ts ãñ m r ãñ nu pincr rq tλtt. r ãñ pn ` 1q s ãñ mu More generally: tr ãñ nu pincr rq tλtt. r ãñ pn ` 1qu th r ãñ nu pincr rq tλtt. r ãñ pn ` 1q Hu Specification of mutable sets operations in terms of pure sets: tp Mrbtree Eu padd x pq tλtt. p Mrbtree pe Y txuqu 33 / / 59 The frame rule Frame rule and allocation Frame rule: th 1 u t tλx. H 1 1u th 1 H 2 u t tλx. H 1 1 H 2 u Calling ref returns a fresh location: t r s u pref 3q tλr. pr ãñ 3qu Reformulation: For example, applying the frame rule with s ãñ 5 gives: where Q H λx. pq x Hq. th 1 u t tq 1 u th 1 H 2 u t tq 1 H 2 u ts ãñ 5u pref 3q tλr. pr ãñ 3q ps ãñ 5qu where the post-condition ensures r s. 35 / / 59

10 Strengthening of the pre-condition Strengthening rule: Example: if then H Ź H 1 th 1 u t tqu tdn. pr ãñ nq reven nsu t tqu tr ãñ 6u t tqu. In Separation Logic, H and H 1 must cover the same set of memory cells, i.e. no garbage collection is allowed here. Weakening of the post-condition Weakening rule: thu t tq 1 u Q 1 Q where Q 1 Q 1 v Ź Q v Example: if thu t tλx. rx 4s pr ãñ 6qu then thu t tλx. reven xs Dn. pr ãñ nq reven nsu rv 4s pr ãñ 6q Ź reven vs Dn. pr ãñ nq reven ns 37 / / 59 The garbage collection rules Derivability of gc-pre Exercise: show that gc-pre is derivable from gc-post and frame. Garbage collection in post-condition: Garbage collection in pre-condition: thu t tq H 1 u gc-post th H 1 u t tqu gc-pre Solution: thu t tq H 1 u gc-post th H 1 u t tqu gc-pre th 1 u t tq 1 u th 1 H 2 u t tq 1 H 2 u frame th H 1 u t tq H 1 u frame th H 1 u t tqu gc-post 39 / / 59

11 The combined rule Extraction of existentials and propositions H Ź H 1 th 1 u t tqu strengthen thu t tq 1 u Q 1 Q weaken Consider the triple: thu t tq H 1 u gc th 1 u t tq 1 u th 1 H 2 u t tq 1 H 2 u frame tdn. pr ãñ nq reven nsu p!rq tqu To prove it, we need to show that, for any even number n, we have: H H 1 H 2 th 1 u t tq 1 u Q 1 H 2 Q frame Corresponding reasoning rules: tr ãñ nu p!rq tqu Combined as one: H Ź H 1 H 2 th 1 u t tq 1 u Q 1 H 2 Q H tdx. Hu t tqu P ñ trp s Hu t tqu 41 / / 59 Summary: structural rules Reasoning rule for sequences Combined rule: H Ź H 1 H 2 th 1 u t tq 1 u Q 1 H 2 Q H 3 Example: tr ãñ nu pincr rq tλtt. r ãñ n ` 1u tr ãñ n ` 1u p!rq tλx. rx n ` 1s r ãñ n ` 1u tr ãñ nu pincr r;!rq tλx. rx n ` 1s r ãñ n ` 1u Extraction tdx. Hu t tqu P ñ trp s Hu t tqu Reasoning rule: t...u t 1 t...u t...u t 2 t...u thu pt 1 ; t 2 q tqu 43 / / 59

12 Reasoning rule for sequences Reasoning rule for let-bindings Solution 1: thu t 1 tλtt. H 1 u th 1 u t 2 tqu thu pt 1 ; t 2 q tqu Exercise: t...u t 1 `t...u t 2 t...u thu plet x t 1 in t 2 q tqu Solution 2: thu t 1 tq 1 u tq 1 ttu t 2 tqu thu pt 1 ; t 2 q tqu Solution: thu t 1 tq 1 tq 1 xu t 2 tqu thu plet x t 1 in t 2 q tqu Remark: Q 1 λtt. H 1 is equivalent to Q 1 tt H / / 59 Example of let-binding Reasoning rule for values Example: t r s u 3 tλx. rx 3su Exercise: instantiate the rule for let-bindings on the following code. Rule: Solution: tr ãñ 3u plet a =!r in a+1q tqu Q λx. rx 4s pr ãñ 3q Q 1 λy. ry 3s pr ãñ 3q t r s u v tλx. rx vsu Exercise: state a reasoning rule for values using a heap implication.... Ź... thu v tqu Solution: H Ź Q v r s Ź ppλx. rx 3sq 3q Example: thu v tqu t r s u 3 tλx. rx 3su 47 / / 59

13 Reasoning rule for conditionals Reasoning rule for functions Code: Rule: pv true ñ thu t 1 tquq pv false ñ thu t 2 tquq thu pif v then t 1 else t 2 q tqu Transformation to A-normal form: pif t 0 then t 1 else t 2 q plet v t 0 in pif v then t 1 else t 2 qq Specification: let incr r = let a =!r in r := tr ãñ nu pincr rq tλtt. r ãñ n ` 1u Verification: Fix r and n. We need to prove that the body satisfies the specification: tr ãñ nu plet a =!r in r := a+1q tλtt. r ãñ n ` 1u 49 / / 59 Renaming of the argument Reasoning rule for functions Code: Specification: let incr r = let a =!r in r := ts ãñ nu pincr sq tλtt. s ãñ n ` 1u Verification: Fix s and n. We need to prove that the body satisfies the specification: Rule: f λx. t thu pxv{xy tq tqu thu pf vq tqu Transformation to A-normal form: pt 1 t 2 q plet f t 1 in let v t 2 in pf vqq ts ãñ nu plet a =!s in s := a+1q tλtt. s ãñ n ` 1u 51 / / 59

14 Verification of function calls Specification: Verification: let incr r = let a =!r in r := a+1 let _ = incr s; incr tr ãñ nu pincr rq tλtt. r ãñ n ` 1u tr ãñ nu plet a =!r in r := a+1q tλtt. r ãñ n ` 1u Reasoning on calls: ts ãñ xu pincr sq tλtt. s ãñ x ` 1u tt ãñ yu pincr tq tλtt. t ãñ y ` 1u Verification of a recursive function let rec f n = if n = 0 then 0 else let y = f(n-1) in y+2 trn ě 0su pf nq tλr. rr 2nsu Verification: by induction on n. Case n 0. tr0 ě 0su 0 tλr. rr 0su Case n 0. trn ě 0su plet y = f(n-1)in y+2q tλr. rr 2nsu using the induction hypothesis: trn 1 ě 0su pf(n-1)q tλy. ry 2pn 1qsu 53 / / 59 Reasoning rule for local functions Summary: rules for terms Rule p...q ñ thu t 2 tqu thu plet rec f x t 1 in t 2 q tqu H Ź Q v thu v tqu thu t 1 tq 1 u tq 1 ttu t 2 tqu thu pt 1 ; t 2 q tqu Hypothesis about 1 Q 1. th 1 u t 1 tq 1 u ñ th 1 u pf xq tq 1 u `@xh 1 Q 1. th 1 u t 1 tq 1 u ñ th 1 u pf xq tq 1 u ñ thu t 2 tqu thu plet rec f x t 1 in t 2 q tqu thu t 1 tq 1 tq 1 xu t 2 tqu thu plet x t 1 in t 2 q tqu v true ñ thu t 1 tqu v false ñ thu t 2 tqu thu pif v then t 1 else t 2 q `@xh 1 Q 1. th 1 u t 1 tq 1 u ñ th 1 u pf xq tq 1 u ñ thu t 2 tqu thu plet rec f x t 1 in t 2 q tqu 55 / / 59

15 Exercise: interface for mutable sets Exercises Specify the functions from the OCaml interface for mutable sets in terms of an abstract representation predicate p Mset E. create : unit -> a set is_empty : a set -> bool mem : a -> a set -> bool add : a -> a set -> unit rem : a -> a set -> unit 57 / / 59 Solution: interface for mutable sets tr su pcreate()q tλp. p Mset Hu tp Mset Eu pis_empty pq tλb. rb true ô E Hs p Mset Eu tp Mset Eu pmem x pq tλb. rb true ô x P Es p Mset Eu tp Mset Eu padd x pq tλtt. p Mset pe Y txuqu tp Mset Eu prem x pq tλtt. p Mset pe z txuqu 59 / 59

Separation Logic 2/4. Chapter 7. Preservation of independent state. The frame rule. The Frame Rule. Arthur Charguéraud.

Separation Logic 2/4. Chapter 7. Preservation of independent state. The frame rule. The Frame Rule. Arthur Charguéraud. Separation Logic 2/4 Arthur Charguéraud Chapter 7 The Frame Rule Febuary 8th, 2017 1 / 75 2 / 75 Preservation of independent state The frame rule We have: tr ÞÑ 2u pincr rq tλ. r ÞÑ 3u Principle: a triple

More information

Separation Logic. Part 3. Arthur Charguéraud. February / 66

Separation Logic. Part 3. Arthur Charguéraud. February / 66 Separation Logic Part 3 Arthur Charguéraud February 2014 1 / 66 Content Reasoning about loops For loops While loops Repeat-loops Total correctness Frame in a while loop Higher-order iterators for pure

More information

Example of a for-loop. Separation Logic. The repeat construct. Reasoning rule for for-loops. Before the loop:

Example of a for-loop. Separation Logic. The repeat construct. Reasoning rule for for-loops. Before the loop: Example of a for-loop Separation Logic Part 3 Arthur Charguéraud February 2015 let facto n = let r = ref 1 in for i = 2 to n do let v =!r in r := v * i; done;!r Before the loop: r ãñ 1 At each iteration:

More information

Separation Logic 4/4. Chapter 18. Integration of structural rules. Definition of the local predicate (1/2)

Separation Logic 4/4. Chapter 18. Integration of structural rules. Definition of the local predicate (1/2) Separation Logic 4/4 Arthur Charguéraud Chapter 18 Characteristic Formulae with structural rules Febuary 22th, 2016 1 / 72 2 / 72 Integration of structural rules Definition of the local predicate (1/2)

More information

A new, axiom-free implementation of CFML for the verification of imperative programs

A new, axiom-free implementation of CFML for the verification of imperative programs A new, axiom-free implementation of CFML for the verification of imperative programs Arthur Charguéraud Inria 2017/10/13 1 / 31 CFML: program verification using characteristic formulae Old CFML: too large

More information

1 Introduction. 2 First Order Logic. 3 SPL Syntax. 4 Hoare Logic. 5 Exercises

1 Introduction. 2 First Order Logic. 3 SPL Syntax. 4 Hoare Logic. 5 Exercises Contents 1 Introduction INF5140: Lecture 2 Espen H. Lian Institutt for informatikk, Universitetet i Oslo January 28, 2009 2 Proof System 3 SPL 4 GCD 5 Exercises Institutt for informatikk (UiO) INF5140:

More information

CS 151. Red Black Trees & Structural Induction. Thursday, November 1, 12

CS 151. Red Black Trees & Structural Induction. Thursday, November 1, 12 CS 151 Red Black Trees & Structural Induction 1 Announcements Majors fair tonight 4:30-6:30pm in the Root Room in Carnegie. Come and find out about the CS major, or some other major. Winter Term in CS

More information

DS-GA 1002: PREREQUISITES REVIEW SOLUTIONS VLADIMIR KOBZAR

DS-GA 1002: PREREQUISITES REVIEW SOLUTIONS VLADIMIR KOBZAR DS-GA 2: PEEQUISIES EVIEW SOLUIONS VLADIMI KOBZA he following is a selection of questions (drawn from Mr. Bernstein s notes) for reviewing the prerequisites for DS-GA 2. Questions from Ch, 8, 9 and 2 of

More information

Extensive Form Abstract Economies and Generalized Perfect Recall

Extensive Form Abstract Economies and Generalized Perfect Recall Extensive Form Abstract Economies and Generalized Perfect Recall Nicholas Butler Princeton University July 30, 2015 Nicholas Butler (Princeton) EFAE and Generalized Perfect Recall July 30, 2015 1 / 1 Motivation

More information

Mathematical Induction

Mathematical Induction Mathematical Induction COM1022 Functional Programming Techniques Professor Steve Schneider University of Surrey Semester 2, 2010 Week 10 Professor Steve Schneider Mathematical Induction Semester 2, 2010

More information

Dynamic Semantics. Dynamic Semantics. Operational Semantics Axiomatic Semantics Denotational Semantic. Operational Semantics

Dynamic Semantics. Dynamic Semantics. Operational Semantics Axiomatic Semantics Denotational Semantic. Operational Semantics Dynamic Semantics Operational Semantics Denotational Semantic Dynamic Semantics Operational Semantics Operational Semantics Describe meaning by executing program on machine Machine can be actual or simulated

More information

Solution suggestions for examination of Logic, Algorithms and Data Structures,

Solution suggestions for examination of Logic, Algorithms and Data Structures, Department of VT12 Software Engineering and Managment DIT725 (TIG023) Göteborg University, Chalmers 24/5-12 Solution suggestions for examination of Logic, Algorithms and Data Structures, Date : April 26,

More information

CSC236H Lecture 2. Ilir Dema. September 19, 2018

CSC236H Lecture 2. Ilir Dema. September 19, 2018 CSC236H Lecture 2 Ilir Dema September 19, 2018 Simple Induction Useful to prove statements depending on natural numbers Define a predicate P(n) Prove the base case P(b) Prove that for all n b, P(n) P(n

More information

Colby College Catalogue

Colby College Catalogue Colby College Digital Commons @ Colby Colby Catalogues College Archives: Colbiana Collection 1871 Colby College Catalogue 1871-1872 Colby College Follow this and additional works at: http://digitalcommonscolbyedu/catalogs

More information

Program Verification Using Separation Logic

Program Verification Using Separation Logic Program Verification Using Separation Logic Cristiano Calcagno Adapted from material by Dino Distefano Lecture 1 Goal of the course Study Separation Logic having automatic verification in mind Learn how

More information

Iris: Higher-Order Concurrent Separation Logic. Lecture 4: Basic Separation Logic: Proving Pointer Programs

Iris: Higher-Order Concurrent Separation Logic. Lecture 4: Basic Separation Logic: Proving Pointer Programs 1 Iris: Higher-Order Concurrent Separation Logic Lecture 4: Basic Separation Logic: Proving Pointer Programs Lars Birkedal Aarhus University, Denmark November 10, 2017 2 Overview Earlier: Operational Semantics

More information

Dictionary: an abstract data type

Dictionary: an abstract data type 2-3 Trees 1 Dictionary: an abstract data type A container that maps keys to values Dictionary operations Insert Search Delete Several possible implementations Balanced search trees Hash tables 2 2-3 trees

More information

Amortized Complexity Verified

Amortized Complexity Verified Amortized Complexity Verified Tobias Nipkow Technische Universität München Abstract A framework for the analysis of the amortized complexity of (functional) data structures is formalized in Isabelle/HOL

More information

NOTES WEEK 01 DAY 1 SCOT ADAMS

NOTES WEEK 01 DAY 1 SCOT ADAMS NOTES WEEK 01 DAY 1 SCOT ADAMS Question: What is Mathematics? Answer: The study of absolute truth. Question: Why is it so hard to teach and to learn? Answer: One must learn to play a variety of games called

More information

Verified Characteristic Formulae for CakeML. Armaël Guéneau, Magnus O. Myreen, Ramana Kumar, Michael Norrish April 18, 2017

Verified Characteristic Formulae for CakeML. Armaël Guéneau, Magnus O. Myreen, Ramana Kumar, Michael Norrish April 18, 2017 Verified Characteristic Formulae for CakeML Armaël Guéneau, Magnus O. Myreen, Ramana Kumar, Michael Norrish April 18, 2017 CakeML Has: references, modules, datatypes, exceptions, a FFI,... Doesn t have:

More information

For example, p12q p2x 1 x 2 ` 5x 2 x 2 3 q 2x 2 x 1 ` 5x 1 x 2 3. (a) Let p 12x 5 1x 7 2x 4 18x 6 2x 3 ` 11x 1 x 2 x 3 x 4,

For example, p12q p2x 1 x 2 ` 5x 2 x 2 3 q 2x 2 x 1 ` 5x 1 x 2 3. (a) Let p 12x 5 1x 7 2x 4 18x 6 2x 3 ` 11x 1 x 2 x 3 x 4, SOLUTIONS Math A4900 Homework 5 10/4/2017 1. (DF 2.2.12(a)-(d)+) Symmetric polynomials. The group S n acts on the set tx 1, x 2,..., x n u by σ x i x σpiq. That action extends to a function S n ˆ A Ñ A,

More information

4 Quantifiers and Quantified Arguments 4.1 Quantifiers

4 Quantifiers and Quantified Arguments 4.1 Quantifiers 4 Quantifiers and Quantified Arguments 4.1 Quantifiers Recall from Chapter 3 the definition of a predicate as an assertion containing one or more variables such that, if the variables are replaced by objects

More information

Colby College Catalogue

Colby College Catalogue Colby College Digital Commons @ Colby Colby Catalogues College Archives: Colbiana Collection 1870 Colby College Catalogue 1870-1871 Colby College Follow this and additional works at: http://digitalcommonscolbyedu/catalogs

More information

Functional Data Structures

Functional Data Structures Functional Data Structures with Isabelle/HOL Tobias Nipkow Fakultät für Informatik Technische Universität München 2017-2-3 1 Part II Functional Data Structures 2 Chapter 1 Binary Trees 3 1 Binary Trees

More information

Existence and Consistency in Bounded Arithmetic

Existence and Consistency in Bounded Arithmetic Existence and Consistency in Bounded Arithmetic Yoriyuki Yamagata National Institute of Advanced Science and Technology (AIST) Kusatsu, August 30, 2011 Outline Self introduction Summary Theories of PV

More information

4 4 N v b r t, 20 xpr n f th ll f th p p l t n p pr d. H ndr d nd th nd f t v L th n n f th pr v n f V ln, r dn nd l r thr n nt pr n, h r th ff r d nd

4 4 N v b r t, 20 xpr n f th ll f th p p l t n p pr d. H ndr d nd th nd f t v L th n n f th pr v n f V ln, r dn nd l r thr n nt pr n, h r th ff r d nd n r t d n 20 20 0 : 0 T P bl D n, l d t z d http:.h th tr t. r pd l 4 4 N v b r t, 20 xpr n f th ll f th p p l t n p pr d. H ndr d nd th nd f t v L th n n f th pr v n f V ln, r dn nd l r thr n nt pr n,

More information

n r t d n :4 T P bl D n, l d t z d th tr t. r pd l

n r t d n :4 T P bl D n, l d t z d   th tr t. r pd l n r t d n 20 20 :4 T P bl D n, l d t z d http:.h th tr t. r pd l 2 0 x pt n f t v t, f f d, b th n nd th P r n h h, th r h v n t b n p d f r nt r. Th t v v d pr n, h v r, p n th pl v t r, d b p t r b R

More information

Introduction to computability Tutorial 7

Introduction to computability Tutorial 7 Introduction to computability Tutorial 7 Context free languages and Turing machines November 6 th 2014 Context-free languages 1. Show that the following languages are not context-free: a) L ta i b j a

More information

Homework for MATH 4604 (Advanced Calculus II) Spring 2017

Homework for MATH 4604 (Advanced Calculus II) Spring 2017 Homework for MATH 4604 (Advanced Calculus II) Spring 2017 Homework 14: Due on Tuesday 2 May 55. Let m, n P N, A P R mˆn and v P R n. Show: L A pvq 2 ď A 2 v 2. 56. Let n P N and let A P R nˆn. Let I n

More information

L11: Algebraic Path Problems with applications to Internet Routing Lectures 7 and 8

L11: Algebraic Path Problems with applications to Internet Routing Lectures 7 and 8 L: Algebraic Path Problems with applications to Internet Routing Lectures 7 and 8 Timothy G. Grifn timothy.grifn@cl.cam.ac.uk Computer Laboratory University of Cambridge, UK Michaelmas Term, 27 tgg22 (cl.cam.ac.uk)

More information

Verifying Java-KE Programs

Verifying Java-KE Programs Verifying Java-KE Programs A Small Case Study Arnd Poetzsch-Heffter July 22, 2014 Abstract This report investigates the specification and verification of a simple list class. The example was designed such

More information

Mathematical Induction. Rosen Chapter 4.1,4.2 (6 th edition) Rosen Ch. 5.1, 5.2 (7 th edition)

Mathematical Induction. Rosen Chapter 4.1,4.2 (6 th edition) Rosen Ch. 5.1, 5.2 (7 th edition) Mathematical Induction Rosen Chapter 4.1,4.2 (6 th edition) Rosen Ch. 5.1, 5.2 (7 th edition) Motivation Suppose we want to prove that for every value of n: 1 + 2 + + n = n(n + 1)/2. Let P(n) be the predicate

More information

NOTES WEEK 13 DAY 2 SCOT ADAMS

NOTES WEEK 13 DAY 2 SCOT ADAMS NOTES WEEK 13 DAY 2 SCOT ADAMS Recall: Let px, dq be a metric space. Then, for all S Ď X, we have p S is sequentially compact q ñ p S is closed and bounded q. DEFINITION 0.1. Let px, dq be a metric space.

More information

L11: Algebraic Path Problems with applications to Internet Routing Lecture 15. Path Weight with functions on arcs?

L11: Algebraic Path Problems with applications to Internet Routing Lecture 15. Path Weight with functions on arcs? L11: Algebraic Path Problems with applications to Internet Routing Lecture 15 Timothy G. Griffin timothy.griffin@cl.cam.ac.uk Computer Laboratory University of Cambridge, UK Michaelmas Term, 2016 tgg22

More information

Colby College Catalogue

Colby College Catalogue Colby College Digital Commons @ Colby Colby Catalogues College Archives: Colbiana Collection 1872 Colby College Catalogue 1872-1873 Colby College Follow this and additional works at: http://digitalcommonscolbyedu/catalogs

More information

PRINCIPLES OF ANALYSIS - LECTURE NOTES

PRINCIPLES OF ANALYSIS - LECTURE NOTES PRINCIPLES OF ANALYSIS - LECTURE NOTES PETER A. PERRY 1. Constructions of Z, Q, R Beginning with the natural numbers N t1, 2, 3,...u we can use set theory to construct, successively, Z, Q, and R. We ll

More information

PR D NT N n TR T F R 6 pr l 8 Th Pr d nt Th h t H h n t n, D D r r. Pr d nt: n J n r f th r d t r v th tr t d rn z t n pr r f th n t d t t. n

PR D NT N n TR T F R 6 pr l 8 Th Pr d nt Th h t H h n t n, D D r r. Pr d nt: n J n r f th r d t r v th tr t d rn z t n pr r f th n t d t t. n R P RT F TH PR D NT N N TR T F R N V R T F NN T V D 0 0 : R PR P R JT..P.. D 2 PR L 8 8 J PR D NT N n TR T F R 6 pr l 8 Th Pr d nt Th h t H h n t n, D.. 20 00 D r r. Pr d nt: n J n r f th r d t r v th

More information

Propositions and Proofs

Propositions and Proofs Propositions and Proofs Gert Smolka, Saarland University April 25, 2018 Proposition are logical statements whose truth or falsity can be established with proofs. Coq s type theory provides us with a language

More information

Classical Program Logics: Hoare Logic, Weakest Liberal Preconditions

Classical Program Logics: Hoare Logic, Weakest Liberal Preconditions Chapter 1 Classical Program Logics: Hoare Logic, Weakest Liberal Preconditions 1.1 The IMP Language IMP is a programming language with an extensible syntax that was developed in the late 1960s. We will

More information

Predicate Logic. Andreas Klappenecker

Predicate Logic. Andreas Klappenecker Predicate Logic Andreas Klappenecker Predicates A function P from a set D to the set Prop of propositions is called a predicate. The set D is called the domain of P. Example Let D=Z be the set of integers.

More information

Random Variables. Andreas Klappenecker. Texas A&M University

Random Variables. Andreas Klappenecker. Texas A&M University Random Variables Andreas Klappenecker Texas A&M University 1 / 29 What is a Random Variable? Random variables are functions that associate a numerical value to each outcome of an experiment. For instance,

More information

NOTES WEEK 15 DAY 1 SCOT ADAMS

NOTES WEEK 15 DAY 1 SCOT ADAMS NOTES WEEK 15 DAY 1 SCOT ADAMS We fix some notation for the entire class today: Let n P N, W : R n, : 2 P N pw q, W : LpW, W q, I : id W P W, z : 0 W 0 n. Note that W LpR n, R n q. Recall, for all T P

More information

NOTES WEEK 10 DAY 2. Unassigned HW: Let V and W be finite dimensional vector spaces and let x P V. Show, for all f, g : V W, that

NOTES WEEK 10 DAY 2. Unassigned HW: Let V and W be finite dimensional vector spaces and let x P V. Show, for all f, g : V W, that NOTES WEEK 10 DAY 2 SCOT ADAMS Unassigned HW: Let V and W be finite dimensional vector spaces and let x P V. Show, for all f, g : V W, that D x pf ` gq pd x fq ` pd x gq. Also, show, for all c P R, for

More information

H NT Z N RT L 0 4 n f lt r h v d lt n r n, h p l," "Fl d nd fl d " ( n l d n l tr l t nt r t t n t nt t nt n fr n nl, th t l n r tr t nt. r d n f d rd n t th nd r nt r d t n th t th n r lth h v b n f

More information

NOTES WEEK 02 DAY 1. THEOREM 0.3. Let A, B and C be sets. Then

NOTES WEEK 02 DAY 1. THEOREM 0.3. Let A, B and C be sets. Then NOTES WEEK 02 DAY 1 SCOT ADAMS LEMMA 0.1. @propositions P, Q, R, rp or pq&rqs rp p or Qq&pP or Rqs. THEOREM 0.2. Let A and B be sets. Then (i) A X B B X A, and (ii) A Y B B Y A THEOREM 0.3. Let A, B and

More information

,. *â â > V>V. â ND * 828.

,. *â â > V>V. â ND * 828. BL D,. *â â > V>V Z V L. XX. J N R â J N, 828. LL BL D, D NB R H â ND T. D LL, TR ND, L ND N. * 828. n r t d n 20 2 2 0 : 0 T http: hdl.h ndl.n t 202 dp. 0 02802 68 Th N : l nd r.. N > R, L X. Fn r f,

More information

Hoare Logic: Reasoning About Imperative Programs

Hoare Logic: Reasoning About Imperative Programs Hoare Logic: Reasoning About Imperative Programs COMP1600 / COMP6260 Dirk Pattinson Australian National University Semester 2, 2018 Programming Paradigms Functional. (Haskell, SML, OCaml,... ) main paradigm:

More information

( V ametavariable) P P true. even in E)

( V ametavariable) P P true. even in E) Propositional Calculus E Inference rules (3.1) Leibniz: (3.2) Transitivity: (3.3) Equanimity: P = Q E[V := P ]=E[V := Q] P = Q Q = R P = R P P Q Q ( V ametavariable) Derived inference rules (3.11) Redundant

More information

Discrete Mathematics Review

Discrete Mathematics Review CS 1813 Discrete Mathematics Discrete Mathematics Review or Yes, the Final Will Be Comprehensive 1 Truth Tables for Logical Operators P Q P Q False False False P Q False P Q False P Q True P Q True P True

More information

CIS 500: Software Foundations

CIS 500: Software Foundations CIS 500: Software Foundations Midterm I October 3, 2017 Directions: This exam booklet contains both the standard and advanced track questions. Questions with no annotation are for both tracks. Other questions

More information

Induction and Recursion

Induction and Recursion Induction and Recursion Prof. Clarkson Fall 2016 Today s music: Dream within a Dream from the soundtrack to Inception by Hans Zimmer Review Previously in 3110: Behavioral equivalence Proofs of correctness

More information

Automata Theory and Formal Grammars: Lecture 1

Automata Theory and Formal Grammars: Lecture 1 Automata Theory and Formal Grammars: Lecture 1 Sets, Languages, Logic Automata Theory and Formal Grammars: Lecture 1 p.1/72 Sets, Languages, Logic Today Course Overview Administrivia Sets Theory (Review?)

More information

0 t b r 6, 20 t l nf r nt f th l t th t v t f th th lv, ntr t n t th l l l nd d p rt nt th t f ttr t n th p nt t th r f l nd d tr b t n. R v n n th r

0 t b r 6, 20 t l nf r nt f th l t th t v t f th th lv, ntr t n t th l l l nd d p rt nt th t f ttr t n th p nt t th r f l nd d tr b t n. R v n n th r n r t d n 20 22 0: T P bl D n, l d t z d http:.h th tr t. r pd l 0 t b r 6, 20 t l nf r nt f th l t th t v t f th th lv, ntr t n t th l l l nd d p rt nt th t f ttr t n th p nt t th r f l nd d tr b t n.

More information

Proof Techniques (Review of Math 271)

Proof Techniques (Review of Math 271) Chapter 2 Proof Techniques (Review of Math 271) 2.1 Overview This chapter reviews proof techniques that were probably introduced in Math 271 and that may also have been used in a different way in Phil

More information

Verification of Recursive Programs. Andreas Podelski February 8, 2012

Verification of Recursive Programs. Andreas Podelski February 8, 2012 Verification of Recursive Programs Andreas Podelski February 8, 2012 1 m(x) = x 10 if x > 100 m(m(x + 11)) if x 100 2 procedure m(x) returns (res) `0: if x>100 `1: res:=x-10 else `2: x m := x+11 `3: res

More information

Heaps Induction. Heaps. Heaps. Tirgul 6

Heaps Induction. Heaps. Heaps. Tirgul 6 Tirgul 6 Induction A binary heap is a nearly complete binary tree stored in an array object In a max heap, the value of each node that of its children (In a min heap, the value of each node that of its

More information

APPROXIMATE HOMOMORPHISMS BETWEEN THE BOOLEAN CUBE AND GROUPS OF PRIME ORDER

APPROXIMATE HOMOMORPHISMS BETWEEN THE BOOLEAN CUBE AND GROUPS OF PRIME ORDER APPROXIMATE HOMOMORPHISMS BETWEEN THE BOOLEAN CUBE AND GROUPS OF PRIME ORDER TOM SANDERS The purpose of this note is to highlight a question raised by Shachar Lovett [Lov], and to offer some motivation

More information

Intrinsic Four-Point Properties

Intrinsic Four-Point Properties Intrinsic Four-Point Properties Edward Andalafte, Raymond Freese, Brody Dylan Johnson and Rebecca Lelko Abstract. Many characterizations of euclidean spaces (real inner product spaces) among metric spaces

More information

4 8 N v btr 20, 20 th r l f ff nt f l t. r t pl n f r th n tr t n f h h v lr d b n r d t, rd n t h h th t b t f l rd n t f th rld ll b n tr t d n R th

4 8 N v btr 20, 20 th r l f ff nt f l t. r t pl n f r th n tr t n f h h v lr d b n r d t, rd n t h h th t b t f l rd n t f th rld ll b n tr t d n R th n r t d n 20 2 :24 T P bl D n, l d t z d http:.h th tr t. r pd l 4 8 N v btr 20, 20 th r l f ff nt f l t. r t pl n f r th n tr t n f h h v lr d b n r d t, rd n t h h th t b t f l rd n t f th rld ll b n

More information

Static Program Analysis

Static Program Analysis Static Program Analysis Xiangyu Zhang The slides are compiled from Alex Aiken s Michael D. Ernst s Sorin Lerner s A Scary Outline Type-based analysis Data-flow analysis Abstract interpretation Theorem

More information

Program verification. Hoare triples. Assertional semantics (cont) Example: Semantics of assignment. Assertional semantics of a program

Program verification. Hoare triples. Assertional semantics (cont) Example: Semantics of assignment. Assertional semantics of a program Program verification Assertional semantics of a program Meaning of a program: relation between its inputs and outputs; specified by input assertions (pre-conditions) and output assertions (post-conditions)

More information

An 1.75 approximation algorithm for the leaf-to-leaf tree augmentation problem

An 1.75 approximation algorithm for the leaf-to-leaf tree augmentation problem An 1.75 approximation algorithm for the leaf-to-leaf tree augmentation problem Zeev Nutov, László A. Végh January 12, 2016 We study the tree augmentation problem: Tree Augmentation Problem (TAP) Instance:

More information

Lecture Notes: Program Analysis Correctness

Lecture Notes: Program Analysis Correctness Lecture Notes: Program Analysis Correctness 15-819O: Program Analysis Jonathan Aldrich jonathan.aldrich@cs.cmu.edu Lecture 5 1 Termination As we think about the correctness of program analysis, let us

More information

The Assignment Axiom (Hoare)

The Assignment Axiom (Hoare) The Assignment Axiom (Hoare) Syntax: V := E Semantics: value of V in final state is value of E in initial state Example: X:=X+ (adds one to the value of the variable X) The Assignment Axiom {Q[E/V ]} V

More information

Binary Decision Diagrams. Graphs. Boolean Functions

Binary Decision Diagrams. Graphs. Boolean Functions Binary Decision Diagrams Graphs Binary Decision Diagrams (BDDs) are a class of graphs that can be used as data structure for compactly representing boolean functions. BDDs were introduced by R. Bryant

More information

l f t n nd bj t nd x f r t l n nd rr n n th b nd p phl t f l br r. D, lv l, 8. h r t,., 8 6. http://hdl.handle.net/2027/miun.aey7382.0001.001 P bl D n http://www.hathitrust.org/access_use#pd Th r n th

More information

13 Dynamic Programming (3) Optimal Binary Search Trees Subset Sums & Knapsacks

13 Dynamic Programming (3) Optimal Binary Search Trees Subset Sums & Knapsacks 13 Dynamic Programming (3) Optimal Binary Search Trees Subset Sums & Knapsacks Average-case analysis Average-case analysis of algorithms and data structures: Input is generated according to a known probability

More information

King s Research Portal

King s Research Portal King s Research Portal Document Version Version created as part of publication process; publisher's layout; not normally made publicly available Link to publication record in King's Research Portal Citation

More information

Version January Please send comments and corrections to

Version January Please send comments and corrections to Mathematical Logic for Computer Science Second revised edition, Springer-Verlag London, 2001 Answers to Exercises Mordechai Ben-Ari Department of Science Teaching Weizmann Institute of Science Rehovot

More information

Semantic Groundedness I: Kripke and Yablo

Semantic Groundedness I: Kripke and Yablo Semantic Groundedness I: Kripke and Yablo Jönne Speck 21st April 2012 The full Tarski T-schema leads to paradox. It is consistent, if restricted to sentences without truth predicate but we want more. What

More information

Binary Decision Diagrams

Binary Decision Diagrams Binary Decision Diagrams Binary Decision Diagrams (BDDs) are a class of graphs that can be used as data structure for compactly representing boolean functions. BDDs were introduced by R. Bryant in 1986.

More information

THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester COMP2600/COMP6260 (Formal Methods for Software Engineering)

THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester COMP2600/COMP6260 (Formal Methods for Software Engineering) THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester 2016 COMP2600/COMP6260 (Formal Methods for Software Engineering) Writing Period: 3 hours duration Study Period: 15 minutes duration Permitted Materials:

More information

ICS141: Discrete Mathematics for Computer Science I

ICS141: Discrete Mathematics for Computer Science I ICS141: Discrete Mathematics for Computer Science I Dept. Information & Computer Sci., Jan Stelovsky based on slides by Dr. Baek and Dr. Still Originals by Dr. M. P. Frank and Dr. J.L. Gross Provided by

More information

CSCE 222 Discrete Structures for Computing. Review for Exam 2. Dr. Hyunyoung Lee !!!

CSCE 222 Discrete Structures for Computing. Review for Exam 2. Dr. Hyunyoung Lee !!! CSCE 222 Discrete Structures for Computing Review for Exam 2 Dr. Hyunyoung Lee 1 Strategy for Exam Preparation - Start studying now (unless have already started) - Study class notes (lecture slides and

More information

In this episode of The Verification Corner, Rustan Leino talks about Loop Invariants. He gives a brief summary of the theoretical foundations and

In this episode of The Verification Corner, Rustan Leino talks about Loop Invariants. He gives a brief summary of the theoretical foundations and In this episode of The Verification Corner, Rustan Leino talks about Loop Invariants. He gives a brief summary of the theoretical foundations and shows how a program can sometimes be systematically constructed

More information

NOTES WEEK 04 DAY 1 SCOT ADAMS

NOTES WEEK 04 DAY 1 SCOT ADAMS NOTES WEEK 0 DAY 1 SCOT ADAMS DEFINITION 01 Let m, n P N, B P BpR m, R n q Let e 1,, e m be the standard basis of R m Let f 1,, f n be the standard basis of R n Then we define rbs P R nˆm by rbs ji Bpe

More information

NOTES WEEK 11 DAY 2 SCOT ADAMS

NOTES WEEK 11 DAY 2 SCOT ADAMS NOTES WEEK 11 DAY 2 SCOT ADAMS In Proposition 0.1 below, Bp0, δq is just the open interval p δ, δq and Bp0, x q is just the closed interval r x, x s. PROPOSITION 0.1. Let g : R R and let δ ą 0. Assume

More information

Symmetries of Weight Enumerators

Symmetries of Weight Enumerators Martino Borello (Paris 8-LAGA) Trento, 16.11.2016 1 / 23 Symmetries of Weight Enumerators Martino Borello Université Paris 8 - LAGA Trento, 16.11.2016 Martino Borello (Paris 8-LAGA) Trento, 16.11.2016

More information

Structuring the verification of heap-manipulating programs

Structuring the verification of heap-manipulating programs Structuring the verification of heap-manipulating programs Aleksandar Nanevski (IMDEA Madrid) Viktor Vafeiadis (MSR / Univ. of Cambridge) Josh Berdine (MSR Cambridge) Hoare/Separation Logic Hoare logic

More information

N V R T F L F RN P BL T N B ll t n f th D p rt nt f l V l., N., pp NDR. L N, d t r T N P F F L T RTL FR R N. B. P. H. Th t t d n t r n h r d r

N V R T F L F RN P BL T N B ll t n f th D p rt nt f l V l., N., pp NDR. L N, d t r T N P F F L T RTL FR R N. B. P. H. Th t t d n t r n h r d r n r t d n 20 2 04 2 :0 T http: hdl.h ndl.n t 202 dp. 0 02 000 N V R T F L F RN P BL T N B ll t n f th D p rt nt f l V l., N., pp. 2 24. NDR. L N, d t r T N P F F L T RTL FR R N. B. P. H. Th t t d n t r

More information

Inductive Predicates

Inductive Predicates Inductive Predicates Gert Smolka, Saarland University June 12, 2017 We introduce inductive predicates as they are accommodated in Coq s type theory. Our prime example is the ordering predicate for numbers,

More information

THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester COMP2600 (Formal Methods for Software Engineering)

THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester COMP2600 (Formal Methods for Software Engineering) THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester 2010 COMP2600 (Formal Methods for Software Engineering) Writing Period: 3 hours duration Study Period: 15 minutes duration Permitted Materials: One A4

More information

The Locally Nameless Representation

The Locally Nameless Representation Noname manuscript No. (will be inserted by the editor) The Locally Nameless Representation Arthur Charguéraud Received: date / Accepted: date Abstract This paper provides an introduction to the locally

More information

Lecture 7: Dynamic Programming I: Optimal BSTs

Lecture 7: Dynamic Programming I: Optimal BSTs 5-750: Graduate Algorithms February, 06 Lecture 7: Dynamic Programming I: Optimal BSTs Lecturer: David Witmer Scribes: Ellango Jothimurugesan, Ziqiang Feng Overview The basic idea of dynamic programming

More information

CS 220: Discrete Structures and their Applications. Mathematical Induction in zybooks

CS 220: Discrete Structures and their Applications. Mathematical Induction in zybooks CS 220: Discrete Structures and their Applications Mathematical Induction 6.4 6.6 in zybooks Why induction? Prove algorithm correctness (CS320 is full of it) The inductive proof will sometimes point out

More information

First-Order Predicate Logic. Basics

First-Order Predicate Logic. Basics First-Order Predicate Logic Basics 1 Syntax of predicate logic: terms A variable is a symbol of the form x i where i = 1, 2, 3.... A function symbol is of the form fi k where i = 1, 2, 3... und k = 0,

More information

REAL ANALYSIS II TAKE HOME EXAM. T. Tao s Lecture Notes Set 5

REAL ANALYSIS II TAKE HOME EXAM. T. Tao s Lecture Notes Set 5 REAL ANALYSIS II TAKE HOME EXAM CİHAN BAHRAN T. Tao s Lecture Notes Set 5 1. Suppose that te 1, e 2, e 3,... u is a countable orthonormal system in a complex Hilbert space H, and c 1, c 2,... is a sequence

More information

Axiomatic Semantics. Semantics of Programming Languages course. Joosep Rõõmusaare

Axiomatic Semantics. Semantics of Programming Languages course. Joosep Rõõmusaare Axiomatic Semantics Semantics of Programming Languages course Joosep Rõõmusaare 2014 Direct Proofs of Program Correctness Partial correctness properties are properties expressing that if a given program

More information

Models of Computation. by Costas Busch, LSU

Models of Computation. by Costas Busch, LSU Models of Computation by Costas Busch, LSU 1 Computation CPU memory 2 temporary memory input memory CPU output memory Program memory 3 Example: f ( x) x 3 temporary memory input memory Program memory compute

More information

COP4020 Programming Languages. Introduction to Axiomatic Semantics Prof. Robert van Engelen

COP4020 Programming Languages. Introduction to Axiomatic Semantics Prof. Robert van Engelen COP4020 Programming Languages Introduction to Axiomatic Semantics Prof. Robert van Engelen Assertions and Preconditions Assertions are used by programmers to verify run-time execution An assertion is a

More information

Shared on QualifyGate.com

Shared on QualifyGate.com CS-GATE-05 GATE 05 A Brief Analysis (Based on student test experiences in the stream of CS on 8th February, 05 (Morning Session) Section wise analysis of the paper Section Classification Mark Marks Total

More information

CSE20: Discrete Mathematics

CSE20: Discrete Mathematics Spring 2018 Summary Today: Induction, Program Correctness Reading: Chap. 5 Division Theorem Theorem: For every integer a and positive integer d 1, there exist integers q, r such that a = qd + r and 0 r

More information

Mariusz Jurkiewicz, Bogdan Przeradzki EXISTENCE OF SOLUTIONS FOR HIGHER ORDER BVP WITH PARAMETERS VIA CRITICAL POINT THEORY

Mariusz Jurkiewicz, Bogdan Przeradzki EXISTENCE OF SOLUTIONS FOR HIGHER ORDER BVP WITH PARAMETERS VIA CRITICAL POINT THEORY DEMONSTRATIO MATHEMATICA Vol. XLVIII No 1 215 Mariusz Jurkiewicz, Bogdan Przeradzki EXISTENCE OF SOLUTIONS FOR HIGHER ORDER BVP WITH PARAMETERS VIA CRITICAL POINT THEORY Communicated by E. Zadrzyńska Abstract.

More information

CSE548, AMS542: Analysis of Algorithms, Fall 2017 Date: Oct 26. Homework #2. ( Due: Nov 8 )

CSE548, AMS542: Analysis of Algorithms, Fall 2017 Date: Oct 26. Homework #2. ( Due: Nov 8 ) CSE548, AMS542: Analysis of Algorithms, Fall 2017 Date: Oct 26 Homework #2 ( Due: Nov 8 ) Task 1. [ 80 Points ] Average Case Analysis of Median-of-3 Quicksort Consider the median-of-3 quicksort algorithm

More information

Theory of Computation

Theory of Computation Theory of Computation Prof. Michael Mascagni Florida State University Department of Computer Science 1 / 33 This course aims to cover... the development of computability theory using an extremely simple

More information

Colby College Catalogue

Colby College Catalogue Colby College Digital Commons @ Colby Colby Catalogues College Archives: Colbiana Collection 1866 Colby College Catalogue 1866-1867 Colby College Follow this and additional works at: http://digitalcommons.colby.edu/catalogs

More information

Hoare Calculus and Predicate Transformers

Hoare Calculus and Predicate Transformers Hoare Calculus and Predicate Transformers 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

46 D b r 4, 20 : p t n f r n b P l h tr p, pl t z r f r n. nd n th t n t d f t n th tr ht r t b f l n t, nd th ff r n b ttl t th r p rf l pp n nt n th

46 D b r 4, 20 : p t n f r n b P l h tr p, pl t z r f r n. nd n th t n t d f t n th tr ht r t b f l n t, nd th ff r n b ttl t th r p rf l pp n nt n th n r t d n 20 0 : T P bl D n, l d t z d http:.h th tr t. r pd l 46 D b r 4, 20 : p t n f r n b P l h tr p, pl t z r f r n. nd n th t n t d f t n th tr ht r t b f l n t, nd th ff r n b ttl t th r p rf l

More information

Cataraqui Source Protection Area Stream Gauge Locations

Cataraqui Source Protection Area Stream Gauge Locations Cqu u P m Gu s Ts Ez K Ts u s sp E s ms P Ps s m m C Y u u I s Ts x C C u R 4 N p Ds Qu H Em us ms p G Cqu C, s Ks F I s s Gqu u Gqu s N D U ( I T Gqu C s C, 5 Rs p, Rs 15, 7 N m s m Gus - Ps P f P 1,

More information

Th n nt T p n n th V ll f x Th r h l l r r h nd xpl r t n rr d nt ff t b Pr f r ll N v n d r n th r 8 l t p t, n z n l n n th n rth t rn p rt n f th v

Th n nt T p n n th V ll f x Th r h l l r r h nd xpl r t n rr d nt ff t b Pr f r ll N v n d r n th r 8 l t p t, n z n l n n th n rth t rn p rt n f th v Th n nt T p n n th V ll f x Th r h l l r r h nd xpl r t n rr d nt ff t b Pr f r ll N v n d r n th r 8 l t p t, n z n l n n th n rth t rn p rt n f th v ll f x, h v nd d pr v n t fr tf l t th f nt r n r

More information