decision procedures for recursive data structures

Upload: andreas-sander

Post on 30-May-2018

228 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 Decision Procedures for Recursive Data Structures

    1/96

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Decision Procedures for Recursive Data Structures

    Andreas Sander

    Decision Procedures for Logical Theories, SS 2010

    16.06.2010

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    2/96

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Motivation

    Intuition

    A recursive data structure is (partially) composed of smaller orsimpler instances of the same structure.

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    3/96

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Motivation

    Intuition

    A recursive data structure is (partially) composed of smaller orsimpler instances of the same structure.

    Example: cons(1,cons(2,cons(3,nil)))

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    4/96

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Motivation

    Intuition

    A recursive data structure is (partially) composed of smaller orsimpler instances of the same structure.

    Example: cons(1,cons(2,cons(3,nil)))

    Main Goal

    The main goal is to define decision procedures for recursive data

    structures.

    M i i P bl O li Th R i D S Th I d Th

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    5/96

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Motivation

    Intuition

    A recursive data structure is (partially) composed of smaller orsimpler instances of the same structure.

    Example: cons(1,cons(2,cons(3,nil)))

    Main Goal

    The main goal is to define decision procedures for recursive data

    structures.Whats about:|cons(1,cons(2,cons(3,nil)))| > 3 ?

    M ti ti P bl O tli Th t t R i D t St t Th I t t d Th

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    6/96

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Problem-OutlineWhat we have and what we want

    Theory of recursive data structures Th(A)

    Motivation Problem Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    7/96

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Problem-OutlineWhat we have and what we want

    Theory of recursive data structures Th(A)

    Presburger Arithmetic Th(AZ)

    Motivation Problem Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    8/96

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Problem-OutlineWhat we have and what we want

    Theory of recursive data structures Th(A)

    Presburger Arithmetic Th(AZ)

    Length Function

    |.| : Z

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    9/96

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Problem-OutlineWhat we have and what we want

    Theory of recursive data structures Th(A)

    Presburger Arithmetic Th(AZ)

    Length Function

    |.| : Z

    GoalGet a decision procedure for the combination of Th( A), Th(AZ)and |.| : Z

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    10/96

    Motivation Problem Outline The structures Recursive Data Structures The Integrated Theory

    Problem-OutlineApplicability of Nelson & Oppen

    We want to combine this with Nelsons and Oppens method:

    Theory of recursive data structures Th(A)

    Presburger Arithmetic Th(AZ)

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    11/96

    g y

    Problem-OutlineApplicability of Nelson & Oppen

    We want to combine this with Nelsons and Oppens method:

    Theory of recursive data structures Th(A)

    Presburger Arithmetic Th(AZ)

    Length Function|.| : Z

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    12/96

    g y

    Problem-OutlineApplicability of Nelson & Oppen

    We want can not combine this with Nelsons and Oppens method:

    Theory of recursive data structures Th(A)

    Presburger Arithmetic Th(AZ)

    Length Function|.| : Z

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    13/96

    g y

    Problem-OutlineThe Solution

    Solution

    Extension of Nelsons and Oppens original method!

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    14/96

    Problem-OutlineThe Solution

    Solution

    Extension of Nelsons and Oppens original method!

    Overview of this talk:

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    15/96

    Problem-OutlineThe Solution

    Solution

    Extension of Nelsons and Oppens original method!

    Overview of this talk:

    Presburger Arithmetic

    Decision Procedure

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    16/96

    Problem-OutlineThe Solution

    Solution

    Extension of Nelsons and Oppens original method!

    Overview of this talk:

    Presburger Arithmetic

    Decision Procedure

    Theory of recursive data structure

    Decision Procedure

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    17/96

    Problem-OutlineThe Solution

    Solution

    Extension of Nelsons and Oppens original method!

    Overview of this talk:

    Presburger Arithmetic

    Decision Procedure

    Theory of recursive data structure

    Decision ProcedureExtension of Nelsons and Oppens method in the presence oflength |.|

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    18/96

    Presburger Arithmetic

    first-order theory

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    19/96

    Presburger Arithmetic

    first-order theory

    corresponding structure AZ : Z; 0, s,+,,

  • 8/9/2019 Decision Procedures for Recursive Data Structures

    20/96

    Presburger Arithmetic

    first-order theory

    corresponding structure AZ : Z; 0, s,+,,

  • 8/9/2019 Decision Procedures for Recursive Data Structures

    21/96

    Presburger Arithmetic

    first-order theory

    corresponding structure AZ : Z; 0, s,+,,

  • 8/9/2019 Decision Procedures for Recursive Data Structures

    22/96

    Presburger Arithmetic

    first-order theory

    corresponding structure AZ : Z; 0, s,+,,

  • 8/9/2019 Decision Procedures for Recursive Data Structures

    23/96

    Presburger Arithmetic

    first-order theory

    corresponding structure AZ : Z; 0, s,+,,

  • 8/9/2019 Decision Procedures for Recursive Data Structures

    24/96

    Presburger Arithmetic

    first-order theory

    corresponding structure AZ : Z; 0, s,+,,

  • 8/9/2019 Decision Procedures for Recursive Data Structures

    25/96

    Presburger Arithmetic

    first-order theory

    corresponding structure AZ : Z; 0, s,+,,

  • 8/9/2019 Decision Procedures for Recursive Data Structures

    26/96

    Presburger Arithmetic

    first-order theory

    corresponding structure AZ : Z; 0, s,+,,

  • 8/9/2019 Decision Procedures for Recursive Data Structures

    27/96

    Recursive Data Structures

    A : ; A, C,S, T consists of

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    28/96

    Recursive Data Structures

    A : ; A, C,S, T consists of

    a data domain

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    29/96

    Recursive Data Structures

    A : ; A, C,S, T consists of

    a data domain

    a set of atoms A (e.g. A = {a, b, c,...})

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    30/96

    Recursive Data Structures

    A : ; A, C,S, T consists of

    a data domain

    a set of atoms A (e.g. A = {a, b, c,...})

    a finite set of constructors C (e.g. C = {,,,...})

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    31/96

    Recursive Data Structures

    A : ; A, C,S, T consists of

    a data domain

    a set of atoms A (e.g. A = {a, b, c,...})

    a finite set of constructors C (e.g. C = {,,,...})

    a finite set of selectors S (e.g. if has arity k > 0:

    {s1 , ..., sk } S)

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    32/96

    Recursive Data Structures

    A : ; A, C,S, T consists of

    a data domain

    a set of atoms A (e.g. A = {a, b, c,...})

    a finite set of constructors C (e.g. C = {,,,...})

    a finite set of selectors S (e.g. if has arity k > 0:

    {s1 , ..., sk } S)

    a finite set of testers T (e.g. Is(x) is true iff x is an -term.)

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    A f A A (LISP l )

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    33/96

    Axiomatization ofA = AList (LISP list structure)

    A Example AList

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    A i i i f A A (LISP li )

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    34/96

    Axiomatization ofA = AList (LISP list structure)

    A Example AListt(x) = x cons (x, y) = x

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    A i i i f A A (LISP li )

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    35/96

    Axiomatization ofA = AList (LISP list structure)

    A Example AList

    a = (x1, ...,xar()) a = cons(x, y)

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    A i ti ti f A A (LISP li t t t )

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    36/96

    Axiomatization ofA = AList (LISP list structure)

    A Example AList

    (x1, ..., xar()) = (y1, ..., yar()) cons(x, y) = cons(z, t)

    1iar() xi = yi x = z y = t

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    A i ti ti f A A (LISP li t t t )

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    37/96

    Axiomatization ofA = AList (LISP list structure)

    A Example AList

    IsA(x) C Is(x) IsA(x) Iscons(x)

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Axiomatization of A A (LISP list structure)

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    38/96

    Axiomatization ofA = AList (LISP list structure)

    A Example AList

    si

    (x) = y z((z) = x y = zi) cdr(cons(x, y)) = y(z((z) = x) x = y) IsA(x) {car, cdr}+(x) = x

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    39/96

    Goal

    Check satisfiability of

    q1 = r1 ... qk = rk s1 = t1 ... sl = tl

    in Th(A).

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    40/96

    Goal

    Check satisfiability of

    q1 = r1 ... qk = rk s1 = t1 ... sl = tl

    in Th(A).

    Idea

    Use a Directed Acyclic Graph (DAG) for those formulae.

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Term Representation

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    41/96

    Term-Representation

    Term t can be represented by a tree Tt, s.t.

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Term-Representation

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    42/96

    Term-Representation

    Term t can be represented by a tree Tt, s.t.

    1 If t is a constant, Tt is a leaf vertex (labeld by t)

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Term-Representation

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    43/96

    Term-Representation

    Term t can be represented by a tree Tt, s.t.

    1 If t is a constant, Tt is a leaf vertex (labeld by t)

    2 If t = (t1, ..., tk), then Tt is a tree (root labeled by t),having Tt1, ...,Ttk as its subtrees (ordered).

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Term-Representation

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    44/96

    Term Representation

    Term t can be represented by a tree Tt, s.t.

    1 If t is a constant, Tt is a leaf vertex (labeld by t)

    2 If t = (t1, ..., tk), then Tt is a tree (root labeled by t),having Tt1, ...,Ttk as its subtrees (ordered).

    A directed acyclic graph (DAG) Gt of t obtained from Tt byfactoring out common subtrees.

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    45/96

    Goal

    Check satisfiability of

    q1 = r1 ... qk = rk s1 = t1 ... sl = tl

    in Th(A).

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    46/96

    Goal

    Check satisfiability of

    q1 = r1 ... qk = rk s1 = t1 ... sl = tl

    in Th(A).

    Idea

    Use a Directed Acyclic Graph (DAG) for those formulae.

    1 Add (qi, ri)(i {1,...k}) to an equivalence relation R on

    vertices2 Close R under congruences and unification.

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Groundwork

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    47/96

    Groundwork

    G = (V,E) a DAG (with ordered edges).

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Groundwork

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    48/96

    G = (V,E) a DAG (with ordered edges).

    Let be u V

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Groundwork

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    49/96

    G = (V,E) a DAG (with ordered edges).

    Let be u V

    outdegree (u)

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Groundwork

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    50/96

    G = (V,E) a DAG (with ordered edges).

    Let be u V

    outdegree (u)

    the ith successor u[i] (i [0; (u)])

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Groundwork

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    51/96

    G = (V,E) a DAG (with ordered edges).

    Let be u V

    outdegree (u)

    the ith successor u[i] (i [0; (u)])

    R is an equivalence relation on the vertices of G.

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Bidirectional Closure vs. Congruence Closure

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    52/96

    Bidirectional Closure instead of Congruence Closure [Oppen 1980]

    For the following decision procedures we will use the bidirectional

    closure, instead of the congruence closure!

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Bidirectional Closure vs. Congruence Closure

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    53/96

    Bidirectional Closure instead of Congruence Closure [Oppen 1980]

    For the following decision procedures we will use the bidirectional

    closure, instead of the congruence closure!

    Idea

    cons(x, y) = cons(z, t) x = z y = t

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    The Congruence Closure R

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    54/96

    R is the unique minimal extension of R with the followingproperties:

    R is an equivalence relation

    Two vertices u,v with equal (nonzero) outdegree:

    (u, v) R

    (u[i], v[i]) R i [1; (u)]

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    The Unification Closure R

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    55/96

    R is the unique minimal extension of R with the followingproperties:

    R is an equivalence relation

    Two vertices u,v with equal (nonzero) outdegree:

    (u, v) R

    (u[i], v[i]) R i [1; (u)]

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    The Bidirectional Closure R

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    56/96

    Theorem [Oppen 1980]

    R is the unique minimal extension of R with the followingproperties:

    R is an equivalence relation

    Two vertices u,v with equal (nonzero) outdegree:

    (u, v) R

    (u[i], v[i]) R i [1; (u)]

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Oppens Decision Procedure for acyclic A

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    57/96

    Input: : q1 = r1 ... qk = rk s1 = t1 ... sl = tl

    Task: Check satisfiability of

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Oppens Decision Procedure for acyclic A

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    58/96

    Input: : q1 = r1 ... qk = rk s1 = t1 ... sl = tl

    Task: Check satisfiability of

    Algorithm 11 Step 1: Construct the DAG G of

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Oppens Decision Procedure for acyclic A

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    59/96

    Input: : q1 = r1 ... qk = rk s1 = t1 ... sl = tl

    Task: Check satisfiability of

    Algorithm 11 Step 1: Construct the DAG G of

    2 Step 2: Compute R of R = {(qi, ri)|1 i k}.

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Oppens Decision Procedure for acyclic A

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    60/96

    Input: : q1 = r1 ... qk = rk s1 = t1 ... sl = tl

    Task: Check satisfiability of

    Algorithm 11 Step 1: Construct the DAG G of

    2 Step 2: Compute R of R = {(qi, ri)|1 i k}.

    3 Return UNSATISFIABLE if i(si, ti) R;

    Return SATISFIABLE otherwise.

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Problem for Cyclic Data Structures

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    61/96

    In our setting

    If x is NOT an -term, then si

    (x) = x

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Problem for Cyclic Data Structures

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    62/96

    In our setting

    If x is NOT an -term, then si

    (x) = x

    ComplicationWe dont know a priori wether s(x) is a proper subterm of x.

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Problem for Cyclic Data Structures

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    63/96

    In our setting

    If x is NOT an -term, then si

    (x) = x

    ComplicationWe dont know a priori wether s(x) is a proper subterm of x.

    Solution for Complication

    We have to guess the type of all terms occuring inside an selectorfunction before applying the algorithm.

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Oppens Decision Procedure for cyclic A

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    64/96

    Input : q1 = r1 ... qk = rk s1 = t1 ... sl = tl

    Task: Check satisfiability of

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Oppens Decision Procedure for cyclic A

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    65/96

    Input : q1 = r1 ... qk = rk s1 = t1 ... sl = tl

    Task: Check satisfiability of

    Algorithm 2

    1 Step 1:Guess a type completion

    of and simplify selectorterms accordingly.

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Oppens Decision Procedure for cyclic A

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    66/96

    Input : q1 = r1 ... qk = rk s1 = t1 ... sl = tl

    Task: Check satisfiability of

    Algorithm 2

    1 Step 1:Guess a type completion

    of and simplify selectorterms accordingly.

    2 Step 2: Call Algorithm 1 on

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Example Application of Algorithm 2

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    67/96

    Example

    cons(y,z) = cons(cdr(x),z) cons(car(x),y) = x

    Unification Closure

    (u, v) R

    (u[i], v[i]) Ri [1; (u)]

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    The Structure B

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    68/96

    Overview - Where Are We Now?

    Presburger Arithmetic

    Decision Procedure

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    The Structure B

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    69/96

    Overview - Where Are We Now?

    Presburger Arithmetic

    Decision Procedure

    Theory of recursive data structure

    Decision Procedure

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    The Structure B

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    70/96

    Overview - Where Are We Now?

    Presburger Arithmetic

    Decision Procedure

    Theory of recursive data structure

    Decision Procedure

    Extension of Nelsons and Oppens method in the presence oflength |.|

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    The Structure B

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    71/96

    Overview - Where Are We Now?

    Presburger Arithmetic

    Decision Procedure

    Theory of recursive data structure

    Decision Procedure

    Extension of Nelsons and Oppens method in the presence oflength |.|

    The Structure of the Integrated Theory

    B = (

    A;AZ; |.| :

    Z)

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    The Structure B

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    72/96

    Overview - Where Are We Now?

    Presburger Arithmetic

    Decision Procedure

    Theory of recursive data structure

    Decision Procedure

    Extension of Nelsons and Oppens method in the presence oflength |.|

    The Structure of the Integrated Theory

    B = (

    A;AZ; |.| :

    Z)

    For any atom a, |a| = 1

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    The Structure B

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    73/96

    Overview - Where Are We Now?

    Presburger Arithmetic

    Decision Procedure

    Theory of recursive data structure

    Decision Procedure

    Extension of Nelsons and Oppens method in the presence oflength |.|

    The Structure of the Integrated Theory

    B = (

    A;AZ; |.| :

    Z)

    For any atom a, |a| = 1

    For a term (t1, ..., tk), |(t1, ..., tk)| =

    k

    i=1 |ti|.

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Why not Nelson & Oppen?

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    74/96

    Why?

    We want can not combine this with Nelsons and Oppens method

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    75/96

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Why not Nelson & Oppen?

  • 8/9/2019 Decision Procedures for Recursive Data Structures

    76/96

    Why?

    We want can not combine this with Nelsons and Oppens method

    Consider BList,

    : x = cons(car(y),y) and Z :|x|

  • 8/9/2019 Decision Procedures for Recursive Data Structures

    77/96

    IdeaExplicitly compute the hidden constraints!

    Length constraint :

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Induced Length Constraint

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    78/96

    IdeaExplicitly compute the hidden constraints!

    Length constraint :

    is sound, if satisfying of , || is a satisfyingassignment for .

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Induced Length Constraint

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    79/96

    IdeaExplicitly compute the hidden constraints!

    Length constraint :

    is complete, if whenever is satisfiable, for any satisfyingassignment of there exists a satisfying assignment

    of s.t. || = .

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Induced Length Constraint

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    80/96

    IdeaExplicitly compute the hidden constraints!

    Length constraint :

    is induced by , if is sound & complete.

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Satisfiability ofB

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    81/96

    Main Theorem

    Let be in the form Z . Let be the induced lengthconstraint with respect to .

    is satisfiable in B

    Z is satisfiable in AZ and is satisfiable in A

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Predicates based on the DAG

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    82/96

    How to compute the induced length constraints?

    Tree(t) : x1, ..., xn 0 (|t| = (

    n

    i=1(di 1)xi) + 1)

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Predicates based on the DAG

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    83/96

    How to compute the induced length constraints?

    Tree(t) : x1, ..., xn 0 (|t| = (

    n

    i=1(di 1)xi) + 1)

    Node(t, t) : |t| =()

    i=1 |ti|

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Predicates based on the DAG

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    84/96

    How to compute the induced length constraints?

    Tree(t) : x1, ..., xn 0 (|t| = (

    n

    i=1(di 1)xi) + 1)

    Node(t, t) : |t| =()

    i=1 |ti|

    Tree(t) : t(Node(t, t) ()

    i=1 Tree(ti))

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Constructing Length Constraint

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    85/96

    Algorithm 3 (Construction of in B)

    Let be (type-complete) data constraint. G the DAG of andR bidirectional closure.

    From initial state = add the following

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Constructing Length Constraint

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    86/96

    Algorithm 3 (Construction of in B)

    Let be (type-complete) data constraint. G the DAG of andR bidirectional closure.

    From initial state = add the following

    |t| = 1 if t is an atom

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Constructing Length Constraint

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    87/96

    Algorithm 3 (Construction of in B)

    Let be (type-complete) data constraint. G the DAG of andR bidirectional closure.

    From initial state = add the following

    |t| = 1 if t is an atom

    |t| = |s|, if (t, s) R

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Constructing Length Constraint

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    88/96

    Algorithm 3 (Construction of in B)

    Let be (type-complete) data constraint. G the DAG of andR bidirectional closure.

    From initial state = add the following

    |t| = 1 if t is an atom

    |t| = |s|, if (t, s) R

    Tree(t) if t is an untyped leaf vertex.

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Constructing Length Constraint

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    89/96

    Algorithm 3 (Construction of in B)Let be (type-complete) data constraint. G the DAG of andR bidirectional closure.

    From initial state = add the following

    |t| = 1 if t is an atom

    |t| = |s|, if (t, s) R

    Tree(t) if t is an untyped leaf vertex.

    Node

    (t, t) if t is an -typed vertex with children t

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Constructing Length Constraint

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    90/96

    Algorithm 3 (Construction of in B)Let be (type-complete) data constraint. G the DAG of andR bidirectional closure.

    From initial state = add the following

    |t| = 1 if t is an atom

    |t| = |s|, if (t, s) R

    Tree(t) if t is an untyped leaf vertex.

    Node

    (t, t) if t is an -typed vertex with children t

    Tree(t) if t is an -typed leaf vertex.

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Some Deductions

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    91/96

    Proposition 2

    obtained by Algorithm 3 is expressible in a quantifier-freePresburger formula linear in the size of .

    Theorem 1

    obtained by Algorithm 3 is the induced length constraint of .

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Decision Procedure for a Quantifier-Free B

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    92/96

    Input: Z.

    1 Guess a type completion

    of .

    2

    Call Algorithm 1 on

    .Return FAIL if

    is unsatisfiable; continue otherwise.

    3 Construct from G

    using Algorithm 3.

    Return SUCCESS if is satisfiable and Z is satisifiable.

    Return FAIL otherwise.

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Example Application of Algorithm 4

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    93/96

    Example

    x = cons(car(y),y) |cons(car(y),y)| < 2|car(x)|.

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Some Final Remarks

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    94/96

    In Theories were quantifiers (,) occurs, we can usequantifier-elimination to get rid of the quantifiers!

    Application on theories with finite number of atoms is alsopossible, but its far more complicated!

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    95/96

    Thank you for your attention!

    Motivation Problem-Outline The structures Recursive Data Structures The Integrated Theory

    Literature

    http://find/http://goback/
  • 8/9/2019 Decision Procedures for Recursive Data Structures

    96/96

    Zhang, T.; Sipma H.B.; Manna,Z.:

    Decision Procedures for Recursive Data Structures with

    Integer Constraints.Springer-Verlag, 2004.

    Oppen,D.C:

    Reasoning About Recursively Defined Data Structures.Journal of the Association for Computing Machinery (Vol. 27),1980

    Nelson,G; Oppen, D.C:

    Fast Decision Procedures Based on CongruenceClosure.Journal of the Association for Computing Machinery (Vol. 27),1980

    http://find/http://goback/