diff --git "a/data_all_eng_slimpj/shuffled/split2/finalzzlrpo" "b/data_all_eng_slimpj/shuffled/split2/finalzzlrpo" new file mode 100644--- /dev/null +++ "b/data_all_eng_slimpj/shuffled/split2/finalzzlrpo" @@ -0,0 +1,5 @@ +{"text":"\\section{Introduction}\n\nSome people believe that Twitter and Blogs are enthusiastically posted, but most people are supposed to search on the Internet. Therefore, analysis of the search behavior of people of society is very important in grasping social movements. In this research, we analyze theoretically by the idea of social physics, how television information, net information, or Blog, Twitter etc. influences people's search behavior.\n\n\nThe subjects of the analysis are seasonally limited dates, and many people participate in the event. Specifically, Valentine's Day, Halloween, Christmas, and New Year's Countdown. In addition, in the habit peculiar to Japan, we also analyzed Eho-maki, which eats scroll sushi on February 3, and an event to eat eel on the Midsummer Occasion Day of Summer (the day of ox in midsummer). In particular, Specifically, Valentine's Day, Halloween, Christmas, and New Year's Countdown last for only one day and thus, it is easier to analyze the rising excitement and subsequent wane in interest. In many European countries, people return to their homelands for Christmas and enjoy a long Christmas break. In constast, in Japan, however, Christmas is a one-day event in which young people have Christmas parties with friends but do not return home. In Japan, therefore, it is not until the New Year's vacation of the following week that people return to their hometowns. Thus, in Japan, Christmas is very similar to Halloween.\n\n\nIn Japan, Feb.3 is the traditional day to eat \"Eho-maki\". Eho-maki are thick sushi rolls \nshown in fig.\\ref{eho-maki} which is believed to bring good fortune if eaten while facing the year's \"Eho\" (good luck direction of the year) like fig.\\ref{eho-maki2}. Not all, but many Japanese people have Eho-maki at this day.\n\n\\begin{figure}[h]\n\\begin{center}\n\\includegraphics[width=6cm]{eho-maki.eps}\n\\caption{Eho-maki in Japan.}\n\\label{eho-maki}\n\\end{center}\n\\end{figure}\n\n\n\\begin{figure}[h]\n\\begin{center}\n\\includegraphics[width=6cm]{eho-maki2.eps}\n\\caption{How to eat eho-maki in Japan.}\n\\label{eho-maki2}\n\\end{center}\n\\end{figure}\n\n\n\nOn the day of the ox in midsummer Japanese have a custom to eat eel which started in the Edo period, 18th century. Eel is a popular food for Japanese people, and it is expensive, so eating eel on the day of the ox in midsummer once a year is a big concern. On the day of the ox in midsummer Japanese have a custom to eat eel which started in the Edo period. The day of the ox, which is named after one of the twelve animals of the Chinese zodiac. According to one legend, long before the scientific reasons were established, in the 1700s well-known scholar Gennai Hiraga came up with the custom as part of a marketing ploy to boost limp summer sales when the owner of a struggling eel store asked the wise man for some business advice. In fig.\\ref{unagi}, we show the typical cooking of eel in Japan for the day of the ox in midsummer.\n\n\\begin{figure}[h]\n\\begin{center}\n\\includegraphics[width=6cm]{unagi.eps}\n\\caption{Typical cooking of eel in Japan.}\n\\label{unagi}\n\\end{center}\n\\end{figure}\n\n\nThus, this study examines the peaks and falls in interest in these time-limited events, focusing on the medium used to perform searches and on what cohort of the population perform those searches. The mathematical model of search behavior is used for the analysis\\cite{Ishii2018,Okano} .\n\n\n\\section{Theory}\n\n\nIn the theory of search behavior \\cite{Ishii2018,Okano} , the interest and concern on a certain topic can be calculated using a mathematical model of differential equations. Here, we introduce I(t) as the interest or concern on a certain topic. We construct a mathematical model based on the mathematical model for the hit phenomenon within a society presented as a stochastic process of interactions of human dynamics in the sense of many body theory in physics \\cite{Ishii2012a,Ishii2017}. As in the model in \\cite{Ishii2012a,Ishii2017}, we assume that the intention of humans in a society is affected by the three factors: advertisement, communication with friends, and rumors. Advertisements act as external forces; communications with friends are a form of direct communication and its effect is considered as interaction with the intention of friends. The rumor effect is considered as the interaction among three persons and a form of indirect communication as described. In the model, we use only the time distribution of advertisement budget as an input, and word-of-mouth (WOM) represented by posts on social network systems is the observed data for comparison with the calculated results. The parameters in the model are adjusted by the comparison with the calculated and observed social media posting data. \n\nAccording to \\cite{Ishii2012a,Ishii2017}, we write down the equation of purchase intention at the individual level $I_i(t)$ as\n\n \n \\begin{equation}\n\\frac{dI_i(t)}{dt} = \\sum_{\\xi} c_{\\xi}A_{\\xi}(t) - a I_i(t) + \\sum_j d_{ij} I_j(t) + \\sum_j \\sum_k p_{ijk} I_j(t) I_k(t)\n \\end{equation}\n\n\nwhere t is the time, $d_{ij}$, $p_{ijk}$, and $f_i(t)$ are the coefficient of the direct communication, the coefficient of the indirect communication, and the random effect for person i, respectively\\cite{Ishii2012a}. The advertisement and publicity effects are include in $A_{\\xi}(t)$ which is treated as an external force. The index $\\xi$ means sum up of the multi media exposures. \nWord-of-mouth (WOM) represented by posts on social network systems like blog or twitter is used as observed data which can be compared with the calculated results of the model. The unit of time is a day. \n\nHere, it is assumed that the height of interest $I(t)$ of people attenuates exponentially. Although it is known that this is known to occur in movies and the like \\cite{Ishii2012a}, attention such as events and anniversaries is known to attenuate by a power function. \\cite{Sano2013a, Sano2013b} In the case of social interest, we attenuate the intermediate between the exponential function and the power function \\cite{Ishii-Koyabu}, but here we simply adopt exponential decay.\n\nWe consider the above equation for every consumers in the society. Taking the effect of direct communication, indirect communication, and the decline of audience into account, we obtain the above equation for the mathematical model for the hit phenomenon. Using the mean field approximation, we obtain the following equation as equation for averaged intention in the society. The derivation of the equation is explained in detail in ref.\\cite{Ishii2012a}. \n\n\\begin{equation}\n\\label{eq:eq13}\n\\frac{dI(t)}{dt} = \\sum_{\\xi} c_{\\xi}A_{\\xi}(t) + (D-a) I(t) + P I^2(t)\n \\end{equation}\n\nThis equation is the macroscopic equation for the intention of whole society. Using this equation, our calculations for the Japanese motion picture market have agreed very well with the actual residue distribution in time \\cite{Ishii2012a}. The advertisement and publicity effects are obtained from the dataset of M Data and the WOM represented by posts on social network systems are observed using the system of Hottolink. We found that the indirect communication effect is very significant for huge hit movies. \n\n\\subsection{Extension to include Twitter and Blog} \n\nIn the new mathematical model for search behavior, we use daily blog and Twitter postings as the external force. Therefore, we extend the above mathematical model for hit phenomena to include the effects of Twitter and blog as external field as follows.\n\n\\begin{eqnarray}\n\\label{eq:eq14}\n\\frac{dI(t)}{dt} &=& C_{TV}A_{TV}(t) \\nonumber \\\\\n&+& C_{NetNews}A_{NetNews}(t) + C_{Twitter}A_{Twitter}(t) \\nonumber \\\\\n&+& C_{blog}A_{blog}(t) + (D-a) I(t) + P I^2(t)\n\\end{eqnarray}\n\nIn the above equation(\\ref{eq:eq14}), $I(t)$ is the intention to search a certain topic using Google Trend and $C_{TV}$, $C_{NetNews}$, $C_{Twitter}$ and $C_{blog}$ correspond to the strength to influence willingness to search the certain topic. $(D-a) I(t) + P I^2(t)$ correspond to the direct and indirect communications in the previous mathematical model for hit phenomena. In the model of the present paper, these terms correspond to the direct and indirect effect of searching the topic by other people. \n\nOn the real calculation, we use advertisement time data on TV from M Data co. ltd. and the internet news site data, daily Twitter posting data and daily blog posting data on the certain topic from Hottolink co.ltd. The daily search data comes from Google Trend as the reference of our calculation. \n\nThe parameters $C_{TV}$, $C_{NetNews}$, $C_{Twitter}$, $C_{blog}$, $D$ and $P$ are determined in similar way as the previous model by using the metropolis-like Mote Carlo method as noted in the previous paper\\cite{Ishii2012a, Ishii2017}. We define here \"R-factor\" to check the correctness of the adjustment of parameters.\n\n\\begin{equation}\nR = \\frac{\\sum_i (f(i)-g(i))^2}{\\sum_i (f(i)^2 + g(i)^2)},\n\\end{equation}\n\nwhere $f(i)$ and $g(i)$ correspond to the calculated $I(t)$ and the observed number of Google Trend data. The R-factor is originally defined by J B Pendry\\cite{Pendry} to adjust the positions of atoms on surface in the calculation of low energy electron diffraction experiment where measured electric current - voltage curve compared with the corresponding calculation. The smaller the value of R, the better the functions $f$ and $g$. Thus, we use a random number to search for the parameter set that minimizes R. This random number technique is similar to the Metropolis method\\cite{Metropolis}, which we have used previously\\cite{Ishii2012a}. We use this R-factor as a guide to obtain the best parameters for each calculation in this paper.\n\nWe employ the Monte Carlo method like Metropolis method\\cite{Metropolis} to fine the minimum of R. This is very similar for finding the minimum of total energy in the first principle calculation. In the real calculation to adjust the parameters $C_x$, $D$, and $P$, we should take care of the local minimum trapping like the first principle calculation in material physics. It is well-known that there are several ways to find the minimum condition like the steepest descent, the equation of motion method and the conjugate gradient method. Even in the actual calculation of the first principle calculation or the density functional theory, we should be careful of the danger of local minimum trapping. In this paper, the way we employ is just do the calculation using the several initial value in the Metropolis-like method to avoid the local minimum trapping. To check the accuracy of the parameters adjusting, we use the R-factor value. For every calculation which we show in this paper, the R-factor is below 0.01. \n\nActually, the parameters $C_{TV}$, $C_{NetNews}$, $C_{Twitter}$, $C_{blog}$, $D$ and $P$ in equation (\\ref{eq:eq14}) can be considered as functions of time, because people's attention changes over time. However, if we introduce the functions $C_{TV}(t)$, $C_{NetNews}(t)$, $C_{Twitter}(t)$, $C_{blog}(t)$, $D(t)$ and $P(t)$, we can tune any phenomena by adjusting these functions. Thus, we retain $C_{TV}$, $C_{NetNews}$, $C_{Twitter}$, $C_{blog}$, $D$ and $P$ as constant values to examine whether equation (\\ref{eq:eq14}) can be applied to any social phenomena.\n\n\\section{Data}\n\nFor the investigation of this article, we should use Google Trends data for the target data of our calculation. The data of Google Trends can be obtained on the Google Trends page. \n\nThe daily posting number to Twitter and Blog are obtained from the service \"Kuchikomi Kakaricyo\" of Hottolink co.ltd. The mass media advertisement data can be obtained from M Data co.ltd. via the \"Kuchikomi Kakaricyo\" service. \n\n\n\n\\section{Result}\n\nAnalyze the events 1 month before and 1 month after the events, and calculate each coefficients $C_{TV}$, $C_{NetNews}$, $C_{Twitter}$, $C_{blog}$, $D$ and $P$ so that the calculated $I(t)$ is combined with the measured value by Google Trend to best match.\n\nThe calculation results of all coefficients for Christmas are shown in the fig.\\ref{christmas}. For Christmas, the calculation results of all coefficients for the first month before Christmas and one month after Christmas are shown in the fig.\\ref{christmas}.\n\nIn particular, here we examine the difference whether search behavior is affected by Blog or influenced by Twitter. Shown in the fig.\\ref{christmas-blogtwitter} are $C_{blog}$ and $C_{twitter}$ values before and after Christmas. Looking at the results, Twitter's influence is big before Christmas and blog influence is big after Christmas.\n\nIn the same way, the results calculated for Halloween, New Year's countdown, Valentine's Day are shown in the fig.\\ref{halloween-blogtwitter}, fig.\\ref{countdown-blogtwitter} and fig.\\ref{valentine-blogtwitter}, respectively. For Holloween and Valentine's Day, we analyze the events 1 month before and 1 month after the events. For New Year's countdown, we analyze the event 1week before and 1 week after the event in order to avoid the effect of the Christmas before Dec.24. From these, it is possible to read the common tendency that Twitter influences strongly before the event, and after the event the effect of Blog is strong.\n\nAs mentioned above, qualitatively, Halloween, Christmas, Countdown and Valentine's Day are in agreement that it is influenced by Twitter before the event and after the event is affected by Blog.\n\nNext, we introduce the calculation results of Eho-maki and Eel of the Midsummer's Day eating foods decided on a fixed date in fig.\\ref{eho-maki-blogtwitter} and \\ref{unagi-blogtwitter}. As you can see from the results, the influence of Blog and Twitter on people's search behavior is opposite to the previous examples. In the case of this foods, it is from Blog that is influenced before the event and it is influenced by Twitter after the event. The qualitative behavior is same for the two event foods.\n\n\\begin{figure}[h]\n\\begin{center}\n\\includegraphics[width=9cm]{christmas.eps}\n\\caption{Result of $D$, $P$, $C_{TV}$, $C_{NetNews}$, $C_{blog}$, $C_{twitter}$ in calulation for Christmas.}\n\\label{christmas}\n\\end{center}\n\\end{figure}\n\n\n\\begin{figure}[h]\n\\begin{center}\n\\includegraphics[width=9cm]{christmas-blogtwitter.eps}\n\\caption{Result of calulation of $C_{Twitter}$ and $C_{blog}$ before and after Christmas.}\n\\label{christmas-blogtwitter}\n\\end{center}\n\\end{figure}\n\n\n\\begin{figure}[h]\n\\begin{center}\n\\includegraphics[width=9cm]{halloween-blogtwitter.eps}\n\\caption{Result of calulation of $C_{Twitter}$ and $C_{blog}$ before and after Halloween.}\n\\label{halloween-blogtwitter}\n\\end{center}\n\\end{figure}\n\n\n\\begin{figure}[h]\n\\begin{center}\n\\includegraphics[width=9cm]{countdown-blogtwitter.eps}\n\\caption{Result of calulation of $C_{Twitter}$ and $C_{blog}$ before and after New Year Countdown. The analysis is done for a week before the Christmas, a week before the New Year's Day, a week after the New Year's Day and a week after January 8. }\n\\label{countdown-blogtwitter}\n\\end{center}\n\\end{figure}\n\n\\begin{figure}[h]\n\\begin{center}\n\\includegraphics[width=9cm]{valentine-blogtwitter.eps}\n\\caption{Result of calulation of $C_{Twitter}$ and $C_{blog}$ before and after Valentine's Day.}\n\\label{valentine-blogtwitter}\n\\end{center}\n\\end{figure}\n\n\n\\begin{figure}[h]\n\\begin{center}\n\\includegraphics[width=9cm]{Eho-maki-blogtwitter.eps}\n\\caption{Result of calulation of $C_{Twitter}$ and $C_{blog}$ before and after the Eho-maki.}\n\\label{eho-maki-blogtwitter}\n\\end{center}\n\\end{figure}\n\n\n\\begin{figure}[h]\n\\begin{center}\n\\includegraphics[width=9cm]{unagi-blogtwitter.eps}\n\\caption{Result of calulation of $C_{Twitter}$ and $C_{blog}$ before and after the day of the ox in midsummer.}\n\\label{unagi-blogtwitter}\n\\end{center}\n\\end{figure}\n\n\\section{Discussion}\n\nWe analyzed Christmas, Halloween, New Year Countdown, Valentine's Day, Ewaki Roll, and Eel of the Midsummer Day of the ox as events with limited time. Looking at the analysis results, the results were divided for four of Christmas, Halloween, Countdown, Valentine's Day, and the two of Eho-maki and Eel. \n\nThese two groups are thought to depend on surprises or happening for the event and its preparation. In Halloween, there are many matters to investigate beforehand, such as what kind of costumes they themselves, what kind of costumes they are going to do, what kinds of costumes will be popular this year. At Christmas in Japan, there are not many things to consider beforehand, such as what kind of surprise there are lovers to book a Christmas dinner with. In the New Year 's countdown, since the taste of the countdown is different for each gathering, it is necessary to gather information in advance according to which place to go to, which event to go to and which bar to go to. At Japanese Valentine's Day, women collect information in advance, whether women make their own chocolate for her lover or they purchase high-end chocolate at some famous brand shop. \n\nMeanwhile, there are few kinds of Eho-maki to eat as an event, and there is no element to look into in advance as there are also decided how to eat. Also, there is no surprise when eating Eho-maki. As for the Eel to eat on the Midsummer Day of the ox, as shown in the fig.\\ref{unagi}, the method of cooking has been decided traditionally. It is impossible to make home made, so Japanese people have to eat Eel at a restaurant. Therefore, the information to be checked in advance is the only restaurant to eat. Besides, there is not much difference in Eel's cuisine for each restaurant.\n\nIn this way, events that need to check information sufficiently in advance are affected by Twitter. On the contrary, in the case of an event where there is no surprise and there is no need to check in advance, the effect of Twitter at the prior stage is small, and the influence of Blog is expected to be relatively high. \n\nTherefore, if search actions that are strongly influenced by Twitter are observed beforehand, those who come to the event are collecting information. For those people, event-related marketing will be effective. In this way, the method of this research can be applied to marketing.\n\n\\section{Conclusion}\n\nPosting on Blog and Twitter is an act performed by some people in society. On the other hand, search behavior is used by most people who use the Internet. Therefore, analysis of search behavior on the Internet is very important in social analysis in that it can also target people without voice.\n\nIn this research, we have analyzed such search behavior on the Internet using mathematical model of search behavior. As an object, we observed preliminary excitement and post cool down at the event to be held in a short time. The events analyzed are Halloween, Christmas, Countdown, Valentine's Day, Eho-maki, Eel of the Midsummer Day of the ox in Japan. According to the analysis, it turned out that these are divided into events requiring preparatory preparations for surprises, and events not being prepared. Twitter has a strong influence on events requiring advance preparations for surprises. In other events the effect of Twitter is after the incident.\n\nThis research result is expected to be applicable to marketing.\n\n\\section*{Acknowlegement}\n\nThe authors are grateful for helpful discussion to Yasuko Kawahata of Gunma University, Japan.\n\n\n\n\n","meta":{"redpajama_set_name":"RedPajamaArXiv"}} +{"text":"\\subsection{Background and Scope}\nAndroid applications are developed in Java and then compiled to a custom bytecode format called \\emph{Dalvik}, which is run by the Dalvik Virtual Machine (DVM). Unlike Java VMs, which are stack machines, the DVM adopts a register-based architecture.\nAndroid applications are different from standard Java programs, since\nthey are structured in \\emph{components} of four different types:\nactivities, services, content providers and broadcast\nreceivers~\\cite{Android}. These components represent distinct entry\npoints of the Android framework into the application. Hence, the\noperational behaviour of an Android application does not simply amount\nto the sequential execution of its bytecode implementation, but it\nheavily relies on callbacks from the Android framework, as a reaction\nto user inputs, system events, or inter-component\ncommunication. Different Android components, either in the same\napplication or from different applications, can communicate by\nexchanging \\emph{intents}, i.e., dictionary-like messaging\nobjects. Intents may be sent either to a specific component\n(\\emph{explicit} intents) or to any component which declares the will\nof providing a given functionality (\\emph{implicit} intents). \n\nIn our formal model we consider Android applications consisting of\nactivities only. We focus on activities, since a tested semantics is\navailable for them and because they exhibit the most complicated\nlife-cycle among all the component types~\\cite{PayetS14}. Also, we\nonly model intra-application communication based on explicit\nintents: implicit intents are mostly, if not only, used for inter-application\nmessages. As we discuss in Section~\\ref{sec:experiments}, {$\\mu\\text{-Dalvik}_{A}$}\\xspace does not\ncover all the Android features supported by {HornDroid}\\xspace{}: the purpose of {$\\mu\\text{-Dalvik}_{A}$}\\xspace is\nensuring that the design principles at the core of {HornDroid}\\xspace{} are sound and\nthat most of the Android-specific subtleties have been taken into due account. \n\n\\subsection{Syntax}\nWe write $(r_i)^{i \\leq n}$ for the sequence $r_1,\\ldots,r_n$. If the length of the sequence is immaterial, we just write $r^*$ and we still let $r_j$ stand for its $j$-th element. We represent the empty sequence with a dot ($\\cdot$). We let $r^*[j \\mapsto r']$ be the sequence obtained from $r^*$ by replacing its $j$-th element with $r'$. A \\emph{partial map} is a sequence of key-value bindings $(k_i \\mapsto v_i)^*$, where all the keys $k_i$ are pairwise distinct. Given a partial map $M$, let $\\textit{dom}(M)$ stand for the set of its keys and let $M(k) = v$ whenever the binding $k \\mapsto v$ occurs in $M$. We identify partial maps which are identical up to the order of their key-value bindings.\n\nTable~\\ref{tab:dalvik} provides the syntax of {$\\mu\\text{-Dalvik}_{A}$}\\xspace{} programs. It is an extension of the original $\\mu$-Dalvik syntax~\\cite{JeonMF12} with a few additional statements modelling method calls to Android APIs used for inter-component communication.\n\n\\begin{table}[t]\n\\[\\begin{array}{lll}\nP & ::= & \\mathit{cls}^* \\\\\n\\mathit{cls} & ::= & \\cls{c}{c'}{c^*}{\\mathit{fld}^*}{\\mathit{mtd}^*} \\\\\n\\mathit{\\tau_{prim}} & ::= & \\type{bool} ~|~ \\type{int} ~|~ \\dots \\\\\n\\tau & ::= & c ~|~ \\mathit{\\tau_{prim}} ~|~ \\arrtype{\\tau} \\\\ \n\\mathit{fld} & ::= & f: \\tau \\\\\n\\mathit{mtd} & ::= & \\meth{m}{\\methsign{\\tau^*}{\\tau}{n}}{\\mathit{st}^*} \\\\\\\\\n\\mathit{st} & ::= & \\goto{\\mathit{pc}} \\\\\n & | & \\move{\\mathit{lhs}}{\\mathit{rhs}} \\\\\n & | & \\ifbr{r_1}{r_2}{\\mathit{pc}} \\\\\n & | & \\unop{r_d}{r_s} \\\\\n & | & \\binop{r_d}{r_1}{r_2} \\\\\n & | & \\new{r_d}{c} \\\\\n & | & \\newarray{r_d}{r_l}{\\tau} \\\\\n & | & \\checkcast{r_s}{\\tau} \\\\\n & | & \\instanceof{r_d}{r_s}{\\tau} \\\\\n & | & \\invoke{r_o}{m}{r^*} \\\\\n & | & \\sinvoke{c}{m}{r^*} \\\\\n & | & \\texttt{return} \\\\\n & | & \\newintent{r_i}{c} \\\\\n & | & \\putextra{r_i}{r_k}{r_v} \\\\\n & | & \\getextra{r_i}{r_k}{\\tau} \\\\\n & | & \\startact{r_i}\n\\\\\\\\\nr & \\in & \\textit{Registers} \\\\\n\\mathit{pc} & \\in & \\mathbb{N} \\\\\n\\oplus & ::= & + ~|~ - ~|~ \\dots \\\\\n\\odot & ::= & - ~|~ \\neg ~|~ \\dots \\\\\n\\varolessthan & ::= & < ~|~ > ~|~ \\dots \\\\\n\\mathit{prim} & ::= & \\mathtt{true} ~|~ \\mathtt{false} ~|~ \\dots \\\\\n\\mathit{lhs} & ::= & r \\\\\n& | & r[r] \\\\\n& | & r.f \\\\\n& | & c.f \\\\\n\\mathit{rhs} & ::= & \\mathit{lhs} \\\\\n& | & \\mathit{prim}\n\\end{array}\n\\]\n\\caption{{$\\mu\\text{-Dalvik}_{A}$}\\xspace{} Syntax}\n\\label{tab:dalvik}\n\\end{table}\n\nA {$\\mu\\text{-Dalvik}_{A}$}\\xspace{} program $P$ is a sequence of classes $\\mathit{cls}^*$, which in turn are defined by a class name $c$, a direct super-class $c'$, some implemented interfaces $c^*$, and a number of fields $\\mathit{fld}^*$ and methods $\\mathit{mtd}^*$. Field declarations $f: \\tau$ include the field name $f$ and its type $\\tau$, while method declarations $\\meth{m}{\\methsign{\\tau^*}{\\tau}{n}}{\\mathit{st}^*}$ include the method name $m$, the argument types $\\tau^*$, the return type $\\tau$, and the method body $\\mathit{st}^*$. The annotation $n$ on top of the arrow tracks the number of local registers used by the method, which is statically known in Dalvik.\n\nWe briefly discuss below the statements of the language. An\nunconditional branch $\\goto{\\mathit{pc}}$ sets the program counter to\n$\\mathit{pc}$. The statement $\\move{\\mathit{lhs}}{\\mathit{rhs}}$ moves the right-hand side\n$\\mathit{rhs}$ into the left-hand side $\\mathit{lhs}$: here, $\\mathit{lhs}$ may be a register\n$r$, an array cell $r_1[r_2]$, an object field $r.f$, or a static field\n$c.f$; $\\mathit{rhs}$ may be any of these elements or a constant. A\nconditional branch $\\ifbr{r_1}{r_2}{\\mathit{pc}}$ compares the content of two\nregisters $r_1$ and $r_2$ using the comparison operator $\\varolessthan$ and\nsets the program counter to $\\mathit{pc}$ if the check is successful,\notherwise it moves to the next instruction. We then have unary and\nbinary operations, represented by $\\unop{r_d}{r_s}$ and\n$\\binop{r_d}{r_1}{r_2}$ respectively, where $r_d$ is the destination\nregister where the result of the operation must be stored and the\nother registers contain the operands. Object creation is modelled by\n$\\new{r_d}{c}$, which creates an object of class $c$ and stores a\npointer to it in $r_d$; array creation is similarly handled by\n$\\newarray{r_d}{r_l}{\\tau}$, where $r_d$ is the destination register\nwhere the pointer to the new array must be stored, $r_l$ contains the\narray length and $\\tau$ specifies the type of the array cells. The\ntype cast statement $\\checkcast{r_s}{\\tau}$ checks whether the\nregister $r_s$ contains a pointer to an object of type $\\tau$ and it\nmoves to the next instruction if this is the case, otherwise it stops\nthe execution\\footnote{The corresponding Dalvik opcodes would raise an\nexception, but we do not model exceptions in our formalism.}. The\nstatement $\\instanceof{r_d}{r_s}{\\tau}$ stores $\\mathtt{true}$ in $r_d$ if\n$r_s$ points to an object of type $\\tau$, otherwise it stores\n$\\mathtt{false}$. A method invocation $\\invoke{r_o}{m}{r^*}$ calls the method\n$m$ on the receiver object pointed by $r_o$, passing the values in the\nregisters $r^*$ as actual arguments. The invocation of static methods\nis modelled by $\\sinvoke{c}{m}{r^*}$. The $\\texttt{return}$ statement has no\nargument, rather there is a special register $r_{\\mathit{ret}}$ for holding\nreturn values: the return value must be moved to $r_{\\mathit{ret}}$ by the\ncallee before calling $\\texttt{return}$. \n\nThe last four statements are used to model inter-component\ncommunication. Intent creation is modelled by $\\newintent{r_i}{c}$,\nwhich creates an intent for the activity $c$ and stores a pointer to\nit in $r_i$. The statement $\\putextra{r_i}{r_k}{r_v}$ adds to the\nintent pointed by $r_i$ a new key-value binding $k \\mapsto v$, where\n$k$ and $v$ are the contents of $r_k$ and $r_v$ respectively. The\nstatement $\\getextra{r_i}{r_k}{\\tau}$ retrieves from the intent\npointed by $r_i$ the value bound to key $k$, where $k$ is the content\nof $r_k$, provided that this value has type $\\tau$. Finally,\n$\\startact{r_i}$ sends the intent pointed by $r_i$, thus starting a\nnew activity. Throughout the paper, we only consider \\emph{well-formed} programs.\n\n\\begin{definition}\nA program $P$ is \\emph{well-formed} iff: (1) all its class names are pairwise distinct, (2) for each of its classes, all the field names are pairwise distinct, and (3) for each of its classes, all the method names are pairwise distinct.\n\\end{definition}\n\nNotice that the last condition of the definition above is not restrictive, since overloading resolution is performed at compile time in Java~\\cite{JavaSpec} and Dalvik bytecode thus identifies methods through their signature, rather than their name. In our formalism, we then suppose that method names are tagged with some distinctive information drawn from their signature, so that we can identify each method of a given class just by its name. Notice that two different classes can still define two methods with the same name, which is important to model dynamic dispatching.\n\nFrom now on, we focus our attention on some well-formed program $P = \\mathit{cls}^*$. Most of the definitions we present in the paper depend on $P$, but we do not make this dependence explicit in the notation to keep it lighter.\n\n\\subsection{Dalvik Semantics}\n\\label{sec:dalvik}\nTable~\\ref{tab:dalvik-domains} defines the semantic domains employed by the operational semantics of {$\\mu\\text{-Dalvik}_{A}$}\\xspace. Values include primitive values and \\emph{locations}, i.e., pointers to heap elements extended with an annotation $\\lambda$. Annotations have no semantic import and are only needed for our static analysis: we will discuss their role in Section~\\ref{sec:statics}. \n\n\\begin{table*}[htb]\n\\begin{mathpar}\n\\begin{array}{llcl}\n\\text{Pointers} & p & \\in & \\textit{Pointers} \\\\\n\\text{Program points} & \\mathit{pp} & ::= & c,m,\\mathit{pc} \\\\\n\\text{Annotations} & \\lambda & ::= & \\mathit{pp} ~|~ c ~|~ \\astart{c} \\\\\n\\text{Locations} & \\ell & ::= & \\pointer{p}{\\lambda} \\\\\n\\text{Values} & u,v & ::= & \\mathit{prim} ~|~ \\ell \\\\\n\\text{Registers} & R & ::= & (r \\mapsto v)^* \\\\\n\\text{Local states} & L & ::= & \\slocstate{\\mathit{pp}}{\\mathit{st}^*}{R} \\\\\n\\text{Call stacks} & \\alpha & ::= & \\varepsilon ~|~ L :: \\alpha \\\\\n\\text{Pending activity stacks} & \\pi & ::= & \\varepsilon ~|~ i :: \\pi \\\\\n\\end{array}\n\\begin{array}{llll}\n\\text{Objects} & o & ::= & \\obj{c}{(f_{\\tau} \\mapsto v)^*} \\\\\n\\text{Arrays} & a & ::= & \\arr{\\tau}{v^*} \\\\\n\\text{Intents} & i & ::= & \\intent{c}{(k \\mapsto v)^*} \\\\\n\\text{Memory blocks} & b & ::= & o ~|~ a ~|~ i \\\\\n\\text{Heaps} & H & ::= & (\\ell \\mapsto b)^* \\\\\n\\text{Static heaps} & S & ::= & (c.f \\mapsto v)^* \\\\\n\\text{Local configurations} & \\Sigma & ::= & \\smethconf{\\alpha}{\\pi}{H}{S}\n\\end{array}\n\\end{mathpar}\n\\caption{{$\\mu\\text{-Dalvik}_{A}$}\\xspace{} Semantic Domains}\n\\label{tab:dalvik-domains}\n\\end{table*}\n\nA \\emph{local configuration} $\\Sigma =\n\\smethconf{\\alpha}{\\pi}{H}{S}$ represents the state of a\nspecific activity. It includes a call stack $\\alpha$, a pending\nactivity stack $\\pi$, a heap $H$, and a static heap $S$. A\ncall stack $\\alpha$ is a list of \\emph{local states}, which is\npopulated upon method invocation. Each local state includes: (1) a\nprogram point $\\mathit{pp} = c,m,\\mathit{pc}$, where $c$ and $m$ identify the invoked\nmethod, while $\\mathit{pc}$ points to the next instruction to execute; (2) a list\nof statements $\\mathit{st}^*$, modelling the method body; and (3) a map $R$ \nbinding local registers to their current value. \n\nA pending activity stack $\\pi$ is a list of intents, which are treated\nas (untyped) dictionaries in our formalism. As anticipated, for the\nsake of simplicity, we only consider\nexplicit intents in the formalization, i.e., intents which are meant to be delivered\nto an activity of a given class $c$: this class is specified after the\n\\lq at\\rq\\ symbol (@) in the intent syntax\\footnote{Extending the formalism\nto include implicit intents would not be difficult, but this would introduce\nnon-determinism on the choice of the receiving activity, thus making\nthe presentation harder to follow.}. We use $\\pi$ to keep track of\nwhich activities have been started by the activity modelled by the\nlocal configuration.\n\nFinally, a heap $H$ is a mapping between locations and memory\nblocks, where each block is either an object, an array or an\nintent. Object fields are annotated with their static type, though we\ntypically omit this annotation when it is unimportant. The static heap\n$S$ simply binds static fields to their corresponding value. \n\nThe small-step operational semantics of {$\\mu\\text{-Dalvik}_{A}$}\\xspace{} is defined by a reduction relation $\\Sigma \\rightsquigarrow \\Sigma'$. Reduction takes place by fetching the next statement to execute, based on the program counter of the top-most local state of the call stack in $\\Sigma$, and by running it to produce $\\Sigma'$. The definition of the reduction relation is lengthy, but unsurprising, and it is given in \\iffull Appendix~\\ref{sec:bytecode}. \\else the full version~\\cite{full}. \\fi The only point worth noticing here is that, when a new memory block is created, e.g., by \\texttt{new}, the corresponding pointer to the heap is annotated with the program point $c,m,\\mathit{pc}$ where creation takes place.\n\n\\subsection{Activity Semantics}\n\nThe operational behaviour of an activity does not depend only on its bytecode implementation, but also on external events, like user inputs and system callbacks. The event-driven nature of Android applications gives rise to highly non-deterministic executions, which are not trivial to approximate correctly by static analysis.\n\n\\subsubsection{Formalizing Activities}\n\nWe start by introducing a formal notion of activity.\n\n\\begin{definition}\nA class $\\mathit{cls}$ is an \\emph{activity class} if and only if $\\mathit{cls} = \\cls{c}{c'}{c^*}{\\mathit{fld}^*}{\\mathit{mtd}^*}$ for some $c' \\leq \\texttt{Activity}$. An \\emph{activity} is an instance of an activity class. We stipulate that each activity has the following fields: (1) $\\textit{finished}$: a boolean flag stating whether the activity has finished or not; (2) $\\textit{intent}$: a pointer to the intent which started the activity; (3) $\\textit{result}$: a pointer to an intent storing the result of the activity computation; and (4) $\\textit{parent}$: a pointer to the parent activity, i.e., the activity which started the present one.\n\\end{definition}\n\nWe require that each activity has a (possibly empty) set of \\emph{event handlers} for user inputs: given an activity class $c$, we let $\\textit{handlers}(c) = \\{m_1,\\ldots,m_n\\}$ be the set of the names of the methods of $c$ which may be dispatched when some user input event occurs. We assume a set of activity states $\\textit{ActStates}$ and a relation $\\textit{Lifecycle} \\subseteq \\textit{ActStates} \\times \\textit{ActStates}$ defining the state transitions admitted by the activity lifecycle~\\cite{PayetS14}. We assume that each activity class $c$ has a set of callbacks for each activity state $s$, whose names are returned by a function $\\mathit{cb}(c,s)$; for the $\\actstate{running}$ state we let $\\mathit{cb}(c,\\actstate{running}) = \\textit{handlers}(c)$, i.e., when an activity is running, any callback set for user inputs may be dispatched.\n\nWe then extend the syntax of {$\\mu\\text{-Dalvik}_{A}$}\\xspace{} with the elements in Table~\\ref{tab:ext-dalvik}. A \\emph{frame} $\\varphi$ includes a location $\\ell$ pointing to an activity, a corresponding activity state $s$, a pending activity stack $\\pi$ and a call stack $\\alpha$. Frames are organized in an \\emph{activity stack} $\\Omega$, modelling different activities executing in the same application: a single frame in $\\Omega$ has priority of execution and is underlined. A \\emph{configuration} $\\Psi$ includes an activity stack $\\Omega$, a heap $H$ and a static heap $S$.\n\n\\begin{table}[ht]\n\\[\n\\begin{array}{llcl}\n\\text{Activity states} & s & \\in & \\textit{ActStates} \\\\\n\\text{Frames} & \\varphi & ::= & \\actframe{\\ell}{s}{\\pi}{\\alpha} ~|~ \\uactframe{\\ell}{s}{\\pi}{\\alpha} \\\\\n\\text{Activity stacks} & \\Omega & ::= & \\varphi ~|~ \\varphi :: \\Omega \\\\\n\\text{Configurations} & \\Psi & ::= & \\actconf{\\Omega}{H}{S}\n\\end{array}\n\\]\n\\textbf{Convention:} each activity stack $\\Omega$ contains at most one active (underlined) frame.\n\\caption{Extensions to the Syntax of {$\\mu\\text{-Dalvik}_{A}$}\\xspace}\n\\label{tab:ext-dalvik}\n\\end{table}\n\n\\subsubsection{Reduction Rules}\nBefore presenting the formal semantics, we need to introduce some additional definitions. We start with the notion of \\emph{callback stack}, identifying the admissible format of a call stack for new frames pushed on the activity stack upon the invocation of a callback from the Android system. Let $\\textit{sign}(c,m) = \\methsign{\\tau^*}{\\tau}{n}$ iff there exists a class $\\mathit{cls}_i$ such that $\\mathit{cls}_i = \\cls{c}{c'}{c^*}{\\mathit{fld}^*}{\\mathit{mtd}^*, \\meth{m}{\\methsign{\\tau^*}{\\tau}{n}}{\\mathit{st}^*}}$. Let then $\\textit{lookup}$ stand for a \\emph{method lookup} function such that $\\textit{lookup}(c,m) = (c',\\mathit{st}^*)$ iff: (1) $c'$ is the class defining the method which is dispatched when $m$ is invoked on an object of type $c$, and (2) $\\mathit{st}^*$ is the method body. \n\n\\begin{definition}\nGiven a location $\\ell$ pointing to an activity of class $c$, we let $\\getcb{\\ell}{s}$ stand for an arbitrary \\emph{callback stack} for state $s$, i.e., any call stack $\\slocstate{c',m,0}{\\mathit{st}^*}{R} :: \\varepsilon$, where $(c',\\mathit{st}^*) = \\textit{lookup}(c,m)$ for some $m \\in \\mathit{cb}(c,s)$, $\\textit{sign}(c',m) = \\methsign{\\tau_1,\\ldots,\\tau_n}{\\tau}{\\mathit{loc}}$ and:\n\\[ \nR = ((r_i \\mapsto \\mathbf{0})^{i \\leq \\mathit{loc}}, r_{\\mathit{loc}+1} \\mapsto \\ell, (r_{\\mathit{loc}+1+j} \\mapsto v_j)^{j \\leq n}),\n\\]\nfor some values $v_1,\\ldots,v_n$ of the correct type $\\tau_1,\\ldots,\\tau_n$.\n\\end{definition}\n\nIn the definition, we let $\\mathbf{0}$ be the default value for local registers. There is just one default value for registers in the model, since registers are untyped in Dalvik. In the following, it is also convenient to presuppose for each type $\\tau$ the existence of a a default value $\\mathbf{0}_{\\tau}$, used to initialize fields of type $\\tau$ upon object creation.\n\nA tricky aspect of the operational semantics of activities, which has never been formalized before, is the \\emph{serialization} of objects upon inter-component communication. Different activities may exchange objects using intents, but these objects are never passed by reference: rather, they are serialized at the sender side and a copy of them is created at the receiver side. The intent itself is serialized upon communication. We formalize this serialization routine by two mutually recursive functions $\\serval{H}(v) = (v',H')$ and $\\serblock{H}(b) = (b',H')$, returning a serialized copy of their argument and a new heap where all the pointers created in the serialization process have been instantiated correctly. We refer to Table~\\ref{tab:activity-semantics} below for the definition of the two functions. Their definition uses a set of pointers $\\Gamma$ to keep track of which pointers have already been followed in the serialization process, so as to allow the serialization of memory blocks including self-references.\n\nFinally, the operational semantics requires the next definition of \\emph{successful} call stack. A successful call stack is the call stack of an activity which has completed its computation.\n\n\\begin{definition}\nA call stack $\\alpha$ is \\emph{successful} if and only if $\\alpha = \\slocstate{\\mathit{pp}}{\\texttt{return}}{R} :: \\varepsilon$ for some $\\mathit{pp}$ and $R$. We let $\\overline{\\callstack}$ range over successful call stacks.\n\\end{definition}\n\nNow we have all the ingredients to define the formal semantics of\nactivities, which is given by the reduction rules in\nTable~\\ref{tab:activity-semantics}. As anticipated, the rules closely\nfollow previous work by Payet and Spoto~\\cite{PayetS14}, which we\nextend to provide a more accurate account of inter-component\ncommunication by modelling value-passing based on a serialization routine. \nWe give a short explanation of all the rules, we refer\nto~\\cite{PayetS14} for a longer description. \n\n\\begin{table*}[p]\\small\n\\begin{mathpar}\n\\inferrule[(A-Active)]\n{\\smethconf{\\alpha}{\\pi}{H}{S} \\rightsquigarrow \\smethconf{\\alpha'}{\\pi'}{H'}{S'}}\n{\\actconf{\\Omega :: \\uactframe{\\ell}{s}{\\pi}{\\alpha} :: \\Omega'}{H}{S} \\Rightarrow \\actconf{\\Omega :: \\uactframe{\\ell}{s}{\\pi'}{\\alpha'} :: \\Omega'}{H'}{S'}}\n\n\\inferrule[(A-Deactivate)]\n{}\n{\\actconf{\\Omega :: \\uactframe{\\ell}{s}{\\pi}{\\overline{\\callstack}} :: \\Omega'}{H}{S} \\Rightarrow \\actconf{\\Omega :: \\actframe{\\ell}{s}{\\pi}{\\overline{\\callstack}} :: \\Omega'}{H}{S}}\n\n\\inferrule[(A-Step)]\n{(s,s') \\in \\textit{Lifecycle} \\\\\n\\pi \\neq \\varepsilon \\Rightarrow (s,s') = (\\actstate{running},\\actstate{onPause}) \\\\\nH(\\ell).\\textit{finished} = \\mathtt{true} \\Rightarrow (s,s') \\in \\{(\\actstate{running},\\actstate{onPause}),(\\actstate{onPause},\\actstate{onStop}),(\\actstate{onStop},\\actstate{onDestroy})\\}}\n{\\actconf{\\actframe{\\ell}{s}{\\pi}{\\overline{\\callstack}} :: \\Omega}{H}{S} \\Rightarrow \\actconf{\\uactframe{\\ell}{s'}{\\pi}{\\getcb{\\ell}{s'}} :: \\Omega}{H}{S}}\n\n\\inferrule[(A-Destroy)]\n{H(\\ell).\\textit{finished} = \\mathtt{true}}\n{\\actconf{\\Omega :: \\actframe{\\ell}{\\actstate{onDestroy}}{\\pi}{\\overline{\\callstack}} :: \\Omega'}{H}{S} \\Rightarrow \\actconf{\\Omega :: \\Omega'}{H}{S}}\n\n\\inferrule[(A-Back)]\n{H' = H[\\ell \\mapsto H(\\ell)[\\textit{finished} \\mapsto \\mathtt{true}]]}\n{\\actconf{\\actframe{\\ell}{\\actstate{running}}{\\varepsilon}{\\overline{\\callstack}} :: \\Omega}{H}{S} \\Rightarrow \\actconf{\\actframe{\\ell}{\\actstate{running}}{\\varepsilon}{\\overline{\\callstack}} :: \\Omega}{H'}{S}}\n\n\\inferrule[(A-Replace)]\n{H(\\ell) = \\obj{c}{(f_{\\tau} \\mapsto v)^*,\\textit{finished} \\mapsto u} \\\\ \no = \\obj{c}{(f_{\\tau} \\mapsto \\mathbf{0}_{\\tau})^*,\\textit{finished} \\mapsto \\mathtt{false}} \\\\ \nH' = H, \\pointer{p}{c} \\mapsto o}\n{\\actconf{\\actframe{\\ell}{\\actstate{onDestroy}}{\\pi}{\\overline{\\callstack}} :: \\Omega}{H}{S} \\Rightarrow \\actconf{\\uactframe{\\pointer{p}{c}}{\\actstate{constructor}}{\\pi}{\\getcb{\\pointer{p}{c}}{\\actstate{constructor}}} :: \\Omega}{H'}{S}}\n\n\\inferrule[(A-Hidden)]\n{\\varphi = \\actframe{\\ell}{s}{\\pi}{\\overline{\\callstack}} \\\\\ns \\in \\{\\actstate{onResume},\\actstate{onPause}\\} \\\\\n(s',s'') \\in \\{(\\actstate{onPause},\\actstate{onStop}),(\\actstate{onStop},\\actstate{onDestroy})\\} }\n{\\actconf{\\varphi :: \\Omega :: \\actframe{\\ell'}{s'}{\\pi'}{\\overline{\\callstack}'} :: \\Omega'}{H}{S} \\Rightarrow \\actconf{\\varphi :: \\Omega :: \\uactframe{\\ell'}{s''}{\\pi'}{\\getcb{\\ell'}{s''}} :: \\Omega'}{H}{S}}\n\n\\inferrule[(A-Start)]\n{s \\in \\{\\actstate{onPause},\\actstate{onStop}\\} \\\\\ni = \\intent{c}{(k \\mapsto v)^*} \\\\\n\\emptyset \\vdash \\serblock{H}(i) = (i',H') \\\\\n\\pointer{p}{c},\\pointer{p'}{\\astart{c}} \\not\\in \\textit{dom}(H,H') \\\\\no = \\obj{c}{(f_{\\tau} \\mapsto \\mathbf{0}_{\\tau})^*,\\textit{finished} \\mapsto \\mathtt{false}, \\textit{intent} \\mapsto \\pointer{p'}{\\astart{c}}, \\textit{parent} \\mapsto \\ell} \\\\\nH'' = H,H',\\pointer{p}{c} \\mapsto o, \\pointer{p'}{\\astart{c}} \\mapsto i'}\n{\\actconf{\\actframe{\\ell}{s}{i :: \\pi}{\\overline{\\callstack}} :: \\Omega}{H}{S} \\Rightarrow \\actconf{\\uactframe{\\pointer{p}{c}}{\\actstate{constructor}}{\\varepsilon}{\\getcb{\\pointer{p}{c}}{\\actstate{constructor}}} :: \\actframe{\\ell}{s}{\\pi}{\\overline{\\callstack}} :: \\Omega}{H''}{S}}\n\n\\inferrule*[width=30em,lab=(A-Swap)]\n{\\varphi' = \\actframe{\\ell'}{\\actstate{onPause}}{\\varepsilon}{\\overline{\\callstack}'} \\\\\nH(\\ell').\\textit{finished} = \\mathtt{true} \\\\\n\\varphi = \\actframe{\\ell}{s}{i :: \\pi}{\\overline{\\callstack}} \\\\\ns \\in \\{\\actstate{onPause},\\actstate{onStop}\\} \\\\\nH(\\ell').\\textit{parent} = \\ell}\n{\\actconf{\\varphi' :: \\varphi :: \\Omega}{H}{S} \\Rightarrow \\actconf{\\varphi :: \\varphi' :: \\Omega}{H}{S}}\n\n\\inferrule*[width=50em,lab=(A-Result)]\n{\\varphi' = \\actframe{\\ell'}{\\actstate{onPause}}{\\varepsilon}{\\overline{\\callstack}'} \\\\\nH(\\ell').\\textit{finished} = \\mathtt{true} \\\\\n\\varphi = \\actframe{\\ell}{s}{\\varepsilon}{\\overline{\\callstack}} \\\\\ns \\in \\{\\actstate{onPause},\\actstate{onStop}\\} \\\\\nH(\\ell').\\textit{parent} = \\ell \\\\\n\\emptyset \\vdash \\serval{H}(H(\\ell').\\textit{result}) = (\\ell'',H') \\\\\nH'' = (H,H')[\\ell \\mapsto H(\\ell)[\\textit{result} \\mapsto \\ell'']]}\n{\\actconf{\\varphi' :: \\varphi :: \\Omega}{H}{S} \\Rightarrow \\actconf{\\uactframe{\\ell}{s}{\\varepsilon}{\\getcb{\\ell}{\\actstate{onActivityResult}}} :: \\varphi' :: \\Omega}{H''}{S}}\n\\end{mathpar}\nwhere:\n\\begin{mathpar}\n\\inferrule\n{}\n{\\Gamma \\vdash \\serval{H}({\\mathit{prim}}) = (\\mathit{prim}, \\cdot)}\n\n\n\\inferrule\n{\\pointer{p}{\\lambda} \\in \\Gamma}\n{\\Gamma \\vdash \\serval{H}(\\pointer{p}{\\lambda}) = (\\newpointer{\\pointer{p}{\\lambda}}, \\cdot)}\n\n\\inferrule\n{\\pointer{p}{\\lambda} \\notin \\Gamma \\\\ \n\\Gamma \\cup \\{\\pointer{p}{\\lambda}\\} \\vdash\n\\serblock{H}(H(\\pointer{p}{\\lambda})) = (b, H'') \\\\\nH' = H'',\\newpointer{\\pointer{p}{\\lambda}} \\mapsto b }\n{\\Gamma \\vdash \\serval{H}(\\pointer{p}{\\lambda}) = (\\newpointer{\\pointer{p}{\\lambda}}, H')}\n\n\\inferrule\n{\\forall i \\in [1,n]: \\Gamma \\vdash \\serval{H}(v_i) = {(u_i,H_i)} \\\\\nH' = H_1, \\ldots, H_n}\n{\\Gamma \\vdash \\serblock{H}(\\arr{\\tau}{(v_i)^{i \\leq n}}) = (\\arr{\\tau}{(u_i)^{i \\leq n}}, H')}\n\n\\inferrule\n{\\forall i \\in [1,n]: \\Gamma \\vdash \\serval{H}(v_i) = {(u_i,H_i)} \\\\\nH' = H_1, \\ldots, H_n}\n{\\Gamma \\vdash \\serblock{H}(\\obj{c'}{(f_i \\mapsto v_i)^{i \\leq n}}) = (\\obj{c'}{(f_i \\mapsto u_i)^{i \\leq n}}, H')}\n\n\\inferrule\n{\\forall i \\in [1,n]: \\Gamma \\vdash \\serval{H}(v_i) = {(u_i,H_i)} \\\\\nH' = H_1, \\ldots, H_n }\n{\\Gamma \\vdash \\serblock{H}(\\intent{c'}{(k_i \\mapsto v_i)^{i \\leq n}}) = (\\intent{c'}{(k_i \\mapsto u_i)^{i \\leq n}}, H')}\n\\end{mathpar}\n\\textbf{Conventions:} the activity stack on the left-hand side does\nnot contain underlined frames, but for the first two rules. In the\nserialization rules we assume the existence of a function $\\newpointer{\\_}$\nassigning to each pointer a fresh pointer with the same annotation, used to \nstore the result of the serialization.\n\\caption{Reduction Relation for Configurations ($\\actconf{\\Omega}{H}{S} \\Rightarrow \\actconf{\\Omega'}{H'}{S'}$)}\n\\label{tab:activity-semantics}\n\\end{table*}\n\nRule \\irule{A-Active}\nallows the execution of the statements in the active frame, using the\nreduction relation for local configurations described in\nSection~\\ref{sec:dalvik}. Rule \\irule{A-Deactivate} models the\nsituation where the active frame has run up to completion: the frame\nloses priority and one of the other rules can be applied. Rule\n\\irule{A-Step} models the transition of the top-level activity from\nstate $s$ to one of its successors $s'$ in the activity lifecycle:\ncorrespondingly, a new callback method is executed. Two\nside-conditions constrain the possible state transitions, based on the\npresence of pending activities to start and on whether the activity has\nfinished or not. \n\nRule \\irule{A-Destroy} models the removal of a finished activity from the activity stack. Rule \\irule{A-Back} models the scenario where the user hits the back button on the Android device and the top-most activity gets finished by the system. Rule \\irule{A-Replace} corresponds to screen orientation changes: the foreground activity is destroyed and gets replaced by a fresh activity instance; notice that the new pointer to the heap is annotated with the class of the activity. Rule \\irule{A-Hidden} models the scenario where a new activity (the frame $\\varphi$) has come to the foreground and hides a previously running activity, which gets stopped or destroyed by the system.\n\nThe starting of a new activity is modelled by rule \\irule{A-Start}. The top-most activity is paused or stopped and there is some intent $i$ to be sent to $c$: the intent is serialized and a new instance of $c$ is pushed on the activity stack, setting its $\\textit{intent}$ field to a pointer to the serialized copy of $i$ and setting its $\\textit{parent}$ field to a pointer to the activity which sent the intent. The pointer to the new activity is annotated with the class $c$, while the pointer to the serialized copy of the intent gets the annotation $\\astart{c}$: again, this is needed just for the static analysis and will be discussed later. Notice that, if multiple activities need to be started, rule \\irule{A-Swap} allows a parent activity to substitute itself to a child activity on the top of the activity stack, so that rule \\irule{A-Start} can be applied again to fire the remaining intents. Finally, rule \\irule{A-Result} allows a finished activity in the foreground to return the result of its computation to the parent activity: the parent activity gets a serialized copy of the result and becomes active by executing a corresponding callback, bound to the \\actstate{onActivityResult} state.\n\n\\subsection{Examples}\n\\label{sec:examples}\nOne reason why it is useful to have a formal semantics before devising\na static analysis technique is to pinpoint corner cases which may\npotentially lead\nto unsound analysis results. We discuss two examples below. \n\n\\subsubsection{Static Fields}\nEven though inter-component communication does not allow for the\nexchange of references, activities in the same application can still\nshare memory by using static fields. This is apparent in the formal\nsemantics, since the syntax of configurations $\\Psi$ contains a global\nstatic heap $S$, which can be accessed by using publicly known\nnames of static fields. We then observe that the order of execution of\ndifferent activities, or even different callbacks inside the same\nactivity, is very hard to predict: for instance, the rules in\nTable~\\ref{tab:activity-semantics} highlight that even activities\nwhich are not on the top of the activity stack may become active and\nexecute callbacks by rule \\irule{A-Hidden}. Also, the same callback\nmay be executed multiple times, since an activity may be routinely\nrecreated by the Android system due to user activities (e.g., screen\norientation changes), which cannot be known statically, \nas modelled by rule \\irule{A-Replace}. \n\nThe implication on static analysis is that it is extremely challenging to implement flow-sensitivity on accesses to static fields without producing unsound results. Furthermore, given that static fields may be used to share pointers to heap locations, flow-sensitivity for heap accesses is also hard to achieve. Since we target soundness in this work, the static analysis we devise in the next section is flow-insensitive on both static fields and heap locations.\n\n\\subsubsection{Serialization}\nRule \\irule{A-Start} of the operational semantics highlights that\nintents are serialized upon inter-component communication. This means\nthat, when a parent activity starts a child activity, the latter\noperates on a copy of the intent sent by the former and not on the\nsame intent. \n\nThe implication on static analysis is that, although the callback bound to the \\actstate{onActivityResult} state of the parent activity is always executed after the construction of the child activity, no change to the intent done by the child activity should overwrite the original over-approximation of the intent computed for the parent\nactivity when a result is returned to it. This applies to any object which is serialized with the intent. The static analysis in the next section provides a conservative over-approximation of this behaviour.\n\n\n\n\n\\subsection{Value-sensitivity}\nValue-sensitivity is the ability of a static analysis to approximate runtime values and use this information to improve precision, e.g., by skipping unreachable program branches~\\cite{NielsonNH99}. Concretely, consider the following code:\n\\begin{verbatim}\nint x = 0;\nfor (int y = 0; y <= 10; y++) { x++; }\nTelephonyManager tm = ...\nString imei = tm.getDeviceId();\nif (x == 0) { leak(imei); }\n\\end{verbatim}\nThough this code is perfectly safe, all the existing tools (IccTA, AmanDroid and DroidSafe) will identify it as leaky. IccTA and DroidSafe conservatively assume all the program points to be potentially reachable. Even AmanDroid raises a false alarm for this code, though it internally implements a dedicated data-flow analysis~\\cite{WeiROR14}. \n\nBesides this simple example, there are many reasons why real-world static analysis tools for Android applications should be value-sensitive to be practically useful. First, several features of Java and the Android APIs, most notably \\emph{reflection} and \\emph{dictionary-like} containers, e.g., intents and bundles, need value-sensitivity to be analysed precisely. Second, the loss of precision entailed by value-insensitivity may creep and interact badly with other desirable features of the static analysis, e.g., \\emph{context-sensitivity}, which has been deemed as crucial by previous studies~\\cite{ArztRFBBKTOM14,GordonKPGNR15}. \n\nContext-sensitivity is the ability of the analysis to compute\ndifferent static approximations upon different method calls. To\nunderstand why the benefits of context-sensitivity can be voided by\nvalue-insensitivity, consider the following method, where we assume to\nknow a valid upper bound for the GPS location values:\n\n\\begin{verbatim}\nvoid m (double x, double y) {\n if (x <= MAX_X && y <= MAX_Y)\n ...\n else\n leak(\"Invalid location:\" + x + y);\n}\n\\end{verbatim} \nContext-insensitive static analyses would detect a dangerous information flow whenever the method \\texttt{m} is invoked at two different program points and one of these invocations provides the location of the device in the actual parameters, while the other one provides an invalid location. The reason is that the method \\texttt{m} would be analysed only once, hence the static analysis would detect that both public and confidential values may reach a sink. Conversely, a context-sensitive analysis potentially has the ability to discriminate between the two methods invocations and be precise, but the lack of value-sensitivity would necessarily lead to the detection of a non-existent information flow.\n\nFinally, it is worth noticing that value-sensitivity is crucial to support \nsecurity-relevant, value-dependent security queries (e.g., ``Is the credit card \nnumber sent on HTTP rather than on HTTPS?'' or ``Is the picture actually \nuploaded on Facebook, as opposed to some other untrusted website?'').\n\n\\subsection{Flow-sensitivity}\nFlow-sensitivity is the ability of a static analysis to take the order of statements into account and compute different approximations at different program points~\\cite{NielsonNH99}. To understand its importance, consider the following code:\n\\begin{verbatim}\nTelephonyManager tm = ...\nString imei = tm.getDeviceId();\nimei = new String(\"empty\");\nleak(imei);\n\\end{verbatim}\nThough the code above is safe, the flow-insensitive analysis implemented in DroidSafe will identify it as leaky, since the variable \\texttt{imei} does contain a secret information at some program point. Conversely, both FlowDroid and AmanDroid will correctly deem the program as safe.\n\nClearly, it is tempting to target a flow-sensitive information flow analysis tool to achieve a higher level of precision, but, as pointed out by the authors of DroidSafe~\\cite{GordonKPGNR15}, flow-sensitivity is very hard to get right for Android applications, due to their massive use of asynchronous callbacks. Both FlowDroid and AmanDroid suggest to tackle this problem by introducing a \\emph{dummy main method} emulating each possible interleaving of the callbacks defining the application life-cycle. Unfortunately, it is difficult to ensure that the dummy main method construction is accurate and comprehensive, which leads to missing malicious information flows~\\cite{GordonKPGNR15}. \n\n\\subsection{HornDroid}\nOur tool, {HornDroid}\\xspace, targets a \\emph{sound} and \\emph{practical} information flow analysis for Android applications. We report on the design choices we made to hit the sweet spot between these two potentially conflicting requirements.\n\n{HornDroid}\\xspace{} implements a \\emph{value-sensitive} information flow analysis. As anticipated, value-sensitivity is crucial to support a practically useful analysis of real-world applications. The analysis implemented in {HornDroid}\\xspace{} is reminiscent of \\emph{abstract interpretation}, whereby the operational semantics of a program is over-approximated by a computable abstract semantics. As it is customary for abstract interpretation, the design of the analysis is parametric with respect to the choice of a set of \\emph{abstract domains}, defining how runtime values are statically approximated: one can then fine-tune the precision of the analysis by testing different abstract domains. To ensure the scalability of our value-sensitive analysis, the abstract semantics implemented in {HornDroid}\\xspace{} is based on \\emph{Horn clauses}, whose efficient resolution is supported by state-of-the-art SMT solvers~\\cite{BjornerMR12}.\n\n{HornDroid}\\xspace{} performs a \\emph{flow-sensitive} information flow analysis on the registers employed by the Dalvik Virtual Machine, while implementing a \\emph{flow-insensitive} analysis for callback methods and heap locations. This is crucial to preserve the precision of the analysis, without sacrificing soundness. We already mentioned that previous studies highlighted that flow-sensitive analyses may easily produce unsound results, due to the challenges of predicting all the possible orderings of the Android callbacks~\\cite{GordonKPGNR15}. Moreover, while carrying out the soundness proof for {HornDroid}\\xspace, we realized that \\emph{static fields} are particularly delicate to treat in a flow-sensitive fashion. The reason is that static fields provide a way to implement a shared memory between otherwise memory-isolated components running in the same application. Given that the execution order of different Android components is extremely hard to predict, due to their callback-driven nature, it turns out that flow-insensitivity for static fields is in practice needed for soundness. Indeed, since static fields can be used to exchange pointers to heap locations, a sound flow-sensitive analysis for heap locations is in general hard to achieve. Our soundness proof, instead, confirms that flow-sensitivity can be implemented for the registers employed by the Dalvik Virtual Machine without missing any malicious information flow.\n\n\n\\subsection{Evaluation on DroidBench}\nDroidBench~\\cite{ArztRFBBKTOM14} is a set of small applications which\nhas been proposed by the research community as a testing ground for\nstatic information flow analysis tools for Android. The current\nversion of the benchmark (2.0) includes 120 test cases, featuring both\nleaky (positive) and benign (negative) examples. We tested IccTA, AmanDroid, DroidSafe and {HornDroid}\\xspace{} on this benchmark, the results are summarized in the confusion matrix in Table~\\ref{tab:droidbench}, reporting the number of true positives ($tp$), true negatives ($tn$), false positives ($fp$) and false negatives ($fn$) produced by the tools.\n\n\\begin{table}[htb]\n\\begin{center}\n\\begin{tabular}{c|c|c|}\n\\cline{2-3} & \\multicolumn{2}{ c| }{Output} \\\\ \n\\cline{2-3} & \\emph{leaky} & \\emph{benign} \\\\ \n\\cline{2-3}\n\\cline{2-3} & \\emph{IccTA}\/\\emph{AD}\/\\emph{DS}\/\\emph{HD} & \\emph{IccTA}\/\\emph{AD}\/\\emph{DS}\/\\emph{HD} \\\\\n\\cline{1-3}\n\\multicolumn{1}{ |c| }{\\emph{leaky}} & $tp:$ 64 \/ 70 \/ 89 \/ 96 & $fn:$ 36 \/ 30 \/ 11 \/ 4 \\\\ \n\\cline{1-3}\n\\multicolumn{1}{ |c| }{\\emph{benign}} & $fp:$ 8 \/ 5 \/ 10 \/ 6 & $tn:$ 11 \/ 14 \/ 9 \/ 13 \\\\\n\\cline{1-3}\n\\end{tabular}\n\\end{center}\n\\caption{Confusion Matrix on DroidBench}\n\\label{tab:droidbench}\n\\end{table}\n\nIccTA does not detect 36 out of 100 leaky applications, AmanDroid misses 30 and DroidSafe still misses 11. Most of the leaks missed by IccTA and AmanDroid are due to flow-sensitivity and some callbacks which are not correctly detected by the analysis; as to DroidSafe, we do not have definite answers on the unsound results, given the sheer size of the project and the lack of complete documentation. {HornDroid}\\xspace{} performs much better than all its competitors on DroidBench, since it only misses 4 leaky applications: all these cases are related to \\emph{implicit flows}, which are not covered by standard taint analyses (and our formal proof). \n\nBut even better, despite the strong security guarantees it provides,\nthe analysis performed by {HornDroid}\\xspace{} is not overly conservative, since it\ndetects as potentially leaky only 6 out of 19 benign applications. We\nnotice that 3 of these false alarms are due to flow insensitivity of\nthe heap abstraction, one to an over-approximation of exceptions, and\n2 to an over-approximated treatment of inter-app communication. Only\nAmanDroid is more precise, since it produces one less false positive;\non the other hand, it misses many more malicious information flows\nthan {HornDroid}\\xspace{} (30 vs 4). For the sake of completeness, we report in Table~\\ref{tab:droidbench-res}\na full breakdown of the experiments on DroidBench, omitting the cases where all the tools agree with the ground truth.\n\nThe experimental results on DroidBench are summarized by a few standard statistical measures in Table~\\ref{tab:spec-sens}, which highlight that soundness in HornDroid does not come at the\ncost of precision.\n\n\\begin{table}[htb]\n\\begin{center}\n\\begin{tabular}{c|c|c|c|c|}\n\\cline{2-5}\n& \\emph{IccTA} & \\emph{AD} & \\emph{DS} & \\emph{HD} \\\\\n\\cline{1-5}\n\\multicolumn{1}{|c|}{\\emph{Sensitivity}} & 0.64 & 0.70 & 0.89 & 0.96 \\\\ \n\\cline{1-5}\n\\multicolumn{1}{|c|}{\\emph{Specificity}} & 0.58 & 0.74 & 0.47 & 0.68 \\\\\n\\cline{1-5}\n\\multicolumn{1}{|c|}{\\emph{F-Measure}} & 0.61 & 0.72 & 0.62 & 0.80 \\\\\n\\cline{1-5}\n\\end{tabular}\n\\end{center}\n\\emph{Sensitivity} = $tp \/ (tp + fn)$ $\\sim$ Soundness \\\\\n\\emph{Specificity} = $tn \/ (tn + fp)$ $\\sim$ Precision \\\\\n\\emph{F-Measure} = $2 * (sens * spec) \/ (sens + spec)$ $\\sim$ Aggregate\n\\caption{Performance Measures on DroidBench}\n\\label{tab:spec-sens}\n\\end{table}\n\n\\iffull\n\\input{results}\n\\fi\n\nBesides the quality of the results, also performances are important. Table~\\ref{tab:performances} reports the mean and the median of the analysis times for the applications in DroidBench. As it turns out, {HornDroid}\\xspace{} is one order of magnitude faster than both IccTA and AmanDroid, which in turn are one order of magnitude faster than DroidSafe. The extremely good performances of {HornDroid}\\xspace{} are due to both design choices, like flow insensitivity on the activity life-cycle, and excellent support by Z3 in Horn clauses resolution. \n\n\\begin{table}[htb]\n\\begin{center}\n\\begin{tabular}{c|c|c|c|c|}\n\\cline{2-5}\n& \\emph{IccTA} & \\emph{AD} & \\emph{DS} & \\emph{HD} \\\\\n\\cline{1-5}\n\\multicolumn{1}{|c|}{\\emph{Average Analysis Time}} & 19 & 11 & 176 & 1 \\\\ \n\\cline{1-5}\n\\multicolumn{1}{|c|}{\\emph{Median Analysis Time}} & 15 & 10 & 186 & 1 \\\\\n\\cline{1-5}\n\\end{tabular}\n\\end{center}\n\\caption{Analysis Time for DroidBench (Seconds)}\n\\label{tab:performances}\n\\end{table}\n\n\n\\subsection{Evaluation on Real Applications}\nIn order to evaluate the practicality of our analysis, we performed a\ntest on the two largest applications available in the Google Play Top\n30: the game Candy Crash Soda Saga (51.7 Mb) and the Facebook\napplication (46.5 Mb). We ran the experiments on a server with 64\nmulti-thread cores and 758 Gb of memory, however the highest memory\nconsumption by {HornDroid}\\xspace{} was around 10 Gb, so it is possible to\nreproduce our results even on a modern commercial machine. \n\n{HornDroid}\\xspace{} found an information leak in Facebook, while Candy Crash Soda Saga\nappears to be secure. The analysis took around 30 minutes and 60\nminutes respectively. We tested all the existing competitors on both\napplications, to check whether they could confirm the analysis\nresults. Unfortunately, AmanDroid crashed just after the beginning of\nthe analysis of Facebook, while both DroidSafe and IccTA failed to\nterminate within the timeout we set (2 hours). We were able instead to\nanalyse Candy Crash Soda Saga using AmanDroid in around 50 minutes,\ngetting an information flow. After a manual inspection, we realized\nthis is a false positive due to the incorrect inclusion of the\n\\texttt{onHandleIntent} method of the class \\texttt{IntentService}\namong the possible sources of sensitive information: this is not\nincluded in more recent proposals~\\cite{GordonKPGNR15,LiEtAl15}. Both\nIccTA and DroidSafe were not able to analyse the application within 2\nhours. Due to space constraints, we refer to~\\cite{full} for a more\ncomprehensive experimental evaluation on real applications. \n\n\\subsection{Features and Limitations}\n\\label{sec:features}\nAs anticipated, the formalization in the previous sections only captures the \\emph{core} of the analysis implemented in {HornDroid}\\xspace{} and establishes the soundness of its principles. The tool, however, supports more features which are needed to make the analysis scale to real applications. We detail here some important aspects of {HornDroid}\\xspace{} which are not covered by our formal model and we comment on current limitations.\n\n\\subsubsection*{Android Components}\nAlthough the {$\\mu\\text{-Dalvik}_{A}$}\\xspace{} model only represents activities and their life-cycle, {HornDroid}\\xspace{} supports all the component types available on the Android platform, including services, broadcast receivers and content providers~\\cite{Android}. The implementation of the analysis for these components does not significantly differ from the one for activities we presented in the paper, though it requires a correct modelling of their specific life-cycle.\n\n\\subsubsection*{Fragments}\nFragments are used to separate the functionality of an activity among different independent sub-components~\\cite{Fragments}. In order to support a sound analysis of fragments, {HornDroid}\\xspace{} over-approximates their life-cycle by executing all the fragments along with the containing activity in a flow-insensitive way. This might lead to precision problems on real applications, but this is the simplest of the sound options, which follows the philosophy we adopted for activity analysis.\n\n\\subsubsection*{Arrays} \nThough the static analysis we formalized is field-insensitive on\narrays, {HornDroid}\\xspace{} supports a more precise treatment of array\nindexes. Being value-sensitive, {HornDroid}\\xspace{} statically approximates which\nindexes of an array may be accessed at runtime: if a secret value is\nstored in the first position of the array, but only the second element\nof the array is leaked, the tool does not raise an alarm, contrarily\nto all the other existing tools (cf. the breakdown on the experiments\nin~\\cite{full}).\n\n\\subsubsection*{Exceptions} \n{HornDroid}\\xspace{} implements a conservative solution to handle exceptions, i.e., exceptions are always assumed to be thrown. A similar coarse over-approximation is implemented in FlowDroid~\\cite{ArztRFBBKTOM14}. We leave a more precise treatment of exceptions to future work: we believe that the value-sensitivity of the analysis implemented in our tool will be crucial to limit the number of false alarms for exception handling. For instance, a value-sensitive analysis can ensure that a null pointer exception is never raised at runtime, since it over-approximates the set of the possible runtime values.\n\n\\subsubsection*{Inter-app Communication} \n{HornDroid}\\xspace{} has limited support for inter-application communication, i.e., it conservatively detects an information leak whenever an intent storing secret data is sent to another application. More precise results could be achieved by analysing all the communicating applications simultaneously, but the current implementation of {HornDroid}\\xspace{} only supports the analysis of a single application. We plan to leverage existing state-of-the-art solutions to overcome this limitation~\\cite{LiEtAl15}. \n\n\\subsubsection*{Threading} \n{HornDroid}\\xspace{} handles multithreading by assuming that threads are executed in a sequential,\nbut arbitrary order, much in the same spirit of the callbacks defining\nthe activity life-cycle. This is the same strategy used in FlowDroid. We conjecture, but did not prove yet, that\nthis strategy is sound in our case, since the analysis is flow\ninsensitive on everything except for registers, which are not shared. For flow-sensitive analysis techniques (e.g.,\nFlowDroid), instead, this strategy is in general unsound, since it\nmay miss potential interleavings arising due to synchronization on\nshared memory (e.g., static heaps). The only aspect that should be added to our\nstatic analysis is a thread pool simulation. In Java, every time the\nmethod \\texttt{execute} is called on a thread, this is placed in a\npool and then executed by the system by calling the runnable method\n\\texttt{run}. Our static analysis similarly binds each invocation of\n\\texttt{execute} to a corresponding \\texttt{run} method. \n\n\\subsubsection*{Reflection} \nThough supporting reflection soundly is an open research problem~\\cite{SmaragdakisKB14}, {HornDroid}\\xspace{} still covers a significant fraction of common reflection cases by implementing a simple string analysis. The solution we propose is in the same spirit of DroidSafe, i.e., reflective calls which can be statically resolved are replaced by direct calls to the appropriate method. Pragmatically, however, we observed that we are able to achieve much better results than DroidSafe for the reflection cases in DroidBench.\n\n\\subsubsection*{Limitations}\nA comprehensive implementation of analysis stubs for method calls to the Android APIs is still lacking: we only implemented some selected stubs for our experiments, to show that our approach is feasible and practical. When a stub to an external library is missing, the tool tries to be conservative: the return value of the call is over-approximated to the top element of the corresponding abstract domain, and it is tainted whenever at least one of the arguments is tainted. \nOther important limitations of {HornDroid}\\xspace{} are shared with existing\nsolutions~\\cite{ArztRFBBKTOM14,GordonKPGNR15}. First, the analysis\ndoes not capture \\emph{implicit} information flows at\npresent. Second, the analysis does not consider \\emph{native\ncode}: this is a point we leave as a future work, observing that SMT solving has \nbeen successfully applied in the past to C code (see, e.g., the SLAM \nproject~\\cite{Ball_adecade}). Third, the analysis is oblivious to the \\emph{semantics}\nof the information flows, i.e., it lacks any built-in declassification mechanism\nto qualify legitimate data flows. Since our analysis approximates data\ninformation rather than just tracking taints, however, it is in principle \npossible to encode expressive data-dependent declassification policies, e.g.,\none could define the result of an encryption as untainted\nonly if the encryption is performed with the right key.\n\n\n\n\n\\section{Introduction}\n\\label{sec:intro}\n\\input{intro}\n\n\\section{Design and Motivations}\n\\label{sec:design}\n\\input{design}\n\n\\section{Operational Semantics}\n\\label{sec:activity}\n\\input{activity}\n\n\\section{Static Analysis}\n\\label{sec:statics}\n\\input{statics}\n\n\\section{Experiments}\n\\label{sec:experiments}\n\\input{experiments}\n\n\\section{Additional Related Work}\n\\label{sec:related}\n\\input{related}\n\n\\section{Conclusion}\n\\label{sec:conclusion}\n\\input{conclusion}\n\n\n\n\\bibliographystyle{IEEEtranS}\n\n\\subsection{Representation Functions}\nWe presuppose the existence of a representation function $\\beta_{\\textit{Prim}}$ which associates to each primitive value $\\mathit{prim}$ a corresponding abstract value $\\{\\widehat{\\prim}\\}$. For a location $\\ell = \\pointer{p}{\\lambda}$, we let $\\beta_{\\textit{Loc}}(\\ell) = \\{\\lambda\\}$. Based on this, we define $\\beta_{\\textit{Val}}(v)$ as follows:\n\\[\n\\beta_{\\textit{Val}}(v) =\n\\begin{cases}\n\\beta_{\\textit{Prim}}(v) & \\text{if } v = \\mathit{prim} \\\\\n\\beta_{\\textit{Loc}}(v) & \\text{if } v = \\ell\n\\end{cases}\n\\]\nWe typically omit brackets around singleton abstract values. We then define $\\beta_{\\textit{Blk}}(b)$ as follows:\n\\[\n\\beta_{\\textit{Blk}}(b) =\n\\begin{cases}\n\\absobj{c}{(f \\mapsto \\hat{v})^*} & \\text{if } b = \\obj{c}{(f \\mapsto v)^*} \\text{ and } \\forall i: \\beta_{\\textit{Val}}(v_i) = \\hat{v}_i \\\\\n\\absintent{c}{\\hat{v}} & \\text{if } b = \\intent{c}{(f \\mapsto v)^*} \\text{ and } \\hat{v} = \\sqcup_i\\, \\beta_{\\textit{Val}}(v_i) \\\\\n\\absarray{\\tau}{\\hat{v}} & \\text{if } b = \\arr{\\tau}{v^*} \\text{ and } \\hat{v} = \\sqcup_i\\, \\beta_{\\textit{Val}}(v_i)\n\\end{cases}\n\\]\nUsing these definitions, we can define how configurations are translated into facts by a corresponding representation function. This requires one to define a number of clauses, summarized below:\n\n\\[\n\\begin{array}{lcl}\n\\beta_{\\textit{Lst}}(\\locstate{c,m,\\mathit{pc}}{\\mathit{st}^*}{R}{u^*}) & = & \\{\\absreg{c,m,\\mathit{pc}}{\\hat{u}^*}{\\hat{v}^*} ~|~ \\forall j: \\hat{u}_j = \\beta_{\\textit{Val}}(u_j) \\wedge \\forall k: \\hat{v}_k = \\beta_{\\textit{Val}}(R(r_k))\\} \\cup \\bigcup_i\\, \\ainstfull{\\mathit{st}_i}{c,m,i} \\\\\n\n\\beta_{\\textit{Call}}(\\alpha) & = & \\bigcup_{i \\in [1,n]} \\beta_{\\textit{Lst}}(L_i) \\text{ whenever } \\alpha = L_1 :: \\ldots :: L_n \\\\\n\n\\beta_{\\textit{Heap}}(H) & = & \\{\\mathsf{H}(\\lambda,\\hat{b}) ~|~ H = H',\\ell \\mapsto b \\wedge \\lambda = \\beta_{\\textit{Loc}}(\\ell) \\wedge \\hat{b} = \\beta_{\\textit{Blk}}(b)\\} \\\\\n\n\\beta_{\\textit{Stat}}(S) & = & \\{\\mathsf{S}(c,f,\\hat{v}) ~|~ S = S',c.f \\mapsto v \\wedge \\hat{v} = \\beta_{\\textit{Val}}(v)\\} \\\\\n\n\\rfdispatch{\\ell}(\\pi) & = & \\{\\mathsf{I}(c,\\hat{b}) ~|~ c = \\beta_{\\textit{Loc}}(\\ell) \\wedge \\pi = \\pi_0 :: i :: \\pi_1 \\wedge \\hat{b} = \\beta_{\\textit{Blk}}(i)\\} \\\\\n\n\\beta_{\\textit{Lcnf}}(\\methconf{\\alpha}{\\pi}{H}{S}{\\ell}) & = & \\beta_{\\textit{Call}}(\\alpha) \\cup \\rfdispatch{\\ell}(\\pi) \\cup \\beta_{\\textit{Heap}}(H) \\cup \\beta_{\\textit{Stat}}(S) \\\\\n\n\\beta_{\\textit{Frm}}(\\actframe{\\ell}{s}{\\pi}{\\alpha}) & = & \\beta_{\\textit{Frm}}(\\uactframe{\\ell}{s}{\\pi}{\\alpha}) = \\rfdispatch{\\ell}(\\pi) \\cup \\beta_{\\textit{Call}}(\\alpha) \\\\\n\n\\beta_{\\textit{Stk}}(\\Omega) & = & \\bigcup_{i \\in [1,n]} \\beta_{\\textit{Frm}}(\\varphi_i) \\text{ whenever } \\Omega = \\varphi_1 :: \\ldots :: \\varphi_n \\\\\n\n\\beta_{\\textit{Cnf}}(\\actconf{\\Omega}{H}{S}) & = & \\beta_{\\textit{Stk}}(\\Omega) \\cup \\beta_{\\textit{Heap}}(H) \\cup \\beta_{\\textit{Stat}}(S)\n\\end{array}\n\\]\n\n\\subsection{Ordering Abstract Values and Facts}\nWe presuppose the existence of a pre-order $\\sqsubseteq_{\\textit{Prim}}$ on primitive singleton abstract values. Based on this, we define a pre-order $\\sqsubseteq_{\\textit{Val}}$ on abstract values by having $\\hat{u} \\sqsubseteq_{\\textit{Val}} \\hat{v}$ iff:\n\\begin{itemize}\n\\item $\\forall \\widehat{\\prim} \\in \\hat{u}: \\exists \\widehat{\\prim}' \\in \\hat{v}: \\widehat{\\prim} \\sqsubseteq_{\\textit{Prim}} \\widehat{\\prim}'$;\n\\item $\\forall \\lambda \\in \\hat{u}: \\lambda \\in \\hat{v}$.\n\\end{itemize}\nWe then build a pre-order $\\sqsubseteq_{\\textit{Seq}}$ on sequences of abstract values by having $\\hat{u}^* \\sqsubseteq_{\\textit{Seq}} \\hat{v}^*$ iff $\\hat{u}^*$ and $\\hat{v}^*$ have the same length and:\n\\[\n\\forall i: \\hat{u}_i \\sqsubseteq_{\\textit{Val}} \\hat{v}_i.\n\\]\nWe can then define a pre-order $\\sqsubseteq_{\\textit{Blk}}$ on abstract blocks as follows:\n\\begin{itemize}\n\\item if $\\hat{b} = \\absobj{c}{(f \\mapsto \\hat{u})^*}$ and $\\hat{b}' = \\absobj{c}{(f \\mapsto \\hat{v})^*}$ and $\\hat{u}^* \\sqsubseteq_{\\textit{Seq}} \\hat{v}^*$, then $\\hat{b} \\sqsubseteq_{\\textit{Blk}} \\hat{b}'$;\n\\item if $\\hat{b} = \\absintent{c}{\\hat{u}}$ and $\\hat{b}' = \\absintent{c}{\\hat{v}}$ and $\\hat{u} \\sqsubseteq_{\\textit{Val}} \\hat{v}$, then $\\hat{b} \\sqsubseteq_{\\textit{Blk}} \\hat{b}'$;\n\\item if $\\hat{b} = \\absarray{\\tau}{\\hat{u}}$ and $\\hat{b}' = \\absarray{\\tau} {\\hat{v}}$ and $\\hat{u} \\sqsubseteq_{\\textit{Val}} \\hat{v}$, then $\\hat{b} \\sqsubseteq_{\\textit{Blk}} \\hat{b}'$.\n\\end{itemize}\n\nFinally, we let $\\mathsf{f} \\sqsubseteq \\mathsf{f}'$ be the least pre-order on facts such that:\n\\begin{itemize}\n\\item $\\absreg{c,m,\\mathit{pc}}{\\hat{u}_{call}^*}{\\hat{u}^*} \\sqsubseteq \\absreg{c,m,\\mathit{pc}}{\\hat{v}_{call}^*}{\\hat{v}^*}$ whenever $\\hat{u}_{call}^* \\sqsubseteq_{\\textit{Seq}} \\hat{v}_{call}^*$ and $\\hat{u}^* \\sqsubseteq_{\\textit{Seq}} \\hat{v}^*$;\n\\item $\\mathsf{H}(\\lambda,\\hat{b}) \\sqsubseteq \\mathsf{H}(\\lambda,\\hat{b}')$ whenever $\\hat{b} \\sqsubseteq_{\\textit{Blk}} \\hat{b}'$;\n\\item $\\mathsf{S}(c,f,\\hat{u}) \\sqsubseteq \\mathsf{S}(c,f,\\hat{v})$ whenever $\\hat{u} \\sqsubseteq_{\\textit{Val}} \\hat{v}$;\n\\item $\\prhs{\\hat{u}} \\sqsubseteq \\prhs{\\hat{v}}$ whenever $\\hat{u} \\sqsubseteq_{\\textit{Val}} \\hat{v}$;\n\\item $\\absresult{c,m}{\\hat{u}_{call}^*}{\\hat{u}^*} \\sqsubseteq \\absresult{c,m}{\\hat{v}_{call}^*}{\\hat{v}^*}$ whenever $\\hat{u}_{call}^* \\sqsubseteq_{\\textit{Seq}} \\hat{v}_{call}^*$ and $\\hat{u}^* \\sqsubseteq_{\\textit{Seq}} \\hat{v}^*$;\n\\item $\\mathsf{I}(c,\\hat{b}) \\sqsubseteq \\mathsf{I}(c,\\hat{b}')$ whenever $\\hat{b} \\sqsubseteq_{\\textit{Blk}} \\hat{b}'$.\n\\end{itemize}\n\n\\subsection{Formal Results}\n\n\\subsubsection{Preliminaries}\n\n\\begin{definition}\nA local configuration $\\Sigma = \\methconf{\\alpha}{\\pi}{H}{S}{\\ell}$ is \\emph{well-formed} if and only if, whenever $\\alpha = L_1 :: \\ldots :: L_n$, we have:\n\\begin{itemize}\n\\item either $n \\in \\{0,1\\}$, i.e., $\\alpha$ is either empty or it contains just a single local state;\n\\item or $n \\geq 2$ and for each $i \\in [2,n]$, either of the\n following conditions hold true:\n\\MESSAGEIfor{MS}{151202}{We replace $\\mathit{st}_{\\mathit{pc}-1}$ with $\\mathit{st}_{\\mathit{pc}}$, without\n that analysis cannot over-approximate representation function (i.e.,\n we\n will have function calls treated as both nops and real calls in the\n representation function).}\n\\begin{itemize}\n\\item $L_i = \\locstate{c',m',\\mathit{pc}'}{\\mathit{st}'^*}{R'}{v^*}$ and $L_{i-1} = \\locstate{c,m,\\mathit{pc}}{\\mathit{st}^*}{R}{\\_}$ with $\\mathit{st}_{\\mathit{pc}} = \\invoke{r_o}{m'}{r_1',\\ldots,r_n'}$, \\\\ $\\textit{lookup}(\\gettype{H}{\\regval{r_o}},m') = (c',\\mathit{st}'^*)$, $\\textit{sign}(c',m') = \\methsign{\\tau_1,\\ldots,\\tau_n}{\\tau}{\\mathit{loc}}$ and $v^* = (\\regval{r_k'})^{k \\leq n}$\n\\item $L_i = \\locstate{c',m',\\mathit{pc}'}{\\mathit{st}'^*}{R'}{v^*}$ and $L_{i-1} = \\locstate{c,m,\\mathit{pc}}{\\mathit{st}^*}{R}{\\_}$ with $\\mathit{st}_{\\mathit{pc}} = \\sinvoke{c'}{m'}{r_1',\\ldots,r_n'}$, \\\\ $\\textit{lookup}(c',m') = (c',\\mathit{st}'^*)$, $\\textit{sign}(c',m') = \\methsign{\\tau_1,\\ldots,\\tau_n}{\\tau}{\\mathit{loc}}$ and $v^* = (\\regval{r_k'})^{k \\leq n}$.\n\\end{itemize}\n\\end{itemize} \n\\end{definition}\n\n\\begin{lemma}[Preserving Local Well-formation]\n\\label{lem:preserve-local}\nIf $\\Sigma$ is well-formed and $\\Sigma \\rightsquigarrow^* \\Sigma'$, then $\\Sigma'$ is well-formed.\n\\end{lemma}\n\\begin{IEEEproof}\nBy induction on the length of the reduction sequence and a case analysis on the last rule applied.\n\\end{IEEEproof}\n\n\\begin{definition}\nA heap $H$ is \\emph{well-typed} if and only if, whenever $H(\\ell) = \\obj{c}{(f_i \\mapsto v_i)^{i \\leq n}}$, for all $i \\in [1,n]$ we have $\\gettype{H}{v_i} \\leq \\tau_i$, where $\\tau_i$ is the declared type of field $f_i$ for an object of type $c$ according to the underlying program.\n\\end{definition}\n\n\\begin{assumption}[Java Type Soundness]\n\\label{asm:java-sound}\nIf $\\methconf{\\alpha}{\\pi}{H}{S}{\\ell} \\rightsquigarrow \\methconf{\\alpha'}{\\pi'}{H'}{S'}{\\ell}$, then for any value $v$ we have $\\gettype{H'}{v} \\leq \\gettype{H}{v}$. Moreover, if $H$ is well-typed, then also $H'$ is well-typed.\n\\end{assumption}\n\n\\begin{definition}\nA configuration $\\Psi = \\actconf{\\Omega}{H}{S}$ is \\emph{well-formed} if and only if:\n\\begin{itemize}\n\\item whenever $\\Omega = \\Omega_0 :: \\varphi :: \\Omega_1$ with $\\varphi \\in \\{\\actframe{\\ell}{s}{\\pi}{\\alpha},\\uactframe{\\ell}{s}{\\pi}{\\alpha}\\}$, we have $H(\\ell) = \\obj{c}{(f \\mapsto v)^*}$ for some activity class $c$ and $\\ell = \\pointer{p}{c}$ for some pointer $p$;\n\n\\item whenever $\\Omega = \\Omega_0 :: \\varphi :: \\Omega_1$ with $\\varphi \\in \\{\\actframe{\\ell}{s}{\\pi}{\\alpha},\\uactframe{\\ell}{s}{\\pi}{\\alpha}\\}$, we have that $\\Sigma = \\methconf{\\alpha}{\\pi}{H}{S}{\\ell}$ is a well-formed local configuration;\n\n\\item $H$ is a well-typed heap.\n\\end{itemize}\n\\end{definition}\n\n\\begin{lemma}[Preserving Well-formation]\n\\label{lem:preserve-well}\nIf $\\Psi$ is well-formed and $\\Psi \\Rightarrow^* \\Psi'$, then $\\Psi'$ is well-formed.\n\\end{lemma}\n\\begin{IEEEproof}\nBy induction on the length of the reduction sequence and a case analysis on the last rule applied, using Lemma~\\ref{lem:preserve-local} and Assumption~\\ref{asm:java-sound} to deal with case \\irule{A-Active}.\n\\end{IEEEproof}\nFrom now on, we tacitly focus only on well-formed configurations. All the formal results only apply to them: notice that well-formed configurations always reduce to well-formed configurations by Lemma~\\ref{lem:preserve-well}.\n\n\\subsubsection{Main Results}\n\n\\begin{lemma}\n\\label{lem:sub-order}\nIf $\\Delta \\subseteq \\Delta'$, then $\\Delta <: \\Delta'$.\n\\end{lemma}\n\n\\begin{lemma}\n\\label{lem:trans-order}\nIf $\\Delta <: \\Delta'$ and $\\Delta' <: \\Delta''$, then $\\Delta <: \\Delta''$.\n\\end{lemma}\n\n\\begin{lemma}\n\\label{lem:join-order}\nIf $\\Delta_1 <: \\Delta_2$ and $\\Delta_3 <: \\Delta_4$, then $\\Delta_1 \\cup \\Delta_3 <: \\Delta_2 \\cup \\Delta_4$.\n\\end{lemma}\n\n\\begin{assumption}[Soundness of the Abstract Operations]\n\\label{asm:sound-op}\nWe assume all the following properties:\n\\begin{itemize}\n\\item if $u \\varolessthan v$, then $\\hat{u}\\ \\hat{\\comp}\\ \\hat{v}$ for any $\\hat{u},\\hat{v}$ such that $\\hat{u} :> \\beta_{\\textit{Val}}(u)$ and $\\hat{v} :> \\beta_{\\textit{Val}}(v)$\n\\item for any $\\hat{v} :> \\beta_{\\textit{Val}}(v)$, we have $\\hat{\\odot} \\hat{v} :> \\beta_{\\textit{Val}}(\\odot v)$\n\\item for any $\\hat{u},\\hat{v}$ such that $\\hat{u} :> \\beta_{\\textit{Val}}(u)$ and $\\hat{v} :> \\beta_{\\textit{Val}}(v)$, we have $\\hat{u}\\ \\hat{\\oplus}\\ \\hat{v} :> \\beta_{\\textit{Val}}(u \\oplus v)$\n\\end{itemize}\n\\end{assumption}\n\n\\begin{assumption}[Overriding]\n\\label{asm:overriding}\nIf $\\textit{lookup}(c,m) = (c',\\mathit{st}^*)$, then $c \\leq c'$.\n\\end{assumption}\n\nIn the next results, let $\\Delta \\vdash \\Delta'$ whenever $\\Delta \\vdash \\mathsf{f}$ for each $\\mathsf{f} \\in \\Delta'$.\n\n\\begin{lemma}[Right-hand Sides]\n\\label{lem:rhs}\nLet $\\Sigma = \\methconf{\\alpha}{\\pi}{H}{S}{\\ell}$ with $\\alpha = \\locstate{\\mathit{pp}}{\\mathit{st}^*}{R}{u^*}$ and let $\\regval{\\mathit{rhs}} = v$, then for any $\\Delta :> \\beta_{\\textit{Lcnf}}(\\Sigma)$ there exists $\\hat{v}$ such that $\\beta_{\\textit{Val}}(v) \\sqsubseteq_{\\textit{Val}} \\hat{v}$ and $\\Delta \\cup \\arhs{\\mathit{rhs}} \\vdash \\prhs{\\hat{v}}$.\n\\end{lemma}\n\\begin{IEEEproof}\nBy a case analysis on the structure of $\\mathit{rhs}$.\n\\end{IEEEproof}\n\n\\begin{lemma}[Local Preservation]\n\\label{lem:local}\nIf $\\Sigma \\rightsquigarrow \\Sigma'$ under a given program $P$, then for any $\\Delta :> \\beta_{\\textit{Lcnf}}(\\Sigma)$ there exists $\\Delta' :> \\beta_{\\textit{Lcnf}}(\\Sigma')$ such that $\\translate{P} \\cup \\Delta \\vdash \\Delta'$.\n\\end{lemma}\n\\begin{IEEEproof}\n(Sketch) By a case analysis on the rule applied in the reduction step. The cases for the $\\texttt{move}$ instruction use Lemma~\\ref{lem:rhs}. The case for the $\\texttt{return}$ instruction exploits the (implicit) well-formation assumption of the local configuration $\\Sigma$. The case for the $\\texttt{invoke}$ instruction uses Assumption~\\ref{asm:overriding}. The cases for comparison operators and primitive operations exploit Assumption~\\ref{asm:sound-op}.\n\\end{IEEEproof}\n\n\\begin{lemma}[Serialization]\n\\label{lem:serialization}\nBoth the following statements hold true:\n\\begin{itemize}\n\\item if $\\serval{H}(v) = (v',H')$, then $\\beta_{\\textit{Val}}(v) = \\beta_{\\textit{Val}}(v')$\n\\item if $\\serblock{H}(b) = (b',H')$, then $\\beta_{\\textit{Blk}}(b) = \\beta_{\\textit{Blk}}(b')$\n\\end{itemize}\n\\end{lemma}\n\\begin{IEEEproof}\nIf $v = \\mathit{prim}$, then $v' = \\mathit{prim}$ and $\\beta_{\\textit{Val}}(v) = \\beta_{\\textit{Val}}(v') = \\beta_{\\textit{Prim}}(\\mathit{prim})$. If $v = \\pointer{p}{\\lambda}$, then $v' = \\pointer{p'}{\\lambda}$ for some pointer $p'$ and $\\beta_{\\textit{Val}}(v) = \\beta_{\\textit{Loc}}(\\pointer{p}{\\lambda}) = \\lambda = \\beta_{\\textit{Loc}}(\\pointer{p'}{\\lambda}) = \\beta_{\\textit{Val}}(v')$. The second point is a direct consequence of the first one.\n\\end{IEEEproof}\n\n\n\\MESSAGEIfor{MS}{151202}{New definition for the size function.}\n\\begin{definition}\nWe define a function $\\bvsize{H}$ which assigns to values and blocks a natural number as follows:\n\\begin{itemize}\n\\item $\\Gamma \\vdash \\bvsize{H}(\\mathit{prim}) = 1$\n\\item $\\ell \\notin \\Gamma; \\Gamma,\\ell \\vdash\n \\bvsize{H}(\\ell) = 1 + \\bvsize{H}(H(\\ell))$\n\\item $\\ell \\in \\Gamma; \\Gamma,\\ell \\vdash \\bvsize{H}(\\ell) = 0$\n\\item $\\Gamma \\vdash \\bvsize{H}(\\obj{c}{(f_i \\mapsto v_i)^*}) = 1 + \\sum_i \\bvsize{H}(v_i)$\n\\item $\\Gamma \\vdash \\bvsize{H}(\\intent{c}{(k_i \\mapsto v_i)^*}) = 1 + \\sum_i \\bvsize{H}(v_i)$\n\\item $\\Gamma \\vdash \\bvsize{H}(\\arr{\\tau}{v^*}) = 1 + \\sum_i \\bvsize{H}(v_i)$\n\\end{itemize}\n\\end{definition}\n\n\\begin{lemma}[Heap Serialization]\n\\label{lem:heap-serialization}\nIf $\\Delta :> \\beta_{\\textit{Heap}}(H)$, then:\n\\begin{itemize}\n\\item $\\serval{H}(v) = (v',H')$ implies $\\Delta :> \\beta_{\\textit{Heap}}(H')$\n\\item $\\serblock{H}(b) = (b',H')$ implies $\\Delta :> \\beta_{\\textit{Heap}}(H')$\n\\end{itemize}\n\\end{lemma}\n\\begin{IEEEproof}\nBy simultaneous induction on the size of the syntactic element in the\nantecedent. If $v = \\mathit{prim}$, then $H'$ is empty, hence\n$\\beta_{\\textit{Heap}}(H') = \\emptyset$ and we are done. If $v =\n\\pointer{p}{\\lambda}$, then $H' = H'',\\pointer{p'}{\\lambda} \\mapsto\nb$ with $\\serblock{H}(H(\\pointer{p}{\\lambda})) = (b, H'')$\nand $v' = \\pointer{p'}{\\lambda}$. By induction hypothesis $\\Delta :> \\beta_{\\textit{Heap}}(H'')$, so to conclude we just need to show that:\n\\[\n\\begin{array}{lcll}\n\\Delta & :> & \\beta_{\\textit{Heap}}(\\pointer{p'}{\\lambda} \\mapsto b) \\\\\n & = & \\{\\mathsf{H}(\\lambda,\\beta_{\\textit{Blk}}(b))\\} & \\text{by definition} \\\\\n & = & \\{\\mathsf{H}(\\lambda,\\beta_{\\textit{Blk}}(H(\\pointer{p}{\\lambda})))\\} & \\text{by Lemma~\\ref{lem:serialization}} \\\\\n & = & \\beta_{\\textit{Heap}}(\\pointer{p}{\\lambda} \\mapsto H(\\pointer{p}{\\lambda})) & \\text{by definition}\n\\end{array}\n\\]\nbut this follows from the hypothesis $\\Delta :> \\beta_{\\textit{Heap}}(H)$. The remaining cases for blocks follow by inductive hypothesis.\n\\end{IEEEproof}\n\n\\begin{theorem}[Preservation]\n\\label{trm:preservation}\nIf $\\Psi \\Rightarrow^* \\Psi'$ under a given program $P$, then there exists $\\Delta :> \\beta_{\\textit{Cnf}}(\\Psi')$ such that $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\Delta$.\n\\end{theorem}\n\\begin{IEEEproof}\nBy induction on the length of the reduction sequence. If the reduction sequence is empty, we have $\\Psi' = \\Psi$ and the result follows by picking $\\Delta = \\beta_{\\textit{Cnf}}(\\Psi)$. Otherwise, assume that $\\Psi \\Rightarrow^* \\actconf{\\Omega}{H}{S}$ in $n \\geq 0$ reduction steps and let $\\actconf{\\Omega}{H}{S} \\Rightarrow \\actconf{\\Omega'}{H'}{S'}$. By induction hypothesis there exists $\\Delta' :> \\beta_{\\textit{Cnf}}(\\actconf{\\Omega}{H}{S})$ such that $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\Delta'$, we show that there exists $\\Delta$ such that $\\Delta :> \\beta_{\\textit{Cnf}}(\\actconf{\\Omega'}{H'}{S'})$ and $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\Delta$. The proof is by a case analysis on the rule applied in the last reduction step:\n\\begin{itemize}\n\\item[\\irule{A-Active}]: let $\\Omega = \\Omega_0 :: \\uactframe{\\ell}{s}{\\pi}{\\alpha} :: \\Omega_1$ and $\\Omega' = \\Omega_0 :: \\uactframe{\\ell}{s}{\\pi'}{\\alpha'} :: \\Omega_1$ with $\\methconf{\\alpha}{\\pi}{H}{S}{\\ell} \\rightsquigarrow \\methconf{\\alpha'}{\\pi'}{H'}{S'}{\\ell}$. Since $\\beta_{\\textit{Lcnf}}(\\methconf{\\alpha}{\\pi}{H}{S}{\\ell}) \\subseteq \\beta_{\\textit{Cnf}}(\\actconf{\\Omega}{H}{S})$, we have $\\beta_{\\textit{Lcnf}}(\\methconf{\\alpha}{\\pi}{H}{S}{\\ell}) <: \\beta_{\\textit{Cnf}}(\\actconf{\\Omega}{H}{S})$ by Lemma~\\ref{lem:sub-order}. Since $\\beta_{\\textit{Lcnf}}(\\methconf{\\alpha}{\\pi}{H}{S}{\\ell}) <: \\beta_{\\textit{Cnf}}(\\actconf{\\Omega}{H}{S})$ and $\\beta_{\\textit{Cnf}}(\\actconf{\\Omega}{H}{S}) <: \\Delta'$, we get $\\beta_{\\textit{Lcnf}}(\\methconf{\\alpha}{\\pi}{H}{S}{\\ell}) <: \\Delta'$ by Lemma~\\ref{lem:trans-order}. \nHence, by Lemma~\\ref{lem:local} there exists $\\Delta'' :> \\beta_{\\textit{Lcnf}}(\\methconf{\\alpha'}{\\pi'}{H'}{S'}{\\ell})$ such that $\\translate{P} \\cup \\Delta' \\vdash \\Delta''$. By the weakening property of the logic, the latter implies $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\cup \\Delta' \\vdash \\Delta''$. Since we have $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\Delta'$ and $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\cup \\Delta' \\vdash \\Delta''$, we get $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\Delta''$ by the admissibility of the cut rule. Recall now that $\\Delta'' :> \\beta_{\\textit{Lcnf}}(\\methconf{\\alpha'}{\\pi'}{H'}{S'}{\\ell}) = \\beta_{\\textit{Call}}(\\alpha') \\cup \\rfdispatch{\\ell}(\\pi') \\cup \\beta_{\\textit{Heap}}(H') \\cup \\beta_{\\textit{Stat}}(S')$, so we have:\n\\begin{itemize}\n\\item[(1)] $\\Delta'' :> \\beta_{\\textit{Call}}(\\alpha')$\n\\item[(2)] $\\Delta'' :> \\rfdispatch{\\ell}(\\pi')$\n\\item[(3)] $\\Delta'' :> \\beta_{\\textit{Heap}}(H')$\n\\item[(4)] $\\Delta'' :> \\beta_{\\textit{Stat}}(S')$\n\\end{itemize}\nWe then observe that $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\Delta' :> \\beta_{\\textit{Cnf}}(\\actconf{\\Omega}{H}{S})$, which similarly implies:\n\\begin{itemize}\n\\item[(5)] $\\Delta' :> \\beta_{\\textit{Stk}}(\\Omega_0)$\n\\item[(6)] $\\Delta' :> \\beta_{\\textit{Stk}}(\\Omega_1)$\n\\end{itemize}\nCombining all these facts, we get $\\Delta' \\cup \\Delta'' :> \\beta_{\\textit{Cnf}}(\\actconf{\\Omega'}{H'}{S'})$ by Lemma~\\ref{lem:join-order}. Given that $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\Delta' \\cup \\Delta''$, we conclude the case;\n\n\\item[\\irule{A-Deactivate}]: in this case $\\beta_{\\textit{Cnf}}(\\actconf{\\Omega}{H}{S}) = \\beta_{\\textit{Cnf}}(\\actconf{\\Omega'}{H'}{S'})$, hence the conclusion immediately follows by the induction hypothesis;\n\n\\item[\\irule{A-Step}]: let $\\Omega = \\actframe{\\ell}{s}{\\pi}{\\overline{\\callstack}} :: \\Omega_0$ and $\\Omega' = \\uactframe{\\ell}{s'}{\\pi}{\\getcb{\\ell}{s'}} :: \\Omega_0$ for some $(s,s') \\in \\textit{Lifecycle}$, $H' = H$ and $S' = S$. Since $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\Delta' :> \\beta_{\\textit{Cnf}}(\\actconf{\\Omega}{H}{S})$, we have:\n\\begin{itemize}\n\\item[(1)] $\\Delta' :> \\beta_{\\textit{Stk}}(\\Omega_0)$\n\\item[(2)] $\\Delta' :> \\rfdispatch{\\ell}(\\pi)$\n\\end{itemize}\nSince we only focus on well-formed configurations, we have $H(\\ell) = \\obj{c}{(f \\mapsto u)^*}$ for some activity class $c$ and $\\ell = \\pointer{p}{c}$ for some pointer $p$. We then observe that $\\getcb{\\ell}{s'} = \\locstate{c',m,0}{\\mathit{st}^*}{R}{v^*} :: \\varepsilon$, where $(c',\\mathit{st}^*) = \\textit{lookup}(c,m)$ for some $m \\in \\mathit{cb}(c,s)$, $\\textit{sign}(c',m) = \\methsign{\\tau_1,\\ldots,\\tau_n}{\\tau}{\\mathit{loc}}$ and:\n\\[ \nR = ((r_i \\mapsto \\mathbf{0})^{i \\leq \\mathit{loc}}, r_{\\mathit{loc}+1} \\mapsto \\ell, (r_{\\mathit{loc}+1+j} \\mapsto v_j)^{j \\leq n}),\n\\]\nfor some values $v_1,\\ldots,v_n$ of the correct type $\\tau_1,\\ldots,\\tau_n$. By Assumption~\\ref{asm:overriding}, we also have $c \\leq c'$.\n\nGiven that $\\Delta' :> \\beta_{\\textit{Cnf}}(\\actconf{\\Omega}{H}{S})$, we have $\\Delta' :> \\beta_{\\textit{Heap}}(H)$, which implies that there exists $\\mathsf{H}(\\lambda,\\hat{b}) \\in \\Delta'$ such that $\\lambda = \\beta_{\\textit{Loc}}(\\ell) = c$ and $\\hat{b} \\sqsupseteq \\beta_{\\textit{Blk}}(\\obj{c}{(f \\mapsto u)^*})$. This implies that $\\hat{b} = \\absobj{c}{(f \\mapsto \\hat{v})^*}$ for some $v^*$ such that $\\forall i: \\hat{v}_i \\sqsupseteq \\beta_{\\textit{Val}}(u_i)$. Since $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\Delta'$ and $\\mathsf{H}(\\lambda,\\hat{b}) = \\mathsf{H}(c,\\absobj{c}{(f \\mapsto \\hat{v})^*}) \\in \\Delta'$, we have in particular $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\mathsf{H}(c,\\absobj{c}{(f \\mapsto \\hat{v})^*})$, hence:\n\\[\n\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\absreg{c',m,0}{(\\top_{\\tau_j})^{j \\leq n}}{(\\hat{\\mathbf{0}})^{k \\leq \\mathit{loc}},c,(\\top_{\\tau_j})^{j \\leq n}},\n\\]\nby using the implications $\\rulename{Cbk}$ included in $\\translate{P}$. We then observe that:\n\\[\n\\{\\absreg{c',m,0}{(\\top_{\\tau_j})^{j \\leq n}}{(\\hat{\\mathbf{0}})^{k \\leq \\mathit{loc}},c,(\\top_{\\tau_j})^{j \\leq n}}\\} :> \\beta_{\\textit{Call}}(\\getcb{\\ell}{s'})\n\\]\nBy combining (1), (2) and the last observation through Lemma~\\ref{lem:join-order} we then get:\n\\[\n\\{\\absreg{c',m,0}{(\\top_{\\tau_j})^{j \\leq n}}{(\\hat{\\mathbf{0}})^{k \\leq \\mathit{loc}},c,(\\top_{\\tau_j})^{j \\leq n}}\\} \\cup \\Delta' :> \\beta_{\\textit{Call}}(\\getcb{\\ell}{s'}) \\cup \\beta_{\\textit{Stk}}(\\Omega_0) \\cup \\rfdispatch{\\ell}(\\pi) = \\beta_{\\textit{Stk}}(\\Omega')\n\\]\nSince $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\{\\absreg{c',m,0}{(\\top_{\\tau_j})^{j \\leq n}}{(\\hat{\\mathbf{0}})^{k \\leq \\mathit{loc}},c,(\\top_{\\tau_j})^{j \\leq n}}\\} \\cup \\Delta'$, we conclude the case;\n\n\\item[\\irule{A-Destroy}]: in this case $\\beta_{\\textit{Cnf}}(\\actconf{\\Omega'}{H'}{S'}) \\subseteq \\beta_{\\textit{Cnf}}(\\actconf{\\Omega}{H}{S})$, hence $\\beta_{\\textit{Cnf}}(\\actconf{\\Omega'}{H'}{S'}) <: \\beta_{\\textit{Cnf}}(\\actconf{\\Omega}{H}{S})$ by Lemma~\\ref{lem:sub-order}. Since $\\beta_{\\textit{Cnf}}(\\actconf{\\Omega'}{H'}{S'}) <: \\beta_{\\textit{Cnf}}(\\actconf{\\Omega}{H}{S})$ and $\\beta_{\\textit{Cnf}}(\\actconf{\\Omega}{H}{S}) <: \\Delta'$, we have $\\beta_{\\textit{Cnf}}(\\actconf{\\Omega'}{H'}{S'}) <: \\Delta'$ by Lemma~\\ref{lem:trans-order}. Given that $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\Delta'$, we conclude the case;\n\n\\item[\\irule{A-Back}]: let $\\Omega' = \\Omega = \\actframe{\\ell}{\\actstate{running}}{\\varepsilon}{\\overline{\\callstack}} :: \\Omega_0$, $H' = H[\\ell \\mapsto H(\\ell) [\\textit{finished} \\mapsto \\mathtt{true}]]$ and $S' = S$. Let $b = H(\\ell)$. Since we only focus on well-formed configurations, we have $b = \\obj{c}{(f \\mapsto u)^*,\\textit{finished} \\mapsto v}$ for some activity class $c$ and some boolean value $v$. Let then $b' = H'(\\ell) = \\obj{c}{(f \\mapsto u)^*,\\textit{finished} \\mapsto \\mathtt{true}}$ according to the reduction rule. \n\nGiven that $\\Delta' :> \\beta_{\\textit{Cnf}}(\\actconf{\\Omega}{H}{S})$, we have $\\Delta' :> \\beta_{\\textit{Heap}}(H)$, which implies that there exists $\\mathsf{H}(\\lambda,\\hat{b}) \\in \\Delta'$ such that $\\lambda = \\beta_{\\textit{Loc}}(\\ell)$ and $\\hat{b} \\sqsupseteq \\beta_{\\textit{Blk}}(b)$. This means that $\\hat{b} = \\absobj{c}{(f \\mapsto \\hat{u})^*,\\textit{finished} \\mapsto \\hat{v}}$ for some $u^*,v$ such that $\\forall i: \\hat{u}_i \\sqsupseteq \\beta_{\\textit{Val}}(u)$ and $\\hat{v} \\sqsupseteq \\beta_{\\textit{Val}}(v)$. We then observe that:\n\\[\n\\beta_{\\textit{Blk}}(b') = \\absobj{c}{(f \\mapsto \\beta_{\\textit{Val}}(u))^*, \\textit{finished} \\mapsto \\widehat{\\mathtt{true}}}\n\\]\n\nSince $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\Delta'$ and $\\mathsf{H}(\\lambda,\\hat{b}) \\in \\Delta'$, we have in particular $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\mathsf{H}(\\lambda,\\hat{b})$, hence:\n\\[\n\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\mathsf{H}(\\lambda,\\absobj{c}{(f \\mapsto \\hat{u})^*,\\textit{finished} \\mapsto \\top_{\\type{bool}}}),\n\\]\nby using the implication $\\rulename{Fin}$ included in $\\translate{P}$. We then observe that:\n\\[\n\\begin{array}{lcll}\n\\mathsf{H}(\\lambda,\\absobj{c}{(f \\mapsto \\hat{u})^*,\\textit{finished} \\mapsto \\top_{\\type{bool}}}) & \\sqsupseteq & \\mathsf{H}(\\lambda,\\absobj{c}{(f \\mapsto \\hat{u})^*,\\textit{finished} \\mapsto \\widehat{\\mathtt{true}}}) \\\\\n& = & \\mathsf{H}(\\beta_{\\textit{Loc}}(\\ell),\\absobj{c}{(f \\mapsto \\hat{u})^*,\\textit{finished} \\mapsto \\widehat{\\mathtt{true}}}) \\\\\n& \\sqsupseteq & \\mathsf{H}(\\beta_{\\textit{Loc}}(\\ell), \\beta_{\\textit{Blk}}(b'))\n\\end{array}\n\\]\nHence, $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\Delta' \\cup \\{\\mathsf{H}(\\lambda,\\absobj{c}{(f \\mapsto \\hat{u})^*,\\textit{finished} \\mapsto \\top_{\\type{bool}}})\\} :> \\beta_{\\textit{Heap}}(H')$, which is enough to conclude the case;\n\n\\item[\\irule{A-Replace}]: let $\\Omega = \\actframe{\\ell}{\\actstate{onDestroy}}{\\pi}{\\overline{\\callstack}} :: \\Omega_0$ and $\\Omega' = \\uactframe{\\pointer{p}{c}}{\\actstate{constructor}}{\\pi}{\\getcb{\\pointer{p}{c}}{\\actstate{constructor}}} :: \\Omega_0$ with $H(\\ell) = \\obj{c}{(f \\mapsto v)^*,\\textit{finished} \\mapsto u}$, $H' = H, \\pointer{p}{c} \\mapsto o$ with $o = \\obj{c}{(f \\mapsto \\mathbf{0}_{\\tau})^*,\\textit{finished} \\mapsto \\mathtt{false}}$, and $S' = S$. Since we only focus on well-formed configurations, we know that $c$ is an activity class and $\\ell = \\pointer{p'}{c}$ for some pointer $p'$.\n\nGiven that $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\Delta':> \\beta_{\\textit{Cnf}}(\\actconf{\\Omega}{H}{S})$, we have:\n\\begin{itemize}\n\\item[(1)] $\\Delta' :> \\rfdispatch{\\ell}(\\pi)$\n\\item[(2)] $\\Delta' :> \\beta_{\\textit{Stk}}(\\Omega_0)$\n\\end{itemize}\nSince $\\beta_{\\textit{Loc}}(\\ell) = \\beta_{\\textit{Loc}}(\\pointer{p'}{c}) = \\beta_{\\textit{Loc}}(\\pointer{p}{c})$, from (1) we get:\n\\begin{itemize}\n\\item[(3)] $\\Delta' :> \\rfdispatch{\\pointer{p}{c}}(\\pi)$\n\\end{itemize}\nWe then observe that $\\getcb{\\pointer{p}{c}}{\\actstate{constructor}} = \\locstate{c',m,0}{\\mathit{st}^*}{R}{v^*} :: \\varepsilon$, where $(c',\\mathit{st}^*) = \\textit{lookup}(c,\\actstate{constructor})$, $\\textit{sign}(c',\\actstate{constructor}) = \\methsign{\\tau_1,\\ldots,\\tau_n}{\\tau}{\\mathit{loc}}$ and:\n\\[ \nR = ((r_i \\mapsto \\mathbf{0})^{i \\leq \\mathit{loc}}, r_{\\mathit{loc}+1} \\mapsto \\pointer{p}{c}, (r_{\\mathit{loc}+1+j} \\mapsto v_j')^{j \\leq n}),\n\\]\nfor some values $v_1',\\ldots,v_n'$ of the correct type $\\tau_1,\\ldots,\\tau_n$. By Assumption~\\ref{asm:overriding}, we also have $c \\leq c'$.\n\nGiven that $\\Delta' :> \\beta_{\\textit{Cnf}}(\\actconf{\\Omega}{H}{S})$, we have $\\Delta' :> \\beta_{\\textit{Heap}}(H)$, which implies that there exists $\\mathsf{H}(\\lambda,\\hat{b}) \\in \\Delta'$ such that $\\lambda = \\beta_{\\textit{Loc}}(\\ell) = c$ and $\\hat{b} \\sqsupseteq \\beta_{\\textit{Blk}}(H(\\ell))$. This implies that $\\hat{b} = \\absobj{c}{(f \\mapsto \\hat{v})^*,\\textit{finished} \\mapsto \\hat{u}}$ for some $\\hat{v}^*,\\hat{u}$ such that $\\forall i: \\hat{v}_i \\sqsupseteq \\beta_{\\textit{Val}}(v_i)$ and $\\hat{u} \\sqsupseteq \\beta_{\\textit{Val}}(u)$. Since $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\Delta'$ and $\\mathsf{H}(\\lambda,\\hat{b}) \\in \\Delta'$, we have in particular $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\mathsf{H}(\\lambda,\\hat{b}) = \\mathsf{H}(c, \\absobj{c}{(f \\mapsto \\hat{v})^*,\\textit{finished} \\mapsto \\hat{u}})$, hence:\n\\[\n\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\absreg{c',m,0}{(\\top_{\\tau_j})^{j \\leq n}}{(\\hat{\\mathbf{0}})^{k \\leq \\mathit{loc}},c,(\\top_{\\tau_j})^{j \\leq n}},\n\\]\nby using the implications $\\rulename{Cbk}$ included in $\\translate{P}$. We then observe that:\n\\[\n\\{\\absreg{c',m,0}{(\\top_{\\tau_j})^{j \\leq n}}{(\\hat{\\mathbf{0}})^{k \\leq \\mathit{loc}},c,(\\top_{\\tau_j})^{j \\leq n}}\\} :> \\beta_{\\textit{Call}}(\\getcb{\\pointer{p}{c}}{\\actstate{constructor}})\n\\]\nBy combining (2), (3) and the last observation through Lemma~\\ref{lem:join-order} we then get:\n\\[\n\\{\\absreg{c',m,0}{(\\top_{\\tau_j})^{j \\leq n}}{(\\hat{\\mathbf{0}})^{k \\leq \\mathit{loc}},c,(\\top_{\\tau_j})^{j \\leq n}}\\} \\cup \\Delta' :> \\beta_{\\textit{Call}}(\\getcb{\\pointer{p}{c}}{\\actstate{constructor}}) \\cup \\beta_{\\textit{Stk}}(\\Omega_0) \\cup \\rfdispatch{\\pointer{p}{c}}(\\pi) = \\beta_{\\textit{Stk}}(\\Omega')\n\\]\nSince $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\{\\absreg{c',m,0}{(\\top_{\\tau_j})^{j \\leq n}}{(\\hat{\\mathbf{0}})^{k \\leq \\mathit{loc}},c,(\\top_{\\tau_j})^{j \\leq n}}\\} \\cup \\Delta'$, we proved that the change to the activity stack is correctly over-approximated.\n\nTo conclude, we need to deal with the change to the heap. We first observe that $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\Delta' :> \\beta_{\\textit{Cnf}}(\\actconf{\\Omega}{H}{S})$ and $\\beta_{\\textit{Cnf}}(\\actconf{\\Omega}{H}{S}) :> \\beta_{\\textit{Heap}}(H)$, hence:\n\\begin{itemize}\n\\item[(4)] $\\Delta':> \\beta_{\\textit{Heap}}(H)$\n\\end{itemize}\nSince $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\mathsf{H}(\\lambda,\\hat{b}) = \\mathsf{H}(c, \\absobj{c}{(f \\mapsto \\hat{v})^*,\\textit{finished} \\mapsto \\hat{u}})$, we have\\footnote{We assume here that boolean fields are initialized to $\\mathtt{false}$. The proof can be adapted to the case where they are initialized to $\\mathtt{true}$ by using the implication in rule $\\rulename{Fin}$.}:\n\\[\n\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\mathsf{H}(c,\\absobj{c}{(f \\mapsto \\hat{\\mathbf{0}}_{\\tau})^*,\\textit{finished} \\mapsto \\widehat{\\mathtt{false}}})),\n\\]\nby using the implication $\\rulename{Rep}$. We then observe that:\n\\[\n\\{\\mathsf{H}(c,\\absobj{c}{(f \\mapsto \\hat{\\mathbf{0}}_{\\tau})^*,\\textit{finished} \\mapsto \\widehat{\\mathtt{false}}}))\\} :> \\beta_{\\textit{Heap}}(\\pointer{p}{c} \\mapsto o).\n\\]\nBy combining (4) with the latter observation by Lemma~\\ref{lem:join-order}, we get:\n\\[\n\\Delta' \\cup \\{\\mathsf{H}(c,\\absobj{c}{(f \\mapsto \\hat{\\mathbf{0}}_{\\tau})^*,\\textit{finished} \\mapsto \\widehat{\\mathtt{false}}}))\\} :> \\beta_{\\textit{Heap}}(H')\n\\]\nSince $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\Delta' \\cup \\{\\mathsf{H}(c,\\absobj{c}{(f \\mapsto \\hat{\\mathbf{0}}_{\\tau})^*,\\textit{finished} \\mapsto \\widehat{\\mathtt{false}}}))\\}$, we proved that also the change to the heap is over-approximated correctly;\n\n\\item[\\irule{A-Hidden}]: analogous to case \\irule{A-Step};\n\n\\item[\\irule{A-Start}]: let $\\Omega = \\actframe{\\ell}{s}{i :: \\pi}{\\overline{\\callstack}} :: \\Omega_0$ and $\\Omega' = \\uactframe{\\pointer{p}{c}}{\\actstate{constructor}}{\\varepsilon}{\\getcb{\\pointer{p}{c}}{\\actstate{constructor}}} :: \\actframe{\\ell}{s}{\\pi}{\\overline{\\callstack}} :: \\Omega_0$ with $i = \\intent{c}{(k \\mapsto v)^*}$. Also, let $S' = S$ and $H' = H,H'',\\pointer{p}{c} \\mapsto o, \\pointer{p'}{\\astart{c}} \\mapsto i'$ with $\\serblock{H}(i) = (i',H'')$ and $o = \\obj{c}{(f \\mapsto \\mathbf{0}_{\\tau})^*,\\textit{finished} \\mapsto \\mathtt{false}, \\textit{intent} \\mapsto \\pointer{p'}{\\astart{c}}, \\textit{parent} \\mapsto \\ell}$. Since we only focus on well-formed configurations, we know that $\\ell = \\pointer{p'}{c'}$ for some pointer $p'$ and some activity class $c'$.\n\nGiven that $\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\Delta':> \\beta_{\\textit{Cnf}}(\\actconf{\\Omega}{H}{S})$, we have $\\Delta' :> \\rfdispatch{\\ell}(i :: \\pi)$, which implies that there exists $\\mathsf{I}(\\lambda,\\hat{b}) \\in \\Delta'$ such that $\\lambda = \\beta_{\\textit{Loc}}(\\ell) = c'$ and $\\hat{b} \\sqsupseteq \\beta_{\\textit{Blk}}(i)$. This implies that $\\hat{b} = \\absintent{c}{\\hat{v}}$ for some $\\hat{v}$ such that $\\hat{v} \\sqsupseteq \\sqcup_i\\, \\beta_{\\textit{Val}}(v_i)$. We then have:\n\\[\n\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\mathsf{H}(\\astart{c},\\absintent{c}{\\hat{v}}),\n\\]\nand:\n\\[\n\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\mathsf{H}(c, \\absobj{c}{(f \\mapsto \\hat{\\mathbf{0}}_{\\tau})^*, \\textit{finished} \\mapsto \\widehat{\\mathtt{false}}, \\textit{parent} \\mapsto c', \\textit{intent} \\mapsto \\astart{c}}),\n\\]\nby using the implications $\\rulename{Act}$ included in $\\translate{P}$. Using the latter fact and the implications $\\rulename{Cbk}$, we can prove that the change to the activity stack is over-approximated correctly, similarly to what we did in case \\irule{A-Replace}: we omit details.\n\nWe focus instead on the changes to the heap. Since $\\Delta' :> \\beta_{\\textit{Heap}}(H)$ and $\\serblock{H}(i) = (i',H'')$, we know that $\\Delta' :> \\beta_{\\textit{Heap}}(H'')$ by Lemma~\\ref{lem:heap-serialization}. We then observe that:\n\\[\n\\{\\mathsf{H}(c, \\absobj{c}{(f \\mapsto \\hat{\\mathbf{0}}_{\\tau})^*, \\textit{finished} \\mapsto \\widehat{\\mathtt{false}}, \\textit{parent} \\mapsto c', \\textit{intent} \\mapsto \\astart{c}})\\} = \\beta_{\\textit{Heap}}(\\pointer{p}{c} \\mapsto o)\n\\]\nFinally, we notice that:\n\\[\n\\begin{array}{lcll}\n\\{\\mathsf{H}(\\astart{c},\\absintent{c}{\\hat{v}})\\} & :> & \\{\\mathsf{H}(\\astart{c},\\beta_{\\textit{Blk}}(i)\\} & \\text{since } \\hat{b} = \\absintent{c}{\\hat{v}}) \\sqsupseteq \\beta_{\\textit{Blk}}(i) \\\\\n& = & \\beta_{\\textit{Heap}}(\\pointer{p'}{\\astart{c}} \\mapsto i) & \\text{by definition} \\\\\n& = & \\beta_{\\textit{Heap}}(\\pointer{p'}{\\astart{c}} \\mapsto i') & \\text{by Lemma~\\ref{lem:serialization}}\n\\end{array}\n\\]\nBy combining all these observations, we prove that the new heap is over-approximated correctly;\n\n\\item[\\irule{A-Swap}]: in this case $\\beta_{\\textit{Cnf}}(\\actconf{\\Omega}{H}{S}) = \\beta_{\\textit{Cnf}}(\\actconf{\\Omega'}{H'}{S'})$, hence the conclusion immediately follows by the induction hypothesis;\n\n\\item[\\irule{A-Result}]: let:\n\\[\n\\Omega = \\actframe{\\ell'}{\\actstate{onPause}}{\\varepsilon}{\\overline{\\callstack}'} :: \\actframe{\\ell}{s}{\\varepsilon}{\\overline{\\callstack}} :: \\Omega_0,\n\\]\nand: \n\\[\n\\Omega' = \\uactframe{\\ell}{s}{\\varepsilon}{\\getcb{\\ell}{\\actstate{onActivityResult}}} :: \\actframe{\\ell'}{\\actstate{onPause}}{\\varepsilon}{\\overline{\\callstack}'} :: \\Omega_0,\n\\]\nwith $H(\\ell').\\textit{parent} = \\ell$. Also, let $S' = S$ and $H' = (H,H'')[\\ell \\mapsto H(\\ell)[\\textit{result} \\mapsto \\ell'']]$ with: \n\\[\n\\serval{H}(H(\\ell').\\textit{result}) = (\\ell'',H'').\n\\]\nSince we focus only on well-formed configurations, we have $\\ell = \\pointer{p}{c}$ and $\\ell' = \\pointer{p'}{c'}$ for some pointers $p,p'$ and some activity classes $c,c'$. Also, let $H(\\ell) = \\obj{c}{(f \\mapsto \\hat{v})^*}$ and $H(\\ell') = \\obj{c'}{(f' \\mapsto \\hat{v}')^*, \\textit{parent} \\mapsto \\ell}$. Since $H(\\ell) = \\obj{c}{(f \\mapsto \\hat{v})^*}$, to prove that the changes to the activity stack are correctly over-approximated we can proceed like in case \\irule{A-Step}, using the implications in \\rulename{Cbk}: we omit details.\n\nWe focus instead on the changes to the heap. Since $\\Delta' :> \\beta_{\\textit{Cnf}}(\\actconf{\\Omega}{H}{S})$, we have in particular:\n\\begin{itemize}\n\\item[(1)] $\\Delta' :> \\beta_{\\textit{Heap}}(H)$\n\\end{itemize}\nBy (1) and $\\serval{H}(H(\\ell').\\textit{result}) = (\\ell'',H'')$, using Lemma~\\ref{lem:heap-serialization}, we prove:\n\\begin{itemize}\n\\item[(2)] $\\Delta' :> \\beta_{\\textit{Heap}}(H'')$ \n\\end{itemize}\nAgain by (1), there exists $\\mathsf{H}(\\lambda,\\hat{b}) \\in \\Delta'$ such that $\\lambda = \\beta_{\\textit{Loc}}(\\ell) = c$ and $\\hat{b} \\sqsupseteq \\beta_{\\textit{Blk}}(H(\\ell))$. This implies that $\\hat{b} = \\absobj{c}{(f \\mapsto \\hat{v})^*}$ for some $\\hat{v}^*$ s.t. $\\forall i: \\hat{v}_i \\sqsupseteq \\beta_{\\textit{Val}}(v_i)$. Similarly, we show that there exists $\\mathsf{H}(\\lambda',\\hat{b}') \\in \\Delta'$ s.t. $\\lambda' = \\beta_{\\textit{Loc}}(\\ell') = c'$ and $\\hat{b}' \\sqsupseteq \\beta_{\\textit{Blk}}(H(\\ell'))$, and $\\hat{b}' = \\absobj{c'}{(f' \\mapsto \\hat{v}')^*,\\textit{parent} \\mapsto c,\\textit{result} \\mapsto \\lambda''}$ for some $\\hat{v}'^*,\\lambda''$ such that $\\forall i: \\hat{v}_i' \\sqsupseteq \\beta_{\\textit{Val}}(v_i')$ and $\\lambda'' = \\beta_{\\textit{Loc}}(H(\\ell').\\textit{result})$. Hence, we have:\n\\[\n\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\mathsf{H}(c,\\absobj{c}{(f \\mapsto \\hat{v})^*}) \\wedge \\mathsf{H}(c',\\absobj{c'}{(f' \\mapsto \\hat{v}')^*,\\textit{parent} \\mapsto c}),\n\\]\nwhich allows us to prove:\n\\[\n\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\mathsf{H}(c,\\absobj{c}{(f \\mapsto \\hat{v})^*[\\textit{result} \\mapsto \\lambda'']}),\n\\]\nby using the implication $\\rulename{Res}$. We then observe that:\n\\[\n\\begin{array}{lcll}\n\\{\\mathsf{H}(c,\\absobj{c}{(f \\mapsto \\hat{v})^*[\\textit{result} \\mapsto \\lambda'']})\\} & :> & \\beta_{\\textit{Heap}}(\\ell \\mapsto H(\\ell)[\\textit{result} \\mapsto H(\\ell').\\textit{result}]) & \\text{by definition} \\\\\n& = & \\beta_{\\textit{Heap}}(\\ell \\mapsto H(\\ell)[\\textit{result} \\mapsto \\ell'']) & \\text{by Lemma~\\ref{lem:serialization}}\n\\end{array}\n\\]\nSince $H' = (H,H'')[\\ell \\mapsto H(\\ell)[\\textit{result}\n\\mapsto \\ell'']] = H[\\ell \\mapsto H(\\ell)[\\textit{result} \\mapsto\n\\ell'']],H''$, by combining (1), (2) and the last observation\nusing Lemma~\\ref{lem:join-order}, we conclude as follows:\n\\[\n\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\Delta' \\cup \\{\\mathsf{H}(c,\\absobj{c}{(f \\mapsto \\hat{v})^*[\\textit{result} \\mapsto \\lambda'']})\\} :> \\beta_{\\textit{Heap}}(H')\n\\]\n\\end{itemize}\n\\end{IEEEproof}\n\n\n\n\n\\subsection{Overview}\nThe analysis is based on the syntactic categories in Table~\\ref{tab:absdoms}. We start by discussing how values are approximated. We presuppose the existence of an arbitrary set of abstract domains used to approximate primitive values: for each primitive value $\\mathit{prim}$, we assume that there exists a corresponding abstraction $\\widehat{\\prim}$, e.g., integer numbers could be approximated by their sign. Locations of the form $\\ell = \\pointer{p}{\\lambda}$, instead, are abstracted into their annotation $\\lambda$. An \\emph{abstract value} $\\hat{v}$ is a set of elements drawn from either the abstract domains or the set of annotations.\n\n\\begin{table*}[htb]\n\\begin{mathpar}\n\\begin{array}{llcl}\n\\text{Facts} & \\mathsf{f} & ::= & \\\\\n\\text{Abs. registers} & & | & \\absreg{\\mathsf{pp}}{t^*}{t^*} \\\\\n\\text{Abs. heap entries} & & | & \\mathsf{H}(t,t') \\\\\n\\text{Abs. static fields} & & | & \\mathsf{S}_{\\mathsf{c},\\mathsf{f}}(t) \\\\\n\\text{Abs. right-hand sides} & & | & \\prhs{t} \\\\\n\\text{Abs. results} & & | & \\absresult{\\mathsf{c},\\mathsf{m}}{t^*}{t} \\\\\n\\text{Abs. pending activities} & & | & \\mathsf{I}(t,t') \\\\\n\\text{Set membership} & & | & t \\in t' \\\\\n\\text{Subtyping} & & | & t \\leq t' \\\\\n\\text{Horn clauses} & & | & \\forall x^*.\\bigwedge_i \\mathsf{f}_i \\implies \\mathsf{f} \\\\\n\\text{Abs. programs} & \\Delta & ::= & \\{\\mathsf{f}_1,\\ldots,\\mathsf{f}_n\\}\n\\end{array}\n\\begin{array}{llcl}\n\\text{Abs. values} & \\hat{u},\\hat{v} & ::= & \\emptyset ~|~ \\{\\widehat{\\prim}\\} ~|~ \\{\\lambda\\} ~|~ \\hat{v} \\cup \\hat{v} \\\\\n\\text{Abs. objects} & \\hat{o} & ::= & \\absobj{c}{(f_{\\tau} \\mapsto \\hat{v})^*} \\\\\n\\text{Abs. arrays} & \\hat{a} & ::= & \\absarray{\\tau}{\\hat{v}} \\\\\n\\text{Abs. intents} & \\hat{i} & ::= & \\absintent{c}{\\hat{v}} \\\\\n\\text{Abs. mem. blocks} & \\hat{b} & ::= & \\hat{o} ~|~ \\hat{a} ~|~ \\hat{i} \\\\\n\\\\\n\\text{Variables} & x,y & \\in & \\textit{Vars} \\\\\n\\text{Constants} & \\const{k} & ::= & \\hat{v} ~|~ \\hat{b} ~|~ \\tau ~|~ \\lambda \\\\\n\\text{Terms} & t & ::= & \\const{k} ~|~ x ~|~ \\astart{t}\n\\end{array}\n\\end{mathpar}\n\\caption{Abstract Domains and Analysis Facts}\n\\label{tab:absdoms}\n\\end{table*}\n\nThe different forms of annotations $\\lambda$ provide insight on different\naspects of the static analysis. Program point annotations $\\mathit{pp} =\nc,m,\\mathit{pc}$ are used to represent pointers to memory blocks instantiated\nusing the statements \\texttt{new}, \\texttt{newarray} and\n\\texttt{newintent}: by abstracting these elements with the program\npoint where they are created, we implement a\n\\emph{plain-object-sensitive} static\nanalysis~\\cite{Smaragdakis:2011:PYC:1926385.1926390}. {We chose it because it is \nwell-understood and convenient to both formalize and\npresent: we plan to integrate more advanced analyses like 2full+1H in\nfuture releases. Class name \n annotations $c$, instead, are used to represent activities in an \n object-insensitive way: different activities of the same class $c$ are all \n abstracted by the annotation $c$, since it is generally hard to statically \n discriminate between different activity instances. Finally, we use the annotation \n $\\astart{c}$ to abstract all the intents which are used to start an activity of class \n $c$.\n\nComing to memory blocks, our analysis is field-sensitive on objects, but field-insensitive on both arrays and intents. It is easier to implement field-sensitivity for objects, since field names are statically known in Java. Implementing field-sensitivity for arrays would require precise information on array bounds and indexes; intents, instead, would need an accurate string analysis, to deal with their dictionary-like programming patterns. It would be possible to leverage existing proposals~\\cite{DilligDA11} to implement a more precise analysis in terms of field-sensitivity, but we propose a simpler framework here to focus on the Android-specific aspects of the analysis. Notice that, just like the objects they approximate, abstract objects $\\hat{o}$ feature type annotations on their fields, which are omitted when unimportant. \n\nAbstract values and abstract memory blocks, plus all the types available in the analysed program and the annotations, determine a universe of \\emph{constants}, ranged over by $\\const{k}$. A \\emph{term} $t$ is either a constant $\\const{k}$, a variable $x$ drawn from a denumerable set $\\textit{Vars}$ disjoint from the set of constants, or an expression of the form $\\astart{t'}$ for some term $t'$. The set of terms is used to define the syntax of \\emph{facts} $\\mathsf{f}$, logical formulas built on selected predicate symbols used by the analysis.\n\nThe fact $\\absreg{\\mathsf{c},\\mathsf{m},\\mathsf{pc}}{\\hat{u}^*}{\\hat{v}^*}$ states that, whenever the method $m$ of class $c$ is invoked with some arguments over-approximated by $\\hat{u}^*$, the state of the local registers at the $\\mathit{pc}$-th statement is over-approximated by $\\hat{v}^*$. The syntax of the fact highlights that: (1) the analysis is flow-sensitive for register values, since it computes different static approximations at different program points, and (2) method invocations are handled in a context-sensitive way, where the notion of context coincides with the (abstraction of) the actual arguments supplied to the method upon invocation. The fact $\\mathsf{H}(\\lambda,\\hat{b})$ states that some location $\\pointer{p}{\\lambda}$ refers to a heap element storing a memory block over-approximated by $\\hat{b}$ at some point of the program execution. Notice that the fact does not contain any program point information, i.e., the analysis is flow-insensitive for heap locations, which is important for soundness (see Section~\\ref{sec:examples}). Similarly, the fact $\\mathsf{S}_{\\mathsf{c},\\mathsf{f}}(\\hat{v})$ states that the static field $f$ of class $c$ contains a value which is over-approximated by $\\hat{v}$ at some point of the program execution. The fact $\\prhs{\\hat{v}}$ states that the right-hand side of the \\texttt{move} statement at program point $\\mathit{pp}$ evaluates to a value over-approximated by $\\hat{v}$. The fact $\\absresult{\\mathsf{c},\\mathsf{m}}{\\hat{u}^*}{\\hat{v}}$ states that, whenever the method $m$ of class $c$ is invoked with some arguments over-approximated by $\\hat{u}^*$, its return value is over-approximated by $\\hat{v}$. The fact $\\mathsf{I}(c,\\hat{i})$ tracks that an activity of class $c$ has sent an intent which is over-approximated by $\\hat{i}$. We then have set membership facts $t \\in t'$ and subtyping facts $\\tau \\leq \\tau'$ with the obvious meaning. \n\nFinally, Horn clauses define the abstract semantics of programs. A Horn clause has the form:\n\\[ \n\\forall x_1,\\ldots,\\forall x_m.\\mathsf{f}_1 \\wedge \\ldots \\wedge \\mathsf{f}_n \\implies \\mathsf{f},\n\\]\nwhere all the variables of $\\mathsf{f}_1,\\ldots,\\mathsf{f}_n,\\mathsf{f}$ belong to $\\{x_1,\\ldots,x_m\\}$ and each variable of $\\mathsf{f}$ occurs among the variables of $\\mathsf{f}_1,\\ldots,\\mathsf{f}_n$. Since most of the Horn clauses we present do not make use of constants, to improve readability we omit the universal quantifiers in front of Horn clauses and we just represent each variable occurring therein with a constant of the expected type. The few exceptions where constants are actually used are disambiguated using a $\\mathsf{sans\\ serif}$ font, e.g., we use $\\const{c}$ to denote the constant corresponding to the activity class $c$ specifically, rather than some universally quantified variable standing for an arbitrary activity class. We let an underscore (\\_) stand for any syntactic element occurring in a Horn clause which is not significant to understanding.\n\n\\subsection{Analysis Specification}\n\n\\subsubsection{Abstract Semantics of Dalvik}\nWe start by presenting the abstract evaluation rules for right-hand sides, which are simple and provide a good intuition on how the static analysis works. These rules are given in Table~\\ref{tab:abs-rhs}.\n\n\\begin{table*}[htb]\n\\begin{mathpar}\n\\arhs{\\mathit{prim}} = \\{\\prhs{\\{\\widehat{\\prim}\\}}\\}\n\n\\arhs{r_i} = \\{\\absreg{\\mathsf{pp}}{ \\_ }{\\hat{v}^*} \\implies \\prhs{\\hat{v}_i }\\}\n\n\\arhs{c.f} = \\{\\mathsf{S}_{\\mathsf{c},\\mathsf{f}}(\\hat{v}) \\implies \\prhs{\\hat{v}}\\}\n\n\\arhs{r_i.f} = \\{\\absreg{\\mathsf{pp}}{ \\_ }{\\hat{v}^*} \\wedge \\lambda \\in \\hat{v}_i \\wedge \\mathsf{H}(\\lambda,\\absobj{c}{(f' \\mapsto \\hat{v}')^*, f \\mapsto \\hat{u}}) \\implies \\prhs{\\hat{u}}\\}\n\n\\arhs{r_i[r_j]} = \\{\\absreg{\\mathsf{pp}}{ \\_ }{\\hat{v}^*} \\wedge \\lambda \\in \\hat{v}_i \\wedge \\mathsf{H}(\\lambda, \\absarray{\\tau}{\\hat{u}}) \\implies \\prhs{\\hat{u}}\\}\n\\end{mathpar}\n\\caption{Abstract Evaluation of Right-hand Sides}\n\\label{tab:abs-rhs}\n\\end{table*}\n\nTo abstract a primitive value $\\mathit{prim}$ at any program point $\\mathit{pp}$, we just pick the corresponding element $\\widehat{\\prim}$ from the underlying abstract domain. To abstract the content of the register $r_i$ at program point $\\mathit{pp}$, we take the fact $\\absreg{\\mathsf{pp}}{ \\_ }{\\hat{v}^*}$ and we return the $i$-th abstract value $\\hat{v}_i$. To abstract the content of a static field $c.f$ at any program point, we take any fact $\\mathsf{S}_{\\mathsf{c},\\mathsf{f}}(\\hat{v})$ and we return the abstract value $\\hat{v}$. Abstracting the content of the field $f$ of an object at program point $\\mathit{pp}$ is slightly more complicated: if the pointer to the object is stored in the register $r_i$, we pick the $i$-th abstract value $\\hat{v}_i$ from the fact $\\absreg{\\mathsf{pp}}{ \\_ }{\\hat{v}^*}$ modelling the state of the registers at $\\mathit{pp}$; then, if $\\hat{v}_i$ contains any pointer abstraction $\\lambda$, we use it to match a corresponding abstract heap entry $\\mathsf{H}(\\lambda,\\hat{o})$ and we return the value of the field $f$ of the abstract object $\\hat{o}$ contained therein. We similarly abstract the content of array cells: just notice that, since the representation of arrays is field-insensitive, the index of the cell does not play any role in the static analysis.\n\nThe rules for abstracting a right-hand side are useful to define the abstract semantics of the \\texttt{move} statement. Other statements require some additional definitions. First, for each comparison operator $\\varolessthan$ and each primitive operation $\\odot,\\oplus$ of the concrete semantics, we presuppose the existence of a corresponding abstract operation $\\hat{\\comp}$, $\\hat{\\odot}$ and $\\hat{\\oplus}$ defined over the elements of the appropriate abstract domain. Then, given an abstract memory block $\\hat{b}$, we define a function $\\widehat{\\textit{get-type}}(\\hat{b})$ as follows:\n\\[\n\\widehat{\\textit{get-type}}(\\hat{b}) =\n\\begin{cases}\nc & \\text{if } \\hat{b} = \\absobj{c}{(f \\mapsto \\hat{v})^*} \\\\\n\\arrtype{\\tau} & \\text{if } \\hat{b} = \\absarray{\\tau}{\\hat{v}} \\\\\n\\texttt{Intent} & \\text{if } \\hat{b} = \\absintent{c}{\\hat{v}}\n\\end{cases}\n\\]\nFinally, we assume a function $\\widehat{\\textit{lookup}}(m)$, which returns the set of classes which define (or inherit) a method called $m$.\n\nWith these definitions, we are ready to introduce the abstract semantics of statements. The idea is to define, for each possible form of statement $\\mathit{st}$, a translation $\\ainst{\\mathit{st}}$ into a set of Horn clauses, which over-approximate the semantics of $\\mathit{st}$ at program point $\\mathit{pp}$. The full formal semantics of the translation is given in Table~\\ref{tab:abs-statements} and explained below. \n\n\\begin{table*}[htb] \\small\n\\begin{mathpar}\n\\begin{array}{lcl}\n\\ainst{\\goto \\mathit{pc}'} & = & \\{\\absreg{\\mathsf{pp}}{ \\_ }{\\hat{v}^*} \\implies \\absreg{\\mathsf{c},\\mathsf{m},\\mathsf{pc'}}{ \\_ }{\\hat{v}^*}\\} \\\\\n\n\\ainst{\\ifbr {r_i}{r_j} {\\mathit{pc}'}} & = & \\{\\absreg{\\mathsf{pp}}{ \\_ }{\\hat{v}^*} \\wedge \\hat{v}_i\\ \\hat{\\comp}\\ \\hat{v}_j \\implies \\absreg{\\mathsf{c},\\mathsf{m},\\mathsf{pc'}}{ \\_ }{\\hat{v}^*}\\}\\, \\cup \\\\\n& & \\{\\absreg{\\mathsf{pp}}{ \\_ }{\\hat{v}^*} \\wedge \\neg(\\hat{v}_i\\ \\hat{\\comp}\\ \\hat{v}_j) \\implies \\absreg{\\mathsf{c},\\mathsf{m},\\mathsf{pc+1}}{ \\_ }{\\hat{v}^*}\\} \\\\\n\n\\ainst{\\binop{r_d}{r_i}{r_j}} & = & \\{\\absreg{\\mathsf{pp}}{ \\_ }{\\hat{v}^*} \\implies\n\\absreg{\\mathsf{c},\\mathsf{m},\\mathsf{pc+1}}{ \\_ }{\\hat{v}^*[d \\mapsto \\hat{v}_i\\ \\hat{\\oplus}\\ \\hat{v}_j]}\\} \\\\\n\n\\ainst{\\unop{r_d}{r_i}} & = & \\{\\absreg{\\mathsf{pp}}{ \\_ }{\\hat{v}^*} \\implies\n\\absreg{\\mathsf{c},\\mathsf{m},\\mathsf{pc+1}}{ \\_ }{\\hat{v}^*[d \\mapsto \\hat{\\odot}\\, \\hat{v}_i]}\\} \\\\\n\n\\ainst{\\move{r_d}{\\mathit{rhs}}} & = & \\{\\prhs{\\hat{v}'} \\wedge \\absreg{\\mathsf{pp}}{\\_}{\\hat{v}^*} \\implies \\absreg{\\mathsf{c},\\mathsf{m},\\mathsf{pc+1}}{ \\_} {\\hat{v}^*[d \\mapsto \\hat{v}']}\\} \\cup \\arhs{\\mathit{rhs}} \\\\\n\n\\ainst{\\move{r_a[r_\\mathit{idx}]}{\\mathit{rhs}}} & = & \\{\\prhs{\\hat{v}''} \\wedge \\absreg{\\mathsf{pp}}{\\_ }{\\hat{v}^*} \\wedge \\lambda \\in \\hat{v}_a \\wedge \\mathsf{H}(\\lambda,\\absarray{\\tau}{\\hat{v}'}) \\implies \\mathsf{H}(\\lambda,\\absarray{\\tau}{\\hat{v}' \\cup \\hat{v}''})\\}\\, \\cup \\\\\n& & \\{\\absreg{\\mathsf{pp}}{ \\_ }{\\hat{v}^*} \\implies \\absreg{\\mathsf{c},\\mathsf{m},\\mathsf{pc+1}}{ \\_ }{\\hat{v}^*}\\} \\cup \\arhs{\\mathit{rhs}} \\\\\n\n\\ainst{\\move{r_o.f}{\\mathit{rhs}}} & = & \\{\\prhs{\\hat{v}''} \\wedge \\absreg{\\mathsf{pp}}{ \\_} {\\hat{v}^*} \\wedge \\lambda \\in \\hat{v}_o \\wedge \\mathsf{H}(\\lambda,\\absobj{c'}{(f' \\mapsto \\hat{u}')^*, f \\mapsto \\hat{v}'}) \\implies \\\\\n& & \\mathsf{H}(\\lambda,\\absobj{c'}{(f' \\mapsto \\hat{u}')^*, f \\mapsto \\hat{v}'')})\\} \\cup \\{\\absreg{\\mathsf{pp}}{ \\_} {\\hat{v}^*} \\implies \\absreg{\\mathsf{c},\\mathsf{m},\\mathsf{pc+1}}{ \\_ }{\\hat{v}^*}\\} \\cup \\arhs{\\mathit{rhs}} \\\\\n\n\\ainst{\\move{c'.f}{\\mathit{rhs}}} & = & \\{\\prhs{\\hat{v}'} \\implies \\mathsf{S}_{\\mathsf{c'},\\mathsf{f}}(\\hat{v}')\\} \\cup \\{\\absreg{\\mathsf{pp}}{ \\_ }{\\hat{v}^*} \\implies \\absreg{\\mathsf{c},\\mathsf{m},\\mathsf{pc+1}}{ \\_}{\\hat{v}^*}\\} \\cup \\arhs{\\mathit{rhs}} \\\\\n\n\\ainst{\\instanceof{r_d}{r_s}{\\tau}} & = & \\{\\absreg{\\mathsf{pp}}{ \\_}{\\hat{v}^*} \\wedge \\lambda \\in \\hat{v}_s \\wedge \\mathsf{H}(\\lambda, \\hat{b}) \\wedge \\widehat{\\textit{get-type}}(\\hat{b}) \\leq \\tau \\implies \\absreg{\\mathsf{c},\\mathsf{m},\\mathsf{pc+1}}{ \\_ }{\\hat{v}^*[d \\mapsto \\widehat{\\mathtt{true}}]}\\}\\, \\cup \\\\\n& & \\{\\absreg{\\mathsf{pp}}{ \\_ }{\\hat{v}^*} \\wedge \\lambda \\in \\hat{v}_s \\wedge \\mathsf{H}(\\lambda,\\hat{b}) \\wedge \\widehat{\\textit{get-type}}(\\hat{b}) \\not\\leq \\tau \\implies \\absreg{\\mathsf{c},\\mathsf{m},\\mathsf{pc+1}}{ \\_ }{\\hat{v}^*[d \\mapsto \\widehat{\\mathtt{false}}]}\\} \\\\\n\n\\ainst{\\checkcast{r_s}{\\tau}} & = & \\{\\absreg{\\mathsf{pp}}{ \\_ }{\\hat{v}^*} \\wedge \\lambda \\in \\hat{v}_s \\wedge \\mathsf{H}(\\lambda,\\hat{b}) \\wedge \\widehat{\\textit{get-type}}(\\hat{b}) \\leq \\tau \\implies \\absreg{\\mathsf{c},\\mathsf{m},\\mathsf{pc+1}}{ \\_}{\\hat{v}^*}\\} \\\\\n\n\\ainst{\\invoke{r_o}{m'}{(r_{i_j})^{j \\leq n}}} & = & \\{\\absreg{\\mathsf{pp}}{ \\_ }{\\hat{v}^*} \\wedge \\lambda \\in \\hat{v}_o \\wedge \\mathsf{H}(\\lambda,\\absobj{c'}{(f \\mapsto \\hat{u})^*}) \\wedge c' \\leq \\const{c''} \\implies \\\\\n& & \\absreg{\\mathsf{c''},\\mathsf{m'},\\mathsf{0}}{(\\hat{v}_{i_j})^{j \\leq n}}{(\\hat{\\mathbf{0}}_k)^{k \\leq \\mathit{loc}}, (\\hat{v}_{i_j})^{j \\leq n}} ~|~ c'' \\in \\widehat{\\textit{lookup}}(m') \\wedge \\textit{sign}(c'',m') = \\methsign{(\\tau_j)^{j \\leq n}}{\\tau}{\\mathit{loc}}\\}\\, \\cup \\\\\n& & \\{ \\absreg{\\mathsf{pp}}{ \\_ }{\\hat{v}^*} \\wedge \\lambda \\in \\hat{v}_o \\wedge \\mathsf{H}(\\lambda,\\absobj{c'}{(f \\mapsto \\hat{u})^*}) \\wedge c' \\leq \\const{c''} \\wedge \\absresult{\\mathsf{c''},\\mathsf{m'}}{(\\hat{v}_{i_j})^{j \\leq n}}{\\hat{v}'_{\\mathit{ret}}} \\implies \\\\\n& & \\absreg{\\mathsf{c},\\mathsf{m},\\mathsf{pc+1}}{ \\_} {\\hat{v}^*[\\mathit{ret} \\mapsto \\hat{v}'_{\\mathit{ret}}]} ~|~ c'' \\in \\widehat{\\textit{lookup}}(m')\\} \\\\\n\n\\ainst{\\sinvoke{c'}{m'}{(r_{i_j})^{j \\leq n}}} & = & \\{\\absreg{\\mathsf{pp}}{ \\_ }{\\hat{v}^*} \\implies \\absreg{\\mathsf{c'},\\mathsf{m'},\\mathsf{0}}{(\\hat{v}_{i_j})^{j \\leq n}}{(\\hat{\\mathbf{0}}_k)^{k \\leq \\mathit{loc}},(\\hat{v}_{i_j})^{j \\leq n}} ~|~ \\textit{sign}(c', m') = \\methsign{(\\tau_j)^{j \\leq n}}{\\tau}{\\mathit{loc}} \\}\\, \\cup \\\\\n& & \\{\\absreg{\\mathsf{pp}}{ \\_ }{\\hat{v}^*} \\wedge \\absresult{\\mathsf{c'},\\mathsf{m'}}{(\\hat{v}_{i_j})^{j \\leq n}}{\\hat{v}'_{\\mathit{ret}}} \\implies \\absreg{\\mathsf{c},\\mathsf{m},\\mathsf{pc+1}}{ \\_} {\\hat{v}^*[\\mathit{ret} \\mapsto \\hat{v}'_{\\mathit{ret}}]}\\} \\\\\n\n\\ainst{\\new{r_d}{c'}} & = & \\{ \\absreg{\\mathsf{pp}}{\\_}{\\hat{v}^*} \\implies \\mathsf{H}(\\mathsf{pp}, \\absobj{c'}{(f \\mapsto \\hat{\\mathbf{0}}_{\\tau})^*}\\} \\cup \\{ \\absreg{\\mathsf{pp}}{ \\_ }{\\hat{v}^*} \\implies \\absreg{\\mathsf{c},\\mathsf{m},\\mathsf{pc+1}}{\\_}{\\hat{v}^*[d \\mapsto \\mathsf{pp}]}\\} \\\\\n\n\\ainst{\\newarray{r_d}{r_l}{\\tau}} & = & \\{ \\absreg{\\mathsf{pp}}{\\_}{\\hat{v}^*} \\implies \\mathsf{H}(\\mathsf{pp}, \\absarray{\\tau}{\\hat{\\mathbf{0}}_{\\tau}})\\} \\cup \\{ \\absreg{\\mathsf{pp}}{ \\_ }{\\hat{v}^*} \\implies \\absreg{\\mathsf{c},\\mathsf{m},\\mathsf{pc+1}}{\\_}{\\hat{v}^*[d \\mapsto \\mathsf{pp}]}\\} \\\\\n\n\\ainst{\\texttt{return}} & = & \\{\\absreg{\\mathsf{pp}}{\\hat{v}^*_{call}}{\\hat{v}^*} \\implies \\absresult{\\mathsf{c},\\mathsf{m}}{\\hat{v}^*_{call}}{\\hat{v}_{\\mathit{ret}}}\\} \\\\\n\n\\ainst{\\startact{r_i}} & = & \\{\\absreg{\\mathsf{pp}}{\\_}{\\hat{v}^*} \\wedge \\lambda \\in \\hat{v}_i \\wedge \\mathsf{H}(\\lambda,\\absintent{c'}{\\hat{u}}) \\implies \\mathsf{I}(\\const{c},\\absintent{c'}{\\hat{u}})\\}\\, \\cup \\\\ \n& & \\{ \\absreg{\\mathsf{pp}}{\\_ }{\\hat{v}^*} \\implies \\absreg{\\mathsf{c},\\mathsf{m},\\mathsf{pc+1}}{\\_}{\\hat{v}^*}\\} \\\\\n\n\\ainst{\\newintent{r_d}{c'}} & = & \\{\\absreg{\\mathsf{pp}}{\\_}{\\hat{v}^*} \\implies \\mathsf{H}(\\mathsf{pp}, \\absintent{c'}{\\emptyset})\\} \\cup \\{\\absreg{\\mathsf{pp}}{ \\_ }{\\hat{v}^*} \\implies \\absreg{\\mathsf{c},\\mathsf{m},\\mathsf{pc+1}}{\\_}{\\hat{v}^*[d \\mapsto \\mathsf{pp}]}\\} \\\\\n\n\\ainst{\\putextra{r_i}{r_k}{r_j}} & = & \\{\\absreg{\\mathsf{pp}}{\\_}{\\hat{v}^*} \\wedge \\lambda \\in \\hat{v}_i \\wedge \\mathsf{H}(\\lambda, \\absintent{c'}{\\hat{v}'}) \\implies \\mathsf{H}(\\lambda, \\absintent{c'}{\\hat{v}' \\cup \\hat{v}_j})\\}\\, \\cup \\\\\n& & \\{\\absreg{\\mathsf{pp}}{ \\_ }{\\hat{v}^*} \\implies \\absreg{\\mathsf{c},\\mathsf{m},\\mathsf{pc+1}}{\\_}{\\hat{v}^*}\\} \\\\\n\n\\ainst{\\getextra{r_i}{r_k}{\\tau}} & = & \\{\\absreg{\\mathsf{pp}}{\\_}{\\hat{v}^*} \\wedge \\lambda \\in \\hat{v}_i \\wedge \\mathsf{H}(\\lambda, \\absintent{c'}{\\hat{v}'}) \\implies \\absreg{\\mathsf{c},\\mathsf{m},\\mathsf{pc+1}}{\\_}{\\hat{v}^*[\\mathit{ret} \\mapsto \\hat{v}']}\\}\n\\end{array}\n\\end{mathpar}\n\\caption{Abstract Semantics of {$\\mu\\text{-Dalvik}_{A}$}\\xspace{} - Statements (let $\\mathit{pp} = c,m,\\mathit{pc}$)}\n\\label{tab:abs-statements}\n\\end{table*}\n\nThe rule for $\\goto{\\mathit{pc}'}$ propagates the state of the registers at the current program counter $\\mathit{pc}$ to $\\mathit{pc}'$. The rule for $\\ifbr{r_i}{r_j}{\\mathit{pc}'}$ propagates the state of the registers at the current program counter $\\mathit{pc}$ either to $\\mathit{pc}'$ or to $\\mathit{pc}+1$, based on the outcome of a comparison $\\hat{\\comp}$ between the abstract values $\\hat{v}_i$ and $\\hat{v}_j$ approximating the content of registers $r_i$ and $r_j$ respectively: both branches may be enabled, as the result of an over-approximation of the contents of the registers. The two rules for unary and binary operations just employ the appropriate abstract operation to update the approximation of the content of the destination register $r_d$. The four rules for the \\texttt{move} statement rely on the auxiliary rules for abstracting a right-hand side we introduced before: these rules store their result in a $\\mathsf{RHS}$ fact, which occurs in the premises of the Horn clause used to update the abstraction of the left-hand side. The most interesting point to notice here is that field-sensitivity or its absence has an import on how fields are updated: for objects, we replace the old value of the field with the new one; for arrays and intents, instead, we add the new value to the old approximation, since their abstraction over-approximates the content of the entire data structure, rather than just the single element which is updated. The rules for \\texttt{instof} and \\texttt{checkcast} use the $\\widehat{\\textit{get-type}}$ function previously defined.\n\nThe rule for \\texttt{invoke} is the most complicated one, since it has to deal with dynamic dispatching. The challenge here is that the name of the invoked method is statically known from the syntax of the statement, but the method implementation is not, since it depends on the runtime type of the receiver object, an information which is only over-approximated when solving the Horn clauses, rather than when generating them. We then use the method name and the number of arguments passed upon invocation to narrow the set of possible classes of the receiver object, using the functions $\\widehat{\\textit{lookup}}$ and $\\textit{sign}$, and we generate one Horn clause for each of them. We then rely on subtyping to make the analysis precise, by imposing that a Horn clause generated for class $c''$ can only be fired if the class $c'$ of (the abstraction of) the receiver object is a subtype of $c''$. Besides implementing a sound approximation of the dynamic dispatching mechanism, the rule for \\texttt{invoke} generates additional Horn clauses used to propagate the abstraction of the method return value from the callee to the caller: this is done by using a $\\mathsf{Res}$ fact, which is introduced by a \\texttt{return} statement in the implementation of the callee, as we discuss below. The rule for static method invocation follows a similar logic, but it is significantly simpler, due to the lack of dynamic dispatching on static calls.\n\nThe rules for object and array creation create a new abstract heap entry $\\mathsf{H}(\\lambda,\\hat{b})$, where $\\lambda$ is the current program point and $\\hat{b}$ is the abstraction of a freshly initialized object\/array. The rule for \\texttt{return} introduces a $\\mathsf{Res}$ fact, storing an over-approximation of the method return value; notice that the arguments $\\hat{v}_{call}^*$ supplied upon method invocation are propagated in the $\\mathsf{Res}$ fact, which is important to implement context-sensitivity, i.e., to propagate the result to the right caller. The rule for \\texttt{start-activity} tracks that the present activity $c$ has sent an intent: an over-approximation of the intent is propagated from the corresponding abstract heap entry into the $\\mathsf{I}$ fact modelling the presence of a pending activity which is about to start. The last rules for managing intents should be easy to understand, based on the intuitions given for the other rules.\n\n\\subsubsection{Abstract Semantics of Activities}\nWe can finally introduce the abstract semantics of activities. Intuitively, it is defined by: (1) the Horn clauses produced by translating each statement in the bytecode, and (2) a small set of bytecode-independent Horn clauses, abstracting the event-driven behaviour of activities. This is formalized next.\n\n\\begin{definition}\nLet $P = (\\mathit{cls}_i)^{i \\leq n}$ be a program where $\\mathit{cls}_i = \\cls{c_i}{c'}{c^*}{\\mathit{fld}^*}{(\\mathit{mtd}_j)^{j \\leq h_i}}$ and $\\mathit{mtd}_j = \\meth{m_j}{\\methsign{\\tau^*}{\\tau}{\\mathit{loc}}}{(\\mathit{st}_k)^{k \\leq s_{ij}}}$, we let $\\translate{P}$ be defined as follows:\n\\[\n\\translate{P} = \\bigcup_{i \\leq n, j \\leq h_i, k \\leq s_{ij}} \\ainstfull{\\mathit{st}_k}{c_i,m_j,k} \\cup \\mathcal{R},\n\\]\nwhere $\\mathcal{R}$ stands for the union of all the rules in Table~\\ref{tab:abs-activity}.\n\\end{definition}\n\n\\begin{table*}[htb]\n\\begin{mathpar}\n\\begin{array}{lcl}\n\\rulename{Cbk} & = & \\{\\mathsf{H}(c,\\absobj{c}{(f \\mapsto \\_)^*}) \\wedge c \\leq \\const{c'} \\implies \\absreg{\\mathsf{c'},\\mathsf{m},\\mathsf{0}}{(\\top_{\\tau_j})^{j \\leq n}}{(\\hat{\\mathbf{0}}_k)^{k \\leq \\mathit{loc}},c,(\\top_{\\tau_j})^{j \\leq n}} ~|~ \\\\\n& & c' \\text{ is an activity class} \\wedge \\exists s: m \\in \\mathit{cb}(c',s) \\wedge \\textit{sign}(c',m) = \\methsign{\\tau_1,\\ldots,\\tau_n}{\\tau}{\\mathit{loc}}\\} \\\\\n\n\\rulename{Fin} & = & \\{\\mathsf{H}(c,\\absobj{c}{(f \\mapsto \\_)^*,\\textit{finished} \\mapsto \\_}) \\implies \\mathsf{H}(c,\\absobj{c}{(f \\mapsto \\_)^*,\\textit{finished} \\mapsto \\top_{\\type{bool}}})\\} \\\\\n\n\\rulename{Rep} & = & \\{\\mathsf{H}(c,\\absobj{c}{(f_{\\tau} \\mapsto \\_)^*}) \\implies \\mathsf{H}(c,\\absobj{c}{(f_{\\tau} \\mapsto \\hat{\\mathbf{0}}_{\\tau})^*})\\} \\\\\n\n\\rulename{Act} & = & \\{\\mathsf{I}(c',\\absintent{c}{\\hat{v}})) \\implies \\mathsf{H}(\\astart{c},\\absintent{c}{\\hat{v}})\\}\\, \\cup \\\\\n& & \\{\\mathsf{I}(c',\\absintent{c}{\\hat{v}})) \\implies \\mathsf{H}(c, \\absobj{c}{(f_{\\tau} \\mapsto \\hat{\\mathbf{0}}_{\\tau})^*, \\textit{finished} \\mapsto \\widehat{\\mathtt{false}}, \\textit{parent} \\mapsto c', \\textit{intent} \\mapsto \\astart{c}})\\} \\\\\n\n\\rulename{Res} & = & \\{\\mathsf{H}(c',\\absobj{c'}{(f' \\mapsto \\_)^*,\\textit{parent} \\mapsto c,\\textit{result} \\mapsto \\lambda} \\wedge \\mathsf{H}(c,\\absobj{c}{(f \\mapsto \\_)^*,\\textit{result} \\mapsto \\_} \\implies \\\\\n& & \\mathsf{H}(c,\\absobj{c}{(f \\mapsto \\_)^*,\\textit{result} \\mapsto \\lambda}\\} \\\\\n\n\\rulename{Sub} & = & \\{\\tau \\leq \\tau' ~|~ \\tau \\leq \\tau' \\text{ is a valid subtyping judgement} \\}\n\\end{array}\n\\end{mathpar}\n\\caption{Abstract Semantics of {$\\mu\\text{-Dalvik}_{A}$}\\xspace{} - Activity Rules}\n\\label{tab:abs-activity}\n\\end{table*}\n\nWe explain the rules from Table~\\ref{tab:abs-activity}. Rule \\rulename{Cbk} simulates the invocation of a callback: since we do not approximate the activity state in the abstract semantics, any callback method bound to a state $s$ of the activity lifecycle may be non-deterministically dispatched; the statically unknown arguments supplied to the callback are abstracted by the top element ($\\top$) of the abstract domain associated to their type, which is a sound over-approximation of any value of that type. Rule \\rulename{Fin} tracks updates to the $\\textit{finished}$ field of an activity in the abstract semantics: since it is hard to statically track whether an activity has finished or not, the rule sets the field to the top element of the abstract domain used to represent boolean value ($\\top_{\\type{bool}}$). Rule \\rulename{Rep} approximates the behaviour of rule \\irule{A-Replace} of the concrete semantics: the activity fields may be reset to their default abstract value as the result of a screen orientation change. \n\nRule \\rulename{Act} represents the starting of a new activity. If an intent has been sent by an activity of class $c'$ to start an activity of class $c$, we introduce: (1) a new abstract heap entry to bind an abstraction of the intent to $\\astart{c}$, and (2) a new abstract heap entry to bind an abstraction of the started activity to $c$. No serialization happens in the abstract semantics: if an intent is used to send an object in the concrete semantics, a reference to the corresponding abstract object is sent in our abstraction. This is sound, since our analysis is flow-insensitive on heap values, hence no over-approximation of the original object is ever lost as the result of an update to the heap at the receiver side. We then have rule \\rulename{Res}, which is used to communicate a result from a child activity to its parent, thus simulating the behaviour of rule \\irule{A-Result} in the concrete semantics; again, no serialization happens in the process, rather a pointer to the result is passed. Finally, rule \\rulename{Sub} corresponds to an axiomatization of the subtyping relationships for the analysed program.\n\n\\subsection{Formal Results}\nThe soundness of the analysis is proved using \\emph{representation functions}, a standard approach in program analysis~\\cite{NielsonNH99}.\nThe representation function $\\beta_{\\textit{Cnf}}$ maps an arbitrary configuration $\\Psi$ into a corresponding set of facts $\\Delta$, modelling an over-approximation of $\\Psi$. Its definition is lengthy, but unsurprising, e.g., each element $\\ell \\mapsto b$ of the heap is converted into an abstract heap entry $\\mathsf{H}(\\lambda,\\hat{b})$, where $\\lambda$ is the annotation on $\\ell$ and $\\hat{b}$ is an abstraction of $b$. After defining $\\beta_{\\textit{Cnf}}$, we introduce a partial order $\\sqsubseteq$ on analysis facts, with the intuitive understanding that $\\mathsf{f} \\sqsubseteq \\mathsf{f}'$ whenever $\\mathsf{f}$ is a more precise abstraction than $\\mathsf{f}'$. The partial order is then lifted to abstract programs by having\n$\\Delta <: \\Delta'$ if and only if $\\forall \\mathsf{f} \\in \\Delta: \\exists \\mathsf{f}' \\in \\Delta': \\mathsf{f} \\sqsubseteq \\mathsf{f}'$.\n\nOur main theorem states that any reachable configuration in the concrete semantics is over-approximated by some set of facts which is provable using the abstract semantics of the program and an abstraction of the initial configuration. The proof is parametric with respect to the choice of the abstract domains\/operations used for primitive values, provided they offer some minimal soundness guarantees. This allows for choosing different trade-off between efficiency and precision of the analysis.\n\n\\begin{theorem}[Preservation]\nIf $\\Psi \\Rightarrow^* \\Psi'$ under a program $P$, there exists $\\Delta :> \\beta_{\\textit{Cnf}}(\\Psi')$ such that:\n\\[\n\\translate{P} \\cup \\beta_{\\textit{Cnf}}(\\Psi) \\vdash \\Delta.\n\\]\n\\end{theorem}\n\nBy providing an over-approximation of any reachable configuration of the concrete semantics in terms of a corresponding set of facts, the theorem can be used to prove the absence of undesired information flows of sensitive data into local registers of selected sink methods. In particular, we leverage the theorem to develop a provably sound taint analysis, based on standard ideas. Due to space constraints, we refer to \\iffull Appendix~\\ref{sec:proofs} \\else the online version~\\cite{full} \\fi for full details.\n\n\n","meta":{"redpajama_set_name":"RedPajamaArXiv"}} +{"text":"\\section{Introduction}\n\nOne of the most well-studied mechanisms for setting the observed dark matter (DM) abundance is thermal freeze-out, where DM is in equilibrium with the Standard Model (SM) thermal bath at very early times. The DM abundance is then depleted through annihilations at later times until the DM drops out of chemical equilibrium. The appeal of this mechanism is that the final relic abundance is generally independent of the high-temperature initial conditions at reheating. Furthermore, producing the observed relic abundance requires a particular thermally averaged annihilation cross section in most thermal freeze-out scenarios, $\\langle \\sigma v\\rangle \\sim 10^{-26}$ cm$^3$\/s. This weak-scale cross section provides a target that can be probed by direct and indirect detection experiments. Assuming the relic abundance is set by annihilations to SM particles, then consistency with Big Bang Nucleosynthesis (BBN) generally requires that thermal freeze-out candidates have masses $m_\\chi \\gtrsim 1$~MeV~\\cite{Boehm:2013jpa, Nollett:2013pwa,Nollett:2014lwa}. \nThe appealing simplicity of this scenario has led to an enormous number of DM searches targeting the thermal freeze-out mechanism, with a particular emphasis on weakly interacting massive particle (WIMP) candidates in the $m_\\chi\\sim$~GeV$-$TeV mass range. More recently, there has been a growing interest in $m_\\chi\\sim$~MeV$-$GeV thermal candidates where interactions with the SM or within a hidden sector deplete the DM density to the observed value \\cite{Boehm:2003hm,Pospelov:2007mp,Feng:2008ya,Hochberg:2014dra,Hochberg:2014kqa,Hochberg:2018rjs,Choi:2017zww,DAgnolo:2018wcn,DAgnolo:2017dbv,DAgnolo:2015ujb,Pappadopulo:2016pkp,Cline:2017tka,Kopp:2016yji}. \n\nThe freeze-in mechanism for DM production is a compelling alternative to thermal freeze-out, where DM is instead produced by feeble, sub-Hubble interactions of SM particles~\\cite{Asaka:2005cn,Asaka:2006fs,Gopalakrishna:2006kr,Page:2007sh,Hall:2009bx,Bernal:2017kxu}. If the dominant freeze-in process is annihilation of SM particles into DM via a light mediator, then many of the appealing features of thermal freeze-out are maintained. For annihilation through a mediator lighter than the DM, the thermal cross section typically scales as $\\langle \\sigma v \\rangle \\sim g_\\chi^2 g_{\\rm SM}^2\/(4 \\pi T)^2$ where $g_\\chi$ is the mediator-DM coupling, $g_{\\rm SM}$ is the mediator-SM coupling, and $T$ is the SM temperature. With this scaling, DM freeze-in dominantly occurs at the lowest temperature where the process is kinematically accessible, and thus the mechanism is not sensitive to the reheat scale.\\footnote{We assume the minimal scenario where the dark sector is not populated in abundance at reheating.}\n \n\nFreeze-in through a light vector mediator has emerged as a key benchmark for sub-GeV direct detection experiments. Producing the observed DM relic abundance implies a tiny value for the coupling constants, which is difficult to target with accelerator searches. However, sufficiently light mediators give rise to scattering cross sections that scale as $\\sigma \\propto 1\/v^4$ for relative velocity $v$, implying that the kinematics of the Milky Way (where $v\\sim 10^{-3}$) can enhance the detectability of DM coupling to a light mediator. If the mediator also couples to charged SM fermions, then the DM can scatter off of electrons or nuclei and may be detectable with the next generations of direct detection experiments~\\cite{Essig:2011nj,Essig:2012yx,Essig:2015cda,Hochberg:2016ntt,Derenzo:2016fse,Hochberg:2017wce,Knapen:2017ekk,Griffin:2018bjn,Schutz:2016tid,Knapen:2016cue,Hochberg:2015pha,Hochberg:2015fth} (see also Ref.~\\cite{Battaglieri:2017aum} for a recent review). Indeed, recent experimental results by SENSEI~\\cite{Crisler:2018gci,sensei}, SuperCDMS~\\cite{Agnese:2018col}, and DarkSide~\\cite{Agnes:2018oej} are demonstrating significant progress towards achieving the sensitivity needed in the MeV-GeV mass range. It was also shown recently that Xenon1T~\\cite{Aprile:2018dbl} is for the first time constraining freeze-in in the GeV-TeV mass range~\\cite{Hambye:2018dpi}. \n\nIn the keV$-$MeV DM mass range, freeze-in is the leading scenario that could be tested by proposed low-threshold direct detection experiments. Refs.~\\cite{Knapen:2017xzo,Green:2017ybv} studied the possible direct detection cross sections in models of sub-MeV DM, finding that it would be difficult to observe thermal freeze-out scenarios (even purely within a dark sector) due to a combination of BBN, CMB, fifth force, and stellar emission constraints. Obtaining accurate predictions of freeze-in is thus an important step in the program to search for low-mass DM. While freeze-in from electron-positron annihilations via a light vector mediator has been studied in the past~\\cite{Chu:2011be,Essig:2011nj}, in this work we thoroughly explore a previously overlooked production mechanism: freeze-in through plasma effects. The contribution of plasma effects to dark sector thermalization was estimated earlier in Refs.~\\cite{Davidson:2000hf,Vogel:2013raa} and the effect on freeze-in via a heavy mediator was recently considered in Ref.~\\cite{An:2018nvz} as we were in the late stages of completing this work, but it was not included in previous studies of freeze-in through a light vector mediator. We find that the plasma production of DM is a dominant channel for sub-MeV DM masses, and will therefore restrict our discussion to this mass range. The additional contribution to the relic abundance implies that the target cross section for direct detection is lower by roughly an order of magnitude for the lowest experimentally accessible DM masses.\n\nThe rest of this paper is organized as follows. We begin in Section~\\ref{sec:model} by reviewing the arguments for the simplest viable freeze-in models in the keV-MeV mass range: either pure millicharged DM arising from a DM hypercharge or \\emph{effectively} millicharged DM that is coupled to an ultralight dark photon mediator. These two scenarios are almost phenomenologically identical, with the key difference being that DM-DM scattering can be parametrically larger when dark photon interactions are present. These DM candidates have recently received considerable attention in the context of the anomalous 21~cm global signal~\\cite{Bowman:2018yin,barkana2018possible,Barkana:2018cct,Berlin:2018sjs,Munoz:2018pzp}. In Section~\\ref{sec:prod} we compute the DM relic abundance from freeze-in via a light mediator. We include the effects of plasmon decays for the first time, and show the impact for direct detection. We then present the calculation of the phase space distribution for freeze-in DM in Section~\\ref{sec:phasespace}. A summary of our results can be found in Section~\\ref{summary}.\nIn a companion paper~\\cite{inprep}, we will apply the calculations of the phase-space distribution to cosmological observables, showing that the cosmic microwave background (CMB) and probes of large-scale structure (LSS) provide a strong complementary test of DM freeze-in for $m_\\chi\\sim$~keV$-$MeV. In particular, we find that existing cosmological constraints restrict $m_\\chi \\gtrsim$ tens of keV for freeze-in via a light mediator, and it will be possible to probe even higher masses with planned experiments. \n\n\\section{Models for sub-MeV freeze-in \\label{sec:model}}\n\n\\subsection{The case for light vector mediators}\n\\label{vectors}\nThe simplest observationally viable models for sub-MeV freeze-in through a light mediator can be divided into two classes, where (1) the DM only has interactions mediated by the SM photon or (2) the DM has interactions with an ultralight kinetically mixed dark photon. We note that models of millicharged DM~\\cite{Davidson:2000hf,Dubovsky:2003yn} can fall under either category: they can arise as a limit of the dark-photon model where the dark photon is nearly massless, or they could be present as Dirac fermions with a tiny hypercharge.\\footnote{Other models that have been considered in the past require giving neutrinos small charges as well~\\cite{Foot:1992ui}, which we do not consider further due to strong experimental bounds on neutrino charge~\\cite{Chen:2014dsa}.}\n\nFor sub-MeV freeze-in to be relevant for direct detection, vector mediators are the only observationally viable option due to stringent constraints on other light mediators with the requisite couplings to the SM, as outlined below. For direct detection of freeze-in, the mediator masses must be sufficiently small compared to the typical momentum transfer for scattering processes. If the mediators are heavier, then they do not give rise to the $v^{-4}$ enhancement that would render extremely feeble DM-SM interactions detectable on Earth. For nuclear recoils the relevant momentum scale is set by galactic kinematics $q \\sim m_\\chi v \\sim 10^{-3} m_\\chi$, while for electron recoils the typical electron momentum in the target material is most relevant $q \\sim \\alpha m_e \\approx 4$~keV, where $m_e$ is the electron mass and $\\alpha$ is the electromagnetic fine structure constant. Thus for sub-MeV DM, the experimentally relevant mediators have masses below $\\mathcal{O}(1)$~keV. \n\nAssuming an annihilation cross section of SM fermions into DM with the form $\\langle \\sigma v\\rangle \\sim g_\\chi^2 g_{\\rm SM}^2\/(4 \\pi T)^2$, the relic abundance can be estimated as \n\\begin{align}\n Y_\\chi = \\frac{n_\\chi}{s} \\sim \\frac{n_{\\rm SM}^2 \\langle \\sigma v\\rangle}{s H} \\sim 2\\times10^{-4} \\, \\frac{g_\\chi^2 g_{\\rm SM}^2 M_{\\rm Pl} }{ T},\n\\end{align}\nwhere $M_{\\rm Pl}=1\/\\sqrt{8 \\pi G}$ is the reduced Planck mass and we assumed $T \\sim $ MeV. Then for $m_\\chi\\sim$ MeV, we find that $g_\\chi g_{\\rm SM} \\simeq 10^{-12}$ to saturate the relic abundance. This order-of-magnitude estimate is in agreement with more detailed calculations below. Since obtaining the relic abundance from freeze-in requires $g_\\chi g_{\\rm SM} \\sim 10^{-12}$, $g_{\\rm SM}$ must be greater than $10^{-12}$ if we require the dark sector to be perturbative (i.e. $g_\\chi~\\lesssim~1$). Weakly coupled, sub-keV mediators can be emitted in stars, affecting their luminosity and lifetime. The observed properties of stars lead to strong bounds on such mediators, which we summarize here (see also Refs.~\\cite{Knapen:2017xzo,Green:2017ybv} where these bounds are collected and discussed in the context of sub-MeV DM models): \n\\begin{itemize}\n\\item {\\emph{Scalars and pseudoscalars coupled to electrons}} $-$ The strongest bound on a light scalar with interaction $g_{\\phi ee} \\phi \\bar e e$ comes from helium ignition in red giants, with $g_{\\phi e e} \\lesssim 7 \\times 10^{-16}$ for sub-keV masses~\\cite{Hardy:2016kme}. For a sub-keV pseudoscalar, observations of white dwarfs give typical constraints of $g_{a e e} \\lesssim 2 \\times 10^{-13}$~\\cite{Raffelt:2006cw,Viaux:2013lha,Bertolami:2014wua}. A caveat for most stellar emission bounds is that when the coupling is increased, the new particle may be trapped within the star and would not lead to anomalous energy loss. However, this would still affect energy transport in the star, which can be constrained for the range of couplings relevant for freeze-in through this mediator~\\cite{Carlson:1988jg,Raffelt:1988rx}.\n\\item {\\emph{Scalars and pseudoscalars coupled to nucleons}} $-$ Similar to the case of mediators coupling to electrons, red giants constrain $g_{\\phi n n} \\lesssim 10^{-12}$ for a scalar~\\cite{Hardy:2016kme} and $g_{a n n} \\lesssim {\\rm few} \\times 10^{-10}$ for a pseudoscalar~\\cite{Raffelt:2006cw,Giannotti:2017hny}. While the latter coupling appears at face value to be sufficiently large, freeze-in through baryons is largely suppressed after the QCD phase transition due to the low baryon number density. Therefore, in this case our estimate for the minimum $g_{\\rm SM}$ with $T\\sim 1$~MeV is much too low and freeze-in would have to occur with a larger value of $g_{\\rm SM}$ that is in tension with stellar bounds. \n\\item {\\emph{Scalar mixing with the Higgs}} $-$ The bounds here are similar to those in the two previous cases, and it has been shown in Ref.~\\cite{Krnjaic:2017tio} that freeze-in through this portal is only a viable mechanism for producing all of the DM for DM masses above a few hundred MeV. \n\\item {\\emph{Kinetically mixed dark photon}} $-$ In this case, the stellar constraints on $g_{\\rm SM}$ decrease linearly with the mediator mass for masses below $\\sim 100$ eV~\\cite{An:2013yfc,An:2013yua} because of the in-medium plasma mass suppression of producing dark photons from SM interactions, as detailed in Eq.~\\eqref{eq:inmedium_L} and the surrounding discussion in Section~\\ref{sec:darkphoton}. From the collected bounds on dark photons from Refs.~\\cite{Jaeckel:2013ija}, a dark photon can have $g_{\\rm SM} > 10^{-12}$ when its mass is well below $1$~eV. At even lower masses, the coupling could be $\\sim 10^{-3}$ for masses below $\\lesssim 10^{-14}$~eV. \n\\item {\\emph{$B-L$ vector}} $-$ Stellar constraints on a $B-L$ vector are similar to that for the dark photon. However, for eV-scale and lighter mediator masses, a $B-L$ vector is also strongly constrained by fifth force searches (e.g.~\\cite{Murata:2014nra,Adelberger:2003zx}), which limits the mediator-SM coupling to below $10^{-12}$. \n\\end{itemize} \nSince we are focusing on the simplest benchmarks for direct detection, we do not consider more exotic possibilities with additional particles and interactions. From the bounds on new particles with the couplings described above, we conclude that freeze-in through a light mediator is viable either when the mediator is (1) the SM photon, and the DM has a tiny electric charge, or (2) when the mediator is an ultralight kinetically mixed dark photon. \n\nWe discuss these two closely related scenarios in the rest of the section. In both cases, DM has an effective charge $Q e$ (or millicharge $Q$) with respect to the SM photon. This parameter determines the relic abundance, irrespective of which of the two models is under consideration. Both models allow for heat and momentum transfer between SM particles and DM during epochs when the typical relative velocities are low (as discussed in Section~\\ref{sec:scattering}), which is relevant to observations of the CMB~\\cite{Dvorkin:2013cea,Xu:2018efh,Slatyer:2018aqg,Kovetz:2018zan,Boddy:2018wzy,Dubovsky:2001tr,Boddy:2018kfv} and the cosmological 21~cm global signal~\\cite{Bowman:2018yin,barkana2018possible,Barkana:2018cct,Berlin:2018sjs,Munoz:2018pzp}. The main phenomenological difference between these two possibilities is that DM-DM scattering via a dark photon can be parametrically larger than DM-DM scattering mediated by the SM photon, as discussed below. If present at a sufficient level, the DM self-scattering can play an important role in determining the DM phase space distribution at late times, well after freeze-in.\n\n\n\\subsection{DM with photon-mediated interactions \\label{sec:millicharge}}\n \nIf the DM is a Dirac fermion $\\chi$ with a tiny hypercharge $Q_Y$ (the only gauge-invariant, renormalizable operator leading to a bare millicharge), then it can interact via the SM photon. After electroweak symmetry breaking, the DM obtains an electric charge given by $e Q_Y \\equiv eQ$ (taking the convention where the Gell-Mann Nishijima formula reads $Q = I_3 +Y$). Although there are also $Z$-mediated DM interactions, they are negligible for the relevant epochs where $T \\ll m_Z$. This gives the simplest model of millicharged DM. It is difficult to incorporate such matter content into a Grand Unified Theory (GUT)~\\cite{Okun:1983vw}; however, this scenario is economical in that it requires that no additional particles be introduced to the SM aside from the DM itself. \n\nThe possibility that this DM candidate obtains its relic abundance by thermal freeze-out has been considered before in Ref.~\\cite{McDermott:2010pa}, where it was shown to be excluded by structure formation when all of the DM is produced this way. Thus, freeze-in is the simplest remaining possibility for producing this DM candidate, with $g_\\chi = eQ$ and $g_{\\rm SM} = e$ in the language of the previous subsections.\n\nThere are stellar emission bounds on this DM candidate because the DM can be pair produced by the decay of plasmons in stars, leading to additional energy loss. These bounds are shown as the shaded region in our summary plot, Fig.~\\ref{fig:summaryplot}. Constraints on DM pair produced in SN1987a were derived in Refs.~\\cite{Davidson:2000hf,Chang:2018rso} and require $Q\\lesssim 10^{-9}$ for $m_\\chi$ up to a few MeV, which does not impact freeze-in. However, there are constraints for $m_\\chi$ below $\\mathcal{O}(10)$~keV from emission in white dwarfs, horizontal branch stars, and red giants (see Appendix of Ref.~\\cite{Vogel:2013raa}). Note that the range of $m_\\chi$ where stellar emission can constrain freeze-in is exponentially sensitive to assumptions about temperatures within the stars. In addition, the bounds derived are applicable in the weak coupling limit where the DM escapes cleanly from the star. For sufficiently large $Q$, DM emission could contribute to energy transport within the star and the effects have not been carefully studied in this regime. The couplings for freeze-in are large enough that they could be in this regime and stellar bounds on freeze-in should be regarded with care. \n\nThe relevant interactions for the relic abundance and phase space distribution in this model are SM annihilations and plasma decay into the DM. DM-SM scattering can become important at late times but, as we discuss in Section~\\ref{sec:scattering}, the effect must be small to be consistent with limits from the CMB. The DM self-scattering cross section is proportional to $Q^4$, and we find it to be irrelevant for the phase space. Finally DM-photon scattering is also proportional to $Q^4$ and is not enhanced in the low-velocity limit, so it is also irrelevant.\n\n\\subsection{DM with dark photon interactions \\label{sec:darkphoton}}\n\nWe next consider Dirac fermion DM coupled to a kinetically mixed dark photon $A'$, with the vacuum Lagrangian given by\n\\begin{align}\n\t{\\cal L} \\supset & -\\frac{1}{4} F_{\\mu \\nu} F^{\\mu \\nu} +\\frac{\\kappa}{2} F_{\\mu \\nu} F^{\\prime \\mu \\nu} -\\frac{1}{4} F^\\prime_{\\mu \\nu} F^{\\prime \\mu \\nu} + \\frac{1}{2} m_{A'}^2 A_\\mu^\\prime A^{\\prime \\mu} \\nonumber \\\\\n &+ \\, e J^\\mu_{\\rm EM} A_\\mu + g_\\chi\\bar \\chi \\gamma^\\mu \\chi A^\\prime_{\\mu} + \\bar \\chi (i \\partial - m_\\chi) \\chi, \\label{eq:vacuumL} \n\\end{align}\nwhere $A$ is the SM photon, $\\kappa$ is the kinetic mixing parameter and $\\chi$ is Dirac fermion DM. For the purposes of this discussion, we consider Abelian kinetic mixing, noting that non-Abelian kinetic mixing is also possible~\\cite{Barello:2015bhq,Arguelles:2016ney}. The mixing parameter $\\kappa$ could have any number of origins; for instance, it could be generated as a result of loop diagrams with heavy matter fields charged under both $A$ and $A'$ \\cite{Dienes:1996zr} or from certain compactifications of type IIB strings \\cite{Abel:2008ai,Goodsell:2009xc}. Since the kinetic mixing term is a marginal operator, we take the point of view of a bottom-up effective field theory and we will treat it here as a small free parameter without specifying its origin. \nIn this model, the combination of couplings relevant for the relic abundance is $g_\\chi g_\\text{SM} = g_\\chi \\kappa e$.\n\n\n\nAs discussed in Section~\\ref{vectors}, the dark photon mass must satisfy $m_{A'} \\lesssim 1$~eV in order to give a sufficient coupling for freeze-in while also evading existing bounds on stellar energy loss~\\cite{Jaeckel:2013ija}. However, the requirements are even more stringent because unlike the model presented in Section~\\ref{sec:millicharge} there could be large $A'$-mediated DM self interaction. For $m_{A'} <$~eV, the mediator would be light enough to give rise to $v^{-4}$ enhanced DM self-scattering in astrophysical environments, with a rate proportional to $g_\\chi^4$. Furthermore, as mentioned before, the freeze-in relic abundance is determined by the product $g_\\chi \\kappa e$, meaning that large $g_\\chi$ can be compensated by reducing $\\kappa$ to give the same observed relic abundance. Thus a sizable DM self-interaction is possible, and could be relevant to astrophysical probes of self-interacting DM (SIDM). The effects of SIDM are typically parameterized by the momentum-transfer self-scattering cross section, which in the limit of a very light vector mediator is given by~\\cite{Feng:2009hw} \n\\begin{align}\n\\sigma_{T,\\, \\chi \\chi} &= \\int d\\cos \\theta_\\text{CM} \\, \\frac{d\\sigma_{\\chi \\chi}}{d\\cos \\theta_\\text{CM}} (1 - \\cos \\theta_\\text{CM}) \\approx \\frac{8\\pi\\alpha_\\chi^2}{m_\\chi^2 v^4} \\ln \\frac{(m_\\chi v)^2}{m_{A'}^2},\n \\label{eq:transfer}\n\\end{align}\nwhere $\\theta_\\text{CM}$ is the scattering angle in the center-of-mass (CM) frame, $\\sigma_{\\chi\\chi}$ is the self-interaction cross section, and $\\alpha_\\chi$ is the dark equivalent of the electromagnetic fine structure constant, $\\alpha_\\chi \\equiv g_\\chi^2\/4 \\pi$.\nTypical bounds on SIDM require $\\sigma_{\\chi \\chi}\/m_\\chi < 1-10$ cm$^2$\/g for systems ranging from dwarf galaxies where $v\\sim 10^{-4}$ to merging clusters where $v\\sim 10^{-2}$ (for a recent review, see Ref.~\\cite{Tulin:2017ara}). While few simulation-based studies of self-interactions have been done in the ultralight mediator limit (see for instance Ref.~\\cite{Kummer:2019yrb}), we can estimate the expected bound. \nTaking the more restrictive limit of $\\sigma_{\\chi \\chi}\/m_\\chi\\sim$1~cm$^2\/$g, the bound is \n\\begin{equation} g_\\chi \\lesssim 4 \\times 10^{-5}\\times \\left( \\frac{v}{10^{-3}}\\right) \\times \\left(\\frac{m_\\chi}{1\\,\\text{MeV}}\\right)^{3\/4}\\times \\left(\\frac{10}{\\ln \\left(m_\\chi^2 v^2\/m_{A'}^2\\right) }\\right)^{1\/4}. \\label{SIDMbound}\n\\end{equation}\nSince $\\kappa e g_\\chi \\gtrsim 10^{-12}$ is needed for sub-MeV freeze-in, the SIDM bounds imply that the kinetic mixing is $\\kappa \\gtrsim 10^{-7}$ for MeV-scale DM. For sub-eV dark photons, such large kinetic mixing is only possible when $m_{A'} \\lesssim 10^{-10}$ eV~\\cite{Jaeckel:2013ija}. For even lighter DM, $g_\\chi$ is even more restricted so $\\kappa \\gtrsim 10^{-5}$ is required for freeze-in, which is possible when $m_{A'}\\lesssim 10^{-14}$~eV. Therefore, we are required to consider an ``ultralight'' dark photon~\\cite{Knapen:2017xzo}. Note that black hole superradiance constrains dark photons being present in the mass spectrum (in the small-coupling limit) between $\\sim 10^{-14} - 10^{-11}$~eV and preliminarily between $\\sim 10^{-19} - 10^{-17}$~eV~\\cite{Baryakhtar:2017ngi}.\n\nSuch a light dark photon is phenomenologically equivalent to the massless dark photon limit for all processes considered in this paper because the $m_{A'}$ is much lower than the effective in-medium photon mass $m_A$ in the early universe. Then, following Appendix D of Ref.~\\cite{Knapen:2017xzo}, the vacuum Lagrangian in Eq.~\\eqref{eq:vacuumL} is modified with an additional term $m_{A}^2 A^\\mu A_\\mu \/2$.\\footnote{For simplicity we consider a constant $m_A^2$ for the schematic purposes of this discussion, although the photon polarization tensor $\\Pi^{\\mu \\nu}(\\vec{q}, \\omega)$ (which gives rise to the in-medium effective mass) depends on the photon momentum $\\vec{q}$, energy $\\omega$, polarization, and thermal properties of the medium. For an on-shell mode with $\\omega \\sim |\\vec{q}|$, $m_A^2$ would correspond to the plasma mass, as discussed in Section~\\ref{sec:plasmon}. For scattering processes with a highly off-shell mode, $|\\vec{q}| \\gg \\omega$, $m_A^2$ is given by the Debye mass~\\cite{Blaizot:1995kg}.} Rotating away the mixing term in the presence of $m_{A}$ and $m_{A'}$ and rewriting in terms of the mass eigenstates $\\tilde A$ and $\\tilde A'$, the in-medium Lagrangian is given by\n\\begin{align}\n\t{\\cal L}_{\\rm IM} \\supset & -\\frac{1}{4} \\tilde F_{\\mu \\nu} \\tilde F^{\\mu \\nu} \n\t\t\t- \\frac{1}{4} \\tilde F'_{\\mu \\nu} \\tilde F'^{\\mu \\nu} \n\t\t\t+ \\frac{m_{A}^2}{2} \\tilde A^\\mu \\tilde A_\\mu\n\t\t\t+ \\frac{m_{A'}^2}{2} \\tilde A'^\\mu \\tilde {A'}_\\mu \\nonumber \\\\\n\t &+ J_{\\rm EM}^\\mu \\left(e \\tilde A_\\mu + \\frac{e \\kappa \\, m_{A'}^2}{m_{A'}^2 - m_{A}^2} \\tilde {A'}_\\mu\\right) + g_\\chi \\bar \\chi \\gamma^\\mu \\chi \\left( \\tilde {A^\\prime}_\\mu - \\frac{\\kappa m_{A}^2}{m_{A'}^2 - m_{A}^2} \\tilde A_\\mu \\right).\n\t\\label{eq:inmedium_L}\n\\end{align}\nFrom this, we see that when $m_{A} \\gg m_{A'}$, the interaction terms above reduce to\n\\begin{align}\n\t{\\cal L}_{\\rm IM} \\supset J_{\\rm EM}^\\mu \\left(e \\tilde A_\\mu \\right) + g_\\chi \\bar \\chi \\gamma^\\mu \\chi \\left(\\tilde {A^\\prime}_\\mu + \\kappa \\tilde A_\\mu \\right),\n\t\\label{eq:inmedium_interactions}\n\\end{align}\nmeaning that DM has an effective millicharge parameter $Q = \\kappa g_\\chi\/e$, and the interactions are identical to those for a massless dark photon. Note that this suppression of the $A'$-SM coupling in the $m_{A'} \\ll m_A$ limit is the source of the in-medium (plasma mass) suppression of the stellar constraints on dark photons~\\cite{An:2013yfc,An:2013yua} discussed in Section~\\ref{vectors}. Also note that this suppression means that the dark photon is not abundantly produced by SM interactions in the early universe and does not contribute to the effective number of relativistic species, $N_\\text{eff}$.\n\nIn the exactly massless $A'$ limit, we are free to perform a field redefinition on $A' \\to A' + \\kappa A$ in the vacuum Lagrangian, Eq.~\\eqref{eq:vacuumL}, which eliminates the kinetic mixing term and generates a DM interaction term $g_\\chi \\bar \\chi \\gamma^\\mu \\chi (A^\\prime_\\mu + \\kappa A_\\mu)$, which is again identical to having a millicharge $Q = \\kappa g_\\chi\/e$ under $U(1)_{EM}$. \n\nThe model considered here thus provides another realization of millicharged DM, and all of the stellar constraints discussed in the previous section apply. The only difference is the additional DM self-interaction via the $A'$, which potentially leads to sizeable self-interactions. \n\n\n\\section{Relic abundance from freeze-in \\label{sec:prod}}\n\nHere we compute the relic abundance of DM from freeze-in. We begin by reproducing the contribution from annihilation of SM fermions $f \\bar f \\to \\chi \\bar \\chi$ that was previously calculated in Refs.~\\cite{Essig:2011nj,Chu:2011be}. Because freeze-in is peaked at low temperatures and this paper concerns sub-MeV DM, electrons are the primary source of DM for this channel; in the rest of this section we explicitly refer to freeze-in off electrons, noting we have numerically checked that adding heavier fermions (for instance muons) to the calculation changes the results by less than 1\\%. In addition to freeze-in off electrons, there is a contribution from plasmon decays, $\\gamma^* \\to \\chi \\bar \\chi$, which we calculate for the first time. Photon annihilation into DM $\\gamma \\gamma \\to \\chi \\bar \\chi$ is suppressed by an additional factor of $Q^2$ and can be safely neglected. \n\nIn what follows, we take the observed present-day relic DM abundance to be $\\omega_{c} \\equiv \\Omega_{c} h^2 = 0.12$~\\cite{Aghanim:2018eyx}. After freeze-in, the DM density should scale like $a^{-3}$ and it is common practice to compare this to another quantity that has the same scaling irrespective of changes to the SM bath temperature. In this work we choose to compare the number density to the entropy density. Taking the present-day CMB temperature to be 2.73~K, the observed yield is then \\begin{equation} Y\\equiv n_\\chi\/s = 4.35\\times 10^{-7} \\times \\left(\\frac{1\\, \\mathrm{ MeV}}{m_\\chi}\\right) .\\end{equation}\nFor $m_\\chi\\gtrsim1$~keV, the DM yield is much lower than the order unity yield for relativistic species, such that DM contributes negligibly to $N_\\text{eff}$. This is in contrast to other DM models, such as thermal freeze-out, where sub-MeV DM would generically inject a considerable amount of entropy to the photon or neutrino sectors and would violate observational bounds on $N_\\text{eff}$.\\footnote{An exception for thermal, sub-MeV DM was pointed out in Ref.~\\cite{Berlin:2017ftj}, where the DM thermalizes with the SM thermal bath {\\emph{after}} neutrino-photon decoupling, reducing the contribution to $N_\\text{eff}$. Furthermore, in this model changes to $N_\\text{eff}$ that occur after DM thermalization are compensated by decoupling at a later time.}\n\nThe low DM occupation number also implies that it is possible to self-consistently ignore back-reactions that would reduce the DM number density, namely DM annihilation to electrons and inverse decays to plasmons. For instance, if we ignore the back-reaction, the solution for the number density of DM is significantly lower than the electron number density during the entirety of freeze-in in spite of the fact that the latter is becoming Boltzmann suppressed. Depletion of the DM number density through annihilation to dark photons $\\chi \\bar \\chi \\to \\gamma^{'} \\gamma^{'}$ is negligible for the same reason. In what follows, we solve the $0^\\text{th}$ moment of the Boltzmann equation ignoring back-reactions, noting that we have numerically checked that they are negligible. The relevant equation is then\n \\begin{equation} \n \\frac{d n_\\text{DM}}{d a} + \\frac{3 n_\\text{DM}}{a} = \\frac{2}{a H}\\left( \\avg{\\sigma v}_{e^+ e^- \\rightarrow \\chi\\bar{\\chi}} n_e^2\n + \\avg{\\Gamma}_{\\gamma^{*} \\rightarrow \\chi \\bar{\\chi}} n_{\\gamma^*}\\right).\n \\label{0thboltz}\n \\end{equation}\nHere we are using $a$ as our time variable. The relationship between $a$ and the SM temperature $T$ (which determines the DM production rate) is not adiabatic during freeze-in because the electrons are leaving the thermal bath at this time; this is discussed further in Appendix~\\ref{clock}. Note that we are solving for the total DM density which includes both $\\chi$ and $\\bar{\\chi}$ in the matter budget; assuming zero DM chemical potential, $n_\\text{DM} = 2 n_\\chi = 2 n_{\\bar{\\chi}}$, which accounts for the factor of two in Eq.~\\eqref{0thboltz}.\\footnote{This factor is related to the usual factor of $1\/2$ that appears in the Boltzmann equation for Dirac fermions~\\cite{Gondolo:1990dk, Srednicki:1988ce}; however, unlike the ordinary case of thermal DM, the change in the comoving DM density for freeze-in is independent of the DM number density (i.e. there is no factor of $n_\\text{DM}^2$ appearing in Eq.~\\eqref{0thboltz}) which accounts for the factor of four difference.}\n\n\n\\subsection{Annihilations}\n\n\nIn computing the DM relic abundance from annhilations of electron-positron pairs, we treat the two scenarios discussed in Section~\\ref{sec:model} as indistinguishable in the limit that $m_{A'}\\rightarrow 0$. We also ignore the in-medium photon mass for this process, which we find to be a percent level effect for $s$-channel annihilations happening at the relevant range of temperatures. In this limit, the matrix element squared is\n \\begin{align*} \n \\sum_\\mathrm{d.o.f.}\\abs{\\mathcal{M}}^2_{e^+ e^- \\leftrightarrow \\chi \\bar{\\chi}} =\\frac{32 \n Q^2 e^4}{ (p_{e^+}+p_{e^-})^4 \n} \\Big(& (p_{e^+}\\cdot p_\\chi) (p_{e^-}\\cdot p_{\\bar{\\chi}}) + (p_{e^+}\\cdot p_{\\bar{\\chi}}) (p_{e^-}\\cdot p_{\\chi})\\\\ &\n + m_e^2 (p_\\chi\\cdot p_{\\bar{\\chi}}) + m_\\chi^2(p_{e^+}\\cdot p_{e^-}) + 2 m_e^2 m_\\chi^2 \\Big), \\numberthis\n \\end{align*} \n where we sum over both initial \\emph{and} final spin degrees of freedom (d.o.f.) without averaging and where $Q$ is the effective millicharge in the dark photon case, $Q = \\kappa g_\\chi \/e$.\nThe thermally averaged cross section appearing in Eq.~\\eqref{0thboltz} for this process is given by\n\\begin{align*} \\avg{\\sigma v}_{e^+ e^- \\rightarrow \\chi\\bar{\\chi}} n_e^2 = \\int \\frac{ \\ensuremath{\\mathchar'26\\mkern-12mu d}^3 p_{e^+}}{2 E_{e^+}} \\frac{ \\ensuremath{\\mathchar'26\\mkern-12mu d}^3 p_{e^-}}{2 E_{e^-}}& \\frac{ \\ensuremath{\\mathchar'26\\mkern-12mu d}^3 p_\\chi}{2 E_\\chi} \\frac{ \\ensuremath{\\mathchar'26\\mkern-12mu d}^3 p_{\\bar{\\chi}}}{2 E_{\\bar{\\chi}}} ~e^{-(E_{e^+} + E_{e^-})\/T}\\numberthis \\label{sigmavann}\\\\& \\times \\sum_\\mathrm{d.o.f.} \\abs{\\mathcal{M}}_{e^+ e^- \\rightarrow \\chi\\bar{\\chi}}^2 (2 \\pi)^4 \\delta^{(4)}(p_{e^+} + p_{e^-} - p_\\chi - p_{\\bar{\\chi}}) \\quad \\quad \\end{align*}\nwhere $\\ensuremath{\\mathchar'26\\mkern-12mu d}^3 p \\equiv d^3 p\/(2\\pi)^3$. \nWe assume that from the onset of freeze-in, the electrons have entered the non-relativistic regime where their phase space is given by a Maxwell-Boltzmann distribution with temperature $T$ and zero chemical potential. As we will show, sub-MeV DM freeze-in through the annihilation channel is most effective at temperatures $T\\lesssim m_e$ where the effects of Fermi-Dirac statistics can be neglected. We also ignore Pauli blocking of the DM due to its low occupation number.\n\n\n\n \n To evaluate the thermal cross section, we note that the primordial plasma has a preferred rest frame (where bulk motions average to zero), which breaks Lorentz invariance. The phase space factors of Eq.~\\eqref{sigmavann} are evaluated in a frame that is comoving with the plasma. Practically, we can perform the integration by inserting factors of unity, \n\\begin{equation} \n \\int \\frac{ d^3 q_{12} d s_{12} }{2 E_{12}} \\delta^{(4)}(q_{12} - p_1 - p_2)=1, \n\\label{eq:unity}\n\\end{equation} \n where $q_{12}$ is the effective bulk 4-momentum of the particles labelled 1 and 2 and $s_{12}$ can be thought of as the effective (Lorentz invariant) mass-squared of a single particle with that bulk 3-momentum and energy (\\emph{i.e.} here $E_{12} = \\sqrt{s_{12} + \\vec{q}_{12}^{\\,2}}$). Inserting such a factor into Eq.~\\eqref{sigmavann} gives\n \\begin{align*} \\avg{\\sigma v}_{e^+ e^- \\rightarrow \\chi\\bar{\\chi}} n_e^2 &= \n \\int \\frac{ d^3 q_{\\chi \\bar{\\chi}} d s_{\\chi \\bar{\\chi}} }{2 E_{\\chi \\bar{\\chi}}} \\int \\frac{ \\ensuremath{\\mathchar'26\\mkern-12mu d}^3 p_{e^+}}{2 E_{e^+}} \\frac{ \\ensuremath{\\mathchar'26\\mkern-12mu d}^3 p_{e^-}}{2 E_{e^-}} \\frac{ \\ensuremath{\\mathchar'26\\mkern-12mu d}^3 p_\\chi}{2 E_\\chi} \\frac{ \\ensuremath{\\mathchar'26\\mkern-12mu d}^3 p_{\\bar{\\chi}}}{2 E_{\\bar{\\chi}}} ~e^{-(E_{e^+} + E_{e^-})\/T}\\numberthis \\\\& \\times \\sum_\\mathrm{d.o.f.} \\abs{\\mathcal{M}}_{e^+ e^- \\rightarrow \\chi\\bar{\\chi}}^2 (2 \\pi)^4 \\delta^{(4)}(p_{e^+} + p_{e^-} - p_\\chi - p_{\\bar{\\chi}}) \\delta^{(4)}(q_{\\chi \\bar{\\chi}} - p_\\chi - p_{\\bar{\\chi}}).\\quad \\quad \\end{align*}\nThe integral over $p_\\chi$ and $p_{\\bar{\\chi}}$ does not depend on the frame of $q_{\\chi \\bar{\\chi}}$, so the two-body phase space of $p_\\chi$ and $p_{\\bar{\\chi}}$ can be evaluated in the CM frame of $q_{\\chi \\bar{\\chi}}$. We define\n \\begin{align*} &\\Phi_{\\chi \\bar{\\chi}}(s_{\\chi \\bar{\\chi}}) \\abs{\\mathcal{M}}^2_\\text{CM}(s_{\\chi \\bar{\\chi}}) \\equiv \\int \\frac{ \\ensuremath{\\mathchar'26\\mkern-12mu d}^3 p_\\chi}{2 E_\\chi} \\int \\frac{ \\ensuremath{\\mathchar'26\\mkern-12mu d}^3 p_{\\bar{\\chi}}}{2 E_{\\bar{\\chi}}} (2 \\pi)^4 \\delta^{(4)}(q_{\\chi \\bar{\\chi}} - p_\\chi - p_{\\bar{\\chi}}) \\sum_\\mathrm{d.o.f.} \\abs{\\mathcal{M}}_{e^+ e^- \\rightarrow \\chi\\bar{\\chi}}^2 \\\\\n& = \\frac{ Q^2 e^4}{2 \\pi s_{\\chi \\bar{\\chi}}^2 } \\sqrt{1 -\\frac{4 m_\\chi^2}{s_{\\chi \\bar{\\chi}}}} \\left( s_{\\chi \\bar{\\chi}}^2 + \\frac{1}{3}(s_{\\chi \\bar{\\chi}} - 4 m_e^2) (s_{\\chi \\bar{\\chi}} - 4 m_\\chi^2)+ 4 s_{\\chi \\bar{\\chi}} (m_\\chi^2 +m_e^2) \\right),\\quad \\quad \\quad \\numberthis \\end{align*}\n and insert this into the expression for the thermally averaged cross section\n \\begin{align*} \\avg{\\sigma v}_{e^+ e^- \\rightarrow \\chi\\bar{\\chi}} n_e^2 = \\int \\frac{ d^3 q_{\\chi \\bar{\\chi}} d s_{\\chi \\bar{\\chi}} }{2 E_{\\chi \\bar{\\chi}}}~ e^{-E_{\\chi \\bar{\\chi}}\/T} & \\Phi_{\\chi \\bar{\\chi}}(s_{\\chi \\bar{\\chi}})\\abs{\\mathcal{M}}^2_\\text{CM}(s_{\\chi \\bar{\\chi}})\\\\\n \\times & \\int \\frac{ \\ensuremath{\\mathchar'26\\mkern-12mu d}^3 p_{e^+}}{2 E_{e^+}} \\frac{ \\ensuremath{\\mathchar'26\\mkern-12mu d}^3 p_{e^-}}{2 E_{e^-}} \\delta^{(4)}(p_{e^+}+p_{e^-}-q_{\\chi \\bar{\\chi}} ) . \\numberthis \\end{align*}\nAgain, we can evaluate the integral over $p_{e^+}$ and $p_{e^-}$ in the center-of-mass frame. Defining\n\\begin{equation} \\Phi_{e^+ e^- }(s_{\\chi \\bar{\\chi}}) \\equiv \\frac{1}{8 \\pi} \\sqrt{1 - \\frac{4 m_e^2}{s_{\\chi \\bar{\\chi}}}},\\end{equation}\nthe thermally averaged cross section becomes\n \\begin{align}\n\\avg{\\sigma v}_{e^+ e^- \\rightarrow \\chi\\bar{\\chi}} n_e^2 &= \\frac{1 }{ (2 \\pi)^4} \\int \\frac{ d^3 q_{\\chi \\bar{\\chi}} d s_{\\chi \\bar{\\chi}} }{2 E_{\\chi \\bar{\\chi}}} e^{-E_{\\chi \\bar{\\chi}}\/T} \\Phi_{e^+ e^- }(s_{\\chi \\bar{\\chi}})\\Phi_{\\chi \\bar{\\chi}}(s_{\\chi \\bar{\\chi}})\\abs{\\mathcal{M}}^2_\\text{CM}(s_{\\chi \\bar{\\chi}}).\n\\end{align}\nWe can write this result in terms of the first order modified Bessel function of the second kind $K_1(z) = z \\int_1^\\infty d u \\,e^{- z u} \\sqrt{u^2 - 1} $ with $u = \\sqrt{1+ q_{\\chi \\bar{\\chi}}^2 \/s_{\\chi \\bar{\\chi}}} \\,$ :\n\\begin{equation} \\avg{\\sigma v}_{e^+ e^- \\rightarrow \\chi\\bar{\\chi}} n_e^2 = \\frac{ T}{(2 \\pi)^3} \\int ds\\,\\sqrt{s}~ \\Phi_{e^+ e^- }(s)\\,\\Phi_{\\chi \\bar{\\chi}}(s) \\abs{\\mathcal{M}}^2_\\text{CM}(s)\\, K_1(\\sqrt{s}\/T)\\end{equation}\nwhere we have dropped the subscript on the integration variable $s$. Note that $s$ is restricted to $s > 4\\max\\left(m_e^2, m_\\chi^2\\right)$. The procedure above provides an alternate derivation of the well-known results from Ref.~\\cite{Gondolo:1990dk}, and we have validated this method here because we use similar techniques to derive the full collision term for annihilation in Section~\\ref{sec:ann_phasespace}.\n\n\n\n\\subsection{Plasmon decay \\label{sec:plasmon}}\n\nThe early Universe is an optically thick plasma where photons acquire an in-medium mass; this can be understood classically as arising from the electrons' oscillatory response to a propagating electric field and the dynamical shielding of that electric field. This effective mass is also manifest in the photon propagator and the polarization vectors of external photon legs in the medium; in other words, the photon mass and wavefunction are renormalized in the plasma. The effective masses and dressed polarization functions for the transverse and longitudinal ``plasmon'' modes are shown in Fig.~\\ref{fig:plasmon} and explicit formulae are provided in Appendix~\\ref{plasma}. The effective mass for plasmons is closely related to the plasma frequency. For a relativistic plasma at zero chemical potential, the plasma frequency is $\\omega_p = eT\/3 \\approx 0.1 T$ where $e$ is electric charge. \n\nPlasmons can undergo decay provided that it is kinematically allowed. For instance, plasmons can decay to neutrino pairs through mixing with the $Z$ boson \\cite{Braaten:1993jw}. Plasmons cannot decay to charged particles in the SM because their effective mass is also renormalized in the medium and it is always kinematically forbidden. However, this is not the case for millicharged DM where corrections to the mass are suppressed by powers of $Q$. \n\n\\onecolumngrid\n\\begin{figure*}[t!]\n\\includegraphics[width=\\textwidth]{m_eff_Zk.pdf}\n\\caption{The effective in-medium mass (left) and wavefunction renormalization (right) for photons, as computed in Coulomb gauge for a plasma with $T=1$~MeV and zero chemical potential (see Appendix~\\ref{plasma} for relevent formulae). The transverse mode is relevant at all wavelengths while the longitudinal mode crosses the lightcone at high $k$ and can thus only propagate at low $k$. Also shown are the low-$k$, low-$T$ and high-$k$, high-$T$ limits for the effective transverse mass, $m_t = \\omega_p$ and $m_t = \\sqrt{3\/2}\\omega_p$, respectively.}\n\\label{fig:plasmon}\n\\end{figure*}\n \n\nThe effective matrix element that captures plasmons decaying to DM is \n\\begin{equation} \ni \\mathcal{M}_{\\gamma^* \\rightarrow \\chi \\bar{\\chi}} = i Q e\\, \\tilde{\\epsilon}_\\mu(k) \\bar{u}(p_\\chi) \\gamma^\\mu v(p_{\\bar{\\chi}}), \\end{equation} \nwhere $\\tilde{\\epsilon}_\\mu(k)$ is the dressed polarization vector for the longitudinal and transverse plasmon modes as detailed in Appendix~\\ref{plasma}, where we work in Coulomb gauge. We express this process in terms of the DM effective millicharge $Q$ and in Appendix~\\ref{basis} we show explicitly that decaying through a dark photon gives the same effective matrix element in the limit $m_{A'}\\rightarrow 0$. In squaring and summing over polarizations, only the diagonal terms ($LL$, $++$, and $--$) contribute,\n\\begin{equation} \\sum_\\mathrm{d.o.f.} \\abs{\\mathcal{M}}^2_{\\gamma^* \\rightarrow \\chi \\bar{\\chi}} = 4 Q^2 e^2 \\times \\begin{cases}\n2 Z_t(k) ( p_\\chi^2 \\sin^2 \\theta + \\omega_t(k) E_\\chi - k p_\\chi \\cos \\theta) & {++ \\& --} \\\\\nZ_\\ell(k) \\frac{\\omega_\\ell(k)^2}{k^2} (\\omega_\\ell(k) E_\\chi - 2 E_\\chi^2 + k p_\\chi \\cos \\theta) & \\text{LL},\n\\end{cases}\n\\end{equation}\nwhere the photon four-momentum is given by $K^\\mu = \\big(\\omega(k), \\vec{k}\\big)^\\mu$ with appropriate dispersion relations for transverse and longitudinal modes $\\omega_t(k)$ and $\\omega_\\ell(k)$ (see Appendix~\\ref{plasma}), the DM four-momentum is given by $\\left(E_\\chi, \\vec{p}_\\chi\\right)^\\mu$, $\\theta$ is the angle between $\\vec{k}$ and $\\vec{p}_\\chi$, and $Z_t(k)$ and $Z_\\ell(k)$ are wavefunction renormalization factors (shown in Fig.~\\ref{fig:plasmon}) that are related to the dressed polarization vectors for the transverse and longitudinal modes.\n\nThe thermally averaged decay rate is \\begin{equation} \\left< \\Gamma\\right>_{\\gamma^* \\rightarrow \\chi \\bar{\\chi}} n_{\\gamma^*} = \\int \\frac{\\ensuremath{\\mathchar'26\\mkern-12mu d}^3 k}{2 \\omega(k)} \\frac{\\ensuremath{\\mathchar'26\\mkern-12mu d}^3 p_\\chi}{2 E_\\chi}\\frac{\\ensuremath{\\mathchar'26\\mkern-12mu d}^3 p_{\\bar{\\chi}}}{2 E_{\\bar{\\chi}}} ~f\\left(\\omega(k)\\right) \n (2\\pi)^4 \\delta^{(4)}\\left(K - p_\\chi - p_{\\bar{\\chi}}\\right) \\sum_\\mathrm{d.o.f.} \\abs{\\mathcal{M}}^2_{\\gamma^* \\rightarrow \\chi \\bar{\\chi}},\\end{equation}\nand can be evaluated directly. Taking the plasmons to be Bose-Einstein distributed, the longitudinal and transverse contributions to this rate are\n\\begin{equation} \\left< \\Gamma\\right>_{\\gamma^*_\\ell \\rightarrow \\chi \\bar{\\chi}} n_{\\gamma^*_\\ell} =\\frac{ Q^2 e^2}{(2 \\pi)^3} \\int k^2 \\,d k \\, \\frac{Z_\\ell(k) \\omega_\\ell (k)(m_\\ell(k)^2 + 2 m_\\chi^2 )\\sqrt{m_\\ell(k)^2(m_\\ell(k)^2 -4 m_\\chi^2)}}{3 m_\\ell(k)^4 \\left(e^{\\omega_\\ell(k)\/T}-1 \\right)} \\end{equation}\n\\begin{equation} \\left< \\Gamma\\right>_{\\gamma^*_t \\rightarrow \\chi \\bar{\\chi}} n_{\\gamma^*_t}= \\frac{ 4Q^2 e^2 }{(2 \\pi)^3} \\int k^2 \\,d k \\, \\frac{ Z_t(k)(m_t(k)^2 -m_\\chi^2)\\sqrt{m_t(k)^2 (m_t(k)^2 - 4 m_\\chi^2)}}{3 \\omega_t (k)\\,m_t(k)^2 \\left(e^{\\omega_t(k)\/T}-1 \\right)}, \\end{equation}\nwhere the effective plasmon masses are $m_\\ell(k)^2 = \\omega_\\ell(k)^2 - k^2$ for the longitudinal modes and $m_t(k)^2 = \\omega_t(k)^2 - k^2$ for the tranverse ones.\nThe final integrals over $k$ can be computed numerically and the total plasmon contribution to decay is dominated by the transverse modes (note that we are working in Coulomb gauge). This is because the longitudinal mode has a finite range of $k$ over which it can propagate, meaning that it has less available phase space than the transverse mode which has no restriction in $k$. Furthermore, the longitudinal mass and renormalization factors fall steeply within the range of $k$ where this mode can propagate. \n\n\n\\subsection{Couplings for freeze-in}\n\nIn solving the zeroth moment of the Boltzmann equation for the DM relic abundance, we find that the relative contributions from $e^+ e^-$ annihilation and plasmon decays are starkly different in different mass ranges, as illustrated in Fig.~\\ref{masscomp_abundance}. \n\\begin{figure*}[t]\n\\includegraphics[width=0.5\\textwidth]{abundance_40.pdf}\\includegraphics[width=0.5\\textwidth]{abundance_400.pdf}\n\\caption{Evolution of the comoving DM number density for $m_\\chi = 40$~keV (left) and $m_\\chi = 400$~keV (right) as compared to the relic abundance of DM with that mass. Also shown are the relative contributions from electron-positron annihilations and plasmon decays, as discussed in the text.}\n\\label{masscomp_abundance}\n\\end{figure*}\nThis can be understood by considering the fact that freeze-in is dominant at low temperatures, provided that it is kinematically allowed and that the population the DM is freezing in from has a sufficient abundance. For sub-MeV DM, freeze-in from $e^+e^-$ annihilation is always kinematically allowed and this process only ends when the electron number density becomes Boltzmann suppressed, namely $T\\lesssim m_e$. Meanwhile, the plasmon abundance is not Boltzmann suppressed but the mass runs with temperature, so freeze-in through plasmon decay ends when it is no longer kinematically allowed, namely when $m_{\\gamma^*}\\sim \\omega_p = 2 m_\\chi$. Since $\\omega_p \\approx 0.1 T$ in the relativistic limit, plasmon decay to millicharged DM shuts off at an earlier time compared to annihiliation. These two criteria are shown in Fig.~\\ref{masscomp_abundance} and indeed we see that plasmon decays are more dominant in determining the relic abundance for lower mass DM because the decays are active for a longer period of time.\n\nIn terms of the effective millicharge needed to produce the observed DM relic abundance, we find that including plasmon decays leads to a significant reduction in coupling for keV-mass DM while the effect is small once $m_\\chi$~=~MeV. \nThe change to the freeze-in benchmark for direct detection is shown in Fig.~\\ref{DDshift},\n\\begin{figure}[t]\n\\includegraphics[width=0.7\\textwidth]{DD_comparison.pdf} \n\\caption{The effect of plasmon decays on the freeze-in benchmark for direct detection via electron recoils. Also shown are the projected sensitivities of low-threshold experiments with kg-day exposure, including a SuperCDMS G2 experiment~\\cite{Battaglieri:2017aum} and proposals using polar materials (GaAs and Al$_2$O$_3$)~\\cite{Griffin:2018bjn, Knapen:2017ekk}, Dirac materials (ZrTe$_5$)~\\cite{Hochberg:2017wce}, or superconductors (Al SC)~\\cite{Hochberg:2015fth}.\n\\label{DDshift}}\n\\end{figure} \nwhere the cross section for electron recoils is \n\\begin{equation} \\sigma_e = \\frac{16 \\pi Q^2 \\alpha^2 \\mu_{\\chi e}^2}{ (\\alpha m_e)^4} . \\end{equation}\nHere $\\mu_{\\chi e}$ is the electron-DM reduced mass, $\\mu_{\\chi e} = m_e m_\\chi \/ (m_e + m_\\chi)$. At the lowest mass where proposed low-threshold direct detection experiments are sensitive, the plasmon decay channel for DM production lowers the expected signal strength by roughly an order of magnitude.\n\nIt has been noted in the literature~\\cite{Chuzhoy:2008zy,Hu:2016xas,Dunsky:2018mqs} that millicharged DM could be efficiently accelerated in supernova remnants, which would lead to an accelerated component of dark cosmic rays and eject DM from the disk. Both of these effects can lead to substantial changes to the predicted direct detection rates and sensitivities of proposed experiments shown above. However, the conclusions are highly sensitive to aspects of cosmic ray physics which are not fully understood, such as the injection of particles into the diffusive shock acceleration process. The predictions would also be sensitive to whether the DM obtains its effective millicharge through a kinetic mixing portal; in this case, the dark photon mass and couplings can affect the acceleration, and an exploration of these effects is beyond the scope of this work.\n\n\n\n\\section{Dark matter phase space distribution \\label{sec:phasespace}}\n\nSince freeze-in DM is so weakly coupled to the SM, it does not thermalize with the SM during freeze-in and the phase space distribution can deviate substantially from a thermal distribution. While this has no clear impact on direct detection, since galaxy assembly is expected to significantly alter the DM velocity distribution, it does affect DM free-streaming and DM-SM scattering in the early universe. Here we compute the full phase space distributions needed to determine the cosmological observables; the signatures, constraints, and detection prospects will be presented in a companion paper~\\cite{inprep}.\n\nWe must solve the full Boltzmann equation in an expanding background, given by \n\\begin{equation} \n \\frac{\\partial f_\\chi}{\\partial t} - H \\frac{p_\\chi^2}{E_\\chi} \\frac{\\partial f_\\chi}{\\partial E_\\chi} = \\frac{C(p_\\chi, t)}{E_\\chi}, \n\\end{equation}\nwhere $C(p_\\chi, t)$ is the collision term, which encapsulates all interactions that affect the phase space. At early times, the interactions that determine the phase space evolution are $e^+ e^-$ annihilation and plasmon decay. We have checked numerically that heavier fermion annihilation processes (for instance the annihilation of muon-antimuon pairs) affect the phase space by a negligible amount because they occur only at early times when freeze-in is less efficient. Scattering has a negligible impact on the phase space during freeze-in since the DM occupation number is much smaller than that of electrons or plasmons. Neglecting the small effect of scattering during freeze-in, the collision term is independent of $f_\\chi$ to leading order and the Boltzmann equation can be solved by direct integration~\\cite{Bae:2017dpt}, \n\\begin{equation} \n f_\\chi(p_\\chi, t) = \\int_{t_i}^{t} dt'\\, \\frac{C\\left(\\frac{a(t)}{a(t')}\\, p_\\chi, t'\\right)}{\\sqrt{\\frac{a(t)^2}{a(t')^2}\\, p_\\chi^2+m_\\chi^2} } = \\int_{a_i}^{a(t)} \\frac{da'}{a' H(a')}\\, \\frac{C\\left(\\frac{a(t)}{a'}\\, p_\\chi, a'\\right)}{\\sqrt{\\frac{a(t)^2}{a'^2}\\, p_\\chi^2+m_\\chi^2} }. \\label{axinoapprox}\n\\end{equation}\nHere the factors of $a$ in the integrand keep track of redshifting of momentum due to expansion. We use the scale factor $a$ as our time variable rather than the common choice of using the SM temperature because it is not evolving adiabatically as the electron-positron pairs leave the bath during freeze-in. The temperature evolution and the evolution of the Hubble parameter are detailed in Appendix~\\ref{clock}. \n\nAfter freeze-in ends, the DM momenta redshift and the phase space distribution is constant in comoving momentum. However, at late times DM-SM and DM-DM scattering eventually can become important since the scattering cross sections are peaked at low relative velocities. The effects of DM-SM scattering on the phase space are generally negligible for the allowed parameter space, but DM self-scattering can lead to thermalization of the DM phase space distribution. Whether this occurs is model-dependent, and we discuss the conditions for this to occur in Section~\\ref{sec:DMscattering}.\n \n\\subsection{Phase space from annihilation \\label{sec:ann_phasespace} }\nThe computation of the full collision term from annihilation proceeds similarly to the computation of its zeroth moment. Once again, inserting a factor of unity as defined in Eq.~\\eqref{eq:unity}, we find \n\\begin{align*} \n C(p_\\chi, t)_{e^+ e^- \\rightarrow \\chi\\bar{\\chi}} \n = \\frac{1}{2(2 \\pi)^3} \\int \\frac{ d^3 q_{e^+ e^-} d s_{e^+ e^- } }{2 E_{\\bar{\\chi}} 2 E_{e^+ e^-}} & \\delta(E_{e^+ e^-} - E_\\chi - E_{\\bar{\\chi}}) ~e^{-E_{e^+ e^-}\/T}\\\\\n &\\times \\Phi_{e^+ e^-}(s_{e^+ e^-}) \\abs{\\mathcal{M}}^2_\\text{CM}(s_{e^+ e^-}), \\numberthis\n\\end{align*}\nwhere $E_{\\bar{\\chi}} = \\sqrt{m_\\chi^2 + p_{{\\chi}}^2 + q_{e^+ e^-}^2 - 2 p_\\chi q_{e^+ e^-} \\cos \\theta}$, $E_{e^+ e^-} = \\sqrt{s_{e^+e^-}+q^2_{e^+ e^-}}$ and $\\theta$ is the angle that $\\vec{q}_{e^+ e^-}$ makes with the unconstrained, unintegrated $\\vec{p}_\\chi$. \nDefining $x \\equiv \\cos\\theta$ and dropping the subscript on the bulk electron momentum, we find \n\\begin{align}\n& C(p_\\chi, t)_{e^+ e^- \\rightarrow \\chi\\bar{\\chi}} = \\frac{1}{2 (2 \\pi)^2 p_\\chi} \\int \\frac{ dx \\,q d q\\, d s }{ 4 E} \\delta \\left(x-\\frac{2 E_\\chi E -s}{2 p_\\chi q}\\right) e^{-E\/T} \\Phi_{e^+ e^-}(s) \\abs{\\mathcal{M}}^2_\\text{CM}(s).\n\\end{align}\nRequiring that $x \\in [-1, 1]$ and switching integration variables,\n\\begin{align*} &C(p_\\chi, t)_{e^+ e^- \\rightarrow \\chi\\bar{\\chi}} = \\frac{1}{8 p_\\chi (2 \\pi)^2} \\int\nd s\\int_{\\frac{E_\\chi s - p_\\chi \\sqrt{s(s-4 m_\\chi^2)}}{2 m_\\chi^2}}^{\\frac{E_\\chi s + p_\\chi \\sqrt{s(s-4 m_\\chi^2)}}{2 m_\\chi^2}} d E \\, e^{-E\/T} \\Phi_{e^+ e^-}(s) \\abs{\\mathcal{M}}^2_\\text{CM}(s) \\\\\n&= \\frac{ T }{ 4 p_\\chi (2 \\pi)^2} \\int\nd s \\, e^{-\\frac{ E_\\chi s}{2 m_\\chi^2 T}} \\sinh \\left( \\frac{ p_\\chi \\sqrt{s(s-4 m_\\chi^2)}}{2 m_\\chi^2 T}\\right) \\Phi_{e^+ e^-}(s) \\abs{\\mathcal{M}}^2_\\text{CM}(s). \\numberthis \\label{colltermann} \\end{align*}\nThen, to solve for the final phase space from annihilation, we can combine Eqs.~\\eqref{axinoapprox} and \\eqref{colltermann}. Note that because $p_\\chi$ is fixed (rather than an integration variable), $s$ in the above integral is restricted to $s > \\max \\left(4 m_e^2, 2 m_\\chi (E_\\chi + m_\\chi)\\right)$ unlike in the integral for determining the thermally averaged cross section. The resulting evolution of the phase space distribution is shown in the left panel of Fig.~\\ref{freezephase}.\n\n\n\\onecolumngrid\n\\begin{figure*}[t]\n\\includegraphics[width=\\textwidth]{freezein_temp_new.pdf}\n\\caption{A comparison of the phase space evolution of DM being produced by $e^+ e^-$ annihilation (left) and $\\gamma^*$ decay (right) at $m_\\chi = 40$~keV. The momenta shown here are comoving, $P_\\chi \\equiv a p_\\chi$ where $a=1$ corresponds to $T= 1$~MeV. The phase space is normalized arbitrarily for the purposes of comparing the $P_\\chi$-dependence side by side. Over time, the comoving phase space converges to its final frozen-in shape. The phase space from annihilation is similar to that of the thermal electrons from which they inherit their kinematics. Meanwhile, the phase space from plasmon decay is highly peaked at low $P_\\chi$ because freeze-in through this channel occurs predominantly at threshold when $\\omega_p \\sim 2 m_\\chi$ and the decay is peaked when the plasmon is ``at rest,'' $k\\rightarrow0$. }\n\\label{freezephase}\n\\end{figure*}\n \n\n\\subsection{Phase space from plasmon decay \\label{sec:plasmon_phasespace} }\n\nThe collision term from plasmon decay,\n\\begin{equation} C(p_\\chi, t)_{\\gamma^* \\rightarrow \\chi \\bar{\\chi}} = \\frac{1}{2}\\int \\frac{ \\ensuremath{\\mathchar'26\\mkern-12mu d}^3 k}{2 \\omega(k)} \\frac{ \\ensuremath{\\mathchar'26\\mkern-12mu d}^3 p_{\\bar{\\chi}}}{2 E_{\\bar{\\chi}}} \\frac{1}{e^{\\omega(k)\/T}-1} (2 \\pi)^4 \\delta^{(4)}(K - p_\\chi - p_{\\bar{\\chi}}) \\sum_\\mathrm{d.o.f.} \\abs{\\mathcal{M}}^2_{\\gamma^* \\rightarrow \\chi \\bar{\\chi}}\\end{equation} \nproceeds through direct computation. We find\n\\begin{align} C(p_\\chi, t)_{\\gamma^*_\\ell \\rightarrow \\chi \\bar{\\chi}} &= \\frac{ Q^2 e^2 }{4 \\pi p_\\chi} \\int \\frac{dk\\, \\omega_\\ell (k) Z_\\ell(k) }{k\\, (e^{\\omega_\\ell(k)\/T}-1)} \\left(2 E_\\chi (\\omega_\\ell(k) - E_\\chi) - m_\\ell(k)^2\/2\\right)\n \\\\ C(p_\\chi, t)_{\\gamma^*_t \\rightarrow \\chi \\bar{\\chi}} &= \\frac{ Q^2 e^2 }{4 \\pi p_\\chi} \\int \\frac{dk\\,k Z_t(k)}{\\omega_t(k) (e^{\\omega_t(k)\/T}-1)} \\left(2 p_\\chi^2 - \\frac{( 2 E_\\chi \\omega_t(k) - m_t(k)^2)^2}{2 k^2} +m_t(k)^2\\right)\n\\end{align}\nwhere the limits of the $k$ integral are determined by the requirement that $x_0 = (2 E_\\chi \\omega_{\\ell, t}(k) - m_{\\ell, t}(k)^2)\/2 k p_\\chi$ lies in the range $[-1,1]$. The limits of integration cannot be solved for in closed form because of the nontrivial dispersion relations, so the phase space must be determined numerically.\n\nThe evolution of the phase space from plasmon decays is shown in the right panel of Fig.~\\ref{freezephase}, and our results for the combined phase space can be found in Fig.~\\ref{masscomp_phase}. The distributions are noticeably nonthermal due to plasmon decays. Fig.~\\ref{Teff} compares the average momentum and momentum-squared of the DM to the SM photons, which serves as a useful metric to determine the DM free-streaming and suppression of the growth of structure.\n\n\\onecolumngrid\n\\begin{figure*}[t]\n\\includegraphics[width=\\textwidth]{phase_comp_new.pdf}\n\\caption{A comparison of the contributions to the phase space for $m_\\chi = 40$~keV (left) and $m_\\chi = 400$~keV (right). The momenta shown here are comoving, $P_\\chi \\equiv a p_\\chi$ where $a=1$ corresponds to $T= 1$~MeV. The phase space is normalized to the comoving DM relic abundance for each mass depicted. The plasmon contribution dominates more at low masses than at high masses because freeze-in through this channel persists for longer at lower masses, ending when the plasmon mass is at threshold, $\\omega_p \\sim 2 m_\\chi$. Also shown (dashed lines) are the phase space distributions that would arise if the DM could thermalize within its own sector, conserving $\\left$ for non-relativistic DM.}\n\\label{masscomp_phase}\n\\end{figure*}\n \n\n\\begin{figure}[t]\n\\includegraphics[width=0.7\\textwidth]{Teff_new.pdf}\n\\caption{A comparison between moments of the DM phase space and the SM photon phase space as a function of DM mass. For reference, the moments for the SM photon are $\\langle p_\\gamma \\rangle = 2.7\\, T_\\gamma$ and $\\langle p_\\gamma^2 \\rangle = 10.35\\, T_\\gamma^2$. While the DM phase space is not thermal, these moments can be thought of as relating to the DM effective temperature, which will have ramifications for the subsequent cosmology. As the DM mass rises, the effective temperature increases because $e^+ e^-$ annihilations become more important than plasmon decays and have a comparatively fatter high-$p_\\chi$ tail. At even larger masses where $m_\\chi$ is comparable to $m_e$, that high-$p_\\chi$ tail is suppressed because the DM mass becomes relevant to the kinematics of annihilation, causing the effective temperature to drop. }\n\\label{Teff}\n\\end{figure}\n\n\\subsection{Effect of DM-SM scattering \\label{sec:scattering}}\n\nWe argue here that the effect of DM-SM scattering on the DM phase-space distribution is small from freeze-in until the onset of recombination. The relevant quantity is the momentum-transfer rate, which we estimate in the limits where the DM is relativistic and non-relativistic. We do not consider scattering by relativistic, charged SM particles because this is only relevant for electrons during freeze-in; during freeze-in, the number density of DM is many orders of magnitude smaller than the number density of electrons and the effect of electron-DM scattering is suppressed by $n_\\chi\/n_e$ relative to the dominant effect of electron-positron annihilations on the phase space. \nAs outlined below, DM-SM scattering becomes more important at low velocities, corresponding to later cosmological times. This can affect CMB anisotropies and the cosmological 21~cm signal, and we provide more detailed calculations in that context in our companion paper~\\cite{inprep}.\n\nIn the limit of relativistic DM scattering with non-relativistic SM particles (the case after freeze-in until $T_\\gamma \\sim m_\\chi$), the differential cross section with respect to the center-of-mass scattering angle $\\theta_\\text{CM}$ is given by\n\\begin{align}\n \\frac{d\\sigma_{\\chi b}}{d\\cos \\theta_\\text{CM}} = \\frac{ \\pi Q^2 \\alpha^2 }{ p_\\text{CM}^2} \\frac{ (1+ \\cos \\theta_\\text{CM})}{(1 - \\cos \\theta_\\text{CM} +m_D^2\/2p_{\\text{CM}}^2)^2}, \n \\label{eq:scattering_relativistic}\n\\end{align}\nwhere $p_{\\text{CM}}\\equiv | \\vec{p}_{\\text{CM}}|$ is the momentum in the CM frame. Here we have taken $p_\\chi \\ll m_e$, which is a good approximation after freeze-in has ended. In this approximation, the dependence on the SM particle mass drops out, making scattering with electrons and protons equally important (we refer to them collectively as ``baryons,'' in the remainder of this discussion, hence the subscript $b$ in the cross section). The dependence on the Debye mass $m_D$ comes from the photon propagator for electric scattering in a medium~\\cite{Blaizot:1995kg}. The usual $t$-channel divergence is thus regulated in the forward-scattering limit by the Debye angle, defined as $\\theta_D \\equiv m_D\/p_{\\text{CM}}$. Once the plasma has become non-relativistic with $T_\\gamma \\lesssim m_e$, the Debye mass is given by \\begin{equation} m_D = \\sqrt{4 \\pi \\alpha n_e\/T_\\gamma} = 3.7\\times 10^{-6}\\, T_\\gamma \\end{equation}\nin natural units, assuming $\\Omega_b h^2 = 0.022$ \\cite{Aghanim:2018eyx} and that the ionization fraction is unity. The momentum transfer cross section is defined for DM self-scattering in Eq.~\\eqref{eq:transfer} and the analogous definition applies for scattering between DM and SM particles. For relativistic DM, we find that in the limit of the Debye angle $\\theta_D \\ll 1$\n\\begin{align}\n \\sigma_{T,\\, \\chi b} = \\frac{4 \\pi Q^2 \\alpha^2}{p_\\chi^2} \\log \\frac{2}{\\theta_{D}} .\n\\end{align}\nSince $m_b \\gg m_\\chi$ and the baryons are non-relativistic, the DM momentum in the CM frame can be approximated by the DM momentum in the comoving frame, $p_\\chi$. As illustrated in Fig.~\\ref{Teff}, the typical DM momentum is comparable to the SM photon temperature, with both quantities redshifting after freeze-in. Therefore, we can estimate the momentum transfer rate per DM particle and per Hubble time as\n\\begin{align}\n \\frac{ n_p \\sigma_{T, \\,\\chi b}}{H} \\approx 5.3 \\times 10^{-11} \\, \\left( \\frac{ Q}{10^{-10}} \\right)^2 \\left( \\frac{ \\textrm{MeV} }{T_\\gamma} \\right) ,\n\\end{align}\nwhere $n_p \\approx 1.5 \\times 10^{-10}\\, T_\\gamma^3$ and $p_\\chi \\approx 0.4 \\, p_\\gamma \\approx T_\\gamma$. For $T_\\gamma$ in the keV-MeV range and $Q < 10^{-10}$ for freeze-in, this rate is tiny and thus scattering in this regime has a negligible effect on the DM phase space. \n\nFor scattering of non-relativistic DM and charged SM particles, the differential cross section is instead given by \\begin{align}\n \\frac{d\\sigma_{\\chi b}}{d\\cos \\theta_\\text{CM}} = \\frac{2 \\pi Q^2 \\alpha^2 }{ \\mu_{\\chi b}^2 v^4} \\frac{ 1}{(1 - \\cos \\theta_\\text{CM} +m_D^2\/2p_{\\rm CM}^2)^2}, \n \\label{eq:scattering_NR}\n\\end{align}\nwhere $\\mu_{\\chi b}$ is the reduced mass of the DM and baryon, $\\mu_{\\chi b} = m_\\chi m_b\/(m_\\chi+m_b)$, $v$ is the relative velocity between DM and SM particles, and $ p_{\\rm CM} = \\mu_{\\chi b} v$. The momentum transfer cross section is\n\\begin{align}\n\t\\sigma_{T,\\, \\chi b} = \\frac{4 \\pi \\, Q^2 \\alpha^2 }{ \\mu_{\\chi b}^2 v^4} \\log \\frac{2}{\\theta_{D}}\n \\label{eq:NRmomentumtransfer} \\, ,\n\\end{align}\nwhere again we take the $\\theta_D \\ll 1$ limit.\nNote that the Coulomb logarithm appearing here differs from the one that appears in the often-quoted Ref.~\\cite{McDermott:2010pa}; however, that reference did not include the Debye mass in the photon propagator, as discussed in Appendix~\\ref{appendix:debeye}. Compared to the Coulomb logarithm in Ref.~\\cite{McDermott:2010pa}, our treatment of the Debye mass results in a factor of $2.5-3$ smaller momentum transfer rate at recombination; this will translate to a weaker CMB bound on generic millicharged DM than has been reported previously~\\cite{Dvorkin:2013cea,Xu:2018efh,Slatyer:2018aqg,Kovetz:2018zan,Boddy:2018wzy}, which we explore in more detail in our companion paper~\\cite{inprep}.\n\nGiven the velocity scaling in Eq.~\\eqref{eq:NRmomentumtransfer}, momentum transfer is most important at late times. For freeze-in couplings, there may be a substantial effect at the recombination epoch. In particular, momentum transfer during this epoch leads to a drag force between the DM and baryon fluids, which can affect CMB anisotropies~\\cite{Dubovsky:2001tr,Dvorkin:2013cea,Boddy:2018kfv,Boddy:2018wzy}. The CMB bounds {\\emph{require}} that the momentum transfer rate is slow compared to the rate of Hubble expansion at $z \\approx 1100$, thus limiting the possible effect on the DM phase space. We calculate the bounds in detail in the companion paper~\\cite{inprep}, properly accounting for the velocity distribution for freeze-in DM with the updated Coulomb logarithm.\n\nIn addition to DM-baryon scattering as discussed above, DM-photon scattering is possible. However, these processes do not have the low-velocity $v^{-4}$ enhancement in the rate and the cross section scales as $Q^4$, so the effects are negligible. In the model with a dark photon $A'$, scattering processes such as $ e^-+ \\gamma \\to e^- + A'$ are also possible and scale only as kinetic mixing squared $\\kappa^2$. However, these processes are still negligible compared to DM-baryon scattering since they lack the low-$v$ enhancement and have an additional large suppression due to the in-medium kinetic mixing effects, as discussed in Section~\\ref{sec:darkphoton}. Processes like $\\chi + \\gamma\\to \\chi + A'$ scale as $Q^2 g_\\chi^2$; these also lack the $v^{-4}$ enhancement and any enhancement (relative to DM-baryon scattering) from the large photon-to-baryon ratio is more than compensated by the factor of $g_\\chi^2$, even at the largest values of $g_\\chi$ that saturate SIDM bounds. \n\n\\subsection{Effect of DM-DM scattering \\label{sec:DMscattering}}\n\nIn the absence of a dark photon, DM self scattering is proportional to $Q^4$, rendering it entirely negligible. However, self-interactions of the DM can effectively thermalize the phase space distribution in the model with a dark photon. The rate for dark photon mediated DM scattering is proportional to $g_\\chi^4$, and thus may be important if $g_\\chi$ is sufficiently large compared to $\\kappa$. Similar to DM-baryon scattering, the cross section scales as $1\/v^4$ and so these effects are most important at later times when the DM is cooler. Sufficient levels of self-scattering will convert a free-streaming phase space distribution into a Maxwell-Boltzmann or Gaussian velocity distribution. In the non-relativistic limit, the quantity $\\langle a(t)^2 p_\\chi^2 \\rangle$ will remain the same after this process (by conservation of comoving energy), although other moments of the phase space differ.\n\n\n\n\nTo determine when self-scattering becomes important, we estimate the redshift $z_{\\rm therm}$ when the momentum transfer rate per DM particle and per Hubble time is order unity:\n\\begin{align}\n \\frac{ n_\\chi \\sigma_{T,\\,\\chi \\chi} v}{ H(z_{\\rm therm})} = 1\n\\end{align}\nwhere $v$ is the relative velocity between DM particles and $\\sigma_{T,\\, \\chi \\chi}$ is the self-scattering momentum transfer cross section given in Eq.~\\eqref{eq:transfer}, with the dark photon mass regulating the forward scattering instead of the Debye mass that is present for DM-baryon scattering. Using the ratio of the average DM momentum to the photon momentum in Fig.~\\ref{Teff}, we approximate the relative velocity as $v \\approx p_\\chi\/m_\\chi \\approx T_\\gamma(z)\/m_\\chi$. In this estimate, we have assumed that DM is non-relativistic at the time self-interactions become important.\n\n\\begin{figure}\n\\centering\n\\includegraphics[width=0.7\\textwidth]{DMselftherm_new.pdf}\n\\caption{The approximate redshift when DM self-scattering becomes important, $z_{\\rm therm}$, as a function of DM mass in the model with dark photon mediated interactions. The freeze-in relic abundance is determined by $Q= g_\\chi \\kappa \/e$ and we show $z_\\text{therm}$ assuming two values of $\\kappa$ (where $g_\\chi$ is fixed to obtain the DM relic abundance). The epoch when DM self-thermalization becomes relevant is highly sensitive to the choice of couplings, which can yield different results for CMB observables depending on whether thermalization occurs before recombination. Note that DM halo formation is neglected in this estimate. Also shown are bounds on DM self-thermalization which come from the SIDM limits on $g_\\chi$ in Eq.~\\eqref{SIDMbound}. For illustration, we assume $\\sigma_{T,\\,\\chi \\chi} \\lesssim 1$~cm$^2\/$g for scattering via an ultralight mediator and show both $v\\sim10^{-3}$ and $v\\sim10^{-4}$, speeds relevant to a halo the size of the Milky Way and to a dwarf galaxy. In this figure we have taken $m_{A'} = 10^{-14}$~eV, which is sufficiently light that the constraints on the kinetic mixing parameter $\\kappa$ are rather weak. \\label{fig:DMtherm} }\n\\end{figure} \n\n\nThe self scattering randomizes the DM velocities while preserving the average kinetic energy $ \\tfrac{3}{2} T^{\\rm eff}_\\chi(z) \\equiv \\langle p_\\chi^2 \\rangle\/(2 m_\\chi)$, where $p_\\chi$ is physical momentum and the average momentum-squared is given in Fig.~\\ref{Teff}. After self-scattering becomes significant, the DM phase space is described by a thermal Maxwell-Boltzmann distribution,\n\\begin{align}\n\tf_{\\rm DM}(p_\\chi,z) = n_{\\rm DM}(z) \\, \\left( \\frac{2\\pi }{ m_\\chi T_\\chi^{\\rm eff}(z)} \\right)^{3\/2} 4\\pi p_\\chi^2 \\exp \\left( - \\frac{p_\\chi^2 }{2 m_\\chi T_\\chi^{\\rm eff}(z) } \\right) ,\n \\label{eq:fdm_PSD_Gaussian}\n\\end{align}\nwhere $n_{\\rm DM}(z)$ is the DM number density. \n\n\n\nFig.~\\ref{fig:DMtherm} shows the redshift of thermalization for two representative choices of $\\kappa$ (thus fixing $g_\\chi$ to yield the observed relic abundance), where we see the assumption of non-relativistic DM is a reasonably good approximation in our estimates. Since the phase space calculations here will be an input to determining CMB constraints on freeze-in DM, we compare $z_{\\rm therm}$ with the redshift of recombination $z \\approx 1100$. For constraints from structure formation, a range of redshifts will be relevant. We also show some fiducial limits from SIDM, which give upper bounds on $g_\\chi$. Fig.~\\ref{fig:DMtherm} illustrates that the DM phase space at the time of recombination depends sensitively on the model parameters and on the robustness of SIDM limits in different astrophysical systems. For the largest values of $g_\\chi$ consistent with the weaker assumed SIDM bounds, the DM phase space is described by a Maxwell-Boltzmann distribution at the time of recombination for all the DM masses we consider. However, for $\\kappa = 10^{-3}$ (which is consistent with bounds on ultralight dark photons), $g_\\chi$ is small enough that DM self-interactions are not important at recombination and the phase space is described by the results of Sections~\\ref{sec:ann_phasespace}-\\ref{sec:plasmon_phasespace}. The comparison of the free-streaming and thermalized phase space can be seen in Fig.~\\ref{masscomp_phase}.\n\n\n\\section{Results and Discussion}\n\\label{summary}\nIn this paper, we have shown that DM freeze-in through a light vector mediator is substantially affected by plasmon decay, which constitutes a new production channel. This is an efficient way of producing sub-MeV DM and is dominant over SM fermion annihilation for masses below a few hundred keV. To account for this extra production channel, the couplings between the DM and the SM must be reduced in order to obtain the observed relic abundance of DM. For the lightest DM masses that are accessible to low-threshold direct detection experiments, the predicted cross section is lowered by roughly an order of magnitude. Updated predictions for freeze-in through a light vector mediator are shown in Fig.~\\ref{fig:summaryplot}.\n\\begin{figure}\n\\centering\n\\includegraphics[width=0.7\\textwidth]{Q_new.pdf} \n\\caption{Summary plot including early-universe plasma effects for the parameter space of sub-MeV freeze-in DM. The correct DM relic abundance is obtained for couplings on the freeze-in line. We show constraints coming from emission of DM pairs in white dwarf, horizontal branch and red giant stars~\\cite{Vogel:2013raa}, while bounds from emission of DM pairs in supernovae apply for $Q \\gtrsim 10^{-9}$~\\cite{Chang:2018rso}. Dotted lines are projected sensitivities of proposed direct detection experiments as in Fig.~\\ref{DDshift}. \n\\label{fig:summaryplot}}\n\\end{figure} \n\nThe presence of this channel also affects the DM phase space. In the absence of plasmon decays, the DM is never technically thermal but it acquires a distribution that appears thermal by inheriting the electron phase space distribution at the time of production. At early times $f_{\\chi, \\, e^+e^-}(p_\\chi)\\sim e^{-p_\\chi\/T_{\\chi, \\, e^+e^-}}$, where $T_{\\chi,\\, e^+e^-}$ is an effective DM temperature inherited from the electrons; at late times, this exponential distribution persists because the DM does \\emph{not} thermalize to give the Maxwell-Boltzmann distribution that would be expected for non-relativistic matter in equilibrium. On the other hand, the plasmon decay channel yields a DM phase space distribution that never appears thermal, which can be attributed to the running of the plasmon mass with temperature and the fact that plasmon decays occur dominantly as the plasmon wavenumber $k\\rightarrow 0$. For DM masses where plasmon decays are the dominant production mode, the phase space is peaked at low momentum and has a long tail; for DM masses where contributions from both channels are important, the phase space distribution is bimodal.\n\nThough the DM is born with a highly non-thermal distribution, it may be possible for the DM to thermalize with itself under the right circumstances. For DM that is only charged under the SM $U(1)_{EM}$ with millicharge $Q$, the thermalization rate is suppressed by a factor of $Q^4$ where the requisite $Q$ to produce the DM relic abundance is $Q \\sim \\mathcal{O}\\left(10^{-11}\\right)$. If the DM is also charged under a dark $U(1)$ gauge group that kinetically mixes with the SM $U(1)_{EM}$ (with mixing parameter $\\kappa$), it may be possible for DM self-scattering to thermalize the DM phase space distribution. In this case, $Q = \\kappa g_\\chi\/e$ (where $\\kappa$ can take on a wide range of values) and DM self-scattering via the dark photon scales as $g_\\chi^4$, meaning that with the appropriate choice of $\\kappa$ and $g_\\chi$ it is possible to efficiently self-scatter while still producing the observed relic abundance. The coupling $g_\\chi$ cannot be arbitrarily large due to observational limits on SIDM in astrophysical systems; however, there is a range of $g_\\chi$ where self-scattering thermalizes the DM before recombination and where the SIDM bounds are simultaneously satisfied. Energy is conserved within the DM fluid, so for non-relativistic DM $\\left$ will be conserved and the resulting distribution has a well-defined notion of temperature.\n\nAlthough the freeze-in DM phase space distribution may not be thermal, it is still informative to take moments of the distribution. When comparing the first and second moments of $f_\\chi(p_\\chi)$ to the equivalent quantities for the SM photon bath, we find that the typical DM momentum is similar to the typical photon momentum, $\\langle p_\\chi \\rangle \\approx (0.4-0.7)\\times \\langle p_\\gamma \\rangle$ depending on the DM mass. In other words, the DM is born considerably warmer than what is typically assumed for cold DM initial conditions. This will have ramifications for cosmology in two key ways:\n\\begin{itemize}\n \\item Freeze-in DM will behave like warm DM, leading to suppression of the matter power spectrum below some physical scale roughly corresponding to the free-streaming length. This effect is not already captured by existing limits on warm DM, where different DM phase space distributions are assumed. To understand this suppression quantitatively, a Boltzmann code is necessary that accounts for the potentially nonthermal phase space from freeze-in. Having understood this, it will be possible to constrain DM freeze-in via a light vector mediator using probes of the matter power spectrum and the halo mass function.\n \\item Existing CMB limits on DM with an effective millicharge do not straightforwardly apply to the case of freeze-in. These limits stem from a DM-baryon drag; because the drag is highly sensitive to the relative DM-baryon velocity (the cross section scales like $\\sim v^{-4}$), modifications to the DM phase space can substantially alter the size of the effect. Existing limits have made the assumption of cold dark matter, and the larger DM velocities for freeze-in will lead to reduced drag force. Taking into account the updated Debye logarithm (which may weaken existing limits by a factor of $\\sim 2-3$), the limit on freeze-in will be further reduced compared to previously reported results.\n\\end{itemize}\nBoth of these effects will be thoroughly explored in our companion paper~\\cite{inprep}, which will place restrictions on the range of masses where DM freeze-in via a light mediator is observationally viable.\n\n\n \n\n\n\n\\section*{Acknowledgments}\nWe thank Masha Baryakhtar, Asher Berlin, Simon Knapen, Jung-Tsung Li, Adrian Liu, Aneesh Manohar, Sam McDermott, Julian Mu\\~noz, and Tomer Volansky for helpful discussions. We acknowledge the importance of equity and inclusion in this work and are committed to advancing such principles in our scientific communities. CD was supported by NSF grant AST-1813694, Department of Energy (DOE) grant DE-SC0019018, and the Dean's Competitive Fund for Promising Scholarship at Harvard University. TL is supported by an Alfred P. Sloan Research Fellowship and Department of Energy (DOE) grant DE-SC0019195. Parts of this paper were prepared while at the KITP, supported by the National Science Foundation under Grant No. NSF PHY-1748958. KS is supported by a National Science Foundation Graduate Research Fellowship and a Hertz Foundation Fellowship. KS is grateful for the hospitality of the Lisanti group at Princeton University and of the Center for Cosmology and Particle Physics at New York University, where part of this work was completed.\n\n","meta":{"redpajama_set_name":"RedPajamaArXiv"}} +{"text":"\n\n\n\\section{Conclusions}\n\\label{sec:conclusions}\n\nWe studied an ensemble of 42 MSPs from the EPTA, combining multifrequency\ndatasets from four different observatories, with data spanning more than 15\nyears for almost half of our sample. The analysis was performed with TempoNest\nallowing the simultaneous determination of the white noise parameters and\nmodeling of the stochastic DM and red noise signals. We achieved the detection\nof several new parameters: seven parallaxes, nine proper motions and six apparent\nchanges in the orbital semi-major axis. We also measured Shapiro delay in\ntwo systems, PSRs J1600$-$3053 and J1918$-$0642, with low-mass Helium white dwarf\ncompanions.\nFurther observations of PSR J1600$-$3053 will likely yield the detection of the advance of\nperiastron, dramatically improving the mass measurement of this system and\nimproving the constraints on the geometry of the system. We presented an\nupdated mass measurement for PSR J0751+1807,\nroughly consistent with the previous work by \\citet{nsk08}.\nWe searched for the presence of annual-orbital parallax in three systems, PSRs J1600$-$3053, J1857$+$0943 and J1909$-$3744.\nHowever we could only set constraints on the\nlongitude of ascending node in PSRs J1600$-$3053 and\nJ1909$-$3744 with marginal evidence of annual-orbital parallax in PSR J1600$-$3053.\n\nWith an improved set of parallax distances, we investigated the difference\nbetween the predictions from the NE2001 Galactic electron density model and the\nLK-corrected parallax distances. On average we found an error of $\\sim$ 80\\% in\nthe NE2001 distances, this error increasing further at high Galactic latitudes.\nDespite its flaws for high galactic latitude lines-of-sight, we find NE2001 to\nstill predict more accurate distances than two recent models, M2 and M3, proposed by\n\\citet{sch12}, based respectively on the TC93 and NE2001 models with an extended thick disk. \nWe showed that a change in the scale height of the thick disk of\n the current electron density models also dramatically affects the pulsars that\nare located in the Galactic plane. Our updated set of parallaxes presented here\nwill likely contribute to improving\non any future model of the Galactic electron density model\n\nA comparison of the 2-D velocity distribution between isolated and binary MSPs\nwith a sample two times larger than the last published study \\citep{gsf+11}\nstill shows no statistical difference, arguing that both populations originate from the same underlying population.\nThrough precision measurement of the orbital period derivative, we\nachieved better constraints on the distance to two pulsars, PSRs J1012+5307 and\nJ1909$-$3744, than is possible via the detection of the annual parallax.\n\nBased on the timing results presented in this paper and the red noise\nproperties of the pulsars discussed in \\citet{cll+15}, we will\nrevisit and potentially remove some MSPs from the EPTA observing list.\nThe EPTA is also continuously adding more sources to its observing list, especially in\nthe last five years, as more MSPs are discovered through the targeted survey of\n\\textit{Fermi} sources \\citep{rap+12} and large-scale pulsar surveys\n\\citep[e.g. the PALFA, HTRU and GBNCC collaborations;\n][]{lbh+15,bck+13,nbb+14,slr+14}. Over 60 MSPs\nare now being regularly monitored as part of the EPTA effort.\n\nRecent progress in digital processing, leading in some cases to an increase of\nthe processed bandwidth by a factor of $2-4\\times$, allowed new wide-band coherent\ndedispersion backends to be commissioned at all EPTA sites in the last few\nyears \\citep[see e.g.][]{kss08,dbc+11}. These new instruments provide TOAs with\nimproved precision that will be included in a future release of the EPTA\ndataset.\n The long baselines of MSPs timing data presented here, especially when\nrecorded with a single\nbackend, are of great value, not only for the detection of the GWB but also to\na wide range of astrophysics as shown in this paper.\n\n\\section{Discussion}\n\\label{sec:discussions}\n\n\n\\subsection{Distances}\n\\label{sec:dis_distances}\n\nIn Table~\\ref{tab:distances}, we present the parallaxes measured from our\ndata, based on the distance-dependent curvature of the wave-front\ncoming from the pulsar. This curvature causes an arrival-time delay\n$\\tau$ (in seconds) with a periodicity of six months and a maximal amplitude of\n\\citep{lk04}:\n\\begin{equation}\\label{eq:px}\n\\tau = \\frac{d_{\\odot}^2 \\cos^2 \\beta}{2 c d}\n\\end{equation}\nwhere $d_{\\odot}$ is the distance of the Earth to the Sun, $d$ is the\ndistance of the SSB to the pulsar, $c$ is the\nspeed of light and $\\beta$ is the ecliptic latitude of the pulsar.\n\nBecause of the asymmetric error-volume, parallax measurements with\nsignificance less than $\\sim 4\\sigma$, are unreliable as the\nLutz-Kelker bias dominates the measurement \\citep{lk73,vlm10}. The\nLutz-Kelker-corrected parallax values as well as the derived\ndistances\\footnote{We remind the reader that the most likely distance\nis not necessarily equal to the inverse of the most likely parallax,\ngiven the non-linearity of the inversion.} are also given in\nTable~\\ref{tab:distances}, based on the analytical corrections proposed by\n\\citet{vwc+12} and the flux density values shown in Table~\\ref{tab:summary}.\n\nIn total, we present 22 new parallax measurements. Seven of these new\nmeasurements are for MSPs that had no previous distance measurement,\nbut all of these are still strongly biased since their significance is\nat best $3\\sigma$. For five pulsars (specifically for PSRs J0030+0451,\nJ1012+5307, J1022+1001, J1643$-$1224 and J1857+0943) our parallax\nmeasurement is of comparable significance than the previously\npublished value, but with the exception of PSR J1857+0943, our\nmeasurement precision is better than those published previously; and\nthe lower significance is a consequence of the smaller parallax value\nmeasured (as predicted by the bias-correction). Our measurement for\nPSR J1857+0943 is slightly less precise than the value published by\n\\citet{vbc+09}, but consistent within $1\\sigma$.\n\nFinally, we present improved parallax measurements for ten pulsars:\nPSRs J0613$-$0200, J0751+1807, J1024$-$0719, J1600$-$3053, J1713+0747,\nJ1744$-$1134, J1909$-$3744, J1939+2134, J2124$-$3358 and J2145$-$0750.\nFor seven of these the previous measurement was already free of bias,\nfor the remaining three (PSRs J0613$-$0200, J0751+1807 and\nJ2124$-$3358) our update reduces the bias to below the $1\\sigma$\nuncertainty level (with two out of three moving in the direction predicted\nby the bias-correction code). For three pulsars with previously\npublished parallax measurements we only derive upper limits, but two\nof these previous measurements (for PSRs J0218+4232 and J1853+1303)\nwere of low significance and highly biased. Only PSR J1738+0333's\nparallax was reliably measured with GBT and Arecibo data\n\\citep{fwe+12} and not confirmed by us. Four pulsars had a known\nparallax before the creation of the NE2001 model, namely PSRs J1713$+$0747\n\\citep{cfw94}, J1744$-$1134 \\citep{tbm+99}, J1857$+$0943 and J1939$+$2134\n\\citep{ktr94}. These pulsars are therefore not included in our analysis of the\nNE2001 distance (see below), leaving us with a total of 21 parallaxes.\n\n\\subsubsection{Distance comparison with NE2001 predictions}\nWhen comparing the bias-corrected distances presented in\nTable~\\ref{tab:distances} with those predicted by the widely used NE2001\n electron-density model for the Milky Way \\citep{cl02},\n we find that the model performs reasonably well overall.\nHowever, significant offsets exist, primarily at high positive\nlatitudes and large distance ($d>2$ kpc) into the Galactic plane.\nIn Fig~\\ref{fig:dist1}, we plot this comparison for three ranges of Galactic\n latitude $b$ (defined as low: $\\left|b\\right| < 20^\\circ$, intermediate:\n $20^\\circ < \\left|b\\right| < 40^\\circ$ and high: $\\left|b\\right| > 40^\\circ$)\n highlighting the weakness of NE2001 at high latitude.\nWe find a mean uncertainty of 64\\%, 55\\% and 117\\% respectively for the NE2001\ndistances to be consistent with our measurement.\n On average, the NE2001 distances would require an uncertainty of 80\\%. This\nvalue is significantly higher than the 25\\% uncertainty typically assumed in\nthe literature for this model; or than the fractional uncertainties displayed\nin Figure~12 of \\citet{cl02}.\n\n\\begin{figure}\n\\includegraphics[height=85mm,angle=-90]{plots\/comparison_Px_NE2001_M2_M3.ps}\n\\caption{Comparison between the Lutz-Kelker bias corrected parallax distances\n(in ordinates) and the DM distances (in abscissa) for different Galactic\nlatitudes $b$ on logarithmic scales. The DM distances in the left, middle and\nright panels are derived from the NE2001, M2 and M3 models respectively. Top\npanels: the stars show pulsars with $b>40^{\\circ}$ and the crosses pulsars with\n$b<-40^{\\circ}$. Middle panels: the stars show pulsars with\n$40^{\\circ}>b>20^{\\circ}$ and the crosses pulsars with\n$-40^{\\circ}b>0^{\\circ}$ and the crosses pulsars with\n$-20^{\\circ} D_\\pi \\\\\n {D_\\pi}\/{D_\\text{model}}, & \\text{otherwise}\n\\end{cases}\n\\end{equation}\nwith $D_\\pi$ and $D_\\text{model}$ being the parallax distance and distance\nfrom a given Galactic electron density model (NE2001, M2 or M3), respectively.\n As can be seen, the NE2001 model \nprovides on average slightly better distance estimates (lower $N$)\nthan the M2 or M3 models. M3 gives more accurate distance than M2 for the first\nhalf of lines-of-sight (when the prediction of both models is the best) but\ngets superseded by M2 when N increases.\n\n\n\n\n\n\\begin{figure}\n\\includegraphics[width=90mm]{plots\/cum_distrib_NE2001_M2_M3.ps}\n\\caption{Cumulative distribution of the $N$ factor between \nthe DM distance and the parallax distance (see Eq.~\\ref{eq:Nfactor}). These distributions include\nthe 21 pulsars with measured parallaxes in Table~\\ref{tab:distances}. The DM distances are derived \nfrom the NE2001, M2 and M3 models and represented in black, red and blue respectively.}\n\\label{fig:dist2}\n\\end{figure}\n\n\\input{table-distances}\n\n\n\n\n\n\n\\subsection{Proper motions and 2-D spatial velocities}\n\\label{sec:dis_vel}\n\n\nStellar evolution modeling by \\citet{tb96} and \\citet{cc97} predicted that the\nrecycled MSP population would have a smaller spatial velocity than the normal\npulsar population. A study by \\citet{tsb+99} found a mean transverse velocity\n\\vt for MSPs of $85\\pm13$~km~s$^{-1}$ based on a sample of 23 objects. They\nnoted that this value is four times lower than the ordinary young pulsar\nvelocity. The authors also observed isolated MSPs to have a velocity two-thirds\nsmaller than the binary MSPs.\nWith an ever increasing number of MSPs, further studies by \\citet{hll+05} and\n\\citet{gsf+11} found no statistical evidence for a difference in the velocity\ndistribution of isolated and binary MSPs. \\citet{hll+05} reported on \\vt\n$=76\\pm16$ and \\vt $=89\\pm15$ km~s$^{-1}$ for isolated and binary MSPs\nrespectively while \\citet{gsf+11} found \\vt $=68\\pm16$ and \\vt $=96\\pm15$\nkm~s$^{-1}$ for isolated and binary MSPs. \nAll these results are in agreement with other work by \\citet{lkn+06}.\n\nWithin our sample of 42 MSPs, we measured seven new proper motions, of which\nthree are for \nisolated MSPs (PSRs J1843$-$1113, J1911$+$1347 and J2010$-$1323) and 4 are\nfor binary MSPs (PSRs J0034$-$0534, J0900$-$3144, J1751$-$2857 and J1804$-$2717).\nIn addition, we improved the precision of the proper-motion measurement by a\nfactor of ten for seven other MSPs (PSRs J0610$-$2100, J0613$-$0200, J1455$-$3330,\nJ1801$-$1417, J1911$-$1114, J2229$+$2643 and J2317$+$1439). \n\nThese improvements in the proper motion as well as the distance estimates\npresented in Section~\\ref{sec:dis_distances} and recent discoveries of MSPs\npublished elsewhere led us to re-examine the distribution of $V_T$, the transverse\nvelocity of MSPs in km~s$^{-1}$, where\n\n\\begin{equation}\n V_T =\\text{ 4.74 km s}^{-1} \\times \\mu \\times d.\n\\end{equation}\nAgain, $\\mu$ is the proper motion in mas yr$^{-1}$ and $d$ the distance to the\npulsar in kpc. In this\nanalysis we considered all known MSPs listed in the ATNF pulsar catalogue, but\ndiscarding pulsars in globular clusters, double neutron stars or pulsars with\n$P>20$ ms. This represents 19 isolated and 57 binary pulsars for a total of 76\nMSPs. In comparison, the last published MSP velocity study by \\citet{gsf+11}\nmade use of 10 isolated and 27 binary MSPs with $P$ below 10 ms. If we choose\nto restrict our sample to pulsars with $P$ below 10 ms, only 6 binary pulsars\nwould not pass our criteria. The selected isolated and binary pulsars are\nlisted in Tables \\ref{tab:iso_velocities} and \\ref{tab:bin_velocities}\nrespectively. The distances used in the calculation of $V_T$ and reported in\nthe third column of Tables \\ref{tab:iso_velocities} and\n\\ref{tab:bin_velocities} are the best distance estimates available, either\ncoming from the Lutz-Kelker-corrected parallax or the NE2001 model.\n\nWe find an average velocity of $88\\pm17$ km~s$^{-1}$ and $93\\pm13$ km~s$^{-1}$\nfor the isolated and binary MSPs, respectively. For the entire MSP dataset, we\nget an average velocity of $92\\pm10$ km~s$^{-1}$. Our results are consistent\nwith the work by \\citet{hll+05} and \\citet{gsf+11}.\n\nWhen we keep only the pulsars with a more reliable distance estimate (i.e.\npulsars with a parallax measurement), 8 isolated and 20\nbinary MSPs are left in our sample. In this case, we find an average velocity\nof $75\\pm10$ km~s$^{-1}$ and \n$56\\pm3$ km~s$^{-1}$ for the isolated and binary MSPs respectively. \nConversely, we get an average velocity of $98\\pm29$ km~s$^{-1}$ and $113\\pm20$\nkm~s$^{-1}$ for the pulsars with a distance coming from the Galactic electron\ndensity models. The explanations for this discrepancy are twofold: the\nNE2001 model is overestimating the distances for low Galactic latitude as shown\nin Fig.~\\ref{fig:dist1} and our sample of 2-D velocities is biased against\ndistant low-velocity MSPs. Nearby\npulsars are likely to have a parallax and a proper-motion measurement whereas\ndistant pulsars would most likely have a distance estimate from the NE2001 model and\na proper-motion measurement for the high-velocity pulsars only.\n\nFig.~\\ref{fig:2D_hist} shows the histogram of the velocities for both the\nisolated and binary MSPs populations. A two-sample Kolgomorov-Smirnov (KS) test\nbetween the full isolated and binary MSPs velocity distributions results in a\nKS-statistic of 0.14 and a p-value of 0.92. If we perform the same test on the\npulsars with a parallax distance, we get a KS-statistic of 0.25 and a p-value\nof 0.81. For both cases, we therefore cannot reject the null hypothesis and we argue that there is\nno statistical evidence for the measurements to be drawn from different\ndistributions. This supports the scenario that both isolated and binary MSPs\nevolve from the same population of binary pulsars.\n\n\n\n\n\n\n\n\\begin{figure}\n\\includegraphics[height=80mm,angle=-90]{plots\/PM_histo.ps}\n\\caption{Histogram of the 2-D velocity distribution for a sample of 19 isolated\nMSPs (top panel) and 57 binary MSPs (bottom panel). The respective average\nvelocities are $88\\pm17$ km s$^{-1}$ and $96\\pm12$ km s$^{-1}$. The hatched\npart of the histogram shows the pulsars with a distance estimate from the\nparallax measurement (8 isolated and 21 binary MSPs).}\n\\label{fig:2D_hist}\n\\end{figure}\n\n\\input{table-velocities-isolated}\n\n\\input{table-velocities-binaries}\n\n\n\n\n\\subsection{Shklovskii and Galactic acceleration contributions}\n\\label{sec:dis_shk}\n\nThe observed pulse period derivatives, $\\dot{P}$, reported in Tables \\ref{tab:param1}\n to \\ref{tab:param11} are different from their intrinsic values\n$\\dot{P}_{\\text{int}}$. This is because it includes the 'Shklovskii' contribution due\nto the transverse velocity of the pulsar \\citep[$\\dot{P}_{\\text{shk}}$,][]{shk70}, the\nacceleration from the differential Galactic rotation ($\\dot{P}_{\\text{dgr}}$) and the\nacceleration towards the Galactic disk ($\\dot{P}_{\\text{kz}}$) \\citep{dt91,nt95}.\nHence $\\dot{P}_{\\text{int}}$ can be written as\n\n\\begin{equation}\n\\label{eq:pdot}\n \\dot{P}_{\\text{int}}=\\dot{P}-\\dot{P}_{\\text{shk}}-\\dot{P}_{\\text{dgr}}-\\dot{P}_{\\text{kz}},\n\\end{equation}\nwhere the Shklovskii contribution $\\dot{P}_{\\text{shk}}$ is given by\n\\begin{equation}\n \\frac{\\dot{P}_{\\text{shk}}}{P} = \\frac{\\mu^2 d}{c}.\n\\end{equation}\nAgain $d$ is our best distance estimate for the pulsar and $\\mu$ our measured\ncomposite proper motion. The equation for $\\dot{P}_{\\text{dgr}}$\nis taken from \\citet{nt95} with updated values for the distance to the Galactic center\n$R_0=8.34\\pm0.16$ kpc and the Galactic rotation speed at the Sun\n$\\Theta=240\\pm8$~km~s$^{-1}$ \\citep{rmb+14}. $\\dot{P}_{\\text{kz}}$ is taken from the\nlinear interpolation of the $K_z$ model in \\citet[see Fig.~8]{hf04}.\n\n\nTo compute these contributions with full error propagation we use the distances from\nTable~\\ref{tab:distances} and the proper motions shown in\nTables~\\ref{tab:iso_velocities} and \\ref{tab:bin_velocities}. These values are\nreported for each pulsar at the bottom of Tables~\\ref{tab:param1} to\n\\ref{tab:param11}. The magnitudes of all three corrective\nterms to $\\dot{P}$ depend on the distance $d$ to the pulsar. \nAlternatively, as the pulsar braking torque causes the spin period to increase\n(i.e. $\\dot{P}$ to be positive) in systems where no mass transfer is taking\nplace, we used this constraint to set an upper limit, $D_{\\dot{P}}$, on the\ndistance to the pulsar by assuming all the observed $\\dot{P}$ is a result of\nkinematic and Galactic acceleration effects. This upper limit $D_{\\dot{P}}$ is\nshown in column 5 of Table~\\ref{tab:distances} for 19 pulsars, where this upper\nlimit is below 15 kpc.\n\n\nFor all pulsars except PSRs J0610$-$2100, J1024$-$0719 and J1721$-$2457, the\nupper limits $D_{\\dot{P}}$ are consistent with both the NE2001 and M3\ndistances, $D_{\\text{NE2001}}$ and $D_{\\text{M3}}$ respectively. For PSR\nJ0610$-$2100, $D_{\\text{M3}}=8.94$ kpc is ruled out by\n$D_{\\dot{P}} < 3.89$ kpc. We note that for this pulsar, $D_{\\text{M3}}$ is 2.5 times higher than\n$D_{\\text{NE2001}}$. For PSR J1721$-$2457, both $D_{\\text{NE2001}}$ and\n$D_{\\text{M3}}$ are ruled out by $D_{\\dot{P}} < 0.96$ kpc. The case of PSR J1024$-$0719 is discussed below.\n\n\n\\input{table-pbdot} \n\n For nine pulsars, an independent estimate of\nthe distance from the parallax measurement is available. For all nine pulsars\nbut PSR J1024$-$0719, the parallax distance is consistent with the upper limit\n$D_{\\dot{P}}$.\nPSR J1024$-$0719 has $D_{\\dot{P}} < 0.42$ kpc but a reported Lutz-Kelker-corrected\ndistance $D_{\\pi} = 1.08_{-0.16}^{+0.28}$ kpc, $\\sim4\\sigma$ away above the\nupper limit $D_{\\dot{P}}$.\nTo explain this discrepancy (also discussed in \\citet{egc+13,aaa+13}), we argue that PSR J1024$-$0719 must be subject to\na minimum relative acceleration $a$ along the line of sight,\n\\begin{equation} \n a = \\frac{ \\left| \\dot{P} - \\dot{P}_{\\text{int}} \\right| }{P} \\times c = 1.7 \\times 10^{-9} \\text{m s}^{-2}.\n\\end{equation}\nA possible explanation for this acceleration is the presence of a nearby star,\norbiting PSR J1024$-$0719 in a very long period. A possible companion has been\nidentified by \\citet{srr+03}.\n\nThe same reasoning behind the corrections of Eq.~\\ref{eq:pdot} also apply to the\nobserved orbital period derivative $\\dot{P_b}$. In addition to the previous\nterms, we also consider the contribution due to gravitational radiation\nassuming GR, $\\dot{P_b}_{\\_GR}$ but neglect the contributions from mass loss in the\nbinary, tidal interactions or changes in the gravitational constant $G$.\n $\\dot{P_b}_{\\_GR}$ is therefore the only\ncontribution independent of the distance to the pulsar system but requires an\nestimate of the masses of the binary.\n\n As we measured the orbital period derivative for four pulsars\n(PSRs J0613$-$0200, J0751$+$1807, J1012$+$5307 and J1909$-$3744), we investigate here\nthe possible bias in those measurements assuming the parallax distances from\nTable~\\ref{tab:distances}. Conversely, \\citet{bb96} (hereafter BB96) pointed out that the\nmeasurement of $\\dot{P_b}$ would potentially lead to more accurate distance\nthan the annual parallax. Hence, we also present a new distance estimate,\n$D_{\\dot{P_b}}$, assuming the observed $\\dot{P_b}$ is the sum of all four\ncontributions described above. These results are shown in Table~\\ref{tab:pbdot}. \n\n To estimate the gravitational radiation contribution to $\\dot{P_b}$ for PSR\nJ0613$-$0200 without a mass measurement, we assumed $m_p=1.4$ M$_\\odot$\nand $i=60^\\circ$. The resulting distance estimate is $D_{\\dot{P_b}} = 1.68\\pm0.33$ kpc. This result is\n2.2$\\sigma$ consistent with the parallax distance and currently limited by the precision\non the measured $\\dot{P_b}$. Continued timing of this pulsar will greatly\nimprove this test as the uncertainty on $\\dot{P_b}$ decrease as $t^{-2.5}$.\nFor PSR J0751+1807, we measure a negative orbital period derivative,\n$\\dot{P_b}=(-3.50\\pm0.25) \\times 10^{-14}$, meaning the Shklovskii effect is not\nthe dominant contribution to $\\dot{P_b}$ in this system. We also note that our\nmeasured composite proper motion is 3.3$\\sigma$ higher than the value in \\citet{nss+05}\nresulting in a Shklovskii contribution to $\\dot{P_b}$ that is five times larger than the one quoted\nin \\citet{nss+05}.\nIn the next section, we will combine the corrected orbital period derivative from\nacceleration bias $\\dot{P_b}_{\\text{corr}} = \\dot{P_b} -\n\\dot{P_b}_{\\_\\text{kin}} -\n\\dot{P_b}_{\\_\\text{kz}} - \\dot{P_b}_{\\_\\text{dgr}} = (-4.6\\pm0.4) \\times 10^{-14} $ with the measurement of the Shapiro delay to constrain the masses of the two stars.\n\n\nFor PSR J1012$+$5307, we measured the orbital period derivative\n$\\dot{P_b}=(6.1\\pm0.4) \\times 10^{-14}$, a value similar to the one reported by \\citet{lwj+09}. We\nalso find the contributions to $\\dot{P_b}$ to be consistent with their work.\n After taking into account the companion mass and\ninclination angle from \\citet{kbk96,cgk98} to compute $\\dot{P_b}_{\\_\\text{GR}}$, we find\n$D_{\\dot{P_b}} = 940\\pm30$ pc, in very good agreement with the optical\n\\citep{kbk96,cgk98} and parallax distance, but more precise by a factor three and\neight, respectively.\n\nThe bias in the orbital period derivative measured for PSR J1909$-$3744 is\nalmost solely due to the Shklovskii effect. We get $D_{\\dot{P_b}} = 1140\\pm11$\npc. This result with a fractional uncertainty of only 1\\% is also in very good\nagreement with the parallax distance.\n\nTwenty years ago, BB96 predicted that after only 10 years, several of the MSPs included in\nthis paper would have a better determination of the distance through the measurement of\nthe Shklovskii contribution to $\\dot{P_b}$ compared to the annual parallax.\nHowever we achieved a better distance estimate from\n$\\dot{P_b}$ than the parallax for only two pulsars so far.\n\nWe investigate here the pulsars for which we should have detected $\\dot{P_b}$\nbased on the work by BB96 (i.e. PSRs J1455$-$3330, J2019+2425\nJ2145$-$0750 and J2317+1439). \nIn their paper, BB96 assumed a transverse velocity of 69 km~s$^{-1}$\nfor pulsars where the proper motion was not measured and adopted the distance to the\npulsar based on the \\citet{tc93} Galactic electron density model.\n\n\nIn the case of PSR J2019+2425, our measured proper motion is similar to the\nvalue used by BB96 and the time span of our data is nine years.\n The peak-to-peak timing signature of the Shklovskii contribution\nto $\\dot{P_b}$ (see Eq.~1 of BB96) is $\\Delta T_{pm} = 6\\pm5~\\mu s$,\nwith the large uncertainty coming from the NE2001 distance assumed.\nFor the three remaining pulsars, no proper-motion measurement was available at\nthe time and BB96 assumed in those cases a transverse velocity of 69\nkm~s$^{-1}$. However our new results \nreported in Table~\\ref{tab:bin_velocities} show much smaller transverse\nvelocities for PSRs J1455$-$3330, J2145$-$0750 and J2317+1439, with\n$31\\pm12$ km s$^{-1}$, $40\\pm3$ km s$^{-1}$,\n$17\\pm6$ km s$^{-1}$ respectively, resulting in a much lower Shklovskii\ncontribution to $\\dot{P_b}$ than predicted by BB96, explaining the non-detection of this parameter after 10 to 17 years\nof data with our current timing precision. \n\n\n\n\\subsection{Shapiro delay and mass measurement}\n\\label{sec:dis_mass}\n\n\\input{table-mass}\n\nIn Figures \\ref{fig:0751_mass} to \\ref{fig:1918_mass}, we plot, assuming GR, the\njoint \\mbox{2-D}\nprobability density function of the Shapiro delay that comes directly out of the TempoNest\nanalysis for the three pulsars we achieve greatly improved mass measurements, PSRs J0751+1807, J1600$-$3053 and J1918$-$0642,\nrespectively. For PSR J0751+1807, we use the corrected orbital period\nderivative, $\\dot{P_b}_{corr} = (-4.6\\pm0.4) \\times 10^{-14} $, derived in the previous section to further constrain the\nmasses of the system. The projection of the parameters $\\dot{P_b}$ and\n$\\varsigma$ gives the following 68.3\\%\nconfidence levels:\n$m_p=1.64\\pm0.15$~M$_{\\odot}$ and\n$m_c=0.16\\pm0.01$~M$_{\\odot}$. The inclination angle is constrained with $\\cos\ni < 0.64$ (2$\\sigma$). Our new pulsar mass\nmeasurement is 1.3$\\sigma$ larger from the latest mass value published in \\cite{nsk08}. \n\n\n\\begin{figure*}\n\\centering\n\\begin{minipage}{150mm}\n\\includegraphics[width=150mm]{plots\/J0751_mass_mass.eps}\n\\caption{Constraints on PSR J0751$+$1807 parameters from the\nmeasurement of Shapiro delay and orbital period derivative $\\dot{P_b}$. The bottom left plot shows the $\\cos i - m_c$\nplane. The bottom right plot shows the $m_p - m_c$ plane. The continuous black\nline, the dashed line and the dotted line represent, respectively, the 68.3\\%,\n95.4\\% and 99.7\\% confidence levels of the 2-D probability density function.\nThe grey area is\nexcluded by the mass function with the condition $\\sin i \\leq 1$. The red\ncurves indicate the 1-$\\sigma$ constraint required by $\\dot{P_b}$ assuming GR. The other\nthree panels show the projected 1-D distributions based on $\\dot{P_b}$ and the\ninclination angle (given by $\\varsigma$). The dashed lines\nindicate the median value and the continuous lines the 1-$\\sigma$ contours.}\n\\label{fig:0751_mass}\n\\end{minipage}\n\\end{figure*}\n\nIn the case of PSR J1600$-$3053, the posterior results from TempoNest give\n $\\cos i=0.36\\pm0.06$, $m_p=1.22_{-0.35}^{+0.50}$~M$_{\\odot}$ and\n$m_c=0.21_{-0.04}^{0.06}$~M$_{\\odot}$. We now have\nan accurate mass of the companion compared to the marginal detection\nby \\citet{vbc+09}. Given the eccentricity $e \\sim 1.7\\times10^{-4}$ of this system, a detection of\nthe precession of periastron is likely to happen in the near future and would\ngreatly improve the pulsar mass measurement.\n\nThe results for PSR J1918$-$0642 translate into a pulsar mass $m_p =\n1.25_{-0.4}^{+0.6}$~M$_{\\odot} $ and a companion mass $m_c =\n0.23\\pm0.07$~M$_{\\odot}$. The cosine of the inclination angle\nis $0.09_{-0.04}^{+0.05}$. Based on the mass estimates for the companions to\nPSRs J1600$-$3053 and J1918$-$0642, it is expected that these are low-mass\nHelium white dwarfs.\n\nIn Table~\\ref{tab:mass}, we summarize all our mass measurements and compare them to the values previously published in the literature. We find that PSRs J1713+0747,\nJ1802$-$2124, J1857+0943 and J1909$-$3744 have a mass measurement that is in very good\nagreement to the values reported in the literature \\citep{zsd+15,\nfsk+10, vbc+09}.\n\n\n\\begin{figure*}\n\\centering\n\\begin{minipage}{150mm}\n\\includegraphics[width=150mm]{plots\/J1600_mass_mass.eps}\n\\caption{Constraints on PSR J1600$-$3053 parameters from the\nmeasurement of Shapiro delay. The bottom left plot shows the $\\cos i - m_c$\nplane. The bottom right plot shows the $m_p - m_c$ plane. The continuous black\nline, the dashed line and the dotted line represent, respectively, the 68.3\\%,\n95.4\\% and 99.7\\% confidence levels of the 2-D probability density function.\nThe grey area is\nexcluded by the mass function with the condition $\\sin i \\leq 1$. The other\nthree panels show the projected 1-D distributions with the dashed line\nindicating the median value and the continuous lines the 1-$\\sigma$ contours.}\n\\label{fig:1600_mass}\n\\end{minipage}\n\\end{figure*}\n\n\n\n\n\n\n\\subsection{Search for annual-orbital parallax}\n\\label{sec:dis_kom}\nFor pulsars in binary systems, any change in the direction to the orbit\nnaturally leads to apparent variations in two of the Keplerian parameters, the intrinsic\nprojected semi-major axis $x_{\\text{int}}$ and longitude of periastron\n$\\omega_{\\text{int}}$.\nIn the case of nearby binary pulsars in wide orbits, a small periodic variation\nof $x$ and $\\omega$ due to the annual motion of the Earth around the Sun as\nwell as the orbital motion of the pulsar itself can be measured. This effect,\nknown as the annual-orbital parallax, can be expressed as \\citep{kop95}: \n\n\\begin{equation}\n x = x_{\\text{int}} \\left\\lbrace 1 + \\frac{\\cot i }{d} (\\Delta _{I_0} \\sin \\Omega - \\Delta _{J_0} \\cos \\Omega) \\right\\rbrace \n\\end{equation}\nand \n\\begin{equation}\n \\omega = \\omega_{\\text{int}} - \\frac{\\csc i }{d} (\\Delta _{I_0} \\cos \\Omega + \\Delta _{J_0} \\sin \\Omega), \n\\end{equation}\nwhere $\\Omega$ is the longitude of the ascending node. $\\Delta_{I_0}$ and\n$\\Delta_{J_0}$ are defined in \\citet{kop95} as:\n\\begin{equation}\n\\Delta_{I_0} = -X \\sin \\alpha + Y \\cos \\alpha\n\\end{equation}\nand\n\\begin{equation}\n\\Delta_{J_0} = -X \\sin \\delta \\cos \\alpha - Y \\sin \\delta \\sin \\alpha + Z \\cos \\delta,\n\\end{equation}\nwhere $\\mathbf{r} = (X,Y,Z)$ is the position vector of the Earth in the SSB\ncoordinate system.\n\nThe proper motion of the binary system also changes the apparent viewing\ngeometry of the orbit by \\citep{ajr+96,kop96}:\n\\begin{equation}\n\\label{eq:hot}\n x = x_{\\text{int}} \\left\\lbrace 1 + \\frac{1}{\\tan i} (-\\mu_{\\alpha} \\sin \\Omega +\n\\mu_{\\delta} \\cos \\Omega ) ( t - t_0) \\right\\rbrace ,\n\\end{equation}\n\n\\begin{equation}\n \\omega = \\omega_{\\text{int}} + \\frac{1}{\\sin i} (\\mu_{\\alpha} \\cos \\Omega +\n\\mu_{\\delta} \\sin \\Omega ) ( t - t_0) . \n\\end{equation}\nThe time derivative of Eq.~\\ref{eq:hot} can be expressed as\n\\begin{equation}\n\\label{eq:xdot}\n\\frac{\\dot{x}}{x} = \\mu \\cot i \\sin (\\theta_\\mu - \\Omega),\n\\end{equation}\nwhere $\\theta_\\mu$ is the position angle of the proper motion on the sky. If the inclination\nangle, $i$, can be measured through, e.g., the detection of Shapiro delay, then a\nmeasurement of $\\dot{x}$ can constrain the longitude of ascending node $\\Omega$.\nThese apparent variations in $x$ and $\\omega$ are taken into account in Tempo2's\nT2 binary model with the KOM and KIN parameters, corresponding to the\nposition angle\nof the ascending node $\\Omega$ and inclination angle $i$ (without the 90$^{\\circ}$\nambiguity inherent to the Shapiro delay measurement). Therefore the parameter\n$s \\equiv \\sin i$ of the Shapiro delay has to become a function of KIN.\n\nEven a null $\\dot{x}$ can, if measured precisely enough, be useful.\nAccording to Eq.~\\ref{eq:xdot}, the maximum value for $\\left|\\dot{x}\\right|$ is\n$\\dot{x}_{\\max} = |x \\mu \\cot i|$ (obtained using the inequality $| \\sin\n(\\theta_{\\mu} - \\Omega) | \\leq 1$). Thus whenever the observed value and\nuncertainty represent a small fraction of the interval from $- \\dot{x}_{\\max}$\nto $\\dot{x}_{\\max}$, they are placing a direct constraint on $\\sin\n(\\theta_{\\mu} - \\Omega)$\n\n\nIn our dataset, we measured the apparent variation of $\\dot{x}$ for\n13 pulsars, among which six are new measurements (PSRs J0751+1807,\nJ1455$-$3330, J1640+2224, J1751$-$2857, J1857+0943 and J1955+2908). \n\n\\begin{figure*}\n\\begin{minipage}{150mm}\n\\includegraphics[width=150mm]{plots\/J1918_mass_mass.eps}\n\\caption{Same caption as Fig.~\\ref{fig:1600_mass} for PSR J1918$-$0642.}\n\\label{fig:1918_mass}\n\\end{minipage}\n\\end{figure*}\n\n\nFor the three pulsars where we measured both the Shapiro delay and the variation\nof the semi-major axis (i.e. PSRs J0751+1807, J1600$-$3053 and\nJ1857+0943) and PSR J1909$-$3744 (where $\\dot{x} =0.6\\pm1.7 \\times 10^{-16}$\n and $x \\mu \\cot i = 1.08\\times 10^{-14}$), we map the KOM-KIN space with TempoNest\nusing the following procedure. First, we reduce the dimensionality of the Bayesian\nanalysis by fixing the set of white noise parameters to their maximum\nlikelihood values from the\ntiming analysis. We also choose to marginalize analytically over the astrometric and spin\nparameters. Then we manually set the priors on KOM, KIN and M2 to encompass any\nphysical range of solution. Finally we perform the\nsampling with TempoNest with the constant efficiency option turned off, in\norder to more carefully explore the complex multi-modal parameter space. Because of the strong\ncorrelation between the companion mass and the inclination angle in the\ncase of PSR J0751+1807, (see Fig.~\\ref{fig:0751_mass}), we do not report our\nmeasurements as they were not constrained enough. The results are shown in\nFigures \\ref{fig:1600_komkin} to \\ref{fig:1909_komkin} for the other three pulsars. \n\nFor PSR J1600$-$3053, the 1-$\\sigma$ contours of the 2-D posterior distribution\n(Fig.~\\ref{fig:1600_komkin}) give three solutions for\n($\\Omega, i$): $219^\\circ < \\Omega < 244^\\circ$ and $63^\\circ < i < 71^\\circ$ or\n$303^\\circ < \\Omega < 337^\\circ$ and $61^\\circ < i< 72^\\circ$ and the preferred\nsolution, $37^\\circ < \\Omega < 163^\\circ$ and $105^\\circ < i < 122^\\circ$.\nThe 2.5$\\sigma$ detection of $\\dot{x}$ in the PSR J1857+0943 binary system\nstill limit the constraints that can be set on $\\Omega$ (see\nFig.~\\ref{fig:1857_komkin}). Even though we do not detect $\\dot{x}$ for PSR\nJ1909$-$3744, we can constrain $\\Omega$ (see Fig.~\\ref{fig:1909_komkin}) to $-2^\\circ < \\Omega < 33 ^\\circ$ or $181^\\circ <\n\\Omega < 206 ^\\circ$. The preferred solution is $-2^\\circ < \\Omega < 33 ^\\circ$\nand $93.78^\\circ < i < 93.95^\\circ$.\nHowever, with this EPTA dataset, we still have no statistical evidence for the\ndetection of annual-orbital parallax as we cannot distinguish between the symmetric solutions of\nthe pulsar orbits in these three pulsars.\n\n\n\n\\begin{figure}\n\\includegraphics[width=84mm]{plots\/J1600-3053_komkin.eps}\n\\caption{One and two-dimensional marginalized posterior distributions of the\nlongitude of ascending node $\\Omega $ and inclination angle $i$ for PSR\nJ1600$-$3053. The continuous black line, the dashed line and the dotted line\nrepresent, respectively, the 68.3\\%, 95.4\\% and 99.7\\% confidence levels of the\n2-D probability density function. The red cross indicates the maximum\nlikelihood location. The continuous lines in the panels of the projected 1-D\ndistributions of KOM and KIN show the 68.3\\% confidence levels for each\nparameter.}\n\\label{fig:1600_komkin}\n\\end{figure}\n\n\n\\begin{figure}\n\\includegraphics[width=84mm]{plots\/J1857+0943_komkin.eps}\n\\caption{Same caption as Fig.~\\ref{fig:1600_komkin} for PSR J1857$+$0943.}\n\\label{fig:1857_komkin}\n\\end{figure}\n\n\\begin{figure}\n\\includegraphics[width=84mm]{plots\/J1909-3744_komkin.eps}\n\\caption{Same caption as Fig.~\\ref{fig:1600_komkin} for PSR J1909$-$3744.}\n\\label{fig:1909_komkin}\n\\end{figure}\n\n\n\\subsection{Comparison with the latest NANOGrav and PPTA results}\nWhile this work was under review, similar analysis by NANOGrav and the PPTA were\npublished elsewhere \\citep[][hereafter \\citetalias{abb+15} and\n\\citetalias{rhc+16}, respectively]{abb+15,rhc+16}. \\citetalias{abb+15} presents a thorough\ndescription of their data analysis and \\citet[][hereafter\n\\citetalias{mnf+16}]{mnf+16} report on the study of astrometric parameters.\nOther timing results and their interpretations (e.g. pulsar mass measurements) will be presented in a\nseries of upcoming papers. Hence, we briefly summarize here the similarities and\ndifferences between our work and the ones by \\citetalias{rhc+16} and \\citetalias{mnf+16}.\n\n\n\\citetalias{rhc+16} used Tempo2 linearized, least-squares fitting methods to present timing models for a set of 20 MSPs. White noise, DM variations and red\nnoise are included in the timing analysis and modeled with completely independent techniques from the ones\ndescribed in Section~\\ref{sec:timing}. \nFor all 13 pulsars observed commonly by the EPTA and the PPTA, both PTAs\nachieve the detection of the parallax with consistent results\n(within 1.5$\\sigma$). We note here that the parallax value of PSR J1909$-$3744 should\nread $\\pi=0.81\\pm0.03$~mas in \\citetalias{rhc+16} (Reardon, private communication).\nAlso, the seven new proper motions values reported in this paper are for pulsars that are not\nobserved by \\citetalias{rhc+16}.\nWe obtain similar results for the pulsar and companion masses to the\nvalues reported in \\citetalias{rhc+16}, albeit with much greater precision\nin the case of PSRs J1600$-$3053. Furthermore, all our measurements of $\\dot{x}$ agree with \\citetalias{rhc+16}.\nWhile \\citetalias{rhc+16} measure $\\dot{P_b}$ in PSR J1022$+$1001 for the\nfirst time, the EPTA achieve the detection of $\\dot{P_b}$ for another MSP\n(PSR J0613$-$0200), allowing us to get an independent distance estimate for\nthese systems.\n\n\\citetalias{mnf+16} report on the astrometric results for a set of 37 MSPs analyzed\nwith the linearized least-squares fitting package\nTempo\\footnote{http:\/\/tempo.sourceforge.net\/}. More details on the DM and red\nnoise models included in their analysis can be found in \\citetalias{abb+15}.\nAll 14 parallax measurements for the pulsars presented commonly in this work\nand in \\citetalias{mnf+16} are consistent at the 2-$\\sigma$ level. \nIn addition, \\citetalias{mnf+16} show a new parallax measurement for PSR J1918$-$0642\nthat was not detected with our dataset.\n\\citetalias{mnf+16} also present updated proper motions for 35 MSPs and derived the pulsar\nvelocities in galactocentric coordinates.\nThe new proper-motion measurement for PSR J2010$-$1323 reported in our work is\nconsistent at the 2-$\\sigma$ level with the independent measurement from\n\\citetalias{mnf+16}. \n\n\nFinally, \\citetalias{mnf+16} discuss in detail the same discrepancy reported\nin Section~\\ref{sec:dis_shk} between\ntheir measured parallax distance for PSR J1024$-$0719 and its constraint from $D_{\\dot{P}}$.\n\n\n\n\\section{Timing results}\n\\label{sec:results}\n\nIn this section we summarize the timing results of the 42 MSPs obtained from\nTempoNest. Among these sources, six pulsars, namely PSRs J0613$-$0200, J1012+5307,\nJ1600$-$3053, J1713+0747, J1744$-$1134 and J1909$-$3744, have been selected by\n\\citet{bps+15} to form the basis of the work presented by\n\\citet{ltm+15,tmg+15,bps+15}. The quoted uncertainties represent the $68.3\\%$\nBayesian credible interval of the one-dimensional marginalized posterior\ndistribution of each parameter. The timing models are shown in \nTables~\\ref{tab:param1} to \\ref{tab:param11}. These models, including the\nstochastic parameters, are made publicly available on the\nEPTA website\\footnote{http:\/\/www.epta.eu.org\/aom.html}. The reference\nprofiles at L-Band can be found in Fig.~\\ref{plot:templates-1} and \\ref{plot:templates-2}.\nThroughout the paper, we refer to RMS as the weighted Root Mean Square timing\nresiduals. The details on the data sets used in this paper can be found in\nTable~\\ref{tab:data}.\n\n\\input{table_summary}\n\n\\subsection{PSR J0030$+$0451}\nA timing ephemeris for this isolated pulsar has been published by\n\\citet{aaa+09a} with a joint analysis of gamma-ray data from the \\textit{Fermi} Gamma-ray\nSpace Telescope. Because the authors used the older DE200 version of the Solar\nSystem ephemeris model, we report here updated astrometric measurements.\nWhile our measured proper motion is consistent with the \\citet{aaa+09a} value,\nwe get a significantly lower parallax value $\\pi=2.79\\pm0.23 $ mas that we\nattribute partly to the errors in the DE200 ephemeris. Indeed reverting back to\nthe DE200 in our analysis yields an increased value of the parallax by 0.3 mas\nbut still below the parallax $\\pi=4.1\\pm0.3$ mas determined by \\citet{aaa+09a}.\n\n\\subsection{PSR J0034$-$0534}\nPSR J0034$-$0534 is a very faint MSP when observed at L-Band with a flux\ndensity $S_{1400}=0.01$ mJy leading to profiles with very low S\/N compared to\nmost other MSPs considered here. Helped by the better timing precision at\n 350 MHz, we were able to improve on the previously\npublished composite proper motion $\\mu=31\\pm9$\nmas yr$^{-1}$ by \\citet{hll+05} to $\\mu=12.1\\pm0.5$ mas yr$^{-1}$. We also\nmeasure the eccentricity $e=(4.3\\pm0.7) \\times 10^{-6}$ of this system for the\nfirst time. Even with our improved timing precision characterized by a timing\nresiduals RMS of 4 \\us, the detection of the parallax signature (at most 2.4\n\\us~according to \\citet{aaa+10a}) is still out of reach.\n \n \\input{table_param1}\n\n\\subsection{PSR J0218$+$4232}\nThe broad shape of the pulse profile of this pulsar (with a duty cycle of about\n50\\%, see Figure~\\ref{plot:templates-1}) and its low flux density limit\nour timing precision to about 7~$\\mu$s and, therefore, its use for GWB\ndetection. \\citet{dyc+14} recently published the pulsar composite proper\nmotion $\\mu = 6.53\\pm0.08$ mas~yr$^{-1}$ from very long baseline interferometry\n(VLBI). With EPTA data, we find $\\mu=6.14\\pm0.09$ mas~yr$^{-1}$. This value is\nin disagreement with the VLBI result. A possible explanation for this\ndiscrepancy is\nthat \\citet{dyc+14} overfitted their model with five parameters for five\nobserving epochs. \\citet{dyc+14} also\nreported a distance $d=6.3_{-2.3}^{+8.0}$ kpc from VLBI parallax measurement.\n\\citet{vl14} later argued that the \\citet{dyc+14} parallax suffers from the Lutz-Kelker bias\nand corrected the distance to be $d=3.2_{-0.6}^{+0.9}$ kpc. This\ndistance is consistent with the 2.5 to 4 kpc range estimated from the\nproperties of the white dwarf companion to PSR J0218+4232 \\citep{bkk02}. Even with the\n\\citet{vl14} $3\\sigma$ lowest distance estimate, the parallax would induce a\nsignature on the timing residuals of less than 800 ns \\citep{lk04}, which is far from\nour current timing precision. We therefore cannot further constrain the\ndistance with our current dataset. Our measurement of the system's eccentricity\n$e=(6.8\\pm0.4)\\times10 ^{-6} $ is significantly lower than the previously\nreported value $e = (22 \\pm 2) \\times 10^{-6}$ by \\citet{hlk+04}.\n\n\n\\subsection{PSR J0610$-$2100}\nWith a very low-mass companion ($0.02~\\text{M}_{\\odot} <\n\\text{M}_c<0.05~\\text{M}_{\\odot}$), PSR J0610$-$2100 is a member of the\n`black widow' family, which are a group of (often) eclipsing binary MSPs believed\nto be ablating their companions. Here we report on a newly measured\neccentricity, $e=(2.9\\pm0.8) \\times 10^{-5}$, and an improved proper motion\n($\\mu_{\\alpha}=9.0\\pm0.1$ mas~yr$^{-1}$ and $\\mu_{\\delta}=16.78\\pm0.12$\nmas~yr$^{-1}$) compared to the previous values ($\\mu_{\\alpha}=7\\pm3$\nmas~yr$^{-1}$ and $\\mu_{\\delta}=11\\pm3$ mas~yr$^{-1}$) from \\citet{bjd+06}\nderived with slightly more than two years of data. It is interesting to note\nthat, in contrast to another well studied black widow pulsar, PSR J2051$-$0827 \\citep{lvt+11}, no secular\nvariations of the orbital parameters are detected in this system.\nThere is also no evidence for eclipses of the radio signal in our data.\n\nWe checked our data for possible orbital-phase dependent DM-variation that could\naccount for the new measurement of the eccentricity. We found no evidence for\nthis within our DM precision. We also obtained consistent results for the eccentricity and longitude of\nperiastron after removing TOAs for given orbital phase ranges.\n\n\\subsection{PSR J0613$-$0200}\nFor PSR J0613$-$0200, we measure a parallax $\\pi=1.25\\pm 0.13$ mas that is\n consistent with the value published in \\citet{vbc+09} ($\\pi=0.8\\pm\n0.35$ mas). In addition,\nwe report on the first detection of the orbital period derivative $\\dot{P_b} =\n(4.8 \\pm 1.1) \\times\n10^{-14}$ thanks to our 16-yr baseline. This result will be discussed further\nin Section \\ref{sec:dis_shk}. Finally, we improve on the precision of the\nproper motion with $\\mu_{\\alpha}=-1.822\\pm0.008$ mas~yr$^{-1}$ and\n$\\mu_{\\delta}=-10.355\\pm0.017$ mas~yr$^{-1}$.\n\n\\subsection{PSR J0621$+$1002}\nDespite being the slowest rotating MSP of this dataset with a period of almost 30 ms,\nPSR J0621$+$1002 has a profile with a narrow peak feature of width $\\sim500$\n\\us. We are able to measure the precession of the periastron\n$\\dot{\\omega}=0.0113\\pm0.0006$ deg yr$^{-1}$ and find it\nto be within 1 $\\sigma$ of the value reported by \\citet{nsk08} using\n Arecibo data. We also find a similar value of the proper motion\nto \\citet{sna+02}.\n\n\\subsection{PSR J0751$+$1807}\nPSR J0751$+$1807 is a 3.5-ms pulsar in an approximately 6-h orbit. \\citet{nss+05}\noriginally reported a parallax $\\pi=1.6\\pm0.8$~mas and a measurement of the\norbital period derivative $\\dot{P_b}=(-6.4 \\pm 0.9) \\times 10^{-14}$. Together\nwith their detection of the Shapiro delay, they initially derived a large\npulsar mass $m_p=2.1\\pm0.2 \\text{M}_{\\odot}$. \\citet{nsk08} later corrected\nthe orbital period derivative measurement to $\\dot{P}_b=(-3.1\\pm 0.5) \\times 10^{-14}$,\ngiving a much lower pulsar mass $m_p=1.26 \\pm 0.14 \\text{M}_{\\odot}$. Here we\nreport on a parallax $\\pi=0.82 \\pm 0.17$ mas and $\\dot{P}_{b} = (-3.5 \\pm\n0.25) \\times 10^{-14}$ that is similar to the value in \\citet{nsk08}. \nHowever, we measured a precise composite proper motion of\n$13.7\\pm0.3$ mas yr$^{-1}$, inconsistent with the result ($6\\pm2$ mas yr$^{-1}$) from \\citet{nss+05}.\n\\citet{nsk08} explained the issue found with the timing solution presented\nin \\citet{nss+05} but did not provide an update of the proper motion for\ncomparison with our value.\nWe are also able to measure an apparent change in the semi-major axis\n$\\dot{x}=(-4.9\\pm0.9) \\times 10^{-15}$. Finally, we applied the orthometric\nparametrization of the Shapiro delay to get $h_3=(3.0 \\pm 0.6) \\times 10^{-7}$ and $\\varsigma=0.81\\pm0.17$.\n The interpretation of these results will be discussed in Section \\ref{sec:dis_mass}.\n\n\n\\subsection{PSR J0900$-$3144}\nWith about seven years of timing data available for PSR J0900$-$3144 (discovered\nby \\citep{bjd+06}) we detect the proper motion for the first time,\nrevealing it to be one of the lowest composite proper-motion objects among our\ndata set with $\\mu=2.26\\pm0.07$ mas yr$^{-1}$. We also uncover a marginal\nsignature of the parallax $\\pi=0.77\\pm 0.44$ mas. However, we do not detect the\nsignature of the Shapiro delay despite the improvement in timing precision\ncompared to \\citet{bjd+06}.\nFollowing the criterion introduced in Section~\\ref{sec:criteria}, we\n get $h_{3o}=0.4 \\mu$s. With $\\delta_{\\text{TOAs}} = 4.27\\mu$s and N$_\\text{TOAs} =\n875$, we find $\\xi =0.14$~$\\mu$s. Hence, given $ \\xi < h_{3o}$, we argue for $i \\lesssim 60^\\circ$ to explain\nthe lack of Shapiro delay detection in this system.\n\n\\input{table_param2}\n\n\\subsection{PSR J1012$+$5307}\n\\citet{lwj+09} previously presented a timing solution using a subset of these\nEPTA data to perform a test on gravitational dipole radiation and variation of the\ngravitational constant, $\\dot{G}$. The $\\dot{x}$ and $\\dot{P_b}$ parameters we\npresent here are consistent with the values from \\citet{lwj+09} but we\nimprove on the uncertainties of these parameters by factors of two and three,\nrespectively. Nonetheless, we note that our value for the parallax $\\pi=0.71\\pm 0.17$\nmas differs by less than 2$\\sigma$ from the value measured by \\citet{lwj+09} using\nthe DE405 ephemeris. \n\n\n\\subsection{PSR J1022$+$1001}\nAs recently pointed out by \\citet{van13}, this source requires a high level of\npolarimetric calibration in order to reach the best timing precision. Indeed,\nby carefully calibrating their data, \\citet{van13} greatly improved on the\ntiming model of \\citet{vbc+09} and successfully unveiled the precession of the\nperiastron $\\dot{\\omega }=0.0097\\pm0.0023$ deg yr$^{-1}$, the presence of \nShapiro delay and the secular variation of $\\dot{x}$. Here we find similar\nresults with $\\dot{\\omega }=0.010 \\pm 0.002$ deg yr$^{-1}$ and a 2-$\\sigma$ \nconsistent $\\dot{x}$ with a completely independent dataset.\n Nonetheless, we can not confirm the measurement of Shapiro delay\nwith our dataset. For this pulsar, we get $h_{3o}=0.62 \\mu$s. With $\\xi =\n0.14$ $\\mu$s, our constraint implies that the inclination angle $i \\lesssim 60^\\circ$, in\nagreement with the result presented by \\citet{van13}.\n\n\\subsection{PSR J1024$-$0719}\n\\citet{hbo06} were the first to announce a parallax $\\pi=1.9\\pm 0.4$ mas for\nthis nearby and isolated MSP that shows a large amount of red noise\n\\citep{cll+15}. More recently, \\citet{egc+13} used a subset of this\nEPTA dataset to produce an\nephemeris and detected gamma-ray pulsations from this pulsar. The authors assumed\nthe LK bias corrected distance \\citep{vwc+12} from the \\citet{hbo06} parallax\nvalue to estimate its gamma-ray efficiency. However, it should be noted that\n\\citet{vbc+09} did not report on the measurement of the parallax using an\nextended version of the \\citet{hbo06} dataset. \nWith this independent dataset we detect a parallax $\\pi=0.80\\pm0.17$ mas, a\nvalue inconsistent with the early measurement reported by \\citet{hbo06}. A\npossible explanation for this discrepancy could be that \\citet{hbo06} did not\ninclude a red noise model in their analysis.\n\n\\subsection{PSR J1455$-$3330}\nThe last timing solution for this pulsar was published by \\citet{hlk+04} and\ncharacterized by an RMS of 67 \\us. Thanks to our 9 years of data\nwith an RMS of less than 3 \\us, we successfully detect the signature of\nthe proper motion $\\mu_{\\alpha}=7.88\\pm0.08$ mas~yr$^{-1}$ and\n$\\mu_{\\delta}=-2.23\\pm0.19$ mas~yr$^{-1}$, the parallax $\\pi=1.04\\pm 0.35$ mas\nand the secular variation of the semi-major axis,\n$\\dot{x}=(-1.7\\pm0.4)\\times10^{-14}$ for the first time.\n\n\\subsection{PSR J1600$-$3053}\nThis 3.6-ms pulsar can be timed at very high precision thanks to the $\\sim 45$\n\\us~wide peak on the right edge of its profile (see\nFig.~\\ref{plot:templates-1}). We present here a precise measurement of the\nparallax $\\pi = 0.64 \\pm 0.07$ mas, a value marginally consistent with the\n$\\pi = 0.2 \\pm 0.15$ mas from \\citet{vbc+09}. We also show a large improvement\non the Shapiro delay detection through the use of the orthometric\nparametrization \\citep{fw10} with $h_3= (3.3\\pm0.2) \\times 10^{-7}$ and\n$\\varsigma=0.68\\pm0.05$. The resulting mass measurement of this system\nis discussed in Section~\\ref{sec:dis_mass}.\n\n\\input{table_param3}\n\n\\subsection{PSR J1640$+$2224}\n\\citet{llw+05} used early Arecibo and Effelsberg data to report on the tentative detection of Shapiro delay for\nthis wide binary system in a 6-month orbit. From this measurement they deduced\nthe orientation of the system to be nearly edge-on ($78^{\\circ} < i <\n88^{\\circ}$) and a companion mass for the white dwarf $m_p=0.15_{-0.05}^{+0.08}\n\\text{M}_{\\odot}$. We cannot constrain the Shapiro delay with the\ncurrent EPTA data, even though our data comprise almost twice the number of\nTOAs with a similar overall timing precision. The parallax signature in the\nresiduals also remains undetected (based on Bayesian evidence\\footnote{A\ndifference of 3 in the log evidence between two models is usually required to\njustify the introduction of an additional parameter \\citep{kr95}.}) but we find a significant\n$\\dot{x}=(1.07\\pm0.16)\\times 10^{-14}$, consistent with the upper limit set by \\citet{llw+05}.\n\n\\subsection{PSR J1643$-$1224}\nUsing PPTA data, \\citet{vbc+09} previously announced a parallax value $\\pi =\n2.2 \\pm 0.4$ mas that is marginally consistent with our value of $\\pi = 1.17\n\\pm 0.26$ mas. We get a similar proper motion and $\\dot{x}=(-4.79\\pm0.15) \\times\n10^{-14}$, albeit measured with a greater precision.\n\n\\subsection{PSR J1713$+$0747}\n\\label{sec:1713}\nPSR J1713$+$0747 is one of the most precisely timed pulsars over two decades\n\\citep{vbc+09, zsd+15}.\nOur proper motion and parallax values are consistent with the ones from \\citet{vbc+09} and\n\\citet{zsd+15}. Nonetheless we can not detect any hint of the orbital period derivative $\\dot{P_{b}}$.\nThe measurement of the Shapiro delay yields the following masses of the system,\n$m_p=1.33_{-0.08}^{+0.09} \\text{M}_{\\odot}$ and $m_c=0.289_{-0.011}^{+0.013}\n\\text{M}_{\\odot}$, in very good agreement with \\citet{zsd+15}.\n\n\nWhen inspecting the residuals of PSR J1713$+$0747 we noticed successive TOAs\ntowards the end of 2008 that arrived significantly earlier ($\\sim3$ \\us) than\npredicted by our ephemeris (see top panel of Figure~\\ref{plot:1713_event}).\nAfter inspection of the original archives and comparison with other high\nprecision datasets like those on PSRs J1744$-$1134 and J1909$-$3744, we ruled out any\ninstrumental or clock issue as an explanation for this shift. We therefore\nattribute this effect to a deficiency of the electron content towards the line\nof sight of the pulsar. This event has also been observed by the other PTAs\n\\citep{zsd+15,cks+15} and interpreted as possibly a kinetic shell propagating\nthrough the interstellar medium \\citep{cks+15} followed by a rarefaction of the electron\ncontent.\n\nTo model this DM event we used shapelet basis functions. A thorough\ndescription of the shapelet formalism can be found in \\cite{ref03}, with\nastronomical uses being described in e.g., \\cite{rb03,km04,lah15}. Shapelets\nare a complete ortho-normal set of basis functions that allow us to recreate\nthe effect of non-time-stationary DM variations in a statistically robust\nmanner, simultaneously with the rest of the analysis. We used the Bayesian\nevidence to determine the number of shapelet coefficients to include in the\nmodel (only one coefficient was necessary in this study, i.e. the shapelet is\ngiven by a Gaussian). Our priors on the\nlocation of the event span the entire dataset, while we assume an event width\nof between five days and one year. The maximum likelihood results indicate\nan event centered around MJD 54761 with a width of 10 days. The resulting DM signal\n(including the shapelet functions) and the residuals corrected from it are\nplotted in the middle and bottom panels of Fig.~\\ref{plot:1713_event}\nrespectively. The DM model hence predicts a drop of $(1.3\\pm0.4) \\times 10^{-3}$\npc~cm$^{-3}$.\n\n\n\\begin{figure}\n\\centering\n\\includegraphics[height=80mm,angle=-90]{plots\/1713-event.ps}\n\\caption{Top panel: zoom-in on the PSR J1713$+$0747 residuals (black dots and red\ntriangles are L-Band and S-Band data respectively). Middle panel: DM signal\nfrom the maximum likelihood DM model incorporating the shapelet basis functions\n(see Section~\\ref{sec:1713} for details). The bottom panel shows the residuals after\nsubtraction of the DM signal. The uncertainties on the DM signal come directly\nfrom the 1-$\\sigma$ uncertainties on the shapelet amplitudes used to model the\nevent, obtained from the full Bayesian analysis.}\n\\label{plot:1713_event}\n\\end{figure}\n\n\\input{table_param4}\n\n\\subsection{PSR J1721$-$2457}\nThanks to an additional five years of data compared to \\citet{jsb+10}, the\nproper motion of this isolated MSP is now better constrained. Our current\ntiming precision is most likely limited by the pulsar's large duty cycle (see\nFig.~\\ref{plot:templates-1}) and the apparent absence of sharp features in the\nprofile. The flux density of this pulsar is also quite low with a value of 1 mJy at 1400MHz.\n\n\\subsection{PSR J1730$-$2304}\nThis low-DM and isolated MSP has a profile with multiple pulse components (see\nFig.~\\ref{plot:templates-1}). As this pulsar lies very near to the ecliptic\nplane ($\\beta= 0.19^{\\circ}$), we are unable to constrain its proper motion in\ndeclination, similar to the previous study \\citep{vbc+09}. Assuming the NE2001 distance, the\nexpected parallax timing signature would be as large as 2.3 \\us. We report here on a\ntentative detection of the parallax, $\\pi = 0.86\\pm0.32$ mas.\n\n\\subsection{PSR J1738$+$0333}\nAfter the determination of the masses in this system from optical observations\n\\citep{akk+12}, \\citet{fwe+12} used the precise measurements of the proper motion, parallax\n and $\\dot{P_b}$ in this binary system to put constraints on\nscalar-tensor theories of gravity. Our measured proper motion remains\nconsistent with their measurements. With a longer baseline and more\nobservations recorded with the sensitive Arecibo Telescope, \\citet{fwe+12}\nwere able to detect the parallax and the orbital period derivative of the\nsystem. However, we do not yet reach the sensitivity to detect these two\nparameters with our dataset.\n\n\n\\subsection{PSR J1744$-$1134}\nThis isolated MSP was thought to show long-term timing noise by \\citet{hbo06}\neven with a dataset shorter than 3 years.\nIn our data set we detect a (red) timing noise component \\citep[see][]{cll+15}.\nThe RMS of the time-domain noise signal is\n$\\sim\\,0.4\\mu$s, but has a peak-to-peak variation of $\\sim\\,2\\mu$s. The\nhigher latter value, however, is due to a bump which appears localized\nin time (MJD $\\sim$ 54000 to 56000). As discussed in \\citet{cll+15},\nnon-stationary noise\nfrom instrumental instabilities may cause such effects, but data with\nbetter multi-telescope coverage are necessary to verify such a\npossibility. This is further investigated in Lentati et al. (submitted)\nusing a more extended dataset from the International Pulsar Timing Array (IPTA) \n\\citep{vlh+16}.\n\n\n\\input{table_param5}\n\n\\subsection{PSR J1751$-$2857}\n\\citet{sfl+05} announced this wide ($P_b = 111$~days) binary MSP after\ntiming it for 4 years with an RMS of 28 $\\mu s$ without a detection of the proper\nmotion. With 6 years of data at a much lower RMS, we are able to constrain its\nproper motion ($\\mu_{\\alpha}=-7.4\\pm0.1$ mas~yr$^{-1}$ and\n$\\mu_{\\delta}=-4.3\\pm1.2$ mas~yr$^{-1}$) and detect $\\dot{x}=(4.6\\pm0.8) \\times\n10^{-14}$.\n\n\n\\subsection{PSR J1801$-$1417}\nThis isolated MSP was discovered by \\citet{lfl+06}. With increased timing\nprecision, we measure a new composite proper motion $ \\mu = 11.3\\pm0.3$ mas\nyr$^{-1}$. As our dataset for this pulsar does not include multifrequency\ninformation; we can not rule out DM variations.\n\n\\subsection{PSR J1802$-$2124}\n\\citet{fsk+10} recently reported on the mass measurement of this system by\ncombining TOAs from the Green Bank, Parkes and Nan\\c cay radio telescopes.\nTherefore, our dataset shows no improvement in the determination of the system\nparameters but gives consistent results to \\citet{fsk+10}.\n\n\\subsection{PSR J1804$-$2717}\nWith an RMS timing residual improved by a factor 25 compared to the last\nresults published by \\citet{hlk+04}, we obtain a reliable measurement of the\nproper motion of this system. Assuming the distance based on the NE2001 model\n$d_{\\text{NE2001}} = 780$ pc, the parallax timing signature can amount to 1.5\n\\us, still below our current timing precision.\n\n\\input{table_param6}\n\n\\subsection{PSR J1843$-$1113}\nThis isolated pulsar discovered by \\citet{hfs+04} is the second fastest-spinning\nMSP in our dataset. Its mean flux density (S$_{1400} = 0.6$ mJy)\nis among the lowest, limiting our current timing precision to $\\sim$ 1 \\us. For\nthe first time, we report the detection of the proper motion\n$\\mu_{\\alpha}=-1.91\\pm0.07$ mas~yr$^{-1}$ and $\\mu_{\\delta}=-3.2\\pm0.3$\nmas~yr$^{-1}$ and still low-precision parallax $\\pi = 0.69 \\pm 0.33$ mas.\n\n\\subsection{PSR J1853$+$1303}\nOur values of proper motion and semi-major axis change are consistent with the\nrecent work by \\citet{gsf+11} using high-sensitivity Arecibo and Parkes data,\nthough there is no evidence for the signature of the parallax in our data\n , most likely due to our less precise dataset.\n\n\\subsection{PSR J1857$+$0943 (B1855+09)}\nOur measured parallax $\\pi=0.7\\pm0.26$ mas is lower than, but still compatible\nwith, the value reported by \\citet{vbc+09}. We also report a marginal detection\nof $\\dot{x} = (-2.7 \\pm 1.1) \\times 10^{-15}$. Our measurement of the Shapiro\ndelay is also similar to the previous result from \\citet{vbc+09}.\n\n\\subsection{PSR J1909$-$3744}\nPSR J1909$-$3744 \\citep{jbv+03} is the most precisely timed source with a RMS\ntiming residual of about 100 ns. As these authors pointed out, this pulsar's\nprofile has a narrow peak with a pulse duty cycle of 1.5\\% (43$\\mu$s) at FWHM (see\nFig.~\\ref{plot:templates-2}). Unfortunately its declination makes it only\nvisible with the NRT but it will be part of the SRT timing campaign. We improved\nthe precision of the measurement of the orbital period derivative $\\dot{P_b}$ by a factor\nof six compared to \\citet{vbc+09} and our constraint on $\\dot{x}$ is\nconsistent with their tentative detection.\n\n\n\\subsection{PSR J1910$+$1256}\nWe get similar results as recently published by \\citet{gsf+11} with Arecibo and\nParkes data. In addition, we uncover a marginal signature of the parallax\n$\\pi = 1.44 \\pm 0.74$ mas, consistent with the upper limit set by \\citet{gsf+11}.\n\n\\input{table_param7}\n\n\\subsection{PSR J1911$+$1347}\n With a pulse width at 50\\% of the main peak amplitude (see\nFig.~\\ref{plot:templates-2}), $W_{50} = 89 $ $\\mu$s (only twice the width of\nJ1909$-$3744), this isolated MSP is potentially a good candidate for PTAs.\nUnfortunately it has so far been observed at the JBO and NRT observatories only and\nno multifrequency observations are available. Based on this work, this pulsar\nhas now been included in the observing list at the other EPTA telescopes.\nDespite the good timing precision we did not detect the parallax but we did\nmeasure the proper motion for the first time with $\\mu_{\\alpha}=-2.90\\pm0.04$\nmas~yr$^{-1}$ and $\\mu_{\\delta}=-3.74\\pm0.06$ mas~yr$^{-1}$.\n\n\\subsection{PSR J1911$-$1114}\nThe last ephemeris for this pulsar was published by \\citet{tsb+99} 16 years\nago using the DE200 planetary ephemeris. Our EPTA dataset spans three times\nlonger than the one from \\citet{tsb+99}. We hence report here on a greatly\nimproved position, proper motion ($\\mu_{\\alpha}=-13.75\\pm0.16$ mas~yr$^{-1}$\nand $\\mu_{\\delta}=-9.1\\pm1.0$ mas~yr$^{-1}$) and a new eccentricity\n$e=(1.6\\pm1.0) \\times 10^{-6}$, lower by a factor of 10 than the previous\nmeasurement.\n\n\\subsection{PSR J1918$-$0642}\nPSR J1918$-$0642 is another MSP studied by \\citet{jsb+10} with EPTA data.\nCompared to \\citet{jsb+10} we extended the baseline with an additional five\nyears of data. We unveil the signature of Shapiro delay in this system\nwith $h_3=(8.6\\pm1.2)\\times 10^{-7}$ and $\\varsigma =0.91\\pm0.04$.\nThe masses of the system are discussed in Section~\\ref{sec:dis_mass}.\n\n\n\\input{table_param8}\n\n\\subsection{PSR J1939$+$2134 (B1937+21)}\nThanks to the addition of early Nan\\c cay DDS TOAs, our dataset span over 24\nyears for this pulsar. This pulsar has been long known to show significant DM\nvariations as well as a high level of timing noise \\citep{ktr94}; see\nresiduals in Fig.~\\ref{plot:residuals-2}. A\npossible interpretation of this red noise is the presence of an asteroid belt\naround the pulsar \\citep{scm+13}. Despite this red noise, the timing signature\nof the parallax has successfully been extracted to get $\\pi=0.22 \\pm 0.08$ mas,\na value consistent with \\citet{ktr94} and \\citet{vbc+09}.\n\n\\subsection{PSR J1955$+$2908 (B1953+29)}\nPSR J1955$+$2908 is another MSP recently analyzed by \\citet{gsf+11}. With an\nindependent dataset, we get similar results to \\citet{gsf+11}. We report here on\nthe tentative detection of $\\dot{x}=(4.0\\pm1.4) \\times 10^{-14}$.\n\n\\subsection{PSR J2010$-$1323}\nThis isolated MSP was discovered a decade ago \\citep{jbo+07} and no update on\nthe pulsar's parameters has been published since then. Hence we announce here\nthe detection of the proper motion $\\mu_{\\alpha}=-2.53\\pm0.09$ mas~yr$^{-1}$\nand $\\mu_{\\delta}=-5.7\\pm0.4$ mas~yr$^{-1}$. Assuming the NE2001 distance of 1\nkpc, the parallactic timing signature would amount to 1.17 $\\mu s$ but was not\ndetected in our data.\n\n\\subsection{PSR J2019$+$2425}\nCompared to the Arecibo 430-MHz dataset used by \\citet{nss01}, the EPTA timing\nprecision for this pulsar is limited due to its low flux density at 1400 MHz. Because\nof this we are not able to measure the secular change of the projected\nsemi-major axis $\\dot{x}$.\n\n\\input{table_param9}\n \n\\subsection{PSR J2033$+$1734}\nIn spite of a narrow peak of width $\\sim 160$ $\\mu$s this MSP has a very large\ntiming RMS of 14 $\\mu$s. With the absence of obvious systematics in the\nresiduals, we attribute the poor timing precision to the extremely low flux\ndensity of this pulsar at 1400 MHz, $S_{1400} = 0.1$ mJy where all of our\nobservations were performed. Indeed this pulsar was discovered by\n\\citet{rtj+96} with the Arecibo telescope at 430 MHz and later followed up by\n\\citet{spl04} still at 430 and 820 MHz with the Green Bank 140-ft telescope.\nHere we report with an independent dataset at 1400 MHz a similar proper motion\nresult to \\citet{spl04}. \n\n\\subsection{PSR J2124$-$3358}\nFor the isolated PSR J2124$-$3358, our measured proper motion is consistent\nwith the already precise value published by \\citet{vbc+09}. Our parallax\n$\\pi=2.50\\pm0.36$ mas is also consistent with their results but with a better\nprecision.\n\n\\subsection{PSR J2145$-$0750}\nDespite its rotational period of 16 ms PSR J2145$-$0750 is characterized by a\ntiming RMS of 1.8 $\\mu$s thanks to its narrow leading peak and large average\nflux density, $S_{1400}=7.2$~mJy. The EPTA dataset does not show any\nevidence for a variation of the orbital period of PSR J2145$-$0750 or a\nprecession of periastron, even though \\citet{vbc+09} reported a marginal\ndetection with a slightly shorter data span characterized by a higher RMS\ntiming residual. On the other hand, we detect a significant\n$\\dot{x}=(8.2\\pm0.7)\\times10^{-15}$, which is not consistent with the\nmarginal detection, $\\dot{x}=(-3\\pm1.5)\\times10^{-15}$, reported by \\citet{vbc+09}. \n\n\\subsection{PSR J2229$+$2643}\nWith eight years of data on PSR J2229$+$2643, we measure\n$\\mu_{\\alpha}=-1.73\\pm0.12$ mas~yr$^{-1}$ and $\\mu_{\\delta}=-5.82\\pm0.15$\nmas~yr$^{-1}$. Our measured $\\mu_{\\delta}$ is inconsistent with the last timing solution by\n\\citet{wdk+00} using the DE200 ephemeris ($\\mu_{\\alpha}=1\\pm4$ mas~yr$^{-1}$ and $\\mu_{\\delta}=-17\\pm4$\nmas~yr$^{-1}$). Given our much smaller timing residual RMS, our use of the\nsuperior DE421 model and longer baseline, we are confident our value is\nmore reliable. The expected timing signature of the parallax (0.7 \\us) is too small\nto be detected with the current dataset. Note that the early Effelsberg data\nrecorded with the EPOS backend included in \\citet{wdk+00} are not part of this\ndataset.\n\n\\input{table_param10}\n\n\\subsection{PSR J2317$+$1439}\nCompared to \\citet{cnt96} we are able to constrain the proper motion\n($\\mu_{\\alpha}=-1.19\\pm0.07$ mas~yr$^{-1}$ and $\\mu_{\\delta}=3.33\\pm0.13$\nmas~yr$^{-1}$) and eccentricity $e=(5.7\\pm1.6) \\times 10^{-7}$ of the system\nthrough the use of the ELL1 parametrization. We also detect a marginal\nsignature of the parallax $\\pi=0.7\\pm0.3$ mas. \n\n\\subsection{PSR J2322$+$2057}\nPSR J2322$+$2057 is an isolated MSP with a pulse profile consisting of two\npeaks separated by $\\simeq$ 200\\dg (see Fig.~\\ref{plot:templates-2}).\n\\citet{nt95} were the last to publish a timing solution for this last source in\nour dataset. We measure a proper motion consistent with their results albeit\nwith much greater precision, $\\mu=24.0\\pm0.4$ mas yr$^{-1}$.\n\n\\input{table_param11}\n\n\\section{Introduction}\n\nThree decades ago \\citet{bkh+82} discovered the first millisecond pulsar (MSP), \nspinning at 642 Hz. Now over 300 MSPs have been found; see the Australia\nTelescope National Facility (ATNF) pulsar\ncatalog\\footnote{http:\/\/www.atnf.csiro.au\/people\/pulsar\/psrcat\/} \\citep{mht+05}. MSPs are\nthought to be neutron stars spun-up to rotation periods (generally) shorter than 30 ms via the\ntransfer of mass and angular momentum from a binary companion\n\\citep{acr+82,rs82}. We know that the vast majority of the MSP population ($ \n\\simeq 80$\\%) still\nreside in binary systems and these objects have been shown to be incredible\nprobes for testing physical theories. Their applications range from\nhigh-precision tests of general relativity (GR) in the quasi-stationary strong-field regime\n\\citep{ksm+06,fwe+12} to constraints on the equation of state of matter at supra-nuclear densities\n\\citep{dpr+10,afw+13}. Binary systems with a MSP and a white dwarf in wide orbits\noffer the most stringent tests of the strong equivalence principle\n\\citep[e.g.][]{sfl+05,fkw12,rsa+14}.\n\n Most\nof these applications and associated results mentioned above arise from the use of the pulsar\ntiming technique that relies on two properties of the radio MSPs: their\nextraordinary rotational and average pulse profile stability. The pulsar\ntiming technique tracks the times of arrival (TOAs) of the pulses recorded at\nthe observatory and compares them to the prediction of a best-fit model. This\nmodel, which is continuously improved as more observations are made available,\ninitially contains the pulsar's astrometric parameters, the rotational parameters\nand the parameters describing the binary orbit, if applicable. With the recent\nincrease in timing precision due to e.g. improved receivers, larger available \nbandwidth and the use of coherent dedispersion \\citep{hr75},\nparameters that have a smaller effect on the TOAs have become measurable.\n\nThe first binary pulsar found, PSR B1913+16 \\citep{ht75}, yielded the first evidence\nfor gravitational waves (GWs) emission. Since then, several ground-based detectors have been built\naround the globe, e.g. Advanced LIGO \\citep{lig15} and Advanced Virgo\n\\citep{vir15}, to\ndirectly detect GWs in the frequency range of 10-7000 Hz.\nAlso a space mission, eLISA \\citep{lis+13}, is being designed to study GWs in the mHz regime.\nPulsars, on the other hand, provide a complementary probe for GWs\n by opening a new window in the nHz regime \\citep{saz78,det79}.\nPrevious limits on the amplitude of the stochastic GW background (GWB) have been set by studying individual MSPs\n\\citep[e.g.][]{ktr94}.\nHowever, an ensemble of pulsars spread over the sky (known as Pulsar Timing\nArray; PTA) is required to ascertain the presence of a GWB and discriminate between\npossible errors in the Solar System ephemeris or in the reference time\nstandards \\citep{hd83,fb90}.\n\nA decade ago, \\citet{jhl+05} claimed that timing a set of a least 20 MSPs with a precision of\n100 ns for five years would allow a direct detection of the GWB.\nSuch high timing precision has not yet been reached \\citep{abb+15}.\nNonetheless, \\citet{sej+13} recently argued that when a PTA enters a new signal\nregime where the GWB signal starts to prevail over the low frequency pulsar\ntiming noise, the sensitivity of this PTA\ndepends more strongly on the number of pulsars than the cadence of the\nobservations or the timing precision. Hence, datasets consisting of many pulsars\nwith long observing baselines, even with timing precision of $\\sim 1 \\mu$s, constitute\nan important step towards the detection of the GWB. In addition to the GWB\nstudies, such long and precise datasets allow additional timing parameters, and\ntherefore science, to be extracted from the same data.\n\nParallax measurements can contribute to the construction of Galactic electron\ndensity models \\citep{tc93,cl02}. Once built, these models can provide distance\n estimates for pulsars along generic lines-of-sight. New parallax measurements hence\nallow a comparison and improvement of the current free electron distribution\nmodels \\citep{sch12}.\nAn accurate distance is also crucial to correct the spin-down rate of the\npulsar from the bias introduced by its proper motion \\citep{shk70}. This same\ncorrection has to be applied to the observed orbital period derivative before\nany test of GR can be done with this parameter \\citep{dt91}.\n\nIn binary systems, once the Keplerian parameters are known, it may be possible\nto detect post-Keplerian (PK) parameters. These theory-independent parameters \n describe the relativistic\ndeformation of a Keplerian orbit as a function of the Keplerian parameters and\nthe {\\it a priori} unknown pulsar\nmass ($m_p$), companion mass ($m_c$) and inclination angle ($i$).\nMeasurement of the Shapiro delay, an extra propagation delay of the radio waves\ndue to the gravitational potential of the companion, gives 2 PK parameters\n(range $r$ and shape $s\\equiv \\sin i$).\nOther relativistic effects such as the advance of periastron $\\dot{\\omega}$\nand the orbital decay $\\dot{P_b}$ provide one extra PK parameter each.\nIn GR, any PK parameter can be described by the Keplerian parameters plus the\ntwo masses of the system. Measuring three or more PK parameters therefore\noverconstrains the masses, allowing one to perform tests of GR\n\\citep{tw89,ksm+06}.\n\nThe robustness of the detections of these parameters can be hindered\nby the presence of stochastic influences like dispersion measure (DM)\nvariations and red (low-frequency) spin noise in the timing residuals \\citep{chc+11,lah+14}.\nRecent work by \\citet{kcs+13} and \\citet{lbj+14} discussed the modeling of the\nDM variations while \\citet{chc+11} used Cholesky decomposition of the covariance\nmatrix to properly estimate the parameters in the presence of red noise.\n Correcting for the DM\nvariations and the effects of red noise has often been done through an iterative\nprocess. However, TempoNest, a Bayesian pulsar timing analysis software\n\\citep{lah+14} used in this work allows one to model these stochastic\ninfluences\nsimultaneously while performing a non-linear timing analysis. \n\n\nIn this paper we report on the timing solutions of 42 MSPs observed by the\nEuropean Pulsar Timing Array (EPTA). The EPTA is a collaboration of European\nresearch institutes and radio observatories that was established in 2006\n\\citep{kc13}. The EPTA makes use of the five largest (at decimetric\nwavelengths) radio telescopes in Europe: the Effelsberg Radio Telescope in\nGermany (EFF), the Lovell Radio\nTelescope at the Jodrell Bank Observatory (JBO) in England, the Nan\\c cay Radio\nTelescope (NRT) in France, the Westerbork Synthesis Radio Telescope (WSRT) in\nthe Netherlands and the Sardinia Radio Telescope (SRT) in Italy. As the SRT is\ncurrently being commissioned, no data from this telescope are included in this paper.\nThe EPTA also operates the Large European Array for Pulsars (LEAP), where\ndata from the EPTA telescopes are coherently combined to form a tied-array telescope with\nan equivalent diameter of 195 meters, providing a significant improvement in\nthe sensitivity of pulsar timing observations \\citep{bjk+15}.\n\nThis collaboration has already led to previous publications. Using multi-telescope\ndata on PSR J1012$+$5307, \\citet{lwj+09} put a limit on the gravitational\ndipole radiation and the variation of the gravitational constant $G$.\n\\citet{jsb+10} presented long-term timing results of four MSPs, two of which are\nupdated in this work. More recently, \\citet{hlj+11} set the first EPTA upper\nlimit on the putative GWB. Specifically for a GWB formed by circular, GW-driven\nsupermassive black-hole binaries, they measured the amplitude $A$ of the\ncharacteristic strain level at a frequency of 1\/yr, $A < 6 \\times\n10^{-15}$, using a subset of the EPTA data from only 5 pulsars.\n\n\nSimilar PTA efforts are ongoing around the globe with the Parkes Pulsar\nTiming Array (PPTA; \\citet{mhb+13}) and the NANOGrav collaboration\n\\citep{mac13}, also setting limits on the GWB \\citep{dfg+13, src+13}.\n\n\n\n\nThe EPTA dataset introduced here, referred to as the EPTA Data\nRelease 1.0, serves as the reference dataset for the\nfollowing studies: an analysis of the DM variations (Janssen et al., in prep.),\n a modeling of the red noise in each pulsar \\citep{cll+15}, a limit on the stochastic GWB\n\\citep{ltm+15} and the anisotropic background \\citep{tmg+15} as well as a\nsearch for continuous GWs originating from single sources\n\\citep{bps+15}. The organization of this paper is as follows. The\ninstruments and methods to extract the TOAs at each observatory are described\nin Section~\\ref{sec:obs}. The combination and timing procedures are detailed\nin Section~\\ref{sec:timing}. The timing results and new parameters are\npresented in Section~\\ref{sec:results} and discussed in Section ~\\ref{sec:discussions}.\n Finally, we summarize and present some prospects about the EPTA in Section~\\ref{sec:conclusions}.\n\n\\section{Observations and data processing}\n\\label{sec:obs}\n\nThis paper presents the EPTA dataset, up to mid-2014, that was gathered\nfrom the `historical' pulsar instrumentations at\nEFF, JBO, NRT and WSRT with, respectively, the EBPP (Effelsberg-Berkeley Pulsar Processor), \nDFB (Digital FilterBank), BON (Berkeley-Orl\\'eans-Nan\\c cay) and PuMa (Pulsar\nMachine) backends.\nThe data recorded with the newest generation of instrumentations, e.g. PSRIX\n at EFF \\citep{lkg+16} and PuMaII at WSRT \\citep{kss08}, will be part of a future EPTA data release.\n\n Compared to the dataset presented in\n\\citet{hlj+11}, in which timing of only five pulsars was presented, this\nrelease includes 42 MSPs (listed in Table\n\\ref{tab:summary} with their distribution on the sky shown in\nFig.~\\ref{fig:aitoff}). Among those 42 MSPs, 32 are members of binary systems. The timing\nsolutions presented here span at least seven years, and for 16 of the MSPs the\nbaseline extends back $\\sim 15$ years. For the five pulsars included in\n\\citet{hlj+11}, the baseline is extended by a factor 1.7-4.\nWhen comparing our set of pulsars with the NANOGrav Nine-year Data Set\n\\citep{abb+15} (consisting of 37 MSPs) and the PPTA dataset \\citep{mhb+13,rhc+16}\n(consisting of 20 MSPs), we find\nan overlap of 21 and 12 pulsars, respectively. However, we note that the\nNANOGrav dataset contains data for 7 MSPs with a baseline less than two years.\n\n\n In this paper, we define an observing system as a specific combination\nof observatory, backend and frequency band. The radio telescopes and pulsar\nbackends used for the observations are described below.\n\n\n\n\\begin{figure}\n\\includegraphics[height=80mm,angle=-90]{plots\/MSPs_aitoff.ps}\n\\caption{Distribution of the 42 MSPs, represented with a star, in Galactic\ncoordinates (longitude $l$ and latitude $b$). The center of the plot is\noriented towards the Galactic Center. The hatched area is the part of the sky\n(declination $\\delta < -39^\\circ$) that is not accessible to the EPTA.}\n\\label{fig:aitoff}\n\\end{figure}\n\n\\subsection{Effelsberg Radio Telescope}\n\nThe data from the 100-m Effelsberg Radio Telescope presented in this paper were\nacquired using the EBPP, an online\ncoherent dedispersion backend described in detail by \\citet{bdz+97}. This\ninstrument can process a bandwidth (BW) up to 112 MHz depending on the DM value.\nThe signals from the two circular polarizations are split into 32 channels each\nand sent to the dedisperser boards. After the dedispersion takes place, the\noutput signals are folded (i.e. individual pulses are phase-aligned and summed)\nusing the topocentric pulse period.\n\n \nEPTA timing observations at Effelsberg were made at a central frequency of 1410\nMHz until April 2009 then moved to 1360 MHz afterwards due to a change in the\nreceiver. Additional observations at S-Band (2639 MHz) began in November 2005\nwith observations at both frequencies taken during the same two-day observing\nrun. Typically, the observations occur on a monthly basis with an integration time per source\nof about 30 minutes. The subintegration times range from 8 to 12 mins before\n2009 and 2 mins thereafter. For 4 pulsars, namely PSRs J0030$+$0451,\nJ1024$-$0719, J1730$-$2304 and J2317$+$1439, there is a gap in the data from\n1999 to 2005 as these sources were temporarily removed from the observing list. Data reduction was\nperformed with the PSRCHIVE package \\citep{hvm04}. The profiles were cleaned\nof radio frequency interference (RFI) using the PSRCHIVE {\\tt paz} tool but\nalso examined and excised manually with the {\\tt pazi} tool. No standard\npolarization calibration using a pulsed and linearly polarized noise diode was\nperformed. However the EBPP automatically adjusts the power levels of both \npolarizations prior to each observation. The TOAs were calculated by\ncross-correlating the time-integrated,\nfrequency-scrunched, total intensity profile, with an analytic and noise free\ntemplate. This template was generated using the {\\tt paas} tool to fit a set\nof von Mises functions to a profile formed from high signal-to-noise ratio\n(S\/N) observations. In general, we used the standard `Fourier phase gradient'\nalgorithm \\citep{tay92} implemented in PSRCHIVE to estimate the TOAs and their\nuncertainties. We used a different template for each observing frequency,\nincluding different templates for the 1410 and 1360 MHz observations. Local\ntime is kept by the on-site H-maser clock, which is corrected to Coordinated\nUniversal Time (UTC) using recorded offsets between the maser and the Global\nPositioning System (GPS) satellites.\n\n\\subsection{Lovell Radio Telescope}\n\nAt Jodrell bank, the 76-m Lovell telescope is used in a regular monitoring\nprogram to observe most of the pulsars presented in this paper. All TOAs used\nhere were generated by using the DFB, a clone of the Parkes Digital FilterBank.\n Each pulsar was observed with a typical cadence\nof once every 10 days for 30 mins with a subintegration time of 10~s. The DFB\ncame into operation in January 2009 observing at a central frequency of 1400\nMHz with a BW of 128 MHz split into 512 channels. From September 2009, the center frequency was\nchanged to 1520 MHz and the BW increased to 512 MHz (split into 1024 channels) of which\napproximately 380 MHz was usable, depending on RFI conditions. As this is a\nsignificant change, and to account for possible profile evolution with\nobserving frequency, both setups are considered as distinct observing systems\nand different templates were used. \nData cleaning and TOA generation were done in a similar way to the\nEffelsberg data. There is no standard polarization calibration\n(through observations of a noise diode) applied\nto the DFB data. However the power levels of both polarizations are\nregularly and manually adjusted via a set of attenuators. Local time is kept by the on-site H-maser clock, which is\ncorrected to UTC using recorded offsets between\nthe maser and the GPS satellites.\n\n\\subsection{Nan\\c cay Radio Telescope}\n\\label{sec:obs_nrt}\nThe Nan\\c cay Radio Telescope is a meridian telescope with a collecting area\nequivalent to a 94-m dish. The moving focal carriage that allows an observing\ntime of about one hour per source hosts the Low Frequency (LF) and High\nFrequency (HF) receivers covering 1.1 to 1.8 GHz and 1.7 to 3.5 GHz, respectively.\n A large timing program of MSPs started in late 2004 with the commissioning of\nthe BON instrumentation, a member of the\nASP-GASP coherent dedispersion backend family \\citep{d07}. A 128~MHz BW\nis split into 32 channels by a CASPER\\footnote{https:\/\/casper.berkeley.edu}\nSerendip V board and then sent to servers to be coherently dedispersed and\nfolded to form 2-min subintegrations.\n\nFrom 2004 to 2008 the BW was limited to 64 MHz and then extended to 128~MHz.\n At the same time, the NRT started to regularly observe a pulsed noise\ndiode prior to each observation in order to properly correct for the\ndifference in gain and phase between the two polarizations. In August 2011, the\nL-Band central frequency of the BON backend shifted from 1.4 GHz to 1.6 GHz to\naccommodate the new wide-band NUPPI dedispersion backend \\citep{ldc+14}. Due to\nknown instrumental issues between November 2012 and April 2013\n(i.e. loss of one of the polarization channels, mirroring of the spectrum),\nthese data have not been included in the analysis.\n\nThe flux density values at 1.4 GHz reported in Table \\ref{tab:summary} are\nderived from observations recorded with the NUPPI instrument between MJD 55900\nand 56700. The quasar 3C48 was chosen to be the reference source for the\nabsolute flux calibration. These flux density values have been corrected for\nthe declination-dependent illumination of the mirrors of the NRT. \nAlthough the NUPPI timing data are not included in this work, we used these\nobservations to estimate the median flux densities as no other EPTA data were\nflux-calibrated. The NUPPI timing data will be part of a future EPTA\ndata release along with the data from other telescopes recorded with\nnew-generation instrumentations.\n\nThe data were reduced with the PSRCHIVE package and automatically cleaned\nfor RFI. Except for pulsars with short orbital periods, all daily observations\nare fully scrunched in time and frequency to form one single profile. For PSRs\nJ0610$-$2100, J0751$+$1807, J1738$+$0333, J1802$-$2124 the data were integrated\nto form 6, 12, 16\nand 8 min profiles respectively. The templates for the three observing\nfrequencies are constructed by phase-aligning the $\\sim$10\\% profiles with the\nbest S\/N. The resulting integrated profiles are made noise free with the same\nwavelet noise removal program as in \\citet{dfg+13}. As stated above, we used\nthe standard `Fourier phase gradient' from PSRCHIVE to estimate the TOAs and\ntheir uncertainties. However, we noticed that in the case of very low S\/N\nprofiles, the reported uncertainties were underestimated. \\citet{abb+15} also\nobserved that TOAs extracted from low S\/N profiles deviate from a Gaussian\ndistribution and therefore excluded all TOAs where S\/N <8 (see Appendix B of their paper\nfor more details). Here,\nwe made use of the Fourier domain Markov Chain Monte Carlo TOA estimator\n(hereafter FDM) to properly estimate the error bars in this low S\/N regime. We applied the FDM method\nto PSRs J0034$-$0534, J0218$+$4232, J1455$-$3330, J2019$+$2425, J2033$+$1734.\nAll the BON data are time-stamped with a GPS-disciplined clock.\n\nFor PSR J1939$+$2134, archival data from 1990 to 1999 recorded with a swept-frequency\n local oscillator (hereafter referred to as DDS) at a frequency of 1410\nMHz \\citep{cbl+95} were added to the dataset. These data are time-stamped with\nan on-site Rubidium clock, which is corrected to UTC using recorded offsets between\n the Rubidium clock and the Paris Observatory Universal Time.\n\n\\subsection{Westerbork Synthesis Radio Telescope}\n\nThe Westerbork Synthesis Radio Telescope is an East-West array\nconsisting of fourteen 25-m dishes, adding up to the equivalent size of a 94-m\ndish when combined as a tied-array. From 1999 to 2010, an increasing\n number of MSPs were observed once a\nmonth using the PuMa pulsar machine (a digital filterbank) at WSRT \\citep{vkh+02}. In each observing\nsession, the pulsars were observed for 25 minutes each at one or more\nfrequencies centered at 350 MHz (10 MHz BW), 840 MHz (80 MHz BW) and 1380 MHz\n(80 MHz spread across a total of 160 MHz BW). Up to 512 channels were used to\nsplit the BW for the observations at 350 MHz. At 840 MHz and 1380 MHz, 64 channels were used per 10 MHz subband. For a more detailed description of\nthis instrumentation, see e.g. \\citet{jsk+08}. Since 2007, the 840 MHz band was no longer used for\nregular timing observations, however, an additional observing frequency\ncentered at 2273 MHz using 160 MHz BW was used for a selected set of the\nobserved pulsars. The data were dedispersed and folded offline using custom\nsoftware, and then\nintegrated over frequency and time to obtain a single profile for each\nobservation. \nGain and phase difference between the two polarizations are adjusted during the phased-array calibration of the dishes.\nTo generate the TOAs, a high-S\/N template based on the observations was used\nfor each observing frequency separately.\n Local time is kept by the on-site H-maser\nclock, which is corrected to UTC using recorded\noffsets between the maser and the GPS satellites.\n\n\n\\section{Data combination and timing}\n\\label{sec:timing}\n\nThe topocentric TOAs recorded at each observatory are first converted to the\nSolar System barycenter (SSB) using the DE421 planetary ephemeris \\citep{fwb09} with\nreference to the latest Terrestrial Time standard from the Bureau International\ndes Poids et Mesures (BIPM) \\citep{pet10}. The DE421 model is a major\nimprovement on the DE200 ephemeris that was used for older\npublished ephemerides and later found to suffer from inaccurate values of planetary\nmasses \\citep{sns+05,hbo06,vbs+08}.\n\nWe used TempoNest \\citep{lah+14}, a Bayesian analysis software that uses the\nTempo2 pulsar timing package \\citep{hem06, ehm06} and MULTINEST \\citep{fhb09}, a\nBayesian inference tool, to evaluate and explore the parameter\nspace of the non-linear pulsar timing model. \nAll pulsar timing parameters are sampled in\nTempoNest with uniform priors. The timing model includes the\nastrometric (right ascension, $\\alpha$, declination, $\\delta$, proper motion in\n$\\alpha$ and $\\delta$, $\\mu_{\\alpha}$ and $\\mu_{\\delta}$) and rotational parameters (period $P$\nand period derivative $\\dot{P}$). If the pulsar is part of a binary system,\nfive additional parameters are incorporated to describe the Keplerian binary\nmotion: the orbital period $P_b$, the projected semi-major axis $x$ of the\npulsar orbit, the longitude of periastron $\\omega$, the epoch $T_0$ of the periastron\npassage and the eccentricity $e$. For some pulsars in our set, we require theory-independent PK parameters\n\\citep{dd85, dd86} to account for deviations from a Keplerian motion, or\nparameters to describe changes in the viewing geometry of the systems. The\nparameters we used include the precession of periastron\n$\\dot{\\omega}$, the orbital period derivative $\\dot{P_b}$, the Shapiro delay\n(`range' $r$ and `shape' $s$; $s$ has a uniform prior in $\\cos i$ space) and the apparent\nderivative of the projected semi-major axis $\\dot{x}$. These parameters are implemented\nin Tempo2 under the `DD' binary model. In the case of quasi-circular orbits, the `ELL1'\nmodel is preferred and replaces $\\omega$, $T_0$ and $e$ with the two\nLaplace-Lagrange parameters $\\kappa$ and $\\eta$ and the time of ascending node\n$T_{\\text{asc}}$ \\citep{lcw+01}. For the description of the Shapiro delay in PSRs\nJ0751$+$1807, J1600$-$3053 and J1918$-$0642 we adopted the orthometric\nparametrization of the Shapiro delay introduced by \\citet{fw10} with the\namplitude of the third harmonic of the Shapiro delay $h_3$ and the ratio of\nsuccessives harmonics $\\varsigma$.\n \nTo combine the TOAs coming from the different observing systems described in\nSection~\\ref{sec:obs}, we first corrected them for the phase difference between\nthe templates by cross-correlation of the reference template with the\nother templates. We then fit for the arbitrary time offsets, known as JUMPs, between\nthe reference observing system and the remaining systems. These\nJUMPs encompass, among other things: the difference in instrumental delays,\nthe use of different templates and the choice for the fiducial point on the\ntemplate. The JUMPs are analytically marginalized over during the\nTempoNest Bayesian analysis. In\norder to properly weight the TOAs from each system, the\ntiming model includes a further two {\\it ad~hoc} white noise parameters per observing\nsystem. These parameters known as the error factor `EFAC', $E_f$, and the error\nadded in quadrature `EQUAD', $E_q$ (in units of seconds), relate to a TOA with uncertainty\n$\\sigma_p$ in seconds as:\n\\begin{equation}\n\\sigma = \\sqrt{E_q^2 + E_f^2 {\\sigma_p}^2}.\n\\end{equation}\nNote that this definition of EFAC and EQUAD in TempoNest is different from the\ndefinition employed in Tempo2 and the earlier timing software Tempo, where\n$E_q$ was added in quadrature to $\\sigma_p$ before applying $E_f$. The $E_f$\nand $E_q$ parameters are set with\nuniform {priors in the \nlogarithmic space (log-uniform priors)} in the $\\log_{10}$-range $[-0.5,1.5], [-10, -3]$, respectively.\nThese prior ranges are chosen to be wide enough to include any value of EFAC\nand EQUAD seen in our dataset.\n\nEach pulsar timing model also includes two stochastic models to describe the\nDM variations and an additional {achromatic} red noise process.\n{Both processes are modeled as stationary, stochastic signals with \na power-law spectrum of the form $S(f)\\propto{}A^2f^{-\\gamma}$,\nwhere $S(f)$, $A$, and $\\gamma$ are the power spectral density as function of\nfrequency $f$, the\namplitude and \nthe spectral index, respectively. The power laws \nhave a cutoff frequency at the lowest frequency, equal to the inverse of the data span, \nwhich is mathematically necessary for the subsequent calculation of the\ncovariance matrix \\citep{hlm+09}.\nIt has been shown that this cutoff rises naturally for the achromatic red noise power law in pulsar timing data\nbecause any low-frequency signal's power below the cutoff frequency is absorbed by the fitting of the pulsar's \nrotational frequency and frequency derivative \\citep{hlm+09,lbj+12}. \nIt is possible to do the same for the DM variations model, by fitting a first\nand a second DM derivative (parameters DM1 and DM2)\nin the timing model \\citep{lbj+14}. \nImplementation of the models is made using the time-frequency method of\n\\citet{lah+13}. \nDetails on this process and applications can be found in \\citet{ltm+15} and \\citet{cll+15}.\nIn brief, denoting matrices with boldface letters, the red noise process \ntime-domain signal, is expressed as a Fourier series,\n${\\rm \\bf t}_{\\rm TN}=\\mathbfss{F}_{\\rm TN}\\textrm{{\\bf a}}$, where $\\mathbfss{F}_{\\rm TN}$ \nis the sum of sines and cosines with coefficients given by the matrix $\\textrm{{\\bf a}}$. \nFourier frequencies are sampled with integer multiples of the lowest frequency, \nand are sampled up to $1\/14$\\,days$^{-1}$. The \nFourier coefficients are free parameters.} \n\n{The DM variations component \nis modeled similarly, with the only difference being that the time-domain signal \nis dependent on the observing frequency. According to the \ndispersion law from interstellar plasma, the delay in the arrival time \nof the pulse depends on the inverse square of the \nobserving frequency, see e.g. \\citet{lg12}. As such, the Fourier \ntransform components are \n${\\mathbfss{F}^{DM}_{ij}={\\mathbfss{F}_{ij}}D_{i} D_{j}}$, \nwhere the i,j indices denote the residual index number, $D_i=1\/(k\\nu^2_i)$, \nand $k=2.41\\times 10^{-16}$~Hz$^{-2}$cm$^{-3}$pc~s$^{-1}$, is the dispersion constant. \nThis stochastic DM variations component is additional to the deterministic \nlinear and quadratic components\nimplemented as part of the Tempo2 timing model.} \nIn addition, we used the standard electron density model for the solar wind\nincluded in Tempo2 with a value of 4~cm$^{-3}$ at 1 AU. This solar wind model\ncan be covariant with the measured astrometric parameters of the pulsar.\n\n{The covariance matrix of each of these two components \nis then calculated with a function of the form \\citep{ltm+15}:\n\\begin{equation}\n\\label{eq:BayesCovRed}\n{\\bf C} = {\\bf C^{-1}_{\\textrm{w}}} - {\\bf \nC^{-1}_{\\textrm{w}}}\\mathbfss{F} \\left[(\\mathbfss{F})^{\\textrm{{\\bf T}}}{\\bf \nC^{-1}_{\\textrm{w}}}\\mathbfss{F} + (\\Psi)^{-1}\\right]^{-1} (\\mathbfss{F})^{\\textrm{{\\bf T}}}{\\bf C^{-1}_{\\textrm{w}}} .\n\\end{equation}\nThe equation is valid for both the DM variations and achromatic \nred noise process, by using the corresponding Fourier transform \n$\\mathbfss{F}$ and covariance matrix of the Fourier coefficients $\\Psi=\\langle\n\\textrm{a}_i\\textrm{a}_j\\rangle$. \nThe ${\\bf C_{\\textrm{w}}}$ term is the white noise covariance matrix \nand is a diagonal matrix \nwith the main diagonal formed by the residual uncertainties squared. \nThe superscript ${\\textrm{{\\bf T}}}$ denotes the transpose of the matrix.}\n\n{The power-law parameterization of the DM variations and red noise \nspectra means that the parameters we need to sample are \nthe amplitudes and spectral indices of the power law. We do so by using \nuniform priors in the range $[0,7]$ for the spectral index and\nlog-uniform priors for the amplitudes, in the $\\log_{10}$-range $[-20,-8]$. \nFor discussion on the impact of our prior type selection, \nsee \\citet{lah+14} and \\citet{cll+15}.\nHere, we have used the least informative priors on the noise parameters. \nThis means that the Bayesian inference will assign equal probability to \nthese parameters if the data are insufficient to break the degeneracy between\nthem. This \napproach is adequate to derive a total noise covariance matrix (addition of \nwhite noise, red noise and DM variations covariance matrices) that allows \nrobust estimation of the timing parameters. \nThe prior ranges are set\nto be wide enough to encompass any DM or red noise signal seen in the data. The\nlower bound on the spectral index of the red noise process is set to zero as we\nassume there is no blue process in the data. Together with the EFAC and EQUAD\nvalues, the DM and red noise spectral indices and amplitudes are used by the timing \nsoftware to form the timing residuals.}\n\n \n\n\\subsection{Criterion for Shapiro delay detectability}\n\\label{sec:criteria}\nTo assess the potential detectability of Shapiro delay, we used the following\ncriterion. With the orthometric parametrization of Shapiro delay, we can compute the\n amplitude $h_3$ (in seconds) in the timing residuals \\citep{fw10},\n\\begin{equation}\nh_3 = \\left( \\frac{\\sin i}{1+\\cos i} \\right)^3 m_c T_\\odot.\n\\end{equation}\nHere, $c$ is the speed of light, $ T_\\odot = 4.925~490~947$ $\\mu$s is the mass\nof the Sun in units of time. By assuming a median companion mass, $m_c$, given\nby the mass function with $m_p=1.35$ M$_\\odot$ and an inclination angle\n$i=60^\\circ$, we can predict an observable $h_{3o}$. We can then compare this\n$h_{3o}$ value to the expected precision given by $\\xi = \\delta_{\\text{TOAs}}\n{\\text{N}_{\\text{TOAs}}}^{-1\/2}$ where $ \\delta_{\\text{TOAs}}$ is the median\nuncertainty of the TOAs and ${\\text{N}_{\\text{TOAs}}}$ the number of TOAs in\nthe dataset. The criterion $h_{3o} \\gtrsim \\xi$ associated with a non detection\nof Shapiro delay would likely mean an unfavorable inclination angle, i.e. $i\n\\lesssim 60^\\circ$.\n\n \n\n\\input{paper-results}\n\n\\input{paper-discussion}\n\n\\input{paper-conclusion}\n\n\n\\section*{Acknowledgments}\nThe authors would like to thank D.~Schnitzeler for providing us with the M2 and M3\ndistances used in this work, P.~Freire, M.~Bailes, T.~Tauris and N.~Wex for\nuseful discussions, P.~Demorest for his contribution to the pulsar\ninstrumentation at the NRT.\n\nPart of this work is based on observations with the 100-m telescope of the\nMax-Planck-Institut f\\\"ur Radioastronomie (MPIfR) at Effelsberg in Germany. Pulsar\nresearch at the Jodrell Bank Centre for Astrophysics and the observations using\nthe Lovell Telescope are supported by a consolidated grant from the STFC in the\nUK. The Nan{\\c c}ay radio observatory is operated by the Paris Observatory,\nassociated to the French Centre National de la Recherche Scientifique (CNRS).\nWe acknowledge financial support from `Programme National de Cosmologie et\nGalaxies' (PNCG) of CNRS\/INSU, France. The Westerbork Synthesis Radio Telescope\nis operated by the Netherlands Institute for Radio Astronomy (ASTRON) with\nsupport from the Netherlands Foundation for Scientific Research (NWO).\n\nCGB, GHJ, RK, KL, KJL, DP acknowledge the support from the `LEAP' ERC Advanced\nGrant (337062).\nRNC acknowledges the support of the International Max Planck Research School\nBonn\/Cologne and the Bonn-Cologne Graduate School.\nJG and AS are supported by the Royal Society.\nJWTH acknowledges funding from an NWO Vidi fellowship and CGB, JWTH acknowledge\nthe support from the ERC Starting Grant `DRAGNET' (337062).\nKJL is supported by the National Natural Science Foundation of China (Grant No.11373011).\nPL acknowledges the support of the International Max Planck Research School Bonn\/Cologne.\nCMFM was supported by a Marie Curie International Outgoing Fellowship within\nthe 7th European Community Framework Programme.\nSO is supported by the Alexander von Humboldt Foundation.\nThis research was in part supported by ST's appointment to the NASA\nPostdoctoral Program at the Jet Propulsion Laboratory, administered by Oak\nRidge Associated Universities through a contract with NASA.\nRvH is supported by NASA Einstein Fellowship grant PF3-140116.\n\nThe authors acknowledge the use of the Hydra and Hercules computing cluster from\nRechenzentrum Garching. This research has made extensive use of NASA's Astrophysics Data\nSystem, the ATNF Pulsar Catalogue and the Python Uncertainties package,\nhttp:\/\/pythonhosted.org\/uncertainties\/.\n\n\n\n\\bibliographystyle{mnras}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","meta":{"redpajama_set_name":"RedPajamaArXiv"}} +{"text":"\\section{Introduction}\n\nLight can exist in a chiral state, and this property makes it possible to study chiral objects, such as molecules and nanostructures, in an optical manner.\\cite{tang2011enhanced,zhao2016enantioselective,gorkunov2017enhanced,govorov2010theory,govorov2011plasmon,amabilino2009chirality} Optical detection of chirality is important in a myriad of scientific fields, with key applications in molecular biology and pharmacology.\\cite{behr2008lock,denmark2006topics,tverdislov2017periodic,kasprzyk2010pharmacologically} In common applications, the specimen is illuminated sequentially with right-handed and left-handed circularly polarized light (RCP and LCP), and the chiral information is inferred from the differential response of the material. The chiral state of circularly polarized light is well understood, which facilitates the analysis of such measurements. However, performing similar measurements at the nanoscale can be challenging~\\cite{ho2017enhancing,hanifeh2020helicity,hanifeh2020helicitymax}, because the chiral state of light in the near zone, close to a nano-object, is generally unknown and cannot be directly assessed experimentally. Without experimental tools for extracting information about the chirality of the electromagnetic field, optical examination of chirality at the nanoscale is severely complicated. \n\nThe chiral state of light is related to the curled character of the electric and magnetic fields. The \nquantity commonly used for quantifying this `degree of curliness' is the time-averaged helicity density \\cite{bliokh2013dual,cameron2012optical}, which is defined as {$h=\\frac{1}{2\\omega c}$}\\rm{Im}($\\mathbf{E}\\cdot\\mathbf{H^{\\ast}}$), where $\\mathbf{E}$ and $\\mathbf{H}$ are the phasor electric and magnetic field at angular frequency $\\omega$, and $c$ is the speed of light ($^\\ast$ denotes complex conjugation) \\cite{trueba1996electromagnetic,hanifeh2020optimally}. The helicity density is a time-even, pseudo-scalar conserved quantity that corresponds to the difference between the numbers of RCP and LCP photons \\cite{bliokh2013dual,cameron2012optical,bliokh2011characterizing}. The flux of the helicity density, i.e. the chiral momentum density, is related to the spin angular momentum of the beam \\cite{bliokh2013dual,bliokh2011characterizing}. The latter quantity is a time-odd, pseudo-vector quantity \\cite{cameron2012optical} and its density is defined as ${\\boldsymbol\\sigma}=-\\frac{\\varepsilon_0}{4\\omega}$\\rm{Im}($\\mathbf{E}\\times\\mathbf{E^{\\ast}})-\\frac{\\mu_0}{4\\omega}$\\rm{Im}($\\mathbf{H}\\times\\mathbf{H^{\\ast}}$), where $\\varepsilon_0$ and $\\mu_0$ are the absolute permittivity and permeability of free space \\cite{cameron2012optical,barnett2010rotation}, respectively. Although both quantities describe angular momentum associated with the polarization state of light\\cite{bliokh2013dual}, only the time-averaged helicity density is classified as a conserved property of the electromagnetic field \\cite{tang2010optical,tang2011enhanced}, and, therefore, considered to be the proper descriptor of optical chirality.\n\nThe question arises whether a quantity like the helicity density can be properly measured at the nanoscale. Unlike quantities such as energy, mechanical force and torque carried or performed by the electromagnetic field, properties like linear and angular momentum of light are more difficult to measure and are commonly deduced from other measurable quantities \\cite{emile2018energy}. Helicity density of light falls into the latter category, and measuring it requires a connection to a quantity that can be experimentally assessed. One possibility is to detect helicity density through a photo-induced force. For instance, the technique of photo-induced force microscopy (PiFM) has been used to map electric and magnetic field distributions through the optical force exerted on a metallic tip \\cite{zeng2018sharply} or a specially designed magnetic nanoprobe \\cite{zeng2021photoinduced}. The photo-induced force has also been used for in sorting and trapping of chiral nanoparticles\\cite{hou2021separating,kamenetskii2021chirality,hayat2015lateral,tkachenko2014optofluidic,li2019optical}. In addition, PiFM has been employed to determine enantioselective chirality of nanosamples \\cite{kamandi2017enantiospecific}, and for measuring the geometric chirality of broken symmetry structures with differential force measurements under RCP\/LCP illumination\\cite{rajaei2019giant} .\n\nIn this work, we theoretically investigate the connection between the photo-induced forces felt by a chiral tip under differential RCP\/LCP illumination and the chiral state of light at the nanoscale. Using image dipole theory, we have found a direct relation between the measured differential force and the chiral properties of the incident electromagnetic field in terms of the time-averaged helicity density and spin-angular momentum density. We further model the chiral tip as an isotropic chiral sphere to examine several design considerations and validate our dipole model with full-wave, finite element method (FEM) simulations.\n\n\n\\section{Theoretical Analysis}\n\nWe are interested in detecting the mechanical force that acts on the tip due to the presence of the electromagnetic field. We can model the tip as particle and write the time-averaged force exerted on this particle as:\\cite{novotny2012principles, yang2016resonant}\n\\begin{equation}\\label{eq:Force_general}\n \\langle\\mathbf{F}\\rangle=\\frac{1}{2}\n\\mathrm{Re}\\Big\\{\\int\\limits_{\\mathit{S}}\n{[\\varepsilon(\\mathbf{E}\\cdot\\mathbf{n})\\mathbf{E}\n+\\mu^{-1}(\\mathbf{B}\\cdot\\mathbf{n})\\mathbf{B}\n-\\frac{1}{2}(\\varepsilon|\\mathbf{E}|^2+\\mu^{-1}|\\mathbf{B}|^2)\\mathbf{n}}]\n\\mathit{dS}\\Big\\}\n\\end{equation}\nwhere the integration is over the arbitrary surface $S$ that encloses the particle, $\\mathbf{n}$ is the unit vector normal to this surface, and $\\mathbf{E}$ and $\\mathbf{B}$ are the total electric field and magnetic flux density, which include both the incident light and the scattered light contributions. It is assumed that the particle is embedded in a non-dissipative medium with permittivity {$\\varepsilon$} and permeability $\\mu$. To simplify this expression, we next assume that the tip can be described as a dipolar particle with an electric and magnetic dipole moment in free space, written as $\\mathbf{p}_{tip}~[\\rm{Cm}]$ and $\\mathbf{m}_{tip}~[\\rm{Am}^2]$, respectively. Adopting the $e^{-i\\omega t}$ time convention for the time-harmonic field, the time-averaged electromagnetic force becomes \\cite{nieto2010optical}:\n\\begin{equation}\\label{eq:dipolar_force}\n\\begin{split}\n\\langle\\mathbf{F}\\rangle=\\frac{1}{2}\\mathrm{Re}\\Big\\{\n\\mathbf{p}_{tip}\\cdot\\big(\\nabla\\mathbf{E}^{loc}(\\mathbf{r}_{tip})\\big)^\\ast\n+\\mu_0\\mathbf{m}_{tip}\\cdot\\big(\\nabla\\mathbf{H}^{loc}(\\mathbf{r}_{tip})\\big)^\\ast \\\\\n-\\frac{c\\mu_0 k^4}{6\\pi}(\\mathbf{p}_{tip}\\times\\mathbf{m}^{\\ast}_{tip})\\Big\\}\n\\end{split}\n\\end{equation}\nwhere $\\mathbf{E}^{loc}(\\mathbf{r}_{tip})$ and $\\mathbf{H}^{loc}(\\mathbf{r}_{tip})$ are the local electric and magnetic field at the tip dipole position. The time-averaged force has three distinct contributions: the first term on the right hand side of equation (\\ref{eq:dipolar_force}) is recognized as the electric dipolar force $\\langle\\mathbf{F}_{e}\\rangle$, the second term is known as the magnetic dipolar force $\\langle\\mathbf{F}_{m}\\rangle$, and the last term is called the interaction force $\\langle\\mathbf{F}_{int}\\rangle$. \n\\begin{figure}[t]\n\\centering\n\\includegraphics[width=10cm]{Fig1.eps}\n\\caption{(a) Schematic of the PiFM system with a chiral with illumination from the bottom. (b) Photo-induced chiral tip dipole and image dipole according to image dipole theory. }\n\\label{fig:fig1}\n\\end{figure}\n\nTo calculate the force, we require expressions for the induced electric and magnetic dipole moments. Assuming that the tip is an isotropic and reciprocal chiral object, the dipole moments can be related to the local fields through polarizabilities as \\cite{A}:\n\\begin{align}\n \\mathbf{p}_{tip}&=\\alpha_{ee}\\mathbf{E}^{loc}(\\mathbf{r}_{tip})+\\alpha_{em}\\mathbf{H}^{loc}(\\mathbf{r}_{tip})\\label{eq:electric_dipole_tip}\\\\\n \\mathbf{m}_{tip}&=-\\mu^{-1}_0\\alpha_{em}\\mathbf{E}^{loc}(\\mathbf{r}_{tip})+\\alpha_{mm}\\mathbf{H}^{loc}(\\mathbf{r}_{tip})\\label{eq:magnetic_dipole_tip}\n\\end{align}\nwhere $\\alpha_{ee}$, $\\alpha_{mm}$ and $\\alpha_{em}$ are the electric, magnetic and electro-magnetic polarizabilities, respectively. The local fields at the tip dipole position can be obtained from image dipole theory \\cite{novotny2012principles, jackson2009classical,rajapaksa2010image}. We model the effect of the substrate by substituting the substrate response by the image of the photo-induced (chiral) dipole in the tip, written as $\\mathbf{p}_{img}$ and $\\mathbf{m}_{img}$ and shown in Figure \\ref{fig:fig1}(b). The local electric and magnetic fields at the tip position can then be expressed as:\n\\begin{align}\n \\mathbf{E}^{loc}(\\mathbf{r}_{tip})&=\\mathbf{E}^{inc}(\\mathbf{r}_{tip})+\\mathbf{E}^{sca}_{img\\rightarrow tip}(\\mathbf{r}_{tip})\\label{eq:E_loc}\\\\\n \\mathbf{H}^{loc}(\\mathbf{r}_{tip})&=\\mathbf{H}^{inc}(\\mathbf{r}_{tip})+\\mathbf{H}^{sca}_{img\\rightarrow tip}(\\mathbf{r}_{tip})\\label{eq:H_loc}\n\\end{align}\nwhere $\\mathbf{E}^{inc}(\\mathbf{r}_{tip})$, $\\mathbf{H}^{inc}(\\mathbf{r}_{tip})$ are the incident electric and magnetic field at the tip dipole location, and $\\mathbf{E}^{sca}_{img\\rightarrow tip}(\\mathbf{r}_{tip})$, $\\mathbf{H}^{sca}_{img\\rightarrow tip}(\\mathbf{r}_{tip})$ are the scattered electric and magnetic field by the image dipoles at the tip dipole location.\n\nThe scattered fields are defined through the image dipole moments and their Green's functions as: \\cite{novotny2012principles,jackson2009classical} \n\\begin{align}\n \\mathbf{E}^{sca}_{img\\rightarrow tip}(\\mathbf{r}_{tip})&=\\mathbf{\\underline{G}}^{ee}(\\mathbf{r}_{tip}-\\mathbf{r}_{img})\\cdot\\mathbf{p}_{img}+\\mathbf{\\underline{G}}^{em}(\\mathbf{r}_{tip}-\\mathbf{r}_{img})\\cdot\\mathbf{m}_{img}\\\\\n \\mathbf{H}^{sca}_{img\\rightarrow tip}(\\mathbf{r}_{tip})&=\\mathbf{\\underline{G}}^{me}(\\mathbf{r}_{tip}-\\mathbf{r}_{img})\\cdot\\mathbf{p}_{img}+\\mathbf{\\underline{G}}^{mm}(\\mathbf{r}_{tip}-\\mathbf{r}_{img})\\cdot\\mathbf{m}_{img}\n\\end{align}\nwhere $\\mathbf{\\underline{G}}(\\mathbf{r})=G_x\\mathbf{\\hat{x}\\hat{x}}+G_y\\mathbf{\\hat{y}\\hat{y}}+G_z\\mathbf{\\hat{z}\\hat{z}}$ is the dyadic Green's function in Cartesian coordinates and the four different electric [$\\mathbf{\\underline{G}}^{ee}(\\mathbf{r})$, $\\mathbf{\\underline{G}}^{em}(\\mathbf{r})$] and magnetic [$\\mathbf{\\underline{G}}^{me}(\\mathbf{r})$, $\\mathbf{\\underline{G}}^{mm}(\\mathbf{r})$] dyadic Green's functions for an electric and magnetic dipole are defined as:\n\\cite{campione2013effective} \n\\begin{align}\n \\mathbf{\\underline{G}}^{ee}(\\mathbf{r})&=\\frac{1}{4\\pi\\varepsilon_0|\\mathbf{r}|^{3}}(3\\mathbf{\\hat{r}}\\mathbf{\\hat{r}}-\\mathbf{\\underline{I}})\\\\\n \\mathbf{\\underline{G}}^{mm}(\\mathbf{r})&=\\frac{1}{4\\pi|\\mathbf{r}|^{3}}(3\\mathbf{\\hat{r}}\\mathbf{\\hat{r}}-\\mathbf{\\underline{I}})\\\\\n \\mathbf{\\underline{G}}^{em}(\\mathbf{r})&=-\\frac{1}{i\\omega\\varepsilon_0}\\nabla\\times\\mathbf{\\underline{G}}^{mm}(\\mathbf{r})\\\\\n \\mathbf{\\underline{G}}^{me}(\\mathbf{r})&=\\frac{1}{i\\omega\\mu_0}\\nabla\\times\\mathbf{\\underline{G}}^{ee}(\\mathbf{r})\n\\end{align}\nHere $\\mathbf{\\underline{I}}$ is a unit tensor of rank 2 and $\\mathbf{\\hat{r}}$ is the unit vector from the source point to the point of observation.\n\nIn the same fashion, we can also define the image dipole moments and the local fields at the image location. Our goal is to obtain self-consistent expressions for the local fields at tip location and for the dipole moments at the time in terms of the incident light components. To achieve this, we first ignore any phase retardation effects in the fields between the tip and image dipole position. Second, we will only consider terms in the polarizability up to second order. With these assumptions, we may use equations (\\ref{eq:electric_dipole_tip})-(\\ref{eq:H_loc}) to determine the longitudinal ($z$) component of the time-averaged force in the dipole approximation as:\n\\begin{equation}\n\\begin{split}\n\\langle{F_{z,e}}\\rangle+\\langle{F_{z,m}}\\rangle=~&\\frac{3}{2\\pi|\\mathit{z}|^4}\\Bigg[\\frac{1}{2}\\Big(\\frac{|\\alpha_{ee}|^2}{\\varepsilon_0}+\\mu_0|\\mu^{-1}_0\\alpha_{em}|^2\\Big)\\Big(\\frac{1}{2}|\\mathbf{E}^{inc}_\\parallel|^2-|\\mathbf{E}^{inc}_z|^2\\Big)\\\\\n&+\\frac{1}{2}\\Big(\\frac{|\\alpha_{em}|^2}{\\varepsilon_0}+\\mu_0|\\alpha_{mm}|^2\\Big)\\Big(\\frac{1}{2}|\\mathbf{H}^{inc}_\\parallel|^2-|\\mathbf{H}^{inc}_z|^2\\Big)\\\\\n&+\\mathrm{Re}\\Big\\{\\frac{\\alpha_{ee}\\alpha^{\\ast}_{em}}{\\varepsilon_0}-\\alpha_{mm}\\alpha^{\\ast}_{em}\\Big\\}\n\\mathrm{Re}\\Big\\{\\frac{1}{2}\\mathbf{E}^{inc}_{\\parallel}\\cdot\\mathbf{H}^{inc\\ast}_{\\parallel}-\\mathbf{E}^{inc}_{z}\\cdot\\mathbf{H}^{inc\\ast}_{z}\\Big\\}\\\\\n&-\\mathrm{Im}\\Big\\{\\frac{\\alpha_{ee}\\alpha^{\\ast}_{em}}{\\varepsilon_0}-\\alpha_{mm}\\alpha^{\\ast}_{em}\\Big\\}\n\\mathrm{Im}\\Big\\{\\frac{1}{2}\\mathbf{E}^{inc}_{\\parallel}\\cdot\\mathbf{H}^{inc\\ast}_{\\parallel}-\\mathbf{E}^{inc}_{z}\\cdot\\mathbf{H}^{inc\\ast}_{z}\\Big\\}\\Bigg]\n\\end{split}\n\\label{eq:force_em}\n\\end{equation}\n\n\\begin{equation}\n\\begin{split}\n\\langle{F_{z,int}}\\rangle=~&-\\frac{ck^{4}}{12\\pi}\\Bigg[\\mathrm{Re}\\Big\\{-\\alpha^{\\ast}_{em}\\alpha_{ee}\\Big\\}\\mathrm{Re}\\Big\\{[\\mathbf{E}^{inc}_{\\parallel}\\times\\mathbf{E}^{inc\\ast}_{\\parallel}]_{z}\\Big\\}\\\\\n&+\\mathrm{Re}\\Big\\{\\mu_0\\alpha^{\\ast}_{mm}\\alpha_{em}\\Big\\}\\mathrm{Re}\\Big\\{[\\mathbf{H}^{inc}_{\\parallel}\\times\\mathbf{H}^{inc\\ast}_{\\parallel}]_{z}\\Big\\}\\\\\n&+4\\omega\\mathrm{Im}\\Big\\{-\\frac{\\alpha^{\\ast}_{em}\\alpha_{ee}}{\\varepsilon_0}\\Big\\}[\\boldsymbol{\\sigma}^{inc}_{E}]_{z}+4\\omega\\mathrm{Im}\\Big\\{-\\alpha^{\\ast}_{mm}\\alpha_{em}\\Big\\}[\\boldsymbol{\\sigma}^{inc}_{H}]_{z}\\\\\n&+\\mathrm{Re}\\Big\\{\\alpha^{\\ast}_{em}\\alpha_{em}[\\mathbf{S}^{inc\\ast}]_{z}\\Big\\}+\\mathrm{Re}\\Big\\{\\mu_o\\alpha^{\\ast}_{mm}\\alpha_{ee}[\\mathbf{S}^{inc}]_{z}\\Big\\}\\Bigg]\n\\end{split}\n\\label{eq:force_int}\n\\end{equation}\nwhere $\\mathbf{E}^{inc}_{\\parallel}=\\mathit{E}^{inc}_x\\mathbf{\\hat{x}}+\\mathit{E}^{inc}_y\\mathbf{\\hat{y}}$,~$\\mathbf{H}^{inc}_{\\parallel}=\\mathit{H}^{inc}_x\\mathbf{\\hat{x}}+\\mathit{H}^{inc}_y\\mathbf{\\hat{y}}$ and $\\mathbf{E}^{inc}_{z}=\\mathit{E}^{inc}_z\\mathbf{\\hat{z}}$, $\\mathbf{H}^{inc}_{z}=\\mathit{H}^{inc}_z\\mathbf{\\hat{z}}$ are the transverse and longitudinal components of the incident fields at the tip dipole location, the notation $(\\mathbf{r}_{tip})$ has been avoided here for brevity; $\\mathbf{S}^{inc}=\\mathbf{E}^{inc}\\times\\mathbf{H}^{inc\\ast}$ is the time-averaged Poynting vector of the incident field; $\\boldsymbol{\\sigma}^{inc}_{E}$ and $\\boldsymbol{\\sigma}^{inc}_{H}$ are the electric and magnetic parts of the time-averaged total spin angular momentum density of the incident light; and $z$ is the vertical distance between the tip dipole and its image. See the Supporting Information for a detailed derivation of equations (\\ref{eq:force_em}) and (\\ref{eq:force_int}).\n\nEquation (\\ref{eq:force_em}) describes the force due to the combined electric and magnetic dipolar response of the tip. This force shows a distance dependence on the tip-sample distance which scales as $\\mathit{z}^{-4}$, similar to the distance dependence of the gradient force that is typically measured in PiFM \\cite{novotny2012principles,jahng2014gradient}. The first two lines of equation (\\ref{eq:force_em}) are recognized as the purely electric and purely magnetic dipolar force contributions to the gradient force, whereas the latter two lines describe the forces that arise from a nonzero scalar product of the electric and magnetic fields, i.e. the helicity density.\n\nEquation (\\ref{eq:force_int}) accounts for the interaction force, which lacks a direct dependence on the tip-sample distance. This contribution to the force resembles the scattering force \\cite{novotny2012principles,jahng2014gradient}. In addition to the purely electric and magnetic contributions to the scattering force, described by the first two lines in equation (\\ref{eq:force_int}), the latter two lines add force contributions that scale with the longitudinal component the spin angular momentum density and with the time-averaged Poynting vector. \n\nWe are interested in finding an expression for the differential force, i.e the force difference between sequential measurements where the tip-sample junction is illuminated with incident light of opposite handedness. For this purpose, we assume two states for the incident light, indicated by $\\mathbf{E}^{inc+}$, $\\mathbf{H}^{inc+}$ and $\\mathbf{E}^{inc-}$, $\\mathbf{H}^{inc-}$, describing the input fields of different handedness. The two illumination states have the same energy densities, $|\\mathbf{E}^{inc+}|^2=|\\mathbf{E}^{inc-}|^2$ and $|\\mathbf{H}^{inc+}|^2=|\\mathbf{H}^{inc-}|^2$, but exhibit opposite helicity densities, $\\mathrm{Im}(\\mathbf{E}^{inc+}\\cdot\\mathbf{H}^{inc+\\ast})=-\\mathrm{Im}(\\mathbf{E}^{inc-}\\cdot\\mathbf{H}^{inc-\\ast})$. Note that the longitudinal spin angular momentum density components are related as $[\\boldsymbol{\\sigma}^{inc+}_{E}]_z=-[\\boldsymbol{\\sigma}^{inc-}_{E}]_z$ and $[\\boldsymbol{\\sigma}^{inc+}_{H}]_z=-[\\boldsymbol{\\sigma}^{inc-}_{H}]_z$. We also find that $\\mathbf{S}^{inc+}=\\mathbf{S}^{inc-}$, and that the following relations hold:\n\\begin{equation}\n \\begin{split}\n \\mathrm{Re}\\Big\\{[\\mathbf{E}^{inc+}_{\\parallel}\\times\\mathbf{E}^{inc+\\ast}_{\\parallel}]_{z}\\Big\\}&=\\mathrm{Re}\\Big\\{[\\mathbf{E}^{inc-}_{\\parallel}\\times\\mathbf{E}^{inc-\\ast}_{\\parallel}]_{z}\\Big\\}\\\\\n \\mathrm{Re}\\Big\\{[\\mathbf{H}^{inc+}_{\\parallel}\\times\\mathbf{H}^{inc+\\ast}_{\\parallel}]_{z}\\Big\\}&=\\mathrm{Re}\\Big\\{[\\mathbf{H}^{inc-}_{\\parallel}\\times\\mathbf{H}^{inc-\\ast}_{\\parallel}]_{z}\\Big\\}\n \\end{split}\n\\end{equation}\nBy measuring the force under illumination with incident light of $(+)$ and $(-)$ handedness, and taking the difference, the differential gradient force $\\Delta\\langle{F_{z,grad}}\\rangle$ and the differential scattering force $\\Delta\\langle{F_{z,scat}}\\rangle$ can be obtained from equations (\\ref{eq:force_em}) and (\\ref{eq:force_int}) as:\n\\begin{align}\n\\Delta\\langle{F_{z,grad}}\\rangle&=-\\frac{6\\omega c}{\\pi|\\mathit{z}|^4}\n\\mathrm{Im}\\Big\\{\\frac{\\alpha_{ee}\\alpha^{\\ast}_{em}}{\\varepsilon_o}-\\alpha_{mm}\\alpha^{\\ast}_{em}\\Big\\}\n\\Big(\\frac{1}{2}\\mathit{h}^{inc}_{\\parallel}-\\mathit{h}^{inc}_{z}\\Big)\\label{eq:force_grad}\\\\\n\\Delta\\langle{F_{z,scat}}\\rangle&=-\\frac{2\\omega ck^4}{3\\pi}\\Big[\n\\mathrm{Im}\\Big\\{-\\frac{\\alpha^{\\ast}_{em}\\alpha_{ee}}{\\varepsilon_o}\\Big\\}[\\boldsymbol{\\sigma}^{inc}_{E}]_{z}+\\mathrm{Im}\\Big\\{-\\alpha^{\\ast}_{mm}\\alpha_{em}\\Big\\}[\\boldsymbol{\\sigma}^{inc}_{H}]_{z}\\Big]\n\\label{eq:force_scat}\n\\end{align} \nwhere $\\mathit{h}^{inc}_{\\parallel}=\\frac{1}{2\\omega c}\\mathrm{Im}\\left\\{\\mathbf{E}^{inc}_{\\parallel}\\cdot\\mathbf{H}^{inc\\ast}_{\\parallel}\\right\\}$ and $\\mathit{h}^{inc}_{z}=\\frac{1}{2\\omega c}\\mathrm{Im}\\left\\{\\mathbf{E}^{inc}_{z}\\cdot\\mathbf{H}^{inc\\ast}_{z}\\right\\}$ are the tangential and longitudinal helicity density of the incident chiral light. We see that the differential gradient force depends on the helicity density of the incident beam, whereas the differential scattering force contains qualitative information about the spin angular momentum. For small tip-sample distances, the differential gradient force is expected to form the dominant contribution to the measured force, thus offering a means of experimentally extracting information about the helicity density. Note that the differential force in equation (\\ref{eq:force_grad}) depends on the difference between the helicity density of the transverse and longitudinal components of the incident field. \n\n\n\\section{Mie Scattering Formalism}\n\nWe next study the characteristics of the differential gradient force. We see from equation (\\ref{eq:force_grad}) that $\\Delta\\langle{F_{z,grad}}\\rangle$ depends on the polarizability of the tip material, including the electro-magnetic polarizability. To model the tip polarizability, we assume that the tip can be described as a spherical chiral nanoparticle (NP). We also assume that the following constitutive relations hold: $\\mathbf{D}=\\varepsilon_o\\varepsilon\\mathbf{E}+i\\sqrt{\\varepsilon_0\\mu_0}\\kappa\\mathbf{H}$ and $\\mathbf{B}=\\mu_0\\mu\\mathbf{H}-i\\sqrt{\\varepsilon_0\\mu_0}\\kappa\\mathbf{E}$, where $\\varepsilon$ and $\\mu$ are the relative permittivity and permeability, respectively.\\cite{A} The chirality parameter $\\kappa$ is an empirical quantity that provides the chiral strength of the material under consideration. We can next relate the electric, magnetic and electro-magnetic polarizabilities through the material parameters by using Mie scattering theory as:\\cite{kamandi2017enantiospecific,bohren2012univ,hanifeh2020optimally} $\\alpha_{ee}=-{6\\pi i \\varepsilon_0 b_1}\/{k^3_0}$, $\\alpha_{mm}=-{6\\pi i a_1}\/{k^3_0}$ and $\\alpha_{em}={6\\pi i c_1}\/{(c k^3_0)}$ where $c$ is the free space speed of light, $k_0$ is the wavenumber in free space and $b_1$, $a_1$, $c_1$ are the Mie coefficients. In our calculations, the material parameters of the isotropic chiral NP such as $\\varepsilon$ and $\\mu$ are those of silicon\\cite{aspnes1983dielectric} with $\\mu=1$.\n\n\\begin{figure}[t]\n\\centering\n\\includegraphics[width=6cm]{Fig2.eps}\n\\caption{(a) The total difference force spectrum in pN. (b) The normalized magnitude spectrum of $\\alpha_{ee}-\\varepsilon_0\\alpha_{mm}$. In all calculations, the tip-image dipole distance is $|z|=10~\\rm{nm}$. Black lines indicate resonance condition of $c_1$ and white lines indicate minima due to satisfying the Kerker condition. }\n\\label{fig:fig2}\n\\end{figure}\n\nWe next place the sphere above a flat and transparent dielectric surface at a tip-surface distance of 5~nm. The system is subsequently illuminated with a plane wave of field strength $1.5\\times10^6 ~\\rm{Vm}^{-1}$ that is either in the RCP or LCP state, and which propagates through the transparent dielectric material toward the sphere. The wave induces a polarization in the sphere, which in turn produces an image dipole in the dielectric material. For simplicity, it is assumed that the image dipole strength is identical to the induced dipole in the sphere. In the current configuration, the image dipole is found at a distance $z=10~\\rm{nm}$ from the outer diameter of the sphere. We calculate the total difference force spectrum with the aid of equations (\\ref{eq:force_grad}) and (\\ref{eq:force_scat}), defined as $\\Delta\\langle{F_{z,total}}\\rangle=\\Delta\\langle{F_{z,grad}}\\rangle+\\Delta\\langle{F_{z,scat}}\\rangle$, and plotted in \\ref{fig:fig2}(a) as a function of sphere radius and excitation wavelength. In all calculations, the value of $\\kappa$ is set to 0.1.\\cite{ali2020enantioselective,ali2020probing} It is clear that nonzero $\\Delta\\langle{F_{z,total}}\\rangle$ is achieved under certain experimental conditions. In particular, the maxima and minima are seen to co-localize with the resonant spectral position of the electro-magnetic Mie coefficient $c_1$ of the chiral NP. The black dotted lines show the location of the peak values of $\\mathrm{Im}(c_1)$. Changing $\\kappa$ does not alter the spectral resonances, but instead changes the sign and magnitude of the total differential force proportionally. \n\nA careful inspection of equation \\ref{eq:force_grad} suggests that, for any chosen $r$ and $\\kappa$ of the tip, $\\Delta\\langle{F_{z,total}}\\rangle$ may approach zero when the first Kerker condition of the chiral NP is met, irrespective of helicity density of the incident light. The Kerker condition states that $\\alpha_{ee}=\\varepsilon_0\\alpha_{mm}$~\\cite{kerker1983electromagnetic,lee2017reexamination,hanifeh2020helicity}, and this condition is plotted in Figure \\ref{fig:fig2}(b) as a function of radius and excitation wavelength, while $\\kappa$ is fixed at $0.1$. The white dotted lines depict the conditions where the relation $\\alpha_{ee}=\\varepsilon_0\\alpha_{mm}$ is satisfied whereas the black dotted lines show the resonant position of electro-magnetic Mie coefficient $c_1$ as found in panel (a). The finite separation between the two curves assures that the above relation is less likely to have any impact on helicity density measurements if the force difference measurement is properly maximized. \n\n\\section{Full Wave Simulations}\nTo further validate our analytical findings, we perform 3D full wave simulations to determine the forces between the dipole induced in the chiral sphere and its image in the dielectric material below. We use the finite element method in COMSOL Multiphysics for this purpose. In the simulation, the tip and image dipoles are modeled as isotropic chiral spheres \\cite{yang2016resonant, nieto2004near,PhysRevLett.99.127401} with similar parameters as used above in Figure \\ref{fig:fig2}(a). The system is sequentially illuminated by RCP and LCP plane waves of field strength $1.5\\times10^6~\\rm{Vm}^{-1}$ in the bottom illumination scheme. The force exerted on the tip is determined using Maxwell's stress tensor formalism. \n\nFigures \\ref{fig:fig3}(b), (c) and (d) show the time averaged-force difference spectrum for spheres of radius of 50~nm, 60~nm and 70~nm. The black curve shows the analytical result whereas the full wave FEM result is indicated by the green solid line. For $r=50~\\rm{nm}$, the FEM simulation closely corroborates the analytical result obtained in the dipole approximation, where the dip corresponds to the Mie resonance of the $c_1$ coefficient. The spectra of Figure \\ref{fig:fig4}(c) and (d) display some dissimilarities between the FEM and analytical calculations, which can be attributed to higher order multipole contributions in the lower wavelength range. Yet, in the range examined the dipolar contribution remains dominant and provides a maximum force difference value $-0.32~\\rm{pN}$ for a tip radius of $r_{NP}=70~\\rm{nm}$ when $\\kappa=0.1$. Near resonance, the differential force is of the order of 0.1 pN. Although such forces are near the noise floor of a typical PiFM microscope, sensitive experiments are likely able to resolve the targeted differental force under optimized conditions.\n\n\\begin{figure}[t]\n\\centering\n\\includegraphics[width=10cm]{Fig3.eps}\n\\caption{(a) Schematic of chiral tip sphere and image sphere with radius $r_{NP}$ and tip-image dipole distance of $|z|=10~\\rm{nm}$ used in FEM simulation. Time-averaged differential force from analytical calculation (black solid curve) and from full wave simulation (green solid curve) for a chiral NP with radius (b) $r_{NP}=50~\\rm{nm}$, (c) $r_{NP}=60~\\rm{nm}$, (d) $r_{NP}=70~\\rm{nm}$ and $\\kappa=0.1$ under RCP\/LCP illumination. }\n\\label{fig:fig3}\n\\end{figure}\n\nFinally, we present the differential force map of the helicity density for a focused chiral beam, a scenario of direct relevance to microscopy applications. We assume a circularly polarized beam of $2~\\rm{mW}$ average power at a wavelength of $\\lambda=520\\rm{nm}$ as the incident light source, which is focused by a 1.4 NA oil~($n=1.518$) objective lens. The focal plane electric and magnetic field field components used in the simulation are obtained from \\cite{novotny2012principles}. We first calculate the normalized helicity density distribution at the focal plane for a focused LCP beam, which is shown in \\ref{fig:fig4}(a). As shown in \\ref{fig:fig4}(b) and (c), spatial distribution of the the transverse and longitudinal components of helicity density resemble a circularly and doughnut-shaped profile, respectively. We next calculate the differential force. In Figure \\ref{fig:fig4}(d), $\\Delta\\langle{F_{z,total}}\\rangle$ is shown for the case of a tip of radius $r_{NP}=60~\\rm{nm}$. The central region of the beam is characterized by a negative differential force, surrounded by region where the differential force is positive. We can understand this by realizing that the transverse and longitudinal helicity density contributions have different spatial profiles with opposite signs. We can further separate the transverse and longitudinal contributions by proper design of the tip's chiral properties. For example, if the chiral tip is designed such that it exhibits only longitudinal chirality, i.e. $\\alpha_{em,xx}=\\alpha_{em,yy}=0$ and $\\alpha_{em,zz}=\\alpha_{em}$, then the differential force map will track the doughnut-shaped longitudinal helicity density as shown in \\ref{fig:fig4}(e). Conversely, a chiral tip having solely transverse chirality with $\\alpha_{em,xx}=\\alpha_{em,yy}=\\alpha_{em}$ and $\\alpha_{em,zz}=0$ produces a map that reports on the central transverse helicity density, as shown in \\ref{fig:fig4}(f). In the supporting information, we also present the helicity density maps determined with the differential force of a focused azimuthally radially polarized beam (ARPB)\\cite{kamandi2018unscrambling,hanifeh2020optimally,novotny2012principles}.\n\n\\begin{figure}[t]\n\\centering\n\\includegraphics[width=10cm]{Fig4.eps}\n\\caption{(a) The focal plane distribution of normalized helicity density of a circularly polarized(LCP) light focused by a 1.4 NA oil objective. Distributions of (b) longitudinal and (c) transverse component of the normalized helicity density in (a).(d)The total force difference map at the focal plane for a chiral isotropic tip of radius $r_{NP}=60~\\rm{nm}$ under the same focused illumination of LCP and RCP. Force difference maps for a (b)longitudinally chiral($\\alpha_{em,xx}=\\alpha_{em,yy}=0$ and $\\alpha_{em,zz}=\\alpha_{em}$) and (c)transversely chiral($\\alpha_{em,xx}=\\alpha_{em,yy}=\\alpha_{em}$ and $\\alpha_{em,zz}=0$) tip tracking the respective helicity densities with opposite sign. }\n\\label{fig:fig4}\n\\end{figure}\n\n\\section{Conclusion}\nIn this work, we have studied the information contained in the photo-induced force when illuminated by chiral light. Our theoretical analysis reveals that the differential force is directly sensitive to the chiral properties of light. In particular, the differential gradient force is proportional to the helicity density of the incident light field, whereas the differential scattering force is sensitive to the spin angular momentum of the applied light. Using realistic values for the illumination intensity, tip dimension, and the chirality parameter of the tip, we find that the differential force can reach detectable values of several hundreds of fN, just above the noise floor of common scan probe microscopy systems. These findings are significant because a direct characterization of optical chirality at the nanoscale has hitherto been extremely challenging. The observation that the differential gradient force can map out the local helicity density of the light is relevant for numerous applications where knowledge of the chiral state of light at sub-diffraction-limited dimensions is important.\n\n\n\\begin{acknowledgements}\n\nThe authors thank the Keck Foundation and the National Science Foundation, grant CMMI-1905582.\n\n\\end{acknowledgements}\n\n\\section*{Supplementary Information}\n\nDetailed derivations are available in the Supporting Information. Please contact the corresponding author for a copy.\n\n\n","meta":{"redpajama_set_name":"RedPajamaArXiv"}}