Halting and Equivalence of Schemes over Recursive Theories

Similar documents
Halting and Equivalence of Program Schemes in Models of Arbitrary Theories

Introduction to Kleene Algebra Lecture 15 CS786 Spring 2004 March 15 & 29, 2004

Introduction to Kleene Algebra Lecture 14 CS786 Spring 2004 March 15, 2004

Part I: Definitions and Properties

About the relationship between formal logic and complexity classes

Algebras with finite descriptions

Informal Statement Calculus

First-Order Logic First-Order Theories. Roopsha Samanta. Partly based on slides by Aaron Bradley and Isil Dillig

Decision Problems with TM s. Lecture 31: Halting Problem. Universe of discourse. Semi-decidable. Look at following sets: CSCI 81 Spring, 2012

Propositional Logic Language

Introduction to Turing Machines

1 Showing Recognizability

PREDICATE LOGIC: UNDECIDABILITY AND INCOMPLETENESS HUTH AND RYAN 2.5, SUPPLEMENTARY NOTES 2

Herbrand Theorem, Equality, and Compactness

Most General computer?

What are the recursion theoretic properties of a set of axioms? Understanding a paper by William Craig Armando B. Matos

Decidability: Church-Turing Thesis

Further discussion of Turing machines

ON COMPUTAMBLE NUMBERS, WITH AN APPLICATION TO THE ENTSCHENIDUGSPROBLEM. Turing 1936

Turing s thesis: (1930) Any computation carried out by mechanical means can be performed by a Turing Machine

An Overview of Residuated Kleene Algebras and Lattices Peter Jipsen Chapman University, California. 2. Background: Semirings and Kleene algebras

Notes for Lecture 3... x 4

CS481F01 Solutions 6 PDAS

Limits of Computability

Let us first give some intuitive idea about a state of a system and state transitions before describing finite automata.

P is the class of problems for which there are algorithms that solve the problem in time O(n k ) for some constant k.

Q = Set of states, IE661: Scheduling Theory (Fall 2003) Primer to Complexity Theory Satyaki Ghosh Dastidar

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Learning Goals of CS245 Logic and Computation

Finite Automata. Mahesh Viswanathan

Turing Machines Part III

Automata, Logic and Games: Theory and Application

Team Semantics and Recursive Enumerability

Introduction to Turing Machines. Reading: Chapters 8 & 9

PROOFS IN PREDICATE LOGIC AND COMPLETENESS; WHAT DECIDABILITY MEANS HUTH AND RYAN 2.3, SUPPLEMENTARY NOTES 2

Computability Theory. CS215, Lecture 6,

Turing Machines. The Language Hierarchy. Context-Free Languages. Regular Languages. Courtesy Costas Busch - RPI 1

CSCI3390-Lecture 14: The class NP

Generalized Lowness and Highness and Probabilistic Complexity Classes

Computability and Complexity

198:538 Lecture Given on February 23rd, 1998

First-Order Logic. 1 Syntax. Domain of Discourse. FO Vocabulary. Terms

1 The decision problem for First order logic

arxiv: v1 [cs.cc] 3 Feb 2019

Lecture 2: Connecting the Three Models

Non-emptiness Testing for TMs

FINITE MODEL THEORY (MATH 285D, UCLA, WINTER 2017) LECTURE NOTES IN PROGRESS

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem.

Kleene Algebra with Equations

On Modal Logics of Partial Recursive Functions

Lecture 14: Recursive Languages

Provably Total Functions of Arithmetic with Basic Terms

Kleene Algebra with Tests

Computation Histories

Exam Computability and Complexity

CS256/Spring 2008 Lecture #11 Zohar Manna. Beyond Temporal Logics

DRAFT. Diagonalization. Chapter 4

TheTwo-VariableGuardedFragmentwith Transitive Guards Is 2EXPTIME-Hard

The Cook-Levin Theorem

15.1 Proof of the Cook-Levin Theorem: SAT is NP-complete

1 Computational Problems

From Constructibility and Absoluteness to Computability and Domain Independence

The Complexity of Computing the Behaviour of Lattice Automata on Infinite Trees

Advanced topic: Space complexity

Turing machines Finite automaton no storage Pushdown automaton storage is a stack What if we give the automaton a more flexible storage?

Propositional and Predicate Logic - XIII

CMPS 217 Logic in Computer Science. Lecture #17

König s Lemma and Kleene Tree

6.841/18.405J: Advanced Complexity Wednesday, February 12, Lecture Lecture 3

Research Statement Christopher Hardin

(a) Definition of TMs. First Problem of URMs

Partially Ordered Two-way Büchi Automata

Lecture 6: Oracle TMs, Diagonalization Limits, Space Complexity

Introduction to Artificial Intelligence Propositional Logic & SAT Solving. UIUC CS 440 / ECE 448 Professor: Eyal Amir Spring Semester 2010

Notes for Lecture Notes 2

In this paper we present complexity results for a natural hierarchy of decision

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

A MODEL-THEORETIC PROOF OF HILBERT S NULLSTELLENSATZ

Theorem Proving in the Propositional Algebra. Geoff Phillips **************

Introduction to Logic in Computer Science: Autumn 2006

Math 267a - Propositional Proof Complexity. Lecture #1: 14 January 2002

The Turing Machine. Computability. The Church-Turing Thesis (1936) Theory Hall of Fame. Theory Hall of Fame. Undecidability

Griffith University 3130CIT Theory of Computation (Based on slides by Harald Søndergaard of The University of Melbourne) Turing Machines 9-0

A generalization of modal definability

V Honors Theory of Computation

On Recognizable Languages of Infinite Pictures

Essential facts about NP-completeness:

CSE 1400 Applied Discrete Mathematics Definitions

Characterizing the Equational Theory

Introduction to Kleene Algebra Lecture 13 CS786 Spring 2004 March 15, 2004

Notes for Lecture 3... x 4

Part II Logic and Set Theory

Lloyd-Topor Completion and General Stable Models

Equational Theory of Kleene Algebra

Mathematical Foundations of Logic and Functional Programming

Friendly Logics, Fall 2015, Lecture Notes 1

Lecturecise 22 Weak monadic second-order theory of one successor (WS1S)

Opleiding Informatica

CSCE 551 Final Exam, Spring 2004 Answer Key

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2018, face-to-face day section Prof. Marvin K. Nakayama

Transcription:

Halting and Equivalence of Schemes over Recursive Theories Dexter Kozen Computer Science Department, Cornell University, Ithaca, New York 14853-7501, USA Abstract Let Σ be a fixed first-order signature. In this note we consider the following decision problems. (i) Given a recursive ground theory T over Σ, a program scheme p over Σ, and input values specified by ground terms t 1,...,t n,doesp halt on input t 1,...,t n in all models of T? (ii) Given a recursive ground theory T over Σ and two program schemes p and q over Σ, are p and q equivalent in all models of T? When T is empty, these two problems are the classical halting and equivalence problems for program schemes, respectively. We show that problem (i) is r.e.-complete and problem (ii) is Π 0 2-complete. Both these problems remain hard for their respective complexity classes even if T is empty and Σ is restricted to contain only a single constant, a single unary function symbol, and a single monadic predicate. It follows from (ii) that there can exist no relatively complete deductive system for scheme equivalence. Key words: model theory, Kleene algebra, dynamic logic 1991 MSC: 03B60, 03B70, 03G05, 03G15, 06E25, 03C05, 08A70, 08B20 Let Σ be a fixed first-order signature. A ground formula over Σ is a Boolean combination of atomic formulas P (t 1,...,t n ) of Σ, where the t i are ground terms (no occurrences of variables). A ground theory over Σ is a consistent set of ground formulas closed under entailment. A set E of ground formulas is a complete extension of a ground theory T if E contains T and each ground formula or its negation appears in E. Email address: kozen@cs.cornell.edu (Dexter Kozen). Preprint submitted to Elsevier Preprint 5 February 2003

Theorem 0.1 The following problem is r.e.-complete: Given a recursive ground theory T over Σ, a program scheme p over Σ, and input values specified by ground terms t = t 1,...,t n,doesp halt on input t in all models of T?The problem remains r.e.-hard even if T = and Σ is restricted to contain only a single constant, a single unary function symbol, and a single monadic predicate. Theorem 0.2 The following problem is Π 0 2-complete: Given a recursive ground theory T over Σ and two schemes p and q over Σ, arep and q equivalent in all models of T? The problem remains Π 0 2-hard even if T = and Σ is restricted to contain only a single constant, a single unary function symbol, and a single monadic predicate. When T =, these are the classical halting and equivalence problems for program schemes. Note that for the upper bounds, the recursive theory T is part of the input. Classical lower bound proofs (see [1]) establish the r.e. hardness of the two problems for the case T =. TheΠ 0 2-hardness of the second problem in the case T = can also be shown to follow without much difficulty from a result of [2]. Proof of Theorem 0.1. Let T be a recursive ground theory. It suffices to restrict our attention to Herbrand models of T. These models are in one-to-one correspondence with the complete extensions of T. First we show that the problem is r.e. Given p and t, we simulate the computation of p on input t on all Herbrand models of T simultaneously, using the decidability of T to resolve tests. Each branch of the simulation maintains a finite set E of ground atomic formulas consistent with T, initially empty. Whenever a test P (s 1,...,s k ) is encountered, we consult T and E to determine which branch to take. If the truth value of P (s 1,...,s k ) is determined by T and E,thatis,ifT E P (u 1,...,u k )ort E P (u 1,...,u k ), where the ground term u i is the current value of s i,1 i k, then we just take the appropriate branch. Otherwise, if both P (u 1,...,u k )and P (u 1,...,u k ) are consistent with T E, then the simulation branches, extending E with P (u 1,...,u k ) on one branch and P (u 1,...,u k ) on the other. In each simulation step, all current branches are simulated for one step in a round-robin fashion. We thus simulate the computation of p on all possible complete extensions of T simultaneously. If p halts on all such extensions, then by König s Lemma there is a uniform bound on the halting time of all branches of the computation. The simulation halts successfully when that bound is discovered. We now show that the problem is r.e.-hard in the restricted case Σ = {a, f, P }, where a is a constant, f is a unary function symbol, and P is a unary relation symbol. We will encode the halting problem for deterministic Turing machines. Given a deterministic Turing machine M and a string x over M s input alpha- 2

bet, we will construct a scheme p with no input or output and a finite atomic theory T such that p halts on all complete extensions of T iff M halts on input x. The encoding technique used here is fairly standard, but we include the argument for completeness and because we need the resulting scheme p in a certain special form for the proof of Theorem 0.2. The Herbrand domain over a and f is isomorphic to the natural numbers with 0 and successor. An Herbrand model H over this domain is represented by an infinite binary string whose n th digit is 1 iff P (f n (a)) in H. The correspondence is one-to-one. We will use these strings to encode computation histories of M. Each string x over M s input alphabet determines a unique finite or infinite computation history #α0#α x 1#α x 2# x,whereαi x is a string over a finite alphabet encoding the instantaneous configuration of M on input x at time i (tape contents, head position, current state). The configurations αi x are separated by a symbol #. The computation history in turn can be encoded in binary. Finally, an infinite binary string can be encoded by the truth values of P (f n (a)) for successive n. The ground theory T describes the starting configuration #α0 x #ofm on input x. ThusT consists of finitely many ground atomic formulas. Any complete extension of T describes either the unique valid computation history of M on input x or a garbage string. The scheme p can read the n th bit of this string in the corresponding Herbrand model by testing the value of P (f n (a)). It starts by scanning the initial part of the string to check that it is of the form #α0#forsomey. y (This step is not strictly necessary for this proof, since we are restricting our attention to models of T, in which this step will always succeed; but it will be useful later in the proof of Theorem 0.2.) Next, p scans the string from left to right to determine whether each successive αi+1 x follows from αi x in one step according to the transition rules of M. Itdoesthisby comparing corresponding bits in αi x and αi+1 x using two variables to simulate pointers into the string. If the current value of variable x is f n (a), then testing P (x) readsthen th bit of the string. The pointer is advanced by the assignment x := f(x). If p discovers an error, so that the string does not represent a computation history of M on some input, it halts immediately. It also halts if it ever encounters a halting state of M anywhere in the string. Thus the only complete extension of T that would cause p not to halt is the one describing the valid computation history of M on x in the case that M does not halt on x. Thus p halts on all complete extensions of T iff M halts on x. We can further restrict to T = by observing that the T in this construction is finite, so it can be hard-wired into the scheme p itself. Thus the initial format check that p performs can be modified to check whether T holds and 3

halt immediately if not. However, for purposes of the proof of Theorem 0.2 below, it will be important that p not depend on the input x but only on the machine M. Proof of Theorem 0.2. Two schemes are equivalent over all models of T iff they are equivalent over all Herbrand models of T. As above, each Herbrand model of T is uniquely represented by a complete extension of T. First we show that equivalence of schemes over models of T is Π 0 2.Equivalently, inequivalence of schemes over models of T is Σ 0 2. It suffices to show that inequivalence of schemes over models of T can be determined by an IND program over N with an alternation structure [3]. The two schemes p and q are not equivalent over models of T iff there exists an Herbrand model H of T and input values t = t 1,...,t n such that when interpreted over H, either (i) both p and q halt on input t and produce different output values; (ii) p halts on t and q does not; or (iii) q halts on t and p does not. We start by selecting existentially the input t and the alternative (i), (ii) or (iii) to check. If alternative (i) was selected, we simulate p and q on input t, maintaining a finite set E of ground atomic formulas and using T and E as in the proof of Theorem 0.1 to resolve tests. Whenever a test is encountered that is not determined by T and E, we guess the truth value and extend E accordingly. Thus we are nondeterministically guessing the model H as we go along. This is done by existential branching in the IND program. We continue the simulation until both p and q halt, then compare output values, accepting if they differ. If alternative (ii) was selected, we simulate p on t until it halts, maintaining the guessed truth values of undetermined tests in the set E as above. When p has halted, we have a consistent extension T E of T,whereE consists of the finitely many tests that were guessed during the computation of p. So far we have only used existential branching. We must now verify that there exists a complete extension of T E in which q does not halt on input t. By Theorem 0.1, this problem is Π 0 1-complete, so we can solve it with a purely universally-branching IND computation. The argument for alternative (iii) is symmetric. For the lower bound, we reduce the totality problem for Turing machines, a well-known Π 0 2-complete problem, to the equivalence problem. The totality problem is to determine whether a given Turing machine M halts on all inputs. 4

As above, it will suffice to consider T = and Σ = {a, f, P }. Given a deterministic Turing machine M, we construct two schemes p and q with no input or output that are equivalent iff M halts on all inputs. The scheme p is the one constructed in the proof of Theorem 0.1. As in that proof, each input string x over M s input alphabet determines a unique computation history, and the scheme p checks that the Herbrand model in which it is running encodes a valid computation history of M on some input. Now unlike the proof of Theorem 0.1, there is an extra source of non-halting. Recall that there is an initial format check in which p checks that the string has a prefix of the form #α0 x #forsomex. If there is no second occurrence of # in the string, then p will loop infinitely looking for it. If it does detect a second occurrence of #, then as before, the only source of non-halting is if M does not halt on x. We therefore build q to simply check for a prefix of the form #α0 x #exactlyasp does and halt immediately when it encounters the second occurrence of #. Thus p does not halt in the Herbrand model H iff the string represented by H either (i) does not have a prefix of the form #α0 x #, or (ii) does have a prefix of the form #α0 x # and represents a non-halting computation history of M on x; and q does not halt in H in case (i) only. Therefore p and q are equivalent iff M halts on all inputs. In [4], axioms were proposed for reasoning equationally about input/output relations of first-order program schemes over Σ. These axioms have been shown to be adequate for some fairly intricate equivalence arguments arising in program optimization [4,5]. However, unlike the propositional case, it follows from Theorem 0.2 that there can exist no finite relatively complete axiomatization for first-order scheme equivalence. If such an axiomatization did exist, then the scheme equivalence problem over a given first-order theory T would be r.e. in T. But it is decidable whether a given first-order sentence ϕ is a consequence of a given finite set E of ground formulas over the signature Σ = {a, f, P }, since E ϕ iff E ϕ is a valid sentence of the first-order theory of a oneto-one unary function with monadic predicate, a well-known decidable theory [6] (note that every Σ-structure is elementarily equivalent to one in which the interpretation of f is one-to-one). By Theorem 0.2, the scheme equivalence problem relative to E is Π 0 2-hard, therefore not r.e. in the decidable first-order theory generated by E. 5

Acknowledgements This work was supported in part by NSF grant CCR-0105586 and by ONR Grant N00014-01-1-0968. The views and conclusions contained herein are those of the author and should not be interpreted as necessarily representing the official policies or endorsements, either expressed or implied, of these organizations or the US Government. References [1] Z. Manna, Mathematical Theory of Computation, McGraw-Hill, 1974. [2] D. Harel, A. R. Meyer, V. R. Pratt, Computability and completeness in logics of programs, in: Proc. 9th Symp. Theory of Comput., ACM, 1977, pp. 261 268. [3] D. Harel, D. Kozen, A programming language for the inductive sets, and applications, Information and Control 63 (1 2) (1984) 118 139. [4] A. Angus, D. Kozen, Kleene algebra with tests and program schematology, Tech. Rep. 2001-1844, Computer Science Department, Cornell University (July 2001). [5] A. Barth, D. Kozen, Equational verification of cache blocking in LU decomposition using Kleene algebra with tests, Tech. Rep. 2002-1865, Computer Science Department, Cornell University (June 2002). [6] J. Ferrante, C. Rackoff, The computational complexity of logical theories, Vol. 718 of Lecture Notes in Mathematics, Springer-Verlag, 1979. 6