• No results found

4.1 Predicate Abstraction

4.1.1 Boolean Predicate Abstraction

Our work is based on the concept of boolean predicate abstraction [66, 11]

(which we will extend to a three-valued domain in Section 4.1.2). Classical predicate abstraction-based verification tools (e.g. the model checkers Bebop [14] and BLAST [18]) transfer the concrete system under consideration into an abstract system where operations do not refer to concrete variables but to boolean predicates over these variables. In this section, we fundamentally introduce boolean predicate abstraction, following the approach of [11].

As a motivating example, we consider the concurrent system in Figure 4.1.

Here we might be interested in verifying whether Proc2always terminates, or more formally, whether the CTL propertyAF(pc2= 3)holds. It is easy to see that in a fair computation the integer x will be eventually greater or equal to one, and thus, Proc2will finally execute the terminal operation end. However, following our formal approach to verification we first have to transfer the system into a state space model. Assuming that the domain of x and y is Z, the set of reachable states is SVar= {(x = 0, y = 0), (x = 1, y = 0), (x = 1, y =

4.1 Predicate Abstraction 51

−1), (x = 2, y = −1), . . .}, which means we obtain an infinite state space. Hence, a straightforward verification by exploring the concrete state space may fail due to the state explosion problem.

x, y :integer where x = 0, y = 0

Now, the idea of predicate abstraction is to define a set of boolean predicates Predover the system variables Var in order to obtain a much smaller (finite) state space. Thus, in abstract systems operations do not refer to concrete vari-ables but to predicates, i.e. each concrete basic operation bop is approximated by an abstract operation bopawith

bopa ≡ assume(pe) : p1:= pe1, . . . , pk:= pek

where {p1, . . . pk} = Pred and pe, pe1, . . . , pek are boolean expressions over Pred. We generally assume that abstract operations assign to all predicates in Pred. Thus, an abstract operation bopa that does not affect a predicate pi contains the assignment pi:= pi. In our examples we usually omit such self-assignments. Predicate expressions in abstract operations often take the form choice(a, b) for boolean expressions a, b with the following semantics:

s(choice (a, b)) =

Here ∗ denotes a non-deterministic choice between true and false. Hence, ap-plying boolean predicate abstraction may introduce non-deterministic guards and assignments.

For a concrete operation bop ≡ assume(e) : x1:= e1, . . . , xm:= em and a set of predicates Pred = {p1, . . . , pk} we can derive the corresponding abstract operation bopathat approximates bop as follows. We start with the abstract assume condition pe:

pe ≡ choice(EPred(e), EPred(¬e))

where EPred(e)denotes the weakest boolean expression over Pred such that EPred(e)semantically implies e, written EPred(e) |= e. Here ’weakest’ means that all other boolean expressions pe over Pred with pe |= e, also imply EPred(e).

Definition 4.1 (Weaker Boolean Expressions).

Let pe and pe0be boolean expressions with pe |= pe0and pe06|= pe. Then pe0is weaker than pe.

As an example, for the set of predicates Pred = {(x < 0), (x < 1), (y < 0)} and the expression (x = 0) we get EPred(x = 0) = ¬(x < 0) ∧ (x < 1). The expression pe= ¬(x < 0) ∧ (x < 1) ∧ (y < 0)also semantically implies (x = 0). However, we have that pe |= EPred(x = 0) and EPred(x = 0) 6|= pe. Thus, EPred(x = 0)is weaker than pe.

Furthermore, an abstract basic operation bopaconsists of an assignment pi:= peifor each predicate pi∈ Pred with:

pei ≡ choice(EPred(wpbop(pi)), EPred(wpbop(¬pi)))

Here wpbop(pi)is the weakest precondition of the concrete basic operation bop with regard to the predicate pi.

Definition 4.2 (Weakest Precondition).

Let bop ≡ assume(e) : x1:=e1, . . . , xm:=embe a basic operation and p a predicate over the set of variables Var = {x1, . . . , xm}. Then the weakest precondition of bopwith respect to p is

wpbop(p) = e ∧ p[x1/e1, . . . , xm/em]

where p[x1/e1, . . . , xm/em] denotes the substitution of all occurrences of x1, . . . , xmin p by e1, . . . , em, respectively.

The notion of weakest preconditions was originally introduced by Dijkstra in the context of reasoning about imperative programs [52]. In terms of our systems, wpbop(p)corresponds to a predicate expression denoting the set of all states s over Pred such that bop executed in s results in a state where p holds. E.g., the weakest precondition of x := x + 1 with regard to (x < 1) is wpx:=x+1(x < 1) = (x < 0).

Now, we want to see how our example system Sys7can be abstracted over a set of predicates. First of all, we take a look at the concrete control flow graphs corresponding to the processes of Sys7(Figure 4.2).

1 G1::

2 3

skip y:= y − 1

x:= x + 1

1 G2::

2 3

x:= x + 1 (x < 1)

skip

¬(x < 1)

skip

Fig. 4.2 Concrete control flow graphs G1and G2of the processes Proc1and Proc2.

4.1 Predicate Abstraction 53 Here transitions are labelled with concrete basic operations over the variable set Var = {x, y}. For our abstraction we choose the predicate set Pred = {(x <

0), (x < 1)}. The corresponding abstract control flow graphs are depicted in Figure 4.3.

1 Ga1::

2 3

(x < 1) := choice((x < 0), ¬(x < 0)) (x < 0) := choice( f alse, ¬(x < 0))

skip skip 1

Ga2::

2 3

(x < 1) := choice((x < 0), ¬(x < 0)) (x < 0) := choice( f alse, ¬(x < 0))

x:= x + 1 (x < 1)

skip

¬(x < 1)

skip

Fig. 4.3 Abstract control flow graphs Ga1and Ga2over Pred = {(x < 0), (x < 1)}.

These control flow graphs represent an abstraction Sysa7of the concrete system Sys7over the set of predicates Pred = {(x < 0), (x < 1)}. As we can see, the variable y is completely omitted in our abstraction; the concrete operation y :=

y− 1 is abstracted to skip. Furthermore, the operation x := x + 1 is abstracted to list of assignments with regard to the predicates (x < 0) and (x < 1). As the corresponding abstract state space we get

SPred= { (x < 0) , (x < 1), ¬ (x < 0) , (x < 1) , ¬ (x < 0) , ¬ (x < 1) }.

Alike concrete concurrent systems, abstract systems can be straightforwardly transferred into Kripke structures. We only have to take into account that such an abstract Kripke structure is now defined over SPred rather than over SVar, and moreover, the transition relation R is defined with regard to abstract operations (see Definition 3.7). Model checking the CTL formulaAF(pc2= 3)on a Kripke structure corresponding to Sysa7yields true. Hence, boolean predicate abstraction enables us to check temporal logic properties on very small abstractions.

However, so far we have no relation between model checking results ob-tained on concrete and abstract systems. We therefore define an approximation relation  for concrete systems Sys over Var and their abstractions Sysaover Pred. We start on the level of boolean expressions:

Definition 4.3 (Approximation of Boolean Expressions).

Let Var be a set of variables and let e and e0be any two boolean expressions over Var. Then e approximates e0, written e  e0, iff

e|= e0 ∧ ¬e |= ¬e0.

In our notion of abstract systems we have that Pred is a subset of the set of all boolean expressions over Var. Hence, we straightforwardly get that a predicate expression pe over Pred approximates a boolean expression e over Var, pe  e, iff pe |= e and ¬pe |= ¬e. In the particular case of choice expressions we have that choice(a, b) approximates an expression e iff a semantically implies e and bsemantically implies ¬e:

choice(a, b)  e ≡ a |= e ∧ b |= ¬e

Next, we extend the approximation relation to basic operations:

Definition 4.4 (Approximation of Basic Operations).

Let Var be a set of variables and Pred = {p1, . . . , pk} a set of predicates over Var. Moreover, let bop ≡ assume(e) : x1:= e1, . . . , xm:= embe a concrete basic operation over Var and bopa≡ assume(pe) : p1:= pe1, . . . , pk:= pekan abstract basic operation over Pred. Then bopaapproximates bop, written bopa bop, iff

pe e ∧

k

^

i=1

pei wpbop(pi).

Remember that an abstract basic operation generally assigns to all predicates.

Hence, the approximation relation for basic operations is always defined with regard to a given set of predicates Pred. If Pred is clear from the context, we will not explicitly mention it.

For illustration, we again consider our running example and show that (x < 0) := choice( f alse, ¬(x < 0))approximates x := x + 1, which is equivalent to

choice( f alse, ¬(x < 0))  wpx:=x+1(x < 0)

≡ choice( f alse, ¬(x < 0))  (x < −1)

≡ f alse|= (x < −1) ∧ ¬(x < 0) |= ¬(x < −1)

≡ true.

Predicate abstraction solely affects basic operations – and not the control structure of processes. Hence, a process Procai approximates a process Proci iff they have isomorphic control flow graphs and the basic operations in Procai approximate the corresponding ones in Proci.1Finally, a concurrent system Sysa= kni=1Procai approximates a system Sys = kni=1Prociiff each process Procai in Sysaapproximates the corresponding process Prociin Sys. The subsequent definition gives us a formal notion of the approximation relation for concurrent systems:

1Remember that abstract operations bopamay introduce non-determinism, and thus, an abstract control flow transition δia(li, bopa, l0i)may be equivalent to two transitions between the same locations but labelled with different operations. This, however, does not affect isomorphism in our notion.

4.1 Predicate Abstraction 55 Definition 4.5 (Approximation of Concurrent Systems).

Let Sys = kni=1 Proci be a concrete concurrent system over Var and let Sysa= kni=1Procai be an abstract concurrent system over Pred. Moreover, let G1, . . . , Gn, respectively Ga1, . . . , Ganbe the control flow graphs of the processes Proc1, . . . , Procn, resp. Proca1, . . . , Procan. Then Sysa approximates Sys, written Sysa Sys, iff for all i = 1, . . . , n: Giand Gai are isomorphic, i.e. there exists a bijective function h : Loci→ Locai, also called isomorphism, with

• ∀l ∈ Loci: h (l) = l,

(which actually implies that Loci= Locai)

• δi(l, bop, l0)if there exists a bopawith bopa bop and δia(h(l), bopa, h(l0)),

• δia(h(l), bopa, h(l0))if there exists a bop with bopa bop and δi(l, bop, l0).

As we can see, the requirement that each basic operation in the concrete system is approximated by the corresponding one in the abstract system is already included in our notion of isomorphism.

Coming back to our running example, we get by Definition 4.5 that our ab-stract system Sysa7properly approximates the concrete system Sys7. In general, applying boolean predicate abstraction to a concurrent system Sys gives us a conservative over-approximation of Sys. This means an abstraction Sysamay permit more possible behaviour than the original Sys, i.e. all computations that are feasible in Sys are also feasible in Sysa– but a feasible computation of Sysais not necessarily feasible in Sys. Transferred to the field of temporal logic model checking, we get that if a property from the universal fragment of CTL holds for the abstract system then we can deduce that it holds for the corresponding concrete system as well. From [11] we can derive Theorem 4.1 which relates model checking results of concrete and abstract systems for corresponding states.

Definition 4.6 (Corresponding States in Boolean Abstractions).

Let Sys = kni=1Proci be a concurrent system over Var, and Sysa= kni=1Procai an abstract system over Pred, with Sysa Sys. Moreover, let K = (S, R, L, F) be the Kripke structure representing Sys, and Ka= (Sa, Ra, La, Fa)the Kripke structure representing Sysawhere K and Kaare both defined over the same set of atomic predicates AP. Then a concrete state s ∈ S corresponds to an abstract state sa∈ Saiff

∀p ∈ AP : L(s, p) = La(sa, p).

Thus, corresponding states in boolean abstractions have the same labelling with regard to AP, which we sometimes abbreviate by L(s) = La(sa).

Theorem 4.1.

Let Sys = kni=1Procibe a concurrent system over Var, and Sysa= kni=1Procai an abstract system over Pred, with Sysa Sys. Moreover, let K = (S, R, L, F) be the

Kripke structure representing Sys, and Ka= (Sa, Ra, La, Fa)the Kripke structure representing Sysawhere K and Kaare both defined over the same set of atomic predicates AP. Then for any two corresponding states s ∈ S and sa∈ Sa and for any ACTL formula ψ over control locations or the predicates in Pred the following holds:

[Ka, sa|= ψ] ⇒ [K, s |= ψ]

Proof (Theorem 4.1).

We prove this theorem by showing that the notion of corresponding states in boolean abstractions (Definition 4.6) conforms to a fair simulation (Definition 2.7). This can be established based on the following corollary which we get from [11]:

Corollary 4.1.

Let Sys = kni=1Procibe a concurrent system over Var, and Sysa= kni=1Procai an abstract system over Pred, with Sysa Sys. Moreover, let K = (S, R, L, F) be the Kripke structure representing Sys, and Ka= (Sa, Ra, La, Fa)the Kripke structure representing Sysawhere K and Kaare both defined over the same set of atomic predicates AP. Let s ∈ S and sa∈ Sa be any two corresponding states. Then for every path π ∈ Πs in K there is a path πa∈ Πsa in Ka such that for all k∈ N : L(πk) = Laka), i.e πkand πkaare corresponding states.

Hence, for every path in K there is a corresponding path in Kaor, rather, for any two states s ∈ S and sa∈ Sawith L(s) = La(sa)we have that:

R(s, s0) ⇒ ∃s0a∈ Sa: Ra(sa, s0a) ∧ L(s0) = La(s0a)

We have to strengthen this result with regard to fairness, i.e. we require that for every fair path in K there is a corresponding fair path in Ka. This follows by induction from Lemma 4.1.

Lemma 4.1.

Let Sys = kni=1Proci be a concurrent system over Var, and Sysa= kni=1Procai an abstract system over Pred, with Sysa Sys. Moreover, let K = (S, R, L, F) be the Kripke structure representing Sys, and Ka= (Sa, Ra, La, Fa)the Kripke structure representing Sysawhere K and Kaare both defined over the same set of atomic predicates AP. Let s ∈ S and sa∈ Sabe any two states with L(s) = La(sa).

Furthermore, let s0be any state in S and i ∈ [1..n] a process index then Ri(s, s0) ⇒ ∃s0a∈ Sa: Rai(sa, s0a) ∧ L(s0) = La(s0a)

(Remember that, according to Definition 3.7, the transition function R can be reformulated asWni=1Ri.)

Proof (Lemma 4.1).

Ri(s, s0)can be rewritten into Ri(hl, sVari , hl0, s0Vari) where l denotes the location part and sVarthe variable part of the state s. Ri(hl, sVari , hl0, s0Vari) refers to a

4.1 Predicate Abstraction 57 control flow transition δi(l, bop, l0)in Gi= (Loci, δi). According to Definition 4.5 there exists a corresponding transition δia(l, bopa, l0)in Gai with bopa bop.

By assumption, we have that bop can be executed in s and L(s) = La(sa).

Hence, bopa can be executed in sa, i.e. for some state s0a∈ Sa there exists a transition Ri(sa, s0a)associated with bopa. Since bopa bop we have that L(s0) = La(s0a). ut

From Lemma 4.1 we can deduce that our notion of corresponding states in boolean abstractions (Definition 4.6) conforms to a fair simulation (see Definition 2.7).

Corollary 4.2.

Let Sys = kni=1Procibe a concurrent system over Var, and Sysa= kni=1Procai an abstract system over Pred, with Sysa Sys. Moreover, let K = (S, R, L, F) be the Kripke structure representing Sys, and Ka= (Sa, Ra, La, Fa)the Kripke structure representing Sysawhere K and Kaare both defined over the same set of atomic predicates AP. Then the set of all pairs of corresponding states s ∈ S and sa∈ Sa characterises a fair simulation sS× Sabetween K and Ka.

The correctness of Theorem 4.1 now immediately follows from Theorem 2.2, which states that fair simulation preserves ACTL properties. ut

Hence, our result that the propertyAF(pc2= 3)holds for the small abstraction Sysa7can be directly transferred to the concrete system Sys7. In general, boolean predicate abstraction enables us to verify concurrent systems on very small abstract models, and thus, helps us to reduce the complexity of temporal logic model checking.

However, if checking a universally quantified property yields false for an abstraction, we can not conclude that the original system violates this property as well. In this case, the model checking procedure additionally returns an abstract counterexample – a path in the abstract model that refutes the property.

In order to gain certainty about whether this counterexample is spurious (i.e.

it exists in the abstraction only) or corresponds to a real path, it has to be retraced on the original system. The retracement of counterexamples involves a partial exploration of the concrete state space, and thus, suffers from the state explosion problem as well. In the next section we introduce three-valued predicate abstraction. This generalisation of boolean predicate abstraction is capable of preserving both true and false results in verification – which saves us the expensive retracement step. Moreover, three-valued predicate abstraction is straightforwardly compatible with spotlight abstraction – the second abstraction technique that we employ in our framework (compare Section 4.2).