Ranking Templates for Linear Loops Jan Leike Matthias Heizmann The - - PowerPoint PPT Presentation

ranking templates for linear loops
SMART_READER_LITE
LIVE PREVIEW

Ranking Templates for Linear Loops Jan Leike Matthias Heizmann The - - PowerPoint PPT Presentation

Ranking Templates for Linear Loops Jan Leike Matthias Heizmann The Australian University National University of Freiburg Termination safety reduced to reachability - liveness reduced to termination Termination safety reduced to


slide-1
SLIDE 1

Ranking Templates for Linear Loops

Jan Leike Matthias Heizmann

The Australian National University University

  • f Freiburg
slide-2
SLIDE 2

Termination

◮ safety reduced to reachability - liveness reduced to termination

slide-3
SLIDE 3

Termination

◮ safety reduced to reachability - liveness reduced to termination ◮ neither provable nor refutable by testing

slide-4
SLIDE 4

Termination

◮ safety reduced to reachability - liveness reduced to termination ◮ neither provable nor refutable by testing ◮ computing fixpoint on sets of states does not work

slide-5
SLIDE 5

Termination

◮ safety reduced to reachability - liveness reduced to termination ◮ neither provable nor refutable by testing ◮ computing fixpoint on sets of states does not work ◮ ranking function (decreasing, bounded, contradiction!)

slide-6
SLIDE 6

Research directions

  • 1. practical tools for termination analysis

Urban, Min´ e An Abstract Domain to Infer Ordinal-Valued Ranking Functions (ESOP 2014) Brockschmidt, Cook, Fuhs Better Termination Proving through Cooperation (CAV 2013) Kroening, Sharygina, Tsitovich, Wintersteiger Termination analysis with compositional transition invariants (CAV 2010) Cook, B., Podelski, A., Rybalchenko, A. Terminator: Beyond safety (CAV 2006)

...

  • 2. decidability of terminaton for restricted classes of programs

Ben-Amram, Genaim Ranking functions for linear-constraint loops (POPL 2013) Ben-Amram, Genaim, Masud On the Termination of Integer Loops (VMCAI 2012) Tiwari Termination of Linear Programs (CAV 2004)

...

  • 3. constraint-based synthesis of ranking functions for loops

Cook, Kroening, R¨ ummer, Wintersteiger Ranking function synthesis for bit-vector relations (FMSD 2013) Rybalchenko Constraint solving for program verification theory and practice by example (CAV 2010) Col´

  • n, Sankaranarayanan, Sipma

Linear invariant generation using non-linear constraint solving (CAV 2003)

...

slide-7
SLIDE 7

Ranking functions for loops - applications

◮ termination analysis for programs

◮ Terminator (Cook, Rybalchenko, et al.) ◮ T2 (Brockschmidt, et al.) ◮ Tan (Chen, Kroening, Wintersteiger, et al.) ◮ Ultimate B¨

uchi Automizer (H. et al.)

slide-8
SLIDE 8

Ranking functions for loops - applications

◮ termination analysis for programs

◮ Terminator (Cook, Rybalchenko, et al.) ◮ T2 (Brockschmidt, et al.) ◮ Tan (Chen, Kroening, Wintersteiger, et al.) ◮ Ultimate B¨

uchi Automizer (H. et al.)

◮ cost analysis ◮ stability of hybrid systems

slide-9
SLIDE 9

◮ affine-linear ranking functions

Col´

  • n, Sipma

Synthesis of Linear Ranking Functions (TACAS 2001) Podelski, Rybalchenko A complete method for the synthesis of linear ranking functions (VMCAI 2004) Bradley, Manna, Sipma Termination Analysis of Integer Linear Loops (CONCUR 2005) Cook, Kroening, R¨ ummer, Wintersteiger Ranking function synthesis for bit-vector relations (FMSD 2013) Ben-Amram, Genaim Ranking functions for linear-constraint loops (POPL 2013)

slide-10
SLIDE 10

◮ affine-linear ranking functions

Col´

  • n, Sipma

Synthesis of Linear Ranking Functions (TACAS 2001) Podelski, Rybalchenko A complete method for the synthesis of linear ranking functions (VMCAI 2004) Bradley, Manna, Sipma Termination Analysis of Integer Linear Loops (CONCUR 2005) Cook, Kroening, R¨ ummer, Wintersteiger Ranking function synthesis for bit-vector relations (FMSD 2013) Ben-Amram, Genaim Ranking functions for linear-constraint loops (POPL 2013)

◮ lexicographic linear ranking functions

Bradley, Manna, Sipma Linear ranking with reachability (CAV 2005) Alias, Darte, Feautrier, Gonnord Multi-dimensional Rankings, Program Termination, and Complexity Bounds

  • f Flowchart Programs

(SAS 2010) Cook, See, Zuleger Ramsey vs. Lexicographic Termination Proving (TACAS 2013)

slide-11
SLIDE 11

◮ affine-linear ranking functions

Col´

  • n, Sipma

Synthesis of Linear Ranking Functions (TACAS 2001) Podelski, Rybalchenko A complete method for the synthesis of linear ranking functions (VMCAI 2004) Bradley, Manna, Sipma Termination Analysis of Integer Linear Loops (CONCUR 2005) Cook, Kroening, R¨ ummer, Wintersteiger Ranking function synthesis for bit-vector relations (FMSD 2013) Ben-Amram, Genaim Ranking functions for linear-constraint loops (POPL 2013)

◮ lexicographic linear ranking functions

Bradley, Manna, Sipma Linear ranking with reachability (CAV 2005) Alias, Darte, Feautrier, Gonnord Multi-dimensional Rankings, Program Termination, and Complexity Bounds

  • f Flowchart Programs

(SAS 2010) Cook, See, Zuleger Ramsey vs. Lexicographic Termination Proving (TACAS 2013)

◮ piecewise linear ranking functions

Urban, Min´ e An Abstract Domain to Infer Ordinal-Valued Ranking Functions (ESOP 2014)

slide-12
SLIDE 12

◮ affine-linear ranking functions

Col´

  • n, Sipma

Synthesis of Linear Ranking Functions (TACAS 2001) Podelski, Rybalchenko A complete method for the synthesis of linear ranking functions (VMCAI 2004) Bradley, Manna, Sipma Termination Analysis of Integer Linear Loops (CONCUR 2005) Cook, Kroening, R¨ ummer, Wintersteiger Ranking function synthesis for bit-vector relations (FMSD 2013) Ben-Amram, Genaim Ranking functions for linear-constraint loops (POPL 2013)

◮ lexicographic linear ranking functions

Bradley, Manna, Sipma Linear ranking with reachability (CAV 2005) Alias, Darte, Feautrier, Gonnord Multi-dimensional Rankings, Program Termination, and Complexity Bounds

  • f Flowchart Programs

(SAS 2010) Cook, See, Zuleger Ramsey vs. Lexicographic Termination Proving (TACAS 2013)

◮ piecewise linear ranking functions

Urban, Min´ e An Abstract Domain to Infer Ordinal-Valued Ranking Functions (ESOP 2014)

◮ multiphase ranking functions

Bradley, Manna, Sipma The polyranking principle (ICALP 2005)

slide-13
SLIDE 13
  • ne method to synthesize them all
slide-14
SLIDE 14

Ranking function

Loop(x, x’)

slide-15
SLIDE 15

Ranking function

∀ ∀ ∀xx’. Loop(x, x’) → f(x) > f(x’) decreasing ∧ f(x) > 0 bounded

slide-16
SLIDE 16

Synthesis of ranking function

∀ ∀ ∀xx’. Loop(x, x’) → f(x) > f(x’) decreasing ∧ f(x) > 0 bounded Idea:

◮ write definition as logical formula, ◮ let theorem prover find satisfying assignment for free variables

slide-17
SLIDE 17

Synthesis of ranking function

∀ ∀ ∀xx’. Loop(x, x’) → f(x) > f(x’) decreasing ∧ f(x) > 0 bounded Idea:

◮ write definition as logical formula, ◮ let theorem prover find satisfying assignment for free variables

Problem:

◮ no theorem prover for domain of functions

Solution:

◮ use template T(x, x’)

slide-18
SLIDE 18

Synthesis of ranking function

∀ ∀ ∀xx’. Loop(x, x’) →

T(x, x’)

Idea:

◮ write definition as logical formula, ◮ let theorem prover find satisfying assignment for free variables

Problem:

◮ no theorem prover for domain of functions

Solution:

◮ use template T(x, x’)

slide-19
SLIDE 19

Synthesis of affine-linear ranking function

∀ ∀ ∀xx’. Loop(x, x’) → T(x, x’) where the template T(x, x’) is f (x) > f (x’) decreasing ∧ f (x) > 0 bounded and f (x) is a shorthand for the affine-linear term c1 · x1 + · · · + cn · x1 + c0

slide-20
SLIDE 20

Synthesis of affine-linear ranking function

∀ ∀ ∀xx’. Loop(x, x’) → T(x, x’) where the template T(x, x’) is f (x) > f (x’) decreasing ∧ f (x) > 0 bounded and f (x) is a shorthand for the affine-linear term c1 · x1 + · · · + cn · x1 + c0 Difficult!

◮ universal quantification (∀

∀ ∀x ... )

◮ nonlinear arithmetic (c1 · x1 ... )

slide-21
SLIDE 21

Synthesis of affine-linear ranking function

∀ ∀ ∀xx’. Loop(x, x’) → T(x, x’) where the template T(x, x’) is f (x) > f (x’) decreasing ∧ f (x) > 0 bounded and f (x) is a shorthand for the affine-linear term c1 · x1 + · · · + cn · x1 + c0 Difficult!

◮ universal quantification (∀

∀ ∀x ... )

◮ nonlinear arithmetic (c1 · x1 ... )

Lemma (Farkas)

∀x. (... → ...) iff ∃ λ (...)

slide-22
SLIDE 22

Synthesis of affine-linear ranking function

∀ ∀ ∀xx’. Loop(x, x’) → T(x, x’) where the template T(x, x’) is f (x) > f (x’) decreasing ∧ f (x) > 0 bounded and f (x) is a shorthand for the affine-linear term c1 · x1 + · · · + cn · x1 + c0 Difficult!

◮ universal quantification (∀

∀ ∀x ... )

◮ nonlinear arithmetic (c1 · x1 ... )

Lemma (Farkas)

∀x. (... → ...) iff ∃ λ (...)

Col´

  • n, Sipma

Synthesis of Linear Ranking Functions (TACAS 2001)

slide-23
SLIDE 23

Lexicographic ranking function

Lexicographic ranking function program state → lexicographic ordered tuple Lexicographic order: e.g. (2, 3, 4) ≥ (2, 2, 9)

slide-24
SLIDE 24

Lexicographic ranking function

Lexicographic ranking function program state → lexicographic ordered tuple Lexicographic order: e.g. (2, 3, 4) ≥ (2, 2, 9) Linear lexicographic ranking function each entry of the tuple defined by linear function f(x) = ( f1(x), . . . , fk(x) )

slide-25
SLIDE 25

Lexicographic ranking function

Lexicographic ranking function program state → lexicographic ordered tuple Lexicographic order: e.g. (2, 3, 4) ≥ (2, 2, 9) Linear lexicographic ranking function each entry of the tuple defined by linear function f(x) = ( f1(x), . . . , fk(x) ) Recall: Idea:

◮ write definition as logical formula, ◮ let theorem prover find satisfying assignment for free variables

slide-26
SLIDE 26

Linear lexicographic ranking functions

T(x, x’) :=

f1(x) ≥ 0 f1 bounded ∧ f2(x’) ≥ 0 f2 bounded ∧

  • f1(x) > f1(x’)

f1 decreasing ∨ f1(x) ≥ f1(x’) f1 not increasing ∧ f2(x) > f2(x’) f2 decreasing

slide-27
SLIDE 27

Linear lexicographic ranking functions

T(x, x’) :=

f1(x) ≥ 0 f1 bounded ∧ f2(x’) ≥ 0 f2 bounded ∧

  • f1(x) > f1(x’)

f1 decreasing ∨ f1(x) ≥ f1(x’) f1 not increasing ∧ f2(x) > f2(x’) f2 decreasing

  • each f(x) is a shorthand for an affine-linear term c1 · x1 + · · · + cn · x1 + c0
slide-28
SLIDE 28

Linear lexicographic ranking functions

T(x, x’) :=

f1(x) ≥ 0 f1 bounded ∧ f2(x’) ≥ 0 f2 bounded ∧

  • f1(x) > f1(x’)

f1 decreasing ∨ f1(x) ≥ f1(x’) f1 not increasing ∧ f2(x) > f2(x’) f2 decreasing

∀ ∀xx’. Loop(x, x’) → T(x, x’)

slide-29
SLIDE 29

Linear lexicographic ranking functions

T(x, x’) :=

f1(x) ≥ 0 f1 bounded ∧ f2(x’) ≥ 0 f2 bounded ∧

  • f1(x) > f1(x’)

f1 decreasing ∨ f1(x) ≥ f1(x’) f1 not increasing ∧ f2(x) > f2(x’) f2 decreasing

∀ ∀xx’. Loop(x, x’) → T(x, x’)

Lemma (Farkas)

∀x. (... → ...) iff ∃ λ (...)

slide-30
SLIDE 30

Linear lexicographic ranking functions

T(x, x’) :=

f1(x) ≥ 0 f1 bounded ∧ f2(x’) ≥ 0 f2 bounded ∧

  • f1(x) > f1(x’)

f1 decreasing ∨ f1(x) ≥ f1(x’) f1 not increasing ∧ f2(x) > f2(x’) f2 decreasing

∀ ∀xx’. Loop(x, x’) → T(x, x’)

Lemma (Farkas)

∀x. (... → ...) iff ∃ λ (...)

Theorem (Motzkin)

∀x. ¬( ... ≤ ... ∧ ... < ... ) iff ∃ λ (...)

slide-31
SLIDE 31

Ranking Template

∀ ∀ ∀xx’. Loop(x, x’) → T(x, x’)

◮ “building blocks” linear functions f (x) = c1 · x1 + · · · + cn · x1 + c0

slide-32
SLIDE 32

Ranking Template

∀ ∀ ∀xx’. Loop(x, x’) → T(x, x’)

◮ “building blocks” linear functions f (x) = c1 · x1 + · · · + cn · x1 + c0 ◮ boolean combinations of linear inequalities (Motzkin applicable)

slide-33
SLIDE 33

Ranking Template

∀ ∀ ∀xx’. Loop(x, x’) → T(x, x’)

◮ “building blocks” linear functions f (x) = c1 · x1 + · · · + cn · x1 + c0 ◮ boolean combinations of linear inequalities (Motzkin applicable) ◮ well-founded

slide-34
SLIDE 34

Ranking Template

∀ ∀ ∀xx’. Loop(x, x’) → T(x, x’)

◮ “building blocks” linear functions f (x) = c1 · x1 + · · · + cn · x1 + c0 ◮ boolean combinations of linear inequalities (Motzkin applicable) ◮ well-founded

Definition (Linear ranking template)

A linear ranking template T(x, x’) is a

◮ boolean combination whose atoms are of the following form

  • f∈F

αf · f(x) + βf · f(x’) ⊲ 0 , where each f(x) is an affine-linear term c1 · x1 + · · · + cn · x1 + c0, each αf, and βf is a constant and ⊲ ∈ {≥, >}.

◮ such that each instance of T(x, x’) defines a well-founded relation.

slide-35
SLIDE 35

◮ affine-linear ranking function

template Taffine(x, x’)

Lemma

the template Taffine(x, x’) is a linear ranking template.

◮ linear lexicographic ranking function

k-lexicographic template Tk-lex(x, x’)

Lemma

the template Tk-lex(x, x’) is a linear ranking template, for each k

◮ piecewise linear ranking function

k-piece template Tk-piece(x, x’)

Lemma

the template Tk-piece(x, x’) is a linear ranking template, for each k

◮ multiphase linear ranking function

k-phase template Tk-phase(x, x’)

Lemma

the template Tk-phase(x, x’) is a linear ranking template, for each k

slide-36
SLIDE 36

Why has no one used this method before?

Our explanation: recent progress in solving nonlinear arithmetic

Jovanovic,Moura Solving non-linear arithmetic (IJCAR 2012)

SMT solver Z3 http://z3.codeplex.com/

slide-37
SLIDE 37

Our tool: LassoRanker

http://ultimate.informatik.uni-freiburg.de/LassoRanker/

slide-38
SLIDE 38

New kind of ranking function?

You can synthesize your new ranking function automatically in three steps.

◮ write down a template T(x, x’) for this ranking function ◮ prove that each instance of T(x, x’) is a well-founded relation ◮ add template T(x, x’) to our tool LassoRanker