其他分享
首页 > 其他分享> > NJU Static Program Analysis 06: Data Flow Analysis IV

NJU Static Program Analysis 06: Data Flow Analysis IV

作者:互联网

NJU Static Program Analysis 06: Data Flow Analysis IV

Abstract

Notes

Following the previous lecture, we continue to answer the question:

For the first question, we have already described that it is related to the monotonicity of function \(F\). While for the second question, after the introduction of fixed point theorem, we arrive at the conclusion that the iterative algorithm will finally arrive at a best fixed point on the lattice, if \(F\) is monotonic.

Thus we continue to prove the monotonicity of \(F\), which consists of:

To prove this, we only need to prove the monotonicity of \(\sqcup\) and \(\sqcap\). Here given is the proof of \(\sqcup\), that of \(\sqcap\) is obviously similar.


\(P.f.\)

\(\forall~x, y, z \in L, x \sqsubseteq y,\) by the definition of \(\sqcup\) we have:

\[y \sqsubseteq y \sqcup z \]

and by the transitivity of \(\sqsubseteq\) we have:

\[x \sqsubseteq y \sqcup z \]

thus \(y \sqcup z\) is an upper bound for \(x\) and \(z\),

as \(x \sqcup z\) is the least upper bound of \(x\) and \(z\).

thus \(x \sqcup z \sqsubseteq y \sqcup z\), which means \(\sqcup\) is monotonic.


Additionally, there is one more general question:

So far, we can illustrate a conclusion for all the previous points:

In this context, another question emerges that how can we measure the precision of our algorithm? To answer this, we again need to introduce a new concepts:


\(P.f.\)

By the definition of lub \(\sqcup\), we have:

\[x,y \sqsubseteq x \sqcup y \]

As the transfer function \(F\) is monotonic, we have:

\[F(x),F(y) \sqsubseteq F(x \sqcup y) \]

Then \(F(x \sqcup y)\) will be an upper bound of \(F(x)\) and \(F(y)\), so that

\[F(x) \sqcup F(y) \sqsubseteq F(x \sqcup y) \]


From the proof we can see that when \(F\) is distributive, the iterative algorithm will be as precise as MOP. We have a classic analysis whose \(F\) is not distributive: the constant propagation analysis.

Based on these contents, we shall be able to design a constant propagation analysis algorithm, and that will be the Lab 01 for our curriculum.

So far we have learned a lot about the iterative algorithm, then we start to consider a optimization for it -- the Worklist Algorithm:

image-20210718001128839

Once upon the time, Mr. jpggg said that:

那个迭代算法不就是个 Bellman-Ford 吗,那个 Worklist Algorithm 也就是个 SPFA!

Definitely true and inspiring his words are that it can be a key for our comprehension.

标签:06,sqcap,algorithm,Flow,Analysis,will,lattice,sqcup,rm
来源: https://www.cnblogs.com/Shimarin/p/15025624.html