• Keine Ergebnisse gefunden

Komponenten- und Service-orientierte Softwarekonstruktion

N/A
N/A
Protected

Academic year: 2021

Aktie "Komponenten- und Service-orientierte Softwarekonstruktion"

Copied!
22
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Komponenten- und Service-orientierte Softwarekonstruktion

Lecture 4: Inhabitation in λ

Jakob Rehof

LS XIV – Software Engineering

TU Dortmund Sommersemester 2015

(2)

Curry-Howard isomorphism

Γ, x :τ ` x :τ (var)

Γ, x :τ ` M :σ Γ ` λx.M :τ → σ (→I)

Γ ` M :τ → σ Γ ` N :τ

Γ ` M N :σ (→E)

(3)

Curry-Howard isomorphism

Γ, τ `τ(hyp)

Γ, τ `σ Γ`τ→σ(DT) Γ`τ→σ Γ`τ

Γ`σ (MP)

Exercise 1

LetΓ ={τ1, . . . , τn}. Prove that, ifΓ`σthenτ1→ · · · →τn→σis boolean tautology, when→is interpreted as implication.

So, inhabitation isprovabilityin intuitionistic propositional logic.

(4)

Alternating Turing machines (ATM)

Analternating Turing machine is a tupleM= (Σ, Q, q0, qa, qr,∆). The set of states Q=Q ] Qis partitioned into a setQ of existential states and a setQof universal states. There is an initial stateq0∈Q, an accepting stateqa∈Q, and a rejecting stateqr∈Q. We takeΣ ={0,1, }, where is the blank symbol (used to initialize the tape but not written by the machine).

The transition relation∆satisfies

∆⊆Σ×Q×Σ×Q× {l,r},

whereh∈ {l,r}are the moves of the machine head (left and right). Forb∈Σand q∈Q, we write∆(b, q) ={(c, p, h)|(b, q, c, p, h)∈∆}. We assume

∆(b, qa) = ∆(b, qr) =∅, for allb∈Σ, and∆(b, q)6=∅forq∈Q\ {qa, qr}.

(5)

Alternating Turing machines (ATM)

AconfigurationC ofMis a wordwqw0withq∈Qandw, w0∈Σ. Thesuccessor relationC ⇒ C0on configurations is defined as usual, according to∆. We classify a configurationwqw0asexistential,universal,acceptingetc., according toq.

The notion ofeventually accepting configuration is defined by induction (i.e., the set of all eventually accepting configurations is the smallest set satisfying the following closure conditions):

An accepting configuration is eventually accepting.

IfCis existential and some successor ofC is eventually accepting then so isC.

IfCis universal and all successors ofC are eventually accepting then so isC.

(6)

Alternating Turing machines (ATM)

We use the notation for instruction sequences starting from existential states choosex∈A

and instruction sequences starting from universal states forall(i= 1. . . k)Si

A command of the formchoosex∈Abranches from an existential state to successor states in whichxgets assigned distinct elements ofA. A command of the form forall(i= 1. . . k)Si branches from a universal state to successor states from which each instruction sequenceSiis executed.

(7)

Alternating complexity

Some alternating complexity classes:

aptime:=S

k>0atime(nk) apspace:=S

k>0aspace(nk) aexptime:=S

k>0atime(kn)

Theorem 1 (Chandra, Kozen, Stockmeyer 1981)

aptime=pspace apspace=exptime aexptime=expspace

(8)

Inhabitation in λ

is Pspace -complete

We will give a detailed proof of Statman’s Theorem: inhabitation in λ

is Pspace -complete. This result was first proven in [Statman, 1979] (using, among other things, results of Ladner [Ladner, 1977]).

Our proof follows [Urzyczyn, 1997] (see also

[Sørensen and Urzyczyn, 2006]) where a syntactic approach was used, and

where alternation is used to simplify the proof.

(9)

Inhabitation in λ

: upper bound

Notice that every typeτ ofλcan be written on the formτ ≡τ1→ · · ·τn→a,n≥0, whereais an atom (either a type variable or a type constant).

Notice that every application context can be written on the formxP1· · ·Pnfor some maximaln≥0.

An explicitly typedλ-termM is inη-long normal formif it is aβ-normal form and every maximal application inM has the formxτ1→···→τn→aP1τ1· · ·Pnτn. In other words, in such terms applications are fully applied according to the type of the operator.

Notice that every typedβ-normal form of typeτ can be converted intoη-long normal form: any subterm occurrence of a maximal applicationQσ→ρcan be converted into λx:σ.Qxwherex6∈FV(Q).

SetΓ(x:τ) = Γ, if there existsy∈Dm(Γ)withΓ(y) =τ, and otherwise Γ(x:τ) = Γ∪ {(x:τ)}.

(10)

Inhabitation in λ

: upper bound

Algorithm INH(λ)

Input: Γ, τ

loop: 1 if(τ ≡a) 2 then

3 choose(x:σ1→ · · · →σn→a)∈Γ;

4 if(n= 0)then accept;

5 else

6 forall(i= 1. . . n)

7 τ :=σi;

8 gotoloop;

9 else if(τ ≡σ→ρ) 10 then

11 Γ := Γ(y:σ)whereyis fresh;

12 τ :=ρ;

(11)

Inhabitation in λ

: upper bound

Proposition 1

Inhabitation inλ is inpspace.

Proof.

By algorithm INH(λ). Clearly, the algorithm performs exhaustive search forη-long normal form inhabitants. The algorithm decides inhabitation inλin polynomial space.

For consider configurations(Γ, τ)arising during an entire run of the algorithm on input (Γ0, τ0). Notice thatΓandτ always only contain types that are subtrees of types present in the previous values ofΓandτ (line7and line11). Since a tree of sizemhas mdistinct subtrees, the set of distinct configurations(Γ, τ)can be bounded byn2, wherenis the size of the input. Hence, the algorithm shows that the problem is in aptime, which ispspaceby Theorem 1.

(12)

Inhabitation in λ

: lower bound

Reduction from provability of quantified boolean fomulaeφ, χ, ψ:

φ::=p| ¬φ|φ∧ψ|φ∨ψ| ∀p.φ| ∃p.φ

We can assume w.l.o.g. that negation is only applied to propositional variablespinφ, that all bound variables are distinct and that no variable occurs both free and bound.

(13)

Inhabitation in λ

: lower bound

Given formulaφ, construct type environmentΓφby induction onφ:

For each propositional variablepinφ, letαpandα¬pbe fresh type variables. For each subformulaψ, letαψ be fresh type variables.

Ifφ≡p, thenΓφ=∅.

Ifφ≡ ¬p, thenΓφ=∅.

Ifφ≡χ∧ψ, thenΓφ= Γχ∪Γψ∪ {xφχ→αψ →αχ∧ψ}.

Ifφ≡χ∨ψ, thenΓφ= Γχ∪Γψ∪ {xlφχ→αχ∨ψ, xrφψ→αχ∨ψ}.

Ifφ≡ ∀p.ψ, thenΓφ= Γψ∪ {xφ: (αp→αψ)→(α¬p→αψ)→α∀p.ψ}.

Ifφ≡ ∃p.ψ, then

Γφ= Γψ∪ {x0φ: (αp→αψ)→α∃p.ψ, x1φ: (α¬p→αψ)→α∃p.ψ}.

Assume that indices corresponding to distinct subformula occurrences are distinct.

(14)

Inhabitation in λ

: lower bound

A valuationvis a map from propositional variables to truth values in{0,1}.

For a formulaφand a valuationv, letΓvφbe the extension ofΓφ: Γvφ= Γφ∪ [

p∈Dm(v)

{xp:hαipv}

wherehαipvpifv(p) = 1andhαipv¬pifv(p) = 0.

A valuation of a formulaφis a valuation defined on the free variables ofφ.

We writev⊕[p:=b]for the extension ofvmappingptob∈ {0,1}.

We writeΓ6`τ as abbreviation for¬∃M.Γ`M :τ.

(15)

Inhabitation in λ

: lower bound

We letJφKvdenote the truth value ofφunder valuationv, defined by induction onφ:

JpKv = v(p)

J¬pKv = 0,ifv(p) = 1,else1 Jψ∧χKv = min{JψKv,JχKv}

Jψ∨χKv = max{JψKv,JχKv}

J∀p.ψKv = min{JψKv⊕[p:= 1],JψKv⊕[p:= 0]}

J∃p.ψKv = max{JψKv⊕[p:= 1],JψKv⊕[p:= 0]}

Assume w.l.o.g. that formulaeφhave negation signs only applied to propositional variables.

(16)

Inhabitation in λ

: lower bound

Lemma 2

For every formulaφand every valuationvofφ, one has JφKv= 1 ⇔ ∃M.Γvφ`M :αφ

Proof

By induction onφ.

Caseφ≡p. IfJpKv= 1, i.e.,v(p) = 1, thenΓvφ={xvpp}, soΓvφ`xvpp. If Γvφ`M:αp, then, by construction ofΓvφ, it must be the case thatΓvφ={xvpp}, so thatv(p) = 1.

Caseφ≡ ¬p. Similar to previous case.

(17)

Inhabitation in λ

: lower bound

Proof(continued) Caseφ≡χ∧ψ

IfJφKv= 1, thenJχKv=JψKv= 1. By induction hypothesis,Γvχ`M :αχand Γvψ`N:αψ, for someM andN. It follows thatΓvχ∧ψ`xχ∧ψM N:αχ∧ψ. IfJφKv= 0, thenJχKv= 0orJψKv= 0. IfJχKv= 0, then by induction hypothesis, Γvχ6`αχ, hence by construction ofΓvφ, we must haveΓvφ6`αχ. It follows that Γvφ6`αχ∧ψ. The case whereJψKv= 0is analogous.

(18)

Inhabitation in λ

: lower bound

Proof(continued) Caseφ≡ ∀p.ψ

IfJφKv= 1, thenJψKv0=JψKv1= 1, wherev0=v⊕[p:= 0]andv1=v⊕[p:= 1]. By induction hypothesis, we haveΓvψ0`M :αψ andΓvψ1 `N:αψ, for someM andN, which (by definitions) can also be written asΓvφ∪ {xp¬p} `M:αψ and Γvφ∪ {xpp} `N:αψ. Hence,Γvφ`λxp¬p.M:α¬p→αψ and Γvφ`λxpp.N:αp→αψ. It follows that we have

Γvφ`xφ(λxpp.N)(λxp¬p.M) :αφ

(19)

Inhabitation in λ

: lower bound

Proof(continued) Caseφ≡ ∀p.ψ

IfJφKv= 0, then either we haveJψKv⊕[p:= 0] = 0orJψKv⊕[p:= 1] = 0. Suppose that the former is the case. Then, by induction hypothesis, we haveΓvψ0 6`αψ, where v0=v⊕[p:= 0]. Hence, by definitions, we haveΓψ∪ {xp¬p} 6`αψ. By construction ofΓvφ, it follows that we haveΓvφ6`αφ. The case where JψKv⊕[p:= 1] = 0is analogous.

(20)

Inhabitation in λ

: lower bound

Proof(continued)

Remaining cases are left as an exercise©

Proposition 2

Inhabitation inλ ispspace-hard.

Proof.

In order to decide provability of QBF formulaφ, it suffices to ask whetherΓφ`? :αφ, by Lemma 2. Since the construction ofΓφcan be carried out in logarithmic space, the proposition follows.

(21)

Inhabitation in λ

Theorem 3 (Statman 1979)

Inhabitation inλ ispspace-complete.

Proof.

By Proposition 1 and Proposition 2.

(22)

Ladner, R. (1977).

The Computational Complexity of Provability in Systems of Modal Propositional Logic.

SIAM J. Comput., 6(3):467 – 480.

Sørensen, M. and Urzyczyn, P. (2006).

Lectures on the Curry-Howard Isomorphism, volume 149 of Studies in Logic and the Foundations of Mathematics.

Elsevier.

Statman, R. (1979).

Intuitionistic Propositional Logic Is Polynomial-space Complete.

Theoretical Computer Science, 9:67–72.

Urzyczyn, P. (1997).

Inhabitation in Typed Lambda-Calculi (A Syntactic Approach).

In TLCA, volume 1210 of LNCS, pages 373–389. Springer.

Referenzen

ÄHNLICHE DOKUMENTE

The CLS view: Already in simple types, relativized inhabitation defines a Turing-complete logic programming language for component composition...

metaprogramming (SCS) domain-specific languages declarative languages logic programming generative programming model driven design (MDD) verification. automatic

Use modal types 2 φ (“code of type φ”) to expose language distinction to compostion synthesis. Introduction of modal

How did the authors use their method to synthesize a fragment of aza-epithialone A. How do the authors justify their observed

[r]

Numerical Solution of Partial Differential Equations, SS 2014 Exercise Sheet

[r]

To justify the definition of SO-HORN, show that the admission of arbitrary first-order prefixes would make the restriction to Horn clauses pointless. This extension of SO-HORN has