1 Introduction. 2 First Order Logic. 3 SPL Syntax. 4 Hoare Logic. 5 Exercises
|
|
- Rosalyn Atkinson
- 5 years ago
- Views:
Transcription
1 Contents 1 Introduction INF5140: Lecture 2 Espen H. Lian Institutt for informatikk, Universitetet i Oslo January 28, Proof System 3 SPL 4 GCD 5 Exercises Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Introduction Problem Given a program, and a specication, show that the program is correct wrt. the specication. What we will need programming language SPL a minimal language today, semantics next week. Promela extends SPL, used in the model checker Spin. Second half of course. specication language used to describe state of a program. Today. Temporal Logic extends FOL, lets us describe sequences of states. In two weeks. Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Introduction Intuition Program: Add local x ; y : integer where x 2; y 4 ; while px 5q do y : y x ; x : x 1 Assume that we have a program with two integer variables, x and y. We initially assign 2 to x and 4 to y. Now we can give a predicate that expresses something about the state of the program, such as x y or x y 6. But for an entire run of a program, we need to able to express properties of sequences of states. This we can do in temporal logic. Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44
2 Introduction Intuition A run: x2 y4 x2 y6 x3 y6 x3 y9 x4 y9 x4 y13 x5 y13 Language It will always be the case that x is less than x y Is it ever the case that y 3x? 3 y 3x The symbols of our rst-order language are typed variables (a countable set of them V) : relation symbols of varying arity (incl. of arity 2) function symbols of varying arity (if the arity is 0, constant symbols) the connectives, _, ^, Ñ and Ø the and D We can combine the temporal operators to express complex y 9 y 9 Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Expressions (terms) Variables are atomic expressions. If f is a function symbol of arity n, and t 1 ; : : : ; t n are terms compatible with the arguments of f, the following is an expression. f pt 1 ; : : : ; t n q If n 0, f is a constant. Using inx notation, the following are typical expressions we will see. x y 1 U Y V U X V px yq z U zv Atomic formulae J (top) and K (bottom) are atomic formulae. If P is a relation symbol of arity n, and t 1 ; : : : ; t n are terms compatible with the arguments of P, the following is an atomic formulae. Ppt 1 ; : : : ; t n q Using inx notation, the following are typical atomic formulae we may encounter. J x P U x y 1 U V x : x 1 U X V : H Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44
3 Boolean formulae All atomic formulae are boolean formulae. If ' and are boolean formulae, so are the following. Some examples can be: J ' p' _ q p' ^ q p' Ñ q p' Ø q px y 1q Ñ K P Ñ pq Ñ Pq First-order formulae All boolean formulae are rst-order formulae. Let x be a variable. If ' is a rst-order formulae, so are the following. If ' and pdxq' p@xq' are rst-order formulae, so are the following. ' p' _ q p' ^ q p' Ñ q p' Ø q L denotes the set of rst-order formulae. Qpyq _ p@xqppxq p@xqp@yqpx y Ñ pdzqpx z ^ z yqq Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 A model is an pair M pd; I q, such that D is a non-empty set (the domain) I is mapping (the interpretation), such that f I : D n Ñ D for every function symbol f of arity n Observation P I D n for every relation symbol P of arity n We will assume an implicit model, whose domain will include the natural numbers and sets of natural numbers, and it will be obvious what function and relation symbols should be mapped to. For instance if is a function symbol I is the addition function on the natural numbers, and : is mapped to a suitable. A state s over V V is a mapping from V to D. Let V tx ; y ; zu, let x and z of type natural number, and y of type set of natural numbers. spxq 256 spyq t1; 2; 3u spzq 512 Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44
4 We associate a value spt I q to every expression t. spx I q spxq sprf pt 1 ; : : : ; t n qs I q f I pspt1q; I : : : ; sptnqq I sprp2 xq zs I q spr2 xs I q I spz I q psp2 I q I spx I qq I spz I q p2 spxqq spzq p2 256q A variable occurrence is free in a formula if it is not within the scope of a quantier. A variable occurrence that is not free is bound. Let s 1 and s 2 be states over V, and x P V. s 2 is an x-variant of s 1 if s 1 pyq s 2 pyq for all y P V ztxu: Thus x is the only variable the states disagree on. Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Let ' be a rst order formula, x a variable and t an expression. Then 'rx{ts is ', only with every free occurrence of the x replaced with t. ' p@xqppxq _ Ppxq 'rx{cs p@xqppxq _ Ppcq We dene the notion that a state formula ' is true (false) relative to a model M pd; I q in a state s, written M; s ( ' (M; s ( ') as follows. M; s ( J and M; s ( K M; s ( Rpt 1 ; : : : ; t n q i pspt I 1q; : : : ; spt I nqq P R I M; s ( ' i M; s ( ' M; s ( ' _ i M; s ( ' or M; s ( M; s ( ' ^ i M; s ( ' and M; s ( M; s ( ' Ñ i M; s ( ' or M; s ( M; s ( ' Ø i M; s ( ' Ñ and M; s ( Ñ ' M; s ( p@xq' i M; t ( ' for every t that is an x-variant of s M; s ( pdxq' i M; t ( ' for some t that is an x-variant of s Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44
5 Proof System We say that ' is true in the model M, written M ( ', if M; s ( ' for every state s. We say that ' is valid, written ( ', if M ( ' for every model M. A proof system for a given logic consists of axioms (or axiom schemata), formulae assumed to be true, and inference rules, of the form Observation We will abuse this notation, and write ( ' if ' is true in our implicit model, and refer to this as state-validity. For instance: ( x y : y x. In a model where I is the subtraction function, this will obviously not hold. ' 1 ' n ; where ' 1 ; : : : ; ' n are premises and the conclusion. Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Proof System Proof System A derivation from a set of formulae S is a sequence of formulae, where each formula is either in S, an axiom or can be obtained by applying an inference rule to formulae earlier in the sequence. A proof is a derivation from the empty set. A theorem is the last formula in a proof. A proof system is sound if every theorem is valid. complete if evey valid formula is a theorem. We will not be bothered with soundness or completeness but we will (of course) assume that eveything is sound. Observation We can axiomatize a subset of Propositional Logic as follows. (A1) ' Ñ p Ñ 'q (A2) p' Ñ p Ñ qq Ñ pp' Ñ q Ñ p' Ñ qq (MP) ' ' Ñ Let us call this logic PPL. Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44
6 Proof System Basic statements p Ñ p is a theorem of PPL: Skip skip does nothing (like a NOP instruction). (1) (2) (3) (4) (5) Observation pp Ñ ppp Ñ pq Ñ pqq Ñ ppp Ñ pp Ñ pqq Ñ pp Ñ pqq p Ñ ppp Ñ pq Ñ pq AX2 AX1 pp Ñ pp Ñ pqq Ñ pp Ñ pq MP on (1) and (2) p Ñ pp Ñ pq AX1 p Ñ p MP on (3) and (4) A proof can be represented as a tree of inferences where the leaves are axioms. Assignment px 1 ; : : : ; x k q : pt 1 ; : : : ; t k q assigns each t j to x j. x 1 ; : : : ; x k list of variables t 1 ; : : : ; t k list of expressions Await await c waits until c becomes true. c boolean formula halt is an abbreviation for await K. Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Semaphore statements Schematic statements Request request r decrements r by 1 as soon as r has a positive value (in one step). r integer variable Critical critical represents critical activity in programs with mutual exclusion. idle is a synonym used when not dealing with mutual exclusion. Release release r increments r by 1. r integer variable Noncritical noncritical represents noncritical activity in programs with mutual exclusion. Need not terminate. Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44
7 Schematic statements Compound statements Produce produce r represents production activity in producer-consumer programs. Assingns a non-zero (produced) value to r. r integer variable Conditional if c then S 1 else S 2. If c is true, S 1 is executed, and if c is false, S 2 is executed. c boolean expression S 1 ; S 2 statements Consume consume r represents consumer activity in producer-consumer programs. r integer variable Concatenation S 1 ; ; S k. Sequential exectuion of S 1 ; : : : ; S k in that order. S 1 ; : : : ; S k statements Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Compound statements Compound statements Selection S 1 or or S k. One of S 1 ; : : : ; S k that is enabled is nondeterministically chosen and executed. S 1 ; : : : ; S k statements Cooperation S 1 } } S k. The parallell execution of processes S 1 ; : : : ; S k, in an interleaving fashion: steps from the various processes are executed one at a time. Justice ensures that no process is ignored forever. S 1 ; : : : ; S k statements While while c do S. Terminates if c is false, and if c is true, subsequently executes S. c boolean expression S statement Block rlocal declaration ; Ss. local declaration (see foil after next) S statement Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44
8 Programs Programs A declaration consists of a sequence of declaration statements of the form MODE x 1 ; : : : ; x n : TYPE where ' Each declaration statement identies the mode and type of a list of variables and, optionally, species constraints on their initial values. MODE is one of in, local or out. TYPE is typically integer or boolean. ' is of the form y 1 : t 1 ^ ^ y m : t m, where ty 1 ; : : : ; y m u tx 1 ; : : : ; x n u, with natural restrictions on t 1 ; : : : ; t m. A program P consists of a declaration followed by a cooperation statement, in which processes may be named. P :: rdeclaration ; rp 1 :: S 1 } } P k :: S k ss P 1 ; : : : ; P k are referred to as processes. Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 (Triple) Let ' and be rst-order formulae, and S a statement (in SPL). Then the following is a triple: t'u S t u Triples are the formulae of. ' and are called the precondition and postcondition of S resp. Interpretation We (informally) interpret t'u S t u as true when the following holds: Whenever S starts executing and ' is true, if S terminates, then is true. This interpretation is called partial correctness, which is a safety property: ' Ñ If S can be assumed to terminate, we get the corresponding liveness property, total correctness: ' Ñ 3pterminatespSq ^ What does tju S tku express (under partial correctness)? q q We will give a formal semantics later. Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44
9 Await Axiom We would like the following to be a theorem. tx : 0u x : x 1 ; tx : 1u The following, however, should not be a theorem, as it is not always the case that if you assign x 1 to x, then y 1. tx : 0u x : x 1 ; ty : 1u Await Axiom t'u await c t' ^ cu tx 0u await x 1 tx 0 ^ x : 1u Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Assignment Axiom Assignment Axiom t'rx{tsu x : t t'u t1 : 1u x : 1 tx : 1u and t1 2 yu x : 1 2 tx yu Observation It might be easier reading it as going forward instead: tx 0u x : x 1 tx 1u This holds because x 1 1 is equivalent to x 0 (see the Consequence Rule), and the following is an instance of the axiom: Concatenation Rule Concatenation Rule t'u S 1 tu tu S 2 t u t'u S 1 ; S 2 t u tx : 0u x : 1 tx 0u tx 0u x : 2 x tx 0u tx : 0u x : 1 ; x : 2 x tx 0u tx 1 1u x : x 1 tx 1u Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44
10 Skip Axiom and Conditional/Selection Rules While Rule Skip Axiom t'u skip t'u Conditional Rule t' ^ cu S 1 t u t' ^ cu S 2 t u t'u if c then S 1 else S 2 t u Selection Rule t'u S 1 t u : : : t'u S k t u t'u S 1 or or S k t u While Rule t' ^ cu S t'u t'u while c do S t' ^ cu Here ' is a loop invariant; it is true before and after each iteration of the loop. tx % 2 : 0 ^ x 10u x : x 2 tx % 2 : 0u tx % 2 : 0u while px 10q do x : x 2 tx % 2 : 0 ^ x 10qu The loop invariant says that x is even. Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Consequence Rule Consequence Rule t'u S t u t' 1 u S t 1 u if ( ' 1 Ñ ' and ( Ñ 1 3: t x 0u x : x tx 0u 5: tx 0u skip tx 0u 2: tj ^ x 0u x : x tx 0u 4: tj ^ px 0qu skip tx 0u 1: tju if x 0 then x : x else skip tx 0u The precondition is strengthened, and the postcondition weakened. tx 0u x : x 1 tx 0 ^ x 1u tx 0 ^ x 1u x : x 1 tx 0u or tx 0u x : x 1 tx 1u tx 1u x : x 1 tx 0u Note that ( px 1q Ñ px 0q. Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / Conditional Rule 2. Consequence Rule 3. Assignment Axiom 4. Consequence Rule 5. Skip Axiom Axioms in every leaf node, thus the derivation is a proof. Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44
11 GCD The following program (the Euclidean algorithm) is supposed to terminate with the value of gcdpa; bq in g. Program: GCD P :: r in a; b : integer where a 0; b 0 ; local x ; y : integer where x a; y b ; out g : integer ; P 1 :: r while x y do r await x y ; x : x y ; or await y x ; y : y x ; s g : x ; s s We want to show that the program is correct. Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 GCD Problem We want to show that g gcdpa; bq when P terminates. Solution We do this by establishing a loop invariant: I px ; yq px 0q ^ py 0q ^ gcdpx ; yq : gcdpa; bq; and show that the following can be proved in our proof system. ti px ; yqu P 1 tg : gcdpa; bqu Proof See blackboard. Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Exercises Exercises Exercises 1. The program on the next foil is supposed to compute a b. 1 Show a computation (how the variables change when the program runs) for the input x 2 and y 7. 2 Show that the program is correct by proving the following Hoare triple for some suitable ': t'u P 1 tz a b u Program: Exponentiation P :: r in a; b : integer where a 0; b 0 ; local x ; y : integer where x a; y b ; out z : integer where z 1 ; P 1 :: r while y 0 do r z : x z ; y : y 1 ; s s s Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44 Institutt for informatikk (UiO) INF5140: Lecture 2 January 28, / 44
Program Analysis Part I : Sequential Programs
Program Analysis Part I : Sequential Programs IN5170/IN9170 Models of concurrency Program Analysis, lecture 5 Fall 2018 26. 9. 2018 2 / 44 Program correctness Is my program correct? Central question for
More informationProgram 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 informationWhat happens to the value of the expression x + y every time we execute this loop? while x>0 do ( y := y+z ; x := x:= x z )
Starter Questions Feel free to discuss these with your neighbour: Consider two states s 1 and s 2 such that s 1, x := x + 1 s 2 If predicate P (x = y + 1) is true for s 2 then what does that tell us about
More informationAxiomatic Semantics. Lecture 9 CS 565 2/12/08
Axiomatic Semantics Lecture 9 CS 565 2/12/08 Axiomatic Semantics Operational semantics describes the meaning of programs in terms of the execution steps taken by an abstract machine Denotational semantics
More informationAxiomatic 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 informationHoare Logic and Model Checking
Hoare Logic and Model Checking Kasper Svendsen University of Cambridge CST Part II 2016/17 Acknowledgement: slides heavily based on previous versions by Mike Gordon and Alan Mycroft Introduction In the
More informationLecture 2: Axiomatic semantics
Chair of Software Engineering Trusted Components Prof. Dr. Bertrand Meyer Lecture 2: Axiomatic semantics Reading assignment for next week Ariane paper and response (see course page) Axiomatic semantics
More informationProgram verification using Hoare Logic¹
Program verification using Hoare Logic¹ Automated Reasoning - Guest Lecture Petros Papapanagiotou Part 2 of 2 ¹Contains material from Mike Gordon s slides: Previously on Hoare Logic A simple while language
More informationDesign 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 informationCSC 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 informationDynamic 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 informationAxiomatic 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 informationHoare 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 informationHoare Logic (I): Axiomatic Semantics and Program Correctness
Hoare Logic (I): Axiomatic Semantics and Program Correctness (Based on [Apt and Olderog 1991; Gries 1981; Hoare 1969; Kleymann 1999; Sethi 199]) Yih-Kuen Tsay Dept. of Information Management National Taiwan
More informationProgramming Languages and Compilers (CS 421)
Programming Languages and Compilers (CS 421) Sasa Misailovic 4110 SC, UIUC https://courses.engr.illinois.edu/cs421/fa2017/cs421a Based in part on slides by Mattox Beckman, as updated by Vikram Adve, Gul
More informationIntroduction. Pedro Cabalar. Department of Computer Science University of Corunna, SPAIN 2013/2014
Introduction Pedro Cabalar Department of Computer Science University of Corunna, SPAIN cabalar@udc.es 2013/2014 P. Cabalar ( Department Introduction of Computer Science University of Corunna, SPAIN2013/2014
More informationHoare 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 informationLecture 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 informationLECTURE 11: AXIOMATIC SET THEORY PART 3
LECTURE 11: AXIOMATIC SET THEORY PART 3 1. Natural numbers and the ordinal ω Recall from last lecture that a set x is an ordinal just in case it is transitive and wellordered by P (membership). Note that
More informationLearning Goals of CS245 Logic and Computation
Learning Goals of CS245 Logic and Computation Alice Gao April 27, 2018 Contents 1 Propositional Logic 2 2 Predicate Logic 4 3 Program Verification 6 4 Undecidability 7 1 1 Propositional Logic Introduction
More informationComputer-Aided Program Design
Computer-Aided Program Design Spring 2015, Rice University Unit 3 Swarat Chaudhuri February 5, 2015 Temporal logic Propositional logic is a good language for describing properties of program states. However,
More informationNotation for Logical Operators:
Notation for Logical Operators: always true always false... and...... or... if... then...... if-and-only-if... x:x p(x) x:x p(x) for all x of type X, p(x) there exists an x of type X, s.t. p(x) = is equal
More informationReasoning 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 informationDeductive 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 informationAxiomatic Semantics. Operational semantics. Good for. Not good for automatic reasoning about programs
Review Operational semantics relatively l simple many flavors (small vs. big) not compositional (rule for while) Good for describing language implementation reasoning about properties of the language eg.
More informationHoare 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 informationLast Time. Inference Rules
Last Time When program S executes it switches to a different state We need to express assertions on the states of the program S before and after its execution We can do it using a Hoare triple written
More informationProof Rules for Correctness Triples
Proof Rules for Correctness Triples CS 536: Science of Programming, Fall 2018 A. Why? We can t generally prove that correctness triples are valid using truth tables. We need proof axioms for atomic statements
More informationSpring 2015 Program Analysis and Verification. Lecture 4: Axiomatic Semantics I. Roman Manevich Ben-Gurion University
Spring 2015 Program Analysis and Verification Lecture 4: Axiomatic Semantics I Roman Manevich Ben-Gurion University Agenda Basic concepts of correctness Axiomatic semantics (pages 175-183) Hoare Logic
More informationAxiomatic 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 informationJUSTIFYING BOOLE S ALGEBRA of LOGIC for CLASSES
Outline The Paradigm The Starting Point Boole s Partial Algebras Boole s Translations Laws and Rules of Inference Characteristic Functions Signed Multisets NCR 1 R01 Horn Formulas Relativizing Quantifiers
More information20.1 2SAT. CS125 Lecture 20 Fall 2016
CS125 Lecture 20 Fall 2016 20.1 2SAT We show yet another possible way to solve the 2SAT problem. Recall that the input to 2SAT is a logical expression that is the conunction (AND) of a set of clauses,
More informationThe 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 informationHoare Examples & Proof Theory. COS 441 Slides 11
Hoare Examples & Proof Theory COS 441 Slides 11 The last several lectures: Agenda Denotational semantics of formulae in Haskell Reasoning using Hoare Logic This lecture: Exercises A further introduction
More informationPredicate Logic: Sematics Part 1
Predicate Logic: Sematics Part 1 CS402, Spring 2018 Shin Yoo Predicate Calculus Propositional logic is also called sentential logic, i.e. a logical system that deals with whole sentences connected with
More informationVerifying Properties of Parallel Programs: An Axiomatic Approach
Verifying Properties of Parallel Programs: An Axiomatic Approach By Susan Owicki and David Gries (1976) Nathan Wetzler nwetzler@cs.utexas.edu University of Texas, Austin November 3, 2009 Outline Introduction
More informationCS422 - Programming Language Design
1 CS422 - Programming Language Design Denotational Semantics Grigore Roşu Department of Computer Science University of Illinois at Urbana-Champaign 2 Denotational semantics, also known as fix-point semantics,
More informationFirst Order Logic vs Propositional Logic CS477 Formal Software Dev Methods
First Order Logic vs Propositional Logic CS477 Formal Software Dev Methods Elsa L Gunter 2112 SC, UIUC egunter@illinois.edu http://courses.engr.illinois.edu/cs477 Slides based in part on previous lectures
More informationCS558 Programming Languages
CS558 Programming Languages Winter 2017 Lecture 2b Andrew Tolmach Portland State University 1994-2017 Semantics Informal vs. Formal Informal semantics Descriptions in English (or other natural language)
More informationClassical 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 informationAutomata-Theoretic Model Checking of Reactive Systems
Automata-Theoretic Model Checking of Reactive Systems Radu Iosif Verimag/CNRS (Grenoble, France) Thanks to Tom Henzinger (IST, Austria), Barbara Jobstmann (CNRS, Grenoble) and Doron Peled (Bar-Ilan University,
More informationAsynchronous Communication 2
Asynchronous Communication 2 INF4140 22.11.12 Lecture 11 INF4140 (22.11.12) Asynchronous Communication 2 Lecture 11 1 / 37 Overview: Last time semantics: histories and trace sets specification: invariants
More informationFoundations of Computation
The Australian National University Semester 2, 2018 Research School of Computer Science Tutorial 6 Dirk Pattinson Foundations of Computation The tutorial contains a number of exercises designed for the
More informationBilateral 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 informationLecture Notes on Inductive Definitions
Lecture Notes on Inductive Definitions 15-312: Foundations of Programming Languages Frank Pfenning Lecture 2 September 2, 2004 These supplementary notes review the notion of an inductive definition and
More informationHoare 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 informationA 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 informationSpring 2016 Program Analysis and Verification. Lecture 3: Axiomatic Semantics I. Roman Manevich Ben-Gurion University
Spring 2016 Program Analysis and Verification Lecture 3: Axiomatic Semantics I Roman Manevich Ben-Gurion University Warm-up exercises 1. Define program state: 2. Define structural semantics configurations:
More informationAutomated Reasoning Lecture 5: First-Order Logic
Automated Reasoning Lecture 5: First-Order Logic Jacques Fleuriot jdf@inf.ac.uk Recap Over the last three lectures, we have looked at: Propositional logic, semantics and proof systems Doing propositional
More informationProof Calculus for Partial Correctness
Proof Calculus for Partial Correctness Bow-Yaw Wang Institute of Information Science Academia Sinica, Taiwan September 7, 2016 Bow-Yaw Wang (Academia Sinica) Proof Calculus for Partial Correctness September
More informationTHE 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 informationFirst-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 informationLoop Convergence. CS 536: Science of Programming, Fall 2018
Solved Loop Convergence CS 536: Science of Programming, Fall 2018 A. Why Diverging programs aren t useful, so it s useful to know how to show that loops terminate. B. Objectives At the end of this lecture
More informationMid-Semester Quiz Second Semester, 2012
THE AUSTRALIAN NATIONAL UNIVERSITY Mid-Semester Quiz Second Semester, 2012 COMP2600 (Formal Methods for Software Engineering) Writing Period: 1 hour duration Study Period: 10 minutes duration Permitted
More information22c:145 Artificial Intelligence
22c:145 Artificial Intelligence Fall 2005 Propositional Logic Cesare Tinelli The University of Iowa Copyright 2001-05 Cesare Tinelli and Hantao Zhang. a a These notes are copyrighted material and may not
More informationAdvanced Topics in LP and FP
Lecture 1: Prolog and Summary of this lecture 1 Introduction to Prolog 2 3 Truth value evaluation 4 Prolog Logic programming language Introduction to Prolog Introduced in the 1970s Program = collection
More informationLogic Model Checking
Logic Model Checking Lecture Notes 10:18 Caltech 101b.2 January-March 2004 Course Text: The Spin Model Checker: Primer and Reference Manual Addison-Wesley 2003, ISBN 0-321-22862-6, 608 pgs. the assignment
More informationLogic. Propositional Logic: Syntax. Wffs
Logic Propositional Logic: Syntax Logic is a tool for formalizing reasoning. There are lots of different logics: probabilistic logic: for reasoning about probability temporal logic: for reasoning about
More informationINF2220: algorithms and data structures Series 1
Universitetet i Oslo Institutt for Informatikk I. Yu, D. Karabeg INF2220: algorithms and data structures Series 1 Topic Function growth & estimation of running time, trees (Exercises with hints for solution)
More informationHoare Logic: Part II
Hoare Logic: Part II COMP2600 Formal Methods for Software Engineering Jinbo Huang Australian National University COMP 2600 Hoare Logic II 1 Factorial {n 0} fact := 1; i := n; while (i >0) do fact := fact
More informationINF 4140: Models of Concurrency Series 3
Universitetet i Oslo Institutt for Informatikk PMA Olaf Owe, Martin Steffen, Toktam Ramezani INF 4140: Models of Concurrency Høst 2016 Series 3 14. 9. 2016 Topic: Semaphores (Exercises with hints for solution)
More informationLecture Notes on Inductive Definitions
Lecture Notes on Inductive Definitions 15-312: Foundations of Programming Languages Frank Pfenning Lecture 2 August 28, 2003 These supplementary notes review the notion of an inductive definition and give
More informationDiagram-based Formalisms for the Verication of. Reactive Systems. Anca Browne, Luca de Alfaro, Zohar Manna, Henny B. Sipma and Tomas E.
In CADE-1 Workshop on Visual Reasoning, New Brunswick, NJ, July 1996. Diagram-based Formalisms for the Verication of Reactive Systems Anca Browne, Luca de Alfaro, Zohar Manna, Henny B. Sipma and Tomas
More informationCOP4020 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 informationProofs of Correctness: Introduction to Axiomatic Verification
Proofs of Correctness: Introduction to Axiomatic Verification Introduction Weak correctness predicate Assignment statements Sequencing Selection statements Iteration 1 Introduction What is Axiomatic Verification?
More informationif t 1,...,t k Terms and P k is a k-ary predicate, then P k (t 1,...,t k ) Formulas (atomic formulas)
FOL Query Evaluation Giuseppe De Giacomo Università di Roma La Sapienza Corso di Seminari di Ingegneria del Software: Data and Service Integration Laurea Specialistica in Ingegneria Informatica Università
More informationPropositional Logic: Part II - Syntax & Proofs 0-0
Propositional Logic: Part II - Syntax & Proofs 0-0 Outline Syntax of Propositional Formulas Motivating Proofs Syntactic Entailment and Proofs Proof Rules for Natural Deduction Axioms, theories and theorems
More information03 Review of First-Order Logic
CAS 734 Winter 2014 03 Review of First-Order Logic William M. Farmer Department of Computing and Software McMaster University 18 January 2014 What is First-Order Logic? First-order logic is the study of
More informationAxiomatic 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 informationProof 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 informationCS256/Winter 2009 Lecture #6. Zohar Manna
CS256/Winter 2009 Lecture #6 Zohar Manna Chapter 1 Invariance: Proof Methods For assertion q and SPL program P show P Õ ¼ q (i.e., q is P-invariant) 6-1 Proving Invariances Definitions Recall: the variables
More informationPřednáška 12. Důkazové kalkuly Kalkul Hilbertova typu. 11/29/2006 Hilbertův kalkul 1
Přednáška 12 Důkazové kalkuly Kalkul Hilbertova typu 11/29/2006 Hilbertův kalkul 1 Formal systems, Proof calculi A proof calculus (of a theory) is given by: A. a language B. a set of axioms C. a set of
More informationPropositional Logic: Models and Proofs
Propositional Logic: Models and Proofs C. R. Ramakrishnan CSE 505 1 Syntax 2 Model Theory 3 Proof Theory and Resolution Compiled at 11:51 on 2016/11/02 Computing with Logic Propositional Logic CSE 505
More informationProgram Analysis and Verification
Program Analysis and Verification 0368-4479 Noam Rinetzky Lecture 4: Axiomatic Semantics Slides credit: Tom Ball, Dawson Engler, Roman Manevich, Erik Poll, Mooly Sagiv, Jean Souyris, Eran Tromer, Avishai
More informationWeakest Precondition Calculus
Weakest Precondition Calculus COMP2600 Formal Methods for Software Engineering Rajeev Goré Australian National University Semester 2, 2016 (Most lecture slides due to Ranald Clouston) COMP 2600 Weakest
More informationCOMP219: Artificial Intelligence. Lecture 19: Logic for KR
COMP219: Artificial Intelligence Lecture 19: Logic for KR 1 Overview Last time Expert Systems and Ontologies Today Logic as a knowledge representation scheme Propositional Logic Syntax Semantics Proof
More informationFirst-order logic Syntax and semantics
1 / 43 First-order logic Syntax and semantics Mario Alviano University of Calabria, Italy A.Y. 2017/2018 Outline 2 / 43 1 Motivation Why more than propositional logic? Intuition 2 Syntax Terms Formulas
More informationFirst-Order Theorem Proving and Vampire
First-Order Theorem Proving and Vampire Laura Kovács 1,2 and Martin Suda 2 1 TU Wien 2 Chalmers Outline Introduction First-Order Logic and TPTP Inference Systems Saturation Algorithms Redundancy Elimination
More informationLING 106. Knowledge of Meaning Lecture 3-1 Yimei Xiang Feb 6, Propositional logic
LING 106. Knowledge of Meaning Lecture 3-1 Yimei Xiang Feb 6, 2016 Propositional logic 1 Vocabulary of propositional logic Vocabulary (1) a. Propositional letters: p, q, r, s, t, p 1, q 1,..., p 2, q 2,...
More informationA Primer on Boole s Algebra of Logic for Classes
Outline The Paradigm Early Insights Boole s Algebra of Classes (Quick Overview) Defining Multiplication Numbers as Classes Schröder s Translations Two Cautions Boole s Equational System Def A B Def A B
More informationIntroduction to Metalogic
Philosophy 135 Spring 2008 Tony Martin Introduction to Metalogic 1 The semantics of sentential logic. The language L of sentential logic. Symbols of L: Remarks: (i) sentence letters p 0, p 1, p 2,... (ii)
More informationFloyd-Hoare Style Program Verification
Floyd-Hoare Style Program Verification Deepak D Souza Department of Computer Science and Automation Indian Institute of Science, Bangalore. 9 Feb 2017 Outline of this talk 1 Overview 2 Hoare Triples 3
More informationAbstractions and Decision Procedures for Effective Software Model Checking
Abstractions and Decision Procedures for Effective Software Model Checking Prof. Natasha Sharygina The University of Lugano, Carnegie Mellon University Microsoft Summer School, Moscow, July 2011 Lecture
More informationPropositional Logic: Syntax
Logic Logic is a tool for formalizing reasoning. There are lots of different logics: probabilistic logic: for reasoning about probability temporal logic: for reasoning about time (and programs) epistemic
More informationTHE LANGUAGE OF FIRST-ORDER LOGIC (FOL) Sec2 Sec1(1-16)
THE LANGUAGE OF FIRST-ORDER LOGIC (FOL) Sec2 Sec1(1-16) FOL: A language to formulate knowledge Logic is the study of entailment relationslanguages, truth conditions and rules of inference. FOL or Predicate
More informationLogic. Propositional Logic: Syntax
Logic Propositional Logic: Syntax Logic is a tool for formalizing reasoning. There are lots of different logics: probabilistic logic: for reasoning about probability temporal logic: for reasoning about
More informationChapter 2. Assertions. An Introduction to Separation Logic c 2011 John C. Reynolds February 3, 2011
Chapter 2 An Introduction to Separation Logic c 2011 John C. Reynolds February 3, 2011 Assertions In this chapter, we give a more detailed exposition of the assertions of separation logic: their meaning,
More information3. Only sequences that were formed by using finitely many applications of rules 1 and 2, are propositional formulas.
1 Chapter 1 Propositional Logic Mathematical logic studies correct thinking, correct deductions of statements from other statements. Let us make it more precise. A fundamental property of a statement is
More informationCOMP2111 Glossary. Kai Engelhardt. Contents. 1 Symbols. 1 Symbols 1. 2 Hoare Logic 3. 3 Refinement Calculus 5. rational numbers Q, real numbers R.
COMP2111 Glossary Kai Engelhardt Revision: 1.3, May 18, 2018 Contents 1 Symbols 1 2 Hoare Logic 3 3 Refinement Calculus 5 1 Symbols Booleans B = {false, true}, natural numbers N = {0, 1, 2,...}, integers
More informationTHE AUSTRALIAN NATIONAL UNIVERSITY Second Semester COMP2600 (Formal Methods in Software Engineering)
THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester 2007 COMP2600 (Formal Methods in Software Engineering) Writing Period: 3 hours duration Study Period: 15 minutes duration Permitted Materials: None Answer
More informationSyntax. Notation Throughout, and when not otherwise said, we assume a vocabulary V = C F P.
First-Order Logic Syntax The alphabet of a first-order language is organised into the following categories. Logical connectives:,,,,, and. Auxiliary symbols:.,,, ( and ). Variables: we assume a countable
More informationFirst-Order Theorem Proving and Vampire. Laura Kovács (Chalmers University of Technology) Andrei Voronkov (The University of Manchester)
First-Order Theorem Proving and Vampire Laura Kovács (Chalmers University of Technology) Andrei Voronkov (The University of Manchester) Outline Introduction First-Order Logic and TPTP Inference Systems
More informationBehavioural theories and the proof of. LIENS, C.N.R.S. U.R.A & Ecole Normale Superieure, 45 Rue d'ulm, F{75230 Paris Cedex 05, France
Behavioural theories and the proof of behavioural properties Michel Bidoit a and Rolf Hennicker b b a LIENS, C.N.R.S. U.R.A. 1327 & Ecole Normale Superieure, 45 Rue d'ulm, F{75230 Paris Cedex 05, France
More informationThe Journal of Logic and Algebraic Programming
The Journal of Logic and Algebraic Programming 78 (2008) 22 51 Contents lists available at ScienceDirect The Journal of Logic and Algebraic Programming journal homepage: www.elsevier.com/locate/jlap Operational
More informationLogic Part I: Classical Logic and Its Semantics
Logic Part I: Classical Logic and Its Semantics Max Schäfer Formosan Summer School on Logic, Language, and Computation 2007 July 2, 2007 1 / 51 Principles of Classical Logic classical logic seeks to model
More informationCOMP219: Artificial Intelligence. Lecture 19: Logic for KR
COMP219: Artificial Intelligence Lecture 19: Logic for KR 1 Overview Last time Expert Systems and Ontologies Today Logic as a knowledge representation scheme Propositional Logic Syntax Semantics Proof
More informationMath 144 Summer 2012 (UCR) Pro-Notes June 24, / 15
Before we start, I want to point out that these notes are not checked for typos. There are prbally many typeos in them and if you find any, please let me know as it s extremely difficult to find them all
More informationThe assertional versus Tarskian methods
The assertional versus Tarskian methods Uri Abraham May 12, 2014 Abstract In this lecture we analyze Peterson s well known two-process criticalsection protocol [3] and prove that the mutual exclusion property
More informationSoftware Engineering using Formal Methods
Software Engineering using Formal Methods First-Order Logic Wolfgang Ahrendt 26th September 2013 SEFM: First-Order Logic 130926 1 / 53 Install the KeY-Tool... KeY used in Friday s exercise Requires: Java
More information