• Tidak ada hasil yang ditemukan

4 Completeness of CKA

4.2 Closure

Lemma 4.7. Lete, f ∈ T, and suppose that, for everyg∈ T with|g|<|e|+|f|, there exists a closureg↓. Thenef is a preclosure ofef.

Proof. We start by showing thatef CKAef. First, note thatef BKAef by definition ofef. For the other direction, suppose that, r∈ T are such that Δef r. By definition of closure, we know that ↓ r↓ ≡CKA r. By Lemma 4.5, we haverBKAef. Since every subterm ofef is ordered belowef byCKA, we have thatef CKAef. It then follows thatef CKAef.

For the second requirement, suppose thatX efCKA is non-sequential.

We then know that there exists a Y ∈efBKA such that X Y. This leaves us two cases to consider.

– IfX is empty or primitive, thenY =X by Lemma 3.2, thusX ∈efBKA. By the fact thatef BKAef and by Lemma3.8, we findX ∈efBKA. – IfX =X0X1 for non-empty pomsetsX0 and X1, then by Lemma3.3 we find non-empty pomsetsY0 and Y1 withY =Y0 Y1 such thatXi Yi for i∈ 2. By Lemma 4.6, we find , r∈ T with Δef r such that Y0 BKA andY1∈rBKA. By Lemma3.11, we find that||,|r| ≥1. Corollary4.1then allows us to conclude that||,|r|<|ef|.

This means that↓ r↓BKAef. SinceX0 ∈↓BKA and X1∈r↓BKA by definition of closure, we can derive by Lemma3.8that

X =X0X1∈↓ r↓BKA⊆efBKA

There are two obstacles that need to be resolved before we can use the obser- vations above to find the closure of ef. The first problem is that we need to be sure that this process of splitting terms into sequential components is at all possible, i.e., that we can spliteintoe0ande1withe0·e1CKAeandUi∈eiCKA fori∈2. We do this by designing a sequential analogue to the parallel splitting relation seen before. The second problem, which we will address later in this section, is whether this process of splitting a parallel termef according to the exchange law and finding a closure of remaining term e1 f1 is well-founded, i.e., if we can find “enough” of these terms to cover all possible ways of sequen- tialisingef. This will turn out to be possible, by using the fixpoint axioms of KA as in Sect.3.3 with linear systems.

We start by defining the sequential splitting relation.3

Definition 4.5. Let e∈ T;∇e is the smallest relation on T such that

111 a∇a1 1aa 1e0 1

e0 r e0+e1 r

e1 r e0+e1 r e0 r

e0·e1r·e1

e1 r e0·∇e0·e1 r

0e0 r0 1e1 r1 01e0e1 r0r1

e0r e0·∇e0 r·e0 Givene∈ T, we refer toeas thesequential splitting relationofe, and to the elements of e as sequential splices ofe. We need to establish a few properties of the sequential splitting relation that will be useful later on. The first of these properties is that, as for parallel splitting,e is finite.

Lemma 4.8. Fore∈ T,∇e is finite.

We also have that the sequential composition of splices is provably below the term being split. Just like the analogous lemma for parallel splitting, this guarantees that our sequential splices never give rise to semantics not contained in the split term. This lemma also yields an observation about the width of sequential splices when compared to the term being split.

Lemma 4.9. Lete∈ T. If , r∈ T with∇er, then·rCKAe.

Corollary 4.2. Let e∈ T. If , r∈ T with er, then||,|r| ≤ |e|.

Lastly, we show that the splices cover every way of (sequentially) splitting up the semantics of the term being split, i.e., thateis dense when it comes to sequentially composed pomsets.

Lemma 4.10. Lete∈ T, and letV andW be pomsets such thatV·W ∈eCKA. Then there exist, r∈ T with∇ersuch that V CKA andW ∈rCKA. Proof. The proof proceeds by induction on e. In the base, we can discount the case wheree= 0, for then the claim holds vacuously. This leaves us two cases.

3 The contents of this relation are very similar to the set ofleft- and right-spines of a NetKAT expression as used in [5].

– Ife = 1, then V ·W = 1; by Lemma 3.1, we find that V = W = 1. Since 1e1 by definition ofe, the claim follows when we choose=r= 1.

– Ife=afor somea∈Σ, then V ·W =a; by Lemma 3.1, we find that either V =aand W = 1 orV = 1 andW =a. In the former case, we can choose =aandr= 1 to satisfy the claim; the latter case can be treated similarly.

For the inductive step, there are four cases to consider.

– If e= e0+e1, then V ·W eiCKA for some i 2. By induction, we find , r∈ T with ei r such thatV CKA and W rCKA. Since e rin this case, the claim follows.

– If e = e0 ·e1, then there exist U0 e0CKA and U1 e1CKA such that V·W =U0·U1. By Lemma3.4, we find a series-parallel pomsetX such that eitherV U0·X andX ·W U1, orV ·X U0 andW X·U1. In the former case, we find thatX ·W e1CKA, and thus by induction , r ∈ T withe1rsuch thatX∈CKAandW ∈rCKA. We then choose=e0· to find that e r, as well as V U0·X e0CKA·CKA = CKA and thus V CKA. The latter case can be treated similarly; here, we use the induction hypothesis one0.

– If e = e0 e1, then there exist U0 e0CKA and U1 e1CKA such that V·W U0U1. By Lemma3.6, we find series-parallel pomsetsV0, V1, W0, W1 such that V V0 V1 and W W0 W1, as well as Vi·Wi Ui for all i∈2. In that case,Vi·Wi∈eiCKAfor alli∈2, and thus by induction we find i, ri ∈ T with i ei ri such thatVi iCKA and Wi ∈riCKA. We choose =01andr=r0r1to find thatV 0r0CKA andW 1r1CKA, as well aser.

– If e = e0, then there exist U0, U1, . . . , Un1 e0CKA such that V ·W = U0·U1· · ·Un1. Without loss of generality, we can assume that for 0≤i < n it holds thatUi = 1. In the case wheren= 0 we have thatV ·W = 1, thus V =W = 1, we can choose=r= 1 to satisfy the claim.

For the case wheren >0, we find by Lemma3.4an 0≤m < nand series- parallel pomsetsX, Y such thatX·Y Um, andV U0·U1· · ·Um1·X and W Y ·Um+1·Um+2· · ·Un. Since X ·Y Um e0CKA and thus X·Y ∈e0CKA, we find by induction, r∈ T withe0 r andX CKA andY ∈rCKA. We can then choose=e0·andr=r·e0to find thatV U0·U1· · ·Um1·X∈e0CKA·CKA=CKAandW Y·Um+1·Um+2· · ·Un rCKA·e0CKA=rCKA, and thus thatV CKAandW ∈rCKA. Sinceer

holds, the claim follows.

Example 4.5. LetU be the pomsetcaand letV bebc. Furthermore, letebe the term (a·b+c), and note that U·V ∈eCKA. We then find that a∇a 1, and thusa∇a·b1·b. We can now choose= (a·b+c)·aandr= (1·b)·(a·b+c) to find thatU CKA andV ∈rCKA, whileer.

We know how to split a term sequentially. To resolve the second problem, we need to show that the process of splitting terms repeatedly ends somewhere.

This is formalised in the notion of right-hand remainders, which are the terms that can appear as the right hand of a sequential splice of a term.

Definition 4.6. Let e ∈ T. The set of (right-hand) remainders of e, written R(e), is the smallest satisfying the rules

e∈R(e)

f ∈R(e) f r r∈R(e) Lemma 4.11. Let e∈ T.R(e)is finite.

With splitting and remainders we are in a position to define the linear system that will yield the closure of a parallel composition. Intuitively, we can think of this system as an automaton: every variable corresponds to a state, and every row of the matrix describes the “transitions” of the corresponding state, while every element of the vector describes the language “accepted” by that state without taking a single transition. Solving the system for a least fixpoint can be thought of as finding an expression that describes the language of the automaton.

Definition 4.7. Let e, f ∈ T, and suppose that, for every g ∈ T such that

|g|<|e|+|f|, there exists a closureg↓. We choose Ie,f ={gh:g∈R(e), h∈R(f)}

The Ie,f-vector pe,f andIe,f-matrix Me,f are chosen as follows.

pe,f(gh)gf Me,f(gh, g h)

ggg hhh

gh

Ie,f is finite by Lemma 4.11. We write Le,f for the Ie,f-linear system Me,f, pe,f.

We can check thatMe,f is well-defined. First, the sum is finite, because g

and h are finite by Lemma 4.8. Second, if g h I and g, rg, h, rh ∈ T such that g g rg and h h rh, then |g| ≤ |g| ≤ |e| and |h| ≤ |h| ≤ |f| by Corollary 4.2, and thus, ifd∈ T such that|d|<|g|+|h|, then|d|<|e|+|f|, and therefore a closure of dexists, meaning thatghexists, too.

The least solution to Le,f obtained through Lemma 3.12 is the I-vector denoted by se,f. We writee⊗f forse,f(ef), i.e., the least solution atef.

Using the previous lemmas, we can then show thate⊗f is indeed a closure ofef, provided that we have closures for all terms of strictly lower width. The intuition of this proof is that we use the uniqueness of least fixpoints to show that ef CKAe⊗f, and then use the properties of preclosure and the normal form of series-parallel pomsets to show thatefCKA=e⊗fBKA.

Lemma 4.12. Let e, f ∈ T, and suppose that, for every g ∈ T with |g| <

|e|+|f|, there exists a closureg↓. Thene⊗f is a closure of ef.

Proof. We begin by showing that e f CKA e⊗f. We can see that pe,f is a solution toLe,f, by calculating forgh∈Ie,f:

(pe,f+Me,f·pe,f)(gh)

=gh+

rgrhI ggrg hhrh

gh

·(rgrh) (def. Me,f, pe,f)

CKAgh+

rgrhI

ggrg hhrh

(gh)·(rgrh) (distributivity)

CKAgh+

rgrhI

ggrg hhrh

(gh)·(rg rh) (Lemma 4.7)

CKAgh+

rgrhI

ggrg hhrh

(g·rg)(h·rh) (exchange)

CKAgh+

rgrhI

ggrg hhrh

gh (Lemma 4.9)

CKAgh (idempotence)

=pe,f(gh) (def. pe,f)

To see thatpe,f is the least solution to Le,f, letqe,f be a solution toLe,f. We then know that Me,f ·qe,f +pe,f CKA qe,f; thus, in particular, pe,f CKA qe,f. Since the least solution to a linear system is unique up to CKA, we find that se,f CKApe,f, and therefore thate⊗f =se,f(ef)CKApe,f(ef) =ef.

It remains to show that ifU ∈efCKA, thenU ∈e⊗fBKA. To show this, we show the more general claim that if g h I and U ghCKA, then U ∈se,f(gh)BKA. Write U =U0·U1· · ·Un1 such that for 0≤i < n, Ui is non-sequential (as in Corollary3.1). The proof proceeds by induction onn. In the base, we have thatn= 0. In this case,U = 1, and thusU ∈ghBKAby Lemma 3.2. Sincegh=pe,f(gh)BKAse,f(gh), it follows thatU ∈se,f(gh)BKA by Lemma3.8.

For the inductive step, assume the claim holds forn−1. We writeU =U0·U, with U = U1·U2· · ·Un1. Since U0·U ghCKA, there exist W gCKA and X ∈hCKA such that U0·U W X. By Lemma 3.6, we find pomsets W0, W1, X0, X1such thatW0·W1WandX0·X1X, as well asU0W0X0

andUW1X1. By Lemma4.10, we findg, rg, h, rh∈ T withggrg and hhrh, such thatW0gCKA,W1∈rgCKA,X0hCKA andX1∈rhCKA.

From this, we know thatU0 ghCKA andU∈rg rhCKA. Since U0 is non-sequential, we have thatU0ghBKA. Moreover, by induction we find that U ∈se,f(rg rh)BKA. SinceghBKAMe,f(gh, rgrh) by definition ofMe,f, we furthermore find that

(gh)·se,f(rgrh)BKAMe,f(gh, rgrh)·se,f(rgrh) Sincergrh∈I, we find by definition of the solution to a linear system that

Me,f(gh, rgrh)·se,f(rgrh)BKAse,f(gh)

By Lemma3.8and the above, we conclude thatU =U0·U∈se,f(gh)BKA.

For a concrete example where we find a closure of a (non-trivial) parallel composition by solving a linear system, we refer to AppendixA.

With closure of parallel composition, we can construct a closure for any term and therefore conclude completeness ofCKA.

Theorem 4.1. Lete∈ T. We can construct a closure e↓ ofe.

Proof. The proof proceeds by induction on |e| and the structure of e, i.e., by considering f beforeg if|f|<|g|, or iff is a strict subterm ofg(in which case

|f| ≤ |g|also holds). It is not hard to see that this induces a well-ordering onT. Lete be a term of widthn, and suppose that the claim holds for all terms of width at most n−1, and for all strict subterms ofe. There are three cases.

– Ife= 0,e= 1 ore=afor somea∈Σ, the claim follows from Lemma4.2.

– Ife=e0+e1, or e=e0·e1, ore=e0, the claim follows from Lemma4.3.

– If e= e0 e1, then e0⊗e1 exists by the induction hypothesis. By Lemma 4.12, we then find that e0⊗e1is a closure of e.

Corollary 4.3. Let e, f∈ T. IfeCKA=fCKA, thene≡CKAf.

Proof. Follows from Theorem 4.1and Lemma4.1.

Dalam dokumen Quantitative Analysis of Smart Contracts (Halaman 132-137)