recent advances in health and life sciences have led to generation of a large amount of biomedical data , represented in various biomedical databases or ontologies .that these databases and ontologies are represented in different formats and constructed / maintained independently from each other at different locations , have brought about many challenges for answering complex biomedical queries that require integration of knowledge represented in these ontologies and databases .one of the challenges for the users is to be able to represent such a biomedical query in a natural language , and get its answers in an understandable form .another challenge is to extract relevant knowledge from different knowledge resources , and integrate them appropriately using also definitions , such as , chains of gene - gene interactions , cliques of genes based on gene - gene relations , or similarity / diversity of genes / drugs .furthermore , once an answer is found for a complex query , the experts may need further explanations about the answer .table [ tab : queries ] displays a list of complex biomedical queries that are important from the point of view of drug discovery . in the queries , drug - drug interactions present negative interactions among drugs , and gene - gene interactions present both negative and positive interactions among genes .consider , for instance the query q6 .new molecule synthesis by changing substitutes of parent compound may lead to different biochemical and physiological effects ; and each trial may lead to different indications .such studies are important for fast inventions of new molecules .for example , while developing the drug lovastatin ( a member of the drug class of hmg - coa reductase inhibitors , used for lowering cholesterol ) from _ aspergillus terreus _( a sort of fungus ) in 1979 , scientists at merck derived a new molecule named simvastatin that also belongs to the same drug category ( a hypolipidemic drug used to control elevated cholesterol ) targeting the same gene .therefore , identifying genes targeted by a group of drugs automatically by means of queries like q6 may be useful for experts .once an answer to a query is found , the experts may ask for an explanation to have a better understanding . for instance , an answer for the query q3 in table [ tab : queries ] is `` adrb1 '' .a shortest explanation for this answer is as follows :  * the drug epinephrine targets the gene adrb1 according to .+ the gene dlg4 interacts with the gene adrb1 according to .an answer for the query q8 is `` cask '' .a shortest explanation for this answer is as follows :  the distance of the gene cask from the start gene is 2 .the gene cask interacts with the gene dlg4 according to .the distance of the gene dlg4 from the start gene is 1 .the gene dlg4 interacts with the gene adrb1 according to .adrb1 is the start gene .( statements with more indentations provide explanations for statements with less indentations . )  to address the first two challenges described above ( i.e. , representing complex queries in natural language and finding answers to queries efficiently ) , novel methods and a software system , called  ( figure [ fig : bqasp ] ) , have been developed using answer set programming ( asp )  :  * erdem and yeniterzi  developed a controlled natural language , , for expressing biomedical queries related to drug discovery .for instance , queries q1q10 in table [ tab : queries ] are in this language .recently , this language has been extended ( called ) to cover queries q11q13some algorithms have been introduced to translate a given query in ( resp . ) to a program in asp as well .* bodenreider et al . introduced methods to extract biomedical information from various knowledge resources and integrate them by a rule layer .this rule layer not only integrates those knowledge resources but also provides definitions of auxiliary concepts . *erdem et al . have introduced an algorithm for query answering by identifying the relevant parts of the rule layer and the knowledge resources with respect to a given query .the details of representing biomedical queries in natural language and answering them using asp are explained in a companion article .the focus of this article is the last challenge : generating explanations for biomedical queries .most of the existing biomedical querying systems ( e.g. , web services built over the available knowledge resources ) support keyword search but not complex queries like the queries in table [ tab : queries ] .none of the existing systems can provide informative explanations about the answers , but point to related web pages of the knowledge resources available online .the contributions of this article can be summarized as follows .* we have formally defined `` explanations '' in asp , utilizing properties of programs and graphs .we have also defined variations of explanations , such as `` shortest explanations '' and `` different explanations '' .* we have introduced novel generic algorithms to generate explanations for biomedical queries .these algorithms can compute shortest or different explanations .we have analyzed the termination , soundness , and complexity of those algorithms .* we have developed a computational tool , called , that implements these explanation generation algorithms .* we have showed the applicability of our methods to generate explanations for answers of complex biomedical queries related to drug discovery .* we have embedded into so that the experts can obtain explanations regarding the answers of biomedical queries , in a natural language .the rest of the article is organized as follows . in section [ sec : asp ] , we provide a summary of answer set programming .next , in section [ sec : query ] , we give an overview of , in particular , the earlier work done on answering biomedical queries in asp . then ,in sections [ sec : exp][sec : kdiff ] , we provide some definitions and algorithms related to generating shortest or different explanations for an answer , also in asp .next , section [ sec : expex ] illustrates the usefulness of these algorithms on some complex queries over the biomedical knowledge resources  ,  ,  ,  ,  ,  and . in sections [ sec : expnl ] and[ sec : expimp ] , we discuss how to present explanations to the user in a natural language , and embedding of these algorithms in . in section [ sec : related ] , we provide a detailed analysis of the related work on `` justifications ''  in comparison to explanations ; and in section [ sec : relatedwork ] , we briefly discuss other related work .we conclude in section [ sec : conclusion ] by summarizing our contributions and pointing out some possible future work .proofs are provided in the online appendix of the paper .answer set programming ( asp )  is a form of declarative programming paradigm oriented towards solving combinatorial search problems as well as knowledge - intensive problems .the idea is to represent a problem as a `` program '' whose models ( called `` answer sets ''  ) correspond to the solutions .the answer sets for the given program can then be computed by special implemented systems called answer set solvers .asp has a high - level representation language that allows recursive definitions , aggregates , weight constraints , optimization statements , and default negation .asp also provides efficient solvers , such as  . due to the continuous improvement of the asp solvers and highly expressive representation language of asp which is supported by a strong theoretical background that results from a years of intensive research ,asp has been applied fruitfully to a wide range of areas . hereare , for instance , three applications of asp used in industry :  * _ decision support systems _ : an asp - based system was developed to help flight controllers of space shuttle solve some planning and diagnostic tasks  ( used by united space alliance ) . * _ automated product configuration _ : a web - based commercial system uses an asp - based product configuration technology  ( used by variantum oy ) . * _ workforce management _ : an asp - based system is developed to build teams of employees to handle incoming ships by taking into account a variety of requirements , e.g. , skills , fairness , regulations  ( used by gioia tauro seaport ) .let us briefly explain the syntax and semantics of asp programs and describe how a computational problem can be solved in asp .[ [ syntax ] ] syntax + + + + + +  the input language of asp programs are composed of three sets namely _ constant symbols _ , _ predicate symbols _ , and _variable symbols _ where intersection of constant symbols and variable symbols is empty .the basic elements of the asp programs are _an atom is composed of a predicate symbol and _ terms _ where each ( ) is either a constant or a variable .literal _ is either an atom  or its negated form .an asp program is a finite set of _ rules _ of the form : where and each is an atom ; whereas , is an atom or .  for a rule of the form( [ eq_rule ] ) , is called the _head _ of the rule and denoted by .the conjunction of the literals is called the _ body _ of .the set of atoms ( called the positive part of the body ) is denoted by  , and the set of atoms ( called the negative part of the body ) is denoted by  , and all the atoms in the body are denoted by .we say that a rule is a _ fact _if , and we usually omit the sign . furthermore , we say that a rule is a _ constraint _ if the head of is , and we usually omit the sign .  [ [ semantics - answer - sets ] ] semantics ( answer sets ) + + + + + + + + + + + + + + + + + + + + + + +  answer sets of a program are defined over _ground programs_. we call an atom , rule , or program _ ground _ , if it does not contain any variables .given a program  , the set represents all the constants in , and the set represents all the ground atoms that can be constructed from atoms in with constants in .also , denotes the set of all the ground rules which are obtained by substituting all variables in rules with the set of all possible constants in .  a subset of is called an _ interpretation _ for .a ground atom is true with respect to an interpretation if ; otherwise , it is false .similarly , a set of atoms is true ( resp . , false ) with respect to if each atom is true ( resp . ,false ) with respect to  .an interpretation _ satisfies _ a ground rule , if is true with respect to whenever is true and is false with respect to .an interpretation is called a _ model _ of a program if it satisfies all the rules in .the _ reduct _ of a program with respect to an interpretation is defined as follows :   an interpretation is an _ answer set _ for a program , if it is a subset - minimal model for  , and denotes the set of all the answer sets of a program .for example , consider the following program : and take an interpretation .the reduct is as follows : the interpretation  is a model of the reduct ( [ eq : reduct ] ) .let us take a strict subset of which is .then , the reduct  is again equal to ( [ eq : reduct ] ) ; however , does not satisfy ( [ eq : reduct ] ) .therefore , is a subset - minimal model ; hence an answer set of  .note also that is the only answer set of  .the idea of asp  is to represent a computational problem as a program whose answer sets correspond to the solutions of the problem , and to find the answer sets for that program using an answer set solver .when we represent a problem in asp , two kinds of rules play an important role : those that `` generate '' many answer sets corresponding to `` possible solutions '' , and those that can be used to `` eliminate '' the answer sets that do not correspond to solutions .the rules are of the former kind : they generate the answer sets and  .constraints are of the latter kind . for instance , adding the constraint to program ( [ eq : pi2 ] ) eliminates the answer sets for the program that contain  .  in asp , we use special constructs of the form \{a_1, ,a_n}^c ( called _ choice expressions _ ) , and of the form l \{a_1, ,a_m } u ( called _ cardinality expressions _ ) where each is an atom and and are nonnegative integers denoting the `` lower bound '' and the `` upper bound ''  .programs using these constructs can be viewed as abbreviations for normal nested programs defined in  .expression ( [ choice ] ) describes subsets of .such expressions can be used in heads of rules to generate many answer sets .for instance , the answer sets for the program \{p , q , r}^c   are arbitrary subsets of . expression ( [ cardinality ] ) describes the subsets of the set whose cardinalities are at least and at most  .such expressions can be used in constraints to eliminate some answer sets .for instance , adding the constraint   to program ( [ ex : p - q - r ] ) eliminates the answer sets for ( [ ex : p - q - r ] ) whose cardinalities are at least 2 .we abbreviate the rules by the rule   in asp , there are also special constructs that are useful for optimization problems . for instance , to compute answer sets that contain the maximum number of elements from the set , we can use the following optimization statement .   once we represent a computational problem as a program whose answer sets correspond to the solutions of the problem , we can use an answer set solver to compute the solutions of the problem . to present a program to an answer set solver , like, we need to make some syntactic modifications .recall that answer sets for a program are defined over ground programs .thus , the input of asp solvers should be ground instantiations of the programs . for that , programs go through a `` grounding '' phase in which variables in the program ( if exists ) are substituted by constants . for , we use the `` grounder ''  .although the syntax of the input language of is somewhat more restricted than the class of programs defined above , it provides a number of useful special constructs . for instance , the head of a rule can be an expression of one of the forms but the superscript and the sign are dropped .the body can also contain cardinality expressions but the sign is dropped . in the input language of , : - stands for , and each rule is followed by a period . for facts is dropped .for instance , the rule can be presented to as follow :  .... 1{p , q , r}1 . ....variables in a program are represented by strings whose initial letters are capitalized .the constants and predicate symbols , on the other hand , start with a lowercase letter .for instance , the program  can be presented to as follows :  .... index(1 .. n ) .p(i ) : - not p(i+1 ) , index(i ) . ....  here , the auxiliary predicate index is a `` domain predicate '' used to describe the ranges of variables .variables can be also used `` locally '' to describe the list of formulas .for instance , the rule can be expressed in as follows  ....index(1 .. n ) .1{p(i ) : index(i)}1 . ....we have earlier developed the software system  ( see figure [ fig : bqasp ] ) to answer complex queries that require appropriate integration of relevant knowledge from different knowledge resources and auxiliary definitions such as chains of drug - drug interactions , cliques of genes based on gene - gene relations , or similar / diverse genes .as depicted in figure [ fig : bqasp ] , takes a query in a controlled natural language and transforms it into asp .meanwhile , it extracts knowledge from biomedical databases and ontologies , and integrates them in asp .afterwards , it computes an answer to the given query using an asp solver .let us give an example to illustrate these stages ; the details of representing biomedical queries in natural language and answering them using asp are explained in a companion article though .first of all , let us mention that knowledge related to drug discovery is extracted from the biomedical databases / ontologies and represented in asp . if the biomedical ontology is in rdf(s)/owl then we can extract such knowledge using the asp solver  by making use of external predicates . for instance ,consider as an external theory a drug ontology described in rdf .all triples from this theory can be exported using the external predicate & rdf :  .... triple_drug(x , y , z ) : - & rdf["uri for drug ontology"](x , y , z ) . ....  then the names of drugs can be extracted by using the rule :  .... drug_name(a ) : - triple_drug(_,"drugproperties : name",a ) .....  some knowledge resources are provided as relational databases , or more often as a set of triples ( probably extracted from ontologies in rdf ) . in such cases ,we use short scripts to transform the relations into asp .  to relate the knowledge extracted from the biomedical databases or ontologies and also provide auxiliary definitions , a rule layer is constructed in asp . for instance , drugs targeting genes are described by the relation drug_gene defined in the rule layer as follows :  .... drug_gene(d , g ) : - drug_gene_pharmgkb(d , g ) .drug_gene(d , g ) : - drug_gene_ctd(d , g ) . ....  where drug_gene_pharmgkb and drug_gene_ctd are relations for extracting knowledge from relevant knowledge resources .the auxiliary concept of reachability of a gene from another gene by means of a chain of gene - gene interactions is defined in the rule layer as well :  .... gene_reachable_from(x,1 ) : - gene_gene(x , y ) , start_gene(y ) .gene_reachable_from(x , n+1 ) : - gene_gene(x , z ) ,   gene_reachable_from(z , n ) , 0 < n , n < l ,   max_chain_length(l ) . ....  now , consider , for instance , the query q11 from table [ tab : queries ] .what are the drugs that treat the disease depression and that do not target the gene acyp1 ?this type of queries might be important in terms of drug repurposing  which has achieved a number of successes in drug development , including the famous example of pfizer s viagra  .this query is then translated into the following program in the language of :  .... what_be_drugs(drg ) : -  cond1(drg ) , cond2(drg ) .cond1(drg ) : - drug_disease(drg,"depression " ) .cond2(drg ) : - drug_name(drg ) , not drug_gene(drg,"acyp1 " ) .answer_exists : - what_be_drugs(drg ) .: - not answer_exists . ....  where cond1 and cond2 are invented relations , drug_name , drug_disease and drug_gene are defined in the rule layer .once the query and the rule layer are in asp , the parts of the rule layer that are relevant to the given query are identified by an algorithm  .for some queries , the relevant part of the program is almost 100 times smaller than the whole program ( considering the number of ground rules ) .then , given the query as an asp program and the relevant knowledge as an asp program , we can find answers to the query by computing an answer set for the union of these two programs using .for the query above an answer computed in this way is `` fluoxetine '' .once an answer is found for a complex biomedical query , the experts may need informative explanations about the answer , as discussed in the introduction . with this motivation, we study generating explanations for complex biomedical queries .since the queries , knowledge extracted from databases and ontologies , and the rule layer are in asp , our studies focus on explanation generation within the context of asp .before we introduce our methods to generate explanations for a given query , let us introduce some definitions regarding explanations in asp .let be the relevant part of a ground asp program with respect to a given biomedical query ( also a ground asp program ) , that contains rules describing the knowledge extracted from biomedical ontologies and databases , the knowledge integrating them , and the background knowledge .rules in generally do not contain cardinality / choice expressions in the head ; therefore , we assume that in only bodies of rules contain cardinality expressions .let be an answer set for .let be an atom that characterizes an answer to the query .the goal is to find an `` explanation '' as to why is computed as an answer to the query , i.e. , why is in ? before we introduce a definition of an explanation , we need the following notations and definitions .we say that a set  of atoms _ satisfies _ a cardinality expression of the form if the cardinality of is within the lower bound and upper bound .also _ satisfies _ a set of cardinality expressions ( denoted by ) , if satisfies every element of .let be a ground asp program , be a rule in , be an atom in , and and be two sets of atoms .let denote the set of cardinality expressions that appear in the body of .we say that _ supports _ an atom using atoms in but not in ( or with respect to but ) , if the following hold : we denote the set of rules in that support with respect to but , by .we now introduce definitions about explanations in asp .we first define a generic tree whose vertices are labeled by either atoms or rules .  a _ vertex - labeled tree _ for a program and a set of atoms is a tree whose vertices are labeled by a function that maps to . in this tree ,the vertices labeled by an atom ( resp . ,a rule ) are called _ atom vertices _ ( resp . , _ rule vertices _ ) .  for a vertex - labeled tree and a vertex in , we introduce the following notations :  * denotes the set of atoms which are labels of ancestors of .* denotes the set of rule vertices which are descendants of . * denotes the set of children of . * denotes the set of siblings of .* denotes the set of out - going edges of .* denotes the degree of and equals to . * if , then is a _ leaf _ vertex .* denotes the set of leaves of . *the _ root _ of is the root of .* is _ empty _ if .we now define a specific class of vertex - labeled trees which contains all possible `` explanations '' for an atom .[ def : andor ] let be a ground asp program , be an answer set for , be an atom in .the _ and - or explanation tree _ for with respect to and is a vertex - labeled tree that satisfies the following :  * for the root of the tree , ; * for every atom vertex , * for every rule vertex , * each leaf vertex is a rule vertex .let us explain conditions in definition [ def : andor ] in detail .  1 .the root of the and - or explanation tree is labeled by the atom .intuitively , contains all possible explanations for .2 .  for every atom vertex , there is an out - going edge to a rule vertex under the following conditions : the rule that labels supports the atom that labels , using atoms in but not any atom that labels an ancestor of .we want to exclude the atoms labeling ancestors of to ensure that the height of the and - or explanation tree is finite ( e.g. , otherwise , due to cyclic dependencies the tree may be infinite ) .3 .  for every rule vertex , there is an out - going edge to an atom vertex if the atom that labels is in the positive body of the rule that labels . in this way, we make sure that every atom in the positive body of the rule that labels takes part in explaining the head of the rule that labels .4 .  together with conditions and above, this condition guarantees that the leaves of the and - or explanation tree are rule vertices that are labeled by facts in the reduct of the given asp program with respect to the given answer set .intuitively , this condition expresses that the leaves are self - explanatory .[ ex : andor ] let be the program and . the and - or explanation tree for with respect to and is shown in figure [ fig : andor ] .intuitively , the and - or explanation tree includes all possible `` explanations '' for an atom .for instance , according to figure [ fig : andor ] , the atom has two explanations :  * one explanation is characterized by the rules that label the vertices in the left subtree of the root : is in because the rule support .moreover , this rule can be `` applied to generate '' because and , the atoms in its positive body , are in .further , is in because the rule supports .further , is in because is supported by the rule which is self - explanatory . *the other explanation is characterized by the rules that label the vertices in the right subtree of the root : is in because the rule supports .further , this rule can be `` applied to generate '' because is in .in addition , is in because is supported by the rule which is self - explanatory .[ - > ] child node child node child node child node child node child node child node child node child node child node ;  [ prop : andornonempty ] let be a ground asp program and be an answer set for . for every in ,the and - or explanation tree for with respect to and is not empty .note that in the and - or explanation tree , atom vertices are the `` or '' vertices , and rule vertices are the `` and '' vertices .then , we can obtain a subtree of the and - or explanation tree that contains an explanation , by visiting only one child of every atom vertex and every child of every rule vertex , starting from the root of the and - or explanation tree .here is precise definition of such a subtree , called an explanation tree .[ def : exptree ] let be a ground asp program , be an answer set for , be an atom in , and be the and - or explanation tree for with respect to and . an _ explanation tree _ in is a vertex - labeled tree such that  * is a subtree of ; * the root of is the root of ; * for every atom vertex , ; * for every rule vertex , .[ ex : extree ] let be the and - or explanation tree in figure [ fig : andor ] . then , figure [ fig : exptree ] illustrates the explanation trees in .these explanation trees characterize the two explanations for explained in example [ ex : andor ] .[ - > ] child node child node child node child node child node child node child node ;  [ - > ] child node child node child node ;  after having defined the and - or explanation tree and an explanation tree for an atom , let us now define an explanation for an atom .[ def : explanation ] let be a ground asp program , be an answer set for  , and be an atom in  .a vertex - labeled tree is an _ explanation _ for with respect to and if there exists an explanation tree in the and - or explanation tree for with respect to and such that  * ; * .intuitively , an explanation can be obtained from an explanation tree by `` ignoring '' its atom vertices .[ ex : ex ] let and be defined as in example [ ex : andor ] .then , figure [ fig : exp ] depicts two explanations for with respect to and , described in example [ ex : andor ] .so far , we have considered only positive programs in the examples .our definitions can also be used in programs that contain negation and aggregates in the bodies of rules .[ ex : explanationnegaggr ] let be the program and . the and - or explanation tree for with respect to and is shown in figure [ fig : explanationnegaggr](a ) . here, the rule is not included in the tree as is in , whereas the rule is in the tree as is not in and , and are in .also , the rule is in the tree as is in and the cardinality expression is satisfied by . an explanation for with respect to and is shown in figure [ fig : explanationnegaggr](b ) .  note that our definition of an and - or explanation tree considers positive body parts of the rules only to provide explanations .therefore , explanation trees do not provide further explanations for negated literals ( e.g. , why an atom is not included in the answer set ) , or aggregates ( e.g. , why a cardinality constraint is satisfied ) as seen in the example above .as can be seen in figure [ fig : exp ] , there might be more than one explanation for a given atom .hence , it is not surprising that one may prefer some explanations to others .consider biomedical queries about chains of gene - gene interactions like the query q8 in table [ tab : queries ] .answers of such queries may contain chains of gene - gene interactions with different lengths .for instance , an answer for this query is `` cask '' .figure [ fig : expq8 ] shows an explanation for this answer . here, `` cask '' is related to `` adrb1 '' via a gene - gene chain interaction of length ( the chain `` cask''``dlg4''``adrb1 '' ) .another explanation is partly shown in figure [ fig : expq8_3 ] . now , `` cask '' is related to `` adrb1 '' via a gene - gene chain interaction of length ( the chain `` cask'' `` dlg1''``dlg4''``adrb1 '' ) . since gene - gene interactions are important for drug discovery , it may be more desirable for the experts to reason about chains with shortest lengths .  with this motivation , we consider generating shortest explanations . intuitively , an explanation  is shorter than another explanation  if the number of rule vertices involved in  is less than the number of rule vertices involved in  .then we can define shortest explanations as follows .[ - > ] child  node  [ cols= " < " , ]based on the algorithms introduced above , we have developed a computational tool called  , using the programming language c++ . given an asp program andits answer set , generates shortest explanations as well as different explanations .the input of are  * an asp program , * an answer set for , * an atom in , * an option that is used to generate either a shortest explanation or different explanations , * a predicate look - up table ,  and the output are  * a shortest explanation for with respect to and in a natural language ( if shortest explanation option is chosen ) , * different explanations for with respect to and in a natural language ( if different explanations option is chosen ) .  for generating shortest explanations ( resp ., different explanations ) , utilizes algorithm [ alg : shortexp ] ( resp ., algorithm [ alg : kdiff ] ) .  to provide experts with further informative explanations about the answers of biomedical queries ,we have embedded into by utilizing table [ tab : lookup ] as the predicate look - up table of the system .figure [ fig : expgenasp ] shows a snapshot of the explanation generation mechanism of .the most similar work to ours is  that study the question `` why is an atom  in an answer set  for an asp program  '' . as an answer to this question, the authors of  finds a `` justification '' , which is a labeled graph that provides an explanation for the truth values of atoms with respect to an answer set .[ ex : pontelli ] let be the program presented in example [ ex : andor ] : and .figure [ fig : jstfpontelli ] is an offline justification of with respect to and .intuitively , is in since and are also in and there is a rule in that supports using the atoms and .furthermore , is in since is in and there is a rule in that supports using the atom . finally , is in as it is a fact in .[ - > ] child node ( b+ ) edge from parent node[pos=0.4,left ] child node ( c+ ) child node edge from parent node[left ] edge from parent node[pos=0.4,right ] ; ( b+ ) ( c+ )node[pos=.5 , above ] ;  to relate offline justifications and explanations , we need to introduce the following definitions and notations about justifications defined in  .first , let us introduce notations related to asp programs used in  .the class of asp programs studied is normal programs , i.e. , programs that consist of the rules of the form where and and each is an atom .therefore , the programs we consider are more general .let be a normal asp program .then , is the herbrand base of . an _ interpretation _ for a program is defined as a pair , where and .intuitively , denotes the set of atoms that are true , while denotes the set of atoms that are false . is a _ complete interpretation _ if .the _ reduct _ of with respect to is defined as a complete interpretation for a program is an answer set for if is an answer set for .literal _ is either an atom or a formula of the form where is an atom .the set of atoms which appear as negated literals in is denoted by . for an atom , denotes that the atom is true and denotes that is false .then , and are called the _ annotated _ versions of .moreover , it is defined that and . for a set of atoms ,the following sets of annotated atoms are defined .  * *   finally , the set is defined as .apart from the answer set semantics , there is another important semantics of logic programs , called the well - founded semantics  .since this semantics is important to build the notion of a justification , we now briefly describe the well - founded semantics .we consider the definition proposed in  , instead of the original definition proposed in  , as the authors of  considered .let be a normal asp program , and and be two sets of atoms from .then , the _ immediate consequence _ of with respect to and , denoted by is the set defined as follows :   we denote by the least fixpoint of when is fixed .let be a normal asp program , .the sequence is defined as follows : let be the first index of the computation such that .then , _ the well - founded model _ of is where and .[ ex : wellfounded ] let be the program then , the well - founded model of is computed as follows : thus , .we now provide definitions regarding the notion of an offline justification .first , we introduce the basic building of an offline justification , a labeled graph called as e - graph .[ def : egraph ] let be a normal asp program . an _e - graph _ for is a labeled , directed graph , where and , which satisfies following properties :  * the only sinks ( i.e. , nodes without out - going edges ) in the graph are ; * for every , and ; * for every , and ; * for every , if for some and , , then is the only out - going edge originating from .  according to this definition ,an edge of an e - graph connects two annotated atoms or an annotated atom with one of the nodes in and is marked by a label from .an edge is called as _ positive _ ( resp . ,_ negative _ ) if it is labeled by ( resp . , ) .also , a path in an e - graph is called as _ positive _ if it has only positive edges , whereas it is called as _ negative _ if it has at least one negative edge .the existence of a positive path between two nodes and is denoted by . in the offline justification , is used to explain facts , to explain atoms which do not have defining rules , and is for atoms for which explanations are not needed , i.e. , they are assumed to be true or false .[ ex : egraph ] let be the program presented in example [ ex : andor ] , and . then , figure [ fig : egraph ] is an e - graph for . intuitively , the true state of depends on the true state of and the false state of , where is assumed to be true and is assumed to be false .[ - > ] child node child node edge from parent node[left ] edge from parent node[left ] child node child node edge from parent node[left ] edge from parent node[right ] ;  in an e - graph , a set of elements that directly contributes to the truth value of an atom can be obtained through the out - going edges of a corresponding node .this set is defined as follows .[ def : support ] let be a normal asp program , be an e - graph for and be a node in .then , _ _ is defined as follows .* , if for some and , is in ; * , otherwise .[ ex : support ] let be the e - graph in figure [ fig : egraph ] . then , , and define the notion of a justification , an e - graph should be enriched with explanations of truth values of atoms that are derived from the rules of the program .for that , the concept of one step justification of a literal is defined as follows .[ def : lce ] let be a normal asp program , be an atom , be a possible interpretation for , be a set of atoms , and be a set of literals .we say that  * is an _ lce _ of with respect to , if and * * or * * , , and there is a rule such that and . in case , , is denoted by the set .* is an _ lce _ of with respect to , if and * * or * * , , and is a minimal set of literals such that for every rule if , then or . in case , , is denoted by the set .the set of all the lces of with respect to is denoted by and the set of all the lces of with respect to is denoted by .  here , a possible interpretation denotes an answer set .the set consists of atoms that are assumed to be false ( which will be called as assumptions in the notion of justification later on ) .the need for comes from the fact that the truth value of some atoms is first guessed while computing answer sets .intuitively , if an atom is true , an lce consists of the body of a rule which is satisfied by and has in its head ; if is false , an lce consists of a set of literals that are false in and falsify all rules whose head are .[ ex : lce ] let and be defined as in example [ ex : egraph ] .then , the lces of the atoms with respect to is as follows .  accordingly , a class of e - graphs where edges represent lces of the corresponding nodes are defined as follows .[ def : ju ] let be a normal asp program , be a possible interpretation for , be a set of atoms and be an element in .-based e - graph _ of is an e - graph such that  * every node is reachable from , * for every , is an lce of with respect to ;  a -based e - graph is _ safe _ if for all , i.e. , there is no positive cycle in the graph .we now introduce a special class of -based e - graphs where only false elements can be assumed .[ def : offlinegraph ] let be a normal asp program , be a partial interpretation for , be a set of atoms and be an element in .offline e - graph _ of with respect to and is a -based e - graph of that satisfies following properties :  * there exists no such that ; * if and only if . is the set of all offline e - graphs of with respect to and .  here ,the roles of and are the same as their roles in definition [ def : lce ] .observe that true atoms can not be assumed due to the first condition and only elements in the set are assumed due to the second condition .we said earlier that in a -based e - graph represents an answer set and consists of atoms that are assumed to be false . here , is chosen based on some characteristics of . in particular, we want to be a set of atoms such that when its elements are assumed to be false , the truth value of other atoms in the program can be uniquely determined and leads to .we now introduce regarding definitions formally .[ def : tentative ] let be a normal asp program , be an answer set for and be the well - founded model of .the _ tentative assumptions _ of with respect to are defined as   [ ex : tentative ] let be the program : then , is an answer set for and is the well - founded model of . given that , as , and .in fact , tentative assumptions is a set of atoms whose subsets might `` potentially '' form .we provide a definition that would allow one to obtain a program from a given program and a set of atoms by assuming all the atoms in as false .[ def : negreduct ]let be a normal asp program , be an answer set for , and be a set of tentative assumption atoms .the _ negative reduct _ of with respect to is the set of rules defined as   finally , the concept of assumptions can be introduced formally .[ def : assumption ] let be a normal asp program , be an answer set for _ of with respect to is a set of atoms that satisfies the following properties :  * ; * the well - founded model of is equal to . is the set of all assumptions of with respect to .let and be defined as in example [ ex : tentative ] .let .then , is : and is the well - founded model of .thus , is an assumption of with respect to .note that assumptions are nothing but subsets of tentative assumptions that would allow to obtain the answer set .  at last , we are ready to define the notion of offline justification .[ def : justification ] let be a normal asp program , be an answer set for , be an assumption in and be an annotated atom in .an _ offline justification _ of with respect to and is an element of which is safe .  according to the definition ,a justification is a -based e - graph where is an answer set and is an assumption .also , justifications do not allow the creation of positive cycles in the justification of true atoms .for instance , for and defined as in example [ ex : andor ] , figure [ fig : jstfpontelli ] illustrates an offline justification of with respect to and .  in  , the authors prove the following proposition which shows that for every atom in the program , there exists an offline justification .  [prop : pontelli ] let be a ground normal asp program , be an answer for .then , for each atom in , there is an offline justification of with respect to and which does not contain negative cycles .we relate a justification to an explanation .in particular , given an offline justification , we show that one can obtain an explanation tree whose atom vertices are formed by utilizing the `` annotated atoms '' of the justification and rule vertices are formed by utilizing the `` support '' of annotated atoms . to compute such explanation trees , we develop algorithm [ alg : jstf2exp ] .   create a vertex s.t .   let us now explain the algorithm in detail .algorithm [ alg : jstf2exp ] takes as input a ground normal asp program , an answer set for , an atom in , and a justification of with respect to and some .our goal is to obtain an explanation tree in the and - or explanation tree for with respect to and from the justification .the algorithm starts by creating two sets and ( line  ) . here, and corresponds to the set of vertices and the set of edges of the explanation tree , respectively . by condition  in definition [ def : exptree ] and condition  in definition [ def : andor ] , we know that the label of the root of an explanation tree for with respect to and is .thus , a vertex with label is defined ( line  ) , and added into the queue  ( line  ) .then , the algorithm enters into a `` while '' loop which executes until becomes empty . at every iteration of the loop , an element from first extracted ( line  ) and added into ( line  ) .this implies that every element added into is also added into .for instance , the vertex defined at line  is the first vertex extracted from and also added into , which makes sense since we know that the root of an explanation tree is an atom vertex with label .then , according to the type of the extracted vertex , its out - going edges are defined .let be a vertex extracted from at line  in some iteration of the loop .consider the following two cases .  *assume that is an atom vertex .then , the algorithm directly goes to line  . by condition  in definition [ def : exptree ] , we know that an explanation tree is a subtree of the and - or explanation tree .hence , we need to define out - going edges of by taking into account condition  in definition [ def : andor ] , which implies that a child of must be a rule vertex such that the rule that labels `` supports '' the atom that labels .thus , a rule that supports the atom that labels is created ( line  ) .we ensure `` supportedness '' property by utilizing the annotated atoms in the given offline justification which supports the annotated version of the atom that labels .then , a vertex with label is created ( line  ) , and a corresponding child of is added into ( line  ) . by condition  in definition [ def : exptree ] , we know that every atom vertex of an explanation tree has a single child .therefore , another child of is not created .then , before finishing the iteration of the loop , the child of is added into so that its children can be formed in the next iterations of the loop . *assume that is a rule vertex .then , the condition at line  is satisfied and the algorithm goes to line  . in this case, while forming the children of , we should consider condition  in definition [ def : andor ] , which implies that a child of must be an atom vertex such that the atom that labels is in the positive body of the rule that labels .also , by condition in definition [ def : exptree ] , we should ensure that for every atom in the positive body of the rule that labels , there exists a child of such that the atom that labels is equal to .thus , the loop between lines  iterates for every atom in the positive body of the label of and a vertex with label is created ( line  ) .then , becomes a child of ( line  ) .to form the children of in the next iterations of the `` while '' loop , the child of is added into ( line  ) .when the algorithm finishes processing the elements of , i.e. , becomes empty , the `` while '' loop terminates .then , the algorithm returns a vertex - labeled tree ( line  ) .we now provide the proposition about the soundness of algorithm [ alg : jstf2exp ] .[ prop : jstf2exp ] given a ground normal asp program , an answer set for , an atom in , an assumption in , and an offline justification of with respect to and , algorithm [ alg : jstf2exp ] returns an explanation tree in the and - or explanation tree for with respect to and .let and be defined as in example [ ex : egraph ] .figure [ fig : jstf2exp](a ) is an offline justification of with respect to and .figure [ fig : jstf2exp](b ) shows a corresponding explanation tree in the and - or explanation tree for with respect to and that is obtained by using algorithm [ alg : jstf2exp ] .we relate an explanation to a justification . in particular , given an explanation tree whose labels of vertices are unique, we show that one can obtain an offline justification by utilizing the labels of atom vertices of the explanation tree . for that , we design algorithm [ alg : exp2jstf ] . root of   let us now describe the algorithm in detail .algorithm [ alg : exp2jstf ] takes as input a ground normal asp program , an answer set for , an atom in , and an explanation tree in the and - or explanation tree for with respect to and .our goal is to obtain an offline justification of in with respect to and  .the reason to obtain the offline justification in the reduct of with respect to is that our definition of explanation is not defined for the atoms that are not in the answer set .algorithm [ alg : exp2jstf ] starts by creating two sets and which will correspond to the set of nodes and the set of edges of the offline justification , respectively ( line  ) .then , the root of is added into the queue ( line  ) and we enter into a `` while '' loop that iterates until becomes empty . at every iteration of the loop, first an element is extracted from ( line  ) and is added into ( line  ) .then , we form the out - going edges of . due to condition in definition [ def : exptree ] , every atom vertex in an explanation tree has a single child , which is a rule vertex due to condition in definition [ def : exptree ] and condition in definition [ def : andor ] .then , we extract the child of at line  and consider two cases .note that is a rule vertex .* assume that is a fact in .then , satisfies the condition at line  and we add into at line  .the key insight behind that is as follows .due to condition in definition [ def : ju ] , must be an lce of .due to condition in definition [ def : exptree ] and condition in definition [ def : andor ] , the head of is . as is a fact in , i.e., its body is empty in , becomes an lce of with respect to , due to definition [ def : lce ] .thus , by adding to , becomes . *assume that is not a fact in .then , for every child of , we add into at line  .the intuition behind this is to make sure that is an lce of . due to condition in definition [ def : exptree ] ,an explanation tree is a subtree of the corresponding and - or explanation tree .then , due to condition in definition [ def : andor ] , for every atom vertex in an explanation tree , the atoms in the positive body of the rule that labels the child of are in the given answer set  .thus , due to definition [ def : lce ] , adding into for every child of ensures that is an lce of with respect to . also , we add into so that its children in are formed in the next iterations of the `` while '' loop .due to line  , there are incoming edges of .but , is not added into inside the `` while '' loop . thus , when the `` while '' loop terminates , before returning at line  , we add into .algorithm [ alg : exp2jstf ] creates an offline justification of the given atom in the reduct of the given asp program with respect to the given answer set , provided that labels of the vertices of the given explanation tree are unique .[ prop : exp2jstf ] given a ground normal asp program , an answer set for , an atom in , and an explanation tree in the and - or explanation tree for  with respect to and such that for every , if and only if , algorithm [ alg : exp2jstf ] returns an offline justification of in with respect to and .let be the program : and .figure [ fig : exp2jstf](a ) is an explanation tree in the and - or explanation tree for with respect to and .then , given and , algorithm [ alg : exp2jstf ] creates an offline justification of in with respect to and as in figure [ fig : exp2jstf](b ) .the most recent work related to explanation generation in asp are  , in the context of debugging asp programs . among those , studies why a program does not have an answer set , and studies why a set of atoms is not an answer set .as we study the problem of explaining the reasons why atoms are in the answer set , our work differs from those two work .  in  ,similar to our work , the question `` why is an atom  in an answer set  for an asp program  '' is studied . as an answer to this question, the authors of  provide the rule in that supports with respect to ; whereas we compute shortest or different explanations ( as a tree whose vertices are labeled by rules ) .pontelli et al . also introduce the notion of an online justification that aims to justify the truth values of atoms during the computation of an answer set . in  , a framework where the users can construct interpretations through an interactive stepping process is introduced . as a result , and can be used together to provide the users with justifications of the truth values of atoms during the construction of interpretations interactively through stepping .we have formally defined explanations in the context of asp .we have also introduced variations of explanations , such as `` shortest explanations '' and `` different explanations '' .we have proposed generic algorithms to generate explanations for biomedical queries . in particular , we have presented algorithms to compute shortest or different explanations .we have analyzed termination , soundness and complexity of these algorithms .in particular , the complexity of generating a shortest explanation for an answer ( in an answer set ) is where is the number of asp rules representing the query , the knowledge extracted from biomedical resources and the rule layer , and is the number of atoms in . the complexity of generating different explanations is acknowledgments ---------------  we would like to thank yelda erdem ( sanovel pharmaceutical inc . ) for her help in identifying biomedical queries relevant to drug discovery , and halit erdogan ( sabanci university ) for his help with an earlier version of which he implemented as part of his ms thesis studies .we would like to thank hans tompits ( vienna university of technology ) for his useful comments about the work presented in the paper , and pointing out relevant references in the context of debugging asp programs .we also would like to thank anonymous reviewers for their useful comments and suggestions on an earlier draft .this work was partially supported by tubitak grant 108e229 .        ,king , b. l. , mockus , s. , murphy , c. g. , saraceni - richards , c. , rosenstein , m. , wiegers , t. , and mattingly , c. j. 2011 .the comparative toxicogenomics database : update 2011 ._ 39 , _ database issue , d1067d1072 .              ,law , v. , jewison , t. , liu , p. , ly , s. , frolkis , a. , pon , a. , banco , k. , mak , c. , neveu , v. , djoumbou , y. , eisner , r. , guo , a. c. , and wishart , d. s. 2010 . drugbank 3.0 : a comprehensive resource for ` omics ' research on drugs ._ 39 , _ database issue , d1035d1041 .      , whirl - carrillo , m. , garten , y. , altman , r. b. , and klein , t. e. 2011 . from pharmacogenomic knowledge acquisition to clinical applications : the pharmgkb as a clinical pharmacogenomic biomarker resource ._ 5 , _ 6 , 795806 .

Abstract: we introduce novel mathematical models and algorithms to generate ( shortest or different ) explanations for biomedical queries , using answer set programming . we implement these algorithms and integrate them in . we illustrate the usefulness of these methods with some complex biomedical queries related to drug discovery , over the biomedical knowledge resources , , , , , and .   [ firstpage ]  answer set programming , explanation generation , query answering , biomedical queries


local realism the assumption that physical quantities have well established values previous to any measurement and that signals can not travel faster than the speed of light entails limits on the correlations which space - like separated , independent observers may obtain .such restrictions , usually expressed as bell inequalities  , may be surpassed within quantum theory when the observers share certain entangled quantum states .the correlations then can not be explained by any local hidden variable ( lhv ) model , and are hence labeled nonlocal correlations .the experimental evidence for the existence of nonlocal correlations is compelling yet not completely conclusive .existing tests all suffer from one or more loopholes , which open up lhv explanations of the data unless further assumptions are introduced . in some cases ,the measurements are not sufficiently fast or far apart to be space - like separated events  .in other cases , low detection efficiency is the obstacle .for example , in bell tests based on photon pairs  , low photodetection efficiencies imply that in many experimental runs , at least one photon is lost . analysing only the coincidence counts, nonlocal correlations may be observed even when the total dataset can be explained by a lhv model . an additional fair - sampling assumption is therefore required to reject local realism in experiments with low detection efficiency . while this may seem natural , albeit slightly dissatisfactory , in experiments probing the nature of quantum mechanics , it is incompatible with device independent applications for which the violation of a bell inequality is a necessary condition to assure e.g. security of certain tasks  .for example , a malicious eavesdropper could take advantage of detection inefficiency to break a device - independent key distribution protocol without being detected .the robustness of bell test violations to loss and inefficiencies depends on the particular test and setup . to achieve efficiency thresholds compatible with those of laboratory detectors , various approacheshave been considered , e.g. changing the number of settings , outcomes and parties  , as well as the detection schemes and types of states  .interestingly , as first noted by eberhard  , the state providing better robustness against losses , is not necessarily the most entangled . for the chsh inequality ,corresponding to 2 parties , 2 settings , and 2 outcomes , a critical efficiency of 67% is achieved by an almost separable state .however , such a state is very susceptible to noise , and hence not terribly practical in experiment .recently , asymmetric setups have attracted attention .asymmetry in the efficiency of different measurement settings is motivated by the fact that the measurements which can be efficiently performed do not necessarily coincide with those yielding a high bell test violation .for example , homodyne detection of light can be extremely efficient , but it seems very difficult to obtain good violations based solely on homodyning  . combining homodyning and single - photon detection , in ref . the authors obtain a threshold of 71% for single - photon detection .this is higher than for the eberhard scheme , however the required state is not close to separable and seems feasible to prepare .asymmetry between parties is motivated by the natural occurence of entanglement between different physical systems , such as atoms and photons , for which the available detection schemes have widely different efficiencies .atomic states can be measured with almost unit efficiency .nonlocality tests for atom - photon systems have been investigated in refs . , where a critical single - photon detection efficiency of 45% was obtained , and very recently in ref . , where 39% was obtained for a scheme combining atoms , single - photon and homodyne detection .  in this paper, we consider general asymmetric bell tests , based on multipartite w - states .the physical implementation we have in mind is a single photon shared between multiple parties , and possibly entangled with an additional atomic system .however our analysis is applicable also to a wider qubit setting .the motivation for focusing on nonlocality tests based on w - states is threefold : the simplicity of preparing single - photon w - states , the robustness of w - state entanglement against losses , and the existence of bell inequality violations which rapidly approaches the algebraic maximum for an increasing number of parties .  in the following sections we first discuss optical w - states and examine concrete measurements schemes in sec .[ sec.physical ] .we introduce a povm model capturing a broad range of detection imperfections and loss in sec .[ sec.povm ] , and in secs .[ sec.bell ] and [ sec.polytope ] we explore the robustness of nonlocality for the w - state by means of specific bell inequalities and linear programming respectively .we demonstrate , using the bell inequality proposed in ref . , that the local content of the w - state tends exponentially fast to zero for increasing .this , and the fact that the entanglement in the state has a very robust ( size - independent ) resistance to losses  , would seem to suggest that there could be an advantage to increasing in tests of nonlocality .however , we show that this is not the case for several concrete examples where the robustness actually decreases with , while in other cases which we have examined , only slight improvements with are found . at the same time the threshold scaling , for the cases with no improvements ,is not severe .this is positive , since multipartite nonlocality is important in its own right and useful in several information processing tasks  .the w - state for parties , each a 2-dimensional quantum system , can be taken to be where , denote the eigenstates with eigenvalues , respectively of the pauli operator . in a purely optical implementation , ( [ eq.w ] ) can be created by coherently distributing a single photon among parties . heralded single photons can be generated e.g. via spontaneous parametric down conversion , and distributed by means of linear optics .measurements of then correspond simply to single - photon detection ( spd ) .however , measurements in the - plane of the bloch sphere require transformations such as that do not preserve energy , and hence can not be implemented perfectly with passive , linear optics. nevertheless , approximate implementations are possible as discussed below .another case we will consider is atom - photon entanglement . for single trapped atoms or ions , very high detection efficiency and good control over the measurement bases can be achieved . at the same time , through spontaneous emission , the atom can be entangled with an optical field , e.g. in a state of the form , with the first mode referring to the atomic state and the second to the number of photons in the field . distributing the emitted photon over multiple modes ,one arrives at a w - state with one atomic party and photonic parties , that is where denotes a state with all modes in .since the coupling between the atom and the emitted photon is not perfect , the actual state will be an incoherent sum of and with respective probabilities given by and .an approximate implementation of can be achieved using the fact that in the 0 - 1 photon fock space , a homodyne measurement with phase and sign - binning approximates a measurement of , i.e. in the equatorial plane of the bloch sphere .for example , within the 0 - 1 photon fock space , the elements of the projection operator approximating are due to the non - unit factor the detection is not perfect . the probability to produce the correct output giveneither eigenstate of is , where is the homodyne detection efficiency . for unit efficiencythis number becomes .   in ref . an alternative method was proposed for the implementation of measurements of . in this setup the incoming field is displaced by mixing with a coherent state on a highly transmitting beam splitter and subsequently measured with a single - photon detector . for a real displacement ,the probability to observe no clicks at the detector ( in the absence of loss ) , when an eigenstate of is incident , is given by where is the displacement operator and denotes a coherent state .thus , by choosing one can ensure that the state is faithfully detected , in the sense that it will always give a detector click , while the state will give a no - click outcome with probability . as we will see in the next sectionthis has the same structure as an spd -measurement .however , this choice of suggested in ref . is not necessarily optimal .when the single - photon detector has a non - unit efficiency , ( [ eq.dispp0 ] ) becomes the optimal choice of will depend on as well as on the bell scenario in which the approximate -measurement is used .in any experiment , imperfections are likely to be present in the form of losses , detector inefficiencies , and noise . depending on the particular setup, these imperfections might have different effects .we imagine bell experiments in which each party chooses between measurements of the same two dichotomic observables , labeled by and . for most cases we will consider , the settings , will correspond to implementations of and respectively .a broad range of error behaviour can be modeled within the same framework , describing each measurement by a povm with elements where are the eigenstates of the observable . for ideal efficiencies thispovm implements a projective measurement along the direction defined by . for non - ideal efficiencywe capture several types of errors as we now describe in detail .one common loss - induced error occurs in experiments based on single - photon detection , where imperfect detectors lead to a decrease in the probability for observing one outcome ( click ) and an increased probability for the complementary outcome ( no click ) .this makes sense e.g. for an optical implementation of ( [ eq.w ] ) , with the -basis corresponding to the fock basis and .the vacuum never leads to clicks ( in the absence of dark counts ) while the single photon is detected with a finite efficiency .we can model this by taking .\ ] ] note that this models also describes the approximate implementation of via displacement , for , as discussed in sec .[ subsec : dis ] .another relevant error consists in each input state being incorrectly identified as its opposite with some small probability .this corresponds for example to a polarisation measurement on a single photon , with a slight misalignment of the experimental measurement basis .as discussed in sec .[ subsec : homo ] , it also occurs when homodyne measurements are used to approximate a measurement of .we can model this error by .\ ] ]  combining the povms ( [ eq.err_spd ] ) and ( [ eq.err_sym ] ) , several interesting scenarios can be described .for example , taking ( [ eq.err_spd ] ) with for -measurements and ( [ eq.err_sym ] ) with for -measurements models an experiment where the state is subject to an amplitude damping ( ad ) channel which incoherently replaces by with probability , and where all parties measure , .such an ad channel could describe e.g. transmission loss affecting a single - photon w - state .another example is the dephasing ( d ) channel , which is relevant for trapped - ion experiments , where dephasing is caused by magnetic - field and laser - intensity fluctuations , or spontaneous emission during raman transitions , and also for photonic polarization - qubits . for - and -measurements , the d channel with phase - flip probability modeled by ( [ eq.err_sym ] ) with and respectively .one can imagine other scenarios for which measurements return a result that does not correspond to any of the binary outcomes , e.g. no click does not correspond to any polarization direction . to treat such an additional outcomeone can either adopt a binning strategy , grouping it with one of the binary outcomes , or one can consider a setting with more outcomes , for which two - outcome bell inequalities then no longer apply .binning can be modelled within the povm framework .for example ( [ eq.err_spd ] ) can be seen as binning of no - click events with the -outcome .we will return to additional outcomes in [ sec.polytope ] .in this section we analyze the feasibility of the modes w - state and possibly entangled with an additional atomic system to perform loophole free nonlocality tests using several bell inequalities .the atomic party is assumed to be able to perform ideal measurements in any basis . in order to find the best thresholds we optimise over these bases and also on the coefficient that describes the atom - photon entangled state ( [ eq.wasym ] ) .the photonic parties are assumed all to perform the same measurements : single - photon detection with efficiency described by eq .( [ eq.err_spd ] ) or an approximate implementation of . actually , in all the cases considered , we found numerically that the best thresholds for the efficiencies are obtained for , that is for measurements .   to begin with we investigate the inequality proposed for the 3-qubit w - state by cabello in ref . and later generalised to more parties in ref .writing for the probability that outcome is obtained with the measurement setting , in our variant the inequality takes the form    or more formally with   where runs over all cyclic permutations of length and runs over all permutations giving distinct images of .we note that the first term on the left - hand side was not present in previous works .however , it is easy to check that the inequality is still valid , and since the term is always positive it can only increase any violation of the inequality .the violation of ( [ eq.ineq ] ) attained by an -party w - state approaches 1 exponentially fast with , specifically   in ref .  no analysis of the robustness of the violation was presented . from the growing violation and the robustness of the w - state entanglement against lossesone might speculate that there could be experimental advantage to increasing the number of parties . as an illustration consider the -party w - state undergoing amplitude damping in each of its qubits , thus becoming where denotes the state with all modes in , and is the damping rate ( or equivalently the loss probability ) . to assess the effect of the damping, we need to compute the value of for the state , and we find from ( [ eq.heaneybound])-([eq.vacbound ] ) the critical below which no violation is possible can be analytically calculated and is given by this is a monotonously decreasing function for and hence the robustness to amplitude damping_ decreases _ with the number of parties .considering general detection inefficiencies given by ( [ eq.err_spd ] ) and ( [ eq.err_sym ] ) for and respectively , one obtains fig .[ fig.povm_spd_hom ] , which also demonstrates that the robustness of the cabello inequality decreases appreciatively for larger .for the optimal case , to obtain a loophole - free test with homodyne realisations of and spd realisations of we see that is required . fora displacement realisation of one can show that the bound is .  ) for ( bottom to top ) , when the error behaviour of - and -measurements is given respectively by ( [ eq.err_spd ] ) and ( [ eq.err_sym ] ) . the inequality is violated above the solid lines .intersections of the dotted and dashed with the solid lines give respectively the critical survival probability for the ad channel and the critical -efficiency when is approximated via homodyning . ]the inequality ( [ eq.ineq ] ) is not a facet of the local polytope , that is , it is not a tight bell inequality .so one should expect that the results obtained in the previous section are not optimal and that one could improve the thresholds testing the nonlocality of the w - states by means of tight bell inequalities . to probe this we first investigate the tripartite scenario , which is fully characterized by the sliwa inequalities . for higher one can consider the wwwzb - inequality  that fully describes tight bell inequalities that can be formed with only full correlators , that is , only correlations between all subsystems .the wwwzb inequality describes the multipartite case where each party chooses between two different dichotomic measurements .there are tight , linear bell inequalities which can be succinctly expressed in terms of the single non - linear inequality where , and are vectors describing a binary strings , for example with and is the full correlator so that indicates the choice of the observable at site . in the followingwe analyze the pure photonic case and the atom - photon case ._ pure photonic ._ we found that for the mermin inequality - a particular case of the sliwa and wwwzb inequalities - is the one providing the best robustness to losses and detection inneficiencies .however , for the mermin inequality is not violated anymore for the chosen measurement settings , even without any imperfections , and instead we consider the criteria ( [ ww ] ) .the results obtained are displayed in fig .[ fig.wwsym ] .it is interesting to note that with wwwzb inequalities , when the required efficiencies for significantly decrease with increasing . for the particular case of spd -measurements and approximate -measurements based on ideal homodyning , i.e.  , we find that the best threshold for the spd efficiency is obtained for .similarly , when the -measurement is based on displacement followed by spd , the best threshold is again found for .thus , the performance of the two schemes is similar .however , we note that while was assumed for the homodyning scheme , there is no such assumption for the displacement scheme .also , while the former scheme requires a fast switching between homodyning and single - photon detection , in the latter all that is needed is a fast transition between on and off states for the coherent displacement field , which may be easier experimentally ( optimal values of correspond to mean photon numbers on the order of 1 ) .hence , the displacement scheme may be the more attractive option for implementation .  .the dashed and dotted lines indicate as a function of for the approximate implementation of sec .[ subsec : homo ] and amplitude damping respectively . with homodyning, the best critical spd efficiency is obtained for .when displacements are used , the best is . ]  _ atom - photon . _ considering the case where the photonic modes are entangled with an atomthe thresholds can be considerably improved .we compute the thresholds for violation of ( [ ww ] ) in the particular case where -measurements are implemented via ideal homodyning .the results are shown in fig .[ fig.wwasym ] for .one sees that the optimal thresholds are obtained for , a case already considered in ref .  . for perfect coupling between the atom and the photon, a threshold as low as can be obtained in the limit , that is the optimal state is almost separable , in analogy with the eberhard result  . for on the other hand , the threshold is higher , , but the optimal state is more entangled .we find which corresponds to a negativity of between the atom and the photonic modes ( ranges from for a separable state to for a maximally entangled state ) .similar results hold for higher .we note that we are not optimizing over the coefficients that define the photonic state , e.g. the parameters of beam splitters utilized to divide the single photon between different modes . in principleif such an optimization is done , lower values for the minimum efficiencies can be achieved and in the limit where only one photonic mode is populated we effectively fall back into .( bottom to top ) . the approximate implementation of sec .[ subsec : homo ] with perfect homodyning is assumed .one sees that the optimal case is , which implies a very small value for the atom - photon entanglement . ]  to compare the homodyning and displacement schemes for -measurements , we have performed a more detailed calculation for the bipartite case , where the only relevant bell inequality is chsh .we first note , that when all detectors as well as the atom - photon coupling are taken to be perfect , the magnitude of the violation is higher in the displacement scheme .the schemes violate the lhv bound of 2 by 2.64 and 2.56 .next , we consider a realistic case in which the detection of the atomic state is imperfect at behaves according to ( [ eq.err_spd ] ) , which corresponds e.g. to a flourescence measurement where the fluorescing state is detected with a finite efficiency .we fix the atomic detection efficiency to be .similarly , we take the homodyne detection efficiency to be . the result is shown in fig .[ fig.bipartite ] . under these assumptions, we find that for low spd efficiency , the best tolerance to coupling loss is obtained using the homodyning scheme , as in ref . . on the other hand , for a coupling efficiency below , which may well be the case in experiment , the tolerance to spd inefficiency is better in the displacement scheme .we remark that the spd efficiency required for violation for coupling efficiencies around is high , but that detectors reaching efficiencies in the -range have been demonstrated .-implementations based on displacement and homodyning respectively . for the homodyne detectors while the atoms are detected with efficiency . ]to probe nonlocality in a more general scenario we consider a measure of nonlocality based on the elitzur - popescu - rohrlich ( epr2 ) decomposition . for a given experiment , that is for a fixed input state and set of measurement basis , we can compute the joint probability distribution of the outcomes given the settings . if this distribution is nonlocal , then the experiment must necessarily violate some bell inequality .conversely , if it is local no bell inequality can be violated .any such can be decomposed into the convex mixture of a purely local and a purely nonlocal part where and are respectively a local and a non - signalling distribution .the minimal value of over all such possible decompositions provides an unambiguous quantification of the nonlocality , called the _nonlocal content _ of .the nonlocal content can be efficiently calculated by linear programming , and we make use of this to obtain critical efficiencies required for detection of nonlocality under various errors .however , let us first notice that the violation of any particular bell inequality allows one to obtain a nontrivial lower bound on the nonlocal content .indeed , for any ( linear ) bell inequality , the optimal decomposition of yields . since can not violate the bell inequality and is bounded by its maximal algebraic value , it follows that from here , it follows that any which saturates the maximal algebraic value , is automatically fully nonlocal , i.e. it has .this is precisely what happens to ghz states , which reach the algebraic maximum of the mermin inequality and are said to be fully nonlocal .we can now see that the w - state has a similar property for large .on the one hand , the algebraic maximum of ( [ eq.ineq ] ) is , since the only positive terms in the inequality are mutually exclusive events that maximally sum up to one . on the other hand , from ( [ eq.heaneybound ] ) the w - state violation approaches 1 exponentially fast , , as .thus , the nonlocal content of the w - state approaches unity .let us now turn to investigate the robustness of the nonlocality , by means of the polytope approach .we will look at the symmetric w - state ( [ eq.w ] ) , for the case of a single - photon implementation with imperfect photodetection as well as the case where losses are treated as a third outcome , corresponding e.g. to an implementation with polarisation qubits ., measurements with error behaviour given by ( [ eq.err_spd ] ) and ( [ eq.err_sym ] ) respectively .locality is violated above the solid lines .intersections of the solid with the dashed and dotted lines respectively give the critical spd efficiencies for the approximate implementation of sec .[ subsec : homo ] and for amplitude damping . ]  _ single - photon case ._ we map out the regions of locality when all parties perform imperfect measurements of and , with the behavior of the imperfections given by ( [ eq.err_spd ] ) and ( [ eq.err_sym ] ) respectively .the result is shown in fig .[ fig.poly_spd_hom ] , for , and 5 , and should be compared with fig .[ fig.wwsym ] .we note that the regions in the two plots are identical for , i.e. the wwwzb - criterion , based on full correlators only , yields the optimal solution in these cases . however , for , the region obtained from the full polytope , while qualitatively similar to that found taking only full correlators , yields lower critical efficiencies as might be expected in general .one special case of the ( [ eq.err_spd])+([eq.err_sym ] ) model is amplitude damping with ideal detectors , for which as indicated by the dashed line in fig .[ fig.poly_spd_hom ] . in the case , the threshold for violation agrees with ( [ eq.critampdamp ] ) obtained from the inequality ( [ eq.ineq ] ) , but higher allows for better tolerance than this inequality predicts .another case is the approximate implementation of given in sec .[ subsec : homo ] . in this setting , which we note falls in a region with only very modest improvement in critical efficiency up to .it is very interesting to note that within the polytope approach , when the required efficiencies for significantly decrease with increasing n and for example for we have ._ loss as 3rd outcome ._ in some cases , while inefficiencies may not be avoidable it can be possible to detect when a loss occurs .e.g. for measurements on optical polarisation qubits , a no - click event indicates that a photon was lost .for such a scenario , the no - click event can be treated as an additional outcome and by considering a polytope for distributions with three outcomes , the locality regions can be computed .we consider the ideal w - state ( [ eq.w ] ) and two lossy pauli measurements , the same for all parties . when the measurement are and , we find that locality is violated whenever for . in particular , in the limit , any non - zero is sufficient for violation .this is analogous to the result obtained by garbarino in the bipartite scenario .the same holds when the two bases are arbitrary , but the same for all parties . due to the limitations on our numerical algorithm , we were not able to go to .in this paper we have given a detailed analysis of the requirements to perform a nonlocality test using a single - photon w - state shared between multiple parties , and possibly entangled with an additional atomic system .we have focused on implementations using two measurement bases , of which one corresponds exactly to single - photon detection while the other requires and approximate implementation , e.g. via homodyning . through a povm model capturing a broad range of detection imperfections and losswe have numerically obtained the thresholds necessary for a loophole - free violation of local realism . in the case of atom - photon entanglement , comparing different numbers of parties , we have shown that the bipartite scenario yields the best tolerance to loss . for high atom - photon coupling efficiency ,the scheme considered very recently in ref . , using both homodyne and single - photon detectors , yields the lowest thresholds for the single - photon detection efficiency , while for lower coupling efficiency another scheme based on displacements and single - photon detection performs better .  with offset in the bell inequality of ref . we have demonstrated that for increasing , the local content of the w - state under ideal pauli measurements tends exponentially fast to zero , that is , the state becomes genuinely nonlocal .surprisingly , we could also show that despite of that , the robustness of the violation with respect to loss actually decreases rapidly with . taking a step up in terms of generality, we then considered the wwwzb - inequalities which provide a compact description of all tight bell inequalities formed only from full correlators . from thesewe again found that increasing does not necessarily lead to better loss thresholds .for example , assuming one approximate pauli measurement based on ideal homodyning and another based on imperfect single - photon detection , the best threshold is reached already for , giving . finally , we approached the w - state via the polytope of local distributions , covering all possible bell inequalities and thus taking another step up in terms of generality ( as well as numerical complexity ) . with this approach, we found that the loss thresholds for a single photon are similar to those obtained from wwwzb , though slightly better for . for implementations that permit the detection of loss events , such as those based on polarisation qubits , much better thresholdscan be obtained , with the threshold for one basis approaching 0 when the efficiency in the complementary basis is high .we note that in the cases where increasing leads to unchanged or worse loss thresholds , the scaling is not severe .this is a positive result which means that multipartite nonlocality tests become feasible with only slight improvements in detection efficiencies over those required for optimal . as a possible extension of the results presented here, one can consider nonlocality tests involving more than a single photon and that can also be feasible prepared with current technology . also to consider more general scenarios where each party is allowed to perform more than just two measurements can be a interesting approach to obtain less demanding detection efficiencies .* acknowledgements * we would like to acknowledge helpful discussions with a. leverrier , as well as with n. brunner , d. cavalcanti , and a. acn .r. c. was funded by q - essence project .j. b. was funded by the carlsberg foundation .

Abstract: recently much interest has been directed towards designing setups that achieve realistic loss thresholds for decisive tests of local realism , in particular in the optical regime . we analyse the feasibility of such bell tests based on a w - state shared between multiple parties , which can be realised for example by a single photon shared between spatial modes . we develop a general error model to obtain thresholds on the efficiencies required to violate local realism , and also consider two concrete optical measurement schemes .