1 Formal Specifications for Complex Systems (236368) Tutorial #1 Course site : T.A. :Emilia Katz.

Slides:



Advertisements
Similar presentations
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Advertisements

Possible World Semantics for Modal Logic
Copyright , Doron Peled and Cesare Tinelli. These notes are based on a set of lecture notes originally developed by Doron Peled at the University.
Hoare’s Correctness Triplets Dijkstra’s Predicate Transformers
11111 Functional Program Verification CS 4311 A. M. Stavely, Toward Zero Defect Programming, Addison-Wesley, Y. Cheon and M. Vela, A Tutorial on.
CS6133 Software Specification and Verification
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
Inference and Reasoning. Basic Idea Given a set of statements, does a new statement logically follow from this. For example If an animal has wings and.
David Evans CS655: Programming Languages University of Virginia Computer Science Lecture 19: Minding Ps & Qs: Axiomatic.
Axiomatic Verification I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 17.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
ISBN Chapter 3 Describing Syntax and Semantics.
1 Discrete Structures Lecture 29 Predicates and Programming Read Ch
1 Semantic Description of Programming languages. 2 Static versus Dynamic Semantics n Static Semantics represents legal forms of programs that cannot be.
1/22 Programs : Semantics and Verification Charngki PSWLAB Programs: Semantics and Verification Mordechai Ben-Ari Mathematical Logic for Computer.
CS 355 – Programming Languages
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
CSE115/ENGR160 Discrete Mathematics 04/12/11 Ming-Hsuan Yang UC Merced 1.
ESC Java. Static Analysis Spectrum Power Cost Type checking Data-flow analysis Model checking Program verification AutomatedManual ESC.
1 Formal Specifications for Complex Systems (236368) Tutorial #5 I/O specifications; Hoare Logic; OCL.
Axiomatic Semantics Dr. M Al-Mulhem ICS
Formal Specifications for Complex Systems (236368) Tutorial #6 appendix Statecharts vs. Raphsody 7 (theory vs. practice)
1 Formal Specifications for Complex Systems (236368) Tutorial #1 Course site : T.A. :Emilia Katz.
1 מפרטים פורמאליים תירגול מספר 13 מפרטים פורמאליים - תירגול שחר דג LARCH הרמה הראשונה - הרחבת ההגדרה הבסיסית דוגמא – set Initial and Final algebras הרמה.
1 מפרטים פורמאליים תרגול מספר 1 מהות הקורס:כח ביטוי. בעיות מעשיות (ולא הוכחות) מתרגל אחראי:שחר דג מתרגלת:אמיליה כץ אתר:
Dr. Muhammed Al-Mulhem 1ICS ICS 535 Design and Implementation of Programming Languages Part 1 Fundamentals (Chapter 4) Axiomatic Semantics ICS 535.
4/17/2017 Section 3.6 Program Correctness ch3.6.
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
Describing Syntax and Semantics
MATH 224 – Discrete Mathematics
XP New Perspectives on Microsoft Office Access 2003 Tutorial 11 1 Microsoft Office Access 2003 Tutorial 11 – Using and Writing Visual Basic for Applications.
Chapter 3 (Part 3): Mathematical Reasoning, Induction & Recursion  Recursive Algorithms (3.5)  Program Correctness (3.6)
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 4 (Part 3): Mathematical Reasoning, Induction.
1 Inference Rules and Proofs (Z); Program Specification and Verification Inference Rules and Proofs (Z); Program Specification and Verification.
Methods of Proofs PREDICATE LOGIC The “Quantifiers” and are known as predicate quantifiers. " means for all and means there exists. Example 1: If we.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
CS 363 Comparative Programming Languages Semantics.
Program Correctness. 2 Program Verification An object is a finite state machine: –Its attribute values are its state. –Its methods optionally: Transition.
Recursive Algorithms &
Reasoning about programs March CSE 403, Winter 2011, Brun.
Program Analysis and Verification Spring 2014 Program Analysis and Verification Lecture 4: Axiomatic Semantics I Roman Manevich Ben-Gurion University.
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
Chapter 3 Part II Describing Syntax and Semantics.
Semantics In Text: Chapter 3.
COP4020 Programming Languages Introduction to Axiomatic Semantics Prof. Robert van Engelen.
June 11, 2002© Howard Huang1 Boolean algebra Last time we talked about Boolean functions, Boolean expressions, and truth tables. Today we’ll learn.
Emilia Katz, Shahar Dag 1 Formal Specifications for Complex Systems (236368) Tutorial #13 Algebraic Specification and Larch.
13 Aug 2013 Program Verification. Proofs about Programs Why make you study logic? Why make you do proofs? Because we want to prove properties of programs.
Principle of Programming Lanugages 3: Compilation of statements Statements in C Assertion Hoare logic Department of Information Science and Engineering.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
1 2/21/2016 MATH 224 – Discrete Mathematics Sequences and Sums A sequence of the form ar 0, ar 1, ar 2, ar 3, ar 4, …, ar n, is called a geometric sequence.
From Natural Language to LTL: Difficulties Capturing Natural Language Specification in Formal Languages for Automatic Analysis Elsa L Gunter NJIT.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
1 Formal Specifications for Complex Systems (236368) Tutorial #1 Course site:
Section 1.7. Section Summary Mathematical Proofs Forms of Theorems Direct Proofs Indirect Proofs Proof of the Contrapositive Proof by Contradiction.
MATH 224 – Discrete Mathematics
Chapter 4 (Part 3): Mathematical Reasoning, Induction & Recursion
Chapter 3 of Programming Languages by Ravi Sethi
Formal Specifications for Complex Systems (236368) Tutorial #1
Formal Methods in Software Engineering 1
Mathematical Structures for Computer Science Chapter 1
Copyright © Cengage Learning. All rights reserved.
Axiomatic semantics Points to discuss: The assignment statement
Programming Languages and Compilers (CS 421)
Logic for Computer Security Protocols
Functional Program Verification
Program correctness Axiomatic semantics
Programming Languages and Compilers (CS 421)
COP4020 Programming Languages
Presentation transcript:

1 Formal Specifications for Complex Systems (236368) Tutorial #1 Course site : T.A. :Emilia Katz Reception hours: Tuesday 16:00 – 17:00 Taub 641

2 General Information The course is about: Formally expressing requirements -Statements, not proofs Homework submission: In pairs -From previous years experience, we recommend both partners to participate in every homework solution, in order to succeed in the exam -Formal and exact writing of the solutions is required -List all your assumptions (everything you had to assume for your solution) -There might be one “wet” homework No midterm exam. Recommendation: solve midterm exams from previous years before the final exam מפרטים פורמאליים - תירגול שחר דג

3 I/O Assertions Content What are I/O Assertions? What do I/O Assertions mean? Translating verbal properties into logic expression. Annotated programs. Using “logical” and “auxiliary” variables. Examples. Assertion – טענה יכולה להיות נכונה או שגויה מפרטים פורמאליים - תירגול שחר דג

4 An I/O specification defines the set of admissible initial states, and for each initial state, the final states reachable by terminating computations. Termination must be specified separately. Used mainly to specify transformational programs. We can express I/O specifications by attaching a logical expression about the system variables, both at the beginning and at the end of the program’s execution. The assertion at the beginning defines the admissible initial values of the variables, and the one at the end defines a relationship between the final values and the initial ones. What are I/O Assertions מפרטים פורמאליים - תירגול שחר דג

5 Some notations are used: (1)x=0, and x’=x+1 for some program S (2) (3) The last 2 examples are called “Hoare assertion”. In flowcharts the assertion are added after the “START” and before the “END” statements. What are I/O Assertions (cont.) זוהי לוגיקה ולכן מדובר בשוויון ולא בהצבה Hoare נלמד במבוא לאימות תוכנה (לא לדאוג, לא נעסוק באימות) יתרון מודולאריות S1 S2 שקול ל S1;S2 שקול ל S כאשר S הוא S1 שלאחריו מתבצע S2 מפרטים פורמאליים - תירגול שחר דג

6 What do I/O assertions mean Initial assertions are assumptions made by the program, to be satisfied by the environment. Final assertions are requirements to be satisfied by the program, if and when it terminates. Every terminating computation that satisfies the initial assertion when it starts, must satisfy the final assertion if it terminates. Non-terminating computations and computations not satisfying the initial assertion, satisfy the I/O specification “vacuously”. This is called partial correctness and it is a kind of safety property. Partial correctness is safety since it guaranties that if something happens (the program ends) then the condition is true. מפרטים פורמאליים - תירגול שחר דג

7 Expressing properties with I/O assertions We restrict ourselves to first-order logic and common mathematical notation. Sometimes certain (well known / standard) predicates can be left undefined ( for example integer(x) ). Look at the following specification (4) What does it specify? Which programs satisfy this specification? מפרטים פורמאליים - תירגול שחר דג

8 Annotated programs Sometimes a program skeleton is provided, with assertions between statements. Each assertion, called a local invariant and it is supposed to hold whenever the program’s control is at this location. The assertions immediately before and after a statement (usually a place- holder for un-implemented code) are its I/O specification. The implementation can be shown to satisfy the original specification by using a proof method for correctness based on axioms and proof rules. (but in this course we are not going to prove correctness) For example Is an instance of the axiom And an example of a proof rule the meaning of ‘;’ מפרטים פורמאליים - תירגול שחר דג

9 Using logical variables Variables that appear only in the assertions are called “logical variables” (also called “ rigid variables ” or “ specification variables ”). (Sometimes in order to specify a property, we need variables not present in the program.) Their value doesn’t change during the execution of the program. A logical value just represents some value, and can be quantified (with  or  ) We saw logical variables in: (2) - (3) - X (4) - X מפרטים פורמאליים - תירגול שחר דג

10 Using auxiliary variables We may add to a program “auxiliary variables” (new variables) and statements that assign them values, to support the specification. For example: we might add a Boolean variable flag (initialized to false ) to remember that a certain event has occurred, together with an assignment flag := true at the point where the event occurs. Auxiliary variables get their values only in the added assignment statements, which don’t affect the original system variables. The only references to auxiliary variables must be in the added assignment and in assertions within the annotation of the program. מפרטים פורמאליים - תירגול שחר דג

11 דוגמאות – דוגמא מספר 1 מה הוא אוסף התוכניות שמקימות את המפרט: { true } S { false } מפרטים פורמאליים - תירגול שחר דג

12 דוגמאות – דוגמא מספר 2 יש להגדיר בעזרת לוגיקה את הפרדיקט prime(x) מפרטים פורמאליים - תירגול שחר דג

13 דוגמאות – דוגמא מספר 3 יש להגדיר בעזרת לוגיקה וסימוני קבוצות, את קבוצת כל המספרים הראשוניים שאינם גדולים מ x primes_upto(x) איך פותרים את אותה הבעיה בעזרת לוגיקה בלבד? מפרטים פורמאליים - תירגול שחר דג

14 דוגמאות – דוגמא מספר 4 יש לתת מפרט שיביע מניעה הדדית בין שני קטעים קריטיים (cs1, cs2) בתוכנית המקבילית הבאה (רמז: העזר ב auxiliary variables) P1 CS1 P2 CS2 P :: P1 || P2 מפרטים פורמאליים - תירגול שחר דג

15 דוגמאות – דוגמא מספר 5 תן מפרט קלט/פלט לפרוצדורה P המקבלת מספר טבעי n ומחזירה מספר טבעי m ומערך a[1..m] המכיל את כל המספרים הראשוניים שאינם גדולים מ n (אבל לא מכיל אף מספר אחר). כל מספר יופיע במערך בדיוק פעם אחת. מפרטים פורמאליים - תירגול שחר דג

16 דוגמאות – דוגמא מספר 5 (המשך) תיאור אלטרנטיבי יהיה: מפרטים פורמאליים - תירגול שחר דג

17 דוגמאות – שעשועי לוגיקה הגדר בעזרת לוגיקה את המשפט: "לכל אדם יש אב" בצורה דומה נגדיר בעזרת לוגיקה את המשפט: "לכל אדם יש אם אנושית" איך נגדיר כי לכל אדם אב ואם אנושיים הנשואים זה לזו. מפרטים פורמאליים - תירגול שחר דג