• Non ci sono risultati.

8 AN EQUIVALENT GREATEST FIXPOINT ALGORITHM

Let us assume that𝑔 : 𝐢 β†’ 𝐢 is a monotonic function on a complete lattice ⟨𝐢, ≀, ∨, ∧⟩ which admits its unique right-adjoint𝑔 : 𝐢 β†’ 𝐢, i.e., βˆ€π‘, 𝑐e β€² ∈ 𝐢, 𝑔(𝑐) ≀ 𝑐′ ⇔ 𝑐 ≀ e𝑔(𝑐′) holds. Then, Cousot [2000, Theorem 4] shows that the following equivalence holds: for all𝑐, π‘β€²βˆˆ 𝐢,

lfp(πœ†π‘₯. 𝑐 ∨ 𝑔(π‘₯)) ≀ 𝑐′ ⇔ 𝑐 ≀ gfp(πœ†π‘¦. π‘β€²βˆ§ e𝑔(𝑦)) . (24) This property has been used in [Cousot 2000] to derive equivalent least/greatest fixpoint-based invariance proof methods for programs. In the following, we use (24) to derive an algorithm for deciding the inclusionL(A1) βŠ† L(A2), which relies on the computation of a greatest fixpoint rather than a least fixpoint. This can be achieved by exploiting the following simple observation, which defines an adjunction between concatenation and quotients of sets of words.

Lemma 8.1. For all𝑋, π‘Œ ∈ β„˜(Ξ£βˆ—) and 𝑀 ∈ Ξ£βˆ—,π‘€π‘Œ βŠ† 𝑍 ⇔ π‘Œ βŠ† π‘€βˆ’1𝑍 and π‘Œπ‘€ βŠ† 𝑍 ⇔ π‘Œ βŠ† π‘π‘€βˆ’1. PRoof. By definition, for all𝑒 ∈ Ξ£βˆ—,𝑒 ∈ π‘€βˆ’1𝑍 iff 𝑀𝑒 ∈ 𝑍. Hence, π‘Œ βŠ† π‘€βˆ’1𝑍 ⇔ βˆ€π‘’ ∈ π‘Œ, 𝑀𝑒 ∈

𝑍 ⇔ π‘€π‘Œ βŠ† 𝑍. Symmetrically, π‘Œπ‘€ βŠ† 𝑍 ⇔ π‘Œ βŠ† π‘π‘€βˆ’1holds. β–‘

Given a FAA = βŸ¨π‘„, 𝛿, 𝐼, 𝐹, Σ⟩, we define the function gPreA :β„˜(Ξ£βˆ—)|𝑄 | β†’ β„˜(Ξ£βˆ—)|𝑄 |on𝑄-indexed vectors of sets of words as follows:

gPreA(βŸ¨π‘‹π‘žβŸ©π‘žβˆˆπ‘„) β‰œ βŸ¨Γ‘

π‘ŽβˆˆΞ£,π‘žβ€²βˆˆπ›Ώ (π‘ž,π‘Ž) π‘Žβˆ’1π‘‹π‘žβŸ©π‘žβ€²βˆˆπ‘„ , where, as usual,Γ‘

βˆ… = Ξ£βˆ—. It turns out that gPreA is the usual weakest liberal precondition which is right-adjoint of PreA.

Lemma 8.2. For all #»𝑿, #»𝒀 ∈ β„˜(Ξ£βˆ—)|𝑄 |, PreA( #»𝑿) βŠ† #»𝒀 ⇔ #»𝑿 βŠ† gPreA( #»𝒀 ).

PRoof.

PreA(βŸ¨π‘‹π‘žβŸ©π‘žβˆˆπ‘„) βŠ† βŸ¨π‘Œπ‘žβŸ©π‘žβˆˆπ‘„β‡” [by definition of PreA]

βˆ€π‘ž ∈ 𝑄,Ð

π‘žβ†’π‘žπ‘Ž β€²π‘Žπ‘‹π‘žβ€²βŠ† π‘Œπ‘žβ‡” [by set theory]

βˆ€π‘ž, π‘žβ€²βˆˆ 𝑄, π‘žβ†’ π‘žπ‘Ž β€²β‡’ π‘Žπ‘‹π‘žβ€²βŠ† π‘Œπ‘žβ‡” [by Lemma 8.1]

βˆ€π‘ž, π‘žβ€²βˆˆ 𝑄, π‘žβ†’ π‘žπ‘Ž β€²β‡’ π‘‹π‘žβ€² βŠ† π‘Žβˆ’1π‘Œπ‘žβ‡” [by set theory]

βˆ€π‘žβ€²βˆˆ 𝑄, π‘‹π‘žβ€² βŠ†Γ‘

π‘žβ†’π‘žπ‘Ž β€²π‘Žβˆ’1π‘Œπ‘žβ‡” [by definition of gPreA]

βŸ¨π‘‹π‘žβŸ©π‘žβˆˆπ‘„ βŠ† gPreA(βŸ¨π‘Œπ‘žβŸ©π‘žβˆˆπ‘„) . β–‘

Hence, from equivalences (10) and (24), we obtain that for all FAsA1and𝐿2∈ β„˜(Ξ£βˆ—):

L(A1) βŠ† 𝐿2 ⇔ #»𝝐𝐹1 βŠ† gfp(πœ† #»𝑿 . # »𝑳2𝐼1∩ gPreA1( #»𝑿)) . (25) The following algorithm FAIncGfp decides the inclusionL(A1) βŠ† 𝐿2, when𝐿2 is regular, by implementing the greatest fixpoint computation in equivalence (25).

FAIncGfp: Greatest fixpoint algorithm forL(A1) βŠ† 𝐿2

Data: FAA1=βŸ¨π‘„1, 𝛿1, 𝐼1, 𝐹1, Σ⟩; regular language 𝐿2.

1 βŸ¨π‘Œπ‘žβŸ©π‘žβˆˆπ‘„ :=Kleene(βŠ‡, πœ† #»𝑿 . # »𝑳2𝐼1∩ gPreA1( #»𝑿),𝚺# Β»βˆ—);

2 forallπ‘ž ∈ 𝐹1do

3 ifπœ– βˆ‰ π‘Œπ‘žthen return false;

4 return true;

The intuition behind Algorithm FAIncGfp is that

L(A1) βŠ† 𝐿2⇔ βˆ€π‘€ ∈ L(A1), (πœ– ∈ π‘€βˆ’1𝐿2⇔ πœ– βˆˆΓ‘

𝑀 ∈L (A1)π‘€βˆ’1𝐿2) .

Therefore, FAIncGfp computes the setΓ‘{π‘€βˆ’1𝐿2| 𝑀 ∈ L(A1)} by using the automaton A1and by considering prefixes ofL(A1) of increasing lengths. This means that after 𝑛 iterations of Kleene, the algorithm FAIncGfp has computed

Γ‘{π‘€βˆ’1𝐿2 | 𝑀𝑒 ∈ L(A1), |𝑀 | ≀ 𝑛, π‘ž0∈ 𝐼1, π‘ž0 𝑀

{ π‘ž}

for every stateπ‘ž ∈ 𝑄1. The regularity of 𝐿2 and the property of regular languages of being closed under intersections and quotients entail that each Kleene iterate of Kleene(βŠ‡, πœ† #»𝑿 . # »𝑳2𝐼1∩ gPreA1( #»𝑿),𝚺# Β»βˆ—) is a (computable) regular language. To the best of our knowledge, this gfp-based language inclusion algorithm FAIncGfp has never been described in the literature before.

Next, we discharge the fundamental assumption guaranteeing the correctness of this algorithm FAIncGfp: the Kleene iterates computed by FAIncGfp are finitely many. To achieve this, we con-sider an abstract version of the greatest fixpoint computation exploiting a closure operator which ensures that the abstract Kleene iterates are finitely many. This closure operatorπœŒβ‰€A2 will be de-fined by using an ordering relation≀A2 induced by a FAA2such that𝐿2 = L(A2) and will be shown to be forward complete for the functionπœ† #»𝑿 . # »𝑳2𝐼1∩ gPreA1( #»𝑿) used by FAIncGfp.

Forward completeness of abstract interpretations [Giacobazzi and Quintarelli 2001], also called exactness [MinΓ© 2017, Definition 2.15], is different from and orthogonal to backward completeness introduced in Section 3 and crucially used throughout Sections 4–7. In particular, a remarkable con-sequence of exploiting a forward complete abstraction is that the Kleene iterates of the concrete and abstract greatest fixpoint computations coincide. The intuition here is that this forward com-plete closureπœŒβ‰€A2 allows us to establish that all the Kleene iterates ofπœ† #»𝑿 . # »𝑳2𝐼1∩ gPreA1( #»𝑿) belong to the image of the closureπœŒβ‰€A2, more precisely that every Kleene iterate is a language which is upward closed for≀A2. Interestingly, a similar phenomenon occurs in well-structured transition systems [Abdulla et al. 1996; Finkel and Schnoebelen 2001].

Let us now describe in detail this abstraction. A closure𝜌 ∈ uco(𝐢) on a concrete domain 𝐢 is forward complete for a monotonic function𝑓 : 𝐢 β†’ 𝐢 if πœŒπ‘“ 𝜌 = 𝑓 𝜌 holds. The intuition here is that forward completeness means that no loss of precision is accumulated when the output of a computation of𝑓 𝜌 is approximated by 𝜌, or, equivalently, the concrete function 𝑓 maps abstract elements of𝜌 into abstract elements of 𝜌. Dually to the case of backward completeness, forward completeness implies that gfp(𝑓 ) = gfp(𝑓 𝜌) = gfp(πœŒπ‘“ 𝜌) holds, when these greatest fixpoints ex-ist (this is the case, e.g., when𝐢 is a complete lattice). When the function 𝑓 : 𝐢 β†’ 𝐢 admits the right-adjoint e𝑓 : 𝐢 β†’ 𝐢, i.e., 𝑓 (𝑐) ≀ 𝑐′⇔ 𝑐 ≀ e𝑓 (𝑐′) holds, it turns out that forward and backward completeness are related by the following duality [Giacobazzi and Quintarelli 2001, Corollary 1]:

𝜌 is backward complete for 𝑓 iff 𝜌 is forward complete for e𝑓 . (26) Thus, by (26), in the following result instead of assuming the hypotheses implying that a closure𝜌 is forward complete for the right-adjoint gPreA1, we state some hypotheses which guarantee that 𝜌 is backward complete for its left-adjoint, that, by Lemma 8.2, is PreA1.

TheoRem 8.3. LetA1=βŸ¨π‘„1, 𝛿1, 𝐼1, 𝐹1, Σ⟩ be a FA , 𝐿2be a regular language and𝜌 ∈ uco(β„˜(Ξ£βˆ—)).

Let us assume that:

(1) 𝜌(𝐿2) = 𝐿2;

(2) 𝜌 is backward complete for πœ†π‘‹ . π‘Žπ‘‹ for all π‘Ž ∈ Ξ£.

Then, L(A1) βŠ† 𝐿2 iff #»𝝐𝐹1 βŠ† gfp(πœ† #»𝑿 .𝜌( # »𝑳2𝐼1 ∩ gPreA1(𝜌( #»𝑿)))). Moreover, the Kleene iterates of πœ† #»𝑿 . 𝜌( # »𝑳2𝐼1∩ gPreA1(𝜌( #»𝑿))) and πœ† #»𝑿 . # »𝑳2𝐼1∩ gPreA1( #»𝑿) from the initial value𝚺# Β»βˆ—coincide in lockstep.

PRoof. Theorem 4.3 shows that if𝜌 is backward complete for πœ†π‘‹ . π‘Žπ‘‹, for every π‘Ž ∈ Ξ£, then it is backward complete for PreA1. Thus, by (26),𝜌 is forward complete for gPreA1. Then, it turns out that𝜌 is forward complete for πœ† #»𝑿 . # »𝑳2𝐼1∩ gPreA1( #»𝑿), because:

𝜌( # »𝑳2𝐼1∩ gPreA1(𝜌( #»𝑿))) = [by forward completeness for gPreA1and𝜌(𝐿2) = 𝐿2] 𝜌(𝜌( # »𝑳2𝐼1) ∩ 𝜌(gPreA1(𝜌( #»𝑿)))) = [by (3)]

𝜌( # »𝑳2𝐼1) ∩ 𝜌(gPreA1(𝜌( #»𝑿))) = [by forward completeness for gPreA1and𝜌(𝐿2) = 𝐿2] 𝑳# Β»2𝐼1∩ gPreA1(𝜌( #»𝑿)) .

Since, by forward completeness, gfp(πœ† #»𝑿 . # »𝑳2𝐼1∩ gPreA1( #»𝑿)) = gfp(πœ† #»𝑿 . 𝜌( # »𝑳2𝐼1∩ gPreA1(𝜌( #»𝑿)))), by equivalence (25), we conclude thatL(A1) βŠ† 𝐿2iff #»𝝐𝐹1 βŠ† gfp(πœ† #»𝑿 . 𝜌( # »𝑳2𝐼1∩ gPreA1(𝜌( #»𝑿)))).

Finally, we observe that the Kleene iterates ofπœ† #»𝑿 . # »𝑳2𝐼1∩gPreA1( #»𝑿) and πœ† #»𝑿 . 𝜌( # »𝑳2𝐼1∩gPreA1(𝜌( #»𝑿))) starting from𝚺# Β»βˆ—coincide in lockstep since𝜌( # »𝑳2𝐼1 ∩ gPreA1(𝜌( #»𝑿))) = # »𝑳2𝐼1 ∩ gPreA1(𝜌( #»𝑿)) and

𝜌( # »𝑳2𝐼1) = # »𝑳2𝐼1. β–‘

We can now establish that the iterates of Kleene(βŠ‡, πœ† #»𝑿 . # »𝑳2𝐼1∩ gPreA1( #»𝑿),𝚺# Β»βˆ—) are finitely many.

Let𝐿2=L(A2), for some FA A2, and consider the corresponding left state-based quasiorder≀𝑙A2 onΞ£βˆ— as defined by (16). By Lemma 5.8,≀𝑙A2 is a left𝐿2-consistent wqo. Furthermore, since𝑄2

is finite, we have that both≀𝑙A

2 and (≀𝑙A

2)βˆ’1 are wqos, so that, in turn, βŸ¨πœŒβ‰€π‘™

A2(β„˜(Ξ£βˆ—)), βŠ†βŸ© is a poset which is both ACC and DCC. In particular, the definition of≀𝑙A

2 implies that every chain inβŸ¨πœŒβ‰€π‘™

A2(β„˜(Ξ£βˆ—)), βŠ†βŸ© has at most 2|𝑄2|elements, so that if we compute 2|𝑄2| Kleene iterates then we surely converge to the greatest fixpoint. Moreover, as a consequence of the DCC property, we have that Kleene(βŠ‡, πœ† #»𝑿 . πœŒβ‰€A2( # »𝑳2𝐼1∩ gPreA1(πœŒβ‰€A2( #»𝑿))),𝚺# Β»βˆ—) always terminates, thus implying that Kleene(βŠ‡, πœ† #»𝑿 . # »𝑳2𝐼1∩ gPreA1( #»𝑿),𝚺# Β»βˆ—) terminates as well, because their iterates go in lockstep as stated by Theorem 8.3. We have therefore shown the correctness of FAIncGfp.

CoRollaRy 8.4. The algorithm FAIncGfp decides the inclusionL(A1) βŠ† 𝐿2

Example 8.5. Let us illustrate the greatest fixpoint algorithm FAIncGfp on the inclusion check 𝐿(B) βŠ† 𝐿(A) where A is the FA in Fig. 1 and B is the following FA:

π‘ž3 π‘ž4

𝑏

π‘Ž π‘Ž

By Corollary 8.4, the Kleene iterates ofπœ† #»𝒀 .𝑳(A)# Β»{π‘ž3} ∩ gPreB( #»𝒀 ) are guaranteed to converge in finitely many steps. We have that

# Β»

𝑳(A){π‘ž3}∩ gPreB(βŸ¨π‘Œ3, π‘Œ4⟩) = ⟨𝐿(A) ∩ π‘Žβˆ’1π‘Œ4, π‘βˆ’1π‘Œ3∩ π‘Žβˆ’1π‘Œ4⟩ .

Then, the Kleene iterates are as follows (we automatically checked them by the FAdo tool [Almeida et al. 2009]):

π‘Œ3(0)=Ξ£βˆ— π‘Œ4(0)=Ξ£βˆ—

π‘Œ3(1)=𝐿(A) ∩ π‘Žβˆ’1Ξ£βˆ—=𝐿(A) π‘Œ4(1)=π‘βˆ’1Ξ£βˆ—βˆ© π‘Žβˆ’1Ξ£βˆ—=Ξ£βˆ—

π‘Œ3(2)=𝐿(A) ∩ π‘Žβˆ’1Ξ£βˆ—=𝐿(A) π‘Œ4(2)=π‘βˆ’1𝐿(A) ∩ π‘Žβˆ’1Ξ£βˆ—=π‘βˆ’1𝐿(A) = (π‘βˆ—π‘Ž)+ π‘Œ3(3)=𝐿(A) ∩ π‘Žβˆ’1(π‘βˆ—π‘Ž)+ =𝐿(A) π‘Œ4(3)=π‘βˆ’1𝐿(A) ∩ π‘Žβˆ’1(π‘βˆ—π‘Ž)+=(π‘βˆ—π‘Ž)+

Thus, Kleene outputs the vectorβŸ¨π‘Œ3, π‘Œ4⟩ = ⟨𝐿(A), (π‘βˆ—π‘Ž)+⟩. Since πœ– ∈ 𝐿(A), FAIncGfp concludes

that𝐿(B) βŠ† 𝐿(A) holds. ^

Finally, it is worth citing that Fiedor et al. [2019] put forward an algorithm for deciding WS1S formulae which relies on the same lfp computation used in FAIncS. Then, they derive a dual gfp computation by relying on Park’s duality [Park 1969]: lfp(πœ†π‘‹ . 𝑓 (𝑋)) = (gfp(πœ†π‘‹ . (𝑓 (𝑋𝑐))𝑐))𝑐. Their approach differs from ours since we use the equivalence (24) to compute a gfp, different from the lfp, which still allows us to decide the inclusion problem. Furthermore, their algorithm decides whether a given automaton acceptsπœ– and it is not clear how their algorithm could be extended for deciding language inclusion.

Documenti correlati