inferring polynomial invariants - with polyinvar
TRANSCRIPT
![Page 1: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/1.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Inferring polynomial invariantswith Polyinvar
Helmut Seidl and Michael Petter
TU-Munchen
Chair Workshop, 2005
![Page 2: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/2.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Problem:
y := y + 1
x := 0
y := 0
skip
(y − n 6= 0)
7
2
3
1
4
5
6
x := y · y + x
skip
Question
Is x = y valid at program point 3?
Question
What relation holds at program point 7?
⇒ Polynomial invariants
![Page 3: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/3.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Problem:
y := y + 1
x := 0
y := 0
skip
(y − n 6= 0)
7
2
3
1
4
5
6
x := y · y + x
skip
Question
Is x = y valid at program point 3?
Question
What relation holds at program point 7?
⇒ Polynomial invariants
![Page 4: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/4.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Problem:
y := y + 1
x := 0
y := 0
skip
(y − n 6= 0)
7
2
3
1
4
5
6
x := y · y + x
skip
Question
Is x = y valid at program point 3?
Question
What relation holds at program point 7?
⇒ Polynomial invariants
![Page 5: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/5.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Problem:
y := y + 1
x := 0
y := 0
skip
(y − n 6= 0)
7
2
3
1
4
5
6
x := y · y + x
skip
Question
Is x = y valid at program point 3?
Question
What relation holds at program point 7?
⇒ Polynomial invariants
![Page 6: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/6.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Valid invariants:
y := y + 1
x := 0
y := 0
x := y · y + x
(y − n 6= 0)
7
2
3
1
4
5
6
skip2y3 + 3y2 + y − 6x = 0
x = 0
2y3 + 3y2 + y − 6x = 0
skip2y3 + 3y2 + y − 6x = 0
2y3 + 3y2 + y − 6x = 0
2y3 − 3y2 + y − 6x = 0
Power sum
The example programcalculates the square powersum x =
∑ny=0 y2, therefore
x =2y3 + 3y2 + y
6
holds at program point 7
Question
⇒ but how to automate thiscognition?
![Page 7: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/7.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Valid invariants:
y := y + 1
x := 0
y := 0
x := y · y + x
(y − n 6= 0)
7
2
3
1
4
5
6
skip2y3 + 3y2 + y − 6x = 0
x = 0
2y3 + 3y2 + y − 6x = 0
skip2y3 + 3y2 + y − 6x = 0
2y3 + 3y2 + y − 6x = 0
2y3 − 3y2 + y − 6x = 0
Power sum
The example programcalculates the square powersum x =
∑ny=0 y2, therefore
x =2y3 + 3y2 + y
6
holds at program point 7
Question
⇒ but how to automate thiscognition?
![Page 8: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/8.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Related work
Approaches with ideals
E.RC, D.K. Program Verification Using Automatic GenerationOf Invariants
2004
M.MO, H.S. Computing Polynomial Program Invariants 2004
S.S., H.B.S., Z.M. Non-linear Loop Invariant Generation 2004
Approach with modules
M.P. Berechnung von polynomiellen Invarianten 2004
Initial point
Interpret program states as Ideals of polynomials;Store generators of the ideal as representation → M.MO., H.S.
![Page 9: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/9.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Related work
Approaches with ideals
E.RC, D.K. Program Verification Using Automatic GenerationOf Invariants
2004
M.MO, H.S. Computing Polynomial Program Invariants 2004
S.S., H.B.S., Z.M. Non-linear Loop Invariant Generation 2004
Approach with modules
M.P. Berechnung von polynomiellen Invarianten 2004
Initial point
Interpret program states as Ideals of polynomials;Store generators of the ideal as representation → M.MO., H.S.
![Page 10: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/10.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Abstract Model
Polynomial programs...
• modelling control flow with (possibly annotated) edges
• assignments of multivariate polynomial expressions (withoutdivision) x := y · y + x
• method calls x := f (y , z)
• unknown assignments x :=?
... with guards
• negative polynomial equality guards (y − n) 6= 0
• positive polynomial equality guards (y − n) = 0
• non deterministic choice for the rest skip
→ Goal: inferring all valid polynomial relations
![Page 11: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/11.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Abstract Model
Polynomial programs...
• modelling control flow with (possibly annotated) edges
• assignments of multivariate polynomial expressions (withoutdivision) x := y · y + x
• method calls x := f (y , z)
• unknown assignments x :=?
... with guards
• negative polynomial equality guards (y − n) 6= 0
• positive polynomial equality guards (y − n) = 0
• non deterministic choice for the rest skip
→ Goal: inferring all valid polynomial relations
![Page 12: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/12.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Abstract Model
Polynomial programs...
• modelling control flow with (possibly annotated) edges
• assignments of multivariate polynomial expressions (withoutdivision) x := y · y + x
• method calls x := f (y , z)
• unknown assignments x :=?
... with guards
• negative polynomial equality guards (y − n) 6= 0
• positive polynomial equality guards (y − n) = 0
• non deterministic choice for the rest skip
→ Goal: inferring all valid polynomial relations
![Page 13: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/13.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Abstract Model
Polynomial programs...
• modelling control flow with (possibly annotated) edges
• assignments of multivariate polynomial expressions (withoutdivision) x := y · y + x
• method calls x := f (y , z)
• unknown assignments x :=?
... with guards
• negative polynomial equality guards (y − n) 6= 0
• positive polynomial equality guards (y − n) = 0
• non deterministic choice for the rest skip
→ Goal: inferring all valid polynomial relations
![Page 14: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/14.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Intraprocedural example
squarepowsum (n ∈ N) ∈ N {x, y ∈ N;x ⇐ 0, y ⇐ 0;while (y 6= n){
y ⇐ y + 1;x ⇐ y · y + x;
}return x;
}
State abstraction
Still, we have to find an abstraction forprogram states that serves our analysis...
y := y + 1
skip
(y − n 6= 0)
7
2
3
1
4
5
6
x := y · y + x
(y − n = 0)
x := 0; y := 0
n :=?
![Page 15: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/15.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Intraprocedural example
squarepowsum (n ∈ N) ∈ N {x, y ∈ N;x ⇐ 0, y ⇐ 0;while (y 6= n){
y ⇐ y + 1;x ⇐ y · y + x;
}return x;
}
State abstraction
Still, we have to find an abstraction forprogram states that serves our analysis...
y := y + 1
skip
(y − n 6= 0)
7
2
3
1
4
5
6
x := y · y + x
(y − n = 0)
x := 0; y := 0
n :=?
![Page 16: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/16.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
State abstraction
Polynomials
Polynomials are expressed by equations from the set R[X], polynomialsover R and the variables from X, for example x − y2 + 25 = 0.
Polynomial relations
1 ∀PR[s]⊆R[X] ∃p∈PR[s] ∀c∈R∪X ⇒ c · p ∈ PR[s]
2 ∀PR[s]⊆R[X] ∃p∈PR[s] ∀q∈PR[s],◦∈{+,−,·} ⇒ q ◦ p ∈ PR[s]
Polynomial ideals – finitely generated
Polynomial ideals are infinite sets of polynomials, with the upperproperties. All ideals can be represented by a minimal number ofgenerating polynomials.For example 〈{x − y2 + 25, x2 − z}〉
![Page 17: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/17.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Verifying polynomial relations
y := y + 1
x := 0
y := 0
(y − n 6= 0)
7
2
3
1
4
5
6
x := y · y + x
〈2y3 + 3y2 + y − 6x〉
skip
(y − n = 0)
Fixpoint analysis
Associating program states withpolynomial ideals.
Verifing polynomials
Computing the weakest preconditionfor a polynomial invariant ideal
Weakest precondition
The only valid precondition can onlybe the relation 0 = 0.
![Page 18: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/18.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Incremental fixpoint iteration: semantics
xj :=?
PRt
s
{qi | qi = coeffs(q, xij )}
PR′
xj := p
PRt
s
q[p/xj ]
PR′
skip
t
s
PR
PR′
q
(p = 0)
PRt
s
q + ae · p
PR′
(p 6= 0)
PRt
s
p · q
PR′
xi = f (x)
t
s
PR
?
?
![Page 19: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/19.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Incremental fixpoint iteration: semantics
xj :=?
PRt
s
{qi | qi = coeffs(q, xij )}
PR′
xj := p
PRt
s
q[p/xj ]
PR′
skip
t
s
PR
PR′
q
(p = 0)
PRt
s
q + ae · p
PR′
(p 6= 0)
PRt
s
p · q
PR′
xi = f (x)
t
s
PR
?
?
Propagate only new generators – incremental iteration
Recalculation of ideals at each iteration step is expensive⇒ Only new generators q have to be propagated via edges.
![Page 20: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/20.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Verifying polynomial relations
y := y + 1
x := 0
y := 0
(y − n 6= 0)
7
2
3
1
4
5
6
x := y · y + x
〈2y3 + 3y2 + y − 6x〉
skip
(y − n = 0)
Fixpoint analysis
Associating program states withpolynomial ideals.
Verifing polynomials
Computing the weakest preconditionfor a polynomial invariant ideal
Weakest precondition
The only valid precondition can onlybe the relation 0 = 0.
![Page 21: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/21.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Verifying polynomial relations
y := y + 1
x := 0
y := 0
(y − n 6= 0)
7
2
3
1
4
5
6
x := y · y + x
〈2y3 + 3y2 + y − 6x〉
skip
(y − n = 0)
Fixpoint analysis
Associating program states withpolynomial ideals.
Verifing polynomials
Computing the weakest preconditionfor a polynomial invariant ideal
Weakest precondition
The only valid precondition can onlybe the relation 0 = 0.
![Page 22: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/22.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Verifying polynomial relations
y := y + 1
x := 0
y := 0
(y − n 6= 0)
7
2
3
1
4
5
6
x := y · y + x
〈2y3 + 3y2 + y − 6x〉(y − n = 0)
skip
〈2y3 + 3y2 + y − 6x〉
〈2y3 + 3y2 + y − 6x〉
Fixpoint analysis
Associating program states withpolynomial ideals.
Verifing polynomials
Computing the weakest preconditionfor a polynomial invariant ideal
Weakest precondition
The only valid precondition can onlybe the relation 0 = 0.
![Page 23: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/23.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Verifying polynomial relations
y := y + 1
x := 0
y := 0
(y − n 6= 0)
7
2
3
1
4
5
6
x := y · y + x
〈2y3 + 3y2 + y − 6x〉(y − n = 0)
skip
〈2y3 + 3y2 + y − 6x〉
〈2y3 + 3y2 + y − 6x〉
〈2y3 − 3y2 + y − 6x〉
〈x〉 Fixpoint analysis
Associating program states withpolynomial ideals.
Verifing polynomials
Computing the weakest preconditionfor a polynomial invariant ideal
Weakest precondition
The only valid precondition can onlybe the relation 0 = 0.
![Page 24: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/24.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Verifying polynomial relations
y := y + 1
x := 0
y := 0
(y − n 6= 0)
7
2
3
1
4
5
6
x := y · y + x
〈2y3 + 3y2 + y − 6x〉(y − n = 0)
skip
〈2y3 + 3y2 + y − 6x〉
〈2y3 + 3y2 + y − 6x〉
〈2y3 − 3y2 + y − 6x〉
〈x〉
〈0〉
〈2y3 + 3y2 + y − 6x〉
Fixpoint analysis
Associating program states withpolynomial ideals.
Verifing polynomials
Computing the weakest preconditionfor a polynomial invariant ideal
Weakest precondition
The only valid precondition can onlybe the relation 0 = 0.
![Page 25: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/25.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Verifying polynomial relations
y := y + 1
x := 0
y := 0
(y − n 6= 0)
7
2
3
1
4
5
6
x := y · y + x
〈2y3 + 3y2 + y − 6x〉(y − n = 0)
skip
〈2y3 + 3y2 + y − 6x〉
〈2y3 + 3y2 + y − 6x〉
〈2y3 − 3y2 + y − 6x〉
〈x〉
〈0〉
〈2y3 + 3y2 + y − 6x〉
Fixpoint analysis
Associating program states withpolynomial ideals.
Verifing polynomials
Computing the weakest preconditionfor a polynomial invariant ideal
Weakest precondition
The only valid precondition can onlybe the relation 0 = 0.
![Page 26: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/26.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Verifying polynomial relations
y := y + 1
x := 0
y := 0
(y − n 6= 0)
7
2
3
1
4
5
6
x := y · y + x
〈2y3 + 3y2 + y − 6x〉(y − n = 0)
skip
〈2y3 + 3y2 + y − 6x〉
〈2y3 + 3y2 + y − 6x〉
〈2y3 − 3y2 + y − 6x〉
〈x〉
〈0〉
〈2y3 + 3y2 + y − 6x〉
Fixpoint analysis
Associating program states withpolynomial ideals.
Verifing polynomials
Computing the weakest preconditionfor a polynomial invariant ideal
Weakest precondition
The only valid precondition can onlybe the relation 0 = 0.
![Page 27: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/27.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Infering polynomial relations
y := y + 1
x := 0
y := 0
(y − n 6= 0)
7
2
3
1
4
5
6
x := y · y + x
〈ax2 + by2 + cxy + dx + ey + f 〉
skip
(y − n = 0)
Weakest precondition
Evaluating the WP provides valuesfor the generic parameters
Inferring relations
The weakest precondition for ageneric polynomial of degree n. E.g:∑
0≤i1+...+ik≤d
ai1,...,ik · x1i1 · . . . · xk
ik
![Page 28: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/28.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Infering polynomial relations
y := y + 1
x := 0
y := 0
(y − n 6= 0)
7
2
3
1
4
5
6
x := y · y + x
〈ax2 + by2 + cxy + dx + ey + f 〉
skip
(y − n = 0)
〈a + b, b, a− c + d , 2d + a, c − e, f 〉
Weakest precondition
Evaluating the WP provides valuesfor the generic parameters
Inferring relations
The weakest precondition for ageneric polynomial of degree n. E.g:∑
0≤i1+...+ik≤d
ai1,...,ik · x1i1 · . . . · xk
ik
![Page 29: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/29.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Performance issues
Bad news
• Reductions on polynomial ideals are perform doubly exponentially on thenumber of participating variables.
• Ideal membership is in general EXPSPACE-hard
• Ideal membership is NP-hard for fixed number of variables
O Problem
Using generic polynomials with many variables turns polynomial reductionsinfeasible.
⇒ Observation: Generic variables don’t occur in programs, merely model thestructure of invariants; they also contribute linear to the polynomials
O Idea
Mark generic variables for special treatment in the reduction algorithm.⇒ Model of vectors and Modules
![Page 30: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/30.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Performance issues
Bad news
• Reductions on polynomial ideals are perform doubly exponentially on thenumber of participating variables.
• Ideal membership is in general EXPSPACE-hard
• Ideal membership is NP-hard for fixed number of variables
O Problem
Using generic polynomials with many variables turns polynomial reductionsinfeasible.
⇒ Observation: Generic variables don’t occur in programs, merely model thestructure of invariants; they also contribute linear to the polynomials
O Idea
Mark generic variables for special treatment in the reduction algorithm.⇒ Model of vectors and Modules
![Page 31: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/31.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Performance issues
Bad news
• Reductions on polynomial ideals are perform doubly exponentially on thenumber of participating variables.
• Ideal membership is in general EXPSPACE-hard
• Ideal membership is NP-hard for fixed number of variables
O Problem
Using generic polynomials with many variables turns polynomial reductionsinfeasible.
⇒ Observation: Generic variables don’t occur in programs, merely model thestructure of invariants; they also contribute linear to the polynomials
O Idea
Mark generic variables for special treatment in the reduction algorithm.⇒ Model of vectors and Modules
![Page 32: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/32.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Interprocedural example
squarepowsum (n ∈ N) ∈ N {x, y ∈ N;x ⇐ 0, y ⇐ 0;while (y 6= n){
y ⇐ y + 1;x ⇐ sqr(y) + x;
}return x;
}sqr (x ∈ N) ∈ N {
return x · x;}
9
8return := x · x
sqr(x)
y := y + 1
skip
(y − n 6= 0)
7
2
3
1
4
5
6
x := sqr(y) + x
(y − n = 0)
x := 0; y := 0
n :=?
squarepowsum(n)
![Page 33: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/33.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Incremental fixpoint iteration: semantics
xj :=?
PRt
s
{qi | qi = coeffs(q, xij )}
PR′
xj := p
PRt
s
q[p/xj ]
PR′
skip
t
s
PR
PR′
q
(p = 0)
PRt
s
q + ae · p
PR′
(p 6= 0)
PRt
s
p · q
PR′
xi = f (x)
t
s
PR
?
?
![Page 34: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/34.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Method call details
Idea
Use precomputed templates to carry the effect of each method call.
f
y1 = f (y2, y3)
t
s f (x1, x2)
f´〈ax1 + bx2 + c · return + d〉
〈ax1 + bx2 + c(x1 + x2) + d〉
〈(a + b + d − 3c)y2 + ay3 + d〉
〈(a − c)y1 + (b + d − 2c)y2 + cy3 + d〉
→ But: Has yet to be implemented
![Page 35: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/35.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Method call details
Idea
Use precomputed templates to carry the effect of each method call.
f
y1 = f (y2, y3)
t
s f (x1, x2)
f´〈ax1 + bx2 + c · return + d〉
〈ax1 + bx2 + c(x1 + x2) + d〉
〈(a + b + d − 3c)y2 + ay3 + d〉
〈(a − c)y1 + (b + d − 2c)y2 + cy3 + d〉
→ But: Has yet to be implemented
![Page 36: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/36.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Complete analysisSet fixpointiteration (Node ut , Vector vt ,Set Vars, Set Edges,Set Nodes) {
Set [] G ⇐ new Set[|Nodes|];forall (u ∈ Nodes) G [u] ⇐ ∅;Set W ⇐ {(vt , ut)};while (W 6= ∅) {
(v , t) ⇐ extract(W );v ⇐ reduce(v ,G [t]);if (v 6= 0) {
G [t] ⇐ G [t] ∪ {v};forall ( (s, ′′skip;′′ , t) ∈ Edges)
W ⇐ W ∪ {(v , s)};forall ( (s, ′′xj := p′′ , t) ∈ Edges)
W ⇐ W ∪ {(v [p/xj ], s)};forall ( (s, ′′(p 6= 0)′′ , t) ∈ Edges)
W ⇐ W ∪ {(p · v , s)};forall ( (s, ′′xj :=?′′ , t) ∈ Edges)
let l = max({i|ax i ∈ monoms(v )})in let v ⇒ (p00
x0j + . . . + p0l
x lj , . . . , pk0
x0j + . . . + pkl
x lj )
in let vi ⇐ (p0i, p1i
, . . . , pki)
in W ⇐ W ∪ {(v0, u), . . . , (vl , u)};}
}return 〈G [ustart ]〉;
}
![Page 37: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/37.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Benchmarks
Name Calculation ass-deg Invariant Time
geoSeries1 x = (z − 1) ·PK
k=0 zk y = zK ≤ 2 x = y − 1 0, 356s
geoSeries2 x =PK
k=0 zk y = zK−1 ≤ 2 x · (z − 1) = yz − 1 0, 569s
geoSeries3 x =PK
k=0 a · zk y = zK−1 ≤ 2 x · (z − 1) = azy − a 1, 47s
Name Calculation ass-deg Invariant Time
powSum1 x =PK
k=0 1 y =PK
k=0 1 ≤ 1 x = y 0, 331s
powSum2 x =PK
k=0 k y =PK
k=0 1 ≤ 1 2x = y2 + y 0, 776s
powSum3 x =PK
k=0 k2 y =PK
k=0 1 ≤ 2 6x = 2y3 + 3y2 + y 1, 47s
powSum4 x =PK
k=0 k3 y =PK
k=0 1 ≤ 3 4x = y4 + 2y3 + y2 2, 71s
powSum5 x =PK
k=0 k4 y =PK
k=0 1 ≤ 4 30x = 6y5 + 15y4 + 10y3 − y 10, 3s
powSum6 x =PK
k=0 k5 y =PK
k=0 1 ≤ 5 12x = 2y6 + 6y5 + 5y4 − y2 787, 2s
Strategy gs3/5 gs3/6 ps3/5 ps4/5 ps4/6 ps5/5 ps5/6 ps6/6Original vector 8,4s 29,4s 3,83s 14,7s . . .Reduced vector 7,3s 26,6s 2,9s 3,5s 8,1s 10,9s 30,0s 787s
![Page 38: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/38.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Future Work
Implementation
• Treatment of procedure calls
• Scope on relevant variables
• Face large/real examples
Theory
Find a better upper complexity bound
=⇒ http://www2.cs.tum.edu/∼petter/polyinvar
![Page 39: Inferring polynomial invariants - with Polyinvar](https://reader035.vdocuments.mx/reader035/viewer/2022071612/6156f7b6a097e25c764f8188/html5/thumbnails/39.jpg)
Motivation Model Intraprocedural analysis Interprocedural analysis Conclusion
Thank You for Your attention!