Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Satisfying Error Conditions 2 - Lecture Slides | CMPS 290, Study notes of Computer Graphics

Material Type: Notes; Class: Advanced Topics in Computer Graphics; Subject: Computer Science; University: University of California-Santa Cruz; Term: Unknown 2004;

Typology: Study notes

Pre 2010

Uploaded on 08/19/2009

koofers-user-3j4-1
koofers-user-3j4-1 🇺🇸

10 documents

1 / 26

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Satisfying Error Conditions 2
Lecture 14
19 Feb 2004 290G - Lecture 14 1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a

Partial preview of the text

Download Satisfying Error Conditions 2 - Lecture Slides | CMPS 290 and more Study notes Computer Graphics in PDF only on Docsity!

  • Satisfying Error Conditions
    • Lecture
      • 19 Feb
      • 290G - Lecture

Review: Where Are We?

19 Feb 2004

290G - Lecture 14

Error

Verification

Condition

Program

Specification

Semantics

VC

generation

Invalid

Error

Condition

negate

satisfiable

{a=b}

{f(a)=f(b)}

{b=c})

{f(a)=f(c)}

19 Feb 2004

290G - Lecture 14

{a=b}

{f(a)=f(b)}

{b=c}

{f(a)=f(c)}

Sat?

0

0

0

0

0

0

0

0

1

0

0

0

1

0

0

0

0

1

1

0

0

1

0

0

0

0

1

0

1

0

0

1

1

0

0

0

1

1

1

0

1

0

0

0

1

1

0

0

1

0

1

0

1

0

1

1

0

1

1

0

1

1

0

0

0

1

1

0

1

0

1

1

1

0

1

1

1

1

1

0

a=b

.

f(a)

g

f(b)

.

b

g

c

.

f(a)

g

f(c)

a=b

.

f(a)

g

f(b)

.

b=c

.

f(a)

g

f(c)

a=b

.

f(a)=f(b)

.

b=c

.

f(a)

g

f(c)

{a=b}

{f(a)=f(b)}

{b=c})

{f(a)=f(c)}

19 Feb 2004

290G - Lecture 14

{a=b}

{f(a)=f(b)}

{b=c}

{f(a)=f(c)}

Sat?

0

0

0

0

0

0

0

0

1

0

0

0

1

0

0

0

0

1

1

0

0

1

0

0

0

0

1

0

1

0

0

1

1

0

0

0

1

1

1

0

1

0

0

0

1

1

0

0

1

0

1

0

1

0

1

1

0

1

1

0

1

1

0

0

0

1

1

0

1

0

1

1

1

0

1

1

1

1

1

0

a=b

.

f(a)

g

f(b)

.

b

g

c

.

f(a)

g

f(c)

(a=b

f(a)=f(b))

{a=b}

{f(a)=f(b)}

X 0

X 0

Explicated tautology

removes many other

truth assignments

Examples of Theories. Equality.

19 Feb 2004

290G - Lecture 14

Syntax

, f, g, …

Semantics: as expected

E

2

= E

1

E

1

= E

2

E

1

= E

2

E

2

= E

3

E

1

= E

3

E

1

= E

2

f(E

1

) = f(E

2

)

E = E

Example

g(g(g(x)) = x

g(g(g(g(g(x))))) = x

g(x)

x

Satisfiability Algorithm for Equality (1)

19 Feb 2004

290G - Lecture 14

We represent terms as DAGs

Share common subexpressions

E.g. f(f(a, b), b):

f(f(a, b), b)

f

f

a

b

f(a, b) a b

Satisfiability Algorithm for Equality (3)

19 Feb 2004

290G - Lecture 14

t* is representative element for t

For all nodes t = f(t

1

, …, t

n

) and s = f(s

1

, …, s

n

If t

i

= s

i

for all i = 1..n (find)

We add dotted arrow between t* and s*

E.g.

f(a,b) = a

f

f

a

b

Satisfiability Procedure for Equality

19 Feb 2004

290G - Lecture 14

Given F =

i

t

i

= t

i

j

u

j

u

j

Represent all terms in the same DAG

Add dotted edges for t

i

= t

i

Construct the congruence closure of those edges

Check that for all j we have u

j

u

j

Theorem

F is satisfiable

if and only if

for all j

u

j

u

j

Example with Congruence Closure

19 Feb 2004

290G - Lecture 14

13

Consider: g(g(g(x)) = x

g(g(g(g(g(x))))) = x

g(x)

x

g g x

g g g

g g x

g g g

g g g g g x

x

g g g g g

Contra

diction

Presburger Arithmetic

19 Feb 2004

290G - Lecture 14

Syntax:

Semantics: as expected

The most useful in program verification after equality

checking array bounds, etc

Example:

y > 2x + 1

y + x > 1

y < 0

Difference Constraints (cont)

19 Feb 2004

290G - Lecture 14

Hint: Think of a directed graph

with a node for each variable

represent constraint in each graph

and think about graph algorithms

Example

x <= y

y+4 <= w

w-2 <= x

w+1 < =z

What is explanation?

x

y

w 0

z

Difference Constraints

19 Feb 2004

290G - Lecture 14

Theorem

A set of difference constraints is satisfiable

in and only if there is no positive weight cycle in the graph

Can be solved in O(n

2

Algorithm is complete!

Was used successfully in array-bounds checkingelimination and induction variable discovery

How Complete are These Procedures?

19 Feb 2004

290G - Lecture 14

Consider: 3x

2y

3y

2x

x

w

Is it satisfiable?

What is solution?

Is there a solution in Z?

The unsat procedure is sound: unsat Q

unsat Z

But it is incomplete!

Not a problem in practice

Goes away with tricks like:

Transform “ax

b” into “x

b/a

Arithmetic. Discussion

19 Feb 2004

290G - Lecture 14

There are many satisfiability algorithms for Q

even for the general case (e.g. Simplex)

polynomial time

complete

If we add the requirement that solutions are in

Z

then the problem is NP-complete

but

Z

can be handled well with heuristics

No practical satisfiability procedures for (

Q

The satisfiability of (

Z

) is only semi-decidable