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

Size: px
Start display at page:

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

Transcription

1 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: from r ãñ pi 1q! to r ãñ i! After the loop: r ãñ n! Loop invariant pi : int Ñ Hpropq that applies for any i P r2, n ` 1s: I i r ãñ pi 1q! 1 / 70 2 / 70 Reasoning rule for for-loops The repeat construct Reasoning rule for the case a ď b: General rule: H Ź I P ra, bs. ti iu t tλtt. I pi ` 1qu I pb ` 1q Ź Q tt thu pfor i a to b do tq tqu H Ź I P ra, bs. ti iu t tλtt. I pi ` 1qu I pmax a pb ` 1qq Ź Q tt thu pfor i a to b do tq tqu New language construct repeat t such that: repeat t ÝÑ if t then prepeat tq else pq Encodings: repeat t do pq while t do t 1 while t 2 repeat pt 1 ; t 2 q while t 1 do t 2 repeat pif t 1 then pt 2 ; trueq else falseq 3 / 70 4 / 70

2 Reasoning rule for repeat Example of a repeat loop Reduction rule: repeat t ÝÑ if t then prepeat tq else pq H Ź I tiu t tλb. if b then I else pq ttqu thu prepeat tq tqu Reasoning rule (partial correctness): H Ź I tiu t tλb. if b then I else pq ttqu thu prepeat tq tqu Remark: the post-condition uses a logical if-then-else. let facto n = let r = ref 1 in let k = ref 2 in repeat let i =!k in if i <= n then begin let n =!r in r := i * n; incr k; true end else false done;!r Instantiation of the rule: H k ãñ 2 r ãñ 1 Q λtt. k ãñ pn ` 1q r ãñ n! I Di. k ãñ i r ãñ pi 1q! r2 ď i ď n ` 1s 5 / 70 6 / 70 Termination of loops: an example Termination of loops let facto n = let r = ref 1 in let k = ref 2 in repeat let i =!k in if i <= n then begin let n =!r in r := i * n; incr k; true end else false done;!r With indexed invariant to justify termination: H k ãñ 2 r ãñ 1 Q λtt. k ãñ pn ` 1q r ãñ n! I i k ãñ i r ãñ pi 1q! r2 ď i ď n ` 1s i 0 2 i 1 ă i i ă i 1 ď n ` 1 păq is well-founded Generalization to total H Ź I tiu t tλb. if b then I else pq ttqu thu prepeat tq tqu H Ź I X 0 ti Xu t tλb. if b then pdy. I Y ry ă Xsq else pq ttqu thu prepeat tq tqu where A is a user-specified type, px 0 : Aq, px : Aq, pi : A Ñ Hpropq, and pă : A Ñ A Ñ Propq is a well-founded relation. 7 / 70 8 / 70

3 Induction instead of invariants Length with a while loop let facto n = let r = ref 1 in let k = ref 2 in repeat let i =!k in if i <= n then begin let n =!r in r := i * n; incr k; true end else false done;!r Let t denote the body of the repeat loop above. We prove by induction on i (going up to n ` 1) that the following triple tk ãñ i r ãñ pi 1q r2 ď i ď n ` 1su prepeat t doneq tλtt. k ãñ pn ` 1q r ãñ n!u Step 1 unfold the loop body once: tk ãñ i r ãñ pi 1q r2 ď i ď n ` 1su pif t then repeat t else ()q tλtt. k ãñ pn ` 1q r ãñ n!u Step 2 invoke the induction hypothesis on: let rec mlength (p: a cell) = let t = ref 0 in let f = ref p in while!f!= null do incr t; f := (!f).tl; done!t k ãñ pi ` 1q r ãñ i r2 ď i ` 1 ď n ` tp Mlist Lu pmlength pq tλn. rn length Ls p Mlist Lu 9 / / 70 Length with a while loop: invariant Length with a recursive function Loop invariant: I DqL 1 L 2. f ãñ q p MlistSeg q L 1 q Mlist L 2 rl L 1``L 2 s t ãñ L 1 let rec mlength (p: a cell) = if p == null then 0 else 1 + mlength p.tl Specification proved by induction on L, using the frame rule at each tp Mlist Lu pmlength pq tλn. rn length Ls p Mlist Lu 11 / / 70

4 Length with a while loop Length with a while loop: induction let rec mlength (p: a cell) = let t = ref 0 in let f = ref p in while!f!= null do incr t; f := (!f).tl; done!t Starting from a state of the form: q Mlist L 2 f ãñ q t ãñ n the while loop reaches the state: q Mlist L 2 f ãñ null t ãñ pn ` length L 2 q begin: q Mlist L 2 f ãñ q t ãñ n focus: q ÞÑ t hd=x; tl=q 1 u q 1 Mlist L 1 2 f ãñ q t ãñ n incr: q ÞÑ t hd=x; tl=q 1 u q 1 Mlist L 1 2 f ãñ q t ãñ n ` 1 shift: q ÞÑ t hd=x; tl=q 1 u q 1 Mlist L 1 2 f ãñ q1 t ãñ n ` 1 frame: q 1 Mlist L 1 2 f ãñ q1 t ãñ n ` 1 induc: q 1 Mlist L 1 2 f ãñ null t ãñ n ` 1 ` L1 2 exit-fr: q ÞÑ t hd=x; tl=q 1 u q 1 Mlist L 1 2 f ãñ null t ãñ n ` 1 ` L1 2 unfoc: q Mlist L 2 f ãñ null t ãñ n ` L 2 13 / / 70 Summary Towards an interpretation of H Ź I P ra, bs. ti iu t tλtt. I pi ` 1qu I pmax a pb ` 1qq Ź Q tt thu pfor i a to b do tq tqu H Ź I tiu t tλb. if b then I else pq ttqu thu prepeat tq tqu H Ź I X 0 ti Xu t tλb. if b then pdy. I Y ry ă Xsq else pq ttqu thu prepeat tq tqu Assume in this slide that triples describe the entire state. A triple thu t tλx. H 1 u is interpreted in total correctness H m Dv. Dm 1. t {m ^ pxv{xy H 1 q m 1 Let Q λx. H 1. We have Q v xv{xy H 1. So, a triple thu t tqu is interpreted H m Dv. Dm 1. t {m ^ Q v m 1 + Reasoning about loops by induction allows exploiting the frame rule. 15 / / 70

5 Towards an interpretation of triples Soundness theorem In Separation Logic, a triple describes only a part m 1 of the heap. The rest of the heap, call it m 2, is assumed to remain unchanged. A triple thu t tqu can be interpreted 1 m 2. # H m1 m 1 K m 2 Dv. Dm 1 1. $ & % t {m1 Zm 2 1 Zm 2 Q v m 1 1 m 1 1 K m 2 Theorem (Soundness) If the triple thu t tqu holds 1 m 2. # H m1 m 1 K m 2 Dvm 1 1m 3. $ & % t {m1 Zm 2 1 Zm 2 Zm 3 Q v m 1 1 m 1 1 K m 2 K m 3 Above, m 3 describes the part of the heap dropped during the reasoning. 17 / / 70 Soundness proof Proof case: sequence thu t 1 tq 1 u tq 1 ttu t 2 tqu thu pt 1 ; t 2 q tqu t 1{m ó tt {m 1 t 2{m 1 ó v {m 2 pt 1 ; t 2 q {m ó v {m 2 Proof by induction over the size of the derivation of thu t tqu 1 m 2. m 1 K m 2 ^ H m 1 Dvm 1 1. t {m1 Zm 2 1 Zm 2 ^ Q v m 1 1 Ñ Assume m 1 K m 2 and H m 1. Our goal is to find v and m 1 1 such that: pt 1 ; t 2 q {m1 Zm 2 1 Zm 2 ^ Q v m 1 1 Ñ By IH1 applied to m 1 K m 2 and H m 1, we get v 1 and m 1 11 such that: (For simplicity, we leave m 1 1 K m 2 implicit and ignore garbage collection.) t 1{m1 Zm 2 ó v 1{m 1 11 Zm 2 ^ Q 1 v 1 m 1 11 Ñ By typing, v 1 must be tt. In particular, we have Q 1 tt m Ñ By IH2 applied to m 1 11 K m 2 and pq 1 ttq m 1 11, we get v 2 and m 1 12 s.t.: t 2{m 1 11 Zm 2 ó v 2{m 1 12 Zm 2 ^ Q v 2 m 1 12 Ñ We provide v 2 for v and m 1 12 for m / / 70

6 Summary Presentation Theorem (Soundness) If the triple thu t tqu holds 1 m 2. # H m1 m 1 K m 2 Dvm 1 1m 3. $ & % t {m1 Zm 2 1 Zm 2 Zm 3 Q v m 1 1 m 1 1 K m 2 K m 3 Pure pre-conditions as hypotheses: trp s Hu t tqu written as P thu t tqu 21 / / 70 Function apply Function twice let apply f x = f x Specification: let twice f = f(); f() Same thu pf xq tqu thu papply f xq tqu 1 Q. ^ thu pf pqq tλtt. H 1 u th 1 u pf pqq tqu thu ptwice fq th r thu pf xq tqu su papply f xq tqu 23 / / 70

7 Function repeat Function acting over a reference let repeat n f = for i = 0 to n-1 do f() done let refapply r f = r := f!r Exercise: specify the function refapply, first assuming f to be pure, and then assuming f to modify the state from H to H 1. Exercise: specify the function repeat, using an invariant I : int Ñ p@i P r0, nq. ti iu pf pqq tλtt. I pi ` 1quq ti 0u prepeat n fq ti 1 rhh 1 r. tr su pf vq tλy. ry v 1 su tr ãñ vu prefapply r fq tλtt. r ãñ v 1 u thu pf vq tλy. ry v 1 s H 1 u tpr ãñ vq Hu prefapply r fq tλtt. pr ãñ v 1 q H 1 u 25 / / 70 Iteration over a pure list Length using iter let rec iter f l = [] -> () x::t -> f x; iter f t Specification using an invariant pi : list α Ñ where L&x L``px :: nilq. let length l = let r = ref 0 in iter (fun x -> incr r) l;!r Invariant: I k r ãñ k. Specialization of the specification to I and f: `@xk. tr ãñ k u pincr rq tλtt. r ãñ k ` 1u tr ãñ 0u piter f lq tλtt. r ãñ l u 27 / / 70

8 Sum using iter let sum l = let r = ref 0 in iter (fun x -> r :=!r + x) l;!r Invariant: I k r ãñ Sum k Verification of iter let rec iter f l = [] -> () x::t -> f x; iter f t How to prove that the code satisfies its specification? where: Sum k Fold p`q 0 k 29 / / 70 Verification of iter ti ku pf xq tλtt. I pk&xqu Prove: Prove a generalized ti ku piter f sq tλtt. I pk``squ Verification of iter let rec iter f l = [] -> () x::t -> f x; iter f t By induction on l: ti ku pf xq tλtt. I pk&xqu ti ku piter f sq tλtt. I pk``squ Case s nil. We have ti ku piter f sq tλtt. I pk``nilqu Case s x :: t. By the rule for sequences: ti ku pf xq tλtt. I pk&xqu ti pk&xqu piter f tq tλtt. I ppk&xq``tqu ti ku pf x; iter f tq ti pk``squ because pk&xq``t k``px :: tq k``s. 31 / / 70

9 Constraints over the items Constraints over the items, in order Problem for computing b a? x1 ` x 2 ` x 3. Problem for computing? x 1 `... `?x n. iter (fun x -> r := sqrt (!r +. x)) [2.; -1.; 3.] iter (fun x -> r :=!r +. sqrt x) [2.0; 3.0] Generalized `@xk. x P l ti ku pf xq tλtt. I pk&xqu Most-general `@xks. l k``x :: s ti ku pf xq tλtt. I pk&xqu 33 / / 70 Invariant on remaining items Specification of fold-left Invariant on the list of processed items: Description: Code: fold f a r6 :: 4 :: 7s f pf pf a 6q 4q 7 Invariant on the list of remaining items: `@xs. ti 1 px :: squ pf xq tλtt. I 1 su let rec fold f a l = [] -> a x::k -> fold f (f a x) k ti 1 lu piter f lq tλtt. I 1 nilu Specification: Derivable using: I k Ds. rl k``ss I 1 `@xik. tj i ku pf i xq tλj. J j pk&xqu tj a nilu pfold f a lq tλb. J b lu 35 / / 70

10 Application of fold-left Forall tj i ku pf i xq tλj. J j pk&xqu tj a nilu pfold f a lq tλb. J b lu let r = ref 0 let sum_count l = fold (fun a x -> incr r; a+x) 0 l Exercise: give the invariant of fold in the function sum_count. where Sum k Fold p`q 0 k. J i k pr ãñ k q ri Sum ks Definition of Forall P L : Forall P nil Definition of Forall2 P L 1 L 2 : Forall2 P nil nil P x Forall P L Forall P px :: Lq P x 1 x 2 Forall2 P L 1 L 2 Forall2 P px 1 :: L 1 q px 2 :: L 2 q 37 / / 70 Specification of map A general specification of map let rec map f l = [] -> [] x::k -> (f x)::(map f k) Exercise: give a specification to map using Forall2, assuming f to be pure. Specification of l. Specification of p@x. tr su pf xq tλx 1. rp x x 1 suq tr su pmap f lq tλl 1. rforall2 P l l 1 l. p@x. tr su pf xq tλx 1. rp x x 1 suq tr su pmap f lq tλl 1. rforall2 P l l 1 su Combining the Il. `@xk. ti ku pf xq tλx 1. rp x x 1 s I pk&xqu ti nilu pmap f lq tλl 1. rforall2 P l l 1 s I lu 39 / / 70

11 Another general specification of map Specification of Il. ti ku pf xq tλx 1. rp x x 1 s J pk&xqu ti nilu pmap f lq tλl 1. rforall2 P l l 1 s I lu let rec find f l = [] -> None x::k -> if f x then Some x else find f k Alternative `@xkk 1. tj k k 1 u pf xq tλx 1. J pk&xq pk 1 &x 1 qu tj nil nilu pmap f lq tλl 1. J l l 1 u l. p@x. tr su pf xq tλb. rb true ô P xsuq tr su pfind f lq tλo. r match o with None Forall p P q l Some x Dkt. l k``x :: t ^ Forall p P q k ^ P x su 41 / / 70 Specification of sort Summary List.sort (fun x y -> x - y) [2;4;5;3;2;9] `@xik. tj i ku pf i xq tλj. J j ^ total-order pĺq p@xy. tr su pf x yq tλn. rn ď 0 ô x ĺ ysuq tr su psort f lq tλl 1. rpermut l l 1 ^ sorted pĺq l 1 su tj a nilu pfold f a lq tλb. J b lu `@xkk 1. tj k k 1 u pf xq tλx 1. J pk&xq pk 1 &x 1 qu tj nil nilu pmap f lq tλl 1. J l l 1 u Include the hypothesis l k``x :: s if the position of x matters. Specification of the list of past items or of remaining items. Boolean tr su pf xq tλb. rb true ô P xsu. Order tr su pf x yq tλn. rn ď 0 ô x ĺ ysu. 43 / / 70

12 Iterating over a mutable list Iterating over a mutable list let rec miter f p = if p == null then () else (f p.hd; miter f p.tl) Recall the specification of iter on pure Specification of pil. tp Mlist l I nilu pmiter f pq tλtt. p Mlist l I lu 45 / / 70 Mapping a function over a mutable list Mapping a function over a mutable list Recall the specification of map on pure `@xkk 1. tj k k 1 u pf xq tλx 1. J pk&xq pk 1 &x 1 qu tj nil nilu pmap f lq tλl 1. J l l 1 u Mapping a function over elements, in place: Exercise: specify the function mmap, assuming f to be pure. let rec mmap f p = if p == null then () else (p.hd <- f p.hd; mmap f pjl. `@xkk 1. tj k k 1 u pf xq tλx 1. J pk&xq pk 1 &x 1 qu tp Mlist l J nil nilu pmmap f pq tλtt. Dl 1. p Mlist l 1 J l l 1 u 47 / / 70

13 Function mfind Summary From pure lists: Specification: To imperative l. tr su pf xq tλb. rb istrue pp xqsuq tp Mlist lu pmfind f pq tλo. match o with None p Mlist l rforall p P q ls Some q Dkt. p MlistSeg q k q Mlist px :: tq rl k``x :: t ^ Forall p P q k ^ P xs u tp Mlist l I nilu pmiter f pq tλtt. p Mlist l I lu Post-conditions may return different shapes of heap: match o with None p Mlist l rforall p P q ls Some q Dkt. p MlistSeg q k q Mlist px :: tq rl k``x :: t ^ Forall p P q k ^ P xs 49 / / 70 Deallocation Application to file handles Remove the garbage collection rule: Goal: ensure that if a file is open then it is eventually closed. Add the free function: thu t tq H 1 u thu t tqu Representation predicate: f File L where pf : locq and pl : list charq tr Ref vu pfree rq tλtt. r su Terminating on the empty heap ensures the absence of memory leak: tr su t tλn. rp nsu Operations on files: tr su pfopen sq tλf. DL. f File Lu tf File pc :: Lqu pfread fq tλx. rx cs f File Lu tf File Lu pfclose fq tλtt. r su 51 / / 70

14 Implicit parallelism Shared data structures Parallel pairs in parallel ML: let (x,y) = ( f(), g() ) Separation Logic rule for parallel pairs: th 1 u t 1 tq 1 u th 2 u t 2 tq 2 u th 1 H 2 u p t 1, t 2 q tq 1 Q 2 u where Q 1 Q 2 λpx 1, x 2 q. Q 1 x 1 Q 2 x 2 let rec sum t i j = if j - i < 100 then let r = ref 0 in for k = i to j-1 do r :=!r + t.(k) done;!r else let m = (i+j) / 2 in let (s1,s2) = ( sum t i m, sum t m j ) in s1 + s2 53 / / 70 Concurrency Read-only permissions From read-write to read-only permissions: Several threads may concurrently read shared mutable data. The main thread should ultimately get back its write access. Threads may acquire locks for writing in shared mutable data. r ãñ v Ź r ãñ ro v Read-only permissions are duplicatable: pr ãñ ro vq Ź pr ãñ ro vq pr ãñ ro vq Read-only permissions disable writing: Ñ Concurrent Separation Logic, not covered in this course, additionally supports concurrent read/write accesses to shared memory cells. New: tr su pref vq tλr. r ãñ vu tr ãñ v 1 u pr := vq tλtt. r ãñ vu tr ãñ vu p!rq tλx. rx vs r ãñ vu tr ãñ ro vu p!rq tλx. rx vs r ãñ ro vu 55 / / 70

15 Fractional permissions Permission splitting and merging: Read-only permissions as arbitrary fractions We define: r ãñ v pr 1{2 ãñ vq pr 1{2 ãñ vq r ãñ ro v Dα. pr ãñ α vq with α P p0, 1s More generally, pr ãñ vq is a shorthand for pr 1 ãñ vq and: Duplicatibility P p0, 1s. pr α`β ãñ vq pr α ãñ vq pr β ãñ vq pr ãñ ro vq Ź pr ãñ ro vq pr ãñ ro vq tr su pref vq tλr. pr ãñ vqu tr ãñ v 1 u pr := vq tλtt. pr ãñ vqu tr α ãñ vu p!rq tλx. rx vs pr α ãñ vqu Proof: pdα. r α ãñ vq Ź pdα. r α ãñ vq pdα. r α ãñ vq because, for any given α, we have: pr α ãñ vq Ź pr α{2 ãñ vq pr α{2 ãñ vq 57 / / 70 Example of concurrent locks Concurrent locks A lock protects a piece of heap described by some invariant H: let r = ref 0 let s = ref n let p = create_lock() let concurrent_step () = let () = acquire_lock p in incr r; decr s; release_lock p p Lock H Example: p Lock pdi. pr ãñ iq ps ãñ n iqq. thu pcreate_lock ()q tλp. p Lock tp Lock Hu pacquire_lock pq tλtt. th p Lock Hu prelease_lock pq tλtt. r su The existence of a lock is in fact a duplicable information: p ro Lock H. 59 / / 70

16 Exercise: specification of fold-right Description: fold f r6 :: 4 :: 7s a f 6 pf 4 pf 7 aqq Exercises Code: let rec fold_right f l a = [] -> a x::k -> f x (fold_right f k a) Give a specification to fold-right. 61 / / 70 Solution: specification of fold-right Exercise: reasoning rule for while loops Description: fold f r6 :: 4 :: 7s a f 6 pf 4 pf 7 aqq Code: let rec fold_right f l a = [] -> a x::k -> f x (fold_right f k a) Give a direct reasoning rule for while loops, for partial correctness thu pwhile t 1 do t 2 q tqu Jla. `@xik. tj i ku pf x iq tλj. J j px :: kqu tj a nilu pfold f l aq tλb. J b lu 63 / / 70

17 Solution: reasoning rule for while loops Exercise: verification of map The loop invariant I describes the state between every iterations. The post-condition J describes the state after the evaluation of t 1. H Ź I tiu t 1 tju tj trueu t 2 tλtt. Iu J false Ź Q tt thu pwhile t 1 do t 2 q tqu where pi : Hpropq and pj : bool Ñ Hpropq. let rec map f l = [] -> [] x::k -> (f x)::(map f k) Prove that the code satisfies the l. p@x. tr su pf xq tλx 1. rp x x 1 suq tr su pmap f lq tλl 1. rforall2 P l l 1 su 65 / / 70 Solution: verification of map let rec map f l = [] -> [] x::k -> let x = f x in let k = map f k in l. p@x. tr su pf xq tλx 1. rp x x 1 suq tr su pmap f lq tλl 1. rforall2 P l l 1 su Proof by induction on l. Ñ Case l nil. Use the fact: Forall2 P nil nil. Ñ Case l x :: t. tr su pf xq tλx 1. rp x x 1 su tr su pmap f kq tλk 1. rforall2 P k k 1 su by assumption by induction hypothesis tr su px 1 :: k 1 q tλl 1. rforall2 P l l 1 su by Forall2 P px :: kq px 1 :: k 1 q. Exercise: soundness of the frame rule In the proof of the soundness theorem (without garbage 1 m 2. m 1 K m 2 ^ H m 1 Dvm 1 1. t {m1 Zm 2 1 Zm 2 ^ Q v m 1 1 prove the soundness of the frame rule: H H 1 H 2 th 1 u t tq 1 u Q 1 H 2 Q thu t tqu Hint: assume m 1 K m 2 and H m 1 and the induction hypothesis, which 3 m 4. m 3 K m 4 ^ H 1 m 3 Dvm 1 3. t {m3 Zm 4 3 Zm 4 ^ Q 1 v m 1 3 and exhibit v and m 1 1 such that t {m 1 Zm 2 1 Zm 2 and Q v m / / 70

18 Solution: soundness of the frame rule Solution: soundness of the frame rule H H 1 H 2 th 1 u t tq 1 u Q 1 H 2 Q thu t tqu Ñ Assume m 1 K m 2 and H m 1. Our goal is to find v and m 1 1 such that: t {m1 Zm 2 1 Zm 2 ^ Q v m 1 1 Ñ Since H m 1, we have ph 1 H 2 q m 1, so there exists m 11 and m 12 s.t.: m 1 m 11 Z m 12 ^ H 1 m 11 ^ H 2 m 12 Ñ By IH applied to m 11 K pm 12 Z m 2 q, we get v and m 1 11 such that: t {m11 Zpm 12 Zm 2 q 11 Zpm 12 Zm 2 q ^ Q 1 v m 1 11 Ñ By definition of star, we have ppq 1 vq H 2 q pm 1 11 Z m 12q. Ñ Q 1 H 2 Q implies ppq 1 vq H 2 q pq vq. Thus, Q v pm 1 11 Z m 12q. Ñ We provide pm 1 11 Z m 12q for m 1 1 and v for v. We can check: t {pm11 Zm 12 qzm 2 ó v {pm 1 11 Zm 12 qzm 2 ^ Q v pm 1 11 Z m 12 q Goal: t {m1 Zm 2 1 Zm 2 Instantiation: t {pm11 Zm 12 qzm 2 ó v {pm 1 11 Zm 12 qzm 2 Induction hyp.: t {m11 Zpm 12 Zm 2 q 11 Zpm 12 Zm 2 q 69 / / 70

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

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

Focus rules for segments. Focus and defocus rules for concatenation. Mlength with a while loop. Mlength with a while loop. 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

More information

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 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

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

~,. :'lr. H ~ j. l' ", ...,~l. 0 '" ~ bl '!; 1'1. :<! f'~.., I,," r: t,... r':l G. t r,. 1'1 [<, ."" f'" 1n. t.1 ~- n I'>' 1:1 , I. <1 ~'..

~,. :'lr. H ~ j. l' , ...,~l. 0 ' ~ bl '!; 1'1. :<! f'~.., I,, r: t,... r':l G. t r,. 1'1 [<, . f' 1n. t.1 ~- n I'>' 1:1 , I. <1 ~'.. ,, 'l t (.) :;,/.I I n ri' ' r l ' rt ( n :' (I : d! n t, :?rj I),.. fl.),. f!..,,., til, ID f-i... j I. 't' r' t II!:t () (l r El,, (fl lj J4 ([) f., () :. -,,.,.I :i l:'!, :I J.A.. t,.. p, - ' I I I

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

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

Representation of Piecewise Linear Interval Functions

Representation of Piecewise Linear Interval Functions Representation of Piecewise Linear Interval Functions Verimag Research Report n o TR-2012-16 October 2, 2012 Reports are downloadable at the following address http://www-verimag.imag.fr Unité Mite de Recherche

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

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

The essence and origins of FRP

The essence and origins of FRP The essence and origins of FRP Conal Elliott June 13, 2015 Conal Elliott The essence and origins of FRP June 13, 2015 1 / 31 What is FRP? Conal Elliott The essence and origins of FRP June 13, 2015 2 /

More information

L11: Algebraic Path Problems with applications to Internet Routing Lecture 9

L11: Algebraic Path Problems with applications to Internet Routing Lecture 9 L11: Algebraic Path Problems with applications to Internet Routing Lecture 9 Timothy G. Griffin timothy.griffin@cl.cam.ac.uk Computer Laboratory University of Cambridge, UK Michaelmas Term, 2017 tgg22

More information

A TASTE OF COMBINATORIAL REPRESENTATION THEORY. MATH B4900 5/02/2018

A TASTE OF COMBINATORIAL REPRESENTATION THEORY. MATH B4900 5/02/2018 A TASTE OF COMBINATORIAL REPRESENTATION THEORY. MATH B4900 5/02/2018 Young s Lattice is an infinite leveled labeled graph with vertices and edges as follows. Vertices: Label vertices in label vertices

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

Very quick introduction to the conformal group and cft

Very quick introduction to the conformal group and cft CHAPTER 1 Very quick introduction to the conformal group and cft The world of Conformal field theory is big and, like many theories in physics, it can be studied in many ways which may seem very confusing

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

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

Hoare Logic I. Introduction to Deductive Program Verification. Simple Imperative Programming Language. Hoare Logic. Meaning of Hoare Triples

Hoare Logic I. Introduction to Deductive Program Verification. Simple Imperative Programming Language. Hoare Logic. Meaning of Hoare Triples Hoare Logic I Introduction to Deductive Program Verification Işıl Dillig Program Spec Deductive verifier FOL formula Theorem prover valid contingent Example specs: safety (no crashes), absence of arithmetic

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

Iris: Higher-Order Concurrent Separation Logic. Lecture 9: Concurrency Intro and Invariants

Iris: Higher-Order Concurrent Separation Logic. Lecture 9: Concurrency Intro and Invariants 1 Iris: Higher-Order Concurrent Separation Logic Lecture 9: Concurrency Intro and Invariants Lars Birkedal Aarhus University, Denmark November 21, 2017 Overview Earlier: Operational Semantics of λ ref,conc

More information

Axiomatic Semantics. Hoare s Correctness Triplets Dijkstra s Predicate Transformers

Axiomatic Semantics. Hoare s Correctness Triplets Dijkstra s Predicate Transformers Axiomatic Semantics Hoare s Correctness Triplets Dijkstra s Predicate Transformers Goal of a program = IO Relation Problem Specification Properties satisfied by the input and expected of the output (usually

More information

HOPF ALGEBRAS AND LIE ALGEBRAS UCHICAGO PRO-SEMINAR - JANUARY 9, 2014

HOPF ALGEBRAS AND LIE ALGEBRAS UCHICAGO PRO-SEMINAR - JANUARY 9, 2014 HOPF ALGEBRAS AND LIE ALGEBRAS UCHICAGO PRO-SEMINAR - JANUARY 9, 2014 Hopf Algebras Lie Algebras Restricted Lie Algebras Poincaré-Birkhoff-Witt Theorem Milnor-Moore Theorem Cohomology of Lie Algebras Remark

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

Deductive Verification

Deductive Verification Deductive Verification Mooly Sagiv Slides from Zvonimir Rakamaric First-Order Logic A formal notation for mathematics, with expressions involving Propositional symbols Predicates Functions and constant

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

Exhibit 2-9/30/15 Invoice Filing Page 1841 of Page 3660 Docket No

Exhibit 2-9/30/15 Invoice Filing Page 1841 of Page 3660 Docket No xhibit 2-9/3/15 Invie Filing Pge 1841 f Pge 366 Dket. 44498 F u v 7? u ' 1 L ffi s xs L. s 91 S'.e q ; t w W yn S. s t = p '1 F? 5! 4 ` p V -', {} f6 3 j v > ; gl. li -. " F LL tfi = g us J 3 y 4 @" V)

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

Quantum Functional Programming Language & Its Denotational Semantics

Quantum Functional Programming Language & Its Denotational Semantics Quantum Functional Programming Language & Its Denotational Semantics Ichiro Hasuo Dept. Computer Science University of Tokyo Naohiko Hoshino Research Inst. for Math. Sci. Kyoto University Talk based on:

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

Last time: Recall that the fibers of a map ϕ : X Ñ Y are the sets in ϕ 1 pyq Ď X which all map to the same element y P Y.

Last time: Recall that the fibers of a map ϕ : X Ñ Y are the sets in ϕ 1 pyq Ď X which all map to the same element y P Y. Last time: Recall that the fibers of a map ϕ : X Ñ Y are the sets in ϕ 1 pyq Ď X which all map to the same element y P Y. Last time: Recall that the fibers of a map ϕ : X Ñ Y are the sets in ϕ 1 pyq Ď

More information

Axiomatic Semantics. Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 CSE

Axiomatic Semantics. Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 CSE Axiomatic Semantics Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 CSE 6341 1 Outline Introduction What are axiomatic semantics? First-order logic & assertions about states Results (triples)

More information

NOTES WEEK 14 DAY 2 SCOT ADAMS

NOTES WEEK 14 DAY 2 SCOT ADAMS NOTES WEEK 14 DAY 2 SCOT ADAMS We igligt tat it s possible to ave two topological spaces and a continuous bijection from te one to te oter wose inverse is not continuous: Let I : r0, 2πq and let C : tpx,

More information

Iris: Higher-Order Concurrent Separation Logic. Lecture 6: Case Study: foldr

Iris: Higher-Order Concurrent Separation Logic. Lecture 6: Case Study: foldr 1 Iris: Higher-Order Concurrent Separation Logic Lecture 6: Case Study: foldr Lars Birkedal Aarhus University, Denmark November 10, 2017 2 Overview Earlier: Operational Semantics of λ ref,conc e, (h, e)

More information

A Full RNS Implementation of Fan and Vercauteren Somewhat Homomorphic Encryption Scheme

A Full RNS Implementation of Fan and Vercauteren Somewhat Homomorphic Encryption Scheme A Full RNS Implementation of Fan and Vercauteren Somewhat Homomorphic Encryption Scheme Presented by: Vincent Zucca 1 Joint work with: Jean-Claude Bajard 1, Julien Eynard 2 and Anwar Hasan 2 1 Sorbonne

More information

q-de Rham cohomology via Λ-rings

q-de Rham cohomology via Λ-rings q-de Rham cohomology via Λ-rings J.P.Pridham arxiv:1608.07142 1 / 21 q-analogues (Gauss) rns q : qn 1 q 1 1 q... qn 1 rns q! : rns q... r2s q r1s q, ¹ n 1 i 0 n 1 ¹ i 0 p1 p1 n k q : rns q! rn ksq!rksq!

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

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

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

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

Reasoning About Imperative Programs. COS 441 Slides 10b

Reasoning About Imperative Programs. COS 441 Slides 10b Reasoning About Imperative Programs COS 441 Slides 10b Last time Hoare Logic: { P } C { Q } Agenda If P is true in the initial state s. And C in state s evaluates to s. Then Q must be true in s. Program

More information

Timo Latvala. February 4, 2004

Timo Latvala. February 4, 2004 Reactive Systems: Temporal Logic LT L Timo Latvala February 4, 2004 Reactive Systems: Temporal Logic LT L 8-1 Temporal Logics Temporal logics are currently the most widely used specification formalism

More information

A Short Introduction to Hoare Logic

A Short Introduction to Hoare Logic A Short Introduction to Hoare Logic Supratik Chakraborty I.I.T. Bombay June 23, 2008 Supratik Chakraborty (I.I.T. Bombay) A Short Introduction to Hoare Logic June 23, 2008 1 / 34 Motivation Assertion checking

More information

6 Coalgebraic modalities via predicate liftings

6 Coalgebraic modalities via predicate liftings 6 Coalgebraic modalities via predicate liftings In this chapter we take an approach to coalgebraic modal logic where the modalities are in 1-1 correspondence with so-called predicate liftings for the functor

More information

Axiomatic Semantics: Verification Conditions. Review of Soundness and Completeness of Axiomatic Semantics. Announcements

Axiomatic Semantics: Verification Conditions. Review of Soundness and Completeness of Axiomatic Semantics. Announcements Axiomatic Semantics: Verification Conditions Meeting 12, CSCI 5535, Spring 2009 Announcements Homework 4 is due tonight Wed forum: papers on automated testing using symbolic execution 2 Questions? Review

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

Adapted with permission from: Seif Haridi KTH Peter Van Roy UCL. C. Varela; Adapted w. permission from S. Haridi and P. Van Roy 1

Adapted with permission from: Seif Haridi KTH Peter Van Roy UCL. C. Varela; Adapted w. permission from S. Haridi and P. Van Roy 1 Higher-Order Programming: Iterative computation (CTM Section 3.2) Closures, procedural abstraction, genericity, instantiation, embedding (CTM Section 3.6.1) Carlos Varela RPI September 15, 2017 Adapted

More information

First-Order Logic. Resolution

First-Order Logic. Resolution First-Order Logic Resolution 1 Resolution for predicate logic Gilmore s algorithm is correct and complete, but useless in practice. We upgrade resolution to make it work for predicate logic. 2 Recall:

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

Future Self-Guides. E,.?, :0-..-.,0 Q., 5...q ',D5', 4,] 1-}., d-'.4.., _. ZoltAn Dbrnyei Introduction. u u rt 5,4) ,-,4, a. a aci,, u 4.

Future Self-Guides. E,.?, :0-..-.,0 Q., 5...q ',D5', 4,] 1-}., d-'.4.., _. ZoltAn Dbrnyei Introduction. u u rt 5,4) ,-,4, a. a aci,, u 4. te SelfGi ZltAn Dbnyei Intdtin ; ) Q) 4 t? ) t _ 4 73 y S _ E _ p p 4 t t 4) 1_ ::_ J 1 `i () L VI O I4 " " 1 D 4 L e Q) 1 k) QJ 7 j ZS _Le t 1 ej!2 i1 L 77 7 G (4) 4 6 t (1 ;7 bb F) t f; n (i M Q) 7S

More information

Erdinç Dündar, Celal Çakan

Erdinç Dündar, Celal Çakan DEMONSTRATIO MATHEMATICA Vol. XLVII No 3 2014 Erdinç Dündar, Celal Çakan ROUGH I-CONVERGENCE Abstract. In this work, using the concept of I-convergence and using the concept of rough convergence, we introduced

More information

ETIKA V PROFESII PSYCHOLÓGA

ETIKA V PROFESII PSYCHOLÓGA P r a ž s k á v y s o k á š k o l a p s y c h o s o c i á l n í c h s t u d i í ETIKA V PROFESII PSYCHOLÓGA N a t á l i a S l o b o d n í k o v á v e d ú c i p r á c e : P h D r. M a r t i n S t r o u

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

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

MATH 387 ASSIGNMENT 2

MATH 387 ASSIGNMENT 2 MATH 387 ASSIGMET 2 SAMPLE SOLUTIOS BY IBRAHIM AL BALUSHI Problem 4 A matrix A ra ik s P R nˆn is called symmetric if a ik a ki for all i, k, and is called positive definite if x T Ax ě 0 for all x P R

More information

Outline. A recursive function follows the structure of inductively-defined data.

Outline. A recursive function follows the structure of inductively-defined data. Outline A recursive function follows the structure of inductively-defined data. With lists as our example, we shall study 1. inductive definitions (to specify data) 2. recursive functions (to process data)

More information

Midterm Exam. CS 3110: Design and Analysis of Algorithms. June 20, Group 1 Group 2 Group 3

Midterm Exam. CS 3110: Design and Analysis of Algorithms. June 20, Group 1 Group 2 Group 3 Banner ID: Name: Midterm Exam CS 3110: Design and Analysis of Algorithms June 20, 2006 Group 1 Group 2 Group 3 Question 1.1 Question 2.1 Question 3.1 Question 1.2 Question 2.2 Question 3.2 Question 3.3

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

Lecture 4: Probability, Proof Techniques, Method of Induction Lecturer: Lale Özkahya

Lecture 4: Probability, Proof Techniques, Method of Induction Lecturer: Lale Özkahya BBM 205 Discrete Mathematics Hacettepe University http://web.cs.hacettepe.edu.tr/ bbm205 Lecture 4: Probability, Proof Techniques, Method of Induction Lecturer: Lale Özkahya Resources: Kenneth Rosen, Discrete

More information

CSC 7101: Programming Language Structures 1. Axiomatic Semantics. Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11.

CSC 7101: Programming Language Structures 1. Axiomatic Semantics. Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11. Axiomatic Semantics Stansifer Ch 2.4, Ch. 9 Winskel Ch.6 Slonneger and Kurtz Ch. 11 1 Overview We ll develop proof rules, such as: { I b } S { I } { I } while b do S end { I b } That allow us to verify

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

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, 2017 Catch Up / Drop in Lab When Fridays, 15.00-17.00 Where N335, CSIT Building

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

Finite Automata Theory and Formal Languages TMV027/DIT321 LP Recap: Logic, Sets, Relations, Functions

Finite Automata Theory and Formal Languages TMV027/DIT321 LP Recap: Logic, Sets, Relations, Functions Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2017 Formal proofs; Simple/strong induction; Mutual induction; Inductively defined sets; Recursively defined functions. Lecture 3 Ana Bove

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

Lecture Notes: Axiomatic Semantics and Hoare-style Verification

Lecture Notes: Axiomatic Semantics and Hoare-style Verification Lecture Notes: Axiomatic Semantics and Hoare-style Verification 17-355/17-665/17-819O: Program Analysis (Spring 2018) Claire Le Goues and Jonathan Aldrich clegoues@cs.cmu.edu, aldrich@cs.cmu.edu It has

More information

Expected Scott-Suppes Utility Representation

Expected Scott-Suppes Utility Representation Expected Scott-Suppes Utility Representation Nuh Aygün Dalkıran Oral Ersoy Dokumacı Tarık Kara February 7, 2018 1 / 51 1 Introduction Motivation 2 Preliminaries Semiorders Uncertainty Continuity Independence

More information

Dr. Marques Sophie Algebra 1 Spring Semester 2017 Problem Set 9

Dr. Marques Sophie Algebra 1 Spring Semester 2017 Problem Set 9 Dr. Marques Sophie Algebra Spring Semester 207 Office 59 marques@cims.nyu.edu Problem Set 9 Exercise 0 : Prove that every group of order G 28 must contain a normal subgroup of order 7. (Why should it contain

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

CSI Mathematical Induction. Many statements assert that a property of the form P(n) is true for all integers n.

CSI Mathematical Induction. Many statements assert that a property of the form P(n) is true for all integers n. CSI 2101- Mathematical Induction Many statements assert that a property of the form P(n) is true for all integers n. Examples: For every positive integer n: n! n n Every set with n elements, has 2 n Subsets.

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

Element x is R-minimal in X if y X. R(y, x).

Element x is R-minimal in X if y X. R(y, x). CMSC 22100/32100: Programming Languages Final Exam M. Blume December 11, 2008 1. (Well-founded sets and induction principles) (a) State the mathematical induction principle and justify it informally. 1

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

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

Problem One: Order Relations i. What three properties does a binary relation have to have to be a partial order?

Problem One: Order Relations i. What three properties does a binary relation have to have to be a partial order? CS103 Handout 16 Fall 2011 November 4, 2011 Extra Practice Problems Many of you have expressed interest in additional practice problems to review the material from the first four weeks of CS103. This handout

More information

L E C T U R E 2 1 : P R O P E RT I E S O F M AT R I X T R A N S F O R M AT I O N S I I. Wednesday, November 30

L E C T U R E 2 1 : P R O P E RT I E S O F M AT R I X T R A N S F O R M AT I O N S I I. Wednesday, November 30 L E C T U R E 2 1 : P R O P E RT I E S O F M AT R I X T R A N S F O R M AT I O N S I I Wednesday, November 30 1 the range of a linear transformation Let s begin by defining the range of a linear transformation.

More information

Mathematical Induction. How does discrete math help us. How does discrete math help (CS160)? How does discrete math help (CS161)?

Mathematical Induction. How does discrete math help us. How does discrete math help (CS160)? How does discrete math help (CS161)? How does discrete math help us Helps create a solution (program) Helps analyze a program How does discrete math help (CS160)? Helps create a solution (program) q Logic helps you understand conditionals

More information

A Gentle Introduction to Gradient Boosting. Cheng Li College of Computer and Information Science Northeastern University

A Gentle Introduction to Gradient Boosting. Cheng Li College of Computer and Information Science Northeastern University A Gentle Introduction to Gradient Boosting Cheng Li chengli@ccs.neu.edu College of Computer and Information Science Northeastern University Gradient Boosting a powerful machine learning algorithm it can

More information

Imperative Insertion Sort

Imperative Insertion Sort Imperative Insertion Sort Christian Sternagel October 11, 2017 Contents 1 Looping Constructs for Imperative HOL 1 1.1 While Loops............................ 1 1.2 For Loops.............................

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

STAT111 - Homework 3 - Solutions

STAT111 - Homework 3 - Solutions STAT111 - Homework 3 - Solutions 30 points in total Problem 1 (IPS 4.39), 3 points Let A at least one of them is universal donor, then A c = all of them are not universal donor. By complement rule. P paq

More information

On Borel maps, calibrated σ-ideals and homogeneity

On Borel maps, calibrated σ-ideals and homogeneity On Borel maps, calibrated σ-ideals and homogeneity Institute of Mathematics University of Warsaw Ideals and exceptional sets in Polish spaces, Lausanne, 4-8 June 2018 The results come from a joint paper

More information

MTH 505: Number Theory Spring 2017

MTH 505: Number Theory Spring 2017 MTH 505: Number Theory Spring 017 Homework 4 Drew Armstrong 4.1. (Squares Mod 4). We say that an element ras n P Z{nZ is square if there exists an element rxs n P Z{nZ such that ras n prxs n q rx s n.

More information

Bilateral Proofs of Safety and Progress Properties of Concurrent Programs (Working Draft)

Bilateral Proofs of Safety and Progress Properties of Concurrent Programs (Working Draft) Bilateral Proofs of Safety and Progress Properties of Concurrent Programs (Working Draft) Jayadev Misra December 18, 2015 Contents 1 Introduction 3 2 Program and Execution Model 4 2.1 Program Structure..........................

More information

On-the-Fly Model Checking for Extended Action-Based Probabilistic Operators

On-the-Fly Model Checking for Extended Action-Based Probabilistic Operators On-the-Fly Model Checking for Extended Action-Based Probabilistic Operators Radu Mateescu and José Ignacio Requeno Inria Grenoble and LIG / Convecs http://convecs.inria.fr SPIN 2016 - Eindhoven, March

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

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

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

Symmetries of weight enumerators

Symmetries of weight enumerators Martino Borello (Paris 8-LAGA) Gaeta, 06.06.2017 0 / 13 Symmetries of weight enumerators Martino Borello Université Paris 8 - LAGA Fq13 Martino Borello (Paris 8-LAGA) Gaeta, 06.06.2017 1 / 13 Introduction

More information

Flow Interfaces Compositional Abstractions of Concurrent Data Structures. Siddharth Krishna, Dennis Shasha, and Thomas Wies

Flow Interfaces Compositional Abstractions of Concurrent Data Structures. Siddharth Krishna, Dennis Shasha, and Thomas Wies Flow Interfaces Compositional Abstractions of Concurrent Data Structures Siddharth Krishna, Dennis Shasha, and Thomas Wies Background Verifying programs, separation logic, inductive predicates Verifying

More information

Flow Interfaces Compositional Abstractions of Concurrent Data Structures. Siddharth Krishna, Dennis Shasha, and Thomas Wies

Flow Interfaces Compositional Abstractions of Concurrent Data Structures. Siddharth Krishna, Dennis Shasha, and Thomas Wies Flow Interfaces Compositional Abstractions of Concurrent Data Structures Siddharth Krishna, Dennis Shasha, and Thomas Wies Background Verifying programs, separation logic, inductive predicates Slides courtesy

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

Modal and temporal logic

Modal and temporal logic Modal and temporal logic N. Bezhanishvili I. Hodkinson C. Kupke Imperial College London 1 / 83 Overview Part II 1 Soundness and completeness. Canonical models. 3 lectures. 2 Finite model property. Filtrations.

More information

Q1 (12 points): Chap 4 Exercise 3 (a) to (f) (2 points each)

Q1 (12 points): Chap 4 Exercise 3 (a) to (f) (2 points each) Q1 (1 points): Chap 4 Exercise 3 (a) to (f) ( points each) Given a table Table 1 Dataset for Exercise 3 Instance a 1 a a 3 Target Class 1 T T 1.0 + T T 6.0 + 3 T F 5.0-4 F F 4.0 + 5 F T 7.0-6 F T 3.0-7

More information

Existence of weak adiabatic limit in almost all models of perturbative QFT

Existence of weak adiabatic limit in almost all models of perturbative QFT Existence of weak adiabatic limit in almost all models of perturbative QFT Paweł Duch Jagiellonian University, Cracow, Poland LQP 40 Foundations and Constructive Aspects of Quantum Field Theory, 23.06.2017

More information

Jeff Connor IDEAL CONVERGENCE GENERATED BY DOUBLE SUMMABILITY METHODS

Jeff Connor IDEAL CONVERGENCE GENERATED BY DOUBLE SUMMABILITY METHODS DEMONSTRATIO MATHEMATICA Vol. 49 No 1 2016 Jeff Connor IDEAL CONVERGENCE GENERATED BY DOUBLE SUMMABILITY METHODS Communicated by J. Wesołowski Abstract. The main result of this note is that if I is an

More information

1. Examples. We did most of the following in class in passing. Now compile all that data.

1. Examples. We did most of the following in class in passing. Now compile all that data. SOLUTIONS Math A4900 Homework 12 11/22/2017 1. Examples. We did most of the following in class in passing. Now compile all that data. (a) Favorite examples: Let R tr, Z, Z{3Z, Z{6Z, M 2 prq, Rrxs, Zrxs,

More information

Design of Distributed Systems Melinda Tóth, Zoltán Horváth

Design of Distributed Systems Melinda Tóth, Zoltán Horváth Design of Distributed Systems Melinda Tóth, Zoltán Horváth Design of Distributed Systems Melinda Tóth, Zoltán Horváth Publication date 2014 Copyright 2014 Melinda Tóth, Zoltán Horváth Supported by TÁMOP-412A/1-11/1-2011-0052

More information

Singular integral operators and the Riesz transform

Singular integral operators and the Riesz transform Singular integral operators and the Riesz transform Jordan Bell jordan.bell@gmail.com Department of Mathematics, University of Toronto November 17, 017 1 Calderón-Zygmund kernels Let ω n 1 be the measure

More information

Axiomatic Semantics: Verification Conditions. Review of Soundness of Axiomatic Semantics. Questions? Announcements

Axiomatic Semantics: Verification Conditions. Review of Soundness of Axiomatic Semantics. Questions? Announcements Axiomatic Semantics: Verification Conditions Meeting 18, CSCI 5535, Spring 2010 Announcements Homework 6 is due tonight Today s forum: papers on automated testing using symbolic execution Anyone looking

More information