University of Alberta
Probabilisti And-Or Tree Resolution
by
Magdalena Jankowska
A thesis submitted to the Fa ulty of Graduate Studies and Resear h in partial
ful�llment of the requirements for the degree of Master of S ien e.
Department of Computing S ien e
Edmonton, Alberta
Spring 2004
University of Alberta
Fa ulty of Graduate Studies and Resear h
The undersigned ertify that they have read, and re ommend to the Fa ulty of Grad-
uate Studies and Resear h for a eptan e, a thesis entitled Probabilisti And-Or
Tree Resolution submitted by Magdalena Jankowska in partial ful�llment of the
requirements for the degree of Master of S ien e.
Dr. Ryan Hayward (Supervisor)
Dr. Russell Greiner
Dr. Erhan Erkut
Date:
Abstra t
An and-or tree is a Boolean expression over a set of independent probabilisti tests,
ea h with an asso iated performan e ost and truth probability, su h that no test
appears more than on e. It an be represented by a tree in whi h leaf nodes are
tests and non-leaf nodes are either and or or. Probabilisti and-or tree resolution
(PAOTR) is the problem of �nding an algorithm for evaluating an and-or tree with
smallest expe ted ost. The omplexity of PAOTR is unknown.
Our main result is that a natural partial order of sibling tests in an and-or tree
yields a dynami programming algorithm for PAOTR whi h for trees with a bounded
number of non-leaf nodes runs in time polynomial in the input size. We also study
some generalizations of PAOTR and present some spe ial lasses of and-or trees for
whi h PAOTR is in P .
A knowledgements
I am espe ially grateful to my supervisor Ryan Hayward for his assistan e, en-
ouragement, and support. I thank him, Russell Greiner, and Omid Madani for
providing several ideas and onje tures throughout my work. I am very grateful to
Ryan Hayward, Russell Greiner, and Erhan Erkut for the omments on the thesis.
I thank Leah Ha kman and Martha Ledni ky, WISEST 2003 parti ipants, whose
experimentation with instan es of and-or trees resulted in helpful observations.
Contents
1 Introdu tion and Related Work 1
1.1 Introdu tion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 De�nitions and Notations . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Previous Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.3.1 NP-Hard Results . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.3.2 Appli ations of And-Or Trees . . . . . . . . . . . . . . . . . . 12
1.3.3 Depth-First Strategies . . . . . . . . . . . . . . . . . . . . . . 12
1.3.4 Balan ed And-Or Trees . . . . . . . . . . . . . . . . . . . . . 15
1.3.5 Linear Strategies . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.3.6 Pre onditioned Probabilisti Boolean Expressions . . . . . . . 18
1.3.7 Estimations of Su ess Probabilities . . . . . . . . . . . . . . 19
1.3.8 Non-Sto hasti And-Or Trees . . . . . . . . . . . . . . . . . . 20
2 Optimal Order of Sibling Tests 22
2.1 Siblings and Twins Lemma . . . . . . . . . . . . . . . . . . . . . . . 22
2.2 Dynami Programming Algorithm for PAOTR . . . . . . . . . . . . 27
2.3 Simplifying And-Or Trees Using the Twins Lemma . . . . . . . . . . 32
2.4 Parameter-Uniform Ladders . . . . . . . . . . . . . . . . . . . . . . . 34
2.5 Redu tion to Unit-Cost PAOTR . . . . . . . . . . . . . . . . . . . . 35
3 Conje tures and Counterexamples 45
3.1 Best Test of a Subtree . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.2 Prime Impli ants and Impli ates . . . . . . . . . . . . . . . . . . . . 46
3.3 Cograph Representation . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.4 Resolving Subtrees . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.5 Tests Ordering for Ladders . . . . . . . . . . . . . . . . . . . . . . . 52
4 Pre onditioned And-Or Trees 58
4.1 Smith's Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
4.2 1-Alternation And-Or Trees . . . . . . . . . . . . . . . . . . . . . . . 65
5 Con lusion 70
List of Figures
1.1 An and-or tree T
r
. An internal node with a horizontal bar (respe -
tively no bar) indi ates an and-node (respe tively or-node). For ea h
test, the ost and probability values are denoted respe tively by and
p. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Two strategies for the and-or tree T
r
. . . . . . . . . . . . . . . . . . 2
1.3 Illustration for the proof of Theorem 1. The DAG orresponding to
the formula P = (x
1
or :x
3
or :x
4
) and (x
1
or :x
2
or x
3
). . . . . 11
1.4 Depth-First Strategy. . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.5 DFA (Depth First Algorithm). . . . . . . . . . . . . . . . . . . . . . 15
1.6 Balan ed and-or trees T
1
and T
2
. Ea h test has unit ost and su ess
probability 0:7. T
1
is not uniform. T
2
is uniform. . . . . . . . . . . . 16
2.1 a) Sibling tests x
1
, x
2
and x
3
have R-ratio 0.4. The set W =
fx
1
; x
2
; x
3
g is an R- lass. b) Part of a strategy ontiguous on W
performing the tests from W . . . . . . . . . . . . . . . . . . . . . . . 23
2.2 Illustration for the proof of Theorem 10. For any node the up (respe -
tively down) ar denotes the true (respe tively false) ar . (a) The
optimal strategy S with substrategies S
+x
and S
�x
. (b) The strategy
S
0
�x
that may repla e the substrategy S
�x
. ( ) The optimal strategy
S (x! y). (d) The optimal strategy S
�
that ful�lls the onditions of
Theorem 10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.3 a) An and-or tree T
d
with sibling lasses L
1
; L
2
; L
3
. For ea h test the
ost, su ess probability and R-ratio values are denoted respe tively
by , p and R. b) The redu ed tree I = (0; 2; 1) obtained from T
d
and
redu ed trees obtained from I when b
2
su eeds and when b
2
fails. . 28
2.4 Dynami Programming Algorithm (DPA) for PAOTR. . . . . . . . . 30
2.5 An optimal strategy for the tree I shown in Figure 2.3. . . . . . . . . 32
2.6 A parameter-uniform and-or tree T
u
. Ea h test has ost one and
probability of su ess 0:2. W and V denote depth one subtrees. . . . 33
2.7 The unique optimal strategy S
opt
for the and-or tree T
u
where nodes
labeled by W and V denote evaluation of the orresponding subtrees. 33
2.8 An example of an and-or ladder. . . . . . . . . . . . . . . . . . . . . 34
2.9 a) A test x in an and-or tree. b) A subtree A repla ing the test x.
There is k tests in A, ea h with the same ost u and the same su ess
probability p. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.1 (a) An and-or tree T
with all osts unit. (b) The unique optimal
strategy for T
if p ( ) = 0:05, en oded by the �xed order of tests,
starting with a
1
. ( ) The unique optimal strategy for T
if p ( ) = 0:1,
starting with b
1
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.2 a) An and-or tree T
i
. All tests have probability of su ess 0:5. b)
The unique optimal strategy S
i
for T
i
. The tests performed on the
true path of S
i
are from two prime impli ants of T
i
. . . . . . . . . . 46
3.3 a) An and-or tree T
e
. All tests have probability of su ess 0:3. b)
The unique optimal strategy S
e
for T
e
. The tests performed on the
false path of S
e
are from two prime impli ates of T
e
. . . . . . . . . . 47
3.4 An and-or tree and the ograph representing the tree. . . . . . . . . 49
3.5 a) An and-or tree T
l
. All tests have unit ost. b) The unique optimal
strategy for T
e
. After the �rst performed test is true as well as after
the �rst test is false, the strategy leaves the subtree rooted at the
parent of the highest resolved node. . . . . . . . . . . . . . . . . . . 51
3.6 An and-or ladder. Test y is better than test x. . . . . . . . . . . . . 52
4.1 Pre onditioned or-trees. a) The test x has the required value true.
The tests y and z an be performed only after x su eeds. b) The test
x has the required value false. The tests y and z an be performed
only after x fails. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
4.2 Smith's Algorithm (SA). . . . . . . . . . . . . . . . . . . . . . . . . . 62
4.3 An example of using Smith's Algorithm. a) An algorithm's input:
pre onditioned or-tree T
p
. All tests have unit ost. b) The initial
blo ks built by SA. ) The blo ks after ombining blo ks x and y
together. ) The blo ks after ombining blo ks w and xy together.
These blo ks are maximal best blo ks for T . . . . . . . . . . . . . . 63
4.4 An illustration for the proof of Theorem 36; the substrategy S
0
. . . 67
4.5 a) A 1-alternation and-rooted pre onditioned and-or tree T
p
. The
required value of ea h internal node is true. All tests have unit
osts. b) The unique optimal strategy for the tree T
p
. This strategy
is not ontiguous on the maximal or-subtree. . . . . . . . . . . . . . 68
4.6 Two equivalent pre onditioned and-or trees A and A
0
. The root of A
is an or-node asso iated with a test x. The root of A
0
is an and-node
asso iated with the test x, A
0
ontains a depth one or-subtree rooted
at a degenerate node. . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
List of Tables
2.1 Parameters of redu ed trees obtained from the and-or tree T
d
from
Figure 2.3 with less than three tests. . . . . . . . . . . . . . . . . . . 31
4.1 Parameters of initial blo ks shown in Figure 4.3. . . . . . . . . . . . 64
Chapter 1
Introdu tion and Related Work
1.1 Introdu tion
Consider the following re ruitment situation at a hypotheti al ompany. Potential
employees must meet ertain psy hologi al standards and either be in good physi al
shape or pass both an Intelligen e Quotient (IQ) test and a knowledge test. Four
evaluation tests are prepared: a psy hologi al test P , a �tness test F , an IQ test I
and a knowledge test K. For ea h test the only possible output is either pass or fail.
A andidate will be hired if the Boolean expression e = P and [F or (I and K)℄
evaluates to true; see Figure 1.1. Ea h test has a performan e ost. For ea h test,
the ompany knows from its re ruiting history the probability that a andidate will
pass that test. There are several algorithms (strategies) the ompany may use to
c=1p=0.62
P
F
I Kc=1
p=0.15
c=1p=0.05
c=1p=0.76
i 2
i 3
i 1
Figure 1.1: An and-or tree T
r
. An internal node with a horizontal bar (respe tively
no bar) indi ates an and-node (respe tively or-node). For ea h test, the ost and
probability values are denoted respe tively by and p.
de ide whether to a ept a andidate. One su h strategy is the strategy S
1
shown
in Figure 1.2a: �rst administer the psy hologi al test; if the andidate fails this test
then return false (the andidate is reje ted), otherwise next administer the �tness
test; if the andidate passes this test then return true (the andidate is a epted),
otherwise administer the IQ test; if the andidate fails this test then return false,
otherwise administer the knowledge test; if the andidate passes this test then re-
turn true, otherwise return false. Another possible strategy the ompany might
1
FI
K
- -
-
++
PS1+
-
+
- +
-
+
-P
PK
I
-
--
-
++
F+
-+
-
+
-
+
-
+
-
S2
a) b)
Figure 1.2: Two strategies for the and-or tree T
r
.
use is the strategy S
2
shown in Figure 1.2b. The ompany wants to use a strategy
whi h has the minimum expe ted ost.
The aforementioned expression e is an example of a probabilisti Boolean expres-
sion, namely a Boolean expression with a ost and probability for ea h variable.
A probabilisti Boolean expression su h as e that an be represented by a tree in
whi h ea h internal node orresponds to a Boolean operator, either and or or, and
ea h leaf node orresponds to a test with true/false output is alled an and-or
tree. We will provide more formal de�nitions in Se tion 1.2. For a given probabilis-
ti Boolean expression (respe tively and-or tree), the problem of �nding a strategy
with the minimum expe ted ost over all strategies that evaluate the expression
orre tly is alled probabilisti Boolean expression resolution (PBER) (respe tively
probabilisti and-or tree resolution (PAOTR)).
As dis ussed above, the problem of de iding the value of a probabilisti Boolean
expression may arise in pra ti al appli ations. For many Boolean expressions, in-
luding all and-or trees, ea h (deterministi ) strategy has to query all variables in
the worst ase. For this reason the expe ted ost of a strategy is a reasonable per-
forman e measure. The obje tive is to �nd an algorithm that will on average ost
as little as possible.
In this thesis we present the results of our resear h on PAOTR and some of its
generalizations. PAOTR is a natural restri tion of PBER whi h is also interest-
ing from the omplexity point of view. PBER is NP -hard for general probabilisti
Boolean expressions; it is also NP -hard for the lass of probabilisti Boolean ex-
pressions in whi h no variable is negated. And-or trees onstitute a sub lass of the
latter lass, ontaining expressions in whi h ea h variable appears exa tly on e. The
omplexity of �nding an optimal strategy for and-or trees is unknown.
Previous to our work, a polynomial-time algorithms were known for depth one or
two and-or trees (see Se tion 1.3.3) and balan ed and-or trees (see Se tion 1.3.4).
We present a dynami programing algorithm to �nd an optimal strategy for and-or
trees whi h runs in time O(d
2
n
d
), where n is the number of leaves and d is the
number of internal nodes that are leaf-parents in a tree. Thus for trees with a
bounded number of internal nodes, the running time of our algorithm is polynomial
in the input size. The algorithm relies on the dis overed optimal relative order of
2
querying tests (variables) that are siblings in a tree. We also show that PAOTR for
some spe ial and-or trees is in P as well. We des ribe a way in whi h PAOTR for
trees with all osts unit an be used as an approximation for general PAOTR. We
also onsider a generalization of PBER, in whi h there are pre ondition onstraints
for tests. Among su h expressions, pre onditioned and-or trees generalize and-or
trees. We show that an extension of a previously known algorithm (Smith's Algo-
rithm) produ es an optimal strategy for a sub lass of pre onditioned and-or trees.
In this hapter we provide formal de�nitions (Se tion 1.2) and present a survey
of the previous results related to PBER (Se tion 1.3).
We state the key lemma des ribing the optimal relative order of performing
sibling tests in Se tion 2.1. In Se tion 2.2 we present the dynami programming
algorithm to �nd an optimal strategy for and-or trees. We show that PAOTR for
spe ial lasses of and-or trees is in P in Se tions 2.3 and 2.4. In Se tion 2.5 we
des ribe the redu tion that allows to approximate any and-or tree by a tree whose
all tests have the same ost.
In Chapter 3 we dis uss several natural onje tures with respe t to optimal
strategies for and-or trees. For some, we present ounterexamples; others remain
open. In Chapter 4 we study pre onditioned and-or trees and des ribe a general-
ization of Smith's Algorithm for �nding an optimal strategy for some su h trees. In
Chapter 5 we summarize our �ndings and dis uss open problems.
1.2 De�nitions and Notations
Sin e we use dire ted graphs to represent both Boolean expressions and algorithms
for their evaluation, we begin with the related de�nitions. We follow the de�nitions
from [5℄.
A dire ted graph G is an ordered pair (V;A), where V is a �nite set and A is a
set of ordered pairs of elements of V . Elements of V are alled nodes and elements
of A are alled ar s.
Let G = (V;A). For an ar a = (v; w) we say that a leaves v and enters w. The
out-degree of a node v is the number of the ar s that leave v; the in-degree of v is
the number of the ar s that enter v. A subgraph of G indu ed by a set V
0
� V is
the dire ted graph G
0
= (V
0
; A
0
), where A
0
= f(v; w) 2 A : v; w 2 V
0
g. A path of
length k from v to w in G is a sequen e of nodes (v
0
; v
1
; : : : ; v
k
), k � 0 su h that
v
0
= v, v
k
= w and for i = 1; 2; : : : ; k (v
i�1
; v
i
) 2 A. The ar s of the path are the
ar s (v
i�1
; v
i
), i = 1; 2; : : : ; k. A node w is rea hable from v if there is a path from
v to w. A path (v
0
; v
1
; : : : ; v
k
) is a y le if v
0
= v
k
and k � 1. If there is no y le in
G, G is a y li and is alled a DAG (dire ted a y li graph). In a DAG, for ea h
ar (v; w) we all w a hild node of v and v a parent node of w. A node of a DAG
that has in-degree zero (respe tively out-degree zero) is alled a sour e (respe tively
sink).
Let us now de�ne formally a spe ial kind of dire ted a y li graph alled a
dire ted rooted tree. This on ept is often referred to elsewhere as simply a rooted
tree; we add the term \dire ted" to emphasize that this is in fa t a dire ted graph.
De�nition 1 A dire ted graph T = (V;A) is a dire ted tree rooted at a node r
if
3
i) V = frg and A = ;, or
ii) V = frg [ V
1
[ V
2
[ : : : [ V
k
, A = f(r; r
1
); (r; r
2
); : : : ; (r; r
k
)g [A
1
[A
2
[ : : : [
A
k
, k � 1, where frg; V
1
; V
2
; : : : ; V
k
are disjoint sets and T
1
= (V
1
; A
1
); T
2
=
(V
2
; A
2
); : : : ; T
k
= (V
k
; A
k
) are dire ted trees rooted respe tively at nodes r
1
; r
2
;
: : : ; r
k
.
A graph G is a dire ted rooted tree if there is a node r su h that G is a dire ted
tree rooted at r. The graphs shown in Figures 1.1 and 1.2 are examples of dire ted
rooted trees.
Let T = (V;A) be a dire ted tree rooted at r. We all r the root of T . Two
nodes with the same parent node are siblings. A node with out-degree zero is a leaf ;
a node with positive out-degree is internal. A (full) binary tree is a dire ted rooted
tree in whi h ea h internal node has out-degree two. The depth of a node v is the
length of the path from the root r to v. The depth of the tree T is the maximum
depth of a node, over all nodes of T .
Ea h node rea hable from v is alled a su essor of v; ea h node from whi h v is
rea hable is alled a prede essor of v. Noti e that ea h node is both a su essor and
a prede essor of itself. Observe that the subgraph of T indu ed by all su essors of
some node v is a dire ted tree rooted at v.
De�nition 2 A subtree of a dire ted rooted tree T is a subgraph of T indu ed by
all su essors of some node of T .
A subtree rooted at a hild node of r is alled an immediate subtree of T and a hild
subtree of r; the node r is alled the parent node of its hild subtrees.
For a dire ted tree T = (V;A) rooted at r with jV j > 1, there is a unique set of
dire ted rooted trees T
1
; T
2
; : : : ; T
k
that ful�lls ondition ii) of De�nition 1, namely
the set of immediate subtrees of T . Together with the root, this set spe i�es T . For
a node r and a �nite set of dire ted rooted trees , we use
hr;i (1.1)
to denote the dire ted tree rooted at r and with the set of immediate subtrees .
A probabilisti Boolean expression is a Boolean expression over a set of proba-
bilisti tests, ea h of whi h has an asso iated ost and truth probability; we assume
that osts are non-negative.
We say that a test su eeds if it has the value (the out ome) true, otherwise we
say that the test fails. By performing a test we mean determining its value.
For any test x of a probabilisti Boolean expression, (x) denotes the ost of
performing x, p (x) denotes the probability of su ess of x, and �p (x) = 1 � p (x)
denotes the probability of failure of x. We will on o asion use the symbols
x
, p
x
,
�p
x
to denote (x), p(x), �p(x) respe tively.
Consider a set of tests D = fx
1
; x
2
; : : : ; x
k
g. A setting of tests x
1
; x
2
; : : : ; x
k
is an assignment of Boolean values (true or false) for the tests, that is a ve tor
� = (v(x
1
); v(x
2
); : : : ; v(x
k
)) where, for i � k, v(x
i
) is a Boolean value of the test
x
i
. The probability p (�) of a setting � is the probability that for ea h i � k the
test x
i
has the value v(x
i
).
4
The tests x
1
; x
2
; : : : ; x
k
are independent if for any subset D
0
= fy
1
; y
2
; : : : ; y
l
g �
D and any setting � = (v(y
1
); v(y
2
); : : : ; v(y
l
)) of the tests from D
0
p (�) =
l
Y
i=1
p
v(y
i
)
; (1.2)
where
p
v(y
i
)
=
(
p(y
i
) if v(y
i
) is true;
�p(y
i
) if v(y
i
) is false:
(1.3)
De�nition 3 A strategy for a probabilisti Boolean expression e is a binary tree
S su h that ea h internal node is labeled by a test from e, ea h leaf node is labeled
either true or false, and for ea h internal node v of S, one of the ar s leaving v
is labeled true and the other is labeled false.
Whenever we represent a strategy graphi ally, we draw the tree so that ar s point
to the right, and we use the symbols + and � to denote respe tively the labels true
and false. See Figure 1.2.
As de�ned above, a strategy represents an algorithm for al ulating (not ne es-
sary orre tly) the value of the expression, for any setting of tests; the algorithm
performs tests sequentially, and the sele tion of ea h subsequent test is based on the
values of the previous tests. A leaf node of S represents the return by the algorithm
of the value equal to the leaf label as the value of the input expression. The �rst
test performed by the algorithm is the test that labels the root r of S. Depending
on the value of this test, one of ar s leaving r (the one labeled by this value) is
followed; the hild subtree of r entered by this ar represents the further a tions of
the algorithm. For example the tree shown in Figure 1.2a represents an algorithm
that starts with performing the test P . If the value of P is false, the algorithm
returns the value false, otherwise the algorithm performs the test F .
Whenever it does not ause any onfusion, we use the word \strategy" to denote
both a tree and its asso iated algorithm. For example, we use alternatively the
equivalent phrases \the root of the strategy S is labeled by the test x" and \the
strategy S starts with performing the test x".
If in a strategy (tree) a path P ontains a node labeled by a test x then we say
that x is performed on P . If P ontains also a node labeled by a test y and this node
has smaller depth than the node labeled by x, we say that y is performed before x
on P .
Let P = (v
0
; v
1
; : : : ; v
k
) with k � 0 be a path from the root v
0
of S to a leaf node
v
k
. A setting � orresponds to P if for any i < k, the value in � of the test x
i
that
labels the node v
i
is equal to the label of the ar (v
i
; v
i+1
). Observe that any setting
orresponds to exa tly one root-to-leaf path, and several settings may orrespond
to one root-to-leaf path. For example, the settings �
1
= (F�; I+; P�;K+) and
�
2
= (F�; I+; P�;K�), orrespond to the same root-to-leaf path of the strategy
S
2
shown in Figure 1.2b.
A strategy S for a probabilisti expression e is orre t if for any root-to-leaf path
P of S, the value of e under any setting that orresponds to P is the same as the
label of the leaf of P .
5
Considering a strategy as an algorithm, orre tness of the strategy means just
that the algorithm al ulates orre tly the value of a probabilisti Boolean expression
for any setting of tests.
The ost of a strategy S under a setting � is the sum of osts of all tests performed
on the root-to-leaf path of S to whi h � orresponds. For example, the ost of the
strategy S
2
shown in Figure 1.2b under both the above given settings �
1
and �
2
is
(F ) + (I) + (P ). We denote by
�
(S) the ost of S under a setting �.
The expe ted ost C (S) of a strategy S for an expression e is the average ost
of the strategy S over all settings of the tests of e:
C (S) =
X
�2Settings(e)
p (�)
�
(S) ; (1.4)
where the sum is taken over all settings of the tests of e and p (�) is the probability
of the setting �.
The expe ted ost is the measure of the performan e of a strategy we are on-
erned with in this thesis.
De�nition 4 A orre t strategy S for a probabilisti Boolean expression e is opti-
mal for e if S has the minimum expe ted ost among all orre t strategies for e,
that is if for any orre t strategy S
0
for e it holds that C (S) � C (S
0
).
Probabilisti Boolean expression resolution (PBER) is the problem of �nding an
optimal strategy for a given probabilisti Boolean expression. For a given proba-
bilisti Boolean expression e, the optimal resolution ost is the expe ted ost of an
optimal strategy for e.
Several internal nodes of a strategy an be labeled with the same test; see for
example strategy S
2
of Figure 1.2b. Noti e though that for any setting of tests,
performing the same test more than on e always yields the same value, while in-
reasing unne essarily the ost of the strategy under this setting (unless the ost of
the test is zero, in whi h ase performing the test does not in uen e the ost of the
strategy under this setting). More formally, if two nodes of one root-to-leaf path
P of the strategy are labeled by the same test x, then either there is no setting
that orresponds to P (be ause two ar s of P that leave the nodes labeled by x are
labeled by di�erent values) or removing one node labeled by x does not hange the
set of the settings that orrespond to the path without in reasing the ost of the
strategy under any of these settings. We all a strategy nonredundant if on any
root-to-leaf path of the strategy no two nodes are labeled with the same test. We
an restri t our attention to su h strategies, be ause for any probabilisti Boolean
expression there is an optimal nonredundant strategy.
In this thesis we will on entrate on a spe ial ase of a probabilisti Boolean
expression, whi h we de�ne formally in terms of labeled dire ted rooted trees with
spe ial features.
De�nition 5 A rooted dire ted tree T = hr;i with labeled nodes and a Boolean
value is an and-or tree if one of the following onditions is ful�lled:
6
� is empty, r is labeled by a probabilisti test with given non-negative ost and
su ess probability and the Boolean value of T is equal to the value of the test,
or
� any tree T
0
2 has labeled nodes and a Boolean value so that it is an and-or
tree, the tests that label all leaves of all trees in are distin t and independent,
and
{ either r is labeled and and the value of T is true if and only if the value
of ea h tree from is true, or
{ r is labeled or and the value of T is true if and only if the value of at
least one tree from is true.
We draw and-or trees so that ar s point downward. The and-labeled nodes
(respe tively the or-labeled nodes) are denoted by a horizontal bar (respe tively no
horizontal bar) below the nodes. See for example the and-or tree in Figure 1.1.
Obviously, an and-or tree T de�nes a probabilisti Boolean expression (obtained
re ursively by joining the expressions for subtrees by the logi operators and or or
depending on the label of the root), with the same Boolean value as the value of
T . We identify an and-or tree with the expression it represents. The strategy for
an and-or tree is the strategy for the asso iated probabilisti Boolean expression.
Probabilisti and-or tree resolution (PAOTR) is the problem of �nding an optimal
strategy for an and-or tree.
A Boolean fun tion that orresponds to an and-or tree (that is the fun tion
that for any setting of tests returns the Boolean value of the and-or tree) is alled a
read-on e fun tion, be ause it an be expressed by a formula in whi h ea h variable
appears exa tly on e. Observe that any fun tion that an be expressed by su h a
formula, orresponds to an and-or tree.
Sin e all leaf nodes of an and-or tree are labeled by distin t tests, we identify
tests with leaf nodes. Therefore we say that a test x is a leaf of T meaning that x
labels a leaf of T .
We require that tests of an and-or tree are independent, otherwise we ould
onvert an arbitrary probabilisti Boolean expression (not ne essary with read-on e
property) to an and-or tree with dependent tests by repla ing any two o urren es of
the same variable (or o urren es of the variable and its negation) by two separate
variables that in any setting must have the same value (or must have opposite
values).
A strategy to evaluate an and-or tree an be viewed as a sear h through the
tree in order to �nd any subset of leaf nodes with required value that suÆ es to
determine the value of the entire tree. There may be several su h subsets. This
model of sear h is alled satis� ing sear h by Simon and Kadane in [25℄, where the
notion of PAOTR �rst appears.
An and-or tree is stri tly alternating if there is no ar (v; w) in T su h that v
and w are both labeled and or both labeled or. For any and-or tree there exist
an equivalent stri tly alternating one. This is be ause for any T
1
= hr
1
;
1
i, T
2
=
hr
2
;
2
i su h that T
2
2
1
and the labels of r
1
and r
2
are identi al (both and or
both or), T
1
is true if and only if T
0
1
= hr
1
;
1
� fT
2
g [
2
i is true. Therefore,
without loss of generality, we may assume that and-or trees are stri tly alternating.
7
Observe also that for any and-or tree we an �nd an equivalent one in whi h all
internal nodes have out-degree at least two. If T
1
= hr
1
; fT
2
gi, then T
1
is true if
and only if T
2
is true.
By ollapsing we mean repla ing an and-or tree by an equivalent one that is
stri tly alternating and in whi h all internal nodes have out-degree at least two.
We say that a subtree U of an and-or tree resolves its parent node if the value
of U alone determines the value of the tree rooted at the parent node of U , namely
if either U has value true and its parent node is or or U has value false and its
parent node is and.
For a given tree T the redu ed tree T
0
obtained by performing some tests from
T is the tree obtained from T by removing all subtrees whose values have been de-
termined by the values of the performed tests. The empty redu ed tree is obtained
when the value of the entire tree T has been determined.
We now present a few formulae to al ulate the expe ted ost of a nonredundant
strategy. For an internal node v of a strategy, let x
v
denote the test that labels the
node v. For a leaf node v, let x
v
denote its label (true or false) and let (x
v
) = 0.
Let P = (v
0
; v
1
; : : : ; v
k
) with k � 0, be a path of a nonredundant strategy. We
de�ne the ost (P ) of a path P as the sum of osts of the tests performed on P
(P ) =
k
X
i=0
(x
v
i
) (1.5)
and the probability p (P ) of a path P as the produ t of the probabilities of the
orresponding values of the tests performed on P
p (P ) =
(
1 if k = 0,
Q
k�1
i=0
p
v
i
if k � 1,
(1.6)
where
p
v
i
=
(
p(x
v
i
) if the ar (v
i
; v
i+1
) is labeled true;
�p(x
v
i
) if the ar (v
i
; v
i+1
) is labeled false:
(1.7)
The sum of the probabilities of all settings that orrespond to one root-to-leaf
path of a nonredundant strategy is equal to the probability of this path. Therefore
we have the following expression for the expe ted ost of a nonredundant strategy
S:
C(S) =
X
P2RootToLeafPaths(S)
p(P ) (P ); (1.8)
where the sum is taken over all root-to-leaf paths of S.
It follows from (1.8) by indu tion on the number of nodes in a strategy that the
following expression holds for a nonredundant strategy S:
C(S) =
X
v2InternalNodes(S)
p(P
v
) (x
v
); (1.9)
where the sum is taken over all internal nodes of S and P
v
is the path from the root
of S to the node v.
Again by indu tion on the number of nodes in a strategy it follows that the
following re ursive formula omputes the expe ted ost C(�):
8
For any leaf node v (labeled true or false) of a strategy,
C (v) = 0: (1.10)
For any (sub)strategy S
w
rooted at an internal node w,
C (S
w
) = (x
w
) + p (x
w
)� C (S
w+
) + �p (x
w
)�C (S
w�
) ; (1.11)
where x
w
is the test that labels the root node w and S
w+
and S
w�
are the hild
subtrees of w whose root nodes the respe tive true and false ar s enter.
We will use the following notation to des ribe strategies: For strategies S
1
, S
2
and a test x
x : + (S
1
) ;� (S
2
) (1.12)
denotes the strategy whose root is labeled x and whose hild subtrees of the root,
entered by true and false ar s are respe tively S
1
and S
2
.
For a strategy S that has disjoint substrategies S
1
; : : : ; S
m
, m � 1, and for
strategies S
0
1
; : : : ; S
0
m
S
�
S
1
/ S
0
1
; : : : ; S
m
/ S
0
m
�
(1.13)
denotes the strategy that is obtained from the strategy S by repla ing the subtree
S
k
by the tree S
0
k
for ea h k = 1; 2; : : : ;m.
If an and-or tree ontains tests that have ost zero, then there is an optimal
strategy for the tree that �rst performs in an arbitrary order all 0- ost tests. This
means that the problem of al ulating the optimal strategy for a tree that has some
tests with the ost zero redu es to the problem of �nding the optimal strategy for the
and-or tree obtained after performing all 0- ost tests. For this reason, we assume
from now on that all and-or tree tests have stri tly positive osts.
For any and-or tree T and any test x from T there is a Boolean value v su h
that after determining that x has the value v the redu ed tree still ontains all tests
other than x. From this it follows that that every orre t strategy for an and-or
tree performs in the worst ase all the tests from the tree (that is it ontains a
root-to-leaf path whose nodes are labeled by all tests).
De ision problems are problems for whi h the only possible solutions are the
answers \yes" or \no". The de ision version of PBER is the following problem:
Given a probabilisti Boolean expression e and a nonnegative real number B, is
there a orre t strategy for e with the expe ted ost at most B? The lass P is
the lass of de ision problems that are solvable in time polynomial in the size of
their inputs. The lass NP is the lass of de ision problems for whi h there exist
a \ erti� ate" that allows to verify the answer \yes" for problem's inputs, in time
polynomial in the input's size. A problem from NP is NP - omplete if any problem
from NP an be redu ed to it in polynomial time, whi h means that if an NP -
omplete problem an be solved in polynomial time, any problem from NP an. A
problem � is NP -hard, if there is an NP - omplete problem that an be redu ed to
� in polynomial time. See [7, 18℄ for introdu tion to the omplexity theory.
9
1.3 Previous Work
1.3.1 NP-Hard Results
Our interest in PAOTR, the restri tion of PBER to and-or trees, is motivated by
the fa t that for some more general lasses of probabilisti Boolean expressions the
problem is NP -hard.
First onsider PBER for arbitrary probabilisti Boolean expressions. Let P be
a Boolean formula and let e
P
be the asso iated probabilisti Boolean expression,
onstru ted by assigning an arbitrary probability and an arbitrary positive ost to
ea h variable. Now onsider the probabilisti Boolean expression e = (x and e
P
),
where x is a single test with positive ost. If P is unsatis�able, then so is e and
the optimal strategy for e has expe ted ost zero, sin e it suÆ es to return false
without performing any test. If P is satis�able, then any orre t strategy for e has
the expe ted ost greater than zero, sin e we will have to perform at least one test
(e is satis�able but may evaluate to false for example if x fails). It follows from
this observation and from the NP - ompleteness of the satis�ability problem [7℄ that
PBER is NP -hard.
A natural restri tion of PBER is to \positive" expressions, namely those that
do not in lude negated variables (thus are always satis�able). Su h expressions an
be represented as and-or dire ted a y li graphs; an and-or DAG is a DAG with
only one sour e whi h is alled the root, and su h that ea h sink is a probabilisti
test, ea h node that is not a sink is an or-node or an and-node. The value of an
or-node (respe tively and-node) is the value of logi al or (respe tively and) of its
hild nodes' values. The value of the root is the value of the entire expression.
PBER for and-or DAGs is still NP -hard as we now show. Our proof follows
by introdu ing sto hasti ity into the onstru tion presented in [22℄ for a di�erent
and-or stru ture problem.
The de ision version of PBER for and-or DAG is the following problem: Given
an and-or DAG D and a positive real number B, is there a strategy to evaluate D
with expe ted ost at most B?
Theorem 1 PBER for and-or DAGs is NP -hard, even if all test have unit osts.
Proof: Consider the 3-SAT problem: Given a Boolean formula P that is the and of
m lauses, ea h of whi h is the or of exa tly three distin t literals (that is variables
or their negations), is P satis�able?
3-SAT is NP - omplete [7℄. We will show that 3-SAT an be polynomially re-
du ed to PBER for and-or DAG.
For a given instan e of 3-SAT let C
1
; C
2
; : : : ; C
m
be the lauses in the formula P
and let x
1
; x
2
; : : : ; x
n
be all variables from P . Now onstru t the and-or DAG D in
the following way: The root of D is an and-node. It hasm+n hild or-nodes: nodes
C
1
; C
2
; :::; C
m
orrespond to the lauses of P while nodes x
1
; x
2
; : : : ; x
n
orrespond
to the variables from P . Ea h or-node x
i
has exa tly two distin t hild nodes:
the tests x
T
i
and x
F
i
, orresponding to the respe tive values true and false of the
variable x
i
. Ea h test has the ost 1 and the su ess probability q =
�
1�
1
2n
�
1
2n+1
.
These are all the nodes of D. Ea h or-node C
j
has exa tly 3 hild nodes: if the
lause C
j
ontains the literal x
i
, the test x
T
i
is a hild of the node, if the lause C
j
10
ontains the literal :x
i
, the test x
F
i
is a hild of the node. Figure 1.3 presents an
example of su h a onstru tion.
1x 2x 3x 4x1C 2C
1xT 1xF 2xT 2xF 3xT 3xF 4xT 4xF
Figure 1.3: Illustration for the proof of Theorem 1. The DAG orresponding to the
formula P = (x
1
or :x
3
or :x
4
) and (x
1
or :x
2
or x
3
).
We an onstru t su h an and-or DAG in polynomial time. Now we will show
that P is satis�able if and only if there is a strategy for D with expe ted ost at
most n+
1
2
.
For any orre t strategy the single root-to-leaf path of the strategy that in ludes
only true ar s will be alled the true path. Noti e that the true path of any orre t
strategy has to in lude at least n internal nodes, be ause we have to perform at
least one hild test of any x
i
node to on lude that the value of D is true.
We will �rst prove the following laim:
Claim: A orre t strategy S for D has the expe ted ost at most n+
1
2
if and
only if the true path of S ontains exa tly n internal nodes.
Proof of Claim: Let Q be the true path of a strategy S and let k be the number of
the internal nodes of Q, k � n. Thus the ost of the path Q is k and the probability
of Q is q
k
. Noti e that the ost of any other root-to-leaf path of S is at most 2n
and at least 1.
Assume that k = n. Then we obtain the following upper bound on the expe ted
ost of S:
C(S) � q
n
n+ (1� q
n
) 2n = n (2� q
n
) =
= n
"
2�
�
1�
1
2n
�
n
2n+1
#
< n
�
2�
�
1�
1
2n
��
= n+
1
2
:
Now assume that k > n. In this ase we have the following lower bound on the
expe ted ost of S:
C(S) � q
k
k +
�
1� q
k
�
1 = q
k
(k � 1) + 1 � q
k
n+ 1 =
= n
�
1�
1
2n
�
k
2n+1
+ 1 > n
�
1�
1
2n
�
+ 1 = n+
1
2
:
2
11
Now we an �nish the proof, by means of the following equivalent statements,
for whi h it is not diÆ ult to see that (i) , (ii), (ii) , (iii), (iii) , (iv), and, by
the above Claim, (iv), (v):
(i) P is satis�able.
(ii) There is a truth assignment � for P su h that for any lause C
j
there is at
least one literal that has the value true under �.
(iii) There is a set W of tests from D, jW j = n, su h that for any i one and only
one of x
T
i
and x
F
i
belongs to W and any node C
j
has at least one hild in W .
(iv) There is a orre t strategy for D whose true path ontains exa tly n internal
nodes.
(v) There is a orre t strategy for D with the expe ted ost at most n+
1
2
. 2
And-or trees onstitute a proper sub lass of and-or DAGs. It is unknown
whether PBER for and-or trees (namely PAOTR) is in P . Previous to our work,
polynomial-time algorithms have been known for spe ial lasses of and-or trees,
namely for and-or trees with depth one or two (see Se tion 1.3.3) and for balan ed
and-or trees (see Se tion 1.3.4).
In this work we prove that PAOTR for the lass of and-or trees with bounded
number of internal nodes, as well as for some spe ial lasses of trees whose all tests
have identi al ost and identi al probability, is in P .
1.3.2 Appli ations of And-Or Trees
Previously, various appli ations of PAOTR have been presented. They in lude:
s reening andidates for a ertain position [6℄, sele ting ategories at a quiz show
[6℄, gold mining [6, 8, 25℄, sele ting problem-solving methods by simple ontrol
systems [1℄, performing inferen es in expert systems [10, 26℄, sele ting tests for
medi al diagnosis [11℄, and food testing [12℄.
And-or trees have also been studied as game-trees [14, 19, 20, 27℄. A min-max
tree is a dire ted rooted tree whose leaf nodes are assigned some values and internal
nodes either are labeled max and evaluate to the maximum value of their hild
nodes, or are labeled min and evaluate to the minimum value of their hild nodes.
Observe that and-or trees are spe ial ases of min-max trees restri ted to values 0
(false) and 1 (true). In this ontext an and-or tree represents all possible plays
of a two-player game. Consider an or-rooted tree. Call the �rst player OR, the
se ond player AND. Any leaf node represents a terminal position in the game, that
is win (true) or loss (false) of OR player. Any or-node (respe tively and-node)
represents a position in whi h it is the OR player's (respe tively AND player's) turn
to move. Ea h root-to-leaf path orresponds to one omplete play of the game.
Observe that the tree evaluates to true (win) if and only if the OR player an for e
a win.
1.3.3 Depth-First Strategies
Natural strategies to onsider for evaluating and-or trees are those that evaluate
hild subtrees of a node until the value of the node is determined. We all su h
strategies depth-�rst.
12
De�nition 6 A strategy S for an and-or tree T is depth-�rst if for any subtree
U of T and any root-to-leaf path P of S, whenever a test x from U is performed on
P , no test from outside U is performed on P until the value of U is determined.
Depth-First Strategy(and-or tree T)
(1) If T is a single test x
(2) Perform x
(3) Return value of x
(4) Else
(5) Take some order U
�
1
; U
�
2
; : : : ; U
�
k
of immediate subtrees of T
(7) i := 0
(8) Repeat
(9) i := i+ 1
(10) ChildV alue := Depth-First Strategy (U
�
i
)
(11) Until value of T is determined
(12) Return value of T
(13) End Else
Figure 1.4: Depth-First Strategy.
Noti e that in Figure 1.2 the strategy S
1
is depth-�rst, but the strategy S
2
is
not: after test I is performed, S
2
\jumps" to test P before the value of the node i
3
is determined.
The pseudo- ode of the algorithm represented by a depth-�rst strategy is pre-
sented in Figure 1.4. If the root of an and-or tree T is or, the value of T is
determined when any of its immediate subtrees evaluates to true or when all of
them evaluate to false. For a tree T rooted at an and-node, the strategy stops
evaluating subtrees if any of them has value false.
In other words, for any internal node a depth-�rst strategy re ursively evaluates
hild subtrees until one of them resolves its parent node or all are evaluated. It is
now only ne essary to �nd for ea h internal node the best order of evaluating its
hild subtrees.
For depth one and-or trees the best su h order was des ribed by Simon and
Kadane [25℄. Noti e that for su h trees any orre t strategy is depth-�rst: it is
suÆ ient to perform one test after another until any of them resolves its parent
node or all are performed.
Theorem 2 [25℄ Let T be a depth one and-or tree and let x
1
; x
2
; : : : ; x
k
be leaf
nodes (tests) of T . An optimal strategy for T performs one test after another, until
the value of T is determined, in the order x
�
1
; x
�
2
; : : : ; x
�
k
su h that for i < k,
p
r
(
x
�
i
)
(
x
�
i
)
�
p
r
(
x
�
i+1
)
(
x
�
i+1
)
, where p
r
(x
i
) is the probability that x
i
resolves its parent node,
namely
p
r
(x
i
) =
(
p(x
i
) if the root of T is or,
�p(x
i
) if the root of T is and.
13
Proof Let x
�
1
; x
�
2
; : : : ; x
�
k
be the order of performing the tests by an optimal
strategy S. Assume that this order violates the ondition of the theorem, that is
there is at least one index l < k su h that
p
r
(
x
�
l
)
(
x
�
l
)
<
p
r
(
x
�
l+1
)
(
x
�
l+1
)
. We will show that if
we swit h the tests x
�
l
and x
�
l+1
, the expe ted ost of the resulting strategy is not
greater than the expe ted ost of S. Thus we an ontinue, if ne essary, to swit h
tests until the resulting strategy, still optimal, ful�lls the ondition of the theorem.
Let P
i
be the probability of a path from the root of S to the node labeled by x
i
,
that is P
1
= 1, and P
i
=
Q
i�1
j=1
�
1� p
r
�
x
�
j
��
for i > 1. The following expression
holds for the expe ted ost of S:
C(S) =
k
X
i=1
P
i
(x
�
i
) :
Now let S
0
be the strategy obtained from S by swit hing the tests x
�
l
and x
�
l+1
.
Then
C(S
0
)� C(S) = P
l
�
p
r
(x
�
l
)
�
x
�
l+1
�
� p
r
�
x
�
l+1
�
(x
�
l
)
�
� 0:
2
Natarajan [17℄ proposed an algorithm to �nd the best depth-�rst strategy for
deeper trees. The algorithm, alled DFA (Depth First Algorithm), al ulates the
best order of hild subtrees for any internal node of a tree. It is des ribed in
Figure 1.5.
Noti e that in any depth-�rst strategy, on e one de ides how to evaluate ea h
hild subtree of a given internal node, one an treat ea h su h subtree as a single
meta-test, whose e�e tive ost is equal to the expe ted ost of evaluating the sub-
tree and whose probability of su ess is equal to the probability that the subtree
evaluates to true. For a (sub)tree T , DFA al ulates the best order of immediate
subtrees of T (using the rule given in Theorem 2), the expe ted ost
DFA
(T ) of
the resulting depth-�rst strategy for T (as des ribed in the proof of Theorem 2) and
the probability p (T ) that T evaluates to true.
The time omplexity of DFA is O (N ln b), where N is the total number of nodes
in a tree and b is the maximum out-degree of internal nodes (be ause the time spent
at a node is the time required to order that node's hildren).
The next theorem follows by indu tion on the depth of an and-or tree, with the
base ase provided by Theorem 2.
Theorem 3 [12℄ For any and-or tree T , the depth-�rst strategy produ ed by DFA
has minimum expe ted ost among all depth-�rst strategies for T .
Greiner, Hayward and Molloy [12℄ proved that algorithm DFA produ es an op-
timal strategy for depth-two and-or trees. Combined with Theorem 2 that gives us
the following theorem.
Theorem 4 [12℄ DFA produ es an optimal strategy for and-or trees with depth one
or two.
14
DFA(and-or tree T)
(1) If T is a single test x
(2) Return ( (x) ; p (x))
(3) Else
(4) For ea h immediate subtree U
i
of T, i � k
(5) (
DFA
(U
i
) ; p (U
i
)) := DFA (U
i
)
(6) p
r
(U
i
) :=
(
p (U
i
) if the root of T is or
1� p (U
i
) if the root of T is and
(7) End For
(8) Find an order U
�
1
; U
�
2
; : : : ; U
�
k
of immediate subtrees of T
su h that
p
r
(
U
�
i
)
DFA
(
U
�
i
)
�
p
r
(
U
�
i+1
)
DFA
(
U
�
i+1
)
for i < k
(9)
DFA
(T ) :=
DFA
(U
�
1
) +
P
k
i=2
DFA
(U
�
i
)
Q
i�1
j=1
�
1� p
r
�
U
�
j
��
(10) p (T ) :=
(
1�
Q
k
i=1
(1� p (U
i
)) if the root of T is or
Q
k
i=1
p (U
i
) if the root of T is and
(11) Return (
DFA
(T ) ; p (T ))
(12) End Else
Figure 1.5: DFA (Depth First Algorithm).
However, algorithm DFA does not always produ e an optimal strategy for deeper
trees. The best depth-�rst strategy may be suboptimal for and-or trees with depth
three, even if all tests have unit osts. For example, the unique optimal strategy for
the tree T
r
from Figure 1.1 is the strategy S
2
shown in Figure 1.2b, whi h is not
depth-�rst.
Noti e that for a unit- ost and-or tree with n tests, assuming that probabilities
of tests are greater than zero and less than one, the minimum possible expe ted ost
of a strategy is 1 and the maximum is n. Thus no strategy an have expe ted ost
more than n times higher than the expe ted ost of the optimal strategy. Greiner,
Hayward and Molloy showed that DFA may produ e an extremely ostly strategy:
Theorem 5 [12℄ There are unit- ost and-or trees with n tests for whi h the best
depth-�rst strategy has expe ted ost �
�
n
1�o(1)
�
times higher than the optimal res-
olution ost.
1.3.4 Balan ed And-Or Trees
And-or trees with a uniform stru ture have been studied extensively in the ontext
of game-trees.
De�nition 7
� An and-or tree T is parameter-uniform if all tests of T have unit osts and
the same probability of su ess.
15
� An and-or tree T is balan ed if T is parameter-uniform, and all nodes of T
with the same depth have equal out-degree.
� An and-or tree T is uniform if T is balan ed, and all internal nodes of T
have equal out-degree.
Figure 1.6 presents two balan ed and-or trees, among whi h the and-or tree T
1
is not uniform whereas the and-or tree T
2
is uniform.
1T
2T
Figure 1.6: Balan ed and-or trees T
1
and T
2
. Ea h test has unit ost and su ess
probability 0:7. T
1
is not uniform. T
2
is uniform.
Noti e that for an internal node of a balan ed tree, all hild subtrees are indistin-
guishable. Thus any depth-�rst strategy for a balan ed tree has the same expe ted
ost.
Pearl studied asymptoti properties of uniform trees. The following are his re-
sults [19, 20℄ related to a spe i� value of su ess probability of tests that onstitutes
a signi� ant threshold.
Let U(d; b; p) denote an or-rooted uniform and-or tree, with depth equal to
d = 2k, for integer k � 0, out-degree of the internal nodes equal to b and the su ess
probability of tests equal to p.
Let �
b
be the positive root of the equation x
b
+ x � 1 = 0. If the probability
of su ess of tests is �
b
, the tree U(d; b; �
b
) evaluates to true with the probability
�
b
, for any depth d. Moreover, in the limit as d goes to 1, the probability that
U(d; b; p) has value true is 0 for all p < �
b
and 1 for all p > �
b
.
16
The threshold value �
b
is also signi� ant with respe t to the expe ted ost of a
depth-�rst strategy. Let
DFA
(U(d; b; p)) denote the expe ted ost of any depth-�rst
strategy for U(d; b; p). For test probabilities �
b
and any depth d:
DFA
(U(d; b; �
b
)) =
�
�
b
1� �
b
�
d
> b
d
2
:
Also, for any p 6= �
v
it holds that
lim
d!1
[
DFA
(U(d; b; p))℄
1
d
= b
1
2
:
Noti e that one always has to perform at least b
d
2
tests to determine the value
of a tree U(d; b; p). Thus the above result indi ates that for test su ess probability
di�erent than �
b
the depth-�rst strategy is asymptoti ally optimal for deep uniform
trees.
Tarsi [27℄ proved the optimality of the depth-�rst strategy for �nite depth, ar-
bitrary probability and more general lass of trees.
Theorem 6 [27℄ For any balan ed and-or tree, any depth-�rst strategy is optimal.
In a sense, a depth-�rst strategy for an and-or tree is a spe ial variant of the
ommonly used �-� pruning sear h for evaluating min-max game trees (the des rip-
tion of the sear h an be found in [21℄, Se tion 5.4). In fa t, the optimality of a
depth-�rst strategy for balan ed and-or trees allows to establish the asymptoti
optimality of �-� algorithm for ontinuous-valued min-max trees as the tree depth
approa hes in�nity [27, 20℄.
Karp and Zhang [14℄ studied uniform trees U(d; b; p) for the ase when p =
�
b
. They showed that the ost of a depth-�rst strategy for su h trees is likely to
on entrate around the expe ted ost
�
�
b
1��
b
�
d
and that the standard deviation for
the ost of the strategy is of the same order as the expe ted ost with respe t to the
depth d of a tree.
1.3.5 Linear Strategies
Noti e that the strategy S
1
from Figure 1.2 always performs the tests in the relative
order: P; F; I;K, where a test is skipped if its value is not needed after performing
previous tests. We all su h strategies linear.
De�nition 8 A strategy S for an and-or tree T is linear if there is a total order
< on the set of all tests from T su h that for any two di�erent tests x and y su h
that y < x, x is not performed before y on any root-to-leaf path of S.
Linear strategies are of interest be ause they an be expressed very eÆ iently;
it is not known whether optimal strategies an be expressed using spa e polynomial
in the size of an and-or tree.
Depth-�rst strategies are linear. Greiner, Hayward and Molloy [12℄ showed that
the best depth-�rst strategy for some trees may be arbitrarily worse then the best
linear strategy; the ratio is as bad as the one given in Theorem 5. Moreover, the
best linear strategy an be signi� antly worse than the optimal one:
Theorem 7 [12℄ There are unit- ost and-or trees with n tests for whi h the best
linear strategy has the expe ted ost �
�
n
1
3
�o(1)
�
times higher than the optimal res-
olution ost.
17
1.3.6 Pre onditioned Probabilisti Boolean Expressions
There is a more general framework in whi h expressions over probabilisti tests and
their resolution have been studied by many resear hers. In this framework, for ea h
probabilisti test we are given not only non-negative ost and probability of su ess
but also pre onditions in terms of other tests that need to be performed and return
required values before the given test an be queried.
Some su h expressions an be regarded as and-or trees with osts and proba-
bilities asso iated with internal nodes as well as leaf nodes. For example, onsider
the situation in the re ruiting pro ess des ribed in Se tion 1.1 when the �tness test,
the IQ test and the knowledge test may be administrated only if some additional
single s reening test has been performed and passed by the andidate. In this ase
we may onsider the node i
2
of Figure 1.1 as a probabilisti test, and all tests from
the subtree rooted at the node i
2
may be performed only after this s reening test
has su eeded.
By a pre onditioned and-or dire ted a y li graph we mean a dire ted a y li
graph with only one sour e, alled the root node, and su h that ea h node of the
graph is a distin t, independent probabilisti test with a given non-negative ost
and su ess probability. Ea h node that is not a sink is either an or-node or an
and-node. Any or-node and and-node is asso iated with a \required value" (true
or false): its hild tests an be performed only after the test itself has been queried
and returned this required value. The value of a node that has out-degree zero is just
the output of the test. If the output of the test that is an or-node (respe tively and-
node) is its required value, then the node evaluates to the logi al or (respe tively
and) of its hild nodes' values, otherwise the value of the node is the output of the
test. The value of a pre onditioned and-or DAG is the value of its root node.
In our example with the single s reening test asso iated with the node i
2
in the
tree T
r
in Figure 1.1, the required value of that node is true. If the s reening test is
passed by the andidate, the value of i
2
is the logi al or of the values of the nodes
i
3
and F . If the andidate fails this test, the value of i
2
is false.
A pre onditioned and-or DAG that is a dire ted rooted tree is alled a pre on-
ditioned and-or tree.
The optimal strategy for a pre onditioned DAG is de�ned in the same way as
for a probabilisti Boolean expression, with the restri tion that on any root-to-leaf
path of a orre t strategy, the pre eden e onstraints of tests must be ful�lled.
Noti e that a dire ted path in a pre onditioned and-or DAG does not ne essar-
ily alternate between or-nodes and and-nodes: we annot ollapse a pre onditioned
and-or DAG that ontains an ar whose ends are both or or and. By a pre on-
ditioned or-DAG (respe tively pre onditioned or-tree) we mean a pre onditioned
and-or DAG (respe tively tree) with no and-node.
Positive Boolean expressions (des ribed in Se tion 1.3.1) are spe ial ases of
pre onditioned and-or DAGs, and and-or trees are spe ial ases of pre onditioned
and-or trees, namely su h that all tests asso iated with or-nodes and and-nodes
have the ost zero, the required value true, and the probability of su ess one (thus
one an \rea h" any sink node on zero ost and with probability one). Thus the
negative results we stated so far hold also for pre onditioned and-or DAGs/trees.
In parti ular, it is NP -hard to �nd an optimal strategy for general pre onditioned
and-or DAGs, and the best depth-�rst or linear strategy may perform very badly
18
on some pre onditioned and-or trees.
Garey [6℄ and Simon and Kadane [25℄ studied pre onditioned or-DAGs with
required values false for any or-node (that means that whenever any test su eeds,
the entire expression evaluates to true). Garey [6℄ proposed an O
�
n
2
�
algorithm
to �nd an optimal strategy for trees of this type, where n is the number of tests.
Simon and Kadane [25℄ extended this approa h to deal with dire ted a y li graphs.
The algorithm identi�es so- alled \maximal indivisible blo ks", that is sets of tests
that are performed together by an optimal strategy.
This approa h was also used by Smith [26℄, who provided a polynomial-time
algorithm to �nd an optimal strategy for pre onditioned or-trees with required
value true for any or-node. The algorithm is des ribed in detail in Se tion 4.1.
Greiner [10℄ showed that �nding an optimal strategy for a pre onditioned or-
DAG with required values true for any or-node is NP - omplete, even if the prob-
ability of su ess of any or-node is one.
1.3.7 Estimations of Su ess Probabilities
An important diÆ ulty related to the su ess probabilities of tests arises in real
life problems. Though the assumption that one knows the osts of the tests is a
reasonable one, the exa t probability distribution of tests is usually not known. The
re ruiting ompany from our example in Se tion 1.1 may know exa tly how mu h
it has to pay for ea h test, but the probabilities of su ess an only be estimated
using data from previous re ruiting. Thus the optimal strategy al ulated for the
estimated probabilities may not be optimal for the a tual, unknown probability
distribution.
Barnett [1℄ onsidered and-or trees with only two tests. For su h trees he
studied how the expe ted ost of a strategy is sensitive to the approximation of tests'
parameters. His work indi ates that the in rease in the ost aused by a suboptimal
strategy, sele ted for the estimates instead of the exa t values of the parameters, is
bounded by the a ura y of these estimates. Thus reasonable approximations will
lead to reasonably good strategies.
Greiner and Orponen [11℄ addressed the problem of �nding suÆ iently good
probability estimations for tests of pre onditioned and-or trees within the probably
approximately orre t (PAC) model [28℄. If the su ess probabilities of tests are to
be estimated using the outputs of the tests for several trials, the authors showed how
many trials are required to get su h estimates that the optimal strategy al ulated
for them is with high on�den e approximately optimal for a tual probability values.
First let us on entrate on and-or trees. Assume that a tree ontains n tests
and the total ost of all tests is C. If for ea h test the su ess probability has been
estimated using
�
2
�
nC
"
�
2
ln
2n
Æ
�
results of performing the test, then the optimal
strategy for these estimations has with probability 1� Æ the expe ted ost within "
of the expe ted ost of the optimal strategy for the a tual probability distribution.
This required number of results an be olle ted while performing some (suboptimal)
strategies; sin e we always an use a strategy starting with any given test, we are
able to obtain the required number of results in time polynomial in n, C,
1
"
and
1
Æ
.
The situation is more ompli ated for pre onditioned and-or trees, be ause some
tests an only be performed if other tests have already returned required values, so
19
no strategy an assure performing some tests. Authors proposed for su h trees a
polynomial-time algorithm to �nd estimations of tests' probabilities a urate enough
so that the resulting best strategy is probably approximately optimal.
1.3.8 Non-Sto hasti And-Or Trees
And-or tree resolution has also been studied in frameworks in whi h values of tests
are not probabilisti variables. Sin e ea h deterministi strategy has to perform in
the worst ase all tests from the tree, so the simple ost of a strategy under the
worst setting of tests is of no use as a performan e measure.
A purely non-sto hasti model is proposed by Charikar et al. [2℄. For any setting
of tests of a given and-or tree there exists the \proof" of the value of the tree, that
is a set of tests su h that the partial setting restri ted to this set de ides about the
value of the tree. The ost of su h a proof is the sum of osts of the tests from the
set. The performan e ratio of a strategy under a given setting is the ratio of the
ost of the strategy under this setting to the minimum ost of a proof of the tree's
value under this setting. For example, onsider the and-or tree shown in Figure
1.1. The value of the tree for the setting � = (F�; I+; P�;K�) is false. The sets
fPg and fF;Kg are proofs of this value. The minimum ost proof is the set fPg
with the ost equal to 1. The ost of the strategy S
2
, shown in Figure 1.2, under
setting � is equal to 3. Thus the performan e ratio of S
2
under setting � is equal
to
3
1
= 3. The ompetitive ratio of a strategy is the maximum of the performan e
ratio over all settings of tests. The optimal strategy for an and-or tree is the one
that minimizes the ompetitive ratio.
The authors provide an eÆ ient algorithm to �nd an optimal strategy for and-or
trees. The algorithm relies on dis overed fun tions f
T
0
( ) and f
T
1
( ) whi h are lower
bounds on the ost that any strategy for an and-or tree T has to pay in the worst
ase in order to �nd a proof with ost of the value true and false respe tively.
These lower bound fun tions are used by the algorithm to balan e for ea h internal
node the ost spent while performing the tests from ea h of its hild subtrees. The
algorithm runs in time that is polynomial in the number of the nodes in the tree
and in the sum of the osts of all tests.
In the randomized model and-or trees are treated as �xed, non-sto hasti stru -
tures, but randomness is introdu ed into strategies.
A randomized strategy is a strategy that is allowed to perform a random ex-
periment and use the output of the experiment to de ide about a test to perform.
Formally, it is spe i�ed by a set of deterministi strategies and a probability dis-
tribution on this set. For a given setting of tests of an and-or tree, the ost of a
randomized strategy is the expe ted ost of using the strategy under this setting
(over all deterministi strategies). The worst ase ost of a randomized strategy is
the maximum ost of the strategy over all settings of tests. A orre t randomized
strategy is optimal if it has the lowest worst ase ost over all orre t randomized
strategies for a given and-or tree.
In randomized depth-�rst strategy the deterministi strategies with non-zero
probability are all depth-�rst: to evaluate a (sub)tree T the strategy evaluates
20
immediate subtrees of T until the value of T is determined, and the next subtree to
evaluate is sele ted at random.
Saks and Wigderson [23℄ showed that the randomized depth-�rst strategy is
optimal for uniform and-or trees. For uniform binary and-or trees with n tests this
strategy has the worst ase ost �
�
n
0:753:::
�
; re all that the worst ase ost of any
deterministi strategy is n.
It has been onje tured that this is the largest gap between the worst ase ost
of a deterministi and a randomized strategy for a unit- ost and-or tree. Heiman
and Wigderson [13℄ proved that the worst ase ost of any randomized strategy for
any unit- ost and-or tree with n tests is at least n
0:51
.
The randomized strategies mentioned above are always orre t (randomized al-
gorithms that never err are alled Las Vegas algorithms). We an also onsider
Monte Carlo strategies (Monte Carlo algorithms are randomized algorithms that
may err with some non-zero probability). By using the best Monte Carlo strategy
instead of a Las Vegas strategy one an never in rease the worst ase ost. Santha
[24℄ proved that for any unit- ost Boolean expression one an transform a Las Vegas
strategy into a Monte Carlo strategy with a slightly lower (by a fa tor linear in the
error probability) worst ase ost, however, for unit- ost and-or trees Monte Carlo
strategies annot a hieve any better improvement than this linear one.
21
Chapter 2
Optimal Order of Sibling Tests
2.1 Siblings and Twins Lemma
In the sear h for an optimal strategy one is led to the problem of eÆ iently sele ting
the �rst test to perform. A polynomial-time algorithm to �nd the �rst test of an
optimal strategy suÆ es to onstru t a polynomial-time algorithm to �nd an optimal
strategy: one just needs to perform the �rst test, redu e the tree a ordingly to its
output and re urse. A simple approa h to solving PAOTR is to try ea h test as
the �rst one by re ursive al ulation of the best strategy starting with ea h test
and then sele ting the one with the minimum expe ted ost. For an and-or tree
with n tests the running time of su h an algorithm is in O(n
n
). In the sear h for
properties that lead to eÆ ient �rst test sele tion, we investigated lo al stru tures of
and-or trees. This approa h led us to dis overing an optimal a-priori relative order
of sibling test. The order yields a dynami programming algorithm for �nding an
optimal strategy for and-or trees whi h we des ribe in Se tion 2.2. We also showed
that some siblings tests an be performed together by an optimal strategy. We now
present these results.
De�nition 9 For any test x of an and-or tree de�ne the R-ratio as:
R (x) =
p
r
(x)
(x)
; (2.1)
where (x) is the ost of x and p
r
(x) is the probability that x resolves its parent
node, namely
p
r
(x) =
(
p(x) if the parent node of x is or,
�p(x) if the parent node of x is and.
Noti e that the R-ratio is the same ratio that de�nes the best order of sibling
tests in a depth one and-or tree (Theorem 2).
De�nition 10 Tests x
1
and x
2
are R-equivalent if the parent node of x
1
and x
2
is the same and R (x
1
) = R (x
2
). An R- lass is an equivalen e lass with respe t
to the relation of being R-equivalent.
22
x2 x3
z
yc=1
p=0.5
c=1p=0.4
c=1p=0.4
c=2p=0.8
c=1p=0.3
a)
1x
b)+
-1x2x+
-3x+
-
Figure 2.1: a) Sibling tests x
1
, x
2
and x
3
have R-ratio 0.4. The setW = fx
1
; x
2
; x
3
g
is an R- lass. b) Part of a strategy ontiguous on W performing the tests from W .
De�nition 11 For an R- lass W a strategy S is ontiguous on W if on any root-
to-leaf path of S, whenever a test from W is performed, no test from outside W
is performed until a test from W resolves its parent node or all tests from W are
performed.
Figure 2.1 shows an example of an R- lass and illustrates the way of performing
tests from one R- lass by a strategy that is ontiguous on this lass.
Observation 8 Let tests x and y be siblings in an and-or tree T . Let S
xy
be a
orre t nonredundant strategy for T . If the parent node of x and y is or (respe -
tively and) and S
xy
= x : + (S
1
) ;�
�
y : + (S
1
) ;� (S
2
)
�
(respe tively S
xy
= x : +
�
y :
+ (S
2
) ;� (S
1
)
�
;� (S
1
)) for some substrategies S
1
, S
2
, and the strategy S
yx
is ob-
tained from S
xy
by swit hing the labels x and y, then S
yx
is nonredundant, orre t
for T , and
i) if R (y) > R (x) then S
yx
has lower expe ted ost than S
xy
,
ii) if R (y) = R (x) then S
yx
has the same expe ted ost as S
xy
.
Proof: The orre tness and nonredundan y of S
yx
follows from the orre tness and
nonredundan y of S
xy
. We will prove the relations (i) and (ii) assuming that the
parent node of x and y is an or-node. The proof for the other ase is symmetri .
For the expe ted ost of S
xy
we have:
C (S
xy
) = (x) + �p (x) (y) + �p (x) �p (y)C (S
2
) + [1� �p (x) �p (y)℄C (S
1
) :
Using a similar expression for C (S
yx
) we obtain
C (S
yx
)�C (S
xy
) = p (x) (y)� p (y) (x) :
The observation follows immediately from the de�nition of R(x) and R(y). 2
The following observation follows from Observation 8ii).
Observation 9 Let W be an R- lass in an and-or tree T and let S be a orre t,
nonredundant strategy for T that is ontiguous on W . Then any strategy obtain
from S by hanging order of performing tests from W has the same expe ted ost as
S has.
23
The following theorem spe i�es two onditions satis�ed by an optimal strategy.
The �rst ondition deals with the best order of performing sibling tests. The se ond
ondition spe i�es the optimal way of performing sibling tests that are R-equivalent.
Theorem 10 For any and-or tree there is an optimal strategy S su h that both of
the following onditions are satis�ed:
i) (Siblings Lemma) for any sibling tests x and y su h that R (y) > R (x), x
is not performed before y on any root-to-leaf path of S,
ii) (Twins Lemma) for any R- lass W , S is ontiguous on W .
Proof: We prove Theorem 10 by indu tion on the number of tests in an and-or tree.
The theorem holds for the base ase of a tree with only one test. Now assume that
it holds for any and-or tree that has fewer tests than the tree T has.
Let S be an optimal strategy for T . We may assume that it is nonredundant and
that all substrategies of S are optimal for the orresponding redu ed trees (be ause
if it is not, we an repla e it by su h an optimal strategy). Let x be the �rst test
performed by S. Assume that x is a hild of an or-node (the proof for the other
ase is symmetri ). Let S
+x
, S
�x
be the substrategies of S that are followed when
respe tively x is true, x is false. By indu tion, we may assume that S
+x
and S
�x
are ontiguous on any R- lass and preserve \the right order" of sibling tests (that
is never perform a sibling test with lower R-ratio before its sibling test with higher
R-ratio) of the orresponding redu ed trees.
Now assume that S does not ful�ll the onditions of the theorem. That means
that x has at least one sibling test with the same or higher R-ratio. We will show
that in this ase there is another optimal strategy that satis�es the onditions of the
theorem. To onstru t su h a strategy we will use the te hnique of hanging order
of parts of the original strategy.
Let Y be the set of all and only sibling tests of x with R-ratio higher than or
equal to R(x). Let y be the test with minimum R-ratio among all tests from Y .
By Observation 9 the order of performing tests from one R- lass is arbitrary in
a strategy that is ontiguous on this lass, thus we may assume that y is always
performed as the last test from Y by the substrategy S
�x
.
Now letM � 1 be the number of nodes of S
�x
labeled by test y, let S
y
1
; S
y
2
; : : : ;
S
y
M
be the subtrees of S
�x
rooted at nodes labeled by y, and for k = 1; 2; : : : ;M ,
let S
+y
k
, S
�y
k
be the substrategies of S
y
k
followed in the ase when respe tively y is
true, y is false. Also let S
r
denote the (possibly empty) part of S
�x
that ontains
all nodes outside S
y
1
; S
y
2
; : : : ; S
y
M
. See Figure 2.2a.
Consider the strategy S (x! y) = S
�x
(S
y
1
/ S
x
1
; : : : ; S
y
M
/ S
x
M
), where for
k = 1; 2; : : : ;M , S
x
k
= x : + (S
+y
k
) ;� (S
y
k
), shown in Figure 2.2 . In this strategy
we query x just before y. This strategy is obviously nonredundant. To show that it
is also orre t, we need to he k that for ea h leaf node L of S (x! y), the label of
L (true or false) is the orre t value of T for all setting of tests that orrespond
to the path P
L
from the root of S (x! y) to L. This obviously holds if P
L
ontains
a node labeled by test y, sin e in S there is the root-to-leaf path that di�ers from
P
L
only in the order of performing tests. Knowing that, we see that the label of
L is orre t if P
L
ontains node labeled by x and the ar labeled true that leaves
this node (be ause after x su eeds, we do exa tly the same that we do if x fails
24
S x
Sr ...
yS+yS
M
−yM
S+x
Sr ...
yS
S−yM
1−y
.
xS+yMy
S+yMS−yM
.
yS+yMx
S+yMS−yM
..
S+y1 S+y1S−y1
y x
a) b)
c) d)
S+x
yS+y1S−y1
S−x
S’−x
SrS*S(x−>y) Sr ..
xS+y1y
S+y1S−y1
Figure 2.2: Illustration for the proof of Theorem 10. For any node the up (re-
spe tively down) ar denotes the true (respe tively false) ar . (a) The optimal
strategy S with substrategies S
+x
and S
�x
. (b) The strategy S
0
�x
that may repla e
the substrategy S
�x
. ( ) The optimal strategy S (x! y). (d) The optimal strategy
S
�
that ful�lls the onditions of Theorem 10.
but its sibling test y su eeds). The only remaining ase is when neither x nor y is
performed on P
L
. Let �
L
be any setting of tests that orrespond to P
L
. In S we
follow the path identi al to P
L
after x fails. Thus for any �
L
in whi h x is false
the label of the leaf L is orre t. To see that it is also orre t if x is true, onsider
any two setting of tests �
1
and �
2
, that may di�er only in the values of x and y,
assume that in �
1
x is true, in �
2
x is false, y is true, and observe that the value
of the tree T is the same for �
1
and �
2
. Thus the orre tness of the label of the
leaf node of P
L
in this ase follows from the fa t that in S we do not test y on the
orresponding root-to-leaf path.
Now let S
�
be the strategy obtained by swit hing the labels x and y of the
neighbour nodes of the strategy S (x! y). See Figure 2.2d.
If the R- lass ontaining x in ludes also other tests, then it has to ontain y, so
S
�
is ontiguous on this lass. And S
�
is ontiguous on any R- lass that does not
in lude x; for the R- lass in luding y (if R(x) 6= R(y)) it follows from the fa t that
y is performed as the last test from Y . Also, sin e x is tested just after y, when y
25
is false, S
�
preserves the right order of sibling tests of T .
Observation 8 implies that S
�
is orre t and does not have higher expe ted ost
than S (x! y). Thus to omplete the proof it is enough to show that S (x! y) is
optimal.
Let C (S
r
) denote the expe ted ost of performing S
r
, that is the sum of osts
of tests labeling nodes of S
r
, fa tored by the probabilities of paths from the root of
S
�x
to a given node (if S
r
is empty, then C (S
r
) = 0). For any k, let p
y
k
be the
probability of the path from the root of S
�x
to the labeled by y root node of S
y
k
.
Then we an express the expe ted osts of S in the following way:
C (S) = (x) + p (x)C (S
+x
) + �p (x)C (S
�x
) ; (2.2)
where
C (S
�x
) = C (S
r
) +
M
X
k=1
p
y
k
[ (y) + p (y)C (S
+y
k
) + �p (y)C (S
�y
k
)℄ ; (2.3)
while for the expe ted ost of S (x! y) we have:
C (S (x! y)) = C (S
r
) +
M
X
k=1
�
p
y
k
h
(x) + p (x)C (S
+y
k
) +
+�p (x) [ (y) + p (y)C (S
+y
k
) + �p (y)C (S
�y
k
)℄
i
�
: (2.4)
Now assume, by way of ontradi tion, that S (x! y) has the higher expe ted
ost than S. Then using the notation D = C (S
r
) +
P
M
k=1
p
y
k
C (S
+y
k
) � C (S
+x
)
and P
r
= 1�
P
M
k=1
p
y
k
, we obtain
p (x)D > P
r
(x) :
Noti e that
P
M
k=1
p
y
k
is the total probability of rea hing any node labeled by y after
entering the strategy S
�x
, so P
r
� 0. That implies that D > 0, thus
p (x)
(x)
>
P
r
D
: (2.5)
We will show that it follows from (2.5) that we an repla e the substrategy S
�x
of the original strategy by a substrategy with stri tly lower expe ted ost, whi h
ontradi ts the optimality of S
�x
.
Consider the strategy S
0
�x
= y : + (S
+x
) ;� (S
�x
(S
y
1
/ S
�y
1
; : : : ; S
y
M
/ S
�y
M
))
shown in Figure 2.2b. Observe that S
0
�x
is nonredundant and orre t for the redu ed
tree obtained from T when x is false. We have the following expression for the
expe ted ost of S
0
�x
:
C
�
S
0
�x
�
= (y) + p (y)C (S
+x
) + �p (y)
"
C (S
r
) +
M
X
k=1
p
y
k
C (S
�y
k
)
#
: (2.6)
Using the same notation as previously we obtain
C (S
�x
)� C
�
S
0
�x
�
= p (y)D � P
r
(y) : (2.7)
26
But then from (2.5) and the fa t that
p (y)
(y)
�
p (x)
(x)
; (2.8)
it follows that C (S
�x
)� C
�
S
0
�x
�
> 0, ontradi tion.
2
2.2 Dynami Programming Algorithm for PAOTR
The ordering of sibling-tests des ribed by the Siblings Lemma allows us to onstru t
a dynami programing algorithm for PAOTR that runs in time O(d
2
n
d
), where n
is the number of leaves (tests) and d is the number of leaf-parents (that is nodes
that are parents of tests) in the input and-or tree. Thus the running time of the
algorithm is polynomial if the number of leaf-parents is bounded.
As shown in Se tion 1.1, for any and-or tree there is an equivalent one whose all
internal nodes have out-degree at least two. For su h trees the number of internal
nodes is of the same order as the number of leaf-parents, as we show in the following
observation.
Observation 11 Let T be an and-or tree whose all internal nodes have out-degree
at least two. Let d be the number of leaf-parents in T and let N be the number of
all internal nodes in T . Then N � d >
N
2
.
Proof: Let m be the number of all ar s leaving internal nodes that are not leaf-
parents. Sin e out-degree of ea h internal node is at least 2, so m � 2(N �d). Sin e
ea h su h ar enters a distin t internal node, di�erent than the root of the tree, so
m < N . It follows that d >
N
2
. 2
De�nition 12 A sibling- lass is a non-empty set of all leaf hildren of one inter-
nal node of an and-or tree.
For example the and-or tree T
d
shown in Figure 2.3a ontains three sibling- lasses:
L
1
= fa
1
; a
2
g, L
2
= fb
1
; b
2
; b
3
g and L
3
= f
1
;
2
g. The number of sibling- lasses of
an and-or tree is the number of leaf-parents in the tree. For an and-or tree T let
d be the number of leaf-parents in T and L
1
; L
2
; : : : ; L
d
be the sibling- lasses of T .
Assume that S is an optimal strategy for T that ful�lls the onditions of Theorem
10. While evaluating T using S, we gradually redu e our and-or tree (namely after
performing any test we obtain a new redu ed and-or tree to evaluate) until we
obtain the empty tree, at whi h point the evaluation of T is ompleted. Consider
any redu ed and-or tree I that we en ounter while using S. Assume that I still
ontains m
i
tests from the sibling- lass L
i
. If m
i
< jL
i
j, then the remaining tests
from L
i
were already performed. Sin e we always query tests with higher R-ratio
before sibling tests with lower R-ratio, the m
i
tests still present in I must have the
lowest R-ratios among all tests from L
i
.
That means that for any d-tuplet (m
1
;m
2
; :::;m
d
), 0 � m
i
� jL
i
j, there is only
one redu ed tree whi h we may en ounter that has exa tly m
i
tests from the set L
i
,
for any i: this tree ontains the m
i
tests with the lowest R-ratios among all tests
from L
i
. In this way we may identify a redu ed and-or tree with su h a d-tuplet.
27
1a 2a 1b 2b 3b
1c 2c
c=1p=0.5
c=2p=0.4
c=1p=0.6
c=2p=0.8
c=3p=0.6
c=1p=0.7
c=1p=0.5
R=0.7 R=0.5
R=0.2R=0.4R=0.6R=0.2R=0.5
1L 2L
3L
1i
2i
3i 4i
a)
I=(0,2,1)
2b 3b 2c
2b +
2b -
(0,0,0)
(0,1,1)
3b 2c
b)dT
Figure 2.3: a) An and-or tree T
d
with sibling lasses L
1
; L
2
; L
3
. For ea h test the
ost, su ess probability and R-ratio values are denoted respe tively by , p and R.
b) The redu ed tree I = (0; 2; 1) obtained from T
d
and redu ed trees obtained from
I when b
2
su eeds and when b
2
fails.
For example onsider the tree T
d
shown in Figure 2.3a. T
d
is represented by the
3-tuplet (2; 3; 2) while the 3-tuplet (0; 2; 1) orresponds to the redu ed tree I shown
in Figure 2.3b.
Thus there are (jL
1
j+ 1)� (jL
2
j+ 1)� : : :� (jL
d
j+ 1) di�erent redu ed trees to
onsider, in luding the original tree. This number is in O
�
n
d
�
where n =
P
d
i=1
jL
i
j
is the number of tests (leaf nodes) in T .
Noti e also that for any tree we need onsider only d tests in order to �nd the
�rst test to perform, namely a test with maximum R-ratio from ea h of d sibling-
lasses.
Assume that we are given a stru ture of internal nodes of an and-or tree T su h
that for ea h internal node we know its parent node as well as its internal hild
nodes, and ea h leaf-parent is asso iated with its sibling- lass. Assume also that
we are given a redu ed tree I obtained from T en oded by a d-tuplet. We shall
now dis uss how for some sibling lass L one an al ulate the d-tuplets I
+
L
and I
�
L
orresponding to the redu ed trees obtained from I when the test with maximum
R-ratio from L in I respe tively su eeds and fails.
Let x
L
be the test with maximum R-ratio from L in I. If the sum of the numbers
of tests in all sibling- lasses of I is one, then x
L
is the only test in the tree and I
+
L
as well as I
�
L
is the empty tree.
Otherwise we �nd the parent node of x
L
in ollapsed I. To do this we �rstly
need to �nd the last internal node v on the path from the root of T to the parent of
x
L
su h that the sum of the tests' number in the sibling- lasses inside the subtree
rooted at v is greater than one.
The parent node of x
L
is the last internal node w on the path from the root of
T to v su h that w has the same label (or/and) as v and w is the root of T , or w is
28
a hild node of the root of T , or the subtree rooted at the parent node of w ontains
at least one sibling- lass with non-zero number of tests outside the subtree rooted
at w.
Given the parent node w of x
L
in I we an easily modify the d-tuplet I in order
to obtain I
+
L
or I
�
L
. If x
L
resolves its parent w, the required modi� ation is setting
to zero the number of tests for ea h sibling- lass inside the subtree rooted at w.
Otherwise, the modi� ation is done by de rementing the number of tests from the
sibling- lass L by one.
Noti e that the operation of �nding the parent w as well as setting the tests'
numbers of the orresponding sibling- lasses to zero deal only with internal nodes
and sibling- lasses (not with parti ular tests) and an be performed in time linear
in the number of internal nodes, thus also linear in d.
Consider as an example the redu ed tree I = (0; 2; 1) obtained from the tree T
d
from Figure 2.3a. In I the test x
L
2
with maximum R-ratio in L
2
is b
2
. We want
to �nd I
+
L
2
and I
�
L
2
. Using the algorithm des ribed above we �rst �nd the node v
whi h is i
4
. Then we �nd the parent node w whi h is i
1
. The parent node i
1
is or.
If x
L
2
su eeds it resolves its parent node thus we need to set to 0 the number of
tests in all sibling- lasses inside the subtree rooted at i
1
. Thus I
+
L
2
= (0; 0; 0). If x
L
2
fails, we just need to de rement the number of tests in L
2
by one: I
�
L
2
= (0; 1; 1).
See Figure 2.3b.
We shall now des ribe Dynami Programing Algorithm (DPA) for PAOTR.
While performing the algorithm we enumerate all possible (jL
1
j+ 1)� (jL
2
j+ 1)�
: : : � (jL
d
j+ 1) redu ed trees and identify them with d-tuplets. In other words
we identify ea h redu ed tree with one entry in a d-dimensional matrix of the size
(jL
1
j+ 1) � (jL
2
j+ 1)� : : :� (jL
d
j+ 1). The tree (jL
1
j ; jL
2
j ; : : : ; jL
d
j) is the input
tree, ontaining all the tests, the tree (0; 0; : : : ; 0) is the empty tree indi ating that
nothing remains to evaluate.
For ea h tree I we store the following attributes:
Cost[I℄: the expe ted ost of the optimal strategy for I,
FirstTest[I℄: a �rst test performed by the optimal strategy for I,
TrueAr [I℄: the pointer to the redu ed tree obtained if the �rst test su eeds,
FalseAr [I℄: the pointer to the redu ed tree obtained if the �rst test fails.
On e these attributes are stored for ea h redu ed tree, an optimal strategy for the
input tree T is en oded. The strategy starts with performing the test FirstTest[T ℄
and then depending on the value of this test either TrueAr [T ℄ or FalseAr [T ℄ is
followed; the tree pointed by it is the redu ed tree that needs to be evaluated at this
point. The pro edure is arried on until the empty tree is rea hed: if it is rea hed
by a TrueAr , the value of the tree is true, otherwise its value is false.
The algorithm deals with redu ed trees in the order of the number of tests, start-
ing with the empty tree.
Dynami Programing Algorithm for PAOTR is presented in Figure 2.4. The
input and-or tree is stri tly alternating and su h that ea h internal node has out-
degree at least two. The tree is en oded by the set of its internal nodes, su h that
for ea h internal node we know its parent node and all internal nodes that are its
hildren. Moreover ea h leaf-parent is asso iated with the array of its leaf hildren.
29
DPA (and-or tree T)
Output: optimal strategy for T
(1) For ea h sibling- lass L of T
(2) order tests of L by ratio R
(3) End For
(4) For ea h tree I
(5) Cost[I℄:=1
(6) Cal ulate the number M of tests in I
(7) Add I to the list of trees with M tests
(8) End For
(9) Cost[empty tree℄:=0
(10) FirstTest[empty tree℄:=NIL
(11) For M = 1 to # of tests in T
(12) For ea h tree I with M tests
(13) For ea h sibling- lass L of T that is not empty in I
(14) x
L
:=test from L in I with maximum R
(15) I
+
L
:=tree obtained from I if x
L
su eeds
(16) I
�
L
:=tree obtained from I if x
L
fails
(17) C := (x
L
) + p (x
L
)�Cost
h
I
+
L
i
+ �p (x
L
)� Cost
h
I
�
L
i
(18) If C <Cost[I℄
(19) Cost[I℄ := C
(20) FirstTest[I℄ := x
L
(21) TrueAr [I℄ is pointed to I
+
L
(22) FalseAr [I℄ is pointed to I
�
L
(23) End If
(24) End For
(25) End For
(26) End For
Figure 2.4: Dynami Programming Algorithm (DPA) for PAOTR.
Theorem 12 DPA produ es an optimal strategy for and-or trees. The time om-
plexity of the algorithm is in O
�
d
2
n
d
�
and the spa e omplexity is in O
�
n
d
�
, where
n is the total number of tests (leaf nodes) of a tree and d is the number of leaf-parents
in a tree.
Proof: The orre tness of the algorithm follows from Theorem 10, as dis ussed
above. Sin e as shown above the total number of redu ed trees is in O
�
n
d
�
and we
store a onstant amount of data for ea h redu ed tree, the spa e omplexity is in
O
�
n
d
�
.
Lines (1)-(3) order tests inside ea h sibling lass, so the time required to perform
them is in O(n logn). Line (6) takes time O(d) and is alled on e for ea h redu ed
30
redu ed tree I Cost[I℄ FirstTest[I℄ TrueAr [I℄ FalseAr [I℄
points to points to
(0; 0; 0) 0 NIL NIL NIL
(0; 0; 1) 1
2
(0; 0; 0) (0; 0; 0)
(0; 1; 0) 3 b
3
(0; 0; 0) (0; 0; 0)
(1; 0; 0) 2 a
2
(0; 0; 0) (0; 0; 0)
(0; 0; 2) 1.3
1
(0; 0; 0) (0; 0; 1)
(0; 1; 1) 2.5
2
(0; 0; 0) (0; 1; 0)
(0; 2; 0) 2.6 b
2
(0; 0; 0) (0; 1; 0)
(1; 0; 1) 2
2
(0; 0; 0) (1; 0; 0)
(1; 1; 0) 3.2 a
2
(0; 1; 0) (0; 0; 0)
(2; 0; 0) 2 a
1
(0; 0; 0) (1; 0; 0)
Table 2.1: Parameters of redu ed trees obtained from the and-or tree T
d
from Figure
2.3 with less than three tests.
tree thus time required to perform lines (4)-(8) is in O(dn
d
).
We will show that time required by lines (11)-(26) is in O(d
2
n
d
) whi h ends the
proof. Loop (13) has d iterations and is alled on e for ea h of O
�
n
d
�
redu ed trees.
To omplete the proof we need to show that time required by the operations inside
this loop is in O(d). Sin e ea h parent node of a sibling- lass is asso iated with an
array of leaf hildren, ordered by R-ratio, it takes onstant time to �nd x
L
(line 14).
As we have shown before, we an al ulate I
+
L
or I
�
L
in time O(d) (lines (15) and
(16)). Also, sin e we identify trees with d-tuplets, we may �nd data for trees I
+
L
and I
�
L
(line 17) in O(d) time, as elements of a d-dimensional matrix. 2
The orollary below follows immediately from the previous theorem.
Corollary 13 Probabilisti and-or tree resolution for and-or trees with a bounded
number of internal nodes is in P .
As an example onsider again the and-or tree T
d
shown in Figure 2.3a. Assume
that we already pro essed all redu ed trees with less than three tests. The al ulated
parameters for ea h of these trees is given in Table 2.1. We now want to al ulate
the optimal strategy for the redu ed tree I = (0; 2; 1) with three tests; see Figure
2.3b. The sibling- lass L
1
is empty in I. Now onsider the sibling- lass L
2
. The
test x
L
2
with maximum R ratio from L
2
in I is the test b
2
and I
+
L
2
= (0; 0; 0),
I
�
L
2
= (0; 1; 1). Thus we now have
C = (b
2
) + p (b
2
) �Cost
h
I
+
L
2
i
+ �p (b
2
) � Cost
h
I
�
L
2
i
=
= 2 + 0:8 � 0 + 0:2 � 2:5 = 2:5: (2.9)
Thus we set Cost[I℄ to 2:5 and FirstTest[I℄ to b
2
, we point TrueAr [I℄ to (0; 0; 0)
and FalseAr [I℄ to (0; 1; 1). Now we pro eed to the sibling- lass L
3
. We have
x
L
3
=
2
and I
+
L
3
= (0; 0; 0), I
�
L
3
= (0; 2; 0). Thus
C = (
2
) + p (
2
) �Cost
h
I
+
L
3
i
+ �p (
2
) � Cost
h
I
�
L
3
i
=
= 1 + 0:5 � 0 + 0:5 � 2:6 = 2:3: (2.10)
31
Sin e this ost is lower than urrent Cost[I℄, we set Cost[I℄ to 2:3 and FirstTest[I℄
to
2
, we point TrueAr [I℄ to (0; 0; 0) and FalseAr [I℄ to (0; 2; 0). These parameters,
together with the parameters from Table 2.1, en ode the optimal strategy for the
redu ed tree I. This strategy is presented as a binary tree in Figure 2.5.
+
c2-
b2
-
+
-b3
-
++
++
Figure 2.5: An optimal strategy for the tree I shown in Figure 2.3.
2.3 Simplifying And-Or Trees Using the Twins Lemma
The Twins Lemma provides a way of simplifying an and-or tree. Sin e all tests from
an R- lass are performed together by an optimal strategy, it only matters whether
any of them resolves their ommon parent node. Thus we may repla e ea h R-
lass ontaining more than one test by a single meta-test with an e�e tive ost and
probability orresponding to performing all tests from the R- lass. By Observation
9 the order of performing the tests from the R- lass is arbitrary.
Simple al ulations yield the parameters of su h a meta-test.
Observation 14 Let W be an R- lass and let R be the R-ratio of the tests from
W . In sear hing for an optimal strategy we an repla e W by a single meta-test w
with the following parameters:
p (w) =
(
1�
Q
x2W
�p (x) if tests from W have an or-parent,
Q
x2W
p (x) if tests from W have an and-parent,
(2.11)
(w) =
8
>
<
>
:
P
x2W
(x) if R = 0,
p(w)
R
if R > 0 and tests from W have an or-parent,
1�p(w)
R
if R > 0 and tests from W have an and-parent.
(2.12)
The following observation follows immediately from the previous one.
Observation 15 The meta-test w repla ing an R- lass W has the same R-ratio as
tests from W .
The simpli� ation des ribed above allows us to prove that DFA produ es an
optimal strategy for depth three parameter-uniform and-or trees. Re all that an
and-or tree is parameter-uniform if all tests have unit ost and the same su ess
probability.
Observation 16 Let T be a depth three and-or tree su h that for ea h internal
node v of depth two, all tests that are hild nodes of v have the same R-ratio. Then
DFA produ es an optimal strategy for T .
32
a
b
} W
} V
Figure 2.6: A parameter-uniform and-or tree T
u
. Ea h test has ost one and prob-
ability of su ess 0:2. W and V denote depth one subtrees.
V
VW
b
-
--
-
++
a+
-+
-
+
-
+
-
+
-
Sopt
Figure 2.7: The unique optimal strategy S
opt
for the and-or tree T
u
where nodes
labeled by W and V denote evaluation of the orresponding subtrees.
Proof: By Theorem 3 DFA produ es a strategy with minimum expe ted ost among
all depth-�rst strategies. Thus it suÆ es to show that some optimal strategy for T
is depth-�rst.
Let T
0
be the simpli�ed tree obtained from T by repla ing ea h R- lass by a
single meta-test. Observe that in T
0
ea h internal node with depth two has only one
hild: a single meta-test. Thus T
0
ollapses to depth two. By Theorem 4 for any
depth two and-or tree there is an optimal depth-�rst strategy. If we evaluate entire
repla ed subtrees in pla e of meta-tests, the strategy is depth-�rst for T and by the
Twins Lemma is optimal for T . 2
The following theorem follows immediately from Observation 16.
Theorem 17 DFA produ es an optimal strategy for depth three parameter-uniform
and-or trees.
However, this property does not always hold for deeper parameter-uniform and-or
trees; there are depth 4 parameter-uniform and-or trees for whi h the best depth-
�rst strategy is not optimal. For example the strategy S
opt
in Figure 2.7 is the
unique optimal strategy for T
u
in Figure 2.6, but it is not depth-�rst.
33
2.4 Parameter-Uniform Ladders
In the previous se tion we have shown that PAOTR for parameter-uniform depth
three and-or trees an be solved with DFA. By Theorem 6 we also know that an
optimal strategy an be found eÆ iently for any parameter-uniform tree that is
balan ed.
In this se tion we present another parti ular sub lass of parameter-uniform
and-or trees for whi h the optimal strategy has a very simple des ription. PAOTR
for this type of trees is in P .
First let us state two observations; the �rst of these is an unpublished result due
to Greiner, Hayward, and Molloy.
Observation 18 Let T be an and-or tree and let x be a hild test of the root of T .
If a strategy S after performing the �rst test, performs x regardless of the value of
the �rst test, then there is a strategy starting with x whose expe ted ost is less than
or equal to the expe ted ost of S.
Proof: Let y be the �rst test performed by S. Assume that T is or-rooted;
the proof for the other ase is symmetri . Let S
+
be the substrategy followed
when y is true and x is false, let S
�
be the substrategy followed when y is
false and x false (if x is true, the value of T is true). The strategy S
0
=
x : +(true);� (y : + (S
+
) ;� (S
�
)) is nonredundant, orre t for T , and
C(S
0
)� C(S) = (x) + �p(x) (y) + �p(x)p(y)C(S
+
) + �p(x)�p(y)C(S
�
) +
� [ (y) + (x) + p(y)�p(x)C(S
+
) + �p(y)�p(x)C(S
�
)℄ =
= ��p(x) (y) � 0: (2.13)
2
Observation 19 Let T be an and-or tree whose root has a test hild x. If the
root of T is or (respe tively and) and for any test y in T p(y)= (y) � p(x)= (x)
(respe tively �p(y)= (y) � �p(x)= (x)), then there is an optimal strategy for T that
starts with performing x.
Proof: By indu tion on the number of the tests in T . The observation holds if
T has only one test. Now assume that the observation holds for any tree whi h has
fewer tests than T has.
Let S be an optimal strategy for T and assume that it starts with performing a
test y di�erent than x. By the Siblings Lemma and Twins Lemma we may assume
Figure 2.8: An example of an and-or ladder.
34
that S does not perform any sibling test of x before x, so y is not a hild of the root
of T . Sin e we may assume that ea h internal node of T has out-degree at least two,
that means that the redu ed trees obtained from T when y is true and y is false
both ontain x and have fewer tests than T . So by the indu tive assumption, after
testing y, S performs x, regardless of the value of y. But x is a hild of the root of
T , so by Observation 18 there is a strategy for T that has not higher expe ted ost
than S and starts with performing x. 2
The above observation generalizes an unpublished result of Omid Madani.
An and-or ladder is an and-or tree su h that ea h internal node is a parent of
at most one internal node. Figure 2.8 shows an example of an and-or ladder. From
the Observation 19 follows immediately that if all tests of an and-or ladder are
identi al, there is a very simple way of �nding an optimal strategy whi h we now
formalize.
Observation 20 For any parameter-uniform and-or ladder T there is an optimal
linear strategy S that performs tests \from the top to the bottom", that is that per-
forms �rst, in an arbitrary order, tests of depth one, and as long as the value of T
is not determined, after performing in an arbitrary order tests of depth k, performs
in an arbitrary order tests of depth k + 1.
2.5 Redu tion to Unit-Cost PAOTR
In Se tion 2.3 we explained how an and-or tree an be simpli�ed by repla ing an
R- lass by a single meta-test. On the other hand, for any test with ost greater than
one, we may onsider repla ing the test with a depth one subtree having identi al
(same probability) unit- ost tests. Noti e that if we ould �nd for ea h test from
the original tree an appropriate repla ement olle tion of identi al unit ost tests
su h that, for ea h original test, the repla ement subtree probability and evaluation
ost would equal the original leaf probability and ost, then by the Twins Lemma
an optimal strategy for the new unit- ost tree would have the same expe ted ost
as an optimal strategy for the original tree. Su h a repla ement subtree is shown
s hemati ally on Figure 2.9.
As we shall show, while it is not always possible to �nd a unit- ost tree that
yields su h an exa t orresponden e, by keeping suÆ ient pre ision it is possible
to obtain by su h repla ements a unit- ost tree whose optimal resolution ost is
arbitrarily lose to the optimal resolution ost of the original tree. We now des ribe
su h a redu tion in detail.
We start by onsidering depth one subtrees with identi al leaf nodes in a unit-
ost tree. Let u be the hosen unit of ost, that is the ost of ea h test in the
tree. Let A be a depth one subtree with k identi al leaf nodes and let p, �p be
the respe tive su ess, failure probability of ea h test from A. We will denote the
optimal resolution ost of A by C(A), the probability that A evaluates to true by
p(A), and the probability that A evaluates to false by �p(A).
If A is and-rooted then
p(A) = p
k
; (2.14)
35
x
1x 2x kx
jc(x )=ujp(x )=p
a) b)
} A. . .
Figure 2.9: a) A test x in an and-or tree. b) A subtree A repla ing the test x.
There is k tests in A, ea h with the same ost u and the same su ess probability p.
C(A) =
(
u
1�p
k
1�p
if p 6= 1;
uk if p = 1:
(2.15)
If A is or-rooted then
�p(A) = �p
k
; (2.16)
C(A) =
(
u
1��p
k
1��p
if p 6= 0;
uk if p = 0:
(2.17)
Now assume that we want to use the subtree A to repla e a test x with the ost
x
and the su ess probability p
x
. The ost of x expressed in units u is
x
=u. We
require that
x
=u > 1. whi h means that x is not just a unit- ost test (in whi h ase
there is no need for repla ing it).
We would like to obtain the exa t orresponden e between the test x and the
subtree A, so we require that p(A) = p
x
and C(A) =
x
. Observe, that it is not
possible if p
x
= 0 and A is and-rooted be ause we would need p(A) = 0, whi h
requires p = 0, but then we have C(A) = u (meaning that it is always enough to
perform just one test to evaluate A to false). Similarly, it is impossible to repla e
x by an or-rooted subtree if p
x
= 1.
Simple al ulations lead to the following expressions for k and p, yielding p(A) =
p
x
and C(A) =
x
.
For an and-rooted subtree A
k =
8
<
:
ln(p
x
)
ln
�
1�
1�p
x
x
=u
�
if 0 < p
x
< 1;
x
=u if p
x
= 1;
(2.18)
p = p
1=k
x
; (2.19)
whereas for an or-rooted subtree A
k =
8
<
:
ln(�p
x
)
ln
�
1�
1��p
x
x
=u
�
if 0 < p
x
< 1;
x
=u if p
x
= 0;
(2.20)
�p = �p
1=k
x
: (2.21)
36
Before we address the diÆ ulties related to the above onditions, let us investi-
gate the dependen y of the number k on p
x
and
x
=u.
As we shall show at the end of this se tion in Lemma 23, for an and-rooted
subtree k monotoni ally de reases from 1 to
x
=u as p
x
in reases from 0 to 1. By
symmetry, as p
x
in reases from 0 to 1, k for an or-rooted subtree in reases from
x
=u to 1, and the value of k for p
x
= 1=2 is the same for both kinds of subtrees.
Thus we an minimize k by repla ing x by an and-rooted subtree if p
x
� 1=2 and
by an or-rooted subtree if p
x
< 1=2. Then for a given
x
we have the maximum k
when p
x
= 1=2.
We shall show (Lemma 24) that if p
x
= 1=2 then k � 2 ln 2
x
u
< 1:4
x
u
. Therefore,
given our way of sele ting the root of the subtree, for an arbitrary probability p
x
it
holds that
k < 1:4
x
u
: (2.22)
If the onditions (2.18) and (2.19) for an and-rooted subtree or (2.20) and (2.21)
for an or-rooted subtree are satis�ed, then the subtree has exa tly the same ost
and probability of being true as the original test x. There are however two obvious
obsta les. Firstly, sin e k is the number of leaf nodes of A, k must be an integer.
Thus we have to round the value of k given by (2.18) or (2.20) to some integer k
0
.
Moreover, sin e the values of tests' probabilities (p
1=k
0
x
or 1� �p
1=k
0
x
) are not always
rational then assuming that we want to store and use these values as input to some
algorithms, we need to round them using �nite number of digits.
Therefore the exa t orresponden e between a test x and a repla ement subtree
A is not always possible to a hieve. But by hoosing the ost unit u small enough
and by keeping enough pre ision in probabilities of new tests, we an rea h an
arbitrary small error in the optimal resolution ost for the new tree, as des ribed in
the following theorem.
Theorem 21 Given an and-or tree T
�
with the optimal resolution ost C
�
and a
real number r, 0 < r < 1, there is a unit- ost and-or tree T
u
with optimal resolution
ost C
u
su h that C
�
(1� r) � C
u
� C
�
(1 + r).
For n being the number of tests in T ,
max
the maximum ost over all tests in T
and B the maximum number of digits used to represent a probability over all tests
in T , the onstru tion of T
u
runs in time polynomial in n, 1=r,
max
and B.
Moreover, for ea h leaf-parent of T
u
all its test hildren are identi al. If instead
of onstru ting all leaf nodes of T
u
we rather keep for ea h leaf-parent of T
u
the
number of its test hildren and the (uniform) su ess probability of ea h test, then
su h a onstru tion of T
u
runs in time polynomial in n, log(1=r), log(
max
) and B.
The theorem was stated by Omid Madani, with whom we ollaborated to prove
it.
We now des ribe the onstru tion of the unit- ost tree T
u
.
Let r be as stated in the theorem. For the original and-or tree T
�
let n be the
number of tests in T
�
, and for ea h test x of T
�
let p
x0
= min fp
x
; �p
x
g.
In the unit- ost and-or tree T
u
ea h test has ost u �
r
3
min
, where
min
is the
smallest ost of a test in T
�
. We onstru t T
u
by repla ing ea h test x of T
�
by a
depth one subtree A with k
0
identi al tests, su h that
i) if p
x
� 1=2, A is and-rooted, otherwise A is or-rooted,
37
ii) k
0
= bk , where k is given by (2.18) if A is and-rooted, and by (2.20) if A is
or-rooted,
iii) given p
0
= p
1=k
0
x
for an and-rooted A and �p
0
= �p
1=k
0
x
for an or-rooted A, the
su ess probability ~p of tests from an and-rooted A (respe tively the failure
probability
~
�p of tests from an or-rooted A) is obtained by rounding p
0
up
to ~p so that p
0
� ~p � p
0
(1 + ") (respe tively rounding �p
0
up to
~
�p so that
�p
0
�
~
�p � �p
0
(1 + ")), for any " satisfying " �
p
x0
r
4nk
0
.
Noti e that T
u
is not ne essarily stri tly alternating sin e we may repla e a test
hild of an or-node (respe tively and-node) by a or-rooted subtree (respe tively
and-rooted subtree).
Sin e k
0
� k� 1 �
x
u
� 1 �
x
3
min
r
� 1 � 2, ea h test of T
�
is repla ed by a depth
one subtree with at least two tests. Thus for ea h leaf-parent of T
u
, all its tests
hildren have the same probability. Now Theorem 21 follows immediately from the
theorem below.
Theorem 22 Let T
�
be an arbitrary and-or tree, C
�
the optimal resolution ost
of T
�
and 0 < r < 1. If T
u
is onstru ted as des ribed above, then for the optimal
resolution ost C
u
of T
u
we have C
�
(1 � r) � C
u
� C
�
(1 + r), and for ea h depth
one subtree repla ing a test x, the number of leaf nodes k
0
is O
�
x
r
�
, and the number
of signi� ant digits required to obtain the probability pre ision de�ned in (iii) is
O
�
log
�
n
x
p
x0
r
��
.
Proof: We will begin by proving the order of k
0
and of the number of required
signi� ant digits of probabilities.
Sin e k
0
= bk , then from (2.22) and the fa t that 1=u = O(1=r) it follows that
k
0
= O
�
x
r
�
.
For an and-rooted subtree, we round up the probability p
0
= p
1=k
0
x
to ~p and
require that ~p � p
0
(1 + ") = p
0
+ p
0
". So we need to keep a number of signi� ant
digits in order of log
�
1
p
0
"
�
, or
O
�
log
�
1
p
0
�
+ log
�
1
"
��
= O
�
1
k
0
log
�
1
p
x
�
+ log
�
4nk
0
p
x0
r
��
=
= O
�
log
�
n
x
p
x0
r
2
��
= O
�
log
�
n
x
p
x0
r
��
; (2.23)
where we used the fa t that O (log (1=p
x
)) = 1, sin e for an and-rooted subtree
p
x
� 1=2. The argument for an or-rooted subtree is symmetri .
We will now prove that the optimal resolution ost of T
u
is approximately the
same as of T
�
.
Consider a strategy S
�
for T
�
and the orresponding strategy S
u
for T
u
, that is
the strategy that in pla e of ea h test performed by S
�
evaluates the orresponding
depth 1 subtree of T
u
. We will show that for the expe ted osts of S
�
and S
u
the
following ondition is satis�ed:
C (S
�
) (1� r) � C (S
u
) � C (S
�
) (1 + r) ; (2.24)
38
from whi h, by the Twins Lemma, the desired relation between the optimal resolu-
tion osts follows. For the expe ted ost of S
�
we have:
C (S
�
) =
X
x2Tests(T
�
)
P
p
(x)
x
; (2.25)
where the sum is taken over all tests of the tree T
�
and P
p
(x) is the sum of proba-
bilities of all paths from the root of S
�
to nodes labeled by the test x.
If P
p
(A) is the sum of probabilities of all paths from the root of S
u
to nodes
labeled by the �rst test of a repla ement subtree A, then
C (S
u
) =
X
A2RepSubtrees(T
u
)
P
p
(A)C(A); (2.26)
where the sum is taken over all repla ement subtrees in T
u
.
Now assume that after the redu tion, for any subtree A of T
u
repla ing a test x,
the ost of evaluating A is perturbed at most by Æ
in omparison with
x
and the
values of the probability that A is true and false are perturbed at most by Æ
p
in
omparison with p
x
and �p
x
, respe tively, meaning:
x
(1� Æ
) � C(A) �
x
(1 + Æ
) ; (2.27)
p
x
(1� Æ
p
) � p(A) � p
x
(1 + Æ
p
) ; (2.28)
�p
x
(1� Æ
p
) � �p(A) � �p
x
(1 + Æ
p
) : (2.29)
Sin e ea h path from the root of strategy S
�
in ludes at most n nodes labeled by
tests of T
�
, we have for any subtree A repla ing a test x:
P
p
(x) (1� Æ
p
)
n
� P
p
(A) � P
p
(x) (1 + Æ
p
)
n
: (2.30)
This gives us the following relation between the expe ted osts of S
�
and S
u
:
C (S
�
) (1� Æ
p
)
n
(1� Æ
) � C (S
u
) � C (S
�
) (1 + Æ
p
)
n
(1 + Æ
) : (2.31)
If Æ
p
� r=4n, then (1 � Æ
p
)
n
� 1 � nÆ
p
� 1 � r=3 by Observation 27i, and
(1 + Æ
p
)
n
� 1 + r=3 by Observation 27ii. Thus if we have
Æ
p
� r=4n; (2.32)
Æ
� r=3; (2.33)
then
(1� Æ
p
)
n
(1� Æ
) � (1� r=3)
2
> 1� r; (2.34)
(1 + Æ
p
)
n
(1 + Æ
) � (1 + r=3)
2
< 1 + r: (2.35)
Therefore as long as the onditions (2.27), (2.28), (2.29) hold, with Æ
p
and Æ
satisfy-
ing (2.32) and (2.33), the desired relation (2.24) is ful�lled. We will now prove these
bounds for an and-rooted subtree. The ase of an or-rooted subtree is symmetri .
First let C
0
(A) be the ost of the subtree A if the onditions (i) and (ii) of the
redu tion are satis�ed, but the su ess probability of ea h test is equal to p
0
= p
1=k
0
x
,
that is it is not rounded to ~p. The subtree A has k
0
tests, k
0
= bk , where k is given
by (2.18). Thus k � k
0
� k � 1. If p
x
= 1 then p
0
= 1, C
0
(A) = uk
0
and k =
x
=u
39
so
x
� C
0
(A) � u (k � 1) =
x
� u. Lemma 25 implies that also for p
x
6= 1 we have
x
� u � C
0
(A) �
x
. Sin e u �
r
3
min
, it holds that
x
(1� r=3) � C
0
(A) �
x
: (2.36)
We now need to in orporate the e�e t of rounding the probability p
0
to ~p, a -
ording to the ondition (iii) of the redu tion. We have p
x
� 1=2 (A is and-rooted),
and p
x0
= �p
x
� 1=2.
For p
x
= 1 we have ~p = p
0
= 1, so C(A) = C
0
(A). Now assume
1
2
� p
x
< 1.
Observe that " �
p
x0
r
4nk
0
=
3p
x0
4nk
0
r
3
�
3
8nk
0
r
3
�
1
2(k
0
�1)
r
3
. Therefore we an use Lemma
26i and on lude that
C
0
(A) � C(A) � C
0
(A)(1 + r=3): (2.37)
From (2.37) and (2.36) it follows that
x
(1� r=3) � C(A) �
x
(1 + r=3) ; (2.38)
whi h means that (2.27) and (2.33) hold.
Now let us onsider the probability p(A) that A evaluates to true, p(A) = ~p
k
0
.
For p
x
= 1 we have ~p = 1 thus p(A) = 1 = p
x
. If
1
2
� p
x
< 1, it follows from Lemma
26ii and the bound " �
p
x0
r
4nk
0
=
p
x0
k
0
r
4n
that
p
x
� p(A) � p
x
�
1 +
r
4n
�
; (2.39)
�p
x
�
1�
r
4n
�
� �p(A) � �p
x
; (2.40)
so (2.28), (2.29) and (2.32) are satis�ed. 2
In the remainder of this se tion we present the proofs of the lemmas used above.
Lemma 23 If k(p; ) =
ln(p)
ln
(
1�
1�p
)
, where 0 < p < 1 and > 1, then k(p; ) is a
monotone fun tion of p, de reasing from 1 to as p in reases from 0 to 1.
Proof:
lim
p!0
ln(p)
ln
�
1�
1�p
�
=1: (2.41)
lim
p!1
ln (p)
ln
�
1�
1�p
x
�
= lim
p!1
(p)
�1
�
1�
1�p
�
�1
1
= : (2.42)
�k(p; )
�p
=
�
1�
1�p
�
ln
�
1�
1�p
�
� p ln(p)
p
�
1�
1�p
�
ln
2
�
1�
1�p
�
: (2.43)
The above derivative exists for 0 < p < 1 and > 1.
We will show that
�
1�
1�p
�
ln
�
1�
1�p
�
� p ln(p) < 0.
Let g(p; ) =
�
1�
1�p
�
ln
�
1�
1�p
�
. We will �rstly show that g(p; ) is a mono-
tone de reasing fun tion of .
�g(p; )
�
= ln
�
1�
1� p
�
+
1� p
(2.44)
40
and the above derivative exists for 0 < p < 1 and > 1.
For �1 < x < 1, ln (1� x) = �(x+
x
2
2
+
x
3
3
+ : : :), so for 0 < x < 1 ln (1� x) <
�x.
Sin e 0 <
1�p
<
1
< 1, so ln
�
1�
1�p
�
< �
1�p
. Thus:
�g(p; )
�
< 0: (2.45)
Moreover
lim
!1
g(p; ) = p ln p: (2.46)
Thus g(p; ) < p ln p and
�k(p; )
�p
< 0. 2
Lemma 24 For � 1,
ln(0:5)
ln
(
1�
0:5
)
� 2 ln 2 .
Proof: Let k( ) =
ln(0:5)
ln
(
1�
0:5
)
and g( ) = k( )= . Then
g( ) =
ln 2
ln
�
�0:5
�
; (2.47)
and
lim
!1
g( ) = lim
!1
ln 2
�
�
�2
�
�0:5
( �0:5)
= 2 ln 2: (2.48)
We will show that g( ) is a monotone, in reasing fun tion of , from whi h
it follows that k( )= � 2 ln 2. It is enough to show that h( ) = ln
�
�0:5
�
is
monotoni ally de reasing while is in reasing.
dh( )
d
= ln
�
� 0:5
�
�
0:5
� 0:5
: (2.49)
The above derivative exists for � 1. Let b( ) = ln
�
�0:5
�
�
0:5
�0:5
. We will show
that b( ) � 0. Sin e
b(1) = ln 2� 1 < �0:3; (2.50)
lim
!1
b( ) = 0; (2.51)
so it is enough to show that b( ) monotoni ally in reases with :
db( )
d
=
0:5
( � 0:5)
2
�
1�
� 0:5
�
> 0 (2.52)
and the above derivative exists for � 1. 2
Lemma 25 Let 0 < p < 1, > u for some positive u, k =
ln(p)
ln
�
1�
1�p
=u
�
, k�1 � k
0
� k,
p
0
= p
1=k
0
and
0
= u
1�p
0k
0
1�p
0
. Then � u �
0
� .
41
Proof: First noti e that from Lemma 23 it follows that k > 1. Thus k
0
> 0 and
p
0
exists.
0
= u
1� p
0k
0
1� p
0
= u
1� p
1� p
1=k
0
: (2.53)
From (2.18), (2.19) follows that
= u
1� (p
1=k
)
k
1� p
1=k
= u
1� p
1� p
1=k
: (2.54)
The inequality
0
� follows now from k
0
� k.
�
0
= u(1� p)
�
1
1� p
1=k
�
1
1� p
1=k
0
�
� u(1� p)
�
1
1� p
1=k
�
1
1� p
1=(k�1)
�
:
(2.55)
Let B(p; k) = (1 � p)
�
1
1�p
1=k
�
1
1�p
1=(k�1)
�
. We will show that B(p; k) < 1, whi h
ends the proof.
lim
k!1
B(p; k) =
�1 + p
ln(p)
=
�(1� p)
ln(1� (1� p))
< 1; (2.56)
where we used the fa t that ln (1� x) < �x for 0 < x < 1 and al ulated the
�rst equality using asymptoti expansion into series for k approa hing 1 from the
\Maple" pa ket. Now it is enough to show that B(p; k) in reases when k in reases.
�B(p; k)
�k
= (1� p) ln(p)
2
6
4
p
1
k�1
�
1� p
1
k�1
�
2
(k � 1)
2
�
p
1
k
�
1� p
1
k
�
2
k
2
3
7
5
=
= �(1� p) ln(p)
p
1
k�1
�
1� p
1
k�1
�
2
k
2
2
6
4
0
�
1� p
1
k�1
1� p
1
k
1
A
2
1
p
1
k(k�1)
�
k
2
(k � 1)
2
3
7
5
: (2.57)
The above derivative exists for 0 < p < 1, k > 1. Let Z(p; k) =
1�p
1
k�1
1�p
1
k
!
2
1
p
1
k(k�1)
.
We will show that Z(p; k)�
k
2
(k�1)
2
> 0, whi h ends the proof.
lim
p!0
Z(p; k) =1: (2.58)
lim
p!1
Z(p; k) =
0
�
lim
p!1
1� p
1
k�1
1� p
1
k
1
A
2
=
�
lim
p!1
k
k � 1
p
1
k�1
�
1
k
�
2
=
k
2
(k � 1)
2
: (2.59)
So now it is enough to show that Z(p; k) is a monotone (de reasing) fun tion of p. Let
us hange the variables. De�ne y(k; p) = p
1
k(k�1)
. Now Z(y(k; p); k) =
�
1�y
k
1�y
k�1
�
2
1
y
.
y(k; p) in reases when p in reases and 0 < y(k; p) < 1. It is enough to show that
Z(y(k; p); k) de reases when y in reases.
�Z(y(k; p); k)
�y
=
1� y
k
(1� y
k�1
)
3
y
2
h
y
2k�1
� (2k � 1)y
k
+ (2k � 1)y
k�1
� 1
i
:(2.60)
42
The above derivative exists for 0 < p < 1, k > 1.
LetW (y; k) = y
2k�1
�(2k�1)y
k
+(2k�1)y
k�1
�1. We will show thatW (y; k) <
0.
lim
y!0
W (y; k) = �1: (2.61)
lim
y!1
W (y; k) = 0: (2.62)
Now we need to show that W (y; k) is a monotone (in reasing) fun tion of y.
�W (y; k)
�y
= (2k � 1)y
2k�2
� (2k � 1)ky
k�1
+ (2k � 1)(k � 1)y
k�2
=
= (2k � 1)y
k�2
h
y
k
� ky + k � 1
i
: (2.63)
The above derivative exists for 0 < p < 1, k > 1. Let J(y; k) = y
k
� ky+ k� 1. We
will show that J(y; k) > 0.
lim
y!0
J(y; k) = k � 1: (2.64)
lim
y!1
J(y; k) = 0: (2.65)
Now it is enough to show that J(y; k) is a monotone (de reasing) fun tion of y.
�J(y; k)
�y
= ky
k�1
� k = k
�
y
k�1
� 1
�
< 0: (2.66)
The above derivative exists for 0 < p < 1, k > 1. 2
Lemma 26 Let
1
2
� p < 1, p
0
= p
1=k
0
, p
0
� ~p � p
0
(1 + "), for integer k
0
� 2. Let
0
= u
�
1 + p
0
+ p
02
+ : : : + p
0k
0
�1
�
and ~ = u
�
1 + ~p+ ~p
2
+ : : :+ ~p
k
0
�1
�
, for u > 0.
For any 0 < Æ < 1:
i) if " �
1
2(k
0
�1)
Æ then
0
� ~ �
0
(1 + Æ),
ii) if " �
1�p
k
0
Æ then p � ~p
k
0
� p(1 + Æ) and (1� p)(1� Æ) � 1� ~p
k
0
� 1� p.
Proof:
i)
Sin e ~p � p
0
so ~ �
0
.
~ = u
�
1 + ~p+ ~p
2
+ : : : + ~p
k
0
�1
�
�
� u
�
1 + p
0
(1 + ") + p
02
(1 + ")
2
+ : : :+ p
0k
0
�1
(1 + ")
k
0
�1
�
�
� (1 + ")
k
0
�1
u
�
1 + p
0
+ p
02
+ : : :+ p
0k
0
�1
�
=
= (1 + ")
k
0
�1
0
�
0
�
1 +
Æ
2(k
0
� 1)
�
k
0
�1
�
0
(1 + Æ); (2.67)
where the last inequality follows from Observation 27ii.
ii)
Sin e ~p � p
0
so ~p
k
0
� p
0k
0
= p and 1� ~p
k
0
� 1� p.
~p
k
0
�
�
p
0
(1 + ")
�
k
0
= p(1 + ")
k
0
� p
�
1 +
1� p
k
0
Æ
�
k
0
= p
1 +
Æ
1
1�p
k
0
!
k
0
: (2.68)
43
Sin e
1
1�p
� 2 so by Observation 27ii we have
p
1 +
Æ
1
1�p
k
0
!
k
0
� p
1 +
Æ
1
1�p
� 1
!
= p
�
1 + Æ
1 � p
p
�
: (2.69)
Now sin e
1�p
p
� 1 we obtain eventually ~p
k
0
� p (1 + Æ).
For 1� ~p
k
0
it holds that
1� ~p
k
0
� 1� p
�
1 + Æ
1� p
p
�
= (1� p)(1� Æ): (2.70)
2
Observation 27 For integer k � 1 and real x, 0 � x � 1, the following inequalities
hold:
i) (1� x)
k
� 1� kx; (2.71)
ii)
�
1 +
x
ak
�
k
� 1 +
x
a� 1
for a � 2: (2.72)
Proof:
i)
By indu tion on k. Assume it holds for k.
(1� x)
k+1
� [1� (k + 1)x℄ � (1� x)(1� kx)� [1� (k + 1)x℄ = kx
2
� 0: (2.73)
ii)
Trivial for x = 0. Now assume 0 < x � 1.
�
1 +
x
ak
�
k
=
k
X
i=0
k
i
!
�
x
ak
�
i
�
k
X
i=0
�
x
a
�
i
=
1�
�
x
a
�
k+1
1�
x
a
; (2.74)
and
1�
�
x
a
�
k+1
1�
x
a
�
�
1 +
x
a� 1
�
=
�
1�
x
a
�
�1
�
�
�
x
a
�
�
x(1� x)
a(a� 1)
�
� 0: (2.75)
2
44
Chapter 3
Conje tures and
Counterexamples
3.1 Best Test of a Subtree
The natural approa h to solving PAOTR is to try to exploit the lo al stru tures in
the input trees. We expe ted that the Siblings Lemma an be generalized so that
for ea h immediate subtree of a given tree we ould �nd, independently on other
subtrees, the \best" test, in the sense that there is an optimal strategy su h that
the �rst performed test is the best test from its subtree. However it turns out not
the ase.
Consider as an example the and-or tree T
shown in Figure 3.1a. Tests a
1
, a
2
,
b
1
and b
2
are grand hildren of the same and-node, but the relative order in whi h
these tests are queried by an optimal strategy, varies with the probability of su ess
of test ; depending on p ( ), an optimal strategy starts with a
1
or with b
1
.
a1 a2 b1 b2
c
a2a1 b1 cb2
+
+−
+
++−
−
b1
a1
+a2 c
c
b2a1 a2
cp( )=0.05
c
p=0.41 p=0.34 p=0.61 p=0.13
b)
a) c)
−
+−
+
+
−
−
+ +
−
+
−
+
−+
−
p( )=0.1
Tc
Figure 3.1: (a) An and-or tree T
with all osts unit. (b) The unique optimal
strategy for T
if p ( ) = 0:05, en oded by the �xed order of tests, starting with a
1
.
( ) The unique optimal strategy for T
if p ( ) = 0:1, starting with b
1
.
45
For example, if p ( ) = 0:05, the unique optimal strategy starts with testing
a
1
and then follows the linear strategy shown in Figure 3.1b. But if p ( ) = 0:1,
the unique optimal strategy is the strategy shown in Figure 3.1 , whi h starts with
testing b
1
.
3.2 Prime Impli ants and Impli ates
A minimal set with some property P is a set with the property P whi h does not
in lude any set with the property P as its proper subset. A prime impli ant of an
and-or tree is a minimal set of tests with the property that if all tests from the set
are true then the entire tree evaluates to true. A prime impli ate in an and-or
tree is a minimal set of tests, su h that if all tests from the set are false, the entire
tree evaluates to false. A tree evaluates to true (respe tively false) if and only
if there is at least one prime impli ant (respe tively prime impli ate) whose tests
are all true (respe tively false). To see that, assume that the value of T is true,
but ea h prime impli ant of T ontains at least one false test. But then the set
of all true tests in ludes a prime impli ant for T , ontradi tion. Whenever, while
performing a orre t strategy, we on lude that an and-or tree evaluates to true
(respe tively to false), it is only after all tests of some prime impli ant (respe tively
prime impli ate) have been performed and su eeded (respe tively failed).
The true path (respe tively false path) of a orre t strategy is the root-to-leaf
path of the strategy that ontains only true (respe tively only false) ar s. Ob-
viously the leaf node of the true path is labeled true, the leaf of the false path is
labeled false.
One might onje ture that for an or-rooted and-or tree, all tests performed on
the true path of an optimal strategy are from exa tly one prime impli ant. In other
words, we expe ted that in or-rooted tree, if the �rst test performed by an optimal
strategy su eeds, the strategy will perform tests from this prime impli ant, as long
as they are true. Noti e that it would mean that the optimal strategy does not
leave one hild subtree of the or-root as long as the performed tests su eed. The
onje ture is equivalent to the one that all tests performed on the false path of an
optimal strategy for an and-rooted tree are from exa tly one prime impli ate.
y
c=2
c=1
x1 x2
c=12c=20
p=0.5
z1 z2c=12
-
+
+
+
y
z1
y
-
x1
x2
+
- y-
-
+ z2
- x2
--
+ ++ +
+ +
--
+ z1+ +
- z2-
-
+ +
--
a) b)
Figure 3.2: a) An and-or tree T
i
. All tests have probability of su ess 0:5. b) The
unique optimal strategy S
i
for T
i
. The tests performed on the true path of S
i
are
from two prime impli ants of T
i
.
46
This onje ture turned out to be false. Consider the or-rooted tree T
i
in Figure
3.2a. The prime impli ants are the sets fx
1
; x
2
g, fy; z
1
g and fy; z
2
g. The unique
optimal strategy S
i
for T
i
, shown in Figure 3.2b, starts with performing x
1
, but
then, if x
1
is true, it leaves the subtree. The true path of S
i
, whose �rst node is
labeled by x
1
, ontains then the nodes labeled by z
1
and y: tests from another prime
impli ant.
c=1
x1 x2
c=100
p=0.3a) b)
c=1
y1 y2
c=100
z
c=200
-
+
+
y1-
x1
y2
+
- z-
-
-
+x2
+ +
- z-
-
+ +
-
+ +
+ +
y1
z-
+ + +
x2
-
+y2
-
+
-
-
Figure 3.3: a) An and-or tree T
e
. All tests have probability of su ess 0:3. b) The
unique optimal strategy S
e
for T
e
. The tests performed on the false path of S
e
are
from two prime impli ates of T
e
.
Noti e that the tests performed on the false path of S
i
are from only one prime
impli ate, fx
1
; yg. But it also is not always the ase. On Figure 3.3a we depi t
an or-rooted tree T
e
, with prime impli ates fx
1
; x
2
; zg and fy
1
; y
2
; zg. The false
path of the unique optimal strategy S
e
for T
e
shown in Figure 3.3b ontains nodes
labeled by tests x
1
; z; x
2
, interlaid by a node labeled by a test y
1
from another prime
impli ate.
We still expe t though that an optimal strategy will either omplete one prime
impli ant or one prime impli ate.
Conje ture 1 For any and-or tree there is an optimal strategy S su h that either
all tests performed on the true path of S are from exa tly one prime impli ant, or
all tests performed on the false path of S are from exa tly one prime impli ate.
3.3 Cograph Representation
There is a representation of the and-or trees that may be helpful in studying prime
impli ants and impli ate. We now des ribe this representation. We start with basi
de�nitions related to graphs. We follow the de�nitions from [5℄.
In undire ted graphs, we onsider unordered pairs of nodes (edges) as opposed
to the ordered pairs (ar s) in dire ted graphs. An undire ted graph G is an ordered
pair (V;E), where V is a �nite set (whose elements are alled nodes of G) and E is
the set of unordered pairs of nodes of G (whose elements are alled edges of G). We
denote an edge by (v; w), understanding that (v; w) and (w; v) is the same edge.
47
Let G = (V;E). If (u; v) 2 E, we say that u and v are adja ent. The no-
tion of a path, subgraph and the relation of being rea hable for nodes is de�ned
as for a dire ted graph (if v is rea hable from w then w is rea hable from v).
G is onne ted if every vertex is rea hable from every other vertex, and dis on-
ne ted otherwise. The onne ted omponents of G are the equivalen e lasses of
nodes for the relation of being rea hable from. The graph
�
G = (V;
�
E), where
�
E = f(v; w) : v; w 2 V; v 6= w; (v; w) =2 Eg is alled the omplement of G.
A set of nodes V
0
� V is alled a lique if the nodes in V
0
are pairwise ad-
ja ent, and is alled an independent set if no two nodes from V
0
are adja ent. A
lique (respe tively independent set) V
0
is maximal if there is no lique (respe tively
independent set) V
00
su h that V
0
� V
00
.
Let G
1
= (V
1
; E
1
); G
2
= (V
2
; E
2
); : : : ; G
k
= (V
k
; E
k
), k � 2 be graphs with
disjoint sets of nodes. G is the union of G
1
; G
2
; : : : ; G
k
, if V = V
1
[ V
2
[ : : : [ V
k
and E = E
1
[E
2
[ : : :[E
k
. G is the join of G
1
; G
2
; : : : ; G
k
, if V = V
1
[V
2
[ : : :[V
k
and E = E
1
[ E
2
[ : : : [ E
k
[ f(v; w) : v 2 V
i
; w 2 V
j
; i 6= j; i; j � kg. By the
operation of taking omplement, the operation of union, the operation of join we
mean onstru ting the graph that is the omplement of a graph, union of graphs,
join of graphs, respe tively.
A otree of a graph G is a dire ted rooted tree T whose leaf nodes are nodes
of G, internal nodes are labeled 0 or 1 and two nodes v and w of G are adja ent
if and only if the least ommon prede essor (that is the ommon prede essor with
maximum depth) of v and w in T is labeled 1.
The lass of ographs ( omplement redu ible graphs) is the lass of graphs that
an be onstru ted from single nodes using the operations of union and taking
omplement.
There is a number of important hara terization of ographs.
Theorem 28 [15, 3℄ The following statements are equivalent:
� G is a ograph,
� there exists a otree of G,
� G does not ontain a path on four nodes as an indu ed subgraph,
� the omplement of ea h onne ted indu ed subgraph of G with more than one
node is dis onne ted,
� in every indu ed subgraph H of G, the interse tion of any maximal lique of
H and any maximal independent set of H ontains pre isely one node.
The representation of a ograph by its otree enables a linear-time re ognition
of ographs [4℄, and allows to use ographs to re ognize whether a Boolean fun tion
is a read-on e fun tion [9℄.
We say that a graphG represents an and-or tree T if ea h node of G is asso iated
with a leaf of T and two nodes v and w of G are adja ent if and only if the least
ommon prede essor of v and w in T is labeled and. From the de�nition of a otree
and Theorem 28 it follows that a graph G whose nodes are asso iated with distin t
48
independent tests represents an and-or tree if and only if G is a ograph. Figure
3.4 shows a ograph representing an and-or tree.
x1 x2 y1 y2
z x1
x2
y1
y2
z
Figure 3.4: An and-or tree and the ograph representing the tree.
Observe that a join of graphs G
1
and G
2
is the omplement of the union of
omplements of G
1
and G
2
. It is easy to see how to build a unique ograph repre-
senting given and-or tree, using the operations of union and join. If T is a single
leaf, then the graph with a single node represents T . Let = fT
1
; T
2
; : : : ; T
k
g,
k � 2, be a set of and-or trees and let G
1
; G
2
; : : : ; G
k
be the graphs representing
T
1
; T
2
; : : : ; T
k
, respe tively. Now onsider the and-or tree T = hr;i (that is rooted
at r and whose set of immediate subtrees is ) and let G be a graph that represents
T . For any two tests from the same subtree T
i
their least ommon prede essor in
T belong to T
i
, whereas for any two tests from di�erent subtrees T
i
, T
j
, their last
ommon prede essor in T is the root r. Thus if r is labeled and, G is the join of
G
1
; G
2
; : : : ; G
k
, whereas if r is labeled or, G is the union of G
1
; G
2
; : : : ; G
k
.
On the other hand, for any ograph G whose nodes are asso iated with distin t
tests one an onstru t an and-or tree T that is represented by G. If G is a single
node, then T is a single test. Otherwise, if G is dis onne ted, then the root of
T is or, and ea h of the immediate subtrees of T is represented by one onne ted
omponent of G, whereas when G is onne ted, then the root of T is and and
ea h of its immediate subtrees is represented by one onne ted omponent of the
omplement of G.
There is a orresponden e between prime impli ants of and-or trees and maximal
liques of ographs as well as between prime impli ates and maximal independent
sets.
Observation 29 Let T be an and-or tree and let G be the ograph representing
T . A set W of tests of T is a prime impli ant (respe tively prime impli ate) if and
only if the set of nodes of G asso iated with the tests from W is a maximal lique
(respe tively a maximal independent set).
Proof: We will prove the orresponden e between prime impli ants and maxi-
mal liques. The proof of the other orresponden e is analogous. The proof is by
indu tion on the depth of T . The observation trivially hold for a depth zero tree,
namely for a single test. Now assume that T is of depth at least one and that the
observation is true for any tree shallower than T .
Let T
1
; T
2
; : : : ; T
k
, k � 2 be the immediate subtrees of T and G
1
; G
2
; : : : ; G
k
the
ographs representing T
1
; T
2
; : : : ; T
k
, respe tively.
Assume that T is and-rooted. W is a prime impli ant of T if and only if
W =W
1
[W
2
[ : : : [W
k
, where for i � k W
i
is a prime impli ant of T
i
. By the
49
indu tive assumption W
i
is a prime impli ant of T
i
if and only if the set of nodes of
G
i
asso iated with tests from W
i
is a maximal lique. But sin e all nodes from dif-
ferent subgraphs G
i
, G
j
are adja ent in G, so the set of nodes V
0
of G is a maximal
lique if and only if V
0
= V
0
1
[ V
0
2
[ : : : [ V
0
k
, where for i � k V
0
i
is a maximal lique
of G
i
.
Now assume that T is or-rooted. W is a prime impli ant of T if and only if
W is a prime impli ant of one of T
1
; T
2
; : : : ; T
k
. So the observation for this ase
follows from the indu tive assumption and the fa t that sin e G is the union of
G
1
; G
2
; : : : ; G
k
, a set of nodes of G is a maximal lique if and only if it is a maximal
lique in one of G
1
; G
2
; : : : ; G
k
. 2
We an de�ne a problem related to ographs that is equivalent to PAOTR.
We are given a graph G su h that ea h node of G is assigned one of two olours:
it an be either bla k or white, independently on other nodes. We all any given
assignment of olours to nodes a olouring of nodes. For ea h node we know a non-
negative ost of he king the olour of the node and the probability that the node is
bla k. The strategy for the graph G is an algorithm that for any olouring of nodes
determines whether there is a maximal lique in G whose nodes are all bla k, via
sequential he king olours of nodes. For any given olouring, the ost of a strategy
on this olouring is the total ost of performed olour he king. The expe ted ost
of a strategy is the average ost of the strategy, over all olourings of the nodes of
G. An optimal strategy for G is a strategy with the smallest expe ted ost.
From the dis ussion above it follows that the problem of �nding an optimal
strategy for a ograph is equivalent to PAOTR.
Our Conje ture 1 an be now rephrased as follows: For any ograph G there is
an optimal strategy S su h that S either does not leave one maximal lique as long
as the he ked nodes are bla k, or does not leave one maximal independent set, as
long as the he ked nodes are white.
Generalizing, we ould ask for an optimal strategy for an arbitrary graph (whi h
is not related to the and-or tree problem). We will show that this problem is
NP -hard.
Observation 30 Finding an optimal strategy for an arbitrary graph is NP -hard.
Proof: Let G be an arbitrary graph on n nodes. For ea h node, let the ost of
he king the olour be 1 and the probability of being bla k be q =
�
1�
1
2n
�
1
n+1
. Let
S be a strategy for G, represented by a binary tree. The root-to-leaf path of the
strategy that is followed when all he ked nodes are bla k is alled the bla k path. Let
k be the number of internal nodes of the bla k path of S. Observe that ea h other
root-to-leaf path of S ontains at least 1 and at most n internal nodes. Analogously
as in the proof of Theorem 1, we obtain following bounds on the expe ted ost of S:
C(S) � q
k
k + (1� q
k
)n = n� (n� k)
�
1�
1
2n
�
k
n+1
<
< n� (n� k)
�
1�
1
2n
�
= k +
n� k
2n
� k +
1
2
(3.1)
50
and
C(S) � q
k
k + (1� q
k
)1 = 1 + (k � 1)
�
1�
1
2n
�
k
n+1
>
> 1 + (k � 1)
�
1�
1
2n
�
= k �
k � 1
2n
� k �
1
2
: (3.2)
Therefore there is a strategy for G with expe ted ost not greater than k+
1
2
if and
only if there is a strategy for G that he ks at most k nodes along its \bla k path"
if and only if there is a maximal lique in G with at most k nodes.
But the problem of determining whether a graph G has a maximal lique with
at most k nodes ( alled the Minimum Maximal Clique Problem) is NP - omplete
by redu tion from the Minimum Maximal Independent Set Problem, that is the
problem of determining whether a graph G has a maximal independent set with at
most k nodes [7℄.
Therefore, by redu tion from the Minimum Maximal Clique Problem �nding an
optimal strategy for an arbitrary graph is NP -hard. 2
3.4 Resolving Subtrees
A depth-�rst strategy, whi h is optimal for depth two and-or trees, does not leave a
given subtree until its value is determined. Su h approa h is not ne essary optimal
for deeper trees, but we onje tured a weaker property of an optimal strategy.
After a test from an and-or tree is performed, let the highest resolved node in
the tree be the root of the maximal subtree whose value has been determined. For
example, assume that a test x is false. If the parent of x is labeled or and x has a
sibling, then the highest resolved node is x itself. But if the parent of x is and and
is a hild of an or-node, then the highest resolved node is the parent of x.
a
b
c
d e
p=0.13
p=0.72
p=0.21
p=0.43 p=0.86
a)
-
+
d
+
-
b
+
c-
+ b-
+
-
-
e+
- c-
+ +
a-
-
+ +
a-
-
+ +
+
+
-
a
+
b)
Figure 3.5: a) An and-or tree T
l
. All tests have unit ost. b) The unique optimal
strategy for T
e
. After the �rst performed test is true as well as after the �rst test is
false, the strategy leaves the subtree rooted at the parent of the highest resolved
node.
We expe ted that after a test x is performed, an optimal strategy would at least
in one ase (when x is true, or if x is false) performs after x a test from the subtree
51
rooted at the parent of the highest resolved node. However it turns out that it is not
always so. Consider the tree T
l
in Figure 3.5a. The unique optimal strategy for T
l
is
presented in Figure 3.5b. After performing the �rst test d, when d is true, as well
as when d is false, the strategy performs the next test from outside the subtree
rooted at the parent of the highest resolved node. We thank Leah Ha kman and
Martha Ledni ky, WISEST 2003 parti ipants, whose experimentation with instan es
of and-or trees led to the dis overy of this example.
3.5 Tests Ordering for Ladders
As de�ned in Se tion 2.4, in an and-or ladder ea h internal node has at most one
internal hild node. In an and-or ladder a test y is alled better than a test x if y is
a hild of a prede essor v of x and either v is labeled or and p(y)= (y) > p(x)= (x),
or v is labeled and and �p(y)= (y) > �p(x)= (x). See Figure 3.6 for an example. For
p=0.2c=2
y
x
p=0.7c=1
Figure 3.6: An and-or ladder. Test y is better than test x.
a large number of ladders, there is a pattern in the order of tests in an optimal
strategy, observed by Leah Ha kman and Martha Ledni ky, whi h an be des ribed
by the following onje ture.
Conje ture 2 Let T be an and-or ladder. There is an optimal strategy S for T
su h that for any tests x and y su h that y is better than x, x is not performed before
y on any root-to-leaf path of S.
For and-or ladders the onje ture generalizes the Siblings Lemma and the Ob-
servation 19. For depth one ladders, it is equivalent to the Siblings Lemma. For
depth two ladders, the orre tness of the onje ture follows by the Observation 32
from the fa t that DFA produ es an optimal strategy for depth two and-or trees
(Theorem 4). Though a large number of numeri ally he ked examples of ladder
trees justify the onje ture, we were able to prove it only for a spe ial ase of a
depth three and-or ladder:
Observation 31 If an and-or ladder T has depth one or two, or T has depth three
and has only two tests with depth three, then Conje ture 2 holds for T .
Proof: We prove the observation by indu tion on the number of the tests of T .
The observation trivially holds for a ladder with only one test. Now assume that
the observation hold for any ladder ful�lling the onditions of the observation, that
52
has less tests than T . Sin e, as dis ussed above, the observation hold for any depth
1 or depth 2 ladder, assume that T is depth 3 and that the last internal node of
T has exa tly 2 tests. Assume that T is or-rooted; the proof for the other ase is
symmetri .
Let a, b and be the tests with the highest R-ratio among the tests with depth
1, depth 2 and depth 3, respe tively. By the Sibling and Twins Lemma there is an
optimal strategy that starts with a or with b or with . If there is a test that is
better than , then it has either depth 1 or 2. If a test with depth 2 is better than ,
then b is better than . Then by Lemma 35 there is an optimal strategy for T that
starts either with a or b. If a test with depth 1 is better than , then a is better
than and by Lemma 34 there is an optimal strategy that starts with a. Now if
there is a test better than b, then it has depth 1, and thus a is better than b. In this
ase, by Lemma 34, there is an optimal strategy for T that starts with a. No test
in T an be better than a. It follows that there is an optimal strategy for T whose
root is labeled by a test for whi h there is no better test in T .
Now let T
0
be the redu ed tree obtained from T when the �rst test performed by
S is, say, true. Assume that a test y is better than x in T . If y and x are still present
in the tree T
0
, then y is better than x in T
0
. Thus by the indu tive assumption there
is an optimal strategy for T
0
that never performs y before x. The same holds for
the redu ed tree obtained when the �rst test preformed by S is false. Therefore
there is an optimal strategy for T that ful�lls the ondition of Conje ture 2. 2
In the remainder of the se tion we present the proofs of the observations used
above.
Observation 32 Let A be a depth one and-or tree with at least two leaf nodes and
let A
0
be the tree obtained from A by removing one leaf. Assume that the parent
nodes of A and A
0
have di�erent labels than the root of A. Let C(A) (C(A
0
)) be the
expe ted ost of the optimal strategy to evaluate A (respe tively A
0
) and let p
r
(A)
(p
r
(A
0
)) be the probability that A (respe tively A
0
) resolves its parent node. Then
p
r
(A
0
)
C(A
0
)
�
p
r
(A)
C(A)
.
Proof: Assume that the root of A is and. The proof for the other ase is sym-
metri . Now p
r
(A) (p
r
(A
0
)) is the probability that A (respe tively A
0
) evaluates to
true.
Let x
1
; x
2
; : : : ; x
k
, k � 2, be the tests of A and assume that R(x
1
) � R(x
2
) �
: : : � R(x
k
). Then by Theorem 2 the above order of tests is the order of performing
them by the optimal strategy for A. Let x
m
, 1 � m � k, be the test that is removed
from A to reate A
0
.
Thus we have p
r
(A) =
Q
i�k
p(x
i
), p
r
(A
0
) =
Q
i�k;i 6=m
p(x
i
), and C(A) = (x
1
)+
P
2�i�k
(x
i
)
Q
1�j<i
p(x
j
).
We introdu e the following notation:
C
1
=
(
0 if m = 1;
(x
1
) +
P
2�i�m�1
(x
i
)
Q
1�j<i
p(x
j
) if m � 2;
(3.3)
p
1
=
(
1 if m = 1;
Q
1�i�m�1
p(x) if m � 2;
(3.4)
53
C
2
=
(
0 if m = k;
(x
m+1
) +
P
m+2�i�k
(x
i
)
Q
m+1�j<i
p(x
j
) if m < k:
(3.5)
Then we an use the following expressions:
C(A) = C
1
+ p
1
(x
m
) + p
1
p(x
m
)C2; (3.6)
C(A
0
) = C
1
+ p
1
C
2
: (3.7)
Now we obtain
p
r
(A
0
)
(A
0
)
�
p
r
(A)
(A)
=
p
r
(A
0
)
(A
0
) (A)
[(1� p(x
m
))C
1
+ p
1
(x
m
)℄ � 0: (3.8)
2
Lemma 33 Let T be an and-or tree and let x and y be di�erent tests from T .
Assume that y is a hild of a prede essor of x and that there is an optimal strategy
S
x
for T that starts with performing the test x. If
i) y is the �rst test performed by S
x
after x is false and R(y) �
p(x)
(x)
, or
ii) y is the �rst test performed by S
x
after x is true and R(y) �
�p(x)
(x)
,
then there is an optimal strategy S
y
for T that starts with performing y.
Proof: We will prove the theorem for the ase when the ondition (i) is ful-
�lled. The proof for the ondition (ii) is symmetri . Assume that y is the �rst test
performed by S
x
after x is false and R(y) �
p(x)
(x)
.
If x and y are hild nodes of the same or-node then we may assume that the
substrategies followed when x is true, and when x is false, y is true, are the
same (be ause if they are not, we may repla e them by su h strategies). Then, by
Observation 8, the strategy S
y
obtained by swit hing labels x and y is optimal.
Now assume that x and y are not hild nodes of the same or-node. Sin e y is a
hild node of a prede essor of x, so after x is true, y is still present in the redu ed
tree. Let S
+x
, S
�x
be the substrategies of S
x
followed when x is true, false,
respe tively. The root of S
�x
is labeled by y. Let S
�
+y
, S
�
�y
be the substrategies
of S
�x
followed when y is true, false, respe tively. Let M � 1 be the number of
nodes of S
+x
labeled by test y, let S
y
1
; S
y
2
; : : : ; S
y
M
be the subtrees of S
+x
rooted
at nodes labeled by y, and for k = 1; 2; : : : ;M , let S
+y
k
, S
�y
k
be the substrategies of
S
y
k
followed in the ase when y is true, y is false, respe tively. Also let S
r
denote
the (possibly empty) part of S
+x
that ontains all nodes outside S
y
1
; S
y
2
; : : : ; S
y
M
.
The following strategy S
0
+x
is nonredundant and orre t for the tree obtained
from T when x is true, and may repla e the substrategy S
+x
:
S
0
+x
= y : +
�
S
0+
+y
�
;�
�
S
0+
�y
�
, where S
0+
+y
= S
+x
(S
y
1
/ S
+y
1
; : : : ; S
y
M
/ S
+y
M
),
S
0+
�y
= S
+x
(S
y
1
/ S
�y
1
; : : : ; S
y
M
/ S
�y
M
).
Assume that y is a hild of an or-node. The proof for the other ase is symmetri .
Thus
R(y) =
p(y)
(y)
�
p(x)
(x)
: (3.9)
54
Let C (S
r
) denote the expe ted ost of performing S
r
, that is the sum of osts
of tests labeling nodes of S
r
, fa tored by the probabilities of paths from the root of
S
+x
to a given node (if S
r
is empty, then C (S
r
) = 0). For any k, let p
y
k
be the
probability of the path from the root of S
+x
to the labeled by y root node of S
y
k
.
Then we have
C
�
S
0+
+y
�
= C (S
r
) +
M
X
k=1
p
y
k
C (S
+y
k
) : (3.10)
If y is true, its parent node is resolved. Sin e y is a hild of a prede essor of x, so
the redu ed trees evaluated by S
0+
+y
and S
�
+y
are identi al. Sin e S
�
+y
is a substrategy
of the optimal strategy S
x
, so C
�
S
�
+y
�
� C
�
S
0+
+y
�
, that is
C
�
S
�
+y
�
� C (S
r
) +
M
X
k=1
p
y
k
C (S
+y
k
) : (3.11)
Now it is obvious that the following strategy S
y
is nonredundant and orre t for
T : S
y
= y : +
�
S
�
+y
�
;�
�
x : +
�
S
0+
�y
�
;�
�
S
�
�y
��
. For the expe ted osts of S
x
and
S
y
we have
C(S
x
) = (x) + p(x)
"
C(S
r
) +
M
X
k=1
p
y
k
�
(y) + p(y)C (S
+y
k
) + �p(y)C (S
�y
k
)
�
#
+
+�p(x)
h
(y) + p(y)C
�
S
�
+y
�
+ �p(y)C
�
S
�
�y
�i
; (3.12)
C(S
y
) = (y) + p(y)C
�
S
�
+y
�
+
+�p(y)
"
(x) + p(x)
C (S
r
) +
M
X
k=1
p
y
k
C (S
�y
k
)
!
+ �p(x)C
�
S
�
�y
�
#
; (3.13)
thus
C(S
y
)� C(S
x
) = � [p(y) (x) � p(x) (y)℄ +
�p(x)p(y)
"
C (S
r
) +
M
X
k=1
p
y
k
C (S
+y
k
)� C
�
S
�
+y
�
#
+
�p(x) (y)
M
X
k=1
p
y
k
�
� 0; (3.14)
where the inequality holds by (3.9), (3.11). Therefore S
y
is optimal for T . 2
Lemma 34 Let T be an or-rooted depth three ladder. Let a, b and be ea h a test
with the highest R-ratio among all tests with depth one, depth two and depth three
respe tively. If
p(a)
(a)
� min
n
p( )
( )
;
p(b)
(b)
o
then there is an optimal strategy for T that
starts with a.
Proof: First assume that
p(a)
(a)
�
p( )
( )
. The proof is by indu tion on the number
of tests with depth 3. If there is only one su h test, then the tree ollapses to depth
2 and by Observation 32 from the fa t that
p(a)
(a)
�
p( )
( )
it follows that DFA prefers a
55
to the and-rooted subtree of the root. Now assume that the lemma hold for a depth
3 ladder that has fewer tests with depth 3 than T has.
Let S be an optimal strategy for T . Assume that S starts with . If is false,
the redu ed tree is a ladder ful�lling the ondition of the lemma (be ause ea h
sibling of has lower ratio of su ess probability to the ost, than ). So by the
indu tive assumption S performs a after is false, thus by Lemma 33 there is an
optimal strategy for T that starts with a.
Assume that S starts with b. Let b
1
= b and let b
2
; b
3
; : : : ; b
k
, k � 1, be siblings
of b
1
su h that S performs b
i+1
after b
i
is true, and S does not perform a sibling
of b
1
after b
k
. When any b
i
is false, the optimal strategy performs a (be ause the
only tests left in the redu ed tree are hild tests of the root). After b
k
is true the
value of the tree is not resolved yet; let T
0
be the redu ed tree obtained at this point
of the strategy and let S
0
be the optimal strategy for T
0
. If S
0
starts with a, then
by Observation 18 we an \move" a to the root of the strategy S, that is there is an
optimal strategy for T that starts with a. If b
k
was the last test with depth 2 then
T
0
ollapses to depth 1. Then, sin e
p(a)
(a)
�
p( )
( )
, the S
0
starts with a. So assume the
there is still at least one test sibling of b and S
0
starts with . But then the redu ed
tree obtained from T
0
when is false ful�lls the onditions of the lemma, so by
the indu tive assumption S
0
performs a after is false. Thus by Lemma 33 there
is an optimal strategy for T
0
that starts with a.
Now assume that
p(a)
(a)
�
p(b)
(b)
. The proof is by indu tion on the number of the
depth 3 tests. If there is only one su h test, then the tree ollapses to depth 2 and
by Observation 32 from the fa t that
p(a)
(a)
�
p(b)
(b)
follows that DFA prefers a than
the and-rooted hild subtree of the root. Now assume that the lemma hold for a
depth 3 ladder that has less tests of depth 3 than T has.
Let S be an optimal strategy for T . Assume that S starts with b. If b is false, S
performs a (be ause the only tests left in the redu ed tree are hild tests of the root).
So by Lemma 33 there is an optimal strategy for T that starts with a. Assume that
S starts with . By the indu tive assumption, S performs a after is false. If is
true, the redu ed tree ollapse to depth 2 or depth 1, if b does not have any test
sibling. From the fa t that
p(a)
(a)
�
p(b)
(b)
follows that in both ases a is the �rst test to
perform by an optimal substrategy (for depth 2 tree, it follows by Observation 32).
Thus S performs a after regardless of the value of , so by Observation 18 there is
an optimal strategy for T that starts with a. 2
Lemma 35 Let T be an or-rooted depth three ladder su h that there are only two
tests with depth three. Let a, b and be the tests with the highest R-ratio among
the tests with depth one, depth two and depth three, respe tively. If
�p(b)
(b)
�
�p( )
( )
then
there is an optimal strategy for T that starts either with a or with b.
Proof: Let S be an optimal strategy for T . Assume that S starts with performing
. Let BC be the subtree rooted at the and- hild of the root and let B be the depth
1 subtree obtained from BC when is true and B
0
be the depth 1 subtree obtained
from BC if is false (after ollapsing the or-node); B
0
has all hild tests of B and
additionally the test that was a sibling of in BC.
If the �rst test performed by S after is true is a, it means that DFA prefers
a than B. Thus by Observation 32 DFA also prefers a than B
0
, and a is also the
56
�rst test performed when is false. But a is a hild of the root of T , so there is an
optimal strategy for T that starts with a (see Observation 18).
So assume that the �rst test performed after is true is b. But then by Lemma
33 there is an optimal strategy for T that starts with b. 2
57
Chapter 4
Pre onditioned And-Or Trees
4.1 Smith's Algorithm
In this hapter we deal with a generalization of and-or trees, namely with pre ondi-
tioned and-or trees. As explained in Se tion 1.3.6, in a pre onditioned and-or tree
both leaf nodes and internal or-nodes and and-nodes are probabilisti tests, with
given su ess probabilities and performan e osts. The value of a leaf node is the
output of the asso iated test. Ea h internal node is additionally asso iated with a
required value, true or false. The tests that are hild nodes of a given and-node
(respe tively or-node) v may be queried only if the test asso iated with v was per-
formed and returned its required value: in su h a ase v evaluates to the logi and
(respe tively or) of the hild nodes' values. If the output of the test asso iated with
v is not the required value of v, the node v evaluates to the output of this test. The
value of a tree is the value of its root node.
To understand better the notion of the required value of an internal node, on-
sider the following example. A ompany uses three tests x, y and z to evaluate
andidates for a ertain position. There are pre eden e onstraints: the test x has
to be performed before y and z.
zy
x-
zy
x+
a) b)
Figure 4.1: Pre onditioned or-trees. a) The test x has the required value true. The
tests y and z an be performed only after x su eeds. b) The test x has the required
value false. The tests y and z an be performed only after x fails.
First onsider the ase when a andidate is reje ted if he or she fails test x
(that is passing this test is a ne essary ondition for a epting the andidate). Ad-
ditionally the su essful andidate has to pass either y or z. To des ribe this situa-
tion, we use the pre onditioned or-tree presented in Figure 4.1a, where the or-node
x has the required value true. If the output of x is false then the tree evaluates
to false. If the output of x is true then the tree evaluates to or of values of y and
z. Thus the value of the tree is the value of the expression e
1
= x and (y or z).
58
But what if a andidate to be a epted needs just to pass one of the tests x,
y or z? In su h a ase we use the pre onditioned or-tree from Figure 4.1b, where
the or-node x has the required value false. If x has the value true then the tree
evaluates to true, otherwise it evaluates to or of the values of y and z. Thus the
tree evaluates to the value of the expression e
2
= x or y or z.
Consider the negation of a pre onditioned and-or tree. For the tree in Figure 4.1a
we have :e
1
= (:x) or [(:y) and (:z)℄, whi h is equivalent to the pre onditioned
and-tree with tests :x, :y and :z, in whi h the required value of the and-node :x is
false. For the tree in Figure 4.1b :e
2
= (:x) and (:y) and (:z). This expression
des ribes the pre onditioned and-tree in whi h the required value of the and-node
:x is true. In general, we obtain the negation of a pre onditioned and-or tree by
negating the output of any test, hanging ea h or-node to an and-node and vi e
versa, and negating the required value of ea h internal node.
Smith [26℄ presented an eÆ ient algorithm to �nd an optimal strategy for pre-
onditioned or-trees (that is pre onditioned and-or trees without and-nodes) if the
required value of ea h or-node is true. We will all this algorithm SA (Smith's
Algorithm).
We will �rst des ribe the idea of SA, then explain the natural generalization
of the algorithm that deals with both true and false required values of internal
nodes in a pre onditioned or-tree, and present the pseudo- ode of the generalized
algorithm.
SA operates on blo ks, that is sequen es of tests. Ea h blo k has to obey the
pre eden e onstraints in a given tree. For a blo k a we an al ulate the expe ted
ost C(a) of performing the tests from a and the resolving probability P
r
(a), that is
the probability that performing the tests from a will ause the entire tree to evaluate
to true. The R-ratio R(a) for a blo k a is de�ned as R(a) =
P
r
(a)
C(a)
. Noti e that for
a blo k that ontains a single leaf test it is equivalent to our previous de�nition of
R-ratio in and-or trees. A blo k is rooted at a test x if it starts with x and ontains
only tests from the subtree rooted at x.
The best blo k for a node, alled \best strategy" in [26℄, is the blo k that maxi-
mizes the R-ratio, over all blo ks rooted at this node. Consider any two tests x and
y su h that y is inside the subtree rooted at x. It turns out that if the best blo k for
x ontains y, then it also ontains the entire best blo k for y, not interlaid by other
tests. A maximal best blo k in a tree is the best blo k for some node that is not
in luded in the best blo k for any other node. The optimal strategy for the entire
or-tree performs one maximal best blo k after another, ordered by nonin reasing
blo ks' R-ratios. An equivalent des ription of an optimal strategy may be used.
Instead of onstru ting and storing the maximal best blo ks, we an rather store
with ea h test the R-ratio of the best blo k for this test, alled the worth of the test.
Then the best-�rst strategy, that is the strategy that always performs the test with
the highest worth over all available tests, is optimal for the tree.
The best blo k for a node is reated by starting with the blo k that ontains
only the single test asso iated with the node, and then building it up as long as we
an improve its R-ratio. Nodes are pro essed from bottom up, that is any test x is
pro essed only after the best blo k for ea h node inside the subtree rooted at x has
been already found. As mentioned before, whenever a test is added to a blo k, at
59
the same time the entire best blo k for this test needs to be added to it.
Sin e any two tests are never onsidered separately after they have been in luded
in one blo k, a blo k is treated as a single meta-node. Two blo ks are ombined
(one sequen e added at the end of another) by merging two meta-nodes into a single
one. At the beginning ea h original node is a single blo k. Noti e that at this stage
if there is a dire ted path from a blo k a to a blo k b, then b has to be performed
after a, but if there is no dire ted path between a and b then there is no restri tion
on the order of performing a and b. This property is maintained be ause a parent
blo k a an be only merged with its hild blo k b, by repla ing a with ab, with the
set of hild nodes being the union of hild nodes of a and b.
For a leaf node, the smallest, single-test blo k is the best blo k. Now onsider
an internal test x and the blo k a rooted at x that is initialized with x. We �rst
re ursively �nd the maximal best blo ks for ea h hild subtree of x. We then sele t
the hild blo k b of a with the highest R-ratio. If the R-ratio of b is not less than
the R-ratio of a, then we ombine a and b together, as des ribed above: the new
blo k will have higher R-ratio than a previously had. We repeat this pro ess until
no hild blo k of a has higher R-ratio than a, at whi h point a is the best blo k for
x and we are left with the maximal best blo ks for the subtree rooted at x.
Smith proved the orre tness of the algorithm under the assumption that the
required value of ea h or-node is true, that is that performing an internal test an
never resolve the entire tree. But the algorithm builds a best blo k by ombining
nodes together and then treats it as a single meta-node. In doing so, it reates nodes
that are internal (that is have hildren) but that an resolve the entire tree (be ause
they result from ombining internal and leaf nodes). This is the intuitive argument
why in fa t Smith's Algorithm an deal with the presen e of or-nodes with the
required value false (that is internal tests whose su ess resolves the entire tree).
We now explain formally this generalization to arbitrary required values of or-nodes.
SA and the proof of its orre tness [26℄ deal with blo ks and are based on the
following expressions for the expe ted ost C(a) and the resolving probability P
r
(a)
of a blo k a:
For any test x we have
C(x) = (x); (4.1)
if a test x is a leaf node
P
r
(x) = p(x); (4.2)
if a test x is an internal node with the required value true
P
r
(x) = 0: (4.3)
Moreover if x is an internal node with the required value true, a parameter L(x) is
de�ned as follows:
L(x) = p(x): (4.4)
Noti e that the value of L(x) is the value of the probability that hild tests of x
be ame available to perform after querying x.
For a sequen e a of internal tests, L(a) is de�ned as
L(a) =
Y
x2a
L(x); (4.5)
60
where the produ t is taken over all tests from a.
Given blo ks a and b, where b is rooted at its �rst test, the following expression
al ulates the expe ted ost and the resolving probability of the bigger blo k ab
regardless of the required values of nodes:
C(ab) = C(a) + P
0
(a; b)C(b); (4.6)
P
r
(ab) = P
r
(a) + P
0
(a; b)P
r
(b); (4.7)
where P
0
(a; b) is the probability that one starts performing the blo k b after per-
forming a, that is that the blo k a fails to resolve the tree, but in su h a way that
performing b is still possible.
In the ase when all internal nodes in an or-tree have the required value true,
no internal node an resolve the tree, and performing b is still possible only if all
internal nodes of a that are prede essors of the �rst test (thus of all tests) of b
su eeded. Thus the expression for P
0
(a; b) used in [26℄ is
P
0
(a; b) = L(a
b
)(1 � P
r
(a
�
b
)); (4.8)
where a
b
is the subsequen e of internal tests of a that are prede essors of the �rst
test of b, a
�
b
is the remaining subsequen e of a.
Now assume that in a tree internal nodes an have both required values. For a
blo k ontaining a single internal test x with the required value false, the resolving
probability is p(x). Moreover, in a blo k ab (with b rooted at its �rst test) we start
performing the blo k b if and only if all internal tests from a that are prede essors
of the �rst test of b, returned their required values (noti e that at the same time
it means that none of these tests resolved the tree) and the remaining subsequen e
of a did not resolve the tree. Observe that we may use exa tly the same formulae
(4.5) and (4.8) if we use the following expressions for internal or-nodes with required
value false:
if x is an internal node with the required value false:
P
r
(x) = p(x); (4.9)
L(x) = 1� p(x): (4.10)
Thus if in addition to formulae (4.1) and (4.2) we use (4.3) and (4.4) for the
or-nodes with the required value true and (4.9) and (4.10) for the or-nodes with
the required value false, we obtain orre t values of the expe ted ost and the re-
solving probability for single-test blo ks and the same expressions to al ulate these
parameters for bigger blo ks as the ones on whi h SA and the proof of its orre tness
rely, namely (4.5), (4.8), (4.6) and (4.7).
Smith's Algorithm for pre onditioned or-trees is presented in Figure 4.2. The
pro edure Create Blo ks(x) builds maximal best blo ks for a tree rooted at test x;
the pro edure Combine(x,y) ombines blo ks x and y into one blo k xy. Instead of
using (4.8) dire tly to al ulate P
0
(a; b), we rather keep for ea h blo k b the value
P
0
(b) = P
0
(a; b), where a is the node (blo k) that is the urrent parent of b. Noti e
that this is all we need sin e we add a blo k b at the end of a only in the ase when
a is the parent of b. If the parent a is a single test x then P
0
(x; b) = L(x). If a is
being ombined with other blo k , we update P
0
(b) using the following expressions:
61
SA(pre onditioned or tree T)
(1) Create Blo ks(root test of T)
(2) Order maximal best blo ks from T by nonin reasing R()
Create Blo ks(test x)
(1) C(x) := (x)
(2) If x is a leaf
(3) P
r
(x) := p(x)
(4) R(x) :=
P
r
(x)
C(x)
(5) Else
(6) P
r
(x) :=
(
0 if required value of x is true
p(x) if required value of x is false
(7) R(x) :=
P
r
(x)
C(x)
(8) For ea h hild y of x
(9) P
0
(y) :=
(
p(x) if required value of x is true
�p(x) if required value of x is false
(10) Create Blo ks(y)
(11) End For
(12) While x has hild blo ks
(13) Find hild y
best
of x with maximum R()
(14) If R (y
best
) < R(x) Then Go To (17)
(15) Combine (x,y
best
)
(16) End While
(17) End Else
Combine (blo k x,blo k y)
(1) P
r
(x) := P
r
(x) + P
0
(y)P
r
(y)
(2) C(x) := C(x) + P
0
(y)C(y)
(3) R(x) :=
P
r
(x)
C(x)
(4) For ea h hild y
0
of x other than y
(5) P
0
(y
0
) := P
0
(y
0
)(1 � P
r
(y))
(6) End For
(7) For ea h hild z of y
(8) P
0
(z) := P
0
(y)P
0
(z)
(9) End For
(10) x := xy
(11) Add all hildren of y to the set of hildren of x
(12) Dis ard y
Figure 4.2: Smith's Algorithm (SA).
62
if blo k a is being added at the end of , whi h means that in the urrent tree a is
a hild of , we have
P
0
( a; b) = L(( a)
b
) [1� P
r
(( a)
�
b
)℄ = L(
a
)L(a
b
) [1� P
r
(
�a
)℄ [1� P
r
(a
�
b
)℄ =
= P
0
( ; a)P
0
(a; b); (4.11)
whereas if blo k is being added at the end of a, it means that in the urrent tree
blo k is a hild of a, thus a sibling of b, therefore
P
0
(a ; b) = L((a )
b
) [1� P
r
((a )
�
b
)℄ = L(a
b
) [1� P
r
(a
�
b
)℄ [1� P
r
( )℄ =
= P
0
(a; b) [1� P
r
( )℄ : (4.12)
Observe that if ea h or-node from a tree has either the required value false,
or the probability of su ess 1, then for any blo k b rooted at its �rst test and the
parent blo k a of b we have P
0
(a; b) = 1 � P
r
(a). Therefore in su h a ase we do
not need to store P
0
(b).
Let n be the number of all tests (nodes) in the tree. Noti e that ex ept for the
initialization of blo ks whi h is performed n times, SA ombines blo ks at most n
times. Ea h ombining two blo ks requires time linear in the number of hild nodes
of the ombined blo ks, so the worst ase omplexity of SA is O(n
2
).
a)
b) c) d)
w+
x-
y z
p=1
p=0.4
p=0.2p=0.5
w
x
y z
R=0
R=0.4
R=0.2R=0.5
w
xy
z
R=0
R=0..4375
R=0.2
wxy
z
R=0.2692
R=0.2
Figure 4.3: An example of using Smith's Algorithm. a) An algorithm's input:
pre onditioned or-tree T
p
. All tests have unit ost. b) The initial blo ks built by
SA. ) The blo ks after ombining blo ks x and y together. ) The blo ks after
ombining blo ks w and xy together. These blo ks are maximal best blo ks for T .
We will now dis uss a simple example of using SA. The input pre onditioned or-
tree T
p
is given in Figure 4.3a. Firstly after the initialization of blo ks the stru ture
of blo ks is given in Figure 4.3b. Sin e all tests have ost one, so all blo ks have
63
ost one as well. The other parameters of the blo ks have the values shown in Table
4.1.
P
r
(w) = 0 R(w) = 0
P
r
(x) = p(x) = 0:4 R(x) = 0:4 P
0
(x) = p(w) = 1
P
r
(y) = p(y) = 0:5 R(y) = 0:5 P
0
(y) = �p(x) = 0:6
P
r
(z) = p(z) = 0:2 R(z) = 0:2 P
0
(z) = �p(x) = 0:6
Table 4.1: Parameters of initial blo ks shown in Figure 4.3.
Blo ks z and y do not have any hildren. Now we pro ess the blo k x. Among
its hild blo ks, y has the highest R-ratio and R(y) > R(x). So we ombine blo ks
x and y together. The resulting blo ks are shown in Figure 4.3 . The following
parameters hange:
P
r
(xy) = P
r
(x) + P
0
(y)P
r
(y) = 0:4 + 0:6 � 0:5 = 0:7;
C(xy) = C(x) + P
0
(y) � C(y) = 1 + 0:6 � 1 = 1:6;
R(xy) =
P
r
(xy)
C(xy)
= 0:4375;
P
0
(z) = P
0
(z) (1� P
r
(y)) = 0:6 � 0:5 = 0:3: (4.13)
The only hild of the blo k xy is the blo k z and it has less R-ratio than xy has.
Thus now we pro ess the blo k w. This blo k has only one hild xy whose R-ratio
is higher than R(w). Thus we ombine w and xy and in this way obtain the blo ks
shown in Figure 4.3d. Noti e that, a ording to the algorithm, P
0
(xy) = P
0
(x).
The following expressions des ribe parameters update:
P
r
(wxy) = P
r
(w) + P
0
(xy)P
r
(xy) = 0 + 1 � 0:7 = 0:7;
C(wxy) = C(w) + P
0
(xy) � C(xy) = 1 + 1 � 1:6 = 2:6;
R(wxy) =
P
r
(wxy)
C(wxy)
=
7
26
� 0:2692;
P
0
(z) = P
0
(xy)P
0
(z) = 1 � 0:3 = 0:3: (4.14)
Sin e R(z) < R(wxy), z and wxy are the maximal best blo ks of T . By order-
ing them a ording to nonin reasing R-ratios we obtain the optimal strategy for T :
wxyz.
As dis ussed at the beginning of this se tion, a pre onditioned and-tree is equiv-
alent, up to the negation of its value, to some pre onditioned or-tree, namely the
tree obtained by hanging every and-node into or-node, negating output of every
test and negating the required value for ea h internal node. In a pre onditioned
and-or tree the resolving probability is the probability that the entire tree evalu-
ates to false. From this it follows that the obvious modi� ation in lines (3) and
(6) of the Create Blo ks pro edure allow us to use the algorithm for pre onditioned
and-trees.
The alternation number of a path in an and-or tree is the number of ar s of the
path whose ends are internal nodes with di�erent (or/and) labels. The alternation
64
number of a tree is the maximum alternation number of a path over all root-to-leaf
paths in the tree. For a stri tly alternating and-or tree the alternation number
is equal to the tree's depth minus one. We all a pre onditioned and-or tree a
k-alternation tree if its alternation number is k.
Using the above de�nition, we may summarize the main result of the se tion
that SA �nds an optimal strategy for 0-alternation pre onditioned and-or trees.
To end this se tion let us dis uss a feature of the optimal strategy produ ed by
SA that we will use in the next se tion. Consider an internal test x and let W be
the set of all maximal best blo ks from all hild subtrees of x. Be ause any maximal
best blo k has higher R-ratio than any of its hild maximal best blo ks (otherwise
it would be ombined with the best hild blo k), so the best blo k for x is grown by
ombining it with maximal best blo ks from W in the order of their nonin reasing
R-ratio until all remaining blo ks from W have lower R-ratio than the urrent blo k
for x. Now assume that x is the root test of the entire tree. Observe that in this
ase it does not really matter whether we reate the best blo k for x or not, be ause
after building the best blo k for x, all remaining blo ks fromW are added at its end
in the order of their nonin reasing R-ratios, to reate the entire strategy. Therefore
we an use the following des ription of the optimal strategy al ulated by SA: given
a set W of all maximal best blo ks for all hild subtrees of the root test x of a tree,
the optimal strategy �rst perform the root test x and then, if the tree is not resolved
yet, performs the blo ks from W , ordered by their nonin reasing R-ratios.
4.2 1-Alternation And-Or Trees
We will present an extension of SA that �nds an optimal strategy for some 1-
alternation pre onditioned and-or trees.
Let T be a 1-alternation pre onditioned and-or tree and let A be a subtree of T .
A is a maximal pure in luded subtree if A is 0-alternation subtree, is not a leaf node,
and the parent node of the root of A has di�erent label (or/and) than the internal
nodes of A. If a maximal pure in luded subtree is an or-subtree (respe tively and-
subtree), we all the subtree a maximal or-subtree (respe tively and-subtree).
We all an internal node degenerate if it is asso iated with a test with ost 0,
su ess probability 1 and required value true. Observe that and-or trees are pre-
onditioned and-or trees whose internal nodes are all degenerate. Also, on e a test
asso iated with an internal node has returned its required value, the node be omes
degenerate.
The following algorithm, proposed in [12℄ is alled DFA
�
: in a 1-alternation pre-
onditioned and-or tree T , �rst run SA on ea h maximal pure in luded subtree of
T . Then repla e ea h maximal pure in luded subtree A by a leaf meta-test, whose
ost is equal to the expe ted ost of the al ulated strategy for A and whose su ess
probability is equal to the probability that A evaluates to true. Given maximal
best blo ks for A found by SA, the expe ted ost and the resolution probability of
the entire strategy an be easily al ulated in the same way as SA al ulates them
for ombined blo ks; the resolution probability of the entire strategy is equal to the
probability that the tree evaluates to true, if it is an or-tree, and to the probability
65
that the tree evaluates to false, if it is an and-tree. After su h a repla ement,
the tree is 0-alternation: use SA again to �nd an optimal strategy for it. In the
resulting strategy we understand that any meta-test denotes the sequen e of tests
for the orresponding original subtree.
We all a strategy S ontiguous on a subtree T
0
if on any root-to-leaf path of
S, whenever a test from T
0
is performed, no test from outside T
0
is performed until
the value of T
0
is determined. Sin e SA al ulates an optimal strategy for any 0-
alternation tree, so DFA
�
produ es an optimal strategy for a 1-alternation tree T if
and only if there exists an optimal strategy for T that is ontiguous on any maximal
pure in luded subtree of T . Unfortunately this is not true for all 1-alternation trees,
as we shall dis uss at the end of this se tion, but there are trees for whi h this
ondition hold. The following theorem spe i�es su h trees.
Theorem 36 DFA
�
produ es an optimal strategy for a 1-alternation pre onditioned
and-or tree T if for ea h maximal pure in luded subtree A of T one of the following
onditions is ful�lled:
i) A is depth one and rooted at a degenerate internal node, or
ii) the required value of ea h internal node of A is true if T is or-rooted, or
false if T is and-rooted.
Proof: Assume that T is an or-rooted pre onditioned and-or tree ful�lling the
onditions of the theorem. The proof for the other ase is symmetri .
If a test from a maximal and subtree in T fails, the entire subtree evaluates to
false. A strategy S is not ontiguous on some maximal and-subtrees if and only if
there is at least one node v of S su h that v is labeled by a test from a maximal and-
subtree A, the substrategy followed when this test is true starts with performing a
test not in A, but ontains at least one node labeled by a test from A. We will all
su h a node v a violating node of a subtree.
Let S be an optimal strategy for T . Let k be the number of violating nodes of
S. We will show that there is an optimal strategy for T that is ontiguous on any
maximal and subtree (from whi h the theorem follows). The proof is by indu tion
on k. The base ase when k = 0 is trivial. Now assume that the statement holds if
k < K, for some K � 1, and let S ontain K violating nodes.
Let v be a violating node of S su h that both hild substrategies of v do not
ontain any violating node (there is at least one su h node). Let S
0
be the strategy
rooted at v and let T
0
be the orresponding redu ed tree, evaluated by S
0
. Let x
be the test that labels v and let A be the maximal and-subtree of T
0
that ontains
test x. Let T
0
+
, T
0
�
be the redu ed trees obtained from T
0
when x is true, false
respe tively and let S
0
+
, S
0
�
be the substrategies of S
0
followed when x is true, false
respe tively.
If T
0
ontains any and-subtree other than A, then it is evaluated as one meta-test
by both S
0
+
and S
0
�
. Thus we may repla e any su h subtree by a single meta-test,
in other words we may assume that A is the only and-subtree of T
0
.
A test from a pre onditioned and-or tree is available to perform if it is a root
test, or if all internal nodes on the path from the root of the tree to the test are
degenerate. We an ollapse any degenerate node that is a hild of a node with the
66
+
-
x
b1b2...b l A+ d1d2...dm
b1b2...b l d1d2...dm
Figure 4.4: An illustration for the proof of Theorem 36; the substrategy S
0
.
same label (and/or), thus a test from a tree an be perform only if it is the root
test or there is a path of degenerate internal nodes from the root of the tree to the
parent node of the test stri tly alternating between and-nodes and or-nodes.
Therefore in T
0
test x is either a root of A or a hild of the root of A, and the
root of A is a hild of the root of T
0
. If x is false, the entire subtree A, and only
it, disappears. Let A
+
be the redu ed subtree obtained from A
+
when x is true.
Noti e that S
0
+
evaluates A
+
as one meta-test. Thus we an treat A
+
as a one node,
observe that it is a leaf hild of the root of T
0
+
.
We may assume that S
0
+
and S
0
�
are obtained by running SA on T
0
+
and T
0
�
respe tively (be ause if they are not, they may be repla ed by su h optimal strate-
gies). Let W
+
and W
�
be the sets of all maximal best blo ks for all hild subtrees
of the root of T
0
+
and T
0
�
respe tively. S
0
+
(respe tively S
0
�
) �rst performs the de-
generate root test and then preforms blo ks from W
+
(respe tively W
�
) in order of
their R-ratio. Sin e A
+
is a single leaf hild of the root, so it is a separate maximal
best blo k in W
+
. All other subtrees of the root are the same for both T
0
+
and T
0
�
,
so W
+
= W
�
[ fA
+
g. Let b
1
; b
2
; : : : ; b
l
, l � 1 be all maximal best blo ks from W
+
performed (in this order) by S
0
+
before A
+
, and d
1
; d
2
; : : : ; d
m
, m � 0 be all (if any)
maximal best blo ks performed (in this order) by S
0
+
after A
+
. This means that S
0
�
performs maximal blo ks b
1
; b
2
; : : : ; b
l
; d
1
; d
2
; : : : ; d
m
, in this order. S
0
is shown on
Figure 4.4.
Let b be the blo k onsisting of b
1
; b
2
; : : : ; b
l
. Sin e A
+
is a hild of the root
test, so it does not depend on any internal test from the blo k b; A
+
is performed
if b does not resolve the tree. For any 1 � i � m let P
0
(d
i
) be the probability that
b; d
1
; d
2
; : : : ; d
i�1
fail to resolve the tree but in su h a way that performing d
i
is still
possible. Thus we have the following expression for the expe ted ost of the strategy
S
0
:
C(S
0
) = (x) +
+p(x)
"
C(b) + (1� P
r
(b))C(A
+
) + (1� P
r
(A
+
))
m
X
i=1
P
0
(d
i
)C(d
i
)
#
+
+�p(x)
"
C(b) +
m
X
i=1
P
0
(d
i
)C(d
i
)
#
=
= (x) + C(b) + p(x)(1� P
r
(b))C(A
+
) +
+
h
p(x)(1 � P
r
(A
+
)) + �p(x)
i
m
X
i=1
P
0
(d
i
)C(d
i
): (4.15)
Now let S
0�
be the linear strategy onsisting of blo ks b; x;A
+
; d
1
; d
2
; : : : ; d
m
in this
order. Test x also does not depend on any internal node from b. Thus the expe ted
67
ost of S
0�
is given by
C(S
0�
) = C(b) + (1� P
r
(b)) (x) + (1� P
r
(b))p(x)C(A
+
) +
+
h
�p(x) + p(x)(1� P
r
(A
+
))
i
m
X
i=1
P
0
(d
i
)C(d
i
) =
= C(S
0
)� P
r
(b) (x) �
� C(S
0
): (4.16)
Sin e S
0
is optimal for T
0
, thus so is S
0�
. We an repla e the substrategy S
0
in
the optimal strategy S by S
0�
. But there is no violating node in S
0�
, so after this
repla ement S has K � 1 violating nodes, so by the indu tive assumption there is
an optimal strategy for T that is ontiguous on any maximal and-subtree. 2
If a 1-alternation tree is and-rooted and some or-nodes have the required value
true or, equivalently, it is or-rooted and some and-nodes have the required value
false, the strategy produ ed by DFA
�
is not ne essary optimal. Figure 4.5 presents
an and-rooted tree, for whi h the unique optimal strategy is not ontiguous on the
maximal or-subtree.
a+
e+
g
c+b
d
f
p=1
p=0.9
p=0.1p=0.8
p=0.1
p=0.9p=0.9
a-
-
-
-+
c+
d+
b+ +
e-
-
+b
+
-
-
f+
+
-
-g
++
-
-
- -
a) b)
Figure 4.5: a) A 1-alternation and-rooted pre onditioned and-or tree T
p
. The
required value of ea h internal node is true. All tests have unit osts. b) The
unique optimal strategy for the tree T
p
. This strategy is not ontiguous on the
maximal or-subtree.
While DFA
�
may also produ e an suboptimal strategy for a tree that ontains a
depth one maximal pure in luded subtree rooted at a non-degenerate node, we an
use a simple pro edure to transform any depth one maximal pure in luded subtree
into a depth one maximal pure in luded subtree rooted at a degenerate node. Let
A be a depth one maximal pure in luded subtree of a 1-alternation tree T and let
x be the test asso iated with the root of A.
Let L
1
be the label (and/or) of the root of T and let L
2
be the (di�erent)
label of the root of A. Now onsider the following subtree A
0
: the root v of A
0
is asso iated with test x but has label L
1
. The root v has only one hild node w
whi h is a degenerate node with label L
2
. The leaf nodes of A are the hild nodes of
w. Figure 4.6 illustrates the subtrees A and A
0
. Subtrees A and A
0
are equivalent.
If we repla e A by A
0
in the tree T , then instead of a depth one maximal pure
68
x+
z3z2z1
y+
z3z2z1
x+
p=1c=0
A A'
Figure 4.6: Two equivalent pre onditioned and-or trees A and A
0
. The root of A is
an or-node asso iated with a test x. The root of A
0
is an and-node asso iated with
the test x, A
0
ontains a depth one or-subtree rooted at a degenerate node.
in luded subtree rooted at a non-degenerate node, we have a depth one maximal
pure in luded subtree with a degenerate root node.
Therefore, if all maximal pure in luded subtrees with depth greater than one
ful�ll the ondition (ii) of Theorem 36, then after pro essing all depth one maximal
pure in luded subtrees in a tree as des ribed above we obtain a tree for whi h DFA
�
omputes an optimal strategy. The pro essing takes onstant time for every su h
subtree.
69
Chapter 5
Con lusion
The problem of �nding an optimal strategy for an arbitrary and-or tree remains
open. In this thesis we showed that for tests that are hild nodes of the same internal
node, there exists a relative order of performing the tests by an optimal strategy
that does not depend on the other parts of the tree. Moreover, some of su h sibling
tests are always performed together. These �ndings led to the design of the Dynami
Programming Algorithm (DPA) to �nd an optimal strategy for and-or trees whi h
runs in time O(d
2
n
d
), where n is the number of tests in the tree and d is the number
of internal nodes that are leaf-parents. For and-or trees with a bounded number of
internal nodes this time is learly polynomial in the trees' size. We also showed that
the known eÆ ient algorithm DFA produ es an optimal strategy for depth three
and-or trees whose all tests are identi al (have the same ost and probability of
su ess). For other type of trees with identi al tests: parameter-uniform ladders, an
optimal strategy also an be found in a simple, eÆ ient way. On the other hand,
we showed that the probabilisti and-or tree resolution for trees whose all tests
have the same ost, but may have di�erent su ess probability, an be used as an
approximation of the problem with arbitrary osts.
We also studied a sub lass of probabilisti Boolean expressions with pre eden e
onstraints imposed on the set of tests, alled pre onditioned and-or trees. We
showed that an extension of Smith's Algorithm produ es an optimal strategy for
some type of su h expressions.
We hope that the optimal order of performing sibling tests we des ribed may
be helpful in designing a polynomial-time algorithm to solve the problem, either for
general and-or trees or at least for further sub lasses (for example for depth three
and-or trees). Su h an algorithm does not ne essary have to onstru t the entire
strategy at on e (as DPA or DFA does); it would be suÆ ient to show how to �nd in
polynomial time the �rst test to be performed, as we an simply redu e the original
tree, given the value of the �rst test and re urse.
If it turns out that PAOTR is NP -hard, then it would be of interest to �nd
an approximation algorithm. The present known algorithms annot be used in this
way: DPA does not run in polynomial time for general and-or trees, whereas the
strategy produ ed by DFA may be arbitrarily worse than the optimal one for some
trees.
In the thesis we showed how to �nd an optimal strategy for two types of parameter-
70
uniform trees. It is interesting whether PAOTR for parameter-uniform trees is sim-
pler than the general problem; whether the algorithm to �nd an optimal strategy
for and-or trees with identi al tests an be designed.
Pre onditioned and-or trees generalize and-or trees. We showed how to �nd
an optimal strategy for a subset of 1-alternation pre onditioned and-or trees; the
important �rst step on the way to solving the general problem would be to dis over
an algorithm for an arbitrary 1-alternation tree.
71
Bibliography
[1℄ Je�rey A. Barnett. How mu h is ontrol knowledge worth? A primitive exam-
ple. Arti� ial Intelligen e, 22:77-89, 1984.
[2℄ Moses Charikar, Ronald Fagin, Venkatesan Guruswami, Jon Kleinberg, Prab-
hakar Raghavan and Amit Sahai. Query strategies for pri ed information. J.
Computer and System S ien es, 64:785-819, 2002.
[3℄ D. G. Corneil, H. Ler hs, L. Stewart Burlingham. Complement redu ible
graphs. Dis rete Applied Mathemati s, 3:163-174, 1981.
[4℄ D. G. Corneil, Y. Pearl, L. K. Stewart. A linear re ognition algorithm for
ographs. SIAM Journal of Computing, 14:926-934, 1985.
[5℄ Thomas H. Cormen. Charles E. Leiserson, Ronald L. Rivest, Cli�ord Stein.
Introdu tion to Algorithms The MIT Press, Cambridge, Massa husetts, 2001.
[6℄ Mi hael R. Garey. Optimal task sequen ing with pre eden e onstraints. Dis-
rete Mathemati s, 4:37-56, 1973
[7℄ Mi hael R. Garey and David S. Johnson. Computers and Intra tability. A Guide
to the Theory of NP-Completeness. W. H. Freeman and Company, New York,
1979.
[8℄ Dan Geiger and Je�rey A. Barnett. Optimal satis� ing tree sear hes. Pro eed-
ings of AAAI-91, 441-445, 1991.
[9℄ Martin C. Golumbi , Aviad Mintz, Udi Roti s. Fa toring and Re ognition of
Read-On e Fun tions using Cographs and Normality. Pro eedings of the 38th
Design Automation Conferen e, 109-114, 2001.
[10℄ Russell Greiner. Finding optimal derivation strategies in redundant knowledge
bases. Arti� ial Intelligen e, 50:95-115, 1991.
[11℄ Russell Greiner, Pekka Orponen. Probably approximately optimal satis� ing
strategies. Arti� ial Intelligen e, 82:21-44, 1996.
[12℄ Russell Greiner, Ryan Hayward and Mi hael Molloy. Optimal depth-�rst strate-
gies for and-or trees. Pro eedings of AAAI-02, 725-730, 2002.
[13℄ Ra� Heiman, Avi Wigderson. Randomized vs. deterministi de ision tree om-
plexity for read-on e boolean fun tion. Pro eedings of 6th IEEE Stru ture in
Complexity Theory, 172-179, 1991.
72
[14℄ Ri hard M. Karp and Yanjun Zhang. Bounded bran hing pro ess and AND/OR
tree evaluation. Random Stru tures and Algorithms, 7(2):97-116, 1995.
[15℄ H. Ler hs. On liques and kernels. Te hni al Report, Dept. of Computer S i-
en e, University of Toronto, 1971.
[16℄ David Fran is Manlove. Minimaximal and maximinimal optimisation problems:
a partial order-based approa h. PhD Thesis, University of Glasgow, 1998.
[17℄ K. S. Natarajan. Optimizing depth-�rst sear h of AND-OR trees. Report RC-
11842, IBM Watson Resear h Center, 1986.
[18℄ Christos H. Papadimitriou. Computational Complexity. Addison-Wesley, Reas-
ing, MA, 1995.
[19℄ Judea Pearl. Asymptoti properties of minimax trees and game-sear hing pro-
edures. Arti� ial Intelligen e, 14(2):113-138, 1980.
[20℄ Judea Pearl. Heuristi . Addison-Wesley, Reading, MA, 1984.
[21℄ Stuart Russell, Peter Norvig. Arti� ial Intelligen e: A Modern Approa h. Pren-
ti e Hall, 1995.
[22℄ Sartaj Sahni. Computationally related problems. SIAM Journal on Computing,
3(4):262-279, 1974.
[23℄ Mi hael Saks, Avi Wigderson. Probabilisti boolean de ision trees and the om-
plexity of evaluating game trees. Pro eedings of 27th IEEE FOCS, 29-38, 1986.
[24℄ Miklos Santha. On the Monte Carlo boolean de ision tree omplexity of read-
on e formulae. Random Stru tures and Algorithms 6(1):75-88, 1995.
[25℄ Herbert A. Simon and Joseph B. Kadane. Optimal problem-solving sear h: all-
or-none solutions. Arti� ial Intelligen e, 6:235-247, 1975.
[26℄ David E. Smith. Controlling ba kward inferen e. Arti� ial Intelligen e,
39(2):145-208, 1989.
[27℄ Mi hael Tarsi. Optimal sear h on some game trees. Journal of ACM, 30:389-
396, 1983.
[28℄ L. Valiant. A theory of the learnable. Communi ations of the ACM,
27(11):1134-1142, 1984.
73