• No se han encontrado resultados

h- S; A i, [A/z]Agi, zi : [A/x]A, [A/z]Agg basis

E; A i, [A/z]Agi, zi : [A/z]A, [A/z]Agg => z% : [A/z]A The proof of this case is concluded by using the following identities:

[A/z]Ag = [A/z]Agi,zi : [A/z]A, [A/z]Agg; [A/z]zj = zi.

Case last step of TT is =*- 3:

S; A i, z -dcf A : r, Ag =»> ei ; [Ai/y]Gi E; A i, z —dcf A : r, Ag h Ai : n E; A%, z —def A : T, Ag paivq^A\, c%) : 3y;xiGi

where e — pair,(A i,ei) and G — ^y^^Gi. From a derivation of E; A i,z =d«/ A : r, Ag 1- Ai : n ,

we may construct a derivation of

E; Ai, [A/z]Ag h [A/z]Ai : ri.

(A sketch of this construction is given in the proof of Lemma 4.2.) By the I.H., there is a derivation of

E; A i, [A/z]Ag => [A/z]ei : [A/z]([Ai/p]Gi). Using the identity

[A /x]([A i/y]G i) = [[A /x]A i/y]([A /® ]G ,),

which may be shown by using the substitution property of the following derivation may be formed

E; A i, [A/z]Ag [A/z]ei : [[A/z]Ai/p]([A/z]Gi) E; Ai, [A/z]Ag h [A/z]Ai : n

E; A i, [A/z]Ag => pmVg([A/z]Ai, [A/z]ei) : 3y:x^[A/z]Gi

The proof of this case is concluded by observing that the following identities hold: [A/z]pairg(Ai, ei) = pair, ( [A/z] Ai, [A/z]ei);

[ A / z ] ( 3 y :r ,Gi ) = 3 y : n [ A / z ] G i .

The case where the last step of TT is a rule V => follows by similar arguments. The other

cases follow directly from the I.H.. □

L em m a 4.5 Let E; A i,z —def A : r, Ag h G p / and E; Ai, [A/z]Ag => [A/z]e : [A/z]G be de­ rivable in H H '. Then, E; A i, z =def A : r, Ag e : G is derivable in H H '.

P roof: Let TT be a 77H'-derivation of S; A i, [A/zjAg => [A/z]e : [A/z]G. The proof follows by induction on the structure of TT.

Case last step of TTis an axiom of the form:

h E; A i, Agi, zi : A, Agg basis

E; A i, Agi, zi : A, Agg zi : A axiom

where [A/z]Ag = (Agi,zi : A, Agg), [A/z]e = zi and [A/z]G = A. It is easy to show that: Ag must be of the form (A31, zi : Ai, A3g), where [A/z]A3i = Agi, [A/z]Ai = A, [A/z]A3g = Agg; and e = zi. By hypothesis, E; A i, z —dcj A : r, Ag h G p / is derivable, then there is a derivation of f- E; A i, z —dcf A : r, Ag basis. Since [A/z]Ai = A, a derivation of

E; Ai, z =dcf A : r, Ag h Ai = A may be constructed. Thus, the following derivation may be formed:

h E; A i, z =de/ A : r, Ag basis axiom

E; A i, z —dcf A : r, Ag => zi : Ai________ E; A i, z =dcf A : r, Ag h Ai = A _

E; Ai, z A : r, Ag =>> zi : A ‘

Case last step of TT is a rule => 3 of the form:

E; A i, [A/z]Ag =» ei : [Ai/p]Gi E; Ai, [A/z]Ag h Ai : n ^ ^ E; A i, [A/z]Ag pctir,(Ai, 61) : 3y.xjGi

where [A/z]e = pair,(A i, ei) and [A/z]G = 3y;x,Gi. It is easy to show that: (i) e is of the form pair,(Ag, eg), where [A/z]Ag = Ai and [A/z]eg = ei; and (ii) G is of the form 3y;x,Gg, where [A/z]Gg = Gi. The identities below hold:

[Ai/p]Gi = [[A/z]Ag/p]([A/z]Gg) = [A/z]([Ag/p]Gg);

[A/z] eg = Cl. So, by the I.H., there is a derivation of

E; Ai, z =dcf A : r, Ag => eg : [Ag/p]Gg.

Since h S; A i, z =dcf A : r, Ag basis is derivable, by using Lemma 4.3, from the derivation of E; A i, [A/z]Ag h [A/z]Ag : n ,

we may construct a derivation of

E; A i, z —dcf A : r, Ag h Ag : ri. Thus, the following derivation may be formed:

E; A i, z -dcf A : r, Ag => eg : [Ag/p]Gg E; Ai, z =def A : r, Ag h Ag : n E; A i, z =dcf A : r, Ag pair,(Ag, eg) : 3y:rjGg

The case where the last step of TT is a rule V => follows by similar arguments. The other

T h eo rem 4 .1 Let E ;A h G g f be derivable in H H '. Then, the sequent E;A=>-e :G is derivable in H H ' iff the sequent E;H(A) => [A]e : [A]<j is derivable in H H .

P roof: The proof follows by induction on the number of simple definitions in A.

Case A contains no simple definitions. Then, by Lemma 4.1, E; A => e : G is derivable in

H H ' iff E; fJ>{A) => e : [A]G is derivable in H H . The proof of this case is concluded by observing that, for A contains no simple definitions: (i) ^(A) = /i(^(A)) = //(A); and (ii) [A]e = e.

Case A contains n > 0 simple definitions, A may be written as A i,x A : T, Ag, where A2 contains no simple definitions.

(i) By Lemma 4.4, if

E; A i, X —def A : r, A2 e : G is derivable in H H ' then

E; Ai, [A/x]A2 => [A/x]e : [A/x]G is derivable in H H ' .

(ii) By Lemma 4.5, for E; A h G is derivable, if

E; A i, [A/x]A2 [A/x]e : [A/x]G is derivable in H H ' then

E; A i, X —d^f A : r, A2 e : G is derivable in H H '.

So, from (i) and (ii), since (Ai,[A/x]A2) has one simple definition fewer than (Ai,x A : r, A2), by the I.H.,

E; A i, [A/x]A2 => [A/x]e : [A/x]G is derivable in H H ' iff

E; K(Ai, [A/x]A2) => [Ai, [A/x]A2][A/x]e : [Ai, [A/x]A2][A/x]G

is derivable in H H . For concluding the proof it suffices to observe that the following identities hold:

i^(Ai, [A/x]A2) = ^(Ai, X —def A : r, A2); [Ai, [A/x]A2][A/x]e = [Ai,x -d^f A : r, A2]e; [Ai, [A/x]A2][A/x]G = [Ai, X —d^f A : r, A2]G,

since A2 contains no simple definitions. □

Theorem 4.1 gives a means to interpret a logic programming language based on the calculus if JT'into HOPLP. Consider the programming language HOPLPD based on if if'defined as follows.

• A program is a pair (S, A), usually written S;A, where E is a signature and A is a if if'-context; E; A is a well-formed program iff h E; A basis is derivable in if if'.

• A goal is a G-formula; G is a well-formed goal w.r.t. a program E; A iff E; A h G 5/ is derivable in if if'.

• A goal G is achievable w.r.t. a program S; A iff there exists a proof-term e s.t. E; A => e : G is derivable in if if'; the proof-term e is called a witness for the achievement of G w.r.t E;A.

Theorem 4.1 guarantees that for every witness for the achievement of [A]G w.r.t. E; A in HOPLP there is a witness for the achievement of G w.r.t. E; A in HOPLPD. Now, a complete set S of witnesses for the achievement of a goal G w.r.t. a program E; A in HOPLPD is defined as a maximal set s.t.: (i) the elements of S are uniform linear focused proof-terms e

s.t. E; A => e : G is derivable in if if ' ; (ii) no two members ej, 62 of S are such that [Ajei and [A]e2 are A-convertible. Then HOPLP and HOPLPD may be regarded, in logical terms, as essentially the same language. The differences between the two languages are the mechanisms provided for writing programs and goals, e.g. HOPLPD allows an abbreviation mechanism for terms of simple type whereas HOPLP does not have such mechanism.

The programming language LeFun, as described in [AKN89], is a language that integrates logic and functional programming. LeFun provides a mechanism for simple definitions that is essentially the same as the mechanism for simple definitions of HOPLPD. In LeFun a program is essentially a list of logical formulae together with a list of definitions of the form / =def where

f is an identifier and f is a A-term. The computation mechanism is called residuation, which is essentially a form of resolution, where not all unification problems on A-terms are solved; those unification problems involving function application to arguments that are not fully instantiated are left to be verified as constraints.

4.3

T he calcuU

and

So far, the achievement of a goal G w.r.t. a program P has been considered to be a search for a special form of derivation of a sequent P => G in calculi having no rule similar to Gentzen’s

cut rule [Gen35]. The cut rule in Gentzen’s L J may be written in the form: P = > G r , G = > B cut,

where F is a set of formulae and JS, C are formulae. The formula C is called the cut formula.

This rule may be read as follows. For proving that B is a logical consequence of F it suffices to prove that there exists a C s.t. G is a logical consequence of F and B is a logical consequence ofF,G.

Using cuts for constructing derivations allows much shorter derivations of some judgements, see e.g. [WW92]. In [Boo84] are shown formulae whose shortest cut-free derivations are expo­ nentially longer than their derivations using cuts.

The problem of using a cut rule in proof-search is to decide when and how a cut rule should be applied; in other words, what the adequate lemmas are to use in proving a theorem and when they should be applied. Usually, the lemmas are established based on experience.

In logic programming lemmas should not be established during proof-search. Instead, the programmer should know what lemmas may be useful and define names for the proofs of those lemmas. Then, during the search for a proof of a formula these formulae, previously established, may be used several times without having to be proved. In parallel to a mathematician who wants to prove a theorem, in order to achieve a goal, firstly some lemmas are proved and then those lemmas are combined to achieve the initial goal.

In this thesis the ideas described above are realised in the integrated logical and functional programming language LFPL, defined in Sec. 4.6. The semantics of LFPL is described in terms of the proof theory of the calculus , defined in Sec. 4.5. The language LFPL may be interpreted into HOPLP by means of an interpretation of into H H that essentially corresponds to a process of cut elimination, as shown in Sec. 4.5.

This section defines the calculi H H^^^ and HH^^^ ; they are essentially extensions of

H H and H H ' , respectively, with a cut rule. These calculi are used as intermediate calculi in the interpretation of H H ^^^ into H H described in Sec, 4.5. This interpretation is also used in relating the programming languages LFPL and HOPLP. The remainder of this section defines the calculi H H^^^ and H H^^^ and presents some results needed for interpreting H H ^'^f into

H H .

As noted above, the calculus H H^^^ is an extension of H H with a cut rule. The cut rule may only allow cut formulae which are simultaneously iï-formulae and G-formulae, otherwise one or more premises of this rule would be ill-formed sequents.

All the classes of objects used in H H are also used in H H ^^^‘, their definitions are the same except for the class of proof-terms e. The proof-terms e of H H ^^^ are all the proof-terms of

H H together with the proof-terms that may obtained by the rule: if ei,e% are proof-terms of

H H ^^^ then let x = €\ in 6 2 is a proof-term of H H ^^^, where x is a variable. Proof-terms of the form let x = ei in eg are used to annotate cut rules. In proof-terms of the form let x = e% in eg, X is a binder of scope eg; any occurrence of x in eg is said to be bound. As before, proof-terms are equal up to renaming of bound variables.

The operation [A/x]e of substitution of a variable by a term of simple type on HH'^^^ proof- terms is defined as for H H , with the following extra case to deal with the let constructor:

The class I of intersection formulae is defined by the following grammar:

/ : : = A | / A / | / D / 1 Vz:T/.

The class of /-formulae is the maximal subclass s.t. it is simultaneously a subclass of H-

formulae and a subclass of G-formulae.

The forms of judgement in are the same as those in H H . The derivable judgements of the same as those of H H except for sequents. For constructing derivations of sequents in H H^^^ all the rules of H H are allowed, as well as the cut rule, presented in Fig. 4.5.

E;A=4>'e:/ E; A, x : / => ei : G ,

Figure 4.5: Cut rule of HH^^^.

The result below shows that H H^^^ is an extension of H H .

L em m a 4.6 / / S; A e : G is derivable in H H then S; A => e : G is derivable in H H ^^^.

P roof: The proof is by induction on the structure of the derivation of E; A =>• e : G in H H .

Notice that all the rules allowed in H H are also allowed in H H ^^^. □ Now a result converse to Lemma 4.6 is addressed, i.e. a mapping from derivable sequents in

jjjjc u t derivable sequents in H H .

Let HH*^^^ be the calculus obtained from HH^^^ by replacing the conversion rules and axioms by the new form of axiom, axiomconv, shown in Fig. 4.6.

\-Tf', A ,x : A basis YArA = Ai

S ; A , x :

Figure 4.6: The rule axiomconv.

The following result is an analogue to Theorem 3.21 relating H H and HH°.

T h eo rem 4.2 A sequent is derivable in HH^^^ iff it is derivable in H H ^^^ .

Proof: If a sequent is derivable in HH^^^ then it is derivable in H H ^^^ since axiomconv

is derivable in H H^^^.

In order to prove the other implication, first is proved that: every i/i/'^^^-derivation TT of a sequent E; A => e : G may be transformed into a derivation whose conversion rules occur either immediately below axioms or other conversion rules. The proof is obtained, analogously to

Theorem 3.21, by showing that every conversion rule may be moved above both logical rules and cuts. For example, consider TT to have the form below.

7Ti 7^2

E; A => : / E; A, x : / => eg : Gi

E;A=> W x = ei in eg :G i E h Gi = G _

T>’, A let X = Cl in € 2 G ^ Thus, the following derivation may be formed.

3Tg 3f3

TTi E; A, X : / =4^ eg : Gi E f~ Gi = G E; A =/► ei : / E; A, x : / eg : G

A let X = ei in eg : G

Secondly, following the proof of Theorem 3.21, it may be shown that: every sequent derivable in by using only axioms and conversion rules, is derivable in by using axiom —

conv.

It may be readily shown that in the proof-term of a derivation identifies uniquely the derivation, up to renaming of bound variables.

In order to prove cut elimination first is shown the admissibility of a form of contraction in

H H . Since proof-terms are being used for representing derivations, the transformations on derivations required for showing admissibility of contraction are captured at the level of proof- terms. If proof-terms are regarded as the expressions of a functional language, see [Wad93], then the operation of contraction on proof-terms corresponds to substitution of a variable by another variable inside an expression.

The operation {x/x}e of contraction on proof-terms is defined in Fig. 4.7.