• Aucun résultat trouvé

Encoding Terms

Dans le document Symbolic model-checking with Set Rewriting (Page 54-58)

which is not possible in the original setting. The goal of this union is to preserve typ-ing,i.e.,preserve the association of domains with images. The association of domains and images allow to know the profile of the branch of theIIPF just by knowing the value that takes we to that branch (remember thatIIPFscreated with Def.4.2.3might not have a unique profile.) It is worth noting that this new structure is also a Boolean lattice which is isomorphic to the powersetP(X) for some set X. We note also, that the new carrier set has taken away the bottom elements of the two initial lattices, since the new lattice has a new unique bottom element 0

M.

The union of two IIPF lattices can be easily extended to do the union of several IIPF lattices, as long as the conditions stated in definition Def. 4.2.3 are met. In particular all the domains (resp. co-domains) must be pairwise disjoint, the other details are left as exercise to the reader.

4.3 Encoding Terms

Terms and term rewriting are widely used in model checking. Model checkers ma-nipulate billions of terms to describe the states and transitions of systems. We plan to leverage the efficient encoding that we have for n-ary relations to encode terms.

In Section 4.2, we have seen a framework that helps defining functions that are canonical and injective up to the partitioning of their domain. These functions char-acterized well the strong typing of operations in terms. Then we defined in Def.4.2.3 a union ofIIPFslattices to allow us to have a new set of functions that keep the strong typing while allowing us to have different profiles. Now, using theIIPFwe can define theΣDDs.

The line of reasoning for this sections is as follows. We first use the notion of Order-Sorted Algebra (OSA)to define a structure based onIPFsandIIPFs: theΣDDs.

OSAis defined in detail in Section3.2. Subsequently, we prove that the set of ΣDDs is a lattice. Then we proceed with terms as we did withIPFsandIIPFs, we first define an encoding and then prove that this encoding is unique.

The idea behindΣDDsis to encode set of terms. In the first place, we define them basing ourselves on the same signature that we used to define terms. We later explain the link between sets of terms andΣDDs. AΣDDis a pair composed by a sorts∈S ort and anIIPFthat we noteσ. We define it inductively in Def.4.3.1.

Definition 4.3.1 (ΣDD) LetΣ =hS,≤,Fibe a signature defined in Def.3.2.1and X be a set of variables. The set ofΣDDconsists of a family noted(ΣDDΣ,X s)s∈S overΣ and X. Each setΣDDs is defined as the limit ofΣDDns when n → ∞, whereΣDDns is defined by:

• ∀n∈N : ∀s∈S : – ΣDDns = S

s0≤s

Sn

i=0SIGDDis0, with – SIGDD0s = ∆F,s∪Xs

– SIGDDns =U

Fs

1,...,sn,s

∈F

∆(P(Fs1,...,sn,s),∆ΣDDn−1s

1 ,...,ΣDDn−1sn )

36 Chapter 4. ΣDecision Diagrams Remark 4.3.1 Similarly to terms, a ΣDD in which a variable occurs at most (resp.

more that) one time is said to be (resp. non) linear.

By using the Boolean signature example of Section3.2let us generate someΣDDs from the definition to understand it better. We suppose that the set of variables is empty. We present theΣDDsderiving from this signature up ton=1.

ΣDD0bool =SIGDD0bool = ∆F,bool∪Xbool =

bool {true}|{f alse}|{true,f alse} 1

, bool{true,f alse}0

To compress the representation we use the following notation: The edges’ labels con-tain the separator “|” like in {true}|{f alse}|{true, f alse}to denote that the arc can be labeled with one of those three elements. For the latter example that means that the first element represents three elements of the set. The last element of the set is the lower bound (encodes the empty relation). Forn=1 the set ofΣDDsis the following:

ΣDD1bool =

bool) is left as exercise to the reader (Hint: It contains 3 elements as the setΣDD0bool.) The set∆({and},∆ΣDD0bool,ΣDD0bool) contains 16 elements. We present 15 elements here (we omit the lower bound):

∆({and},∆ΣDD0

The set created by the union plus is too big to be represented here. The elements of that set are the elements of all previous sets and all the possible unions among them.

For the sake of the example, an element of∆F,bool∪XboolU∆({and},∆ΣDD0

bool,ΣDD0bool) can be seen in Fig.4.2.

To make the link betweenΣDDsand terms we need to develop a theory to encode set of terms. A naive approach is to use IIPFs directly to encode n-relations where the domain is the set of terms. However, this approach does not solve the problem of encoding sets of terms, since the domain of the IIPFs is the power set of terms itself. At this point we need an encoding that efficiently encodes sets of terms and

4.3. Encoding Terms 37 not n-ary relations. Let us suppose that such an encoding exists. Using this encoding its very easy to reuse our IIPFs framework to have an efficient encoding for n-ary relations of terms, we just encode the domain elements of theIIPFusing this encoding.

In Def.4.3.2we define an encoding for n-ary relations of terms where f is an encoding for sets of terms.

Definition 4.3.2 (Encoded relation of terms) Let L a lattice s.t. L P(TΣ,X), f : P(TΣ,X)→ L a lattice morphism,Ran n-ary relation of terms and h anIIPFencoding R. Theencoded relation using f for R (noted hf) is the IIPF hf : L → ∆L,...,L s.t.

Def.4.3.2is very general and puts all the load of the encoding on a function f that is not yet defined. In Def. 4.3.3 we define a specific encoding for sets of terms. It defines clearly what does it mean for a set of terms to be encoded by someΣDD. As terms are defined sively, the encoding is also defined recur-sively. The recursivity of the encoding is explicited by the functionhenc. The func-tion hencodes a n-ary relation of terms using the same encoding being defined. The base case is the case of constants and variables. To ease the understanding of the notion the definition is followed by an example showing the encoding (Example4.3.1).

Notation For ΣDD we also use the graphical notation that we introduced in Sec-tion4.2for theIIPFs. The name of the set on the nodes are however replaced by the name of the sort.

To draw ΣDDswe use the same DD-like graphical notation that we used in Sec-tion 4.2. In this case the nodes are labeled with the sort of the given ΣDD and the arcs are labeled either with a set of function symbols or with aΣDD. Example4.3.1 illustrates clearly the representation and the notation.

38 Chapter 4. ΣDecision Diagrams Example 4.3.1 Let a,b,c be constants of sort t, let also f : t×t → s be a function and s,t be two sorts such that : s ≤ t. Let us encode the following set of terms:

{a,b, f(a, f(a,b)), f(b, f(a,b)), f(c, f(a,b))}usingσaΣDD. Let us write the mapping forσ:

σ :{f} 7→δ1 δ11 7→δ2 δ22 7→ 1

:{a,b} 7→ 1 σ1 :{a,b,c} 7→ 1 σ2 :{f} 7→δ3 δ317→ δ4 δ43 7→ 1 σ3 :{b} 7→ 1

It is much easier to follow the representation in graphical notation in Fig.4.3. In the figure, it is also easier to see the sharing. We can see not only the recursive nature of the structure (some arcs are labeled by ΣDDs) but also the sub-sorting relation.

TheΣDDlabeling an arc of a given sort can be of any of its sub-sorts.

s {f} t t

t {a,b,c} 1

s t t 1

{a,b}

{f}

t {b}

Figure4.3 – Example of aΣDDsencoding five terms

Since we need to manipulate sets of terms that are encoded, it is of vital importance to define a union and intersection operation for ΣDDs. We define such an union and intersection in Def.4.3.4. The union and intersection are crafted to take into account the sub-sorting. Both operations are based on the union of theIIPFs. It is worth noting that the lower bound of the set {s: s≥ s2ands≥ s2}is guaranteed by the regularity of the signature [GM92].

Definition 4.3.4 (Union and intersection ofΣDDs) Letσ1 ∈ΣDDs1, σ2 ∈ΣDDs2 be twoΣDDsand s3the lower bound of the set{s: s≥ s2and s ≥ s2}

The unionσ1ΣDDσ2is defined by:

σ1ΣDDσ21σ2 ∈ΣDDs3

The intersectionσ1ΣDDσ2is defined by:

σ1ΣDDσ21σ2 ∈ΣDDs3

4.4. Operations 39

Dans le document Symbolic model-checking with Set Rewriting (Page 54-58)