Java s Precedence. Extended Grammar for Boolean Expressions: Implication. Parse tree. Highest precedence. Lowest precedence

Similar documents
Suppose I have two C programs: M1.c and M2.c

Epimenides, Gödel, Turing: an Eternal Gölden Tangle [0]

THE HALTING PROBLEM. Joshua Eckroth Chautauqua Nov

Kurt Gödel and Computability Theory

Chapter 12. Computability Mechanizing Reasoning

In order to solve the puzzle, you try to form the string MU starting with the string MI and using the following rules for forming new strings from old

Propositional Logic Formal Syntax and Semantics. Computability and Logic

CS61A Lecture 38. Robert Huang UC Berkeley April 17, 2013

Menu. Lecture 25: Gödel and Computability. Computability. Proof General Idea. Gödel s Statement

05. Turing Machines and Spacetime. I. Turing Machines and Classical Computability.

Diagonalization. The cardinality of a finite set is easy to grasp: {1,3,4} = 3. But what about infinite sets?

NP versus PSPACE. Frank Vega. To cite this version: HAL Id: hal

Notes on Turing s Theorem and Computability

Computability, Cantor s diagonalization, Russell s Paradox, Gödel s s Incompleteness, Turing Halting Problem.

Introduction to Computer Science

λ-calculus Lecture 1 Venanzio Capretta MGS Nottingham

the Computability Hierarchy

UNIT 14C The Limits of Computing: Non computable Functions. Problem Classifications

Chapter 3. Describing Syntax and Semantics

Material from Recitation 1

CSE 120. Computer Science Principles

Introduction to Automata Theory. BİL405 - Automata Theory and Formal Languages 1

MATH Iris Loeb.

Chapter Summary. Mathematical Induction Recursive Definitions Structural Induction Recursive Algorithms

Presented By : Abhinav Aggarwal CSI-IDD, V th yr Indian Institute of Technology Roorkee. Joint work with: Prof. Padam Kumar

What computers just cannot do. COS 116: 2/28/2008 Sanjeev Arora

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

Typing Control. Chapter Conditionals

Lambda Calculus and Computation

Midterms Save the Dates!

Chapter 3. Describing Syntax and Semantics ISBN

Logical Operators and switch

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

Lecture 5: The Halting Problem. Michael Beeson

Recursively Enumerable Languages, Turing Machines, and Decidability

How convincing is our Halting Problem proof? Lecture 36: Modeling Computing. Solutions. DrScheme. What is a model? Modeling Computation

COMP combinational logic 1 Jan. 18, 2016

System Correctness. EEC 421/521: Software Engineering. System Correctness. The Problem at Hand. A system is correct when it meets its requirements

Ramsey s Theorem on Graphs

Introduction to the λ-calculus

CS 106 Winter 2016 Craig S. Kaplan. Module 07 Recursion and fractals Topics. Recursion as an extension of hierarchical modelling Simple fractals

Programming Lecture 3

Today, we will dispel the notion that Java is a magical language that allows us to solve any problem we want if we re smart enough.

The Eval/Apply Cycle Eval. Evaluation and universal machines. Examining the role of Eval. Eval from perspective of language designer

Denotational semantics

Computation Club: Gödel s theorem

CS 531: Notes II. January 31, 2014

Rice s Theorem and Enumeration

Lecture 3: Recursion; Structural Induction

Programming Languages and Techniques (CIS120)

Chapter 3. Describing Syntax and Semantics

AXIOMS FOR THE INTEGERS

CS2 Algorithms and Data Structures Note 10. Depth-First Search and Topological Sorting

Lecture T4: Computability

Program Verification & Testing; Review of Propositional Logic

THEORY OF COMPUTATION

Discrete Mathematics Lecture 4. Harper Langston New York University

CS 135 Lab Assignments Week 1

Computer Sciences Department

Theory of Programming Languages COMP360

Programming Proofs and Proving Programs. Nick Benton Microsoft Research, Cambridge

Formal Semantics. Chapter Twenty-Three Modern Programming Languages, 2nd ed. 1

Introduction to the Theory of Computation, Sipser, PWS, ISBN X, 1996

cis20.1 design and implementation of software applications I fall 2007 lecture # I.2 topics: introduction to java, part 1

CSE101: Design and Analysis of Algorithms. Ragesh Jaiswal, CSE, UCSD

News and information! Review: Java Programs! Feedback after Lecture 2! Dead-lines for the first two lab assignment have been posted.!

Computability and Complexity

Lecture 2: SML Basics

(a) (4 pts) Prove that if a and b are rational, then ab is rational. Since a and b are rational they can be written as the ratio of integers a 1

Formal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5

HW1. Due: September 13, 2018

This book is licensed under a Creative Commons Attribution 3.0 License

ELEMENTARY NUMBER THEORY AND METHODS OF PROOF

4.1 Review - the DPLL procedure

(Refer Slide Time 3:31)

Time Complexity of an Algorithm

(Refer Slide Time 6:48)

CS103 Handout 14 Winter February 8, 2013 Problem Set 5

CS2104 Prog. Lang. Concepts

Verifying Safety Property of Lustre Programs: Temporal Induction

arxiv: v2 [cs.lo] 29 Sep 2015

Objective and Subjective Specifications

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: April 1, 2015

Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction 1

Unsolvable Problems Do Not Exist Only the Absence of Input Prevents Calculation

Compilers - Chapter 2: An introduction to syntax analysis (and a complete toy compiler)

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

Steven Skiena. skiena

CS525 Winter 2012 \ Class Assignment #2 Preparation

How to Compute Halting

CITS5501 Software Testing and Quality Assurance Formal methods

CSCI 270: Introduction to Algorithms and Theory of Computing Fall 2017 Prof: Leonard Adleman Scribe: Joseph Bebel

Propositional Logic. Part I

LOGIC AND DISCRETE MATHEMATICS

Computability Mechanizing Reasoning

Lecture Notes 15 Number systems and logic CSS Data Structures and Object-Oriented Programming Professor Clark F. Olson

CpSc 421 Final Solutions

Computability Mechanizing Reasoning

Chapter 3. Syntax - the form or structure of the expressions, statements, and program units

Transcription:

The Tiling Problem The Halting Problem Highest precedence Java s Precedence G!del, Escher, Bach Natural, yet unsolvable problems Adding variables Adding operators Lecture 19 Lab 4: A Matter of Expression BNF More on Boolean Expressions Unary operators: ++, --,!, unary - and +, type-cast Multiplication and division: *, /, % Addition and subtraction: +, - Relational operators: <, >, <=, >= Equality and inequality: ==,!= Boolean and: && Boolean or: Conditional operator:?: Assignment operators: =, +=, -=, *=, /=, %= Lowest precedence 2 Parse tree Extended Grammar for Boolean Expressions: Implication <bexpr> ::= <bterm> <bexpr > <bexpr > ::= <bterm> <bexpr > -> <bterm> <bexpr > e <bterm> ::= <bfactor> <bterm > <bterm > ::= && <bfactor> <bterm > e <bfactor> ::=! <bfactor> ( <bexpr> ) <boolconst> variable 3 <boolconst> ::= true false 4

Truth table P Q P! Q P " Q P # Q Imp 5 6 Two operators sharing the same symbol <bexpr> ::= <bterm> <bexpr > <bexpr > ::= <bterm> <bexpr > # <bterm> <bexpr > e <bterm> ::= <bfactor> <bterm > <bterm > ::= && <bfactor> <bterm > e <bfactor> ::=! <bfactor> # <bfactor> ( <bexpr> ) <boolconst> variable <boolconst> ::= true false 7 BNF expressed in BNF <syntax> ::= { <rule> } <rule> ::= <id> ::= <bnfexpr> <bnfexpr> ::= <bnfterm> { <bnfterm> } <bnfterm> ::= <bnffactor> { <bnffactor> } <bnffactor> ::= <id> <quoted_symb> ( <bnfexpr> ) [ <bnfexpr> ] { <bnfexpr> } <id> ::= letter { letter digit } <quoted_symb> ::= { any_character } 8

Computational aspects on problems Many problems are solvable in a finite number of steps. Easy problems with polynomial-time algorithms. Harder problems with exponential time algorithms. Some of these could be easier but no one knows But are all (computational) problems solvable in finite time or even in infinite time.. or at all??! Unfortunately, No. 9 Unsolvable problems (Last lecture: The Tiling Problem: Given a set of k different quadratic 1!1 tiles, can they (any number of each kind) be used to cover all rectangular regions?) Today: The Halting Problem: Given a computer program as input, will that program terminate when given some input I? 10 Preliminaries We only consider programs that get their input when it is requested. A user cannot stall the program indefinitely by refusing to enter data via, say, the keyboard. Computer programs can be represented as strings. This is also true for the input. Source code. A program either terminates or runs forever. To save space we use methods instead of programs. The argument is based on proof by contradiction : Assume X. If we can then establish a contradiction after having argued (correctly), we have proved and can conclude not X. A formal proof would be much more complicated then what is shown here. 11 The Halting Problem Assume that there is a method (a computer program) halt(string s, String i) that given a program s and an input i determines whether s terminates or not when given i as input. The result is either yes or no. Consider this method (computer program): public static String trouble(string x) { if (halt(x, x)== no ) { return yes ; } else { while (true) {}; // infinite loop } } 12

The Halting Problem Let t be the string that represents the method trouble. Then, what is the result (output) of program halt(t, t)? input The Halting Problem Alan Turing, On computable numbers, with an application to the Entscheidungsproblem, Proceedings of the London Mathematical Society, Series 2, 42 (1936), pp 230-265. If no, trouble doesn t terminate if given t as input. But (looking at the code of trouble) that can only happen if trouble terminates! A contradiction. If yes, trouble terminates. But then (again by looking at the code of trouble) if it really terminates the result of halt(t,t) must be no! Yet a contradiction. We conclude that halt doesn t exist. So, the halting problem has no solution; there is no algorithm that solves the problem(!) 13 Alan Turing 14 Comment As stated, the Halting Problem must work for all possible programs. In our proof, we used one program (trouble) to reach contradictions. However, there might be special kinds of programs that can be checked. A common and practical approach to hard problems is to only consider restricted (easy) cases that can be solved efficiently. Gödel, Escher, Bach - An Eternal Golden Braid Douglas R. Hofstadtler (ISBN 0465026567). Pulitzer Prize winner. A book about how the creative achievements of logician Kurt Gödel, artist M. C. Escher and composer Johan Sebastian Bach interweave. As the author states: "I realized that to me, Gödel and Escher and Bach were only shadows cast in different directions by some central solid essence. I tried to reconstruct the central object, and came up with this book. 15 16

"Do words and thoughts follow formal rules, or do they not?" "GEB is a very personal attempt to say how it is that animate beings can come out of inanimate matter. What is a self, and how can a self come out of stuff that is as selfless as a stone or a puddle?" 17 18 20 M. C. Escher (1898-1972) Ascending and Descending, 1960. Drawing Hands, 1948 Johann Sebastian Bach (1685-1750) Two-part invention No. 8, F-Major, BWV 779 (1723) 19

K. Gödel, Über formal unentscheidbare Sätze der Principia Mathematica und verwandter Systeme. I. Monatsh. Math. Phys. 38, 173-198 (1931). René Magritte (1898-1967) Belgian painter Surrealist The Incompleteness Theorem (In any consistent formalization of mathematics that is sufficiently strong to axiomatize the natural numbers, that is, sufficiently strong to define the operations that collectively define the natural numbers ) One can construct a true (!) statement that can be neither proved nor disproved within that system itself. Kurt Gödel (1906-1978) 21 23 22