GNUONJQNZG2MNEE55RW3XOQP3UICEBOKLVLKV42H3K64IBGLUGIQC 45HZPHVHYJ2BXATQ4MKCMPMMPZFBNJECY7JV3WX63BSA4CSQN6HAC TKJMPTB73W5TLLTNUOC4FGRQ7DHE5GRBTL7C5QBXRCNQPMJKGEQAC JCK77YLTPL6VV5ZOTMGUJSFZ5DNMS3MZGP5UQLXYW6WSMEK6GAQAC 567NUQ633R5ESTE2LWXVUGM7XEZGJ65IRKPOCDZJS3JE5RAMR5KAC RVA3DOCNBWFBWA2MLC2TVQOEY25AUCYGEJSWMD72QRQ26AFLVZUAC QIVGMR6INKBVT5IFCO2UJJQEO4PVW3ZM7IDTCTCOKOX7VKG7UPFAC DDNESFMD4LGNTDGTCW27FQPCOR5Y5MJWN2TWCSIRNBK6QGBITBRQC KVSF5AFJEIMIYAC264OUAA56SGP5MFAUG3AECKOTUPIXPGULVFQQC M3WK5HF3XU5MN2JKJMRJVDMC74F4MZAQ23FTGJRW4CGU5ZL72MHAC QCVDPRXH57UFLU4YV3P2I5RQZGCBUKROYUZHDWOCHL43KDYN7MPAC BGMT6NIKIDEGQ74DC4LPVBR7JCUYHHQBOZXHYXMO5F2UVEQ3N47QC 6PTHERE26NXSC3ZXSI5UYKWTMPYZD4WMYFBJKZE3MRRTKC7MIU6QC A5NVU6DZYOG6GRXJU6DZLCUQTKA7LPUWOGQ4NCJSY6FJB6GSP3OAC EIPHTX56WTRFBMBNA4VYMKK4L7GWHA4Q2AQ3BCG2ZGZB3DBRENBQC UVN5HOW3H2OVESJ62UFNQNS6VXHI5TRV22HQ44EOYU42453SDD2QC KUEZAMEH2M3K6EDHWMYXQMHZ2QTTH4KBM5CO7A7EB64ABEWRE6WQC B5T3HFKSQF3T4T6Z2KZOA5ZDMI6TVON7BS7KKB3EAGGYAS7RJPBAC R2A2OD7J5ATBRR7W4QPTZDVH6GGHQ7XBX2JE5R3GKVS5WIQ43O3AC QMVJ2ZKX5ALAMMIL7E47ZQS67QFZJ7Z3HAY5G7X72KPEQEHWRGCQC MQJMCLGFSBSFJ3JPCIHQSBZS4XZPGJI7NGGRASX5UVGJO6HES25AC }@InCollection{barwise1977,author = {Jon Barwise},booktitle = {HANDBOOK OF MATHEMATICAL LOGIC},publisher = {Elsevier},title = {An Introduction to First-Order Logic},year = {1977},editor = {Jon Barwise},pages = {5-46},series = {Studies in Logic and the Foundations of Mathematics},volume = {90},abstract = {Publisher SummaryThis chapter discusses the formulas that are certain finite strings of symbols. The “first” in the phrase “first-order logic” is to distinguish this form of logic from stronger logics, such as second-order or weak second-order logic, where certain extralogical notions (set or natural number) are taken as given in advance. The chapter provides information of what can and what cannot be expressed in first-order logic. Most of the examples are taken from the wealth of notions in modern algebra with which most mathematicians have at least a nodding acquaintance. The chapter also discusses many-sorted first-order logic, ω-logic, weak second-order logic, Infinitary logic, Logic with new quantifiers, and abstract model theory.},doi = {https://doi.org/10.1016/S0049-237X(08)71097-8},file = {:/home/paradyx/MA/literatur/introductiontofo.pdf:PDF},issn = {0049-237X},url = {https://www.sciencedirect.com/science/article/pii/S0049237X08710978},}@InProceedings{gurfinkel2010,author = {Arie Gurfinkel and Sagar Chaki},booktitle = {Static Analysis - 17th International Symposium, {SAS} 2010, Perpignan, France, September 14-16, 2010. Proceedings},title = {Boxes: {A} Symbolic Abstract Domain of Boxes},year = {2010},editor = {Radhia Cousot and Matthieu Martel},pages = {287--303},publisher = {Springer},series = {Lecture Notes in Computer Science},volume = {6337},bibsource = {dblp computer science bibliography, https://dblp.org},biburl = {https://dblp.org/rec/conf/sas/GurfinkelC10.bib},doi = {10.1007/978-3-642-15769-1\_18},groups = {Polyhedra, Octagons, Boxes},timestamp = {Mon, 03 Jan 2022 22:21:24 +0100},url = {https://doi.org/10.1007/978-3-642-15769-1\_18},
% TeX root = ../main.tex\begin{tikzpicture}[scale=0.5]\begin{axis}[axis lines = center,axis on top,xmin=-3.3,xmax=3.3,ymin=0,ymax=5.3,y=1cm,x=1cm,ytick={-0,...,5},xtick={-3,...,3},xlabel = x,ylabel = y,font=\tiny]\addplot [ name path = A, thick ] {x + 4};\addplot [ name path = B, thick ] {x + 1};\addplot [ name path = C, thick ] {-x + 4};\addplot [ name path = D, thick ] {-x + 1};\addplot[name path=top,draw=none] {5.3};\addplot[name path=bottom,draw=none] {0};\addplot[pattern=north west lines,pattern color=blue!30] fillbetween[of=A and top];\addplot[pattern=north west lines,pattern color=blue!30] fillbetween[of=C and top];\addplot[pattern=north west lines,pattern color=blue!30] fillbetween[of=B and bottom];\addplot[pattern=north west lines,pattern color=blue!30] fillbetween[of=D and bottom];\addplot[only marks,mark=o] coordinates {(0, 4)(-1, 3) (0, 3) (1, 3)(-1, 2) (0, 2) (1, 2)(0, 1)};\addplot[fill=red,fill opacity=0.20] fill between [of=B and bottom,softclip={domain=0:1.5}];\addplot[fill=red,fill opacity=0.20] fill between [of=D and bottom,softclip={domain=-1.5:0}];\end{axis}\end{tikzpicture}
% TeX root = ../main.tex\begin{tikzpicture}[scale=0.5]\begin{axis}[axis lines = center,axis on top,xmin=-3.3,xmax=3.3,ymin=-3.3,ymax=3.3,y=1cm,x=1cm,ytick={-3,...,3},xtick={-3,...,3},xlabel = x,ylabel = y,font=\tiny]\addplot [% domain=-3:3,name path = A,thick,% pattern=north east lines,] {0.5*x + 1};\addplot[name path=C,draw=none] {3.3};\addplot [% domain={-1.65:3},name path = B,thick,% pattern=north east lines,] {0.5*x*x-2};\addplot[name path=D,draw=none] {-3.3};\addplot[pattern=north west lines,pattern color=blue!30] fill between[of=A and C];\addplot[pattern=north east lines,pattern color=red!30] fill between[of=B and D];\addplot[only marks,mark=o] coordinates {(2, 2)(0, 1) (1, 1) (2, 1)(-1, 0) (0, 0) (1, 0)(-1, -1) (0, -1) (1, -1)};\end{axis}\end{tikzpicture}
% TeX root = ../main.tex\begin{tikzpicture}[scale=0.5]\begin{axis}[axis lines = center,axis on top,xmin=-3.3,xmax=3.3,ymin=-3.3,ymax=3.3,y=1cm,x=1cm,ytick={-3,...,3},xtick={-3,...,3},xlabel = x,ylabel = y,font=\tiny]\addplot [% domain={-1.65:3},name path = B,thick,% pattern=north east lines,] {0.5*x*x-2};\addplot[name path=D,draw=none] {-3.3};\addplot[pattern=north east lines,pattern color=red!30] fill between[of=B and D];\addplot[only marks,mark=o] coordinates {(-3, 3) (-2, 3) (-1, 3) (0, 3) (1, 3) (2, 3) (3, 3)(-2, 2) (-1, 2) (0, 2) (1, 2) (2, 2)(-2, 1) (-1, 1) (0, 1) (1, 1) (2, 1)(-2, 1) (-1, 1) (0, 1) (1, 1) (2, 1)(-1, 0) (0, 0) (1, 0)(-1, -1) (0, -1) (1, -1)};\end{axis}\end{tikzpicture}
% TeX root = ../main.tex\begin{tikzpicture}[scale=0.5]\begin{axis}[axis lines = center,axis on top,xmin=-3.3,xmax=3.3,ymin=-3.3,ymax=3.3,y=1cm,x=1cm,ytick={-3,...,3},xtick={-3,...,3},xlabel = x,ylabel = y,font=\tiny]\addplot [% domain=-3:3,name path = A,thick,% pattern=north east lines,] {0.5*x + 1};\addplot[name path=C,draw=none] {3.3};\addplot[pattern=north west lines,pattern color=blue!30] fill between[of=A and C];\addplot[only marks,mark=o] coordinates {(2, 2) (3, 2)(0, 1) (1, 1) (2, 1) (3, 1)(-2, -0) (-1, -0) (0, -0) (1, -0) (2, -0) (3, -0)(-3,-1) (-2, -1) (-1, -1) (0, -1) (1, -1) (2, -1) (3, -1)(-3,-2) (-2, -2) (-1, -2) (0, -2) (1, -2) (2, -2) (3, -2)(-3,-3) (-2, -3) (-1, -3) (0, -3) (1, -3) (2, -3) (3, -3)};\addplot[only marks,mark=o,red!80] coordinates { (0, -2) };\end{axis}\end{tikzpicture}
\ESns(\Cost(\Prog')) &= \sum_{i=1}^\infty i \cdot P(\Rt(\Prog)=i)= \sum_{i=1}^\infty P(\Cost(\Prog) \leq i)= \sum_{\substack{f \in \fpath_\Prog\\ \Rt(f) \leqi}}^\infty \prSs(f) \\% & \leq \sum_{\substack{f \in \fpath_{\Prog}\\ \Rt(f) \leq i}}^\infty% \prSns(f)% = \ESns(\Rt(\Prog'))
\subsection{Expected Size bounds}
\section{Abstraction}\label{sec:abstraction}In \Sref{sec:partialevaluation} the abstraction was represented by an oracle,that decides if the location is abstracted and an abstraction function. It wasstated that Algorithm \ref{alg:evaluate_abstr} terminates if\begin{enumerate}\item the oracle eventually always decides to abstract, and\item the abstraction has only a finite number of results.\end{enumerate}First, we will discuss some possibilities to select the locations forabstraction, and then adapt the properties based abstraction developed by\citeauthor{Domenech19}\cite{Domenech19} for probabilistic integer programs.
\subsection{Property based abstraction}\label{sec:propertybasedabstraction}
\begin{comment}pro: easy to implementcontra:- abstractions are expensive- abstractions loose precisionopen question:- how to select properties\end{comment}The naive approach would be to abstract at every location, as it also stated in\cite{Domenech19}. The advantage is that the implementation is easy. Theevaluated program is small and the analysis thereof fast. The disadvantage isthat a lot of evaluated control-flow is lost to the abstraction.The property based abstraction abstraction presented in\Sref{sec:propertybasedabstraction} requires $\Theta(n)$ calls to the\gls{smt}-solver which is computationally expensive.The primary goal of the presented \gls{cfr} via partial evaluation is toevaluate overlapping loops in order to find easier to analyse smaller loops.In practice, the control-flow of a loop is mostly linear. Abstracting the linearcontrol-flow could lead to two linear sections merging together which wouldotherwise-stay separated and thus make finding tight bounds harder in theprocess.\subsection{Abstract Loop heads}\label{ssec:loopheads}The second method proposed by \cite{Domenech19} is to abstract only on loopheads. Termination is guaranteed since every infinite path in the evaluationtree of a finite program must visit some loop (and in turn the head) an infinitenumber of times. With only finitely many possible abstraction results, it isguaranteed that at some point some version repeats and the evaluationbacktracks.The exact definition of a loop head is unclear. For sake of termination it issufficient that every loop contains at least one (but possibly arbitrary)location marked for abstraction. The intuitive candidate is the head of the loopsince that's the location where most branching will probably occur in practice.For this implementation a loop head is defined as follows.\begin{definition}A \textit{loop head} of a loop is the first location of the loop encounteredduring a depth-first search starting at the start location $l_0$.\end{definition}
When selecting all loop heads for abstraction, multiple loop heads can end up ona single loop, for when the loop is overlapping with another loop.\begin{figure}\input{figures/ch3_loopheads}\end{figure}(see examples \todo{} \todo{}). Detecting loops and loop-heads is furtherdiscussed in \Sref{sec:findingloops}.\todo{prove upper bound on program size}% Since% In addition control-flow refinement was introduced to unroll loops in such a way% that hidden branching is resolved. The heuristics presented by \cite{Domenech19}% are focused on loops and the properties are selected for the loop heads.% Constructing a heuristic, that is well suited for every location in the program% is not obvious is left open for future work.\subsection{Property based abstraction}\label{sec:propertybasedabstraction}\section{Sub-\gls{scc} level evaluation}
\subsection{Abstract everything}\begin{comment}pro: easy to implementcontra:- abstractions are expensive- abstractions loose precisionopen question:- how to select properties\end{comment}The naive solution would be to just abstract at every location, as it also statedin \cite{Domenech19}. The advantage is that the implementation is easy, and theresulting program and analysis thereof quick.The disadvantage is that a lot of evaluated control-flow is lost to theabstraction. Every abstraction requires $\Theta(n)$ calls to the SMT-solverwhich is computationally expensive.In addition control-flow refinement was introduced to unroll loops in such a waythat hidden branching is resolved. The heuristics presented by \cite{Domenech19}are focused on loops and the properties are selected for the loop heads.Constructing a heuristic, that is well suited for every location in the programis not obvious is left open for future work.\subsection{Abstract Loop heads}\label{ssec:loopheads}The second method proposed by \cite{Domenech19} is to abstract only on loopheads. Termination is guaranteed since every infinite path in the evaluationtree of a finite program must visit some loop (and in turn the head) an infinitenumber of times. With only finitely many abstraction candidates (versions), itis guaranteed that at some point some version repeats and the evaluationbacktracks.The exact definition of a loop head is unclear. For sake of termination it issufficient that every loop contains at least one (but possibly arbitrary)location marked for abstraction. The intuitive candidate is the head of the loopsince that's the location where most branching will probably occure in practice.For this implementation a loop head is defined as follows.\begin{definition}A \textit{loop head} are the entrance locations to a loop encountered duringa depth-first search starting at the start location $l_0$.\end{definition}A loop can have multiple loop heads, when it can be entered from differentlocations, or when overlapping with other loops (see examples \todo{} \todo{}).Detecting loops and loop-heads is further discussed in \Sref{sec:findingloops}.
Some general notation is introduced as follows. Let $\overline{\N} = \N\union \{\infty\}$. The set of all integer polynomials over some indeterminates$A$ is denoted by $\Z[A]$. A syntactical substitution where one symbol isreplaced by another is denoted with $[\cdot\backslash{}\cdot]$. For example$(x<y)[x\backslash{}1] = (1 < y)$.For a finite set $A = {x_1,\dots,x_n}$, the process of $n$ consecutivesubstitutions $[x_i\backslash{}y(i)]$ where the replacement expression $y$varies only in some index $i$ is denoted using a shortened notation:$[x_i\backslash{}y_i]_{x_i \in A} = [x_1\backslash{}y(1)] \dots[x_n\backslash{}y(n)]$. For example $[x_i\backslash{}i]_{x_i\in A} =
First, some basic notation is introduced. Let $\overline{\N} = \N \union\{\infty\}$. $A^*$ is the set of finite words and $\A^\omega$ is the set ofinfinite words over an alphabet $A$. The set of all integer polynomials oversome indeterminates $A$ is denoted by $\Z[A]$. A syntactical substitution whereone symbol is replaced by another is denoted with $[\cdot\backslash{}\cdot]$.For example $(x<y)[x\backslash{}1] = (1 < y)$. For a finite set $A ={x_1,\dots,x_n}$, the process of $n$ consecutive substitutions$[x_i\backslash{}y(i)]$ where the replacement expression $y$ varies only in someindex $i$ is denoted using a shortened notation: $[x_i\backslash{}y_i]_{x_i \inA} = [x_1\backslash{}y(1)] \dots [x_n\backslash{}y(n)]$. For example$[x_i\backslash{}i]_{x_i\in A} =
variable is replaced by its index in $A = \{x_0, \dots, x_n\}$.
variable is replaced by its index in $A = \{x_0, \dots, x_n\}$. The restrictionof a function $f: A \rightarrow B$ to a smaller domain $A' \subset A$ is denotedby $f|A' : A' \rightarrow B$.
Let $\Zs := (\Z, +, \cdot, 0, 1, \leq, <, =)$ be the structure standard integerarithmetic, and $\Rs := (\R, +, \cdot, 0, 1, \leq, <, =)$ the structure ofstandard real arithmetic. In the following $\V$ denotes a finite set ofvariables $\V$.
This section will define the foundations of various types of constraints thatare special cases of formulas of \gls{fo} logic. In the following$\V$ denotes a finite set of variables $\V$. The set of quantifier-free formulasof first-order logic over a variable set $A\subset\V$ is denoted with $\Phi_A$,or simply $\Phi$, when $A=\V$. For foundations on FO-logic we'll refer to theliterature \cite{barwise1977}.Using the $\models$ relation and $\equiv$ relation from \gls{fo} logic, thenotion of satisfiability is defined.\cite{barwise1977}\begin{definition}[Satisfiability\cite{barwise1977}]\label{def:satisfiability}For a domain $A$ and a structure $\mathfrak{A} = (A, +, \cdot, 0, 1, \leq,<, =)$ we say a variable assignment $\beta: \V \rightarrow A$\textit{satisfies} the formula $\phi \in \Phi$ when $\mathfrak{A}, \beta\models \psi$.$\phi $ is \textit{satisfiable} in when an assignment $\beta: \V \rightarrowA$ exists such that $\mathfrak{A},\beta\models \phi$. When $\phi$ issatisfiable for any assignments, one writes $\mathfrak{A} \models \phi$.\end{definition}\begin{definition}[Solutions\cite{Domenech19}]\label{def:solutions}Let $\varphi \in \Phi$ be an \gls{fo}-formula. $\llbracket \varphi\rrbracket$ is defined as the set of all satisfying assignments or the\textit{solutions} of the formula $\varphi$.\end{definition}
Strict and non-strict linear constraints are a subset of their polynomialcounterpart. For the most part we will just refer to \enquote{constraints}when the exact type of constraint is unimportant.
Strict and non-strict linear constraints are a subset of strict polynomialconstraints and non-strict polynomial constraints respectively. For the mostpart we will just refer to \enquote{constraints} when the distinctionbetween strict and non-strict or linear and polynomial constraints isunimportant.
Constraints are a subset of formulas in \gls{fo} logic.Thus, their semanticsshall be defined accordingly using the $\models$ relation from \gls{fo} logic.\begin{definition}[Satisfiability]\label{def:satisfiability}For a domain $A$ and a structure $\mathfrak{A} = (A, +, \cdot, 0, 1, \leq,<, =)$, a constraint $\psi \in \C$ is \textit{satisfiable} in when$\mathfrak{A} \models \psi$. We say a variable assignment $\beta: \V\rightarrow A$ \textit{satisfies} the constraint $\psi$ when $(\mathfrak{A},\beta) \models \psi$.\end{definition}
A set of constraints $C \subseteq \Lin$ is satisfiable, when their conjunctionis satisfiable and we write $\mathfrak{A} \models C$ instead of $\mathfrak{A}\models \LAnd_{\psi_i \in C} \psi_i$. In addition whenever the structure isevident from context, we write $\models \psi$ and $\beta \models \psi$ insteadof $\mathfrak{A} \models \psi$ and $(\mathfrak{A}, \beta) \models \psi$respectively.
Constraints are a subset of formulas in \gls{fo} logic, thus, their semanticsshall be defined accordingly.
\begin{definition}[Solutions]\label{def:solutions}Let $\varphi$ be an \gls{fo}-formula. $\llbracket \varphi \rrbracket$ isdefined as the set of all satisfying assignments or the \textit{solutions}of the formula $\varphi$.\end{definition}
A set of constraints $C \subseteq \C$ is satisfiable, when their conjunction issatisfiable and we write $\mathfrak{A}, \beta \models C$ instead of$\mathfrak{A} , \beta \models \LAnd_{\psi_i \in C} \psi_i$. In addition thisthesis will only consider integer arithmetic. Let $\Zs := (\Z, +, \cdot, 0, 1,\leq, <, =)$ be the structure standard integer arithmetic. We write $\models\psi$ and $\beta \models \psi$ instead of $\mathfrak{Z} \models \psi$ and$\mathfrak{Z}, \beta \models \psi$ respectively.
\begin{definition}[Entailment]Let $\varphi_1, \varphi_2$ be FO-formulas with variables $\V$. If$\llbracket \varphi_1 \rrbracket \subseteq \llbracket \varphi_2 \rrbracket$and we say that $\varphi_1$ \textit{entails} $\varphi_2$.
\begin{definition}[Entailment\cite{Domenech19}]Let $\varphi_1, \varphi_2 \in \Phi$. If $\llbracket \varphi_1 \rrbracket\subseteq \llbracket \varphi_2 \rrbracket$ and we say that $\varphi_1$\textit{entails} $\varphi_2$.
variables that are only relevant to the scope of a transition. In FO-logic onewould just existentially quantify the variable. However the new FO-formulawouldn't be quantifier-free anymore. Instead a new formula is searched that hasjust the same solutions when ignoring the values for the irrelevant variables.
variables that are only relevant to the scope of a transition. In \gls{fo} logicone would just existentially quantify the variable. However the new \gls{fo}formula wouldn't be quantifier-free anymore. Instead a new formula is searchedthat has just the same solutions when ignoring the values for the irrelevantvariables.
Let $X \subseteq V$ and $\varphi$ be a quantifier-free FO-formula over thevariables $V$ and let $\beta|_X$ denote the restriction of the assignment$\beta$ to the smaller to domain $X$.The projection of $\varphi$ onto $X$ denoted as $\text{proj}_X(\varphi)$ isa quantifier-free FO-formula $\varphi'$ over the variables $X$, with$\llbracket \varphi' \rrbracket = \set{\beta|_X}{\sigma \in \llbracket\varphi \rrbracket}$.
Let $A \subseteq V$ and $\varphi \in \Phi$. The projection of $\varphi$ onto$A$ denoted as $\varphi|_A$ is a quantifier-free FO-formula $\varphi|_A\in\Phi_A$, with $\llbracket \varphi|_A \rrbracket = \set{\beta|_X}{\beta \in\llbracket \varphi \rrbracket}$.
whereas for updates there exists a \textit{before} and an \textit{after}.In this section we will only consider integer arithmetic, although using realarithmetic works analogously.
whereas for updates there exists a \textit{before} and an \textit{after}.
constraint partitions the space into one included and one excluded part. In caseof integer arithmetic the solutions are discrete points in this space.
constraint partitions the space. One part is included and the other is excluded.In case of integer arithmetic the solutions are discrete points in this space.
An abstract domains is a representation of those sets of points. Usually theyover-approximate the sets in order to facilitate operations. Commonly usedabstract domains are Polyhedra\cite{bagnara2005convexpolyhedron}
An abstract domain is a representation of those sets of points. Usually a valueover-approximates the set of points in order to facilitate operations. Commonlyused abstract domains are Polyhedra\cite{bagnara2005convexpolyhedron}
clearly equal to the intersection of both sets of solutions. While$\varphi_1$ and $\varphi_2$ have infinitely many solutions, the conjunction$\varphi_3$ has not.
equal to the intersection of both sets of solutions. While $\varphi_1$ and$\varphi_2$ have infinitely many solutions, the conjunction $\varphi_3$ hasnot.
The orthogonal projection computes the projection of an FO-formula, possiblyloosing some precision in the process. Geometrically, the projection can be seenas set of solutions projected (casting a shadow) onto the remaining dimensions.
The orthogonal projection computes the projection of an \gls{fo} formula.Geometrically, the projection can be seen as set of solutions projected (castinga shadow) onto the remaining dimensions.
talking about integer arithmetic one refers only to polyhedra.
talking about integer arithmetic one refers only to polyhedra.Polyhedra can exactly only represent linear constraints. Non-linear polynomialconstraints are usually just removed, possibly leaving dimensions unbounded inthe process. There are certainly better linear over-approximations to polynomialconstraints, but finding these would go beyond the scope of this thesis.
\todo{more about tightness of operations}\todo{say something aboutoverapproximation of polynomial constraints}
Polyhedra will be used for the partial evaluation algorithm described in chapter\ref{ch:theory}, since in practice the partial evaluation is called only onsmall sub-programs and precision is more desirable than performance.
polyhedron $P$ one can find a box $P'$ that contains the polyhedron$P$.\todo{citation or proof}Whenever it's acceptable to arbitrarily widen thepolyhedron, one can work with boxes instead. Boxes are computationally veryefficient, although rather imprecise, for most applications.
polyhedron $P$ one can find a box $P'$ that contains the polyhedron $P$. Boxesare computationally very efficient, although rather imprecise for mostapplications.
definitions from \cite{billingsley2011}. For additional information wewill refer to the literature.\cite{kraaikamp2005modern, billingsley2011}
definitions from \citeauthor{billingsley2011}\cite{billingsley2011}. Foradditional information we'll refer to theliterature.\cite{kraaikamp2005modern, billingsley2011}
Imagine probabilistic event with some possible outcomes $\Omega$. For example acoin-toss can have arbitrary many outcomes when taking the position on the tableinto account, the fact that the coin might get lost in the process etc.A probability measure describes the probabilities of sets of random outcomes.For example the coin-toss on the table has a sub-set of outcomes where thecoin's head is above. The probability measure would assign a probability closeto 50\% for a somewhat normal coin-toss.
Imagine a probabilistic event with some possible outcomes $\Omega$. For examplea coin-toss can have arbitrary many outcomes when taking the position on thetable into account, the fact that the coin might get lost in the process etc. Aprobability measure describes the probabilities of sets of random outcomes. Forexample the coin-toss on the table has a sub-set of outcomes where the coin'shead is above. The probability measure would assign a probability close to 50\%for a somewhat normal coin-toss.
\begin{definition}[Probability Measure]\label{def:measure}A set function $\mu$ on a $\sigma$-field $\F$ is a probability
\begin{definition}[$\sigma$-Algebra\cite{billingsley2011}]Let $\Omega$ be an arbitrary set. A set $A \subset 2^\Omega$ is called a$\sigma$-algebra (also known as $\sigma$-field) when\begin{enumerate}\item $\Omega \in A$,\item $A$ is closed under complement, i.e. $B \in A$ implies $B^C \inA$,\item $A$ is closed under countable unions, i.e. $A_1, A_2 \dots, \in A$implies $\Union_{n\in\N}A_n \in A$.\end{enumerate}\end{definition}\begin{definition}[Probability Measure\cite{billingsley2011}]\label{def:measure}A set function $\mu$ on a $\sigma$-algebra $\F$ is a probability
\begin{definition}[Probability space]\label{def:probability_space}A probability space is a triple $(\Omega,\F,P)$. Where the
\begin{definition}[Probability space\cite{billingsley2011}]\label{def:probability_space}A probability space is a triple $(\Omega,\F,P)$ where the
\item $\F$ is the set of events that contains $\Omega$, isclosed under complement, intersection and countable unions. Such aset is also called $\sigma$-field or $\sigma$-algebra.\begin{enumerate}\item $\Omega \in \F$\item For $A\subseteq\Omega$, if $A\in\F$ then so isits complement $A^c\in\F$.\item For $A,B \subseteq \Omega$, if $A, B \in \F$,then so is $A \cup B \in \F$.\item For $ A_1, A_2, \dots,A_n \subseteq \Omega$, if $A_i \in\F$, then so is their union $\Union\limits_{i=1}^nA_i \in \F$.\end{enumerate}
\item $\F$ is a $\sigma$-algebra containing $\Omega$.
variables in formulas. Colloquially, a random variable maps the results of aprobabilistic event $\omega$ to a real value, or, the value of the random
variables in formulas. Informally, a random variable maps the results of aprobabilistic event $\omega$ to a real value, or the value of the random
underlying probability space. In case of discrete random variables the aresufficient to fully describe them. The underlying probability space becomesirrelevant at this point, as the specific events and their probabilities are notimportant to the outcome of the random variable, as long as the probability ofthe outcome is fully defined.
underlying probability space. In case of discrete random variables thedistribution is sufficient the random variable. The underlying probability spacebecomes irrelevant at this point, as the specific events and their probabilitiesare not important to the outcome of the random variable, as long as theprobability of the outcome is fully defined.
\begin{definition}[Distribution of a random variable]\label{def:distribution}Let $X$ be a discrete random variable. The distribution is describe by the
\begin{definition}[Distribution of a random variable\cite{billingsley2011}]\label{def:distribution}Let $X$ be a discrete random variable. The distribution is described by the
\begin{definition}[Support]For a random variable with a distribution $\mu$, the support is smallestBorel-set $S$ for which $\mu(S) = 1$. \todo{why borel set?} Discrete randomvariables have a countable support $S = \{S_1, S_2, \dots\}$.
\begin{definition}[Support\cite{billingsley2011}]For a random variable with a distribution $\mu$, the support is smallest set$S$ for which $\mu(S) = 1$. Discrete random variables have a countablesupport $S = \{S_1, S_2, \dots\}$.
The Bernoulli distribution is a distribution with two possible outcomes: $1$ and $0$. Forexample decided by a coin-flip.
The Bernoulli distribution is a distribution with two possible outcomes: $1$ and$0$, for example decided by a coin-flip.
The binomial distribution similar to the geometric distribution except that thenumber of successes of repeated independent Bernoulli events is counted.Or (\enquote{with putting back}).
The binomial distribution is similar to the geometric distribution except thatthe number of successes of repeated independent Bernoulli events is counted.
When considering a random variable one is usually interested the value to expectin general. For example most possible outcomes of a binomial distribution arevery improbable. This is described by the expected value.\begin{definition}[Expected Value\cite{billingsley2011}]The expected value of a random variable $X$ on a probability space $(\Omega,\F, P)$ is the integral of X with respect to the measure $P$:\begin{equation*}\E(X) = \int X dP = \int_\Omega X(\omega) P(d\omega)\end{equation*}This gets simplified for discrete random variables where every the integral canbe replaced by a sum. (see Lemma 48 in \cite{meyer20arxiv})\begin{equation*}\E(X) = \sum_{r \in \bar{\R}_{\geq0}} r \cdot P(X = r)\end{equation*}\end{definition}
$\Z[\V\union D]$, is the set of integer polynomials containing variables $\V$ ordistributions. They behave exactly like normal polynomials except that thevalues of the distributions are sampled probabilistically instead of being givenas argument. As such we can define a function $[\cdot]: \Z[\V\union D]\rightarrow \Sigma \rightarrow \Z \rightarrow [0,1]$ that returns theprobability that the polynomial $f \in \Z[\V \union D]$ with a state $s \in\Sigma$ evaluates to a value $k\in\Z$ with a probability $[f](s)(k)$.
$\Z[\V\union \D]$, is the set of integer polynomials containing variables $\V$or probability distributions $\D$. They behave exactly like normal polynomialsexcept that the values of the distributions are sampled probabilisticallyinstead of being given as argument. As such we can define a function $[\cdot]:\Z[\V\union \D] \rightarrow \Sigma \rightarrow \Z \rightarrow [0,1]$ that returnsthe probability that the polynomial $f \in \Z[\V \union D]$ with a state $s \in\Sigma$ evaluates to a value $k\in\Z$ with a probability $[f](s)(k)$.
some updates. An update assigns a new value to a program variable depending onthe previous state. Ever inter program starts at a unique location usuallycalled $l_0$. Whenever no transition guard is satisfied the program terminates.
some \textit{update}. An update assigns a new value to a program variabledepending on the previous state. Every integer program starts at a uniquelocation usually called $l_0$. Whenever no transition guard is satisfied theprogram terminates.
Probabilistic sampling is done using probability distributions. Coincidentally,only the probability distributions from \Sref{ssec:distributions} are supported.Updates are restricted to integer polynomials with variables and additionallydistributions when probabilistic sampling is allowed. The value of theindeterminate in the polynomial is equal to the (possibly temporary) variable orsampled from the distribution with the corresponding probability.
Probabilistic sampling is done using probability distributions (recall\Sref{distributions}. Updates are restricted to integer polynomials withvariables and additionally distributions when probabilistic sampling is allowed.The value of the indeterminate in the polynomial is equal to the (possiblytemporary) variable or sampled from the distribution with the correspondingprobability.
\cite{meyer2021tacas}. First the formal definition for a probabilistic programis given, then the semantics are introduced.
\cite{meyer2021tacas}. First the formal definition for a \acrfull{pip} is given,then after a small excursion to markov decision processes, the semantics are aredefined.
\item a source and target location $l,l' \in \Loc$.\item a probability $p \geq 0$, that the transition is takenwhen the corresponding general transition $g$ is executed.\item a guard $\tau \in C$
\item a source and target location $l,l' \in \Loc$,\item a probability $p \geq 0$ that the transition is takenwhen the corresponding general transition $g$ is executed,\item a guard $\tau \in C$,
We call $τ_g$ the guard of the general transition $g$; and alltransitions share a common start location which we call $l_g$.
We call $τ_g$ the guard of the general transition $g$ and alltransitions share a common start location which we call $l_g$.
the same purpose. Instead of just vaguely \enquote{terminating} a program takesthe transition $g_\bot$ to the location $l_\bot$ if and only if no othertransition is walkable. Since no normal transition leaves the location $l_\bot$the run loops indefinitely on the location $l_\bot$ after termination. Inaddition a new transition $t_\text{in}$ will be used for the start of theprogram.
the same purpose. Instead of just \enquote{terminating} a program takes thetransition $g_\bot$ to the location $l_\bot$ if and only if no other generaltransitions guard is satisfied. Since no normal transition leaves the location$l_\bot$ the run loops indefinitely on the location $l_\bot$. In addition a newtransition $t_\text{in}$ is added for the start of the program.
\rightarrow \Z$. $\Sigma$ is the set of all states. The set of configuration isdefined as $\confs = L \union \{l_\bot\} \times \T \union \{t_{\text{in}},
\rightarrow \Z$. $\Sigma$ is the set of all states. The set of configurations isdefined as $\confs_\Prog = \Loc_\Prog \union \{l_\bot\} \times \T_\Prog \union \{t_{\text{in}},
\item \textit{states}, the decision process is in at a decision epoch;\item \textit{actions}, that are selected by the decision process;\item \textit{transition probabilities}, that describe the probabilities of
\item \textit{states} the decision process is in at a decision epoch;\item \textit{actions} that are selected by the decision process;\item \textit{transition probabilities} that describe the probabilities of
the program, are the states of the decision process. Non-deterministic sampling,non-deterministic branching are similar to choosing an action, and the
the program are the states of the decision process. Non-deterministic samplingand non-deterministic branching are similar to choosing an action, and the
The reward is usually the optimization goal, of the Markov decision process, andthe literature describes the properties of a given process with regard to thehighest achievable rewards. That is, one looks for a decision policy thatreturns the highest accumulated rewards over a whole process.
The highest reward is the optimization goal, when taking decision in a Markovdecision process. One looks for a decision policy that returns the highestaccumulated rewards over a whole process. In literature\cite{puterman1994markov,puterman1990markov}, the properties of a given process with regard to thehighest achievable rewards is researched extensively.
complexity and runtime costs. If define runtime (or costs) as reward, we canpicture the Markov decision process as an adversary, finding the decision policywith the longest runtime.
complexity. If one defines runtime as reward, one can picture the policy for aMarkov decision process as an adversary. We call the policy \enquote{scheduler}.
\item the states are the configurations $\confs$ of the program\item the actions are the selection of a general transition and fullassignments that satisfy a guard of of the selected general transition,or the terminating transition.
\item The states are the configurations $\confs_\Prog$ of the program.\item The actions are the selection of a general transition and fullassignments that satisfy a guard of the selected general transition orthe terminating transition.
In general, at every decision epoch one can use a different decision rules,described by a policy. However, we will only consider stationary) policies,where the policy uses the same decision rule at every decision epoch.
In general, at every decision epoch one can use a different decision rule,described by a policy. However, we will only consider so-called stationarypolicies, where the policy uses the same decision rule at every decisionepoch.
A function $\scheduler : \fpath \rightarrow (\GT \uplus \{g_\bot\})$ is ahistory dependent scheduler if for every finite prefix $f\in\fpath$ andconfiguration $c=(l,t,s) \in\confs$, $\scheduler(fc) = (g, s')$ implies: items \ref{itm:md1} to\ref{itm:md4} of Definition \ref{def:mscheduler}.
A function $\scheduler : \fpath_\Prog \rightarrow (\GT_\Prog \uplus\{g_\bot\})$ is a history dependent scheduler if for every finite prefix$f\in\fpath$ and configuration $c=(l,t,s) \in \confs_\Prog$, $\scheduler(fc)= (g, s')$ implies: items \ref{itm:md1} to \ref{itm:md4} of Definition\ref{def:mscheduler} for the last configuration $c$.The set of all history dependent schedulers for a program $\Prog$ is denotedby $\HDS^\Prog$, where \enquote{HD} stands for \enquote{history dependentdeterministic}.
Let $\scheduler$ be a scheduler and $s_0$ be an initial state. First, theprobability for a program to start at a configuration $c$ is 1 only for theconfiguration that has the initial state $s_0$ at the start location $l_0$coming from the initial transition $t_\text{in}$. All other configuration areinvalid starting configurations and get assigned a zero probability by theprobability measure $\prSs : \confs \rightarrow [0,1]$
Let $\scheduler \in \MDS^\Prog$ be a scheduler and $s_0$ be an initial state.First, the probability for a program to start at a configuration $c$ is 1 onlyfor the configuration that has the initial state $s_0$ at the start location$l_0$ coming from the initial transition $t_\text{in}$. All other configurationare invalid starting configurations and get assigned a zero probability by theprobability measure $\prSs : \confs_\Prog \rightarrow [0,1]$
Because by definition only the terminating transition $t_\bot$ is admissiblewhen the program is in the terminal location $l_\bot$ and the followingconfiguration must again be in the terminal location $l_\bot$. A terminating runmust end with infinitely many repetitions of a terminating configuration$c_\bot=(l_\bot,t_\bot,s)$ for some assignment $s\in\Sigma$.
By definition only the terminating transition $t_\bot$ is admissible when theprogram is in the terminal location $l_\bot$ and the following configurationmust again be in the terminal location $l_\bot$. A terminating run must end withinfinitely many repetitions of a terminating configuration$c_\bot=(l_\bot,t_\bot,s)$ with some assignment $s\in\Sigma$.
The runtime complexity is a special case of the cost of a run, where everytransition has an associated cost of $\kappa_t=1$ for all $t \in \T$. Then
\begin{example}Consider the program from example \ref{ex:prob_sampling} displayed in\fref{fig:ex_pip_probs}. It must take at least transitions $t_1$ and $t_3$hence any runtime less than $2$ is impossible. The variable $x$ isdecremented by $1$ with a probability of $0.5$ on every transition $t_2$. Sofor a given starting state $s_0$ and $scheduler \in \MDS$, the expectedruntime depends on the initial variable $x$. The probability for decrementing$x$ once follows a geometric distribution. The runtime for decrementing $x$until zero ($x$ times) is\begin{equation*}\ESs(\Rt(\Prog)) = s_0(x) \cdot \frac{1}{p} = s_0(x) \cdot \frac{1}{0.5} = 2s_0(x).\end{equation*}The expected runtime doesn't depend on the scheduler and is finite for allvalues of $x$, hence the program is \gls{past}.\end{example}
\begin{definition}[Runtime complexity bounds]For $s_0\in\Sigma$ and a \gls{pip} $\Prog$, $\RB^1 \in \B$ is a runtime
\begin{definition}[Expected runtime complexity bounds]For $s_0\in\Sigma$ and a \gls{pip} $\Prog$, $\RB \in \B$ is a expected runtime
Analogously, $\RB \in \B$ is a cost bound for $s_0$ if\begin{equation}\RB \geq \sup \Cost(\Prog) = \sup \ESs(\Rt(\Prog))\end{equation}
% Analogously, $\RB \in \B$ is a cost bound for $s_0$ if% \begin{equation}% \RB \geq \sup \Cost(\Prog) = \sup \ESs(\Rt(\Prog))% \end{equation}
The tests are chosen to represent a large variety of commonly encounteredreal-world programs, but also include known-to-be hard-to-solve problems inorder to challenge the competitors and improve their tools. Their collection oftest programs can be found in the \gls{tpdb} which is publiclyavailable\footnote{\url{https://github.com/TermCOMP/TPDB}}. During the latestscompetition in 2022, eleven candidates lined up in twenty-eightcategories\cite{termcomp2022url}.
% The tests are chosen to represent a large variety of commonly encountered% real-world programs, but also include known-to-be hard-to-solve problems in% order to challenge the competitors and improve their tools. Their collection of% test programs can be found in the \gls{tpdb} which is publicly% available\footnote{\url{https://github.com/TermCOMP/TPDB}}. During the latests% competition in 2022, eleven candidates lined up in twenty-eight% categories\cite{termcomp2022url}.
\subsection{\acrshort{aprove}, \acrshort{koat}, and \acrshort{loat}}The \gls{aprove} is developed by \citeauthor{giesl2014ijcar} at RWTHUniversity\cite{giesl2014ijcar}. \Gls{aprove} is capable of analyzing real-worldprogramming languages like Java, C, Haskell, Prolog by transforming the givenprogram into an equivalent \gls{trs} and then analyzing the resulting \gls{trs}with various different techniques and tools. Explaining every technique used in\gls{aprove} would go beyond the scope of this thesis. It should only bementioned that during analysis parts of the \gls{trs} can be transformed furtherinto \gls{its} which opens the possibility for many more analysis techniquestypically not available for \gls{trs}.
\section{Motivation}\begin{figure}\centering\begin{subcaptionblock}[t]{0.4\textwidth}\centering\input{figures/ch1_classic}\caption{Classic integer program $\Prog_1$\label{fig:classic}}\end{subcaptionblock}\begin{subcaptionblock}[t]{0.5\textwidth}\centering\input{figures/ch1_classic_pe}\caption{(UNFINISHED) Partial evaluation of$\Prog_1$\label{fig:classic_pe}}\end{subcaptionblock}\caption{Program with hard to find runtime-complexity bounds using only\gls{mprf}.\cite{giesl2022arxiv}}\end{figure}
The tools LoAT\cite{frohn2022ijcar} and KoAT\cite{brockschmidt2016acm} are alsodeveloped at RWTH University and aim at the finding lower and respectively upperruntime-complexity and size bounds on transition systems. At its core,KoAT computes bounds for subprograms using \gls{mprf} or \gls{twn}, and thenputting the subprograms together generate upper runtime-complexity and sizebounds for the whole program.Optionally to improve the analysis, Koat can resort to partial evaluationas a control-flow refinement techniques\cite{giesl2022lncs}.At first \gls{koat} was aimed at linear integer programs, but it was recentlyextended to probabilistic integer programs\cite{meyer2021tacas} andnon-linear arithmetic\todo{citation needed}.
Consider the program $\Prog_1$ displayed in \fref{fig:classic}. It contains twoprogram variables $x, y$ and two temporary variables $u,w$ where $u$ is used tonon-deterministically sample $x$ in the first transition $t_0$ and $w$ is usedto branch non-deterministically between $t_1$ and $t_2$. The program clearlyterminates, since both loops $t_1$ and $t_2,t_3$ decrement either $x$ or $y$ inevery iteration. However, the classical analysis using only \gls{mprf} fails tofind a finite runtime-complexity bounds for this program.\cite{giesl2022arxiv}.With the help of \gls{cfr} on sub-\gls{scc} level, the program (see\fref{fig:classic_pe}) can be transformed into an equivalent program where theanalysis with \gls{mprf} succeeds at finding a finite runtime-complexity bound.This technique used for the transformation was first introduced by\citeauthor{domenech2019arxiv}\cite{domenech2019arxiv} and is called \gls{cfr}via partial evaluation and implemented in their analysis tooliRankfinder\cite{irankfinder2018wst}. It achieves very similar results to\gls{mprf} when used on the entire programs or whole \gls{scc}. Its realstrength comes from applying it to a sub-\gls{scc} level and refiningspecifically the loops where \gls{mprf} fail to find size bounds. This techniquewas presented by \citeauthor{giesl2022arxiv}\cite{giesl2022lncs,giesl2022arxiv}and implemented in \gls{koat}\cite{giesl2014ijcar} the complexity analysis tooldeveloped by \citeauthor{giesl2014ijcar} at RWTH University.
Underneath, \gls{koat} uses iRankFinder for the \gls{cfr}.Recently, \gls{koat} was extended to probabilistic integerprograms\cite{meyer2021tacas,meyer20arxiv}. Unfortunately, by using iRankfinderwhich is limited to non-probabilistic integer programs, the technique of\gls{cfr} via partial evaluation remained out of reach for probabilisticprograms.\begin{figure}\centering\begin{subcaptionblock}[t]{0.4\textwidth}\centering\input{figures/ch1_prob}\caption{Probabilistic integer program $\Prog_2$\label{fig:prob}}\end{subcaptionblock}\begin{subcaptionblock}[t]{0.5\textwidth}\centering\input{figures/ch1_prob_pe}\caption{Partial evaluation of $\Prog_2$\label{fig:prob_pe}}\end{subcaptionblock}\end{figure}Consider the very similar probabilistic integer program $\Prog_2$ displayed in\fref{fig:prob}. The variables $x$ and $y$ are now only decremented with 50\%probability in every iteration. The program will probably always terminate,since a longer runtime gets increasingly unlikely. The current version of\gls{koat} fails to find finite runtime an expected complexity bounds for thisprogram. It would be nice to transform $\Prog_2$ into an equivalent program likethe one shown in \fref{fig:prob_pe} similarly to the \gls{cfr} techniquepresented by \citeauthor{giesl2022lncs}\cite{giesl2022lncs} and\citeauthor{Domenech19}\cite{Domenech19}.\section{Related works}\subsection{\acrshort{aprove}, \acrshort{koat}, and \acrshort{loat}} The toolsLoAT\cite{frohn2022ijcar} and KoAT\cite{brockschmidt2016acm} are developed atRWTH University and aim at the finding lower and respectively upperruntime-complexity and size bounds on transition systems. At its core, KoATcomputes bounds for subprograms using \gls{mprf} or \gls{twn}, and then puttingthe subprograms together generate upper runtime-complexity and size bounds forthe whole program. Optionally to improve the analysis, Koat can resort topartial evaluation as a control-flow refinement techniqueson a sub-\gls{scc} level\cite{giesl2022lncs}.