• Keine Ergebnisse gefunden

Proving Termination of Programs with Bitvector Arithmetic by Symbolic Execution

N/A
N/A
Protected

Academic year: 2021

Aktie "Proving Termination of Programs with Bitvector Arithmetic by Symbolic Execution"

Copied!
124
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

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

(2)

Termination Analysis in AProVE

Java C Haskell Prolog

JBC

LLVM Symbolic

Execution Graph

Integer Transition

System (ITS)

Safety Termination

Complexity Non-Termination

(3)

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

(4)

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

(5)

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

(6)

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

(7)

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

(8)

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

(9)

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

(10)

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

(11)

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

(12)

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

(13)

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

(14)

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

(15)

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

(16)

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

(17)

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

(18)

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

(19)

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

(20)

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

2

K

KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v

1

, →

type,u

v

2

hai: 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

SL

is satisfied by instantiation corresponding to concrete state

(21)

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

2

K

KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v

1

, →

type,u

v

2

hai: 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

SL

is satisfied by instantiation corresponding to concrete state

(22)

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

2

K

KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v

1

, →

type,u

v

2

hai: 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

SL

is satisfied by instantiation corresponding to concrete state

(23)

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

2

K

KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v

1

, →

type,u

v

2

hai: 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

SL

is satisfied by instantiation corresponding to concrete state

(24)

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

2

K

KB : knowledge base (FO-(in)equalities over symbolic variables)

PT : points-to atoms v

1

, →

type,u

v

2

hai: 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

SL

is satisfied by instantiation corresponding to concrete state

(25)

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

2

K

KB : knowledge base (FO-(in)equalities over symbolic variables)

PT : points-to atoms v

1

, →

type,u

v

2

hai: 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

SL

is satisfied by instantiation corresponding to concrete state

(26)

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

2

K

KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v

1

, →

type,u

v

2

hai: 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

SL

is satisfied by instantiation corresponding to concrete state

(27)

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

2

K

KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v

1

, →

type,u

v

2

hai: 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

SL

is satisfied by instantiation corresponding to concrete state

(28)

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

2

K

KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v

1

, →

type,u

v

2

hai: 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

SL

is satisfied by instantiation corresponding to concrete state

(29)

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

2

K

KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v

1

, →

type,u

v

2

hai: 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

SL

is satisfied by instantiation corresponding to concrete state

(30)

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

2

K

KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v

1

, →

type,u

v

2

hai: 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

SL

is satisfied by instantiation corresponding to concrete state

(31)

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

2

K

KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v

1

, →

type,u

v

2

hai: 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

SL

is satisfied by instantiation corresponding to concrete state

(32)

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

2

K

KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v

1

, →

type,u

v

2

hai: 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

SL

is satisfied by instantiation corresponding to concrete state

(33)

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

2

K

KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v

1

, →

type,u

v

2

hai: 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

SL

is satisfied by instantiation corresponding to concrete state

(34)

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

2

K

KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v

1

, →

type,u

v

2

hai: 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

SL

is satisfied by instantiation corresponding to concrete state

(35)

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

2

K

KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v

1

, →

type,u

v

2

hai: 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

SL

is satisfied by instantiation corresponding to concrete state

(36)

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

2

K

KB : knowledge base (FO-(in)equalities over symbolic variables) PT : points-to atoms v

1

, →

type,u

v

2

hai: 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

SL

is satisfied by instantiation corresponding to concrete state

(37)

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

(38)

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

(39)

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

(40)

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

(41)

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

(42)

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

(43)

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

(44)

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

(45)

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

Referenzen

ÄHNLICHE DOKUMENTE

We introduce a novel pre-processing method which automatically transforms Prolog programs into logic pro- grams without cuts, where termination of the cut-free program

The reason is that in the Eval rule one does not take into account that no concretization of the current abstract goal would unify with any head of a program clause (since

We show how to combine the two most powerful approaches for automated termination analysis of logic programs (LPs): the direct approach which operates directly on LPs and

14 To avoid the need for considering infinitely many rules in the reduction pair processor and in order to handle ITRSs where defined symbols like + oc- cur on non-increasing

Since arbitrary techniques can be applied to search for reduction pairs required in the function exist(G, O), an obvious option is to use polynomial interpre- tations, one of the

More precisely, there is no reduction pair based on polynomial interpretations (or on any other classical order amenable to automation) where one of the DPs (7) and (9) is

Since we consider only definite logic programs, any program which is terminating without occur check is also terminating with occur check, but not vice versa. So if our approach

The dependency pair technique is a powerful modular method for automated termination proofs of term rewrite systems (TRSs).. We present two important extensions of this