Scuola Estiva di Logica Gargnano, August

Similar documents
Soft Linear Logic and Polynomial Complexity Classes

An Implicit Characterization of PSPACE

On Elementary Linear Logic and polynomial time (Extended Abstract)

Soft Linear Logic and the Polynomial Hierarchy (Extended Abstract)

From light logics to type assignments: a case study

Characterizing Polynomial and Exponential Complexity Classes in Elementary Lambda-Calculus

Linear Logic Pages. Yves Lafont (last correction in 2017)

Syntax. Notation Throughout, and when not otherwise said, we assume a vocabulary V = C F P.

Lazy Strong Normalization

On the Complexity of the Reflected Logic of Proofs

Handbook of Logic and Proof Techniques for Computer Science

Propositional Logic Language

On the Computational Complexity of Cut-Elimination in Linear Logic

Constructive approach to relevant and affine term calculi

Intersection Synchronous Logic

Dottorato di Ricerca in Informatica Ciclo XX. Linearity: an Analytic Tool in the Study of Complexity and Semantics of Programming Languages

Call-by-value non-determinism in a linear logic type discipline

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

Logic and Probability Lecture 3: Beyond Boolean Logic

Informal Statement Calculus

Beyond First-Order Logic

Most General computer?

3 Propositional Logic

Preuves de logique linéaire sur machine, ENS-Lyon, Dec. 18, 2018

if t 1,...,t k Terms and P k is a k-ary predicate, then P k (t 1,...,t k ) Formulas (atomic formulas)

Non-Idempotent Typing Operators, beyond the λ-calculus

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

Polynomial Space. The classes PS and NPS Relationship to Other Classes Equivalence PS = NPS A PS-Complete Problem

Applied Logic. Lecture 1 - Propositional logic. Marcin Szczuka. Institute of Informatics, The University of Warsaw

On the satisfiability problem for a 4-level quantified syllogistic and some applications to modal logic

Attack of the Exponentials

Decidability: Church-Turing Thesis

Notation for Logical Operators:

Lecture 4 : Quest for Structure in Counting Problems

Implicit Computational Complexity

185.A09 Advanced Mathematical Logic

Elementary Affine Logic and the Call by Value Lambda Calculus

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65

Encoding Graph Transformation in Linear Logic

Categories, Proofs and Programs

The Many Faces of Modal Logic Day 4: Structural Proof Theory

summer school Logic and Computation Goettingen, July 24-30, 2016

Programming Language Concepts: Lecture 18

A Soft Type Assignment System for λ-calculus

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

A probabilistic lambda calculus - Some preliminary investigations

Abstract model theory for extensions of modal logic

Logic: The Big Picture

Characterizing Polynomial and Exponential Complexity Classes in Elementary Lambda-Calculus

Notes for Lecture 3... x 4

A Tableau Calculus for Minimal Modal Model Generation

Example. Lemma. Proof Sketch. 1 let A be a formula that expresses that node t is reachable from s

TR : Binding Modalities

On Modal Logics of Partial Recursive Functions

A refined calculus for Intuitionistic Propositional Logic

Database Theory VU , SS Complexity of Query Evaluation. Reinhard Pichler

Propositional logic (revision) & semantic entailment. p. 1/34

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

WHAT IS AN SMT SOLVER? Jaeheon Yi - April 17, 2008

Proving Completeness for Nested Sequent Calculi 1

Implicit Computational Complexity

Classical First-Order Logic

Logical Structures in Natural Language: Propositional Logic II (Truth Tables and Reasoning

PROPOSITIONAL MIXED LOGIC: ITS SYNTAX AND SEMANTICS

hal , version 1-21 Oct 2009

Introduction to Model Theory

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

Lambda-Calculus (I) 2nd Asian-Pacific Summer School on Formal Methods Tsinghua University, August 23, 2010

Propositional logic. First order logic. Alexander Clark. Autumn 2014

Team Semantics and Recursive Enumerability

On Sequent Calculi for Intuitionistic Propositional Logic

Decomposition of Computation via Linear Logic

Proofs in classical logic as programs: a generalization of lambda calculus. A. Salibra. Università Ca Foscari Venezia

Algorithmic Model Theory SS 2016

Theory of computation: initial remarks (Chapter 11)

Propositional and Predicate Logic. jean/gbooks/logic.html

1. Propositional Calculus

Classical First-Order Logic

Outline. Complexity Theory. Example. Sketch of a log-space TM for palindromes. Log-space computations. Example VU , SS 2018

Theory of Computing Tamás Herendi

Semantics with Intersection Types

Preliminaries. Introduction to EF-games. Inexpressivity results for first-order logic. Normal forms for first-order logic

07 Equational Logic and Algebraic Reasoning

THE LANGUAGE OF FIRST-ORDER LOGIC (FOL) Sec2 Sec1(1-16)

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

Propositional Dynamic Logic

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

Turing Machines. Lecture 8

Notes for Lecture 3... x 4

Stratifications and complexity in linear logic. Daniel Murfet

Origin in Mathematical Logic

Mathematical Logic. Reasoning in First Order Logic. Chiara Ghidini. FBK-IRST, Trento, Italy

LOGIC PROPOSITIONAL REASONING

Introduction to λ-calculus

MTAT Complexity Theory October 13th-14th, Lecture 6

Lecture Notes on Linear Logic

System description: CondLean

NICTA Advanced Course. Theorem Proving Principles, Techniques, Applications

Lecture 11: Measuring the Complexity of Proofs

Motivation. CS389L: Automated Logical Reasoning. Lecture 10: Overview of First-Order Theories. Signature and Axioms of First-Order Theory

Transcription:

Linear Logic, Linear Logic, Università degli Studi di Torino Scuola Estiva di Logica 2015 Gargnano, August 28 2015

Complexity theory Linear Logic, study of complexity classes and their relations define first a computational model and its associated cost model (for time, space,...). The standard choice: Turing machines measure of time: number of elementary steps measure of space: dimension of the tape the TM M works in bound f iff for any input u, M<u>terminates using less than f ( u ) resources example: PTIME (FPTIME) is the set of decision problems (functions) that can be solved (computed) in polynomial bound

Problems Linear Logic, the design of a program and the proof of its complexity are made in two different steps it is difficult to supply formal proofs of complexity, since the difficulty of dealing formally with TMs

Implicit Computational Complexity (ICC) Linear Logic, describes complexity classes without explicit reference to a machine model and its cost bound uses techniques and results from Mathematical : proof theory recursion theory model theory two aims: to implicitly characterize complexity classes to supply programming languages with a certified complexity bound

A case study Linear Logic, the idea: start from a given programming language L supply a type discipline for L in such a way that: if a term (program) is well typed then its complexity belongs to a given complexity class C all and only the functions belonging to C are computed by well typed terms the realization: language: λ-calculus (with some extension) types: inspired from Soft Linear Logic (one of the light versions of LL) The results characterizations of PTIME, FPTIME, PSPACE and NP

λ-calculus: the paradigm for functional programming languages syntax: M ::= x λx.m MM where x ranges over a countable set of variables. λxy.m stands for λx.(λy.m)) λx 1...x n.m stands forλx 1.(λx 2.(...(λx n.m)...)) M 1 M 2...M n stands for M 1 (M 2 (...M n )). Linear Logic, operational semantics: the β-reduction is the contextual closure of the rule: (λx.m)n M[N/x] β where M[N/x] denotes the (capture free) replacement of all occurrences of x in M by N.

Computing with λ-calculus Linear Logic, coding of natural numbers: n=λxy. x(...(x y)) } {{ } n coding of binary words: < i 1...i n >=λx 0 x 1 y.x i1 (x i2 (...(x in y)) where i j ranges over{0, 1}. Theorem In the λ-calculus, all and only the computable functions can be coded.

Linear Logic: a resource sensitive logic Linear Logic, Two kinds of formulae: A (linear resource, can be used once)!a (can be used as many times we want, also 0) The intuitionistic implication A B is decomposed in!a B ( is the linear implication) Equivalence!!A =!A

The rules of Intuitionistic Linear Logic (ILL) Linear Logic, A A (Id) Γ A, A B Γ, B (cut) Γ, A B Γ A B ( R) Γ A B, C A B,Γ, C ( L) Γ A α FV(Γ) Γ α.a ( R) Γ, B[C/α] A Γ, α.b A ( L) n times { }} { Γ, A,..., A C Γ,!A C (mpx) Γ A!Γ!A (sp) Γ,!!B A Γ,!B A (digging) whereγis a multiset of formulae, andγ, denotes multiset union.

Soft Linear Logic (SLL) A A (Id) Γ A, A B Γ, B (cut) Linear Logic, Γ, A B Γ A B ( R) Γ A B, C A B,Γ, C ( L) Γ A α FV(Γ) Γ α.a ( R) Γ, B[C/α] A Γ, α.b A ( L) n times { }} { Γ, A,..., A C Γ,!A C (mpx) Γ A!Γ!A (sp) all rules of ILL but Γ,!!B A Γ,!B A (digging)

Properties of SLL Linear Logic, The fact that the equation:!a=!!a allows to use the modality! for counting the number of duplications of proofs during the cut-elimination procedure. In SLL all the polynomial computations can be coded.

Linear Logic, STA is a natural deduction style type assignment system inspired by SLL, but: Terms are built in a linear way, and (mpx) rule is used for controlling variable duplication Technically this is realized by using as types a subset of the SLL formulae such that: is not allowed on modal formulae! is not allowed on the right of weakening and axiom introduce not modal formulae. are the following subset of SLL formulae: A ::= α σ A α.a (linear types) σ ::= A!σ

Rules of STA Linear Logic, x : A x : A (Ax) Γ M :σ Γ, x : A M :σ (w) Γ, x :σ M : A Γ λx.m :σ A ( I) Γ M :σ A N :σ Γ# Γ, MN : A ( E) Γ, x 1 :σ,..., x n :σ M :τ Γ, x :!σ M[x/x 1,..., x/x n ] :τ (mpx) Γ M :σ!γ M :!σ (sp) Γ A α FV(Γ) Γ M : α.a ( I) Γ M : α.a Γ M : A[B/α] ( E) where Γ# denotes that the two contexts have disjoint variables.

Properties of STA Linear Logic, subject reduction Γ M :σand M β M implyγ M :σ. strong normalization Γ M :σimplies M is strongly normalizing.

Example Let A= D D, C=A A A B. y : C y : A A A B (Ax) x 1 : A x 1 : A (Ax) ( E) y : C, x 1 : A yx 1 : A A B x 2 : A x 2 : A (Ax) ( E) y : C, x 1 : A, x 2 : A yx 1 x 2 : A B x 3 : A x 3 : A Π 3 y : C, x 1 : A, x 2 : A, x 3 : A yx 1 x 2 x 3 : B (mpx) Π y : C, x :!A yxxx : B (Ax) ( E) Linear Logic, the rank ofπ 3 counts the number of copies of an argument replacing x. Π ( I) y : C λx.yxxx :!A B y : C (λx.yxxx)i : B z : D z: D (Ax) ( I) Φ Id : A (sp) I :!A ( E) Π 3 [(Ax)/Φ] y : C yiii : B whereπ 3 [(Ax)/Φ] denotesπ 3, where all axiom with subject x has been replaced byφ. the rule (sp) is a witness that I will be copied (a number of times corresponding to the rank ofπ 3 ).

measures Linear Logic, Π 3 y : C, x 1 : A, x 2 : A, x 3 : A yx 1 x 2 x 3 : B y : C, x :!A, x 3 : A yxxx 3 : B Π y : C, x :!!A yxxx : B (mpx) (mpx) Π y : C, x :!!A yxxx : B ( I) y : C λx.yxxx :!!A B Ψ y : C (λx.yxxx)i : B Φ I : A I :!A (sp) I :!!A (sp) ( E) Π 3 [(Ax)/Φ] y : C yiii : B the rank ofψis the maximum between the ranks of the (mpx) rules in it (2) the depth ofψis the maximum nesting of the (sp) rules in it (2) In the example, I will be copied a number of times less than or equal to r d (2 2 = 4) NOTE: counting is possible since the equation!a=!!a is no more valid.

Quantitative properties of STA Linear Logic, Theorem (complexity bound) Π Γ M :σimplies M reduces to normal form in nβ-reduction steps, where n M d(π)+1 and this implies that it reduces in normal form on a TM in time: M 3 (d(π)+1) (where M is the number of symbol of M and d(π) is the maximal nesting of (sp) rule applications in Π) Remark M can be assigned an infinite number of types. Every typing for M gives an upper bound to its reduction time.

Coding data types Linear Logic, truth values: true=λxy.x : B f alse=λxy.y : B iterators: natural numbers (binary words): n=λxy. x(...x(x y))) : N } {{ } i n N i = α. }{{}!...! (α α) α α i [b 0, b 1,...,b n ]=λcz.cb 0 ( (cb n z)) : S i where B= α.α α α, i Nat Remark S i = α. }{{}!...! (B α α) α α i Every data type can be typed by a derivation of depth 0.

Coding functions Linear Logic, Letπ: N p B be a predicate of arity p. A closed term M=λx 1...x p.p codesπiff: Mn 1...n p =π(n 1...n p ) M : S i1 S i2... S ip B, (i j Nat) Letφ:N p N be a function of arity p. A closed term M=λx 1...x p.p codesφiff: Mn 1...n p =φ(n 1...n p ) M : S i1 S i2... S ip S, (i j Nat)

Polynomial soundness Linear Logic, Theorem (polynomial soundness) Let P be a term coding either a predicateπ: N p B or a function φ : N p N. Then Pn 1...n p reduces to normal form in a number of steps polynomial in n 1 + n 2 +...+n p. Proof. All n i are typed by derivations of depth 0. Let P be typed by a derivation of depth d, so the derivation for Pn 1...n p has depth d, and reduces to normal form in a number of steps which is Pn 1...n p d. Since the size of the program is a constant with respect to the computation, this time is polynomial in n 1 + n 2 +...+n p.

PTIME and FPTIME completeness Linear Logic, Theorem (PTIMEcharacterization) All decision problems that can be computed in by a TM can be coded in STA. Theorem (FPTIMEcharacterization) All functions that can be computed in by a TM can be coded in STA.

From PTIME to PSPACE PSPACE is the set of problems that can be solved by a TM in polynomial space. Problems: 1 How to measure the space of a reduction? (In the real programming languages substitution is not explicitly performed) 2 How to transfer our tools from time to space? Solution: 1 Use an (abstract) reduction machine for λ-calculus (performing linear substitution) 2 Use the following equivalence: Linear Logic, PSPACE = APTIME where APTIME is the set of problems solved by an Alternating Turing Machine (ATM) (i.e., computation that repeatedly fork into subcomputations and whose result is obtained by a backward computation from all the subcomputations results.)

Extensions of terms and types Linear Logic, Terms: Reduction rules: M ::= x 0 1 λx.m MM if Mthen Melse M (λx.m)n β M[N/x] if 0then Melse N δ M if 1then Melse N δ N βδ denotes the reflexive and transitive closure of βδ. : A ::=B α σ A α.a σ ::= A!σ (Linear )

The type system STAB Linear Logic, x : A x : A (Ax) 0 : B (B 0I) 1 : B (B 1I) Γ M :σ Γ, x : A M :σ (w) Γ, x :σ M : A Γ λx.m :σ A ( I) Γ M :σ A N :σ Γ# Γ, MN : A ( E) Γ, x 1 :σ,..., x n :σ M :µ Γ, x :!σ M[x/x 1,, x/x n ] :µ (mpx) Γ M :σ!γ M :!σ (sp) Γ M : A α FTV(Γ) Γ M : α.a ( I) Γ M : α.b Γ M : B[A/α] ( E) Γ M : B Γ N 0 :σ Γ N 1 :σ Γ if Mthen N 0 else N 1 :σ (BE)

Properties of STAB Linear Logic, subject reduction Γ M :σand M β M implyγ M :σ. strong normalization Γ M :σimplies M is strongly normalizing.

A leftmost outermost reduction machine Linear Logic, The machine is a set of rules of the shape: C,A = N b where: A is the store, and it allows to perform substitutions one occurrence at a time: A ::= A@{x := M} C is a context remembering the computation path, and it allows to avoid backtracking: C[ ] ::= (ifc[ ]then Lelse R )V 1 V n N is a program (a closed term of type B)

The rules of the machine Linear Logic, C,A =b b (Ax) C,A@{x := N} = M[x /x]v 1 V m b C,A = (λx.m)nv 1 V m b (β) {x := N} A C,A = NV 1 V m b C,A = xv 1 V m b (h) C[(if [ ]then N 0 else N 1 )V 1 V m ],A = M 0 C,A = N 0 V 1 V m b C,A = (if Mthen N 0 else N 1 )V 1 V m b (if0) C[(if [ ]then N 0 else N 1 )V 1 V m ],A = M 1 C,A = N 1 V 1 V m b C,A = (if Mthen N 0 else N 1 )V 1 V m b (if1) (*) x is a fresh variable.

Example Linear Logic, Let M=λx.if xthen Ixelse O(Ix)1 (where I=λx.x and O=λxy.y). Clearly M0 βδ 0 and M1 βδ 1 and both are programs. Let us evaluate M0. if [ ]then Iyelse O(Iy)1,{y := 0} = 0 0 (Ax) if [ ]then Iyelse O(Iy)1,{y := 0} = y 0 (h) [ ],{y := 0} = if ythen Iyelse O(Iy)1 0 [ ], = M0 0 [ ],{y := 0, z := y} = 0 0 (Ax) [ ],{y := 0, z := y} = y 0 (h) [ ],{y := 0, z := y} = z 0 (h) (β) [ ],{y := 0} = Iy 0 (if 0) (β)

PSPACE results Let the abstract machine compute:c,a = M b. Then the space used by the machine during this computation is: the maximal size of the store in the computation + the maximal size of the context in the computation Theorem (Polynomial Space Soundness) Let M be a program (a closed term of type B), and letπbe a derivation of M : B, and let d(π) be the depth ofπ(the maximal nesting of applications of (sp) rule in Π). Then M reduces to normal form (through the given abstract machine) in space Linear Logic, 3 M 3 d(π)+4 Theorem (Polynomial Space Completeness) Every decision problemd PSPACE can be coded in STAB.

From PSPACE to NP Linear Logic, NP is the set of problem that can be decided in by a non-deterministic TM. The language: M ::= x MM λx.m M+M The reduction rules: (λx.m)n β M[N/x] M+N γ M M+N γ N Remark The calculus is not confluent!

The type system STA+ x : A x : A (Ax) Γ M :σ Γ, x : A M :σ (w) Linear Logic, Γ, x :σ M : A Γ λx.m :σ A ( I) Γ M :σ A N : A Γ# Γ, MN : A ( E) Γ, x 1 :σ,..., x n :σ M : A Γ, x :!σ M[x/x 1,..., x/x n ] : A (mpx) Γ σ!γ!σ (sp) Γ A α FV(Γ) Γ M : α.a ( I) Γ M : α.a Γ M : A[B/α] ( E) Γ M : A Γ N : A (sum) Γ M+N : A

Properties of STA+ Linear Logic, Theorem (Subject Reduction) LetΓ M :σand M βγ N. ThenΓ N :σ. remark Terms with an exponential time behaviour can be typed: E.g.: M n((λx.zx+zx)i) where n is a Church numeral and I is the identity. Let M be the normal form of M. M N γ M in a number of steps exponential in n (β-reductions β according to an innermost strategy) M βγ M in a number of steps linear in n (a suitable outermost strategy)

A non-deterministic abstract machine Linear Logic, C[λx.[ ]],A = M N C,A =λx.m λx.n (λ) C,A@{x := P} = M[x /x]v 1 V m N x fresh C,A = (λx.m)pv 1 V m N (β) ( ) C[x[ ]V 2 V m ],A = V 1 N 1 C[xN 1 N m 1 [ ]],A = V m N m C,A = xv 1 V m xn 1 N m (h 1 ) {x := P} A C,A = PV 1 V m N C,A = xv 1 V m N (h) C,A = M 0 V 1 V m N C,A = (M 0 + M 1 )V 1 V m N (L) C,A = M 1 V 1 V m N C,A = (M 0 + M 1 )V 1 V m N (R) ( ) x dom(a) C ::= [ ] λx.c[ ] xm 1...M i [ ]M i+1...m n (1 i n)

NPTIME characterization Linear Logic, Theorem (NPTIMESoundness) LetΠ be a derivation provingγ M :σ, for someγ,σ. Then M reduces to each one of its normal forms (by the non-deterministic abstract machine) in time bounded by O( M O(d(Π)) ). Theorem (NPTIMECompleteness) Every decision problem D decidable by a non deterministic TM in can be coded by a term typable in STA+.

Bibliography Linear Logic, Girard, J.-Y., Linear Logic, Theoretical Computer Science 50, p. 1-102, Elsevier (1987) Girard, J.-Y.,Light Linear Logic, Information and Computation 143(2), p. 175-204, 1998 Lafont Y., Soft Linear Logic and Polynomial Time, Theoretical Computer Science 318, p. 163-180, Elsevier (2004) Gaboardi M. and Ronchi Della S., A Soft Type Assignment System for λ-calculus, CSL 07, Lecture Notes in Computer Science, 4646, p. 253 267, 2007, Springer. Gaboardi M. and Marion J.Y. and Ronchi Della S., An Implicit Characterization of PSPACE, ACM Transactions on Computational Logic, 13(2):18:1 18:36, 2012 Gaboardi M. and Ronchi Della S., From Light to Type Assignements: a case study, Logic Journal of the IGPL 17, p. 499 530, 2009.