Types for Programs and Proofs

Slides:



Advertisements
Similar presentations
Chapt.2 Machine Architecture Impact of languages –Support – faster, more secure Primitive Operations –e.g. nested subroutine calls »Subroutines implemented.
Advertisements

Lecture 9: Implementation Dr Valentina Plekhanova University of Sunderland, UK.
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
INF 212 ANALYSIS OF PROG. LANGS Type Systems Instructors: Crista Lopes Copyright © Instructors.
Type Checking.
Software Engineering and Design Principles Chapter 1.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 5 Types Types are the leaven of computer programming;
B-1 Lecture 2: Problems, Algorithms, and Programs © 2000 UW CSE University of Washington Computer Programming I.
Lecture Notes 1/21/04 Program Design & Intro to Algorithms.
School of Computer ScienceG53FSP Formal Specification1 Dr. Rong Qu Introduction to Formal Specification
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
CODING Research Data Management. Research Data Management Coding When writing software or analytical code it is important that others and your future.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
Language Evaluation Criteria
A First Program Using C#
Types for Programs and Proofs Lecture 1. What are types? int, float, char, …, arrays types of procedures, functions, references, records, objects,...
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
CSCE 121: Introduction to Program Design and Concepts, Honors Dr. J. Michael Moore Spring 2015 Set 3: Objects, Types, and Values 1 Based on slides.
Chapter 06 (Part I) Functions and an Introduction to Recursion.
1 ENERGY 211 / CME 211 Lecture 26 November 19, 2008.
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Functions, Procedures, and Abstraction Dr. José M. Reyes Álamo.
Writing Systems Software in a Functional Language An Experience Report Iavor Diatchki, Thomas Hallgren, Mark Jones, Rebekah Leslie, Andrew Tolmach.
Types(1). Lecture 52 Type(1)  A type is a collection of values and operations on those values. Integer type  values..., -2, -1, 0, 1, 2,...  operations.
The Software Development Process
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Chapter 3 Top-Down Design with Functions Part II J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National.
 Programming - the process of creating computer programs.
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming - Week.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
Chapter 1 The Phases of Software Development. Software Development Phases ● Specification of the task ● Design of a solution ● Implementation of solution.
Mid-Year Review. Coding Problems In general, solve the coding problems by doing it piece by piece. Makes it easier to think about Break parts of code.
Introduction to Algorithmic Processes CMPSC 201C Fall 2000.
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
Language-Based Security: Overview of Types Deepak Garg Foundations of Security and Privacy October 27, 2009.
Sub-fields of computer science. Sub-fields of computer science.
Functional Programming
Introduction to Algorithms
CSC 222: Object-Oriented Programming
CSC 222: Object-Oriented Programming
SOFTWARE TESTING Date: 29-Dec-2016 By: Ram Karthick.
CSC 222: Computer Programming II
Coupling and Cohesion Rajni Bhalla.
Basic 1960s It was designed to emphasize ease of use. Became widespread on microcomputers It is relatively simple. Will make it easier for people with.
Computer Programming (BCT 1113)
PROGRAMMING LANGUAGES
CSCI-235 Micro-Computer Applications
Revision Lecture
CSC 222: Object-Oriented Programming
Lecture 2 of Computer Science II
Software Prototyping Animating and demonstrating system requirements.
Foundations of Computer Science
Names, Binding, and Scope
Functions, Procedures, and Abstraction
Chapter 6 Methods: A Deeper Look
Lecture 22 Inheritance Richard Gesick.
MSIS 655 Advanced Business Applications Programming
Programming Languages 2nd edition Tucker and Noonan
Programming.
Introduction to Algorithms
강의 내용 및 방법 접근방법 리포트 시험 Lambda Calculus, Proof of Correctness
Chapter 2. Problem Solving and Software Engineering
Type Systems Terms to learn about types: Related concepts: Type
Oriented Design and Abstract Data Type
CSCE156: Introduction to Computer Science II
Functions, Procedures, and Abstraction
CHAPTER 6 Testing and Debugging.
Presentation transcript:

Types for Programs and Proofs Lecture 1

Building reliable software is hard The scale and complexity of modern systems, the number of people involved in building them, and the range of demands placed on them render it extremely difficult to build software that is even more-or-less correct, much less 100% correct. At the same time, the increasing degree to which information processing is woven into every aspect of society continually amplifies the cost of bugs and insecurities. [“Software Foundations”]

Host of techniques for improving software reliability recommendations about managing software projects and organizing programming teams (e.g., extreme programming)  design philosophies for libraries (e.g., model-view-controller, publish-subscribe, etc.)  programming languages (e.g., object-oriented programming, aspect-oriented programming, functional programming, ...)  mathematical techniques for specifying and reasoning about properties of software tools for helping validate these properties.

What are types? int, float, char, …, arrays types of procedures, functions, references, records, objects, ... recursive types, polymorphic types, abstract types, dependent types, subtypes, …

Purpose of types Specification. To define what the program should do. For example, read an array of integers and return a double. To document the programmer's intentions. It is better than comments, which are not checked by the compiler Bug-finding. To guarantee that the program is meaningful. For example that it does not add a string to an integer and that variables are declared before they are used Optimization. To optimize the use of hardware. To reserve the minimal amount of memory, but not more. To use the most appropriate machine instructions

What belongs to type checking? Depending on the language, the type checker can prevent the application of a function to the wrong number of arguments the application of integer functions to floats The use of undeclared variables in expressions, division by zero array indices out of bounds, non-terminating recursion, sorting algorithms that don't sort... Languages differ greatly: no programming language checks all of the above! But the more static checking in the compiler, the less need for manual debugging.

Types help detect errors E g applying a function to too few arguments, indexing array out of bounds, variable out of scope good to detect errors early rather than at run time can expose a surprisingly wide range of errors if the type system is rich programs tend "to just work" when type-checked (not only trivial mental slips but also deeper conceptual errors are exposed) the strength of this effect depends on the richness of the type system as well as the nature of the task. For example, do we manipulate many data structures? Coding everything in terms of lists will expose fewer errors than if we use different types for different data structures.

Abstraction, modularity structure programs using abstract data types enforce disciplined programming type systems form the backbone of module languages used to package and tie together components structuring large systems in terms of modules with clear interfaces leads to abstract design.

Code reuse Polymorphism in Haskell Generics in Java

Language safety a language is safe if it protects its own abstractions. High-level languages have abstractions of machine services. Safety means that the language protects these abstractions - you expect that an array can be changed just by the update operation and not by writing past the end of some other data structure, etc. In an unsafe language you need to keep track of low level details (C, C++) depending on the implementation. Such languages cannot be understood by the reading the language manual only Checks can happen both at type-checking time and at run-time (Lisp, Scheme, Perl do run-time checks) Array-bounds-checking is normally done at run-time, doing it statically is a long-standing problem ("dependent types" offer the solution, but this is still research topic) - escape hatches (foreign function calls)

New applications Computer and network security (one aspect of programming language based security is type-systems) Program analysis (Anno Domini) Automated theorem proving (Propositions as types) Databases, web metadata (static type system for XML) Computational linguistics (types in computational linguistics)