24
FACULTY OF ENGINEERING Finding Bounds on Ehrhart Quasi-Polynomials Harald Devos Jan Van Campenhout Dirk Stroobandt ELIS/PARIS Ghent University Seventh ACES Symposium September 17–18 2007, Edegem

Finding Bounds on Ehrhart Quasi-Polynomials

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Finding Bounds on Ehrhart Quasi-Polynomials

FACULTY OF ENGINEERING

Finding Bounds on Ehrhart Quasi-Polynomials

Harald Devos Jan Van Campenhout Dirk Stroobandt

ELIS/PARISGhent University

Seventh ACES SymposiumSeptember 17–18 2007, Edegem

Page 2: Finding Bounds on Ehrhart Quasi-Polynomials

Outline

1 IntroductionWhat are (Ehrhart) quasi-polynomials?Where do they arise?Why do we need bounds on quasi-polynomials?

2 How do we find bounds?Continuous versus discrete domain extrema of polynomialsConverting quasi-polynomials into polynomials

3 Conclusions and Future Work

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 2 / 19

Page 3: Finding Bounds on Ehrhart Quasi-Polynomials

Outline

1 IntroductionWhat are (Ehrhart) quasi-polynomials?Where do they arise?Why do we need bounds on quasi-polynomials?

2 How do we find bounds?Continuous versus discrete domain extrema of polynomialsConverting quasi-polynomials into polynomials

3 Conclusions and Future Work

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 3 / 19

Page 4: Finding Bounds on Ehrhart Quasi-Polynomials

Periodic Numbers

Example

0 1 2 3 4 5 6 7 8n

0123456u(n)

u(n) = [3, 1, 4]n

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 4 / 19

Page 5: Finding Bounds on Ehrhart Quasi-Polynomials

Periodic Numbers

DefinitionLet n be a discrete variable, i.e. n ∈ Z. A 1-dimensional periodic numberis a function that depends periodically on n.

u(n) = [u0, u1, . . . , ud−1]n =

u0 if n ≡ 0 (mod d)

u1 if n ≡ 1 (mod d)...

ud−1 if n ≡ d − 1 (mod d)

d is called the period.

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 5 / 19

Page 6: Finding Bounds on Ehrhart Quasi-Polynomials

Quasi-Polynomials

Example

f (n) = −[

12 , 1

3

]nn2 + 3n − [1, 2]n

=

{− 1

3n2 + 3n − 2 if n ≡ 0 (mod 2)

− 12n2 + 3n − 1 if n ≡ 1 (mod 2)

0 1 2 3 4 5 6 7n

−3

−2

−1

0

1

2

3

4

5

f(n

)=

[

1 2,

1 3

]

n

n2+

3n−

[1,2

] n

1

2n2 + 3n − 1

1

3n2 + 3n − 2

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 6 / 19

Page 7: Finding Bounds on Ehrhart Quasi-Polynomials

Quasi-Polynomials

DefinitionA polynomial in a variable x is a linear combination of powers of x :

f (x) =

g∑i=0

cixi

DefinitionA quasi-polynomial in a variable x is a polynomial expression withperiodic numbers as coefficients:

f (n) =

g∑i=0

ui (n)ni

with ui (n) periodic numbers.

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 7 / 19

Page 8: Finding Bounds on Ehrhart Quasi-Polynomials

Quasi-Polynomials

DefinitionA polynomial in a variable x is a linear combination of powers of x :

f (x) =

g∑i=0

cixi

DefinitionA quasi-polynomial in a variable x is a polynomial expression withperiodic numbers as coefficients:

f (n) =

g∑i=0

ui (n)ni

with ui (n) periodic numbers.

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 7 / 19

Page 9: Finding Bounds on Ehrhart Quasi-Polynomials

Outline

1 IntroductionWhat are (Ehrhart) quasi-polynomials?Where do they arise?Why do we need bounds on quasi-polynomials?

2 How do we find bounds?Continuous versus discrete domain extrema of polynomialsConverting quasi-polynomials into polynomials

3 Conclusions and Future Work

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 8 / 19

Page 10: Finding Bounds on Ehrhart Quasi-Polynomials

Where do Quasi-Polynomials arise?

Example

0 1 2 3 4 5 6 7x

0

1

2

3

4

5

6

7

y

p =3

x + y ≤ p

p f (p)3 5

4 85 106 13

5

2p +

[−2,

−5

2

]p

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 9 / 19

Page 11: Finding Bounds on Ehrhart Quasi-Polynomials

Where do Quasi-Polynomials arise?

Example

0 1 2 3 4 5 6 7x

0

1

2

3

4

5

6

7

y

p =4

x + y ≤ p

p f (p)3 54 8

5 106 13

5

2p +

[−2,

−5

2

]p

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 9 / 19

Page 12: Finding Bounds on Ehrhart Quasi-Polynomials

Where do Quasi-Polynomials arise?

Example

0 1 2 3 4 5 6 7x

0

1

2

3

4

5

6

7

y

p =5

x + y ≤ p

p f (p)3 54 85 10

6 13

5

2p +

[−2,

−5

2

]p

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 9 / 19

Page 13: Finding Bounds on Ehrhart Quasi-Polynomials

Where do Quasi-Polynomials arise?

Example

0 1 2 3 4 5 6 7x

0

1

2

3

4

5

6

7

y

p =6

x + y ≤ p

p f (p)3 54 85 106 13

5

2p +

[−2,

−5

2

]p

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 9 / 19

Page 14: Finding Bounds on Ehrhart Quasi-Polynomials

Where do Quasi-Polynomials arise?

Example

0 1 2 3 4 5 6 7x

0

1

2

3

4

5

6

7

y

p =6

x + y ≤ p

p f (p)3 54 85 106 13

5

2p +

[−2,

−5

2

]p

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 9 / 19

Page 15: Finding Bounds on Ehrhart Quasi-Polynomials

Where do Quasi-Polynomials arise?

The number of integer points in a parametric polytope Pp ofdimension n is expressed as a piecewise a quasi-polynomial of degreen in p (Clauss and Loechner).

More general polyhedral counting problems:Systems of linear inequalities combined with ∨,∧,¬,∀, or ∃(Presburger formulas).

Many problems in static program analysis can be expressed aspolyhedral counting problems.

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 10 / 19

Page 16: Finding Bounds on Ehrhart Quasi-Polynomials

Outline

1 IntroductionWhat are (Ehrhart) quasi-polynomials?Where do they arise?Why do we need bounds on quasi-polynomials?

2 How do we find bounds?Continuous versus discrete domain extrema of polynomialsConverting quasi-polynomials into polynomials

3 Conclusions and Future Work

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 11 / 19

Page 17: Finding Bounds on Ehrhart Quasi-Polynomials

Why do we need bounds on quasi-polynomials?

Some problems in static program analysis need bounds onquasi-polynomials.

Example

Number of live elements = quasi-polynomial⇓

Memory usage = maximum over all execution points

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 12 / 19

Page 18: Finding Bounds on Ehrhart Quasi-Polynomials

Outline

1 IntroductionWhat are (Ehrhart) quasi-polynomials?Where do they arise?Why do we need bounds on quasi-polynomials?

2 How do we find bounds?Continuous versus discrete domain extrema of polynomialsConverting quasi-polynomials into polynomials

3 Conclusions and Future Work

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 13 / 19

Page 19: Finding Bounds on Ehrhart Quasi-Polynomials

Continuous vs. Discrete domain extrema of polynomials

Discrete domain ⇒ evaluate in each pointNot possible for

parametric domains

large domains (NP-complete)

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 14 / 19

Page 20: Finding Bounds on Ehrhart Quasi-Polynomials

Continuous vs. Discrete domain extrema of polynomials

0 1 2 3 4n

0

1

2

3

4

5

6

f(n

)=

1 3n

3−

2n2+

5 3n

+5 F c

Fd

Fd

F c

The relative difference issmaller for

I larger intervalsI lower degree

⇒ Continuous-domain extremacan be used as approximationof discrete-domain extrema.

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 15 / 19

Page 21: Finding Bounds on Ehrhart Quasi-Polynomials

Outline

1 IntroductionWhat are (Ehrhart) quasi-polynomials?Where do they arise?Why do we need bounds on quasi-polynomials?

2 How do we find bounds?Continuous versus discrete domain extrema of polynomialsConverting quasi-polynomials into polynomials

3 Conclusions and Future Work

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 16 / 19

Page 22: Finding Bounds on Ehrhart Quasi-Polynomials

How: Mod Classes

Example

0 1 2 3 4 5 6 7n

−2

−1

0

1

2

3

4

5f(n)

f0 = −

1

2n2 + 3n − 1

f1 = −

1

3n2 + 3n − 2F c

Fd

F c = Fd

Good for

small period

large domains

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 17 / 19

Page 23: Finding Bounds on Ehrhart Quasi-Polynomials

How: Other Methods

Other methods

needed for large periods

offer trade-off betweenaccuracy andcomputation time

see poster

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 18 / 19

Page 24: Finding Bounds on Ehrhart Quasi-Polynomials

Conclusions and Future Work

Bounds on quasi-polynomials useful for static program analysis

Different methods fit different situations (period, degree, domainsize).

OutlookI A hybrid method should be constructed.I Parametric bounds on parameterized quasi-polynomials

H. Devos et al. (Ghent University) Finding Bounds on Ehrhart Quasi-Polynomials ACES’07, Edegem 19 / 19