LIBPOLY: A LIBRARY FOR REASONING ABOUT POLYNOMIALS Dejan Jovanovi - - PowerPoint PPT Presentation

libpoly a library for reasoning about polynomials
SMART_READER_LITE
LIVE PREVIEW

LIBPOLY: A LIBRARY FOR REASONING ABOUT POLYNOMIALS Dejan Jovanovi - - PowerPoint PPT Presentation

LIBPOLY: A LIBRARY FOR REASONING ABOUT POLYNOMIALS Dejan Jovanovi Bruno Dutertre SRI International SMT Workshop 2017 OUTLINE INTRODUCTION LIBPOLY Working with Polynomials Constructing a Sign Table Cylindrical Algebraic Decomposition


slide-1
SLIDE 1

LIBPOLY: A LIBRARY FOR REASONING ABOUT POLYNOMIALS

Dejan Jovanović Bruno Dutertre

SRI International

SMT Workshop 2017

slide-2
SLIDE 2

OUTLINE

INTRODUCTION LIBPOLY

Working with Polynomials Constructing a Sign Table Cylindrical Algebraic Decomposition

CONCLUSION

slide-3
SLIDE 3

OUTLINE

INTRODUCTION LIBPOLY

Working with Polynomials Constructing a Sign Table Cylindrical Algebraic Decomposition

CONCLUSION

slide-4
SLIDE 4

NON-LINEAR REASONING

MANY APPLICATIONS

20 40 60 20 20 39 000 39 500 40 000

Tx

1(t) = 3.2484 + 270.7t + 433.12t2 − 324.83999t3

Ty

1(t) = 15.1592 + 108.28t + 121.2736t2 − 649.67999t3

Tz

1(t) = 38980.8 + 5414t − 21656t2 + 32484t3

Tx

2(t) = 1.0828 − 135.35t + 234.9676t22 + 3248.4t3

Ty

2(t) = 18.40759 − 230.6364t − 121.2736t2 − 649.67999t3

Tz

2(t) = 40280.15999 − 10828t + 24061.9816t2 − 32484t3

D = 5 H = 1000 0 ≤ t ≤ 1 20 |Tz

1(t) − Tz 2(t)| ≤ H

(Tx

1(t) − Tx 2(t))2 + (Ty 1(t) − Ty 2(t))2 ≤ D2

Example from Narkawicz, Muõz, Formal Verification of Conflict Detection Algorithms for Arbitrary Trajectories, 2012

slide-5
SLIDE 5

NON-LINEAR REASONING

MANY APPLICATIONS

20 40 60 20 20 39 000 39 500 40 000

Tx

1(t) = 3.2484 + 270.7t + 433.12t2 − 324.83999t3

Ty

1(t) = 15.1592 + 108.28t + 121.2736t2 − 649.67999t3

Tz

1(t) = 38980.8 + 5414t − 21656t2 + 32484t3

Tx

2(t) = 1.0828 − 135.35t + 234.9676t22 + 3248.4t3

Ty

2(t) = 18.40759 − 230.6364t − 121.2736t2 − 649.67999t3

Tz

2(t) = 40280.15999 − 10828t + 24061.9816t2 − 32484t3

D = 5 H = 1000 0 ≤ t ≤ 1 20 |Tz

1(t) − Tz 2(t)| ≤ H

(Tx

1(t) − Tx 2(t))2 + (Ty 1(t) − Ty 2(t))2 ≤ D2

Example from Narkawicz, Muõz, Formal Verification of Conflict Detection Algorithms for Arbitrary Trajectories, 2012

RUN SMT SOLVER

t →

319 16384 ≈ 0.019470215

slide-6
SLIDE 6

NON-LINEAR REASONING

SMT TECHNIQUES

Popular techniques in SMT (QF_NRA):

◮ Interval reasoning: RASAT ◮ Linear reasoning + model-based refinement: CVC4 ◮ DPLL(T) + VTS: VERIT ◮ DPLL(T) + CAD: SMTRAT, VERIT ◮ MCSAT + CAD: Z3, YICES2

Cylindrical Algebraic Decomposition (CAD): complete method, currently state-of-the-art; requires advanced polynomial operations.

slide-7
SLIDE 7

NON-LINEAR REASONING

SMT TECHNIQUES

Popular techniques in SMT (QF_NRA):

◮ Interval reasoning: RASAT ◮ Linear reasoning + model-based refinement: CVC4 ◮ DPLL(T) + VTS: VERIT ◮ DPLL(T) + CAD: SMTRAT, VERIT ◮ MCSAT + CAD: Z3, YICES2

Cylindrical Algebraic Decomposition (CAD):

◮ complete method, currently state-of-the-art; ◮ requires advanced polynomial operations.

slide-8
SLIDE 8

NON-LINEAR REASONING

SMT SOLVERS (2016)

0.001 0.01 0.1 1 10 100 1000 10000 100000 1e+06 2000 4000 6000 8000 10000 cumulative time (s) benchmarks solved z3 yices2 smtrat rasat-0.4 rasat-0.3 cvc4

slide-9
SLIDE 9

NON-LINEAR REASONING

SMT SOLVERS (2017)

0.001 0.01 0.1 1 10 100 1000 10000 100000 1e+06 2000 4000 6000 8000 10000 cumulative time (s) benchmarks solved yices2 z3 verit+rasat+redlog cvc4 smtrat

slide-10
SLIDE 10

NON-LINEAR REASONING

CAD-BASED REASONING

  • 1. Representation of polynomials.
  • 2. Basic operations:

◮ variables, variable ordering; ◮ arithmetic (addition, multiplication, …); ◮ GCD computation; ◮ some factorization.

  • 3. Solving and model representation:

◮ Sturm sequences; ◮ interval reasoning; ◮ root isolation (multivariate); ◮ resultants; ◮ computation with algebraic numbers.

  • 4. Projection and symbolic explanations:

◮ principal subresultant coefgicients.

slide-11
SLIDE 11

NON-LINEAR REASONING

CAD-BASED REASONING

  • 1. Representation of polynomials.
  • 2. Basic operations:

◮ variables, variable ordering; ◮ arithmetic (addition, multiplication, …); ◮ GCD computation; ◮ some factorization.

  • 3. Solving and model representation:

◮ Sturm sequences; ◮ interval reasoning; ◮ root isolation (multivariate); ◮ resultants; ◮ computation with algebraic numbers.

  • 4. Projection and symbolic explanations:

◮ principal subresultant coefgicients.

HOW TO GET THESE?

Use an existing library Use a computer algebra system Borrow and adapt code Implement yourself Use LIBPOLY .

slide-12
SLIDE 12

NON-LINEAR REASONING

CAD-BASED REASONING

  • 1. Representation of polynomials.
  • 2. Basic operations:

◮ variables, variable ordering; ◮ arithmetic (addition, multiplication, …); ◮ GCD computation; ◮ some factorization.

  • 3. Solving and model representation:

◮ Sturm sequences; ◮ interval reasoning; ◮ root isolation (multivariate); ◮ resultants; ◮ computation with algebraic numbers.

  • 4. Projection and symbolic explanations:

◮ principal subresultant coefgicients.

HOW TO GET THESE?

◮ Use an existing library

Use a computer algebra system Borrow and adapt code Implement yourself Use LIBPOLY .

slide-13
SLIDE 13

NON-LINEAR REASONING

CAD-BASED REASONING

  • 1. Representation of polynomials.
  • 2. Basic operations:

◮ variables, variable ordering; ◮ arithmetic (addition, multiplication, …); ◮ GCD computation; ◮ some factorization.

  • 3. Solving and model representation:

◮ Sturm sequences; ◮ interval reasoning; ◮ root isolation (multivariate); ◮ resultants; ◮ computation with algebraic numbers.

  • 4. Projection and symbolic explanations:

◮ principal subresultant coefgicients.

HOW TO GET THESE?

◮ Use an existing library

Use a computer algebra system Borrow and adapt code Implement yourself Use LIBPOLY .

slide-14
SLIDE 14

NON-LINEAR REASONING

CAD-BASED REASONING

  • 1. Representation of polynomials.
  • 2. Basic operations:

◮ variables, variable ordering; ◮ arithmetic (addition, multiplication, …); ◮ GCD computation; ◮ some factorization.

  • 3. Solving and model representation:

◮ Sturm sequences; ◮ interval reasoning; ◮ root isolation (multivariate); ◮ resultants; ◮ computation with algebraic numbers.

  • 4. Projection and symbolic explanations:

◮ principal subresultant coefgicients.

HOW TO GET THESE?

◮ Use an existing library ◮ Use a computer algebra system

Borrow and adapt code Implement yourself Use LIBPOLY .

slide-15
SLIDE 15

NON-LINEAR REASONING

CAD-BASED REASONING

  • 1. Representation of polynomials.
  • 2. Basic operations:

◮ variables, variable ordering; ◮ arithmetic (addition, multiplication, …); ◮ GCD computation; ◮ some factorization.

  • 3. Solving and model representation:

◮ Sturm sequences; ◮ interval reasoning; ◮ root isolation (multivariate); ◮ resultants; ◮ computation with algebraic numbers.

  • 4. Projection and symbolic explanations:

◮ principal subresultant coefgicients.

HOW TO GET THESE?

◮ Use an existing library ◮ Use a computer algebra system

Borrow and adapt code Implement yourself Use LIBPOLY .

slide-16
SLIDE 16

NON-LINEAR REASONING

CAD-BASED REASONING

  • 1. Representation of polynomials.
  • 2. Basic operations:

◮ variables, variable ordering; ◮ arithmetic (addition, multiplication, …); ◮ GCD computation; ◮ some factorization.

  • 3. Solving and model representation:

◮ Sturm sequences; ◮ interval reasoning; ◮ root isolation (multivariate); ◮ resultants; ◮ computation with algebraic numbers.

  • 4. Projection and symbolic explanations:

◮ principal subresultant coefgicients.

HOW TO GET THESE?

◮ Use an existing library ◮ Use a computer algebra system ◮ Borrow and adapt code

Implement yourself Use LIBPOLY .

slide-17
SLIDE 17

NON-LINEAR REASONING

CAD-BASED REASONING

  • 1. Representation of polynomials.
  • 2. Basic operations:

◮ variables, variable ordering; ◮ arithmetic (addition, multiplication, …); ◮ GCD computation; ◮ some factorization.

  • 3. Solving and model representation:

◮ Sturm sequences; ◮ interval reasoning; ◮ root isolation (multivariate); ◮ resultants; ◮ computation with algebraic numbers.

  • 4. Projection and symbolic explanations:

◮ principal subresultant coefgicients.

HOW TO GET THESE?

◮ Use an existing library ◮ Use a computer algebra system ◮ Borrow and adapt code

Implement yourself Use LIBPOLY .

slide-18
SLIDE 18

NON-LINEAR REASONING

CAD-BASED REASONING

  • 1. Representation of polynomials.
  • 2. Basic operations:

◮ variables, variable ordering; ◮ arithmetic (addition, multiplication, …); ◮ GCD computation; ◮ some factorization.

  • 3. Solving and model representation:

◮ Sturm sequences; ◮ interval reasoning; ◮ root isolation (multivariate); ◮ resultants; ◮ computation with algebraic numbers.

  • 4. Projection and symbolic explanations:

◮ principal subresultant coefgicients.

HOW TO GET THESE?

◮ Use an existing library ◮ Use a computer algebra system ◮ Borrow and adapt code ◮ Implement yourself

Use LIBPOLY .

slide-19
SLIDE 19

NON-LINEAR REASONING

CAD-BASED REASONING

  • 1. Representation of polynomials.
  • 2. Basic operations:

◮ variables, variable ordering; ◮ arithmetic (addition, multiplication, …); ◮ GCD computation; ◮ some factorization.

  • 3. Solving and model representation:

◮ Sturm sequences; ◮ interval reasoning; ◮ root isolation (multivariate); ◮ resultants; ◮ computation with algebraic numbers.

  • 4. Projection and symbolic explanations:

◮ principal subresultant coefgicients.

HOW TO GET THESE?

◮ Use an existing library ◮ Use a computer algebra system ◮ Borrow and adapt code ◮ Implement yourself ◮ Use LIBPOLY .

slide-20
SLIDE 20

OUTLINE

INTRODUCTION LIBPOLY

Working with Polynomials Constructing a Sign Table Cylindrical Algebraic Decomposition

CONCLUSION

slide-21
SLIDE 21

LIBPOLY

◮ Open source: https://github.com/SRI-CSL/libpoly. ◮ Permissive License: LGLP ◮ Lightweight: Implemented in C, 15KLOC. ◮ Only depends on GMP. ◮ Basis for non-linear reasoning in YICES2.

slide-22
SLIDE 22

POLYNOMIAL BASICS

◮ Polynomials with coefgicients over Z. ◮ Z[x1, . . . , xn] are polynomials over variables⃗

x = ⟨x1, . . . , xn⟩.

◮ For f ∈ Z[⃗

y, x]: f(⃗ y, x) = am · xdm + am−1 · xdm−1 + · · · + a1 · xd1 + a0 .

◮ am ̸= 0, ai ∈ Z[⃗

y], dm > · · · > d1 > 0

◮ x is the top variable ◮ dm is the degree of f ◮ am is the leading coefgicient

slide-23
SLIDE 23

ASSIGNMENT AND EVALUATION

An assignment assigns variables to values

m = { x → 1, y → 2, z → 3 } .

We can evaluate the sign of a polynomial f ∈ Z[x, y, z]

sgn(f, m) ∈ {+1, 0, −1} .

slide-24
SLIDE 24

ZEROS OF A POLYNOMIAL (ROOT ISOLATION)

ROOT ISOLATION

For f ∈ Z[⃗ y, x] and an assignment⃗ y → ⃗ v, find solutions to f(⃗ v, x) = 0.

EXAMPLE m1 = {} f1(x) = x − 1 m2 = {x → 1} f2(x, y) = y2 − 2x m3 = {x → 1, y → √ 2} f3(x, y, z) = z3 − y2 − x

slide-25
SLIDE 25

SIGN TABLE

EXAMPLE (SIGN TABLE)

(−∞, −1) [−1] (−1, 0) [0] (0, 1) [1] (1, 2) [2] (2, +∞) x2 − 1 +

  • +

+ + x(x − 2) + + +

  • +
slide-26
SLIDE 26

SIGN TABLE: WHAT IS IT?

EXAMPLE (SIGN TABLE)

(−∞, −1) [−1] (−1, 0) [0] (0, 1) [1] (1, 2) [2] (2, +∞) x2 − 1 +

  • +

+ + x(x − 2) + + +

  • +

SIGN TABLE

◮ Partition of R into intervals I1, …In. ◮ Picking an arbitrary sample value v ∈ Ik is enough to evaluate signs. ◮ It completely characterizes the behavior of the polynomials.

slide-27
SLIDE 27

CAN WE DO MULTIVARIATE?

EXAMPLE (MULTIVARIATE) x2 + y2 − 1 ≤ 0 , (x − 1)2 + y2 − 1 ≤ 0 .

slide-28
SLIDE 28

CAN WE DO MULTIVARIATE?

EXAMPLE (MULTIVARIATE) x2 + y2 − 1 ≤ 0 , (x − 1)2 + y2 − 1 ≤ 0 . RECURSIVE SIGN TABLE

  • 1. Pick order, say x < y.
  • 2. Px: polynomials in x.
  • 3. Py: polynomials in x, y.
  • 4. Construct sign table Tx for Px.
  • 5. For each sample v ∈ Tx:

◮ Construct sign table Tv,y for Py.

slide-29
SLIDE 29

CAN WE DO MULTIVARIATE?

EXAMPLE (MULTIVARIATE) x2 + y2 − 1 ≤ 0 , (x − 1)2 + y2 − 1 ≤ 0 . RECURSIVE SIGN TABLE

  • 1. Pick order, say x < y.
  • 2. Px: polynomials in x.
  • 3. Py: polynomials in x, y.
  • 4. Construct sign table Tx for Px.
  • 5. For each sample v ∈ Tx:

◮ Construct sign table Tv,y for Py.

slide-30
SLIDE 30

CAN WE DO MULTIVARIATE?

EXAMPLE (HOW TO GET THE EXTRA POLYNOMIALS?)

We added extra polynomials

x + 1 , x , 2x − 1 , x − 1 , x − 2 .

Can we find these polynomials automatically?

slide-31
SLIDE 31

CAD PROJECTION

FILLING THE BLANKS

DEFINITION (PROJECTION)

Given a set of polynomials A = {f1, . . . , fm} ⊂ Z[⃗ y, x], the x-projection of A is P(A, x) = ∪

f∈A

coeff(f, x) ∪ ∪

f∈A g∈ R∗(f,x)

psc(g, g′

x, x) ∪

i<j gi∈ R∗(fi,x) gj∈ R∗(fj,x)

psc(gi, gj, x) .

slide-32
SLIDE 32

CAD PROJECTION

FILLING THE BLANKS

DEFINITION (PROJECTION)

Given a set of polynomials A = {f1, . . . , fm} ⊂ Z[⃗ y, x], the x-projection of A is P(A, x) = ∪

f∈A

coeff(f, x) ∪ ∪

f∈A g∈ R∗(f,x)

psc(g, g′

x, x) ∪

i<j gi∈ R∗(fi,x) gj∈ R∗(fj,x)

psc(gi, gj, x) .

coeff(f, x): COEFFICIENTS

Signs of coefgicients invariant on S ⇒ degrees of f ∈ A invariant on S.

slide-33
SLIDE 33

CAD PROJECTION

FILLING THE BLANKS

DEFINITION (PROJECTION)

Given a set of polynomials A = {f1, . . . , fm} ⊂ Z[⃗ y, x], the x-projection of A is P(A, x) = ∪

f∈A

coeff(f, x) ∪ ∪

f∈A g∈ R∗(f,x)

psc(g, g′

x, x) ∪

i<j gi∈ R∗(fi,x) gj∈ R∗(fj,x)

psc(gi, gj, x) .

R∗(f, x): REDUCTUMS INCLUDE THE “RIGHT DEGREE” POLYNOMIALS

f =

n

k=0

akxk , R(f, x) =

n−1

k=0

akxk , R∗(f, x) = {f, R(f), R(R(f)), . . .} .

slide-34
SLIDE 34

CAD PROJECTION

FILLING THE BLANKS

DEFINITION (PROJECTION)

Given a set of polynomials A = {f1, . . . , fm} ⊂ Z[⃗ y, x], the x-projection of A is P(A, x) = ∪

f∈A

coeff(f, x) ∪ ∪

f∈A g∈ R∗(f,x)

psc(g, g′

x, x) ∪

i<j gi∈ R∗(fi,x) gj∈ R∗(fj,x)

psc(gi, gj, x) .

PRINCIPAL SUBRESULTANT COEFFICIENTS (PSC)

Signs of PSC invariant on S ⇒ degree of gcd invariant on S.

slide-35
SLIDE 35

CAD: MULTIVARIATE SIGN TABLE

PROJECTION: EXTRA POLYNOMIALS

Given a set of polynomials A ⊆ Z[x1, . . . , xn]:

◮ Project variable xn. ◮ Project variable xn−1. ◮ · · ·

slide-36
SLIDE 36

CAD: MULTIVARIATE SIGN TABLE

LIFTING: CONSTRUCT THE SIGN TABLE

Construct the table variable by variable:

◮ Isolate roots of x1, pick a value in an interval. ◮ Isolate roots of x2, pick a value in an interval. ◮ · · ·

slide-37
SLIDE 37

CAD: MULTIVARIATE SIGN TABLE

LIFTING: CONSTRUCT THE SIGN TABLE

Construct the table variable by variable:

◮ Isolate roots of x1, pick a value in an interval. ◮ Isolate roots of x2, pick a value in an interval. ◮ · · ·

slide-38
SLIDE 38

CAD: MULTIVARIATE SIGN TABLE

  • 2
  • 1.5
  • 1
  • 0.5

0.5 1 1.5 2

  • 2
  • 1.5
  • 1
  • 0.5

0.5 1 1.5 2 y x 1 1 1 1

  • 1

1 1 1 1

◮ Polynomial: x2 + y2 − 1. ◮ Projection: x2 − 1.

slide-39
SLIDE 39

OUTLINE

INTRODUCTION LIBPOLY

Working with Polynomials Constructing a Sign Table Cylindrical Algebraic Decomposition

CONCLUSION

slide-40
SLIDE 40

CONCLUSION

A library for non-linear reasoning:

◮ Open source https://github.com/SRI-CSL/libpoly. ◮ Permissive License: LGLP ◮ Ubuntu and Brew packages incoming. ◮ Lightweight: Implemented in C, around 15KLOC. ◮ Only depends on GMP. ◮ Basis for non-linear reasoning in YICES2. ◮ Both for traditional CAD and MCSAT-style CAD.

Thank you!

slide-41
SLIDE 41

CONCLUSION

A library for non-linear reasoning:

◮ Open source https://github.com/SRI-CSL/libpoly. ◮ Permissive License: LGLP ◮ Ubuntu and Brew packages incoming. ◮ Lightweight: Implemented in C, around 15KLOC. ◮ Only depends on GMP. ◮ Basis for non-linear reasoning in YICES2. ◮ Both for traditional CAD and MCSAT-style CAD.

Thank you!