Logic and Language, Proposition and Types, Proofs and Computation

Similar documents
Mathematical Induction

Reading 13 : Finite State Automata and Regular Expressions

CHAPTER 7 GENERAL PROOF SYSTEMS

ML for the Working Programmer

Termination Checking: Comparing Structural Recursion and Sized Types by Examples

Using the Computer to Prove the Correctness of Programs p.1/12

CS510 Software Engineering

Datavetenskapligt Program (kandidat) Computer Science Programme (master)

Overview of E0222: Automata and Computability

Handout #1: Mathematical Reasoning

The Halting Problem is Undecidable

Logic in Computer Science: Logic Gates

Mathematical Induction. Lecture 10-11

Lecture 2: Universality

Regular Languages and Finite Automata

Deterministic Discrete Modeling

Computability Theory

02 B The Java Virtual Machine

Chapter 7D The Java Virtual Machine

CHAPTER 2. Logic. 1. Logic Definitions. Notation: Variables are used to represent propositions. The most common variables used are p, q, and r.

Regression Verification: Status Report

Automata Theory. Şubat 2006 Tuğrul Yılmaz Ankara Üniversitesi

language 1 (source) compiler language 2 (target) Figure 1: Compiling a program

Fixed-Point Logics and Computation

Dependent Types at Work

Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy

THEORY of COMPUTATION

MACM 101 Discrete Mathematics I

Computer Science Theory. From the course description:

6.080/6.089 GITCS Feb 12, Lecture 3

Automata and Formal Languages

NP-Completeness and Cook s Theorem

Software Modeling and Verification

Basic Proof Techniques

Informatique Fondamentale IMA S8

Properties of Stabilizing Computations

Introduction to formal semantics -

Deterministic Finite Automata

Computational Models Lecture 8, Spring 2009

CSE 135: Introduction to Theory of Computation Decidability and Recognizability

Introduction to Automata Theory. Reading: Chapter 1

Division of Mathematical Sciences

Declarative Models for Hybrid Machine Translation Proposal for VR Projektbidrag, Appendix A

Finite Automata and Formal Languages

CMPSCI 250: Introduction to Computation. Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013

Logic in general. Inference rules and theorem proving

Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

SECTION 10-2 Mathematical Induction

Teaching Formal Methods for Computational Linguistics at Uppsala University

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

CS 301 Course Information

Full and Complete Binary Trees

Chapter 15 Functional Programming Languages

Algorithmic Software Verification

CSC4510 AUTOMATA 2.1 Finite Automata: Examples and D efinitions Definitions

Examination paper for MA0301 Elementær diskret matematikk

Degrees Major in Computer Science Minor in Computer Science Major in Software Engineering

COMPUTER SCIENCE TRIPOS

No Solution Equations Let s look at the following equation: 2 +3=2 +7

CS 3719 (Theory of Computation and Algorithms) Lecture 4

Invalidity in Predicate Logic

Cassandra. References:

Runtime Verification - Monitor-oriented Programming - Monitor-based Runtime Reflection

THE DEGREES OF BI-HYPERHYPERIMMUNE SETS

MATHEMATICS: CONCEPTS, AND FOUNDATIONS Vol. III - Logic and Computer Science - Phokion G. Kolaitis

C H A P T E R Regular Expressions regular expression

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 4 Nancy Lynch

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University

CAs and Turing Machines. The Basis for Universal Computation

(IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems.

Philadelphia University Faculty of Information Technology Department of Computer Science First Semester, 2007/2008.

WRITING PROOFS. Christopher Heil Georgia Institute of Technology

COURSE TITLE COURSE DESCRIPTION

Programming Languages

How To Program In Scheme (Prolog)

INTRODUCTORY SET THEORY

Introduction to Logic: Argumentation and Interpretation. Vysoká škola mezinárodních a veřejných vztahů PhDr. Peter Jan Kosmály, Ph.D

How To Understand The Theory Of Computer Science

Semester Review. CSC 301, Fall 2015

Universality in the theory of algorithms and computer science

Compiler Construction

Regular Languages and Finite State Machines

Regular Expressions and Automata using Haskell

CS154. Turing Machines. Turing Machine. Turing Machines versus DFAs FINITE STATE CONTROL AI N P U T INFINITE TAPE. read write move.

University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. CSC467 Compilers and Interpreters Fall Semester, 2005

An Agda Tutorial. Makoto Takeyama

A Propositional Dynamic Logic for CCS Programs

Lab Experience 17. Programming Language Translation

Turing Machines: An Introduction

Chapter 4 Lecture 5 The Microarchitecture Level Integer JAVA Virtual Machine

Honors Class (Foundations of) Informatics. Tom Verhoeff. Department of Mathematics & Computer Science Software Engineering & Technology

Module Catalogue for the Bachelor Program in Computational Linguistics at the University of Heidelberg

Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

FINITE STATE AND TURING MACHINES

Introduction to Theory of Computation

Model 2.4 Faculty member + student

MATHEMATICAL INDUCTION. Mathematical Induction. This is a powerful method to prove properties of positive integers.

Functional Programming

Today s Agenda. Automata and Logic. Quiz 4 Temporal Logic. Introduction Buchi Automata Linear Time Logic Summary

def: An axiom is a statement that is assumed to be true, or in the case of a mathematical system, is used to specify the system.

Transcription:

Logic and Language, Proposition and Types, Proofs and Computation The Particle Physics of Computer Science Andreas Abel Department of Computer Science and Engineering Chalmers and Gothenburg University Introduction for 1st year students Lunch Seminar, HC2, Chalmers 21 April 2015 Andreas Abel (GU) Logic, Types, Computation Intro 1st year 1 / 15

Programming Logic ProgLog group Professors: Thierry Coquand, Peter Dybjer, Bengt Nordström Permanent staff: Andreas Abel, Ana Bove, Nils Anders Danielsson, Ulf Norell Overall goal: Correctness of programs through logical means Foundations of programming Foundations of logics and mathematics Andreas Abel (GU) Logic, Types, Computation Intro 1st year 2 / 15

Correctness of programs Example: compiler correctness. Produced JVM byte code should faithfully represent Java source code. JAVA: y = x + 5 JVM: iload 1 bipush 5 iadd istore 2 There are infinitely many possible Java programs; we cannot test the compiler on all. Andreas Abel (GU) Logic, Types, Computation Intro 1st year 3 / 15

Compiler correctness Compiler is a function, inputs Java, outputs JVM. compile : Java JVM Correctness means that compilation preserves meaning of code. Meaning of target: behavior of JVM code when run (executed in bytecode interpreter). Meaning of source: behavior of Java program when executed in an interpreter. (p : Java) interpret(p) = run(compile(p)) Andreas Abel (GU) Logic, Types, Computation Intro 1st year 4 / 15

Compiler correctness What is a Java program, mathematically? A sentence (string) following the Java grammar. [Languages, grammars, parsing] Representable as abstract syntax tree. [Data structures, recursion] What is JVM code, mathematically? What is the meaning of a Java program? [Interpreter, semantics] What is the meaning of JVM code? [Machines, execution] What does equal behavior mean? [Relations, models of computation] How can we prove something for all Java programs? [Logic, induction] How can we be sure our proof is correct? [Proof theory, machine-assisted verification] Andreas Abel (GU) Logic, Types, Computation Intro 1st year 5 / 15

A simpler example Say we have a list l of natural numbers. i 0 1 2... i... n 1 l 2 3 5... lookup l i... lookup l (n 1) incr l 3 4 6... 1 + lookup l i... 1 + lookup l (n 1) The following two should be equivalent. 1 Making a copy of the list with each element increased by 1 (incr) and then taking the ith element (lookup). 2 Taking the ith element (lookup) and increase it by 1 (suc). (l : List N)(i : N) lookup (incr l) i suc (lookup l i) Andreas Abel (GU) Logic, Types, Computation Intro 1st year 6 / 15

Modelling our example Data structures: natural numbers and lists [choice, composition, recursion] Functions: traversing a list [case distinction, recursion] Logic: proof of universal ( ) statement [induction = case distinction + recursion] Andreas Abel (GU) Logic, Types, Computation Intro 1st year 7 / 15

Curry-Howard-Isomorphismus Proposition = Set proof = program/data Discovered in 1950s. Logic inspires programming language research. Programming language constructs find logical interpretations. Andreas Abel (GU) Logic, Types, Computation Intro 1st year 8 / 15

Particles of Computer Science A logical approach to information and computation. With quotes from L. & A. Wachowski, The Matrix Reloaded Andreas Abel (GU) Logic, Types, Computation Intro 1st year 9 / 15

Causality (Implication) Merovingian: You see, there is only one constant, one universal, It is the only real truth: causality. Action. Reaction. Cause and effect. Functions. Transforming input to output. Implication. Conclusions from premises. incr : List N List N lookup-incr : (l : List N)(i : N) lookup (incr l) i suc (lookup l i) (Even(n) Prime(n)) n 2 Andreas Abel (GU) Logic, Types, Computation Intro 1st year 10 / 15

Structure (Conjunction) Keymaker: The system is based on the rules of a building. One system built on another. Tuples: several things put together. E.g. the cons of lists, pairing head (1st element) and tail (rest). Conjunction: 2 is an odd prime number. (1, 2) head :: tail Odd(2) Prime(2) If one fails, all fail. Andreas Abel (GU) Logic, Types, Computation Intro 1st year 11 / 15

Choice (Disjunction) The Oracle: We can never see past the choices we don t understand. Morpheus: Everything begins with choice. Bits: false or true, zero or successor, empty list or cons. Each natural number is either even or odd. bit 0 1 Bool false true N zero suc List [] :: Neo: Choice. The problem is choice. Even(n) Odd(n) Andreas Abel (GU) Logic, Types, Computation Intro 1st year 12 / 15

Recursion Agent Jackson: You. Smith: Yes me. Me, me, me! Agent Jackson/Smith: Me too! Smith: Go ahead, shoot. The best thing about being me there s so many me. Recursive data types (e.g. lists). Recursive functions (e.g. incr, lookup). Recursive proofs (induction, e.g. lookup-incr). (n : N) :: (l : List N) : List N lookup (n :: l) (suc i) = lookup l i Andreas Abel (GU) Logic, Types, Computation Intro 1st year 13 / 15

Agda Haskell-like programming language Based on the Curry-Howard-Isomorphismus Agda 2 developed at Chalmers since 2006 Precursors since 1980s (ALF, Half, Alfa, Agda) Andreas Abel (GU) Logic, Types, Computation Intro 1st year 14 / 15

ProgLog Courses DAT060 Logic in computer science (Coquand) Proof calculi, applications of logic TMV027 Finite automata and formal languages (Bove) Grammars, parsing DAT140 Types for proofs and programs (Dybjer) Programming language theory Type theory and Agda TDA183 Models of computation (Nordström) Lambda calculus, Turing machines Undecidability Andreas Abel (GU) Logic, Types, Computation Intro 1st year 15 / 15