


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Material Type: Notes; Class: Advanced Topics in Computer Graphics; Subject: Computer Science; University: University of California-Santa Cruz; Term: Unknown 2004;
Typology: Study notes
1 / 26
This page cannot be seen from the preview
Don't miss anything!
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
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
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
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
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
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
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
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
19 Feb 2004
290G - Lecture 14
Theorem
Can be solved in O(n
2
Algorithm is complete!
Was used successfully in array-bounds checkingelimination and induction variable discovery
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
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
then the problem is NP-complete
but
Z
can be handled well with heuristics
No practical satisfiability procedures for (
The satisfiability of (
) is only semi-decidable