cs 245 logic and computation
play

CS 245 Logic and Computation Lecture 1 Richard Trefler - PowerPoint PPT Presentation

CS 245 Logic and Computation Lecture 1 Richard Trefler trefler@cs.uwaterloo.ca DC 2336 http://www.student.math.uwaterloo.ca/cs245 uw.cs.se112cs245 cs245@student.uwaterloo.ca p.1/42 Todays Agenda What is this course about?


  1. CS 245 Logic and Computation Lecture 1 Richard Trefler trefler@cs.uwaterloo.ca DC 2336 http://www.student.math.uwaterloo.ca/˜cs245 uw.cs.se112cs245 cs245@student.uwaterloo.ca – p.1/42

  2. Today’s Agenda What is this course about? Motivation Course Outline Course Resources Course Grade Questions – p.2/42

  3. CS 245: Logic and Computation This course is about logic and its use in software engineering. In particular, we will study the use of logic for specification and checking the correctness of programs. – p.3/42

  4. Program Correctness When you write a program: . . . how do you know what it’s supposed to do? – p.4/42

  5. Program Correctness When you write a program: . . . how do you know what it’s supposed to do? (specification) – p.4/42

  6. Program Correctness When you write a program: . . . how do you know what it’s supposed to do? (specification) . . . how do you know that it does what it’s supposed to do? (correctness) – p.4/42

  7. Program Correctness When you write a program: . . . how do you know what it’s supposed to do? (specification) . . . how do you know that it does what it’s supposed to do? (correctness) inspection testing – p.4/42

  8. Program Correctness When you write a program: . . . how do you know what it’s supposed to do? (specification) . . . how do you know that it does what it’s supposed to do? (correctness) inspection testing formal verification – p.4/42

  9. Formal Verification In this course, we will learn a technique for doing a more thorough check of whether your program is correct. This is called formal verification (FV) and is based on logical reasoning. It’s also called “formal methods” or “computer-aided verification”. Formal verification checks the correctness of your program for all possible inputs. However, these methods can require more effort, and therefore are complementary to testing and inspection. – p.5/42

  10. What is logical reasoning? Example: If the train arrives late and there are no taxis at the station, then John is late for his meeting. John is not late for his meeting. The train did arrive late. Were there taxis at the station or not? – p.6/42

  11. What is logical reasoning? Example: If the train arrives late and there are no taxis at the station, then John is late for his meeting. John is not late for his meeting. The train did arrive late. Therefore, there were taxis at the station. This argument has a structure. There are premises (facts). Then there is something we deduce from the facts called a conclusion. The conclusion logically follows from the facts. – p.6/42

  12. What is logic? – p.7/42

  13. What is logic? According to Webster’s, logic is “the science of correct reasoning”. – p.7/42

  14. What is logic? According to Webster’s, logic is “the science of correct reasoning”. According to the Free On-Line Dictionary of Computing, “logic is concerned with what is true and how we can know whether something is true”. – p.7/42

  15. What is logic? According to Webster’s, logic is “the science of correct reasoning”. According to the Free On-Line Dictionary of Computing, “logic is concerned with what is true and how we can know whether something is true”. Using logic, we can reason about a system. We can determine whether a program behaves correctly for all possible input values. Testing can only check the program for some (carefully chosen) input values. – p.7/42

  16. Logical Arguments Example 1: If the train arrives late and there are no taxis at the station, then John is late for his meeting. John is not late for his meeting. The train did arrive late. Therefore, there were taxis at the station. Here’s another example of a logical argument: Example 2: If it is raining and Jane does not have her umbrella with her, then she will get wet. Jane is not wet. It is raining. Therefore, Jane has her umbrella with her. – p.8/42

  17. Logical Arguments Example 1: If the train arrives late and there are no taxis at the station, then John is late for his meeting. John is not late for his meeting. The train did arrive late. Therefore, there were taxis at the station. Here’s another example of a logical argument: Example 2: If it is raining and Jane does not have her umbrella with her, then she will get wet. Jane is not wet. It is raining. Therefore, Jane has her umbrella with her. These two arguments have the same structure, but use different sentence fragments. – p.8/42

  18. Logical Arguments Example 1: If the train arrives late and there are no taxis at the station, then John is late for his meeting. John is not late for his meeting. The train did arrive late. Therefore, there were taxis at the station. Example 2: If it is raining and Jane does not have her umbrella with her, then she will get wet. Jane is not wet. It is raining. Therefore, Jane has her umbrella with her. Example 1 Example 2 the train is late it is raining there are taxis at the station Jane has her umbrella with her John is late for his meeting Jane gets wet – p.9/42

  19. Logical Arguments The argument can be stated independently of Jane and John and umbrellas and trains and taxis by substituting letters for the sentences as in: Letter Example 1 Example 2 the train is late it is raining p there are taxis at the station Jane has her umbrella with her q John is late for his meeting Jane gets wet r The valid argument is then: If p and not q then r . Not r . p . (therefore) q – p.10/42

  20. Logic Logic is concerned with the structure of the argument, not the meaning of the sentences. In a logic, there are rules about which structures of arguments are valid and which are not. A logical argument is very rigorous. Only certain rules (the rules of the logic) can be used in a logical argument. In logic, we use symbols to represent the sentences. It’s sometimes called symbolic logic. – p.11/42

  21. Logical Reasoning and Verification Using logical reasoning, we can deduce properties of our software. We can view a program as a logical argument. Logic has many other applications within computer science: digital circuits artificial intelligence compilers database queries etc. – p.12/42

  22. Today’s Agenda What is this course about? Motivation Course Outline Course Resources Course Grade Questions – p.13/42

  23. Motivation It is widely agreed that the main obstacle to “help computers help us more” and relegate to these helpful partners even more complex and sensitive tasks is not inadequate speed and unsatisfactory raw computing power in the existing machines, but our limited ability to design and implement complex systems with sufficiently high degree of confidence in their correctness under all circumstances. – Amir Pnueli, Turing Award Winner This course is about the basics of techniques for ensuring that software works “correctly” in the environments of its intended use. – p.14/42

  24. Software Engineering Because of the complexity of software, it can often have subtle bugs. When used in safety-critical applications, these bugs can cost lives or huge amounts of money. Because of these problems, most commercial software comes with no guarantees. – p.15/42

  25. Safety-critical software In Britain, the use of techniques based on what you will learn in this course is required for some safety-critical applications. British Ministry of Defense Interim defense standard 00-55, is on “requirements for the procurement of safety critical software in defense equipment”: 31.2.1 The Design Team shall construct the Proof Obligations that verify the source code with respect to its Formal Design, and discharge them by means of Formal Arguments, as laid down in 32.1. 32.1.1 Formal Arguments shall be constructed using Formal Proofs or Rigorous Arguments. – p.16/42

  26. Loss of Life: Therac-25 A computer-controlled radiation therapy machine called the Therac-25 made by Atomic Energy of Canada overdosed six people between June, 1985 and January 1987. Two of these people died because of the overdose. In some cases the only indication that something was wrong was the cryptic message: malfunction 54 The error was a timing problem on data entry. – p.17/42

  27. Loss of Life: Therac-25 (cont’d) The Therac-25 could deliver radiation as either a beam of electrons or a beam of X-rays. If the operator entered “x” for x rays, the setting of the magnets took 8 seconds. If the operator discovered she had made a mistake and fixed the entry to be “e” within that 8 seconds, even though the screen reflected the change, the change did not affect a part of the program. – p.18/42

  28. Banking ... February 1994, automated teller machines (ATMs) at Chemical Bank in New York City mistakenly deducted a total of approximately $15 million dollars from about a hundred thousand customer accounts . Until the problem was discovered, any customers making withdrawal were charged double the withdrawal’s actual amount on their accounts, although the printed transaction slip showed the correct amount. Only those people who later checked their balance – and knew what it should have been – realized there had been an error. The culprit proved to be a flawed instruction – a single line in updated computer program the company had installed the day before the problem surfaced. – Ivars Peterson, “Fatal Defect: Chasing Killer Computer Bugs”, Vintage Books, 1996, p. 17 – p.19/42

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend