46
Optimal Implementation of Watched Literals and More General Techniques Ian Gent University of St Andrews Scotland [email protected] Note: this paper will appear in JAIR, in press Monday, 16 September 13

Optimal Implementation of Watched Literals and More General Techniques

Embed Size (px)

DESCRIPTION

Slides for presentation at CSPSAT Workshop 2013, Uppsala. Based on paper to appear in JAIR

Citation preview

Optimal Implementation of Watched Literals and More General

Techniques

Ian GentUniversity of St Andrews

Scotland

[email protected]

Note: this paper will appear in JAIR, in press

Monday, 16 September 13

A surprising result

• Dangerous to use the word “surprising”

• in fact deleted from final version of paper

• But it surprised me

• And it surprised Pete Nightingale

• And it surprised Christian Bessiere

• And there’s no hint of it in the literature

• So I call it surprising

Monday, 16 September 13

Some conventional wisdom is wrong

• Searching a linear list for key element

• e.g. watched literals in SAT

• e.g. support lists in CSP

• Don’t have to backtrack pointer (well known)

• And can still retain optimality (result of this paper)

• Was thought to be non-optimal

• work can be repeated many times on a single branch

• But a different partition of tree gives result

Monday, 16 September 13

The Setup• We are in backtracking search (depth-first like)

• Elements in LIST might be acceptable

• e.g. domain value still valid

• Acceptability is monotonic

• if an element of LIST is unacceptable

• it is unacceptable at all descendant nodes

• When LIST has no acceptable elements

• e.g. no valid values still exist

• Search engine needs to be notified immediately

• typically to perform some propagation

Monday, 16 September 13

The Setup• We maintain a pointer last

• With the following invariant

• EITHER LIST[last] is acceptable

• OR no element in LIST is acceptable

• When LIST[last] becomes unacceptable

• System notifies us (through some assumed mechanism)

• Look for new value of last

• If we can’t find one...

• then no element in LIST is acceptable

• We can notify search engine this information

Monday, 16 September 13

Three ways to maintain last

1. We do not store state of last at all

• Search LIST from start every time

• Can check the same element multiple times per branch

2. Restore value of last on backtracking

• Scan list once only per branch

• But requires additional memory

3. Store value of last without backtracking

• continue search from last+1

• but have to cycle round to start of LIST at end

Monday, 16 September 13

Find-New-Element (FNE)

• FNE: procedure to find new value of last

• Called by our assumed mechanism

• when LIST[last] becomes unacceptable

• Three variants for three approaches

1. last not stored between calls

2. last stored and restored on backtracking

3. last stored but not restored

• call this “circular” because of cycle at end of LIST

Monday, 16 September 13

No State Stored

Optimal Implementation of Watched Literals

node of the search tree, if list[last ] changes from being acceptable to unacceptable, thenfindNewElement(list) will be called before the next node is visited, except when back-tracking occurs from this node before any descendant node is visited. For the purposes ofthis paper, detection of unacceptability is not counted as a call to acceptable: whatevercost this detection has is the same for each approach studied here. We assume an initiali-sation phase in which O(N) calls to acceptable are made to find the initial value of last :these calls are considered as preprocessing and not charged to any node in the search tree.We also assume that calls to findNewElement are only made during initialisation andafter unacceptability has been detected.

Each variant of findNewElement has to ensure the following invariant is maintained.Note that this invariant means when one of the first two cases holds, the value list[last ] isunacceptable i! there is no acceptable element in the list.

Invariant 2. At all times at least one of the following is true:

• the value list[last ] is acceptable; or

• there is no acceptable element in list; or

• the initialisation process has not completed; or

• the value list[last ] has become unacceptable at the current node but findNewEle-ment has not yet been called and completed.

Many calls to findNewElement may happen at a single node, because facts aboutacceptability may not become known at the same time. For example, in the case of unitpropagations in SAT, the current watched literal (i.e. list[last ]) may become unsatisfiable(unacceptable), so we have to scan for a new watched literal (value of last). But laterpropagations at the same node can make this new value unsatisfiable, leading to new scans.

This paper compares three implementations of findNewElement and shows the goodproperties of the last one. The di!erences arise from how last is dealt with in betweeninvocations of findNewElement. The simplest variant is shown in Procedure 1: eachtime it is called the previous value of last is discarded and the list searched from thebeginning.

Procedure 1: FNE-NoState(list)

1: last := -12: repeat

3: last := last + 14: if acceptable(list,last) then return true5: until last = N6: return false

Procedure 1 is simple, certainly maintains Invariant 2, and is highly space-e"cient. Ithas a significant disadvantage in that its worst case is to require #(N2) calls to acceptableat every leaf node, stated here as Proposition 3 and proved in Appendix E. (Appendix E isomitted from the main text but is available online, see Appendix D.)

3

Monday, 16 September 13

State restored on backtracking

Gent

Proposition 3. The procedure FNE-NoState maintains Invariant 2. It makes O(N2)calls to acceptable per branch of a search tree, but requires !(N2) in the worst case.(Proof in Appendix E online.)

The remaining two variants both use FNE-NoState to initialise last , but make di"erentcalls thereafter. The second variant is based on state restoration. Each call continues searchfrom the most recent value of last found at the current node or any of its ancestors. Sincethe value of last may be changed by descendent nodes, some mechanism of the backtrackingsearch solver must be exploited to restore the value of last when backtracking occurs. Whatthis method is will vary between solvers, and is not critical for this paper. Given this, thismethod is shown as Procedure 2.

Procedure 2: FNE-RestoreState(list)

1: repeat

2: last := last + 13: if acceptable(list,last) then return true4: until last = N5: return false

Since acceptability is monotonic and last is always restored to the value it had previously,the invariant is guaranteed. We have the following, for which no proof should be necessary.

Proposition 4. The procedure FNE-RestoreState maintains Invariant 2. On any givenbranch of the search tree from root to leaf node, at most N calls to acceptable are made.

In the final, “backtrack-stable”, variant, we do not restore former values of last onbacktracking. We now have the problem that down a branch, or even at a single node, thevalue of last can be moved by later nodes and not restored when we return to the currentnode. To deal with this correctly, we have to allow every element of list to be checkedeven if some may have already been checked higher on the current branch or even at thesame node. The focus of this paper is the “circular” method for checking all elements: atthe end of the list we circle around from the end of the list to zero, and continue checkinguntil we hit the value that last had when the call was made. For initialisation we call theabove procedure FNE-NoState. All subsequent calls are to the following.

Procedure 3: FNE-Circular(list)

1: last-cache := last2: repeat

3: last := last + 14: if last = N then last := 05: if acceptable(list,last) then return true6: until last = last-cache7: return false

No claim is made for originality of the circular method: it was used by Gent, Je"erson,and Miguel (2006b) and probably by earlier authors. Unlike the previous variants, theinvariant does not hold for all search algorithms. Correctness will be proved in Section 3below, in the context of ‘downwards-explored search trees’, as defined in Definition 5.

4

Monday, 16 September 13

Circular: State Stored but not backtracked

Gent

Proposition 3. The procedure FNE-NoState maintains Invariant 2. It makes O(N2)calls to acceptable per branch of a search tree, but requires !(N2) in the worst case.(Proof in Appendix E online.)

The remaining two variants both use FNE-NoState to initialise last , but make di"erentcalls thereafter. The second variant is based on state restoration. Each call continues searchfrom the most recent value of last found at the current node or any of its ancestors. Sincethe value of last may be changed by descendent nodes, some mechanism of the backtrackingsearch solver must be exploited to restore the value of last when backtracking occurs. Whatthis method is will vary between solvers, and is not critical for this paper. Given this, thismethod is shown as Procedure 2.

Procedure 2: FNE-RestoreState(list)

1: repeat

2: last := last + 13: if acceptable(list,last) then return true4: until last = N5: return false

Since acceptability is monotonic and last is always restored to the value it had previously,the invariant is guaranteed. We have the following, for which no proof should be necessary.

Proposition 4. The procedure FNE-RestoreState maintains Invariant 2. On any givenbranch of the search tree from root to leaf node, at most N calls to acceptable are made.

In the final, “backtrack-stable”, variant, we do not restore former values of last onbacktracking. We now have the problem that down a branch, or even at a single node, thevalue of last can be moved by later nodes and not restored when we return to the currentnode. To deal with this correctly, we have to allow every element of list to be checkedeven if some may have already been checked higher on the current branch or even at thesame node. The focus of this paper is the “circular” method for checking all elements: atthe end of the list we circle around from the end of the list to zero, and continue checkinguntil we hit the value that last had when the call was made. For initialisation we call theabove procedure FNE-NoState. All subsequent calls are to the following.

Procedure 3: FNE-Circular(list)

1: last-cache := last2: repeat

3: last := last + 14: if last = N then last := 05: if acceptable(list,last) then return true6: until last = last-cache7: return false

No claim is made for originality of the circular method: it was used by Gent, Je"erson,and Miguel (2006b) and probably by earlier authors. Unlike the previous variants, theinvariant does not hold for all search algorithms. Correctness will be proved in Section 3below, in the context of ‘downwards-explored search trees’, as defined in Definition 5.

4Monday, 16 September 13

Example Search Tree

Optimal Implementation of Watched Literals

.One di!erence between Procedures 2 and 3 should be noted. At a given node of the

search tree, Procedure 2 can make at most N calls to acceptable. However, Procedure3 can, perhaps counterintuitively, require almost 2N calls at a single node. For example,suppose at a given node we have last = 0. If this value becomes unacceptable and the onlyother acceptable value is N ! 1, this requires N ! 1 calls to set last = N ! 1. Furtherpropagation may later make N ! 1 unacceptable also. The resulting new call to Procedure3 cannot find an acceptable value, but must still check all values from 0 to N!2 as it has nomemory of the previous call. (The variable last-cache is local to each call of the Procedure.)This is a further N ! 1 calls to acceptable, for a total of 2N ! 2 at the node.

2.1 Worked Example

I present a worked example of Procedure 3, showing how we can amortize the count of callsto acceptable in a way which will form the basis of the optimality results of this paper.

Figure 1 shows an example search using the circular approach. In the example we assume

node id = 0 :last=14, cost = 14!

last=17

1 :14, 0

last=19

8 :14, 17!

last=16

2 :17, 3! 5 :17, 18!

last=18

9 :16, 21!! 12 :14, 18!

last=15

3 :17, 19! 4 :19, 2! 6 :18, 20!! 7 :17, 19! 10 :16, 0 11 :16, 0 13 :15, 1! 14 :14, 38!!

!

0,1,2,3

= 36!

0,1,2,4

= 19!

0,1,5,6

= 52!

0,1,5,7

= 51!

0,8,9,10

= 52!

0,8,9,11

= 52!

0,8,12,13

= 50!

0,8,12,14

= 87

Figure 1: A search using the circular approach. See main text for description.

that the list being searched has 20 elements, indexed from 0 to 19. and that initialisationsets last = 0. The box at a node indicates the node number (italics), the value of lastafter any calls to FNE-Circular (bold), and the cost of those calls in total at the node(measured as number of calls to acceptable), including a failed call if there is one. A !

indicates a successful call was made, while a " indicates an unsuccessful call. Both can occurat the same node, if the value of last is moved by a successful call, while that value laterbecomes unacceptable, and another call to FNE-Circular fails. A branch is annotatedwith a value of last if the search to the left changed the value of last . For example, at node5 the value of last was 17, but the left child set it to 18, meaning that it had changed whenwe branched right. The total cost for each branch is listed, e.g. 87 for the last branch.

In the example, the first 14 elements become unacceptable at the root, so calls to FNEmust check 14 elements in order to set last = 14. If we restored last the maximum cost

5

Say length of LIST = N = 20

Monday, 16 September 13

Right Hand Branch

Optimal Implementation of Watched Literals

.One di!erence between Procedures 2 and 3 should be noted. At a given node of the

search tree, Procedure 2 can make at most N calls to acceptable. However, Procedure3 can, perhaps counterintuitively, require almost 2N calls at a single node. For example,suppose at a given node we have last = 0. If this value becomes unacceptable and the onlyother acceptable value is N ! 1, this requires N ! 1 calls to set last = N ! 1. Furtherpropagation may later make N ! 1 unacceptable also. The resulting new call to Procedure3 cannot find an acceptable value, but must still check all values from 0 to N!2 as it has nomemory of the previous call. (The variable last-cache is local to each call of the Procedure.)This is a further N ! 1 calls to acceptable, for a total of 2N ! 2 at the node.

2.1 Worked Example

I present a worked example of Procedure 3, showing how we can amortize the count of callsto acceptable in a way which will form the basis of the optimality results of this paper.

Figure 1 shows an example search using the circular approach. In the example we assume

node id = 0 :last=14, cost = 14!

last=17

1 :14, 0

last=19

8 :14, 17!

last=16

2 :17, 3! 5 :17, 18!

last=18

9 :16, 21!! 12 :14, 18!

last=15

3 :17, 19! 4 :19, 2! 6 :18, 20!! 7 :17, 19! 10 :16, 0 11 :16, 0 13 :15, 1! 14 :14, 38!!

!

0,1,2,3

= 36!

0,1,2,4

= 19!

0,1,5,6

= 52!

0,1,5,7

= 51!

0,8,9,10

= 52!

0,8,9,11

= 52!

0,8,12,13

= 50!

0,8,12,14

= 87

Figure 1: A search using the circular approach. See main text for description.

that the list being searched has 20 elements, indexed from 0 to 19. and that initialisationsets last = 0. The box at a node indicates the node number (italics), the value of lastafter any calls to FNE-Circular (bold), and the cost of those calls in total at the node(measured as number of calls to acceptable), including a failed call if there is one. A !

indicates a successful call was made, while a " indicates an unsuccessful call. Both can occurat the same node, if the value of last is moved by a successful call, while that value laterbecomes unacceptable, and another call to FNE-Circular fails. A branch is annotatedwith a value of last if the search to the left changed the value of last . For example, at node5 the value of last was 17, but the left child set it to 18, meaning that it had changed whenwe branched right. The total cost for each branch is listed, e.g. 87 for the last branch.

In the example, the first 14 elements become unacceptable at the root, so calls to FNEmust check 14 elements in order to set last = 14. If we restored last the maximum cost

5

At Node 0, we set last=14, total cost = 14

Monday, 16 September 13

Optimal Implementation of Watched Literals

.One di!erence between Procedures 2 and 3 should be noted. At a given node of the

search tree, Procedure 2 can make at most N calls to acceptable. However, Procedure3 can, perhaps counterintuitively, require almost 2N calls at a single node. For example,suppose at a given node we have last = 0. If this value becomes unacceptable and the onlyother acceptable value is N ! 1, this requires N ! 1 calls to set last = N ! 1. Furtherpropagation may later make N ! 1 unacceptable also. The resulting new call to Procedure3 cannot find an acceptable value, but must still check all values from 0 to N!2 as it has nomemory of the previous call. (The variable last-cache is local to each call of the Procedure.)This is a further N ! 1 calls to acceptable, for a total of 2N ! 2 at the node.

2.1 Worked Example

I present a worked example of Procedure 3, showing how we can amortize the count of callsto acceptable in a way which will form the basis of the optimality results of this paper.

Figure 1 shows an example search using the circular approach. In the example we assume

node id = 0 :last=14, cost = 14!

last=17

1 :14, 0

last=19

8 :14, 17!

last=16

2 :17, 3! 5 :17, 18!

last=18

9 :16, 21!! 12 :14, 18!

last=15

3 :17, 19! 4 :19, 2! 6 :18, 20!! 7 :17, 19! 10 :16, 0 11 :16, 0 13 :15, 1! 14 :14, 38!!

!

0,1,2,3

= 36!

0,1,2,4

= 19!

0,1,5,6

= 52!

0,1,5,7

= 51!

0,8,9,10

= 52!

0,8,9,11

= 52!

0,8,12,13

= 50!

0,8,12,14

= 87

Figure 1: A search using the circular approach. See main text for description.

that the list being searched has 20 elements, indexed from 0 to 19. and that initialisationsets last = 0. The box at a node indicates the node number (italics), the value of lastafter any calls to FNE-Circular (bold), and the cost of those calls in total at the node(measured as number of calls to acceptable), including a failed call if there is one. A !

indicates a successful call was made, while a " indicates an unsuccessful call. Both can occurat the same node, if the value of last is moved by a successful call, while that value laterbecomes unacceptable, and another call to FNE-Circular fails. A branch is annotatedwith a value of last if the search to the left changed the value of last . For example, at node5 the value of last was 17, but the left child set it to 18, meaning that it had changed whenwe branched right. The total cost for each branch is listed, e.g. 87 for the last branch.

In the example, the first 14 elements become unacceptable at the root, so calls to FNEmust check 14 elements in order to set last = 14. If we restored last the maximum cost

5

Stuff happens on left hand subtree and value of last changes

Right Hand Branch

Monday, 16 September 13

Optimal Implementation of Watched Literals

.One di!erence between Procedures 2 and 3 should be noted. At a given node of the

search tree, Procedure 2 can make at most N calls to acceptable. However, Procedure3 can, perhaps counterintuitively, require almost 2N calls at a single node. For example,suppose at a given node we have last = 0. If this value becomes unacceptable and the onlyother acceptable value is N ! 1, this requires N ! 1 calls to set last = N ! 1. Furtherpropagation may later make N ! 1 unacceptable also. The resulting new call to Procedure3 cannot find an acceptable value, but must still check all values from 0 to N!2 as it has nomemory of the previous call. (The variable last-cache is local to each call of the Procedure.)This is a further N ! 1 calls to acceptable, for a total of 2N ! 2 at the node.

2.1 Worked Example

I present a worked example of Procedure 3, showing how we can amortize the count of callsto acceptable in a way which will form the basis of the optimality results of this paper.

Figure 1 shows an example search using the circular approach. In the example we assume

node id = 0 :last=14, cost = 14!

last=17

1 :14, 0

last=19

8 :14, 17!

last=16

2 :17, 3! 5 :17, 18!

last=18

9 :16, 21!! 12 :14, 18!

last=15

3 :17, 19! 4 :19, 2! 6 :18, 20!! 7 :17, 19! 10 :16, 0 11 :16, 0 13 :15, 1! 14 :14, 38!!

!

0,1,2,3

= 36!

0,1,2,4

= 19!

0,1,5,6

= 52!

0,1,5,7

= 51!

0,8,9,10

= 52!

0,8,9,11

= 52!

0,8,12,13

= 50!

0,8,12,14

= 87

Figure 1: A search using the circular approach. See main text for description.

that the list being searched has 20 elements, indexed from 0 to 19. and that initialisationsets last = 0. The box at a node indicates the node number (italics), the value of lastafter any calls to FNE-Circular (bold), and the cost of those calls in total at the node(measured as number of calls to acceptable), including a failed call if there is one. A !

indicates a successful call was made, while a " indicates an unsuccessful call. Both can occurat the same node, if the value of last is moved by a successful call, while that value laterbecomes unacceptable, and another call to FNE-Circular fails. A branch is annotatedwith a value of last if the search to the left changed the value of last . For example, at node5 the value of last was 17, but the left child set it to 18, meaning that it had changed whenwe branched right. The total cost for each branch is listed, e.g. 87 for the last branch.

In the example, the first 14 elements become unacceptable at the root, so calls to FNEmust check 14 elements in order to set last = 14. If we restored last the maximum cost

5

Stuff happens on left hand subtree and value of last changes

Right Hand Branch

Monday, 16 September 13

Optimal Implementation of Watched Literals

.One di!erence between Procedures 2 and 3 should be noted. At a given node of the

search tree, Procedure 2 can make at most N calls to acceptable. However, Procedure3 can, perhaps counterintuitively, require almost 2N calls at a single node. For example,suppose at a given node we have last = 0. If this value becomes unacceptable and the onlyother acceptable value is N ! 1, this requires N ! 1 calls to set last = N ! 1. Furtherpropagation may later make N ! 1 unacceptable also. The resulting new call to Procedure3 cannot find an acceptable value, but must still check all values from 0 to N!2 as it has nomemory of the previous call. (The variable last-cache is local to each call of the Procedure.)This is a further N ! 1 calls to acceptable, for a total of 2N ! 2 at the node.

2.1 Worked Example

I present a worked example of Procedure 3, showing how we can amortize the count of callsto acceptable in a way which will form the basis of the optimality results of this paper.

Figure 1 shows an example search using the circular approach. In the example we assume

node id = 0 :last=14, cost = 14!

last=17

1 :14, 0

last=19

8 :14, 17!

last=16

2 :17, 3! 5 :17, 18!

last=18

9 :16, 21!! 12 :14, 18!

last=15

3 :17, 19! 4 :19, 2! 6 :18, 20!! 7 :17, 19! 10 :16, 0 11 :16, 0 13 :15, 1! 14 :14, 38!!

!

0,1,2,3

= 36!

0,1,2,4

= 19!

0,1,5,6

= 52!

0,1,5,7

= 51!

0,8,9,10

= 52!

0,8,9,11

= 52!

0,8,12,13

= 50!

0,8,12,14

= 87

Figure 1: A search using the circular approach. See main text for description.

that the list being searched has 20 elements, indexed from 0 to 19. and that initialisationsets last = 0. The box at a node indicates the node number (italics), the value of lastafter any calls to FNE-Circular (bold), and the cost of those calls in total at the node(measured as number of calls to acceptable), including a failed call if there is one. A !

indicates a successful call was made, while a " indicates an unsuccessful call. Both can occurat the same node, if the value of last is moved by a successful call, while that value laterbecomes unacceptable, and another call to FNE-Circular fails. A branch is annotatedwith a value of last if the search to the left changed the value of last . For example, at node5 the value of last was 17, but the left child set it to 18, meaning that it had changed whenwe branched right. The total cost for each branch is listed, e.g. 87 for the last branch.

In the example, the first 14 elements become unacceptable at the root, so calls to FNEmust check 14 elements in order to set last = 14. If we restored last the maximum cost

5

We loop round to set last=14 (again!) total cost = 17

Right Hand Branch

Monday, 16 September 13

Optimal Implementation of Watched Literals

.One di!erence between Procedures 2 and 3 should be noted. At a given node of the

search tree, Procedure 2 can make at most N calls to acceptable. However, Procedure3 can, perhaps counterintuitively, require almost 2N calls at a single node. For example,suppose at a given node we have last = 0. If this value becomes unacceptable and the onlyother acceptable value is N ! 1, this requires N ! 1 calls to set last = N ! 1. Furtherpropagation may later make N ! 1 unacceptable also. The resulting new call to Procedure3 cannot find an acceptable value, but must still check all values from 0 to N!2 as it has nomemory of the previous call. (The variable last-cache is local to each call of the Procedure.)This is a further N ! 1 calls to acceptable, for a total of 2N ! 2 at the node.

2.1 Worked Example

I present a worked example of Procedure 3, showing how we can amortize the count of callsto acceptable in a way which will form the basis of the optimality results of this paper.

Figure 1 shows an example search using the circular approach. In the example we assume

node id = 0 :last=14, cost = 14!

last=17

1 :14, 0

last=19

8 :14, 17!

last=16

2 :17, 3! 5 :17, 18!

last=18

9 :16, 21!! 12 :14, 18!

last=15

3 :17, 19! 4 :19, 2! 6 :18, 20!! 7 :17, 19! 10 :16, 0 11 :16, 0 13 :15, 1! 14 :14, 38!!

!

0,1,2,3

= 36!

0,1,2,4

= 19!

0,1,5,6

= 52!

0,1,5,7

= 51!

0,8,9,10

= 52!

0,8,9,11

= 52!

0,8,12,13

= 50!

0,8,12,14

= 87

Figure 1: A search using the circular approach. See main text for description.

that the list being searched has 20 elements, indexed from 0 to 19. and that initialisationsets last = 0. The box at a node indicates the node number (italics), the value of lastafter any calls to FNE-Circular (bold), and the cost of those calls in total at the node(measured as number of calls to acceptable), including a failed call if there is one. A !

indicates a successful call was made, while a " indicates an unsuccessful call. Both can occurat the same node, if the value of last is moved by a successful call, while that value laterbecomes unacceptable, and another call to FNE-Circular fails. A branch is annotatedwith a value of last if the search to the left changed the value of last . For example, at node5 the value of last was 17, but the left child set it to 18, meaning that it had changed whenwe branched right. The total cost for each branch is listed, e.g. 87 for the last branch.

In the example, the first 14 elements become unacceptable at the root, so calls to FNEmust check 14 elements in order to set last = 14. If we restored last the maximum cost

5

Stuff happens on left hand subtree and value of last changes

Right Hand Branch

Monday, 16 September 13

Optimal Implementation of Watched Literals

.One di!erence between Procedures 2 and 3 should be noted. At a given node of the

search tree, Procedure 2 can make at most N calls to acceptable. However, Procedure3 can, perhaps counterintuitively, require almost 2N calls at a single node. For example,suppose at a given node we have last = 0. If this value becomes unacceptable and the onlyother acceptable value is N ! 1, this requires N ! 1 calls to set last = N ! 1. Furtherpropagation may later make N ! 1 unacceptable also. The resulting new call to Procedure3 cannot find an acceptable value, but must still check all values from 0 to N!2 as it has nomemory of the previous call. (The variable last-cache is local to each call of the Procedure.)This is a further N ! 1 calls to acceptable, for a total of 2N ! 2 at the node.

2.1 Worked Example

I present a worked example of Procedure 3, showing how we can amortize the count of callsto acceptable in a way which will form the basis of the optimality results of this paper.

Figure 1 shows an example search using the circular approach. In the example we assume

node id = 0 :last=14, cost = 14!

last=17

1 :14, 0

last=19

8 :14, 17!

last=16

2 :17, 3! 5 :17, 18!

last=18

9 :16, 21!! 12 :14, 18!

last=15

3 :17, 19! 4 :19, 2! 6 :18, 20!! 7 :17, 19! 10 :16, 0 11 :16, 0 13 :15, 1! 14 :14, 38!!

!

0,1,2,3

= 36!

0,1,2,4

= 19!

0,1,5,6

= 52!

0,1,5,7

= 51!

0,8,9,10

= 52!

0,8,9,11

= 52!

0,8,12,13

= 50!

0,8,12,14

= 87

Figure 1: A search using the circular approach. See main text for description.

that the list being searched has 20 elements, indexed from 0 to 19. and that initialisationsets last = 0. The box at a node indicates the node number (italics), the value of lastafter any calls to FNE-Circular (bold), and the cost of those calls in total at the node(measured as number of calls to acceptable), including a failed call if there is one. A !

indicates a successful call was made, while a " indicates an unsuccessful call. Both can occurat the same node, if the value of last is moved by a successful call, while that value laterbecomes unacceptable, and another call to FNE-Circular fails. A branch is annotatedwith a value of last if the search to the left changed the value of last . For example, at node5 the value of last was 17, but the left child set it to 18, meaning that it had changed whenwe branched right. The total cost for each branch is listed, e.g. 87 for the last branch.

In the example, the first 14 elements become unacceptable at the root, so calls to FNEmust check 14 elements in order to set last = 14. If we restored last the maximum cost

5

Stuff happens on left hand subtree and value of last changes

Right Hand Branch

Monday, 16 September 13

Optimal Implementation of Watched Literals

.One di!erence between Procedures 2 and 3 should be noted. At a given node of the

search tree, Procedure 2 can make at most N calls to acceptable. However, Procedure3 can, perhaps counterintuitively, require almost 2N calls at a single node. For example,suppose at a given node we have last = 0. If this value becomes unacceptable and the onlyother acceptable value is N ! 1, this requires N ! 1 calls to set last = N ! 1. Furtherpropagation may later make N ! 1 unacceptable also. The resulting new call to Procedure3 cannot find an acceptable value, but must still check all values from 0 to N!2 as it has nomemory of the previous call. (The variable last-cache is local to each call of the Procedure.)This is a further N ! 1 calls to acceptable, for a total of 2N ! 2 at the node.

2.1 Worked Example

I present a worked example of Procedure 3, showing how we can amortize the count of callsto acceptable in a way which will form the basis of the optimality results of this paper.

Figure 1 shows an example search using the circular approach. In the example we assume

node id = 0 :last=14, cost = 14!

last=17

1 :14, 0

last=19

8 :14, 17!

last=16

2 :17, 3! 5 :17, 18!

last=18

9 :16, 21!! 12 :14, 18!

last=15

3 :17, 19! 4 :19, 2! 6 :18, 20!! 7 :17, 19! 10 :16, 0 11 :16, 0 13 :15, 1! 14 :14, 38!!

!

0,1,2,3

= 36!

0,1,2,4

= 19!

0,1,5,6

= 52!

0,1,5,7

= 51!

0,8,9,10

= 52!

0,8,9,11

= 52!

0,8,12,13

= 50!

0,8,12,14

= 87

Figure 1: A search using the circular approach. See main text for description.

that the list being searched has 20 elements, indexed from 0 to 19. and that initialisationsets last = 0. The box at a node indicates the node number (italics), the value of lastafter any calls to FNE-Circular (bold), and the cost of those calls in total at the node(measured as number of calls to acceptable), including a failed call if there is one. A !

indicates a successful call was made, while a " indicates an unsuccessful call. Both can occurat the same node, if the value of last is moved by a successful call, while that value laterbecomes unacceptable, and another call to FNE-Circular fails. A branch is annotatedwith a value of last if the search to the left changed the value of last . For example, at node5 the value of last was 17, but the left child set it to 18, meaning that it had changed whenwe branched right. The total cost for each branch is listed, e.g. 87 for the last branch.

In the example, the first 14 elements become unacceptable at the root, so calls to FNEmust check 14 elements in order to set last = 14. If we restored last the maximum cost

5

Right Hand Branch

We loop round to set last=14 (again!) total cost = 18

Monday, 16 September 13

Optimal Implementation of Watched Literals

.One di!erence between Procedures 2 and 3 should be noted. At a given node of the

search tree, Procedure 2 can make at most N calls to acceptable. However, Procedure3 can, perhaps counterintuitively, require almost 2N calls at a single node. For example,suppose at a given node we have last = 0. If this value becomes unacceptable and the onlyother acceptable value is N ! 1, this requires N ! 1 calls to set last = N ! 1. Furtherpropagation may later make N ! 1 unacceptable also. The resulting new call to Procedure3 cannot find an acceptable value, but must still check all values from 0 to N!2 as it has nomemory of the previous call. (The variable last-cache is local to each call of the Procedure.)This is a further N ! 1 calls to acceptable, for a total of 2N ! 2 at the node.

2.1 Worked Example

I present a worked example of Procedure 3, showing how we can amortize the count of callsto acceptable in a way which will form the basis of the optimality results of this paper.

Figure 1 shows an example search using the circular approach. In the example we assume

node id = 0 :last=14, cost = 14!

last=17

1 :14, 0

last=19

8 :14, 17!

last=16

2 :17, 3! 5 :17, 18!

last=18

9 :16, 21!! 12 :14, 18!

last=15

3 :17, 19! 4 :19, 2! 6 :18, 20!! 7 :17, 19! 10 :16, 0 11 :16, 0 13 :15, 1! 14 :14, 38!!

!

0,1,2,3

= 36!

0,1,2,4

= 19!

0,1,5,6

= 52!

0,1,5,7

= 51!

0,8,9,10

= 52!

0,8,9,11

= 52!

0,8,12,13

= 50!

0,8,12,14

= 87

Figure 1: A search using the circular approach. See main text for description.

that the list being searched has 20 elements, indexed from 0 to 19. and that initialisationsets last = 0. The box at a node indicates the node number (italics), the value of lastafter any calls to FNE-Circular (bold), and the cost of those calls in total at the node(measured as number of calls to acceptable), including a failed call if there is one. A !

indicates a successful call was made, while a " indicates an unsuccessful call. Both can occurat the same node, if the value of last is moved by a successful call, while that value laterbecomes unacceptable, and another call to FNE-Circular fails. A branch is annotatedwith a value of last if the search to the left changed the value of last . For example, at node5 the value of last was 17, but the left child set it to 18, meaning that it had changed whenwe branched right. The total cost for each branch is listed, e.g. 87 for the last branch.

In the example, the first 14 elements become unacceptable at the root, so calls to FNEmust check 14 elements in order to set last = 14. If we restored last the maximum cost

5

Stuff happens on left hand subtree and value of last changes

Right Hand Branch

Monday, 16 September 13

Optimal Implementation of Watched Literals

.One di!erence between Procedures 2 and 3 should be noted. At a given node of the

search tree, Procedure 2 can make at most N calls to acceptable. However, Procedure3 can, perhaps counterintuitively, require almost 2N calls at a single node. For example,suppose at a given node we have last = 0. If this value becomes unacceptable and the onlyother acceptable value is N ! 1, this requires N ! 1 calls to set last = N ! 1. Furtherpropagation may later make N ! 1 unacceptable also. The resulting new call to Procedure3 cannot find an acceptable value, but must still check all values from 0 to N!2 as it has nomemory of the previous call. (The variable last-cache is local to each call of the Procedure.)This is a further N ! 1 calls to acceptable, for a total of 2N ! 2 at the node.

2.1 Worked Example

I present a worked example of Procedure 3, showing how we can amortize the count of callsto acceptable in a way which will form the basis of the optimality results of this paper.

Figure 1 shows an example search using the circular approach. In the example we assume

node id = 0 :last=14, cost = 14!

last=17

1 :14, 0

last=19

8 :14, 17!

last=16

2 :17, 3! 5 :17, 18!

last=18

9 :16, 21!! 12 :14, 18!

last=15

3 :17, 19! 4 :19, 2! 6 :18, 20!! 7 :17, 19! 10 :16, 0 11 :16, 0 13 :15, 1! 14 :14, 38!!

!

0,1,2,3

= 36!

0,1,2,4

= 19!

0,1,5,6

= 52!

0,1,5,7

= 51!

0,8,9,10

= 52!

0,8,9,11

= 52!

0,8,12,13

= 50!

0,8,12,14

= 87

Figure 1: A search using the circular approach. See main text for description.

that the list being searched has 20 elements, indexed from 0 to 19. and that initialisationsets last = 0. The box at a node indicates the node number (italics), the value of lastafter any calls to FNE-Circular (bold), and the cost of those calls in total at the node(measured as number of calls to acceptable), including a failed call if there is one. A !

indicates a successful call was made, while a " indicates an unsuccessful call. Both can occurat the same node, if the value of last is moved by a successful call, while that value laterbecomes unacceptable, and another call to FNE-Circular fails. A branch is annotatedwith a value of last if the search to the left changed the value of last . For example, at node5 the value of last was 17, but the left child set it to 18, meaning that it had changed whenwe branched right. The total cost for each branch is listed, e.g. 87 for the last branch.

In the example, the first 14 elements become unacceptable at the root, so calls to FNEmust check 14 elements in order to set last = 14. If we restored last the maximum cost

5

Stuff happens on left hand subtree and value of last changes

Right Hand Branch

Monday, 16 September 13

Optimal Implementation of Watched Literals

.One di!erence between Procedures 2 and 3 should be noted. At a given node of the

search tree, Procedure 2 can make at most N calls to acceptable. However, Procedure3 can, perhaps counterintuitively, require almost 2N calls at a single node. For example,suppose at a given node we have last = 0. If this value becomes unacceptable and the onlyother acceptable value is N ! 1, this requires N ! 1 calls to set last = N ! 1. Furtherpropagation may later make N ! 1 unacceptable also. The resulting new call to Procedure3 cannot find an acceptable value, but must still check all values from 0 to N!2 as it has nomemory of the previous call. (The variable last-cache is local to each call of the Procedure.)This is a further N ! 1 calls to acceptable, for a total of 2N ! 2 at the node.

2.1 Worked Example

I present a worked example of Procedure 3, showing how we can amortize the count of callsto acceptable in a way which will form the basis of the optimality results of this paper.

Figure 1 shows an example search using the circular approach. In the example we assume

node id = 0 :last=14, cost = 14!

last=17

1 :14, 0

last=19

8 :14, 17!

last=16

2 :17, 3! 5 :17, 18!

last=18

9 :16, 21!! 12 :14, 18!

last=15

3 :17, 19! 4 :19, 2! 6 :18, 20!! 7 :17, 19! 10 :16, 0 11 :16, 0 13 :15, 1! 14 :14, 38!!

!

0,1,2,3

= 36!

0,1,2,4

= 19!

0,1,5,6

= 52!

0,1,5,7

= 51!

0,8,9,10

= 52!

0,8,9,11

= 52!

0,8,12,13

= 50!

0,8,12,14

= 87

Figure 1: A search using the circular approach. See main text for description.

that the list being searched has 20 elements, indexed from 0 to 19. and that initialisationsets last = 0. The box at a node indicates the node number (italics), the value of lastafter any calls to FNE-Circular (bold), and the cost of those calls in total at the node(measured as number of calls to acceptable), including a failed call if there is one. A !

indicates a successful call was made, while a " indicates an unsuccessful call. Both can occurat the same node, if the value of last is moved by a successful call, while that value laterbecomes unacceptable, and another call to FNE-Circular fails. A branch is annotatedwith a value of last if the search to the left changed the value of last . For example, at node5 the value of last was 17, but the left child set it to 18, meaning that it had changed whenwe branched right. The total cost for each branch is listed, e.g. 87 for the last branch.

In the example, the first 14 elements become unacceptable at the root, so calls to FNEmust check 14 elements in order to set last = 14. If we restored last the maximum cost

5

Right Hand Branch

We loop round to set last=14 (again!) cost = 18

Monday, 16 September 13

Optimal Implementation of Watched Literals

.One di!erence between Procedures 2 and 3 should be noted. At a given node of the

search tree, Procedure 2 can make at most N calls to acceptable. However, Procedure3 can, perhaps counterintuitively, require almost 2N calls at a single node. For example,suppose at a given node we have last = 0. If this value becomes unacceptable and the onlyother acceptable value is N ! 1, this requires N ! 1 calls to set last = N ! 1. Furtherpropagation may later make N ! 1 unacceptable also. The resulting new call to Procedure3 cannot find an acceptable value, but must still check all values from 0 to N!2 as it has nomemory of the previous call. (The variable last-cache is local to each call of the Procedure.)This is a further N ! 1 calls to acceptable, for a total of 2N ! 2 at the node.

2.1 Worked Example

I present a worked example of Procedure 3, showing how we can amortize the count of callsto acceptable in a way which will form the basis of the optimality results of this paper.

Figure 1 shows an example search using the circular approach. In the example we assume

node id = 0 :last=14, cost = 14!

last=17

1 :14, 0

last=19

8 :14, 17!

last=16

2 :17, 3! 5 :17, 18!

last=18

9 :16, 21!! 12 :14, 18!

last=15

3 :17, 19! 4 :19, 2! 6 :18, 20!! 7 :17, 19! 10 :16, 0 11 :16, 0 13 :15, 1! 14 :14, 38!!

!

0,1,2,3

= 36!

0,1,2,4

= 19!

0,1,5,6

= 52!

0,1,5,7

= 51!

0,8,9,10

= 52!

0,8,9,11

= 52!

0,8,12,13

= 50!

0,8,12,14

= 87

Figure 1: A search using the circular approach. See main text for description.

that the list being searched has 20 elements, indexed from 0 to 19. and that initialisationsets last = 0. The box at a node indicates the node number (italics), the value of lastafter any calls to FNE-Circular (bold), and the cost of those calls in total at the node(measured as number of calls to acceptable), including a failed call if there is one. A !

indicates a successful call was made, while a " indicates an unsuccessful call. Both can occurat the same node, if the value of last is moved by a successful call, while that value laterbecomes unacceptable, and another call to FNE-Circular fails. A branch is annotatedwith a value of last if the search to the left changed the value of last . For example, at node5 the value of last was 17, but the left child set it to 18, meaning that it had changed whenwe branched right. The total cost for each branch is listed, e.g. 87 for the last branch.

In the example, the first 14 elements become unacceptable at the root, so calls to FNEmust check 14 elements in order to set last = 14. If we restored last the maximum cost

5

Right Hand Branch

At the same node we search again and fail, total cost at node = 38

Monday, 16 September 13

Optimal Implementation of Watched Literals

.One di!erence between Procedures 2 and 3 should be noted. At a given node of the

search tree, Procedure 2 can make at most N calls to acceptable. However, Procedure3 can, perhaps counterintuitively, require almost 2N calls at a single node. For example,suppose at a given node we have last = 0. If this value becomes unacceptable and the onlyother acceptable value is N ! 1, this requires N ! 1 calls to set last = N ! 1. Furtherpropagation may later make N ! 1 unacceptable also. The resulting new call to Procedure3 cannot find an acceptable value, but must still check all values from 0 to N!2 as it has nomemory of the previous call. (The variable last-cache is local to each call of the Procedure.)This is a further N ! 1 calls to acceptable, for a total of 2N ! 2 at the node.

2.1 Worked Example

I present a worked example of Procedure 3, showing how we can amortize the count of callsto acceptable in a way which will form the basis of the optimality results of this paper.

Figure 1 shows an example search using the circular approach. In the example we assume

node id = 0 :last=14, cost = 14!

last=17

1 :14, 0

last=19

8 :14, 17!

last=16

2 :17, 3! 5 :17, 18!

last=18

9 :16, 21!! 12 :14, 18!

last=15

3 :17, 19! 4 :19, 2! 6 :18, 20!! 7 :17, 19! 10 :16, 0 11 :16, 0 13 :15, 1! 14 :14, 38!!

!

0,1,2,3

= 36!

0,1,2,4

= 19!

0,1,5,6

= 52!

0,1,5,7

= 51!

0,8,9,10

= 52!

0,8,9,11

= 52!

0,8,12,13

= 50!

0,8,12,14

= 87

Figure 1: A search using the circular approach. See main text for description.

that the list being searched has 20 elements, indexed from 0 to 19. and that initialisationsets last = 0. The box at a node indicates the node number (italics), the value of lastafter any calls to FNE-Circular (bold), and the cost of those calls in total at the node(measured as number of calls to acceptable), including a failed call if there is one. A !

indicates a successful call was made, while a " indicates an unsuccessful call. Both can occurat the same node, if the value of last is moved by a successful call, while that value laterbecomes unacceptable, and another call to FNE-Circular fails. A branch is annotatedwith a value of last if the search to the left changed the value of last . For example, at node5 the value of last was 17, but the left child set it to 18, meaning that it had changed whenwe branched right. The total cost for each branch is listed, e.g. 87 for the last branch.

In the example, the first 14 elements become unacceptable at the root, so calls to FNEmust check 14 elements in order to set last = 14. If we restored last the maximum cost

5

Right Hand Branch

Total cost down branch = 17+16+15+38 = 87

Monday, 16 September 13

Left Branch Segment (LBS)Optimal Implementation of Watched Literals

node id = 0 : last=14, cost = 14!

last=17

1 :14, 0

last=19

8 :14, 17!

last=16

2 :17, 3! 5 :17, 18!

last=18

9 :16, 21!! 12 :14, 18!

last=15

3 :17, 19! 4 :19, 2! 6 :18, 20!! 7 :17, 19! 10 :16, 0 11 :16, 0 13 :15, 1! 14 :14, 38!!

!

0,1,2,3

= 36!

4

= 2!

5,6

= 38!

7

= 19!

8,9,10

= 38!

11

= 0!

12,13

= 19!

14

= 38

Figure 2: The example from Figure 1 with additional annotations. A double line indicatesa left hand branch, while a wavy line the right hand branch. A sequence of doublelines indicates a left branch segment. A solid box around a node indicates thestart of a left branch segment. Finally, the sums of costs are made only over theleft branch segment ending at each leaf node.

for each iteration, i.e. counting a branch twice even if it is a duplicate of a branch froma previous iteration. Some major algorithms do not explore downwards: e.g. breadth-firstor best-first search. In such algorithms, at consecutive nodes last , which is not containedin the search state, moves from pointing to an acceptable to an unacceptable value. Theresults of this paper therefore do not apply in any way to such algorithms.

The first result is correctness of the FNE-circular method, slightly generalised sothat it will also apply to the “middle-out” Procedure 5 in Appendix B.

Definition 6 (Locally Correct). A findNewElement procedure is locally correct i!:

1. if any element of list is acceptable then the procedure sets last to point at an acceptablevalue and succeeds;

2. if no element of list is acceptable then the procedure fails and exits with last set tothe same value it had on entry.

Specifically, FNE-Circular is locally correct by design, and therefore its global cor-rectness is a corollary of the following theorem.

Theorem 7. (Correctness) If the search algorithm defines a downwards-explored searchtree, and if procedure findNewElement is locally correct, Invariant 2 is true at all times.(Proof in Appendix E online.)

Definition 8 (LBS). The left branch segment ending at a leaf node n LBS(n) is definedrecursively as follows:

7

Left Branch Segment is sequence of nodes from solid box down double lines

Monday, 16 September 13

Left Branch Segment (LBS)Optimal Implementation of Watched Literals

node id = 0 : last=14, cost = 14!

last=17

1 :14, 0

last=19

8 :14, 17!

last=16

2 :17, 3! 5 :17, 18!

last=18

9 :16, 21!! 12 :14, 18!

last=15

3 :17, 19! 4 :19, 2! 6 :18, 20!! 7 :17, 19! 10 :16, 0 11 :16, 0 13 :15, 1! 14 :14, 38!!

!

0,1,2,3

= 36!

4

= 2!

5,6

= 38!

7

= 19!

8,9,10

= 38!

11

= 0!

12,13

= 19!

14

= 38

Figure 2: The example from Figure 1 with additional annotations. A double line indicatesa left hand branch, while a wavy line the right hand branch. A sequence of doublelines indicates a left branch segment. A solid box around a node indicates thestart of a left branch segment. Finally, the sums of costs are made only over theleft branch segment ending at each leaf node.

for each iteration, i.e. counting a branch twice even if it is a duplicate of a branch froma previous iteration. Some major algorithms do not explore downwards: e.g. breadth-firstor best-first search. In such algorithms, at consecutive nodes last , which is not containedin the search state, moves from pointing to an acceptable to an unacceptable value. Theresults of this paper therefore do not apply in any way to such algorithms.

The first result is correctness of the FNE-circular method, slightly generalised sothat it will also apply to the “middle-out” Procedure 5 in Appendix B.

Definition 6 (Locally Correct). A findNewElement procedure is locally correct i!:

1. if any element of list is acceptable then the procedure sets last to point at an acceptablevalue and succeeds;

2. if no element of list is acceptable then the procedure fails and exits with last set tothe same value it had on entry.

Specifically, FNE-Circular is locally correct by design, and therefore its global cor-rectness is a corollary of the following theorem.

Theorem 7. (Correctness) If the search algorithm defines a downwards-explored searchtree, and if procedure findNewElement is locally correct, Invariant 2 is true at all times.(Proof in Appendix E online.)

Definition 8 (LBS). The left branch segment ending at a leaf node n LBS(n) is definedrecursively as follows:

7

Left Branch Segment is sequence of nodes where we always branch left

Monday, 16 September 13

Left Branch Segment (LBS)Optimal Implementation of Watched Literals

node id = 0 : last=14, cost = 14!

last=17

1 :14, 0

last=19

8 :14, 17!

last=16

2 :17, 3! 5 :17, 18!

last=18

9 :16, 21!! 12 :14, 18!

last=15

3 :17, 19! 4 :19, 2! 6 :18, 20!! 7 :17, 19! 10 :16, 0 11 :16, 0 13 :15, 1! 14 :14, 38!!

!

0,1,2,3

= 36!

4

= 2!

5,6

= 38!

7

= 19!

8,9,10

= 38!

11

= 0!

12,13

= 19!

14

= 38

Figure 2: The example from Figure 1 with additional annotations. A double line indicatesa left hand branch, while a wavy line the right hand branch. A sequence of doublelines indicates a left branch segment. A solid box around a node indicates thestart of a left branch segment. Finally, the sums of costs are made only over theleft branch segment ending at each leaf node.

for each iteration, i.e. counting a branch twice even if it is a duplicate of a branch froma previous iteration. Some major algorithms do not explore downwards: e.g. breadth-firstor best-first search. In such algorithms, at consecutive nodes last , which is not containedin the search state, moves from pointing to an acceptable to an unacceptable value. Theresults of this paper therefore do not apply in any way to such algorithms.

The first result is correctness of the FNE-circular method, slightly generalised sothat it will also apply to the “middle-out” Procedure 5 in Appendix B.

Definition 6 (Locally Correct). A findNewElement procedure is locally correct i!:

1. if any element of list is acceptable then the procedure sets last to point at an acceptablevalue and succeeds;

2. if no element of list is acceptable then the procedure fails and exits with last set tothe same value it had on entry.

Specifically, FNE-Circular is locally correct by design, and therefore its global cor-rectness is a corollary of the following theorem.

Theorem 7. (Correctness) If the search algorithm defines a downwards-explored searchtree, and if procedure findNewElement is locally correct, Invariant 2 is true at all times.(Proof in Appendix E online.)

Definition 8 (LBS). The left branch segment ending at a leaf node n LBS(n) is definedrecursively as follows:

7

In LBS sequence of nodes is consecutive in number without backtracking

Monday, 16 September 13

Left Branch Segment (LBS)Optimal Implementation of Watched Literals

node id = 0 : last=14, cost = 14!

last=17

1 :14, 0

last=19

8 :14, 17!

last=16

2 :17, 3! 5 :17, 18!

last=18

9 :16, 21!! 12 :14, 18!

last=15

3 :17, 19! 4 :19, 2! 6 :18, 20!! 7 :17, 19! 10 :16, 0 11 :16, 0 13 :15, 1! 14 :14, 38!!

!

0,1,2,3

= 36!

4

= 2!

5,6

= 38!

7

= 19!

8,9,10

= 38!

11

= 0!

12,13

= 19!

14

= 38

Figure 2: The example from Figure 1 with additional annotations. A double line indicatesa left hand branch, while a wavy line the right hand branch. A sequence of doublelines indicates a left branch segment. A solid box around a node indicates thestart of a left branch segment. Finally, the sums of costs are made only over theleft branch segment ending at each leaf node.

for each iteration, i.e. counting a branch twice even if it is a duplicate of a branch froma previous iteration. Some major algorithms do not explore downwards: e.g. breadth-firstor best-first search. In such algorithms, at consecutive nodes last , which is not containedin the search state, moves from pointing to an acceptable to an unacceptable value. Theresults of this paper therefore do not apply in any way to such algorithms.

The first result is correctness of the FNE-circular method, slightly generalised sothat it will also apply to the “middle-out” Procedure 5 in Appendix B.

Definition 6 (Locally Correct). A findNewElement procedure is locally correct i!:

1. if any element of list is acceptable then the procedure sets last to point at an acceptablevalue and succeeds;

2. if no element of list is acceptable then the procedure fails and exits with last set tothe same value it had on entry.

Specifically, FNE-Circular is locally correct by design, and therefore its global cor-rectness is a corollary of the following theorem.

Theorem 7. (Correctness) If the search algorithm defines a downwards-explored searchtree, and if procedure findNewElement is locally correct, Invariant 2 is true at all times.(Proof in Appendix E online.)

Definition 8 (LBS). The left branch segment ending at a leaf node n LBS(n) is definedrecursively as follows:

7

Each node is in exactly one LBSMonday, 16 September 13

Left Branch Segment (LBS)Optimal Implementation of Watched Literals

node id = 0 : last=14, cost = 14!

last=17

1 :14, 0

last=19

8 :14, 17!

last=16

2 :17, 3! 5 :17, 18!

last=18

9 :16, 21!! 12 :14, 18!

last=15

3 :17, 19! 4 :19, 2! 6 :18, 20!! 7 :17, 19! 10 :16, 0 11 :16, 0 13 :15, 1! 14 :14, 38!!

!

0,1,2,3

= 36!

4

= 2!

5,6

= 38!

7

= 19!

8,9,10

= 38!

11

= 0!

12,13

= 19!

14

= 38

Figure 2: The example from Figure 1 with additional annotations. A double line indicatesa left hand branch, while a wavy line the right hand branch. A sequence of doublelines indicates a left branch segment. A solid box around a node indicates thestart of a left branch segment. Finally, the sums of costs are made only over theleft branch segment ending at each leaf node.

for each iteration, i.e. counting a branch twice even if it is a duplicate of a branch froma previous iteration. Some major algorithms do not explore downwards: e.g. breadth-firstor best-first search. In such algorithms, at consecutive nodes last , which is not containedin the search state, moves from pointing to an acceptable to an unacceptable value. Theresults of this paper therefore do not apply in any way to such algorithms.

The first result is correctness of the FNE-circular method, slightly generalised sothat it will also apply to the “middle-out” Procedure 5 in Appendix B.

Definition 6 (Locally Correct). A findNewElement procedure is locally correct i!:

1. if any element of list is acceptable then the procedure sets last to point at an acceptablevalue and succeeds;

2. if no element of list is acceptable then the procedure fails and exits with last set tothe same value it had on entry.

Specifically, FNE-Circular is locally correct by design, and therefore its global cor-rectness is a corollary of the following theorem.

Theorem 7. (Correctness) If the search algorithm defines a downwards-explored searchtree, and if procedure findNewElement is locally correct, Invariant 2 is true at all times.(Proof in Appendix E online.)

Definition 8 (LBS). The left branch segment ending at a leaf node n LBS(n) is definedrecursively as follows:

7

There are the same number of LBSs as branches/leaf nodes

Monday, 16 September 13

Left Branch Segment (LBS)Optimal Implementation of Watched Literals

node id = 0 : last=14, cost = 14!

last=17

1 :14, 0

last=19

8 :14, 17!

last=16

2 :17, 3! 5 :17, 18!

last=18

9 :16, 21!! 12 :14, 18!

last=15

3 :17, 19! 4 :19, 2! 6 :18, 20!! 7 :17, 19! 10 :16, 0 11 :16, 0 13 :15, 1! 14 :14, 38!!

!

0,1,2,3

= 36!

4

= 2!

5,6

= 38!

7

= 19!

8,9,10

= 38!

11

= 0!

12,13

= 19!

14

= 38

Figure 2: The example from Figure 1 with additional annotations. A double line indicatesa left hand branch, while a wavy line the right hand branch. A sequence of doublelines indicates a left branch segment. A solid box around a node indicates thestart of a left branch segment. Finally, the sums of costs are made only over theleft branch segment ending at each leaf node.

for each iteration, i.e. counting a branch twice even if it is a duplicate of a branch froma previous iteration. Some major algorithms do not explore downwards: e.g. breadth-firstor best-first search. In such algorithms, at consecutive nodes last , which is not containedin the search state, moves from pointing to an acceptable to an unacceptable value. Theresults of this paper therefore do not apply in any way to such algorithms.

The first result is correctness of the FNE-circular method, slightly generalised sothat it will also apply to the “middle-out” Procedure 5 in Appendix B.

Definition 6 (Locally Correct). A findNewElement procedure is locally correct i!:

1. if any element of list is acceptable then the procedure sets last to point at an acceptablevalue and succeeds;

2. if no element of list is acceptable then the procedure fails and exits with last set tothe same value it had on entry.

Specifically, FNE-Circular is locally correct by design, and therefore its global cor-rectness is a corollary of the following theorem.

Theorem 7. (Correctness) If the search algorithm defines a downwards-explored searchtree, and if procedure findNewElement is locally correct, Invariant 2 is true at all times.(Proof in Appendix E online.)

Definition 8 (LBS). The left branch segment ending at a leaf node n LBS(n) is definedrecursively as follows:

7

Never make as many as 2N = 40 calls to Acceptable in LBS

Monday, 16 September 13

Left Branch Segment (LBS)Optimal Implementation of Watched Literals

node id = 0 : last=14, cost = 14!

last=17

1 :14, 0

last=19

8 :14, 17!

last=16

2 :17, 3! 5 :17, 18!

last=18

9 :16, 21!! 12 :14, 18!

last=15

3 :17, 19! 4 :19, 2! 6 :18, 20!! 7 :17, 19! 10 :16, 0 11 :16, 0 13 :15, 1! 14 :14, 38!!

!

0,1,2,3

= 36!

4

= 2!

5,6

= 38!

7

= 19!

8,9,10

= 38!

11

= 0!

12,13

= 19!

14

= 38

Figure 2: The example from Figure 1 with additional annotations. A double line indicatesa left hand branch, while a wavy line the right hand branch. A sequence of doublelines indicates a left branch segment. A solid box around a node indicates thestart of a left branch segment. Finally, the sums of costs are made only over theleft branch segment ending at each leaf node.

for each iteration, i.e. counting a branch twice even if it is a duplicate of a branch froma previous iteration. Some major algorithms do not explore downwards: e.g. breadth-firstor best-first search. In such algorithms, at consecutive nodes last , which is not containedin the search state, moves from pointing to an acceptable to an unacceptable value. Theresults of this paper therefore do not apply in any way to such algorithms.

The first result is correctness of the FNE-circular method, slightly generalised sothat it will also apply to the “middle-out” Procedure 5 in Appendix B.

Definition 6 (Locally Correct). A findNewElement procedure is locally correct i!:

1. if any element of list is acceptable then the procedure sets last to point at an acceptablevalue and succeeds;

2. if no element of list is acceptable then the procedure fails and exits with last set tothe same value it had on entry.

Specifically, FNE-Circular is locally correct by design, and therefore its global cor-rectness is a corollary of the following theorem.

Theorem 7. (Correctness) If the search algorithm defines a downwards-explored searchtree, and if procedure findNewElement is locally correct, Invariant 2 is true at all times.(Proof in Appendix E online.)

Definition 8 (LBS). The left branch segment ending at a leaf node n LBS(n) is definedrecursively as follows:

7

All these statements are general. Last is crux of optimality result.

Monday, 16 September 13

Key Lemma• Say length of LIST=N

• In any Left Branch Segment

• there are at most N-1 successful calls to Acceptable()

• Proof is easy:

• if there are N it has checked every element

• after a successful call there is only another call if that element becomes unacceptable

• if there are N every element has become unacceptable

Monday, 16 September 13

Key Corollary

• In any Left Branch Segment

• there are at most 2N-1 calls to Acceptable()

• Proof is easy:

• N-1 successful calls

• then N including cycle for the last failed attempt

Monday, 16 September 13

Optimality Theorem

• In a search tree, FNE-Circular can make no more than 2N calls to Acceptable() per branch of the tree

• Note this applies to every search tree

• no average case or asymptotics

• This is optimal because we must check O(N) per branch in any method

• Worst case is only 2x worst case of state restoration

• and only worse when failure on branch

Monday, 16 September 13

Application: Constraints

• Typically in GAC algorithm

• (Generalised arc consistency)

• Need support for each variable/value

• Each variable/value has list of support tuples

• acceptable means:

• every assignment in tuple is still valid

• Losing support = element unacceptable

Monday, 16 September 13

From GAC to MGAC• MGAC = Maintaining GAC in search

• Two approaches can both be improved

• Restore State

• e.g. Bessiere et al implementation of MGAC

• Optimal per branch but uses additional space to store pointer

• Circular

• e.g. Gent et al, various papers

• Used because of simplicity and effectiveness in practice

• With warning in paper that approach is not optimal

• but it was optimal!

Monday, 16 September 13

Application: SAT• Watched literals in SAT

• Need two acceptable elements

• Generalisation is not hard

• though did not find till the last minute

• Fun Fact:

• if you want w watched elements

• number of calls to Acceptable() does not increase with w

Monday, 16 September 13

Application: SAT• I thought that Circular was standard

implementation

• But Reviewer pointed out that was wrong

• Actually most people do FNE-NoState

• e.g. MiniSat, tiniSat

• meaning can be O(N2) calls per branch

• Complete surprise to me

• So is Circular (optimal) better?

Monday, 16 September 13

Is circular better than no-state in MiniSat?

Gent

0.5 0.6

0.8 1

2

3

4 5 6

8 10

0.5 0.6 0.8 1 1.2 2 3 4 5 6 8 10 20

Circular:Stock0.548x + 0.523

Figure 3: Scatterplot of ! (x-axis) against speedup ratio in conflicts per second of Circularover Stock MiniSat (y-axis). The vertical line shows ! = 1.2. The line 0.548x +0.523 is the best-fit line in the region ! ! 1.2.

will tend to set watches to literals appearing early in a clause. Therefore if a good blockingliteral is late in a clause, Circular has more chance of watching it.

Head-tail lists were an important advance in implementation of unit propagation inSAT (Zhang & Stickel, 2000). Pointers to the first unassigned literal in a clause (head) andthe last (tail) are maintained by state-restoration. Head-tail lists led to “watched literals”(Moskewicz et al., 2001), in which there are two pointers to arbitrary (but di!erent) unas-signed literals. Watched literals (or variants thereof) have become the standard techniquefor e"cient implementation of unit propagation in SAT solvers. When implemented as de-scribed in this paper, the theoretical properties of watched literals are now seen to be verynearly as good as head-tail lists in time, with much reduced space overheads.

A variant implementation of watched literals is in JQuest (Lynce & Marques-Silva,2005). Scans go from last to the end of the list, but restart from last backwards to 0. This“middle-out” search can be big-O optimal provided that the current direction of search ispersistent between calls. However, if the direction of search is always initially in one direc-tion, it can require #(N2) checks per branch, and this is the case in JQuest. Full algorithmicdetails and proofs of these statements are in Appendix B. Lynce and Marques-Silva (2005)also introduced literal sifting to attempt to get the best of both worlds: literals in a clauseare reordered during search to avoid repeating checks and backtracking pointers. Lynce andMarques-Silva report slightly better empirical performance with literal sifting (although asjust noted the comparison was with a non-optimal watched literal implementation). Gen-eralising literal sifting to arbitrary number of acceptable elements and performing furthertheoretical and experimental comparisons with the circular approach is open as future work.

Another application which is now seen to be optimal, if implemented in a circular style,is Van Gelder’s (2002) three literal watching to detect binary clauses.

14

Yes!

Monday, 16 September 13

Is circular better than no-state in MiniSat?

Gent

0.5 0.6

0.8 1

2

3

4 5 6

8 10

0.5 0.6 0.8 1 1.2 2 3 4 5 6 8 10 20

Circular:Stock0.548x + 0.523

Figure 3: Scatterplot of ! (x-axis) against speedup ratio in conflicts per second of Circularover Stock MiniSat (y-axis). The vertical line shows ! = 1.2. The line 0.548x +0.523 is the best-fit line in the region ! ! 1.2.

will tend to set watches to literals appearing early in a clause. Therefore if a good blockingliteral is late in a clause, Circular has more chance of watching it.

Head-tail lists were an important advance in implementation of unit propagation inSAT (Zhang & Stickel, 2000). Pointers to the first unassigned literal in a clause (head) andthe last (tail) are maintained by state-restoration. Head-tail lists led to “watched literals”(Moskewicz et al., 2001), in which there are two pointers to arbitrary (but di!erent) unas-signed literals. Watched literals (or variants thereof) have become the standard techniquefor e"cient implementation of unit propagation in SAT solvers. When implemented as de-scribed in this paper, the theoretical properties of watched literals are now seen to be verynearly as good as head-tail lists in time, with much reduced space overheads.

A variant implementation of watched literals is in JQuest (Lynce & Marques-Silva,2005). Scans go from last to the end of the list, but restart from last backwards to 0. This“middle-out” search can be big-O optimal provided that the current direction of search ispersistent between calls. However, if the direction of search is always initially in one direc-tion, it can require #(N2) checks per branch, and this is the case in JQuest. Full algorithmicdetails and proofs of these statements are in Appendix B. Lynce and Marques-Silva (2005)also introduced literal sifting to attempt to get the best of both worlds: literals in a clauseare reordered during search to avoid repeating checks and backtracking pointers. Lynce andMarques-Silva report slightly better empirical performance with literal sifting (although asjust noted the comparison was with a non-optimal watched literal implementation). Gen-eralising literal sifting to arbitrary number of acceptable elements and performing furthertheoretical and experimental comparisons with the circular approach is open as future work.

Another application which is now seen to be optimal, if implemented in a circular style,is Van Gelder’s (2002) three literal watching to detect binary clauses.

14

Average of 29% faster propagation

Monday, 16 September 13

Is circular better than no-state in MiniSat?

Gent

0.5 0.6

0.8 1

2

3

4 5 6

8 10

0.5 0.6 0.8 1 1.2 2 3 4 5 6 8 10 20

Circular:Stock0.548x + 0.523

Figure 3: Scatterplot of ! (x-axis) against speedup ratio in conflicts per second of Circularover Stock MiniSat (y-axis). The vertical line shows ! = 1.2. The line 0.548x +0.523 is the best-fit line in the region ! ! 1.2.

will tend to set watches to literals appearing early in a clause. Therefore if a good blockingliteral is late in a clause, Circular has more chance of watching it.

Head-tail lists were an important advance in implementation of unit propagation inSAT (Zhang & Stickel, 2000). Pointers to the first unassigned literal in a clause (head) andthe last (tail) are maintained by state-restoration. Head-tail lists led to “watched literals”(Moskewicz et al., 2001), in which there are two pointers to arbitrary (but di!erent) unas-signed literals. Watched literals (or variants thereof) have become the standard techniquefor e"cient implementation of unit propagation in SAT solvers. When implemented as de-scribed in this paper, the theoretical properties of watched literals are now seen to be verynearly as good as head-tail lists in time, with much reduced space overheads.

A variant implementation of watched literals is in JQuest (Lynce & Marques-Silva,2005). Scans go from last to the end of the list, but restart from last backwards to 0. This“middle-out” search can be big-O optimal provided that the current direction of search ispersistent between calls. However, if the direction of search is always initially in one direc-tion, it can require #(N2) checks per branch, and this is the case in JQuest. Full algorithmicdetails and proofs of these statements are in Appendix B. Lynce and Marques-Silva (2005)also introduced literal sifting to attempt to get the best of both worlds: literals in a clauseare reordered during search to avoid repeating checks and backtracking pointers. Lynce andMarques-Silva report slightly better empirical performance with literal sifting (although asjust noted the comparison was with a non-optimal watched literal implementation). Gen-eralising literal sifting to arbitrary number of acceptable elements and performing furthertheoretical and experimental comparisons with the circular approach is open as future work.

Another application which is now seen to be optimal, if implemented in a circular style,is Van Gelder’s (2002) three literal watching to detect binary clauses.

14

Circular can propagate almost 10x faster

Monday, 16 September 13

Is circular better than no-state in MiniSat?

Gent

0.5 0.6

0.8 1

2

3

4 5 6

8 10

0.5 0.6 0.8 1 1.2 2 3 4 5 6 8 10 20

Circular:Stock0.548x + 0.523

Figure 3: Scatterplot of ! (x-axis) against speedup ratio in conflicts per second of Circularover Stock MiniSat (y-axis). The vertical line shows ! = 1.2. The line 0.548x +0.523 is the best-fit line in the region ! ! 1.2.

will tend to set watches to literals appearing early in a clause. Therefore if a good blockingliteral is late in a clause, Circular has more chance of watching it.

Head-tail lists were an important advance in implementation of unit propagation inSAT (Zhang & Stickel, 2000). Pointers to the first unassigned literal in a clause (head) andthe last (tail) are maintained by state-restoration. Head-tail lists led to “watched literals”(Moskewicz et al., 2001), in which there are two pointers to arbitrary (but di!erent) unas-signed literals. Watched literals (or variants thereof) have become the standard techniquefor e"cient implementation of unit propagation in SAT solvers. When implemented as de-scribed in this paper, the theoretical properties of watched literals are now seen to be verynearly as good as head-tail lists in time, with much reduced space overheads.

A variant implementation of watched literals is in JQuest (Lynce & Marques-Silva,2005). Scans go from last to the end of the list, but restart from last backwards to 0. This“middle-out” search can be big-O optimal provided that the current direction of search ispersistent between calls. However, if the direction of search is always initially in one direc-tion, it can require #(N2) checks per branch, and this is the case in JQuest. Full algorithmicdetails and proofs of these statements are in Appendix B. Lynce and Marques-Silva (2005)also introduced literal sifting to attempt to get the best of both worlds: literals in a clauseare reordered during search to avoid repeating checks and backtracking pointers. Lynce andMarques-Silva report slightly better empirical performance with literal sifting (although asjust noted the comparison was with a non-optimal watched literal implementation). Gen-eralising literal sifting to arbitrary number of acceptable elements and performing furthertheoretical and experimental comparisons with the circular approach is open as future work.

Another application which is now seen to be optimal, if implemented in a circular style,is Van Gelder’s (2002) three literal watching to detect binary clauses.

14

Circular is better at finding literals that are not falsified

Monday, 16 September 13

Is circular better than no-state in MiniSat?

No!

Gent

0.01

0.1

1

10

100

0.01 0.1 1 10 100 1000

Circular ratioTwoPointer ratio

Figure 4: Scatterplot of relative performance of Circular and TwoPointer variants comparedwith Stock MiniSat. The x-axis gives run time of Stock MiniSat in seconds. They-axis gives ratio of Stock time to Circular/TwoPointer time. Ratios above 1mean that the alternative was faster, and below 1 that Stock MiniSat was faster.

Linux machine). For the 594 instances unsolved after 60s, the clause set was saved to givea realistic but static instance for the cut-down versions of MiniSat. Two versions of eachpropagator were created: one in which all instrumentation was switched o!, to maximisespeed; and one in which several additional counters were added to provide more metrics onthe nature of the search for watched literals. For reporting cpu times the first version wasused (with times being the median of three runs). Search was performed until a limit of107 conflicts was reached (excepting one instance solved in 7.75 ! 106 conflicts).

For tests of unrestricted MiniSat, three runs were performed for each algorithm-instancecombination. MiniSat default settings were used with a cpu timeout of 1200s and memory-out of 1GB. For 87 instances, taking more than 0.01s and max-to-min deviation for somealgorithm more than 10% of its median, another 18 runs were performed for each algorithm,and the median of all 21 runs used. Instances which no algorithm solved within the timeout,or all did in less than 0.01s, were discarded. 330 instances remained. Results are shownfor both Circular and TwoPointer in Figure 4. There is huge variation between runtimeson the same instance, up to almost 100 times. Each propagation method can find di!erentconflicting clauses, leading to di!erent sets of learnt clauses and heuristics. The instancesvertically above and diagonally below x = 1200 are those where one method timed-out andthe other did not. A paired t-test was performed between Circular and Stock MiniSat,with null hypothesis that the distributions have the same mean. This gave t = "0.127,p = 0.899, i.e. a highly insignificant result. Because the assumption of normality is invalid,the t-test was randomised 100,000 times (Cohen, 1995). Of these, 48.3% gave a lower t-value and 51.7% a higher value. Similar results were obtained with TwoPointer and StockMiniSat. The conclusion must be that there is no statistical evidence that either Circularor TwoPointer is either better or worse than Stock MiniSat in the fully featured solver.

18

Monday, 16 September 13

Is circular better than no-state in MiniSat?

No significant improvement in overall search

Gent

0.01

0.1

1

10

100

0.01 0.1 1 10 100 1000

Circular ratioTwoPointer ratio

Figure 4: Scatterplot of relative performance of Circular and TwoPointer variants comparedwith Stock MiniSat. The x-axis gives run time of Stock MiniSat in seconds. They-axis gives ratio of Stock time to Circular/TwoPointer time. Ratios above 1mean that the alternative was faster, and below 1 that Stock MiniSat was faster.

Linux machine). For the 594 instances unsolved after 60s, the clause set was saved to givea realistic but static instance for the cut-down versions of MiniSat. Two versions of eachpropagator were created: one in which all instrumentation was switched o!, to maximisespeed; and one in which several additional counters were added to provide more metrics onthe nature of the search for watched literals. For reporting cpu times the first version wasused (with times being the median of three runs). Search was performed until a limit of107 conflicts was reached (excepting one instance solved in 7.75 ! 106 conflicts).

For tests of unrestricted MiniSat, three runs were performed for each algorithm-instancecombination. MiniSat default settings were used with a cpu timeout of 1200s and memory-out of 1GB. For 87 instances, taking more than 0.01s and max-to-min deviation for somealgorithm more than 10% of its median, another 18 runs were performed for each algorithm,and the median of all 21 runs used. Instances which no algorithm solved within the timeout,or all did in less than 0.01s, were discarded. 330 instances remained. Results are shownfor both Circular and TwoPointer in Figure 4. There is huge variation between runtimeson the same instance, up to almost 100 times. Each propagation method can find di!erentconflicting clauses, leading to di!erent sets of learnt clauses and heuristics. The instancesvertically above and diagonally below x = 1200 are those where one method timed-out andthe other did not. A paired t-test was performed between Circular and Stock MiniSat,with null hypothesis that the distributions have the same mean. This gave t = "0.127,p = 0.899, i.e. a highly insignificant result. Because the assumption of normality is invalid,the t-test was randomised 100,000 times (Cohen, 1995). Of these, 48.3% gave a lower t-value and 51.7% a higher value. Similar results were obtained with TwoPointer and StockMiniSat. The conclusion must be that there is no statistical evidence that either Circularor TwoPointer is either better or worse than Stock MiniSat in the fully featured solver.

18

Monday, 16 September 13

Is circular better than no-state in MiniSat?

Different propagations = different explanations = different heuristics = different search

Gent

0.01

0.1

1

10

100

0.01 0.1 1 10 100 1000

Circular ratioTwoPointer ratio

Figure 4: Scatterplot of relative performance of Circular and TwoPointer variants comparedwith Stock MiniSat. The x-axis gives run time of Stock MiniSat in seconds. They-axis gives ratio of Stock time to Circular/TwoPointer time. Ratios above 1mean that the alternative was faster, and below 1 that Stock MiniSat was faster.

Linux machine). For the 594 instances unsolved after 60s, the clause set was saved to givea realistic but static instance for the cut-down versions of MiniSat. Two versions of eachpropagator were created: one in which all instrumentation was switched o!, to maximisespeed; and one in which several additional counters were added to provide more metrics onthe nature of the search for watched literals. For reporting cpu times the first version wasused (with times being the median of three runs). Search was performed until a limit of107 conflicts was reached (excepting one instance solved in 7.75 ! 106 conflicts).

For tests of unrestricted MiniSat, three runs were performed for each algorithm-instancecombination. MiniSat default settings were used with a cpu timeout of 1200s and memory-out of 1GB. For 87 instances, taking more than 0.01s and max-to-min deviation for somealgorithm more than 10% of its median, another 18 runs were performed for each algorithm,and the median of all 21 runs used. Instances which no algorithm solved within the timeout,or all did in less than 0.01s, were discarded. 330 instances remained. Results are shownfor both Circular and TwoPointer in Figure 4. There is huge variation between runtimeson the same instance, up to almost 100 times. Each propagation method can find di!erentconflicting clauses, leading to di!erent sets of learnt clauses and heuristics. The instancesvertically above and diagonally below x = 1200 are those where one method timed-out andthe other did not. A paired t-test was performed between Circular and Stock MiniSat,with null hypothesis that the distributions have the same mean. This gave t = "0.127,p = 0.899, i.e. a highly insignificant result. Because the assumption of normality is invalid,the t-test was randomised 100,000 times (Cohen, 1995). Of these, 48.3% gave a lower t-value and 51.7% a higher value. Similar results were obtained with TwoPointer and StockMiniSat. The conclusion must be that there is no statistical evidence that either Circularor TwoPointer is either better or worse than Stock MiniSat in the fully featured solver.

18

Monday, 16 September 13

Conclusions• The circular approach is optimal

• and this is surprising

• minimises space and very easy to implement

• Some existing implementations are optimal

• even though their authors said not

• Generalises to finding multiple elements

• e.g. watched literals in SAT

• Circular can improve propagation in MiniSat

• but there’s no evidence it improves overall solving speed

Monday, 16 September 13

And finally...

• JAIR paper gives me particular pleasure...

• I have published papers in JAIR 20 years apart

• Gent & Walsh, September 1993

• Gent, September, 2013

• JAIR was platinum open access from day one

• Original publication by anon ftp and gopher

• web page set up a few months later!

Monday, 16 September 13