Proving Termination of Programs with Bitvector Arithmetic
by Symbolic Execution
J¨ urgen Giesl
LuFG Informatik 2, RWTH Aachen University, Germany
joint work with Jera Hensel, Florian Frohn, and Thomas Str¨oder
Termination Analysis in AProVE
Java C Haskell Prolog
JBC
LLVM Symbolic
Execution Graph
Integer Transition
System (ITS)
Safety Termination
Complexity Non-Termination
Termination Analysis in AProVE
Java C Haskell Prolog
JBC
LLVM Symbolic
Execution Graph
Integer Transition
System (ITS)
Safety Termination
Complexity Non-Termination
Winner of SV-COMP 2015 & 2016 termination competition
Drawback: assumes mathematical integers Z instead of bitvectors
Termination Analysis in AProVE
Java C Haskell Prolog
JBC
LLVM Symbolic
Execution Graph
Integer Transition
System (ITS)
Safety Termination
Complexity Non-Termination
Termination of C programs with explicit pointer arithmetic
Termination Analysis in AProVE
Java C Haskell Prolog
JBC
LLVM Symbolic
Execution Graph
Integer Transition
System (ITS)
Safety Termination
Complexity Non-Termination
Termination of C programs with explicit pointer arithmetic Winner of SV-COMP 2015 & 2016 termination competition
Z
Java C Haskell Prolog
JBC
LLVM Symbolic
Execution Graph
Integer Transition
System (ITS)
Safety Termination
Complexity Non-Termination
Termination of C programs with explicit pointer arithmetic
Winner of SV-COMP 2015 & 2016 termination competition
Drawback: assumes mathematical integers Z instead of bitvectors
Mathematical Integers Z vs. Bitvectors
void f(unsigned int x) { unsigned int j = 0;
while (j <= x) j++; }
for Z : termination for bitvectors: non-termination
void g(unsigned int j) { while (j > 0) j++; }
for Z : non-termination for bitvectors: termination
Goal: adapt termination analysis of C to bitvector arithmetic Solution: express bitvector relations by relations on Z
standardSMT solving overZ forsymbolic execution standardITSs overZ fortermination proving
Mathematical Integers Z vs. Bitvectors
void f(unsigned int x) { unsigned int j = 0;
while (j <= x) j++; }
for Z : termination
for bitvectors: non-termination
void g(unsigned int j) { while (j > 0) j++; }
for Z : non-termination for bitvectors: termination
Goal: adapt termination analysis of C to bitvector arithmetic Solution: express bitvector relations by relations on Z
standardITSs overZ fortermination proving
Mathematical Integers Z vs. Bitvectors
void f(unsigned int x) { unsigned int j = 0;
while (j <= x) j++; }
for Z : termination for bitvectors: non-termination
void g(unsigned int j) { while (j > 0) j++; }
for Z : non-termination for bitvectors: termination
Goal: adapt termination analysis of C to bitvector arithmetic Solution: express bitvector relations by relations on Z
standardSMT solving overZ forsymbolic execution standardITSs overZ fortermination proving
Mathematical Integers Z vs. Bitvectors
void f(unsigned int x) { unsigned int j = 0;
while (j <= x) j++; }
for Z : termination for bitvectors: non-termination
void g(unsigned int j) { while (j > 0) j++; }
for Z : non-termination
for bitvectors: termination
Goal: adapt termination analysis of C to bitvector arithmetic Solution: express bitvector relations by relations on Z
standardITSs overZ fortermination proving
Mathematical Integers Z vs. Bitvectors
void f(unsigned int x) { unsigned int j = 0;
while (j <= x) j++; }
for Z : termination for bitvectors: non-termination
void g(unsigned int j) { while (j > 0) j++; }
for Z : non-termination for bitvectors: termination
Goal: adapt termination analysis of C to bitvector arithmetic Solution: express bitvector relations by relations on Z
standardSMT solving overZ forsymbolic execution standardITSs overZ fortermination proving
Mathematical Integers Z vs. Bitvectors
void f(unsigned int x) { unsigned int j = 0;
while (j <= x) j++; }
for Z : termination for bitvectors: non-termination
void g(unsigned int j) { while (j > 0) j++; }
for Z : non-termination for bitvectors: termination
Goal: adapt termination analysis of C
byte-accurate symbolic execution
to bitvector arithmetic
Solution: express bitvector relations by relations on Z
Mathematical Integers Z vs. Bitvectors
void f(unsigned int x) { unsigned int j = 0;
while (j <= x) j++; }
for Z : termination for bitvectors: non-termination
void g(unsigned int j) { while (j > 0) j++; }
for Z : non-termination for bitvectors: termination
Goal: adapt termination analysis of C to bitvector arithmetic Solution: express bitvector relations by relations on Z
standardSMT solving overZ forsymbolic execution standardITSs overZ fortermination proving
Mathematical Integers Z vs. Bitvectors
void f(unsigned int x) { unsigned int j = 0;
while (j <= x) j++; }
for Z : termination for bitvectors: non-termination
void g(unsigned int j) { while (j > 0) j++; }
for Z : non-termination for bitvectors: termination
Goal: adapt termination analysis of C to bitvector arithmetic Solution: express bitvector relations by relations on Z
standard SMT solving overZ forsymbolic execution
standardITSs overZ fortermination proving
Mathematical Integers Z vs. Bitvectors
void f(unsigned int x) { unsigned int j = 0;
while (j <= x) j++; }
for Z : termination for bitvectors: non-termination
void g(unsigned int j) { while (j > 0) j++; }
for Z : non-termination for bitvectors: termination
Goal: adapt termination analysis of C to bitvector arithmetic Solution: express bitvector relations by relations on Z
standard SMT solving overZ forsymbolic execution standard ITSs overZ fortermination proving
Mathematical Integers Z vs. Bitvectors
void f(unsigned int x) { unsigned int j = 0;
while (j <= x) j++; }
for Z : termination for bitvectors: non-termination
void g(unsigned int j) { while (j > 0) j++; }
for Z : non-termination for bitvectors: termination
Goal: adapt byte-accurate symbolic execution to bitvector arithmetic Solution: express bitvector relations by relations on Z
standard SMT solving overZ forsymbolic execution standard ITSs overZ fortermination proving
From C to LLVM
entry: 0: ad = alloca i32 1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
void g(unsigned int j) { while (j > 0) j++; }
C LLVM
Symbolic Execution Graph
Integer Transition
System (ITS)
Safety Termination
2: br label cmp cmp: 0: j1 = load i32* ad
1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
C LLVM
Symbolic Execution Graph
Integer Transition
System (ITS)
Safety Termination
Abstract States
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
void g(unsigned int j) while (j > 0) j++; }
C LLVM
Symbolic Execution Graph
Integer Transition
System (ITS)
Safety Termination
Abstract States
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
a
(entry,2)
{j=vj,ad=vad} {Jvad,vendK} {vend =vad+ 3} {vad,→i32,uvj}
⇐ = pos
⇐ = PV
⇐ = AL
⇐ = KB
⇐ = PT
Heuristic: partitionprogram variables intoU ] S
x∈ U: PV(x)represents value ofx as unsigned integer
Abstract state a:
ERR or
pos : program position (block, next instruction) PV : program variables → symbolic variables AL: allocation list J v
1, v
2K
KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v
1, →
type,uv
2hai: FO formula
containing
KB and consequences ofALandPT information on ranges of integers:
a concrete:
∀ symbolic variables v ∃ n ∈ Z such that | = hai ⇒ v = n
hai
SL: separation logic formula, extends hai by details on memory abstract state a represents concrete state
iff
hai
SLis satisfied by instantiation corresponding to concrete state
Abstract States
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
a
(entry,2){j=vj,ad=vad} {Jvad,vendK} {vend =vad+ 3} {vad,→i32,uvj}
⇐ = pos
⇐ = PV
⇐ = AL
⇐ = KB
⇐ = PT
Heuristic: partitionprogram variables intoU ] S
x∈ U: PV(x)represents value ofx as unsigned integer
Abstract state a:
ERR or
pos : program position (block, next instruction)
PV : program variables → symbolic variables AL: allocation list J v
1, v
2K
KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v
1, →
type,uv
2hai: FO formula
containing
KB and consequences ofALandPT information on ranges of integers:
| {z }
vj
| {z }
232−1
a concrete:
∀ symbolic variables v ∃ n ∈ Z such that | = hai ⇒ v = n
hai
SL: separation logic formula, extends hai by details on memory abstract state a represents concrete state
iff
hai
SLis satisfied by instantiation corresponding to concrete state
Abstract States
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
a
(entry,2){j=vj,ad=vad}
{Jvad,vendK} {vend =vad+ 3} {vad,→i32,uvj}
⇐ = pos
⇐ = PV
⇐ = AL
⇐ = KB
⇐ = PT
Heuristic: partitionprogram variables intoU ] S
x∈ U: PV(x)represents value ofx as unsigned integer
Abstract state a:
ERR or
pos : program position (block, next instruction) PV : program variables → symbolic variables
AL: allocation list J v
1, v
2K
KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v
1, →
type,uv
2hai: FO formula
containing
KB and consequences ofALandPT information on ranges of integers:
a concrete:
∀ symbolic variables v ∃ n ∈ Z such that | = hai ⇒ v = n
hai
SL: separation logic formula, extends hai by details on memory abstract state a represents concrete state
iff
hai
SLis satisfied by instantiation corresponding to concrete state
Abstract States
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
a
(entry,2){j=vj,ad=vad} {Jvad,vendK}
{vend =vad+ 3} {vad,→i32,uvj}
⇐ = pos
⇐ = PV
⇐ = AL
⇐ = KB
⇐ = PT
Heuristic: partitionprogram variables intoU ] S
x∈ U: PV(x)represents value ofx as unsigned integer
Abstract state a:
ERR or
pos : program position (block, next instruction) PV : program variables → symbolic variables AL: allocation list J v
1, v
2K
KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v
1, →
type,uv
2hai: FO formula
containing
KB and consequences ofALandPT information on ranges of integers:
| {z }
vj
| {z }
232−1
a concrete:
∀ symbolic variables v ∃ n ∈ Z such that | = hai ⇒ v = n
hai
SL: separation logic formula, extends hai by details on memory abstract state a represents concrete state
iff
hai
SLis satisfied by instantiation corresponding to concrete state
Abstract States
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
a
(entry,2){j=vj,ad=vad} {Jvad,vendK} {vend =vad+ 3}
{vad,→i32,uvj}
⇐ = pos
⇐ = PV
⇐ = AL
⇐ = KB
⇐ = PT
Heuristic: partitionprogram variables intoU ] S
x∈ U: PV(x)represents value ofx as unsigned integer
Abstract state a:
ERR or
pos : program position (block, next instruction) PV : program variables → symbolic variables AL: allocation list J v
1, v
2K
KB : knowledge base (FO-(in)equalities over symbolic variables)
PT : points-to atoms v
1, →
type,uv
2hai: FO formula
containing
KB and consequences ofALandPT information on ranges of integers:
a concrete:
∀ symbolic variables v ∃ n ∈ Z such that | = hai ⇒ v = n
hai
SL: separation logic formula, extends hai by details on memory abstract state a represents concrete state
iff
hai
SLis satisfied by instantiation corresponding to concrete state
Abstract States
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
a
(entry,2){j=vj,ad=vad} {Jvad,vendK} {vend =vad+ 3}
{vad,→i32,uvj}
⇐ = pos
⇐ = PV
⇐ = AL
⇐ = KB
⇐ = PT
Heuristic: partitionprogram variables intoU ] S
x∈ U: PV(x)represents value ofx as unsigned integer
Abstract state a:
ERR or
pos : program position (block, next instruction) PV : program variables → symbolic variables AL: allocation list J v
1, v
2K
KB : knowledge base (FO-(in)equalities over symbolic variables)
PT : points-to atoms v
1, →
type,uv
2hai: FO formula
containing
KB and consequences ofALandPT information on ranges of integers:
| {z }
vj
| {z }
232−1
a concrete:
∀ symbolic variables v ∃ n ∈ Z such that | = hai ⇒ v = n
hai
SL: separation logic formula, extends hai by details on memory abstract state a represents concrete state
iff
hai
SLis satisfied by instantiation corresponding to concrete state
Abstract States
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
a
(entry,2){j=vj,ad=vad} {Jvad,vendK} {vend =vad+ 3}
{vad,→i32,uvj}
⇐ = pos
⇐ = PV
⇐ = AL
⇐ = KB
⇐ = PT
Heuristic: partitionprogram variables intoU ] S
x∈ U: PV(x)represents value ofx as unsigned integer
Abstract state a:
ERR or
pos : program position (block, next instruction) PV : program variables → symbolic variables AL: allocation list J v
1, v
2K
KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v
1, →
type,uv
2hai: FO formula
containing
KB and consequences ofALandPT information on ranges of integers:
a concrete:
∀ symbolic variables v ∃ n ∈ Z such that | = hai ⇒ v = n
hai
SL: separation logic formula, extends hai by details on memory abstract state a represents concrete state
iff
hai
SLis satisfied by instantiation corresponding to concrete state
Abstract States
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
a
(entry,2){j=vj,ad=vad} {Jvad,vendK} {vend =vad+ 3}
{vad,→i32,uvj}
⇐ = pos
⇐ = PV
⇐ = AL
⇐ = KB
⇐ = PT
Heuristic: partitionprogram variables intoU ] S
x∈ U: PV(x)represents value ofx as unsigned integer
Abstract state a: ERR or
pos : program position (block, next instruction) PV : program variables → symbolic variables AL: allocation list J v
1, v
2K
KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v
1, →
type,uv
2hai: FO formula
containing
KB and consequences ofALandPT information on ranges of integers:
| {z }
vj
| {z }
232−1
a concrete:
∀ symbolic variables v ∃ n ∈ Z such that | = hai ⇒ v = n
hai
SL: separation logic formula, extends hai by details on memory abstract state a represents concrete state
iff
hai
SLis satisfied by instantiation corresponding to concrete state
Abstract States
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
a
(entry,2){j=vj,ad=vad} {Jvad,vendK} {vend =vad+ 3}
{vad,→i32,uvj}
⇐ = pos
⇐ = PV
⇐ = AL
⇐ = KB
⇐ = PT
Heuristic: partitionprogram variables intoU ] S
x∈ U: PV(x)represents value ofx as unsigned integer
Abstract state a:
ERR or
pos : program position (block, next instruction) PV : program variables → symbolic variables AL: allocation list J v
1, v
2K
KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v
1, →
type,uv
2hai: FO formula
containing
KB and consequences ofALandPT information on ranges of integers:
a concrete:
∀ symbolic variables v ∃ n ∈ Z such that | = hai ⇒ v = n
hai
SL: separation logic formula, extends hai by details on memory abstract state a represents concrete state
iff
hai
SLis satisfied by instantiation corresponding to concrete state
Abstract States
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
a
(entry,2){j=vj,ad=vad} {Jvad,vendK} {vend =vad+ 3}
{vad,→i32,uvj}
⇐ = pos
⇐ = PV
⇐ = AL
⇐ = KB
⇐ = PT
Heuristic: partitionprogram variables intoU ] S
x∈ U: PV(x)represents value ofx as unsigned integer
Abstract state a:
pos : program position (block, next instruction) PV : program variables → symbolic variables AL: allocation list J v
1, v
2K
KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v
1, →
type,uv
2hai: FO formula containing
KB and consequences ofALandPT
information on ranges of integers:
j∈ U has type i32 ⇒ 0≤PV(j)
| {z }
vj
≤umax32
| {z }
232−1
a concrete:
∀ symbolic variables v ∃ n ∈ Z such that | = hai ⇒ v = n
hai
SL: separation logic formula, extends hai by details on memory abstract state a represents concrete state
iff
hai
SLis satisfied by instantiation corresponding to concrete state
Abstract States
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
a
(entry,2){j=vj,ad=vad} {Jvad,vendK} {vend =vad+ 3}
{vad,→i32,uvj}
⇐ = pos
⇐ = PV
⇐ = AL
⇐ = KB
⇐ = PT
Heuristic: partitionprogram variables intoU ] S
x∈ U: PV(x)represents value ofx as unsigned integer
Abstract state a:
pos : program position (block, next instruction) PV : program variables → symbolic variables AL: allocation list J v
1, v
2K
KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v
1, →
type,uv
2hai: FO formula containing
KB and consequences ofALandPT information on ranges of integers:
j∈ U has type i32 ⇒ 0≤PV(j)
| {z }
vj
≤umax32
| {z }
232−1
a concrete:
hai
SL: separation logic formula, extends hai by details on memory abstract state a represents concrete state
iff
hai
SLis satisfied by instantiation corresponding to concrete state
Abstract States
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
a
(entry,2){j=vj,ad=vad} {Jvad,vendK} {vend =vad+ 3}
{vad,→i32,uvj}
⇐ = pos
⇐ = PV
⇐ = AL
⇐ = KB
⇐ = PT
Heuristic: partitionprogram variables intoU ] S
x∈ U: PV(x)represents value ofx as unsigned integer
Abstract state a:
pos : program position (block, next instruction) PV : program variables → symbolic variables AL: allocation list J v
1, v
2K
KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v
1, →
type,uv
2hai: FO formula containing
KB and consequences ofALandPT
information on ranges of integers:
j∈ U has type i32 ⇒ 0≤PV(j)
| {z }
vj
≤umax32
| {z }
232−1
a concrete:
∀ symbolic variables v ∃ n ∈ Z such that | = hai ⇒ v = n
hai
SL: separation logic formula, extends hai by details on memory abstract state a represents concrete state
iff
hai
SLis satisfied by instantiation corresponding to concrete state
Abstract States
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
a
(entry,2){j=vj,ad=vad} {Jvad,vendK} {vend =vad+ 3}
{vad,→i32,uvj}
⇐ = pos
⇐ = PV
⇐ = AL
⇐ = KB
⇐ = PT
Heuristic: partitionprogram variables intoU ] S
x∈ U: PV(x)represents value ofx as unsigned integer
Abstract state a:
pos : program position (block, next instruction) PV : program variables → symbolic variables AL: allocation list J v
1, v
2K
KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v
1, →
type,uv
2hai: FO formula
containing
KB and consequences ofALandPT
information on ranges of integers: j∈ U has type i32 ⇒ 0≤PV(j)
| {z }
vj
≤umax32
| {z }
232−1
a concrete:
∀ symbolic variables v ∃ n ∈ Z such that | = hai ⇒ v = n hai
SL: separation logic formula, extends hai by details on memory abstract state a represents concrete state
iff
hai
SLis satisfied by instantiation corresponding to concrete state
Abstract States
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
a
(entry,2){j=vj,ad=vad} {Jvad,vendK} {vend =vad+ 3}
{vad,→i32,uvj}
⇐ = pos
⇐ = PV
⇐ = AL
⇐ = KB
⇐ = PT
Heuristic: partitionprogram variables intoU ] S
x∈ U: PV(x)represents value ofx as unsigned integer
Abstract state a:
pos : program position (block, next instruction) PV : program variables → symbolic variables AL: allocation list J v
1, v
2K
KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v
1, →
type,uv
2hai: FO formula
containing
KB and consequences ofALandPT
information on ranges of integers: j∈ U has type i32 ⇒ 0≤PV(j)
| {z }
vj
≤umax32
| {z }
232−1
a concrete: ∀ symbolic variables v ∃ n ∈ Z such that | = hai ⇒ v = n
hai
SL: separation logic formula, extends hai by details on memory abstract state a represents concrete state
iff
hai
SLis satisfied by instantiation corresponding to concrete state
Abstract States
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
a
(entry,2){j=vj,ad=vad} {Jvad,vendK} {vend =vad+ 3}
{vad,→i32,uvj}
⇐ = pos
⇐ = PV
⇐ = AL
⇐ = KB
⇐ = PT
Heuristic: partitionprogram variables intoU ] S
x∈ U: PV(x)represents value ofx as unsigned integer
Abstract state a:
pos : program position (block, next instruction) PV : program variables → symbolic variables AL: allocation list J v
1, v
2K
KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v
1, →
type,uv
2hai: FO formula
containing
KB and consequences ofALandPT
information on ranges of integers: j∈ U has type i32 ⇒ 0≤PV(j)
| {z }
vj
≤umax32
| {z }
232−1
a concrete: ∀ symbolic variables v ∃ n ∈ Z such that | = hai ⇒ v = n hai
SL: separation logic formula, extends hai by details on memory
abstract state a represents concrete state
iff
hai
SLis satisfied by instantiation corresponding to concrete state
Abstract States
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
a
(entry,2){j=vj,ad=vad} {Jvad,vendK} {vend =vad+ 3}
{vad,→i32,uvj}
⇐ = pos
⇐ = PV
⇐ = AL
⇐ = KB
⇐ = PT
Heuristic: partitionprogram variables intoU ] S
x∈ U: PV(x)represents value ofx as unsigned integer
Abstract state a:
pos : program position (block, next instruction) PV : program variables → symbolic variables AL: allocation list J v
1, v
2K
KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v
1, →
type,uv
2hai: FO formula
containing
KB and consequences ofALandPT
information on ranges of integers: j∈ U has type i32 ⇒ 0≤PV(j)
| {z }
vj
≤umax32
| {z }
232−1
a concrete: ∀ symbolic variables v ∃ n ∈ Z such that | = hai ⇒ v = n hai
SL: separation logic formula, extends hai by details on memory abstract state a represents concrete state
iff
hai
SLis satisfied by instantiation corresponding to concrete state
Abstract States
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
a
(entry,2){j=vj,ad=vad} {Jvad,vendK} {vend =vad+ 3}
{vad,→i32,uvj}
⇐ = pos
⇐ = PV
⇐ = AL
⇐ = KB
⇐ = PT
Heuristic: partitionprogram variables intoU ] S
x∈ U: PV(x)represents value ofx as unsigned integer
Abstract state a:
pos : program position (block, next instruction) PV : program variables → symbolic variables AL: allocation list J v
1, v
2K
KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v
1, →
type,uv
2hai: FO formula
containing
KB and consequences ofALandPT
information on ranges of integers: j∈ U has type i32 ⇒ 0≤PV(j)
| {z }
vj
≤umax32
| {z }
232−1
a concrete: ∀ symbolic variables v ∃ n ∈ Z such that | = hai ⇒ v = n hai
SL: separation logic formula, extends hai by details on memory abstract state a represents concrete state iff
hai
SLis satisfied by instantiation corresponding to concrete state
Symbolic Execution
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
(entry,0) {j=vj, ...}
∅
{0≤vj≤umax, ...}
∅ A
{j=vj,ad=vad, ...} {Jvad,vendK} {vend=vad+ 3, ...}
∅ (entry,2)
{j=vj,ad=vad, ...} {Jvad,vendK} {...} {vad,→vj} C
(cmp,0)
{j=vj,ad=vad, ...} {Jvad,vendK} {...} {vad,→vj} D
(cmp,1)
{j=vj,ad=vad, j1=vj, ...} {Jvad,vendK} {...} {vad,→vj} E
⇐=PV
⇐=AL
⇐=KB
⇐=PT
Symbolic Execution
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
(entry,0) {j=vj, ...}
∅
{0≤vj≤umax, ...}
∅ A
(entry,2)
{j=vj,ad=vad, ...} {Jvad,vendK} {...} {vad,→vj} C
(cmp,0)
{j=vj,ad=vad, ...} {Jvad,vendK} {...} {vad,→vj} D
(cmp,1)
{j=vj,ad=vad, j1=vj, ...} {Jvad,vendK} {...} {vad,→vj} E
⇐=pos
⇐=PV
⇐=AL
⇐=KB
⇐=PT
Symbolic Execution
define i32 @g(i32 j) { entry:0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
(entry,0) {j=vj, ...}
∅
{0≤vj≤umax, ...}
∅ A
{j=vj,ad=vad, ...} {Jvad,vendK} {vend=vad+ 3, ...}
∅ (entry,2)
{j=vj,ad=vad, ...} {Jvad,vendK} {...} {vad,→vj} C
(cmp,0)
{j=vj,ad=vad, ...} {Jvad,vendK} {...} {vad,→vj} D
(cmp,1)
{j=vj,ad=vad, j1=vj, ...} {Jvad,vendK} {...} {vad,→vj} E
⇐=pos
⇐=PV
⇐=AL
⇐=KB
⇐=PT
Symbolic Execution
define i32 @g(i32 j) { entry:0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
(entry,0) {j=vj, ...}
∅
{0≤vj≤umax, ...}
∅
A (entry,1)
{j=vj,ad=vad, ...}
{Jvad,vendK} {vend=vad+ 3, ...}
∅ B
(entry,2)
{j=vj,ad=vad, ...} {Jvad,vendK} {...} {vad,→vj} C
(cmp,0)
{j=vj,ad=vad, ...} {Jvad,vendK} {...} {vad,→vj} D
(cmp,1)
{j=vj,ad=vad, j1=vj, ...} {Jvad,vendK} {...} {vad,→vj} E
Symbolic Execution
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
(entry,0) {j=vj, ...}
∅
{0≤vj≤umax, ...}
∅
A (entry,1)
{j=vj,ad=vad, ...}
{Jvad,vendK} {vend=vad+ 3, ...}
∅ B
(entry,2)
{j=vj,ad=vad, ...} {Jvad,vendK} {...} {vad,→vj} C
(cmp,0)
{j=vj,ad=vad, ...} {Jvad,vendK} {...} {vad,→vj} D
(cmp,1)
{j=vj,ad=vad, j1=vj, ...} {Jvad,vendK} {...} {vad,→vj} E
⇐=PV
⇐=AL
⇐=KB
⇐=PT
Symbolic Execution
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
(entry,0) {j=vj, ...}
∅
{0≤vj≤umax, ...}
∅
A (entry,1)
{j=vj,ad=vad, ...}
{Jvad,vendK} {vend=vad+ 3, ...}
∅ B
(entry,2)
{j=vj,ad=vad, ...}
{Jvad,vendK} {...}
{vad,→vj} C
(cmp,0)
{j=vj,ad=vad, ...} {Jvad,vendK} {...} {vad,→vj} D
(cmp,1)
{j=vj,ad=vad, j1=vj, ...} {Jvad,vendK} {...} {vad,→vj} E
Symbolic Execution
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
(entry,0) {j=vj, ...}
∅
{0≤vj≤umax, ...}
∅
A (entry,1)
{j=vj,ad=vad, ...}
{Jvad,vendK} {vend=vad+ 3, ...}
∅ B
(entry,2)
{j=vj,ad=vad, ...}
{Jvad,vendK} {...}
{vad,→vj} C
(cmp,0)
{j=vj,ad=vad, ...} {Jvad,vendK} {...} {vad,→vj} D
(cmp,1)
{j=vj,ad=vad, j1=vj, ...} {Jvad,vendK} {...} {vad,→vj} E
⇐=PV
⇐=AL
⇐=KB
⇐=PT
Symbolic Execution
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
(entry,0) {j=vj, ...}
∅
{0≤vj≤umax, ...}
∅
A (entry,1)
{j=vj,ad=vad, ...}
{Jvad,vendK} {vend=vad+ 3, ...}
∅ B
(entry,2)
{j=vj,ad=vad, ...}
{Jvad,vendK} {...}
{vad,→vj} C
(cmp,0)
{j=vj,ad=vad, ...}
{Jvad,vendK} {...}
{vad,→vj} D
(cmp,1)
{j=vj,ad=vad, j1=vj, ...} {Jvad,vendK} {...} {vad,→vj} E
Symbolic Execution
define i32 @g(i32 j) { entry: 0: ad = alloca i32
1: store i32 j, i32* ad 2: br label cmp
cmp: 0: j1 = load i32* ad 1: j1p = icmp ugt i32 j1, 0 2: br i1 j1p, label body,
label done body: 0: j2 = load i32* ad
1: inc = add i32 j2, 1 2: store i32 inc, i32* ad 3: br label cmp
done: 0: ret void }
(entry,0) {j=vj, ...}
∅
{0≤vj≤umax, ...}
∅
A (entry,1)
{j=vj,ad=vad, ...}
{Jvad,vendK} {vend=vad+ 3, ...}
∅ B
(entry,2)
{j=vj,ad=vad, ...}
{Jvad,vendK} {...}
{vad,→vj} C
(cmp,0)
{j=vj,ad=vad, ...}
{Jvad,vendK} {...}
{vad,→vj} D
(cmp,1)
{j=vj,ad=vad, j1=vj, ...} {Jvad,vendK} {...} {vad,→vj} E
⇐=PV
⇐=AL
⇐=KB
⇐=PT