Top Banner
Lintao Zhang ( 2 3 1 4 5) ( 1 2 -3) ( 1 –2) (-1 4) (-1) BCP Algorithm (2/8) Let’s illustrate this with an example:
15

BCP Algorithm (2/8) - People @ EECS at UC Berkeleysseshia/219c/lectures/... · 2006-02-01 · BCP Algorithm (4.2/8) zNow let’s actually process the second and third cla Lintao Zhang

Jan 18, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: BCP Algorithm (2/8) - People @ EECS at UC Berkeleysseshia/219c/lectures/... · 2006-02-01 · BCP Algorithm (4.2/8) zNow let’s actually process the second and third cla Lintao Zhang

Lin

tao

Zh

an

g

( 2 3 1 4 5)

( 1 2 -3)

( 1 –2)

(-1 4)

(-1)

BC

P A

lgo

rith

m (

2/8

)

Le

t’s illu

str

ate

th

is w

ith

an

exa

mp

le:

Page 2: BCP Algorithm (2/8) - People @ EECS at UC Berkeleysseshia/219c/lectures/... · 2006-02-01 · BCP Algorithm (4.2/8) zNow let’s actually process the second and third cla Lintao Zhang

Lin

tao

Zh

an

g

BC

P A

lgo

rith

m (

2.1

/8)

Le

t’s illu

str

ate

th

is w

ith

an

exa

mp

le:

( 2 3 1 4 5)

( 1 2 -3)

( 1 –2)

(-1 4)

(-1)

watc

hed

litera

ls

Conce

ptu

ally

, w

e ide

ntify

the f

irst

two litera

ls in e

ach c

lause

as

the w

atc

hed o

nes

Page 3: BCP Algorithm (2/8) - People @ EECS at UC Berkeleysseshia/219c/lectures/... · 2006-02-01 · BCP Algorithm (4.2/8) zNow let’s actually process the second and third cla Lintao Zhang

Lin

tao

Zh

an

g

BC

P A

lgo

rith

m (

2.2

/8)

Le

t’s illu

str

ate

th

is w

ith

an

exa

mp

le:

( 2 3 1 4 5)

( 1 2 -3)

( 1 –2)

(-1 4)

(-1)

watc

hed

litera

ls

Conce

ptu

ally

, w

e ide

ntify

the f

irst

two litera

ls in e

ach c

lause

as t

he w

atc

he

d

ones

Chan

gin

g w

hic

h litera

ls a

re w

atc

hed is r

epre

sente

d b

y r

eord

erin

gth

e litera

ls

in t

he c

lause (

wh

ich c

om

es into

pla

y late

r)

Page 4: BCP Algorithm (2/8) - People @ EECS at UC Berkeleysseshia/219c/lectures/... · 2006-02-01 · BCP Algorithm (4.2/8) zNow let’s actually process the second and third cla Lintao Zhang

Lin

tao

Zh

an

g

BC

P A

lgo

rith

m (

2.3

/8)

Le

t’s illu

str

ate

th

is w

ith

an

exa

mp

le:

( 2 3 1 4 5)

( 1 2 -3)

( 1 –2)

(-1 4)

(-1)

watc

hed

litera

ls

One litera

l cla

use b

reaks invari

ants

: hand

led

as a

specia

l ca

se (

ignore

d h

ere

after)

Conce

ptu

ally

, w

e ide

ntify

the f

irst

two litera

ls in e

ach c

lause

as t

he w

atc

he

d

ones

Chan

gin

g w

hic

h litera

ls a

re w

atc

hed is r

epre

sente

d b

y r

eord

erin

gth

e litera

ls

in t

he c

lause (

wh

ich c

om

es into

pla

y late

r)

Cla

uses o

f siz

e o

ne a

re a

spe

cia

l case

Page 5: BCP Algorithm (2/8) - People @ EECS at UC Berkeleysseshia/219c/lectures/... · 2006-02-01 · BCP Algorithm (4.2/8) zNow let’s actually process the second and third cla Lintao Zhang

Lin

tao

Zh

an

g

BC

P A

lgo

rith

m (

3/8

)

We b

egin

by p

rocessin

g the a

ssig

nm

ent v1 =

F (

whic

h is im

plie

d b

y

the

siz

e o

ne

cla

use) ( 2 3 1 4 5)

( 1 2 -3)

( 1 –2)

(-1 4)

State:(v1=F)

Pending:

Page 6: BCP Algorithm (2/8) - People @ EECS at UC Berkeleysseshia/219c/lectures/... · 2006-02-01 · BCP Algorithm (4.2/8) zNow let’s actually process the second and third cla Lintao Zhang

Lin

tao

Zh

an

g

BC

P A

lgo

rith

m (

3.1

/8)

We b

egin

by p

rocessin

g the a

ssig

nm

ent v1 =

F (

whic

h is im

plie

d b

y

the

siz

e o

ne

cla

use) ( 2 3 1 4 5)

( 1 2 -3)

( 1 –2)

(-1 4)

To m

ain

tain

ou

r in

varia

nts

, w

e m

ust

exam

ine e

ach c

lause w

here

the

assig

nm

ent

bein

g p

rocessed h

as s

et

a w

atc

hed litera

l to

F.

State:(v1=F)

Pending:

Page 7: BCP Algorithm (2/8) - People @ EECS at UC Berkeleysseshia/219c/lectures/... · 2006-02-01 · BCP Algorithm (4.2/8) zNow let’s actually process the second and third cla Lintao Zhang

Lin

tao

Zh

an

g

BC

P A

lgo

rith

m (

3.2

/8)

We b

egin

by p

rocessin

g the a

ssig

nm

ent v1 =

F (

whic

h is im

plie

d b

y

the

siz

e o

ne

cla

use) ( 2 3 1 4 5)

( 1 2 -3)

( 1 –2)

(-1 4)

To m

ain

tain

ou

r in

varia

nts

, w

e m

ust

exam

ine e

ach c

lause w

here

the

assig

nm

ent

bein

g p

rocessed h

as s

et

a w

atc

hed litera

l to

F.

We n

eed n

ot

pro

cess c

lauses w

here

a w

atc

hed litera

l has b

een s

et

to T

,

because t

he c

lause is n

ow

sa

tisfied a

nd s

o c

an n

ot

becom

e im

plie

d.

State:(v1=F)

Pending:

Page 8: BCP Algorithm (2/8) - People @ EECS at UC Berkeleysseshia/219c/lectures/... · 2006-02-01 · BCP Algorithm (4.2/8) zNow let’s actually process the second and third cla Lintao Zhang

Lin

tao

Zh

an

g

BC

P A

lgo

rith

m (

3.3

/8)

We b

egin

by p

rocessin

g the a

ssig

nm

ent v1 =

F (

whic

h is im

plie

d b

y

the

siz

e o

ne

cla

use) ( 2 3 1 4 5)

( 1 2 -3)

( 1 –2)

(-1 4)

To m

ain

tain

ou

r in

varia

nts

, w

e m

ust

exam

ine e

ach c

lause w

here

the

assig

nm

ent

bein

g p

rocessed h

as s

et

a w

atc

hed litera

l to

F.

We n

eed n

ot

pro

cess c

lauses w

here

a w

atc

hed litera

l has b

een s

et

to T

,

because t

he c

lause is n

ow

sa

tisfied a

nd s

o c

an n

ot

becom

e im

plie

d.

We certainly

need n

ot

pro

cess a

ny c

lauses w

here

neither

watc

hed litera

l

chang

es s

tate

(in

this

exam

ple

, w

here

v1 is n

ot

watc

hed).

State:(v1=F)

Pending:

Page 9: BCP Algorithm (2/8) - People @ EECS at UC Berkeleysseshia/219c/lectures/... · 2006-02-01 · BCP Algorithm (4.2/8) zNow let’s actually process the second and third cla Lintao Zhang

Lin

tao

Zh

an

g

BC

P A

lgo

rith

m (

4/8

)

No

w le

t’s a

ctu

ally

pro

ce

ss th

e s

eco

nd a

nd

th

ird

cla

use

s:

( 2 3 1 4 5)

( 1 2 -3)

( 1 –2)

(-1 4)

State:(v1=F)

Pending:

Page 10: BCP Algorithm (2/8) - People @ EECS at UC Berkeleysseshia/219c/lectures/... · 2006-02-01 · BCP Algorithm (4.2/8) zNow let’s actually process the second and third cla Lintao Zhang

Lin

tao

Zh

an

g

BC

P A

lgo

rith

m (

4.1

/8)

No

w le

t’s a

ctu

ally

pro

ce

ss th

e s

eco

nd a

nd

th

ird

cla

use

s:

( 2 3 1 4 5)

( 1 2 -3)

( 1 –2)

(-1 4)

For

the s

econd

cla

use,

we r

ep

lace v

1 w

ith ¬

v3 a

s a

ne

w w

atc

hed litera

l.

Sin

ce ¬

v3 is n

ot

assig

ned t

o F

, th

is m

ain

tain

s o

ur

invari

ants

.

( 2 3 1 4 5)

(-3 2 1)

( 1 –2)

(-1 4)

State:(v1=F)

Pending:

State:(v1=F)

Pending:

Page 11: BCP Algorithm (2/8) - People @ EECS at UC Berkeleysseshia/219c/lectures/... · 2006-02-01 · BCP Algorithm (4.2/8) zNow let’s actually process the second and third cla Lintao Zhang

Lin

tao

Zh

an

g

BC

P A

lgo

rith

m (

4.2

/8)

No

w le

t’s a

ctu

ally

pro

ce

ss th

e s

eco

nd a

nd

th

ird

cla

use

s:

( 2 3 1 4 5)

( 1 2 -3)

( 1 –2)

(-1 4)

For

the s

econd

cla

use,

we r

ep

lace v

1 w

ith ¬

v3 a

s a

ne

w w

atc

hed litera

l.

Sin

ce ¬

v3 is n

ot

assig

ned t

o F

, th

is m

ain

tain

s o

ur

invari

ants

.

The t

hird c

lause is im

plie

d.

We r

ecord

the n

ew

im

plic

ation o

f ¬

v2,

and a

dd it

to t

he q

ueue o

f assig

nm

ents

to p

rocess.

Sin

ce t

he c

lause c

annot

ag

ain

becom

e n

ew

ly im

plie

d,

our

invariants

are

ma

inta

ine

d.

( 2 3 1 4 5)

(-3 2 1)

( 1 –2)

(-1 4)

State:(v1=F)

Pending:

State:(v1=F)

Pending:(v2=F)

Page 12: BCP Algorithm (2/8) - People @ EECS at UC Berkeleysseshia/219c/lectures/... · 2006-02-01 · BCP Algorithm (4.2/8) zNow let’s actually process the second and third cla Lintao Zhang

Lin

tao

Zh

an

g

BC

P A

lgo

rith

m (

5/8

)

Next, w

e p

rocess ¬

v2. W

e o

nly

exam

ine the first 2

cla

uses.

( 2 3 1 4 5)

(-3 2 1)

( 1 –2)

(-1 4)

For

the f

irst

cla

use,

we r

epla

ce v

2 w

ith v

4 a

s a

ne

w w

atc

he

d litera

l. S

ince v

4

is n

ot

assig

ned

to F

, th

is m

ain

tain

s o

ur

invari

ants

.

The s

econd c

lause is im

plie

d.

We r

ecord

the n

ew

im

plic

atio

n o

f v3,

and a

dd

it t

o t

he q

ueue o

f assig

nm

ents

to p

rocess.

Sin

ce t

he c

lause c

annot

ag

ain

becom

e n

ew

ly im

plie

d,

our

invariants

are

ma

inta

ine

d.

( 4 3 1 2 5)

(-3 2 1)

( 1 –2)

(-1 4)

State:(v1=F, v2=F)

Pending:

State:(v1=F, v2=F)

Pending:(v3=F)

Page 13: BCP Algorithm (2/8) - People @ EECS at UC Berkeleysseshia/219c/lectures/... · 2006-02-01 · BCP Algorithm (4.2/8) zNow let’s actually process the second and third cla Lintao Zhang

Lin

tao

Zh

an

g

BC

P A

lgo

rith

m (

6/8

)

Next, w

e p

rocess ¬

v3. W

e o

nly

exam

ine the first cla

use

.

( 4 3 1 2 5)

(-3 2 1)

( 1 –2)

(-1 4)

Fo

r th

e f

irst

cla

use

, w

e r

ep

lace

v3

with

v5

as a

ne

w w

atc

he

d lite

ral. S

ince

v5

is n

ot

assig

ne

d t

o F

, th

is m

ain

tain

s o

ur

inva

ria

nts

.

Sin

ce

th

ere

are

no

pe

nd

ing

assig

nm

en

ts,

an

d n

o c

on

flic

t, B

CP

te

rmin

ate

s a

nd

we

ma

ke

a d

ecis

ion

. B

oth

v4

an

d v

5 a

re u

na

ssig

ne

d.

Le

t’s s

ay w

e d

ecid

e t

o a

ssig

n v

4=

T

an

d p

roce

ed

.

( 4 5 1 2 3)

(-3 2 1)

( 1 –2)

(-1 4)

State:(v1=F, v2=F, v3=F)

Pending:

State:(v1=F, v2=F, v3=F)

Pending:

Page 14: BCP Algorithm (2/8) - People @ EECS at UC Berkeleysseshia/219c/lectures/... · 2006-02-01 · BCP Algorithm (4.2/8) zNow let’s actually process the second and third cla Lintao Zhang

Lin

tao

Zh

an

g

BC

P A

lgo

rith

m (

7/8

)

Next, w

e p

rocess v

4. W

e d

o n

oth

ing a

t all.

( 4 5 1 2 3)

(-3 2 1)

( 1 –2)

(-1 4)

Sin

ce t

here

are

no p

end

ing a

ssig

nm

en

ts,

and

no c

onflic

t, B

CP

term

inate

s

and w

e m

ake a

decis

ion.

Only

v5 is u

nassig

ned.

Let’s s

ay w

e d

ecid

e t

o

assig

n v

5=

F a

nd p

rocee

d.

( 4 5 1 2 3)

(-3 2 1)

( 1 –2)

(-1 4)

State:(v1=F, v2=F, v3=F,

v4=T)

State:(v1=F, v2=F, v3=F,

v4=T)

Page 15: BCP Algorithm (2/8) - People @ EECS at UC Berkeleysseshia/219c/lectures/... · 2006-02-01 · BCP Algorithm (4.2/8) zNow let’s actually process the second and third cla Lintao Zhang

Lin

tao

Zh

an

g

BC

P A

lgo

rith

m (

8/8

)

Next, w

e p

rocess v

5=

F. W

e e

xam

ine the first cla

use.

( 4 5 1 2 3)

(-3 2 1)

( 1 –2)

(-1 4)

Th

e f

irst

cla

use

is im

plie

d.

Ho

we

ve

r, t

he

im

plic

ation

is v

4=

T,

wh

ich

is a

du

plic

ate

(sin

ce

v4

=T

alr

ea

dy)

so

we

ig

no

re it.

Sin

ce

th

ere

are

no

pe

nd

ing

assig

nm

en

ts,

an

d n

o c

on

flic

t, B

CP

te

rmin

ate

s a

nd

we

ma

ke

a d

ecis

ion

. N

o v

ari

ab

les a

re u

na

ssig

ne

d,

so

th

e p

rob

lem

is s

at,

an

d w

e a

re

do

ne

.

( 4 5 1 2 3)

(-3 2 1)

( 1 –2)

(-1 4)

State:(v1=F, v2=F, v3=F,

v4=T, v5=F)

State:(v1=F, v2=F, v3=F,

v4=T, v5=F)