SAT Solvers for Queries over Tree Automata with Constraints - - PowerPoint PPT Presentation

sat solvers for queries over tree automata with
SMART_READER_LITE
LIVE PREVIEW

SAT Solvers for Queries over Tree Automata with Constraints - - PowerPoint PPT Presentation

The SAT encoding Implementation and Experiments SAT Solvers for Queries over Tree Automata with Constraints Pierre-Cyrille Ham, Vincent Hugot, Olga Kouchnarenko {pcheam,okouchnarenko}@lifc.univ-fcomte.fr, vhugot@edu.univ-fcomte.fr


slide-1
SLIDE 1

The SAT encoding Implementation and Experiments

SAT Solvers for Queries over Tree Automata with Constraints

Pierre-Cyrille Héam, Vincent Hugot, Olga Kouchnarenko

{pcheam,okouchnarenko}@lifc.univ-fcomte.fr, vhugot@edu.univ-fcomte.fr

Université de Franche-Comté LIFC-INRIA/CASSIS

April 8, 2010

1/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-2
SLIDE 2

The SAT encoding Implementation and Experiments

Plan of the talk

1

Motivating XML example

2/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-3
SLIDE 3

The SAT encoding Implementation and Experiments

Plan of the talk

1

Motivating XML example

2

Introduction of notions:

1

Tree Automata

2

TAGEDs

3

SAT problem

2/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-4
SLIDE 4

The SAT encoding Implementation and Experiments

Plan of the talk

1

Motivating XML example

2

Introduction of notions:

1

Tree Automata

2

TAGEDs

3

SAT problem

3

Main contribution: SAT encoding for TAGED Uniform Membership Problem

2/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-5
SLIDE 5

The SAT encoding Implementation and Experiments

Plan of the talk

1

Motivating XML example

2

Introduction of notions:

1

Tree Automata

2

TAGEDs

3

SAT problem

3

Main contribution: SAT encoding for TAGED Uniform Membership Problem

4

Some experimental results:

1

Natural optimisations

2

The prototype

3

Conversion to CNF

2/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-6
SLIDE 6

The SAT encoding Implementation and Experiments

Plan of the talk

1

Motivating XML example

2

Introduction of notions:

1

Tree Automata

2

TAGEDs

3

SAT problem

3

Main contribution: SAT encoding for TAGED Uniform Membership Problem

4

Some experimental results:

1

Natural optimisations

2

The prototype

3

Conversion to CNF

5

Conclusion.

2/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-7
SLIDE 7

The SAT encoding Implementation and Experiments

A small example

Laboratory toy example

<university> <team> <member> Scotty </member> <member> Spock </member> <member> Uhura </member> <laboratory> Enterprise </laboratory> </team> <team> <member> McCoy </member> <member> Spock </member> <laboratory> Enterprise </laboratory> </team> </university>

Objective: check that all teams belong to the same laboratory and no researcher is affected to two different teams.

3/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-8
SLIDE 8

The SAT encoding Implementation and Experiments

A small example

Laboratory toy example

<university> <team> <member> Scotty </member> <member> Spock </member> <member> Uhura </member> <laboratory> Enterprise </laboratory> </team> <team> <member> McCoy </member> <member> Spock </member> <laboratory> Enterprise </laboratory> </team> </university>

Objective: check that all teams belong to the same laboratory and no researcher is affected to two different teams.

3/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-9
SLIDE 9

The SAT encoding Implementation and Experiments

A small example

Laboratory toy example

<university> <team> <member> Scotty </member> <member> Spock </member> <member> Uhura </member> <laboratory> Enterprise </laboratory> </team> <team> <member> McCoy </member> <member> Spock </member> <laboratory> Enterprise </laboratory> </team> </university>

Objective: check that all teams belong to the same laboratory and no researcher is affected to two different teams.

3/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-10
SLIDE 10

The SAT encoding Implementation and Experiments

Tree automata

Definition through an example

Tree automaton for True propositional formulæ A def =

Σ = { ∧, ∨/2, ¬/1, 0, 1/0 } , Q = { q0, q1 } , F = { q1 } , ∆

  • ∆ = {b → qb,

∧ (qb, qb′) → qb∧b′, ∨ (qb, qb′) → qb∨b′, ¬(qb) → q¬b | b, b′ ∈ 0, 1}

4/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-11
SLIDE 11

The SAT encoding Implementation and Experiments

Tree automata

Definition through an example

∧ ¬ ∧ 0 1 ∨ 0 ¬

5/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-12
SLIDE 12

The SAT encoding Implementation and Experiments

Tree automata

Definition through an example

0 → q0, 1 → q1 ∈ ∆ ∧ ¬ ∧ 0 1 ∨ 0 ¬ →∗

A

∧ ¬ ∧ q0 q1 ∨ q0 ¬ q0

5/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-13
SLIDE 13

The SAT encoding Implementation and Experiments

Tree automata

Definition through an example

∧(q0, q1) → q0, ¬(q0) → q1 ∈ ∆ ∧ ¬ ∧ 0 1 ∨ 0 ¬ →∗

A

∧ ¬ ∧ q0 q1 ∨ q0 ¬ q0 →∗

A

∧ ¬ q0 ∨ q0 q1

5/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-14
SLIDE 14

The SAT encoding Implementation and Experiments

Tree automata

Definition through an example

¬(q0) → q1, ∨(q0, q1) → q1 ∈ ∆ ∧ ¬ ∧ 0 1 ∨ 0 ¬ →∗

A

∧ ¬ ∧ q0 q1 ∨ q0 ¬ q0 →∗

A

∧ ¬ q0 ∨ q0 q1 →∗

A

∧ q1 q1

5/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-15
SLIDE 15

The SAT encoding Implementation and Experiments

Tree automata

Definition through an example

∧(q1, q1) → q1 ∈ ∆ ∧ ¬ ∧ 0 1 ∨ 0 ¬ →∗

A

∧ ¬ ∧ q0 q1 ∨ q0 ¬ q0 →∗

A

∧ ¬ q0 ∨ q0 q1 →∗

A

∧ q1 q1 →A q1

5/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-16
SLIDE 16

The SAT encoding Implementation and Experiments

Tree automata

Definition through an example

∧ ¬ ∧ 0 1 ∨ 0 ¬ →∗

A

∧ ¬ ∧ q0 q1 ∨ q0 ¬ q0 →∗

A

∧ ¬ q0 ∨ q0 q1 →∗

A

∧ q1 q1 →A q1 Definition: run of A on a term t ∈ T (Σ) A run ρ is a mapping from Pos(t) to Q compatible with the transition rules.

5/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-17
SLIDE 17

The SAT encoding Implementation and Experiments

Tree automata

Definition through an example

∧ ¬ ∧ 0 1 ∨ 0 ¬ →∗

A

∧ ¬ ∧ q0 q1 ∨ q0 ¬ q0 →∗

A

∧ ¬ q0 ∨ q0 q1 →∗

A

∧ q1 q1 →A q1 ρ =

ε ∧q1 1 ¬q1 11 ∧q0 111 0q0 112 1q1 2 ∨q1 21 0q0 22 ¬q1 221 0q0

5/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-18
SLIDE 18

The SAT encoding Implementation and Experiments

TAGEDs

Tree Automata With Global Equality and Disequality Constraints

Introduced in Emmanuel Filiot’s PhD thesis on XML query

  • languages. See [Filiot et al., 2008].

A TAGED is a tuple A = (Σ, Q, F, ∆, =

A, = A), where

(Σ, Q, F, ∆) is a tree automaton =

A is a reflexive symmetric binary relation on a subset of Q

=

A is an irreflexive and symmetric binary relation on Q. Note

that in our work, we have dealt with a slightly more general case, where =

A is not necessarily irreflexive.

A TAGED A is said to be positive if =

A is empty and negative if = A

is empty. Runs must be compatible with equality and disequality constraints.

6/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-19
SLIDE 19

The SAT encoding Implementation and Experiments

TAGEDs

Compatibility with global constraints

Le ρ be a run of the TAGED A on a tree t: Compatibility with the equality constraint =

A

∀α, β ∈ Pos(t) : ρ(α) =

A ρ(β) =

⇒ t|α = t|β . Compatibility with the disequality constraint =

A (irreflexive)

∀α, β ∈ Pos(t) : ρ(α) =

A ρ(β) =

⇒ t|α = t|β . Compatibility with the disequality constraint =

A (non irreflexive)

∀α, β ∈ Pos(t) : α = β ∧ ρ(α) =

A ρ(β) =

⇒ t|α = t|β .

7/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-20
SLIDE 20

The SAT encoding Implementation and Experiments

TAGEDs

A non-regular language accepted by TAGEDs TAGED for { f (t, t) | f ∈ Σ, t ∈ T (Σ) }

A def = (Σ = { a, f } , Q = { q, ˆ q, qf } , F = { qf } , ∆, ˆ q =

A ˆ

q), where ∆ def = {f (ˆ q, ˆ q) → qf , f (q, q) → q, f (q, q) → ˆ q, a → q, a → ˆ q, } f f a a f a a

8/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-21
SLIDE 21

The SAT encoding Implementation and Experiments

TAGEDs

A non-regular language accepted by TAGEDs TAGED for { f (t, t) | f ∈ Σ, t ∈ T (Σ) }

A def = (Σ = { a, f } , Q = { q, ˆ q, qf } , F = { qf } , ∆, ˆ q =

A ˆ

q), where ∆ def = {f (ˆ q, ˆ q) → qf , f (q, q) → q, f (q, q) → ˆ q, a → q, a → ˆ q, } f f a a f a a →∗

A

fqf fˆ

q

aq aq fˆ

q

aq aq

8/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-22
SLIDE 22

The SAT encoding Implementation and Experiments

TAGEDs

A non-regular language accepted by TAGEDs TAGED for { f (t, t) | f ∈ Σ, t ∈ T (Σ) }

A def = (Σ = { a, f } , Q = { q, ˆ q, qf } , F = { qf } , ∆, ˆ q =

A ˆ

q), where ∆ def = {f (ˆ q, ˆ q) → qf , f (q, q) → q, f (q, q) → ˆ q, a → q, a → ˆ q, } f f a a f a a →∗

A

fqf fˆ

q

aq aq fˆ

q

aq aq vs. f f a a a

8/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-23
SLIDE 23

The SAT encoding Implementation and Experiments

TAGEDs

A non-regular language accepted by TAGEDs TAGED for { f (t, t) | f ∈ Σ, t ∈ T (Σ) }

A def = (Σ = { a, f } , Q = { q, ˆ q, qf } , F = { qf } , ∆, ˆ q =

A ˆ

q), where ∆ def = {f (ˆ q, ˆ q) → qf , f (q, q) → q, f (q, q) → ˆ q, a → q, a → ˆ q, } f f a a f a a →∗

A

fqf fˆ

q

aq aq fˆ

q

aq aq vs. f f a a a →∗

A

fqf fˆ

q

aq aq aˆ

q

8/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-24
SLIDE 24

The SAT encoding Implementation and Experiments

TAGED membership

. . . through SAT solvers

Uniform Membership Problem INPUT: A a TAGED and t ∈ T (Σ) a term. OUTPUT: Is t accepted by A?

9/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-25
SLIDE 25

The SAT encoding Implementation and Experiments

TAGED membership

. . . through SAT solvers

Uniform Membership Problem INPUT: A a TAGED and t ∈ T (Σ) a term. OUTPUT: Is t accepted by A? Theorem [Filiot2008] The Uniform Membership Problem for TAGEDs is NP-complete.

9/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-26
SLIDE 26

The SAT encoding Implementation and Experiments

TAGED membership

. . . through SAT solvers

Uniform Membership Problem INPUT: A a TAGED and t ∈ T (Σ) a term. OUTPUT: Is t accepted by A? Theorem [Filiot2008] The Uniform Membership Problem for TAGEDs is NP-complete. Possible practical approach XML/. . . ⇒ TAGED membership

9/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-27
SLIDE 27

The SAT encoding Implementation and Experiments

TAGED membership

. . . through SAT solvers

Uniform Membership Problem INPUT: A a TAGED and t ∈ T (Σ) a term. OUTPUT: Is t accepted by A? Theorem [Filiot2008] The Uniform Membership Problem for TAGEDs is NP-complete. Possible practical approach XML/. . . ⇒ TAGED membership ⇒ SAT problem

9/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-28
SLIDE 28

The SAT encoding Implementation and Experiments

TAGED membership

. . . through SAT solvers

Uniform Membership Problem INPUT: A a TAGED and t ∈ T (Σ) a term. OUTPUT: Is t accepted by A? Theorem [Filiot2008] The Uniform Membership Problem for TAGEDs is NP-complete. Possible practical approach XML/. . . ⇒ TAGED membership ⇒ SAT problem

9/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-29
SLIDE 29

The SAT encoding Implementation and Experiments

TAGED membership

. . . through SAT solvers

Uniform Membership Problem INPUT: A a TAGED and t ∈ T (Σ) a term. OUTPUT: Is t accepted by A? Theorem [Filiot2008] The Uniform Membership Problem for TAGEDs is NP-complete. Possible practical approach XML/. . . ⇒ TAGED membership ⇒ SAT problem ⇒ answer

9/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-30
SLIDE 30

The SAT encoding Implementation and Experiments

The SAT Problem

. . . and applications

Definition: The SAT problem Given a propositional formula, for instance ϕ = X ∨ (¬X ∧ ¬Y ) or ψ = X ∧ (¬X ∧ ¬Y ), is there a valuation such that the formula evaluates to true? NP-complete The SAT problem is the first known NP-complete decision problem (Cook, 1971). In practice There are very efficient heuristics implanted in modern SAT solvers.

10/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-31
SLIDE 31

The SAT encoding Implementation and Experiments

Plan

1

The SAT encoding

2

Implementation and Experiments

11/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-32
SLIDE 32

The SAT encoding Implementation and Experiments

The SAT encoding

Choice of variables and Θ

Variables: X α

q

A run is a mapping from Pos(t) to Q. So we take variables of the form X α

q , meaning:

∀α ∈ Pos(t), q ∈ Q : X α

q

⇐ ⇒ ρ(α) = q

12/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-33
SLIDE 33

The SAT encoding Implementation and Experiments

The SAT encoding

Choice of variables and Θ

Variables: X α

q

A run is a mapping from Pos(t) to Q. So we take variables of the form X α

q , meaning:

∀α ∈ Pos(t), q ∈ Q : X α

q

⇐ ⇒ ρ(α) = q Partial function constraint Θ: “ρ is a function” Θ

def

=

  • α∈Pos(t)

q∈Q

  X α

q

= ⇒

  • p∈Q

p=q

¬X α

p

  

12/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-34
SLIDE 34

The SAT encoding Implementation and Experiments

The SAT encoding

Rule application and compatibility: Ψα(r) and Φε(t)

Rule application constraint Ψα(r) We define, for any α ∈ Pos(t), and any transition rule f (q1, . . . , qn) → q ∈ ∆, Ψαf (q1, . . . , qn) → q

def

= X α

q ∧ n

  • k=1

X α.k

qk . α fq α.1 xq1 α.2 xq2 α.k xqk α.n xqn

13/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-35
SLIDE 35

The SAT encoding Implementation and Experiments

The SAT encoding

Rule application and compatibility: Ψα(r) and Φε(t)

Rule application constraint Ψα(r) We define, for any α ∈ Pos(t), and any transition rule f (q1, . . . , qn) → q ∈ ∆, Ψαf (q1, . . . , qn) → q

def

= X α

q ∧ n

  • k=1

X α.k

qk .

Rules compatibility constraint Φε(t) Φε(t) def =

  • α∈Pos(t)
  • r∈∆t(α)

Ψα(r)

  • where ∆f = { f (. . . ) → · · · ∈ ∆ }.

13/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-36
SLIDE 36

The SAT encoding Implementation and Experiments

The SAT encoding

Connecting to TAGEDs: Θ⇆

Accepting run for tree automata We have coded runs for tree automata: one more constraint:

  • q∈F X ε

q makes sure we end up in a final state.

14/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-37
SLIDE 37

The SAT encoding Implementation and Experiments

The SAT encoding

Connecting to TAGEDs: Θ⇆

Accepting run for tree automata We have coded runs for tree automata: one more constraint:

  • q∈F X ε

q makes sure we end up in a final state.

New variables: T q

u

We need new variables to link subterms and states: T q

u denotes

“the subterm u evaluates to q”, for any u t and q ∈ Q.

14/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-38
SLIDE 38

The SAT encoding Implementation and Experiments

The SAT encoding

Connecting to TAGEDs: Θ⇆

Accepting run for tree automata We have coded runs for tree automata: one more constraint:

  • q∈F X ε

q makes sure we end up in a final state.

New variables: T q

u

We need new variables to link subterms and states: T q

u denotes

“the subterm u evaluates to q”, for any u t and q ∈ Q. Structural glue: Θ⇆ Θ⇆

def

=

  • α∈Pos(t)

q∈Q

  • X α

q

= ⇒ T q

t|α

  • .

14/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-39
SLIDE 39

The SAT encoding Implementation and Experiments

The SAT encoding

Compatibility with =

A and = A

Compatibility with =

A: Θ=

A

Θ=

A

def

=

  • α∈Pos(t)

q∈Q

  X α

q

= ⇒

  • p∈Q

p=

Aq

  • ut

u= t|α

¬T p

u

  

Compatibility with =

A (p = q): Θ=

A

Θ=

A

def

=

  • α∈Pos(t)

q∈Q

   X α

q

= ⇒

  • p∈Q

p=

Aq

p=q

¬T p

t|α

   

15/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-40
SLIDE 40

The SAT encoding Implementation and Experiments

The SAT encoding

Compatibility with =

A and = A

Compatibility with =

A with structural glue Θ⇆

Θ=

A ∧ Θ⇆

def

=

  • α∈Pos(t)

q∈Q

   X α

q

= ⇒ T q

t|α ∧

  • p∈Q

p=

Aq

p=q

¬T p

t|α

   

The idea: a counterexample Let t ∈ T (Σ), α, β ∈ Pos(t) and u = t|α = t|β. Suppose that ρ is a run such that ρ(α) = p and ρ(β) = q with p =

A q. Then we

have X α

p , X β q ,

15/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-41
SLIDE 41

The SAT encoding Implementation and Experiments

The SAT encoding

Compatibility with =

A and = A

Compatibility with =

A with structural glue Θ⇆

Θ=

A ∧ Θ⇆

def

=

  • α∈Pos(t)

q∈Q

   X α

q

= ⇒ T q

t|α ∧

  • p∈Q

p=

Aq

p=q

¬T p

t|α

   

The idea: a counterexample Let t ∈ T (Σ), α, β ∈ Pos(t) and u = t|α = t|β. Suppose that ρ is a run such that ρ(α) = p and ρ(β) = q with p =

A q. Then we

have X α

p , X β q , T p t|α, ¬T q t|α,

15/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-42
SLIDE 42

The SAT encoding Implementation and Experiments

The SAT encoding

Compatibility with =

A and = A

Compatibility with =

A with structural glue Θ⇆

Θ=

A ∧ Θ⇆

def

=

  • α∈Pos(t)

q∈Q

   X α

q

= ⇒ T q

t|α ∧

  • p∈Q

p=

Aq

p=q

¬T p

t|α

   

The idea: a counterexample Let t ∈ T (Σ), α, β ∈ Pos(t) and u = t|α = t|β. Suppose that ρ is a run such that ρ(α) = p and ρ(β) = q with p =

A q. Then we

have X α

p , X β q , T p t|α, ¬T q t|α, T q t|β, ¬T p t|β.

15/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-43
SLIDE 43

The SAT encoding Implementation and Experiments

The SAT encoding

Compatibility with =

A and = A

Compatibility with =

A with structural glue Θ⇆

Θ=

A ∧ Θ⇆

def

=

  • α∈Pos(t)

q∈Q

   X α

q

= ⇒ T q

t|α ∧

  • p∈Q

p=

Aq

p=q

¬T p

t|α

   

The idea: a counterexample Let t ∈ T (Σ), α, β ∈ Pos(t) and u = t|α = t|β. Suppose that ρ is a run such that ρ(α) = p and ρ(β) = q with p =

A q. Then we

have X α

p , X β q , T p t|α, ¬T q t|α, T q t|β, ¬T p t|β.

Since u = t|α = t|β we have T q

u , ¬T q u , T p u , ¬T p u , hence the formula is not satisfiable.

15/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-44
SLIDE 44

The SAT encoding Implementation and Experiments

The SAT encoding

Compatibility with =

A, non-irreflexive case: Ω=

A

Compatibility with =

A (p = q): Θ=

A

Θ=

A

def

=

  • α∈Pos(t)

q∈Q

   X α

q

= ⇒

  • p∈Q

p=

Aq

p=q

¬T p

t|α

   

New variables: Sα

u

We need new variables to link subterms and positions: Sα

u encodes

the statement “the subterm u is rooted in α”. Compatibility with =

A (non-irreflexive; q = A q): Ω=

A

Ω=

A

def

=

  • α∈Pos(t)

t|α ∧

  • α=β∈Pos(t)

q=

Aq

  • X α

q ∧ X β q =

⇒ ¬Sα

t|β

  • 16/26

Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-45
SLIDE 45

The SAT encoding Implementation and Experiments

The SAT encoding

Completeness and soundness

Definition (SAT encoding of TAGED membership problem ∆A (t)) Let A = (Σ, ∆, Q, F, =

A, = A) be a TAGED and t ∈ T (Σ); then we

define ∆A (t) def = Θ ∧ Φε(t) ∧

  • q∈F

X ε

q ∧ Θ=

A ∧ Θ= A ∧ Ω= A.

Theorem (TAGED membership, correctness and soundness) There exists a successful run ρ of the TAGED A on a term t iff ∆A (t) is satisfiable. Moreover, if I | = ∆A (t), then for any α ∈ Pos(t) we have ρ (α) = q ⇐ ⇒ I | = X α

q .

17/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-46
SLIDE 46

The SAT encoding Implementation and Experiments

Plan

1

The SAT encoding

2

Implementation and Experiments

18/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-47
SLIDE 47

The SAT encoding Implementation and Experiments

Possible optimisations

. . . from simple observations

The formulæ can be trimmed down: consider Structural glue: Θ⇆ Θ⇆

def

=

  • α∈Pos(t)

q∈Q

  • X α

q

= ⇒ T q

t|α

  • .

Not all couples (α, q) are necessary because not all states are

  • btainable at any given position.

Definition (Possibly obtainable states at position α) σ (α) def = { q ∈ Q/ ∃t(α)(. . . ) → q ∈ ∆ } Given a position α, we only need to deal with q ∈ σ(α).

19/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-48
SLIDE 48

The SAT encoding Implementation and Experiments

Possible optimisations

. . . from simple observations

The formulæ can be trimmed down: consider Structural glue: Θ⇆ Θ⇆

def

=

  • α∈Pos(t)

q∈σ(α)

  • X α

q

= ⇒ T q

t|α

  • .

Not all couples (α, q) are necessary because not all states are

  • btainable at any given position.

Definition (Possibly obtainable states at position α) σ (α) def = { q ∈ Q/ ∃t(α)(. . . ) → q ∈ ∆ } Given a position α, we only need to deal with q ∈ σ(α).

19/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-49
SLIDE 49

The SAT encoding Implementation and Experiments

The prototype

Intro/ Input format

Prototype (OCaml). Takes a TAGED and a term as input (syntax close to the Tree Automata library Timbuk).

(** TAGED Automaton for {f(x,x)} *) Taged fxxA Alphabet f a b States q qq qf Final qf Rules f qq qq : qf f q q : q f q q : qq a:q a:qq b:q b:qq Equal qq qq Different qq qf f(f(a,a), f(a,a)) // in a_fxx

Figure: Input syntax of the tool

20/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-50
SLIDE 50

The SAT encoding Implementation and Experiments

The prototype

Generated formula

21/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-51
SLIDE 51

The SAT encoding Implementation and Experiments

The prototype

CNF Conversion: the BAT

Definition: Conjunctive Normal Form A formula is in Conjunctive Normal Form (CNF) if it is a conjunction of disjunctions of literals and contains only ¬, ∧ or ∨. DIMACS CNF ϕ = (X ∨ ¬Z) ∧ (Y ∨ Z ∨ ¬X).

c DIMACS CNF for ϕ p cnf 3 2 1 -3 0 2 3 -1 0

Problem! Our formula is not in CNF! We must convert it. The BAT solves it.

22/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-52
SLIDE 52

The SAT encoding Implementation and Experiments

The prototype

Results: Laboratory example

CNF solving time, Laboratory example

0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 20 40 60 80 100 SAT solving time (s) Number of elements picoSAT MiniSAT2 23/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-53
SLIDE 53

The SAT encoding Implementation and Experiments

The prototype

Results: { f (t, t) | f ∈ Σ, t ∈ T (Σ) } example

CNF solving time, { f (t, t) | f ∈ Σ, t ∈ T (Σ) }

0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 2000 4000 6000 8000 10000 12000 14000 16000 SAT solving time (s) Size of term picoSAT (accepted) MiniSAT2(accepted) picoSAT (rejected) MiniSAT2(rejected) 24/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-54
SLIDE 54

The SAT encoding Implementation and Experiments

Conclusion, step by step

XML ⇒ TAGED ⇒ ∆A (t) ⇒ CNF ⇒ SAT solver ⇒ answer

25/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-55
SLIDE 55

The SAT encoding Implementation and Experiments

Conclusion, step by step

XML ⇒ TAGED ⇒ ∆A (t) ⇒ CNF ⇒ SAT solver ⇒ answer Theoretical contribution SAT encoding for the TAGED uniform membership problem. Natural

  • ptimisations.

Complexity The formula is quadratic in the size of the input, and so is the generation time (worst case). Implementation Unoptimised OCaml prototype generating optimised ∆A (t) from input TAGED A and term t.

25/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-56
SLIDE 56

The SAT encoding Implementation and Experiments

Conclusion, step by step

XML ⇒ TAGED ⇒ ∆A (t) ⇒ CNF ⇒ SAT solver ⇒ answer Conversion to CNF We use an existing tool, BAT [Manolios and Vroon, 2009], to convert our formula to DIMACS CNF. Caveats For now, CNF conversion is the bottleneck of our experiments: BAT is 4.5 times slower than formula generation on big formulæ. BAT crashed (stack overflow) on big formulæ So we could not produce tests big enough to really push the SAT solvers to their limits.

25/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-57
SLIDE 57

The SAT encoding Implementation and Experiments

Conclusion, step by step

XML ⇒ TAGED ⇒ ∆A (t) ⇒ CNF ⇒ SAT solver ⇒ answer Tested SAT solvers Solvers picoSAT and MiniSAT2 both display good performances,

MiniSAT2 seeming faster in general.

Results Efficient (sub-second) SAT solving even in largest tested casesa

aOrder of magnitude: Term of 20 000 nodes, formula of 70 000 variables,

120 000 clauses and 250 000 literals (in CNF)

25/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-58
SLIDE 58

The SAT encoding Implementation and Experiments

Conclusion, step by step

XML ⇒ TAGED ⇒ ∆A (t) ⇒ CNF ⇒ SAT solver ⇒ answer Conclusion Overall, the current experimental limitations lie in the computationally easier part of the problem, while its inherent difficulty (NP-completeness) seems well overcome by the heuristics

  • f tested SAT solvers.

25/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints

slide-59
SLIDE 59

The SAT encoding Implementation and Experiments

Some references

[Comon et al., 2007, Filiot et al., 2008, Manolios and Vroon, 2009]

Comon, H., Dauchet, M., Gilleron, R., Löding, C., Jacquemard, F., Lugiez, D., Tison, S., and Tommasi, M. (2007). Tree automata techniques and applications. release October, 12th 2007. Filiot, E., Talbot, J.-M., and Tison, S. (2008). Tree Automata with Global Constraints. In 12th International Conference on Developments in Language Theory (DLT), pages 314–326, Kyoto Japon. Manolios, B. and Vroon, D. (2009). Faster SAT Solving with Better CNF Generation. Design, Automation and Test in Europe, DATE.

26/26 Vincent HUGOT SAT Solvers for Queries over Tree Automata with Constraints