Overview Motivation Real Algebraic Numbers Well-Definedness - - PowerPoint PPT Presentation

overview
SMART_READER_LITE
LIVE PREVIEW

Overview Motivation Real Algebraic Numbers Well-Definedness - - PowerPoint PPT Presentation

Algebraic Numbers in Isabelle/HOL 1 Ren e Thiemann and Akihisa Yamada Institute of Computer Science University of Innsbruck ITP 2016, August 23, 2016 1 Supported by the Austrian Science Fund (FWF) project Y757 Overview Motivation Real


slide-1
SLIDE 1

Algebraic Numbers in Isabelle/HOL1

Ren´ e Thiemann and Akihisa Yamada

Institute of Computer Science University of Innsbruck

ITP 2016, August 23, 2016

1Supported by the Austrian Science Fund (FWF) project Y757

slide-2
SLIDE 2

Overview

Motivation Real Algebraic Numbers Well-Definedness Calculating Real Roots of Rational Polynomial Factorizing Rational Polynomial Arithmetic on Real Algebraic Numbers Complex Algebraic Numbers

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 2/22

slide-3
SLIDE 3

Motivation

Certify Complexity of Matrix Interpretations

  • given: automatically generated complexity proof for program

χA = (x − 1) · (−39 + 360x − 832x2 + 512x3)

  • criterions
  • polynomial complexity if norms of all complex roots of χA 1
  • degree d in O(nd): more calculations with complex roots of χA

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 3/22

slide-4
SLIDE 4

Motivation

Certify Complexity of Matrix Interpretations

  • given: automatically generated complexity proof for program

χA = (x − 1) · (−39 + 360x − 832x2 + 512x3)

  • criterions
  • polynomial complexity if norms of all complex roots of χA 1
  • degree d in O(nd): more calculations with complex roots of χA
  • problem: certifier crashed as numbers got too complicated

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 3/22

slide-5
SLIDE 5

Motivation

Closed Form for Cubic Polynomials

  • −39 + 360x − 832x2 + 512x3 = 0 iff
  • x =

1 24

  • 13 +

34

3

91+9i √ 383 +

3

  • 91 + 9i

√ 383

  • ,
  • x = 13

24 − 17(1+i √ 3) 24

3

91+9i √ 383 − 1 48

  • 1 − i

√ 3)

  • 3
  • 91 + 9i

√ 383, or

  • x = 13

24 − 17(1−i √ 3) 24

3

91+9i √ 383 − 1 48

  • 1 + i

√ 3)

  • 3
  • 91 + 9i

√ 383

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 4/22

slide-6
SLIDE 6

Motivation

Closed Form for Cubic Polynomials

  • −39 + 360x − 832x2 + 512x3 = 0 iff
  • x1 =

1 24

  • 13 +

34

3

91+9i √ 383 +

3

  • 91 + 9i

√ 383

  • ,
  • x2 = 13

24 − 17(1+i √ 3) 24

3

91+9i √ 383 − 1 48

  • 1 − i

√ 3)

  • 3
  • 91 + 9i

√ 383, or

  • x3 = 13

24 − 17(1−i √ 3) 24

3

91+9i √ 383 − 1 48

  • 1 + i

√ 3)

  • 3
  • 91 + 9i

√ 383

  • problem: calculate and decide

norm(xj) =

  • Re(xj)2 + Im(xj)2 1

for all j ∈ {1, 2, 3}

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 4/22

slide-7
SLIDE 7

Motivation

Closed Form for Cubic Polynomials

  • −39 + 360x − 832x2 + 512x3 = 0 iff
  • x1 =

1 24

  • 13 +

34

3

91+9i √ 383 +

3

  • 91 + 9i

√ 383

  • ,
  • x2 = 13

24 − 17(1+i √ 3) 24

3

91+9i √ 383 − 1 48

  • 1 − i

√ 3)

  • 3
  • 91 + 9i

√ 383, or

  • x3 = 13

24 − 17(1−i √ 3) 24

3

91+9i √ 383 − 1 48

  • 1 + i

√ 3)

  • 3
  • 91 + 9i

√ 383

  • problem: calculate and decide

norm(xj) =

  • Re(xj)2 + Im(xj)2 1

for all j ∈ {1, 2, 3}

  • problem: no closed form for roots of polynomials of degree 5

and higher

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 4/22

slide-8
SLIDE 8

Motivation

Algebraic Numbers

  • number x ∈ R ∪ C is algebraic iff it is root of non-zero

rational polynomial

  • x1 = “root #1 of −39 + 360x − 832x2 + 512x3”
  • x2 = “root #2 of −39 + 360x − 832x2 + 512x3”
  • x3 = “root #3 of −39 + 360x − 832x2 + 512x3”

Figure: −39 + 360x − 832x2 + 512x3

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 5/22

slide-9
SLIDE 9

Motivation

Problems with Algebraic Numbers

  • well-definedness

is there a “root #3 of −23 + x − 5x2 + x3”

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 6/22

slide-10
SLIDE 10

Motivation

Problems with Algebraic Numbers

  • well-definedness

is there a “root #3 of −23 + x − 5x2 + x3”

  • representation

is there a simpler representation of “root #3 of −108 − 72x + 108x2 + 84x3 − 27x4 − 32x5 − 2x6 + 4x7 + x8”

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 6/22

slide-11
SLIDE 11

Motivation

Problems with Algebraic Numbers

  • well-definedness

is there a “root #3 of −23 + x − 5x2 + x3”

  • representation

is there a simpler representation of “root #3 of −108 − 72x + 108x2 + 84x3 − 27x4 − 32x5 − 2x6 + 4x7 + x8”

  • comparisons

is “root #3 of −39 + 360x − 832x2 + 512x3” smaller than 1

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 6/22

slide-12
SLIDE 12

Motivation

Problems with Algebraic Numbers

  • well-definedness

is there a “root #3 of −23 + x − 5x2 + x3”

  • representation

is there a simpler representation of “root #3 of −108 − 72x + 108x2 + 84x3 − 27x4 − 32x5 − 2x6 + 4x7 + x8”

  • comparisons

is “root #3 of −39 + 360x − 832x2 + 512x3” smaller than 1

  • arithmetic

calculate a polynomial representing “root #2 of −2 + x2” + “root #1 of −3 + x2”

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 6/22

slide-13
SLIDE 13

Motivation

Problems with Algebraic Numbers

  • well-definedness

Sturm’s method is there a “root #3 of −23 + x − 5x2 + x3”

  • representation

factorization of rational polynomials is there a simpler representation of “root #3 of −108 − 72x + 108x2 + 84x3 − 27x4 − 32x5 − 2x6 + 4x7 + x8”

  • comparisons

Sturm’s method is “root #3 of −39 + 360x − 832x2 + 512x3” smaller than 1

  • arithmetic

matrices, determinants, resultants, . . . calculate a polynomial representing “root #2 of −2 + x2” + “root #1 of −3 + x2”

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 6/22

slide-14
SLIDE 14

Motivation

Main Result: Formalization of Algebraic Numbers

  • common properties on algebraic numbers (R and C)
  • executable real algebraic numbers
  • executable complex algebraic numbers indirectly
  • easy to use via data-refinement for R and C

⌊norm(

  • 3

√ 2 + 3 + 2i) · 100⌋

evaluate

֒ → 216

  • applicable inside (eval) and outside Isabelle (export-code)

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 7/22

slide-15
SLIDE 15

Motivation

Related work

  • Cyril Cohen (ITP 2012)
  • Coq
  • similar, but partly based on different paper proofs
  • our work: more focus on efficient execution

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 8/22

slide-16
SLIDE 16

Motivation

Related work

  • Cyril Cohen (ITP 2012)
  • Coq
  • similar, but partly based on different paper proofs
  • our work: more focus on efficient execution
  • Wenda Li and Larry Paulson (CPP 2016)
  • independant Isabelle/HOL formalization, different approach
  • oracle (MetiTarski) performs computations
  • certified code validates results

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 8/22

slide-17
SLIDE 17

Motivation

Related work

  • Cyril Cohen (ITP 2012)
  • Coq
  • similar, but partly based on different paper proofs
  • our work: more focus on efficient execution
  • Wenda Li and Larry Paulson (CPP 2016)
  • independant Isabelle/HOL formalization, different approach
  • oracle (MetiTarski) performs computations
  • certified code validates results
  • experimental comparison (examples of Li and Paulson)

MetiTarski 1.83 seconds (@ 2.66 Ghz) + validation of Li and Paulson 4.16 seconds (@ 2.66 Ghz) Our generated Haskell code 0.03 seconds (@ 3.5 Ghz)

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 8/22

slide-18
SLIDE 18

Real Algebraic Numbers Well-Definedness

Well-Definedness

  • “root #3 of −23 + x − 5x2 + x3”
  • “root #3 of −25 + 155x − 304x2 + 192x3”

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 9/22

slide-19
SLIDE 19

Real Algebraic Numbers Well-Definedness

Sturm’s Method

  • input
  • polynomial over R
  • interval ( [2, 5], (−π, 7], (−∞, 3), or (−∞, +∞) )
  • output: count-roots p itval
  • number of distinct real roots of p in interval itval

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 10/22

slide-20
SLIDE 20

Real Algebraic Numbers Well-Definedness

Sturm’s Method

  • input
  • polynomial over R
  • interval ( [2, 5], (−π, 7], (−∞, 3), or (−∞, +∞) )
  • output: count-roots p itval
  • number of distinct real roots of p in interval itval
  • formalized in Isabelle by Manuel Eberl
  • nearly used as black-box

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 10/22

slide-21
SLIDE 21

Real Algebraic Numbers Well-Definedness

Sturm’s Method

  • input
  • polynomial over R
  • interval ( [2, 5], (−π, 7], (−∞, 3), or (−∞, +∞) )
  • output: count-roots p itval
  • number of distinct real roots of p in interval itval
  • formalized in Isabelle by Manuel Eberl
  • nearly used as black-box
  • adapted functions to work over Q

number of distinct real roots of polynomial over Q in interval over Q reason: apply Sturm’s method to implement R formalization: locale for homomorphisms

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 10/22

slide-22
SLIDE 22

Real Algebraic Numbers Well-Definedness

Sturm’s Method

  • input
  • polynomial over R
  • interval ( [2, 5], (−π, 7], (−∞, 3), or (−∞, +∞) )
  • output: count-roots p itval
  • number of distinct real roots of p in interval itval
  • formalized in Isabelle by Manuel Eberl
  • nearly used as black-box
  • adapted functions to work over Q

number of distinct real roots of polynomial over Q in interval over Q reason: apply Sturm’s method to implement R formalization: locale for homomorphisms

  • precompute first phase of Sturm’s method

⇒ query many intervals for same polynomial more efficiently

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 10/22

slide-23
SLIDE 23

Real Algebraic Numbers Well-Definedness

Applying Sturm’s Method for Well-Definedness

“root #3 of −25 + 155x − 304x2 + 192x3” count-roots (−25 + 155x − 304x2 + 192x3) (−∞, +∞) = 2

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 11/22

slide-24
SLIDE 24

Real Algebraic Numbers Well-Definedness

Representation of Real Algebraic Numbers – Part 1

  • quadruple
  • polynomial over Q: p
  • left and right interval bound ∈ Q: l and r
  • precomputation of Sturm for p: root-info
  • (flag for factorization information on p)

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 12/22

slide-25
SLIDE 25

Real Algebraic Numbers Well-Definedness

Representation of Real Algebraic Numbers – Part 1

  • quadruple
  • polynomial over Q: p
  • left and right interval bound ∈ Q: l and r
  • precomputation of Sturm for p: root-info
  • (flag for factorization information on p)
  • representing real number

THE x ∈ [l, r]. rpoly p x = 0

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 12/22

slide-26
SLIDE 26

Real Algebraic Numbers Well-Definedness

Representation of Real Algebraic Numbers – Part 1

  • quadruple
  • polynomial over Q: p
  • left and right interval bound ∈ Q: l and r
  • precomputation of Sturm for p: root-info
  • (flag for factorization information on p)
  • representing real number

THE x ∈ [l, r]. rpoly p x = 0

  • five invariants
  • p = 0
  • root-info = count-roots p
  • root-info [l, r] = 1
  • . . .

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 12/22

slide-27
SLIDE 27

Real Algebraic Numbers Well-Definedness

Representation of Real Algebraic Numbers – Part 1

  • quadruple
  • polynomial over Q: p
  • left and right interval bound ∈ Q: l and r
  • precomputation of Sturm for p: root-info
  • (flag for factorization information on p)
  • representing real number

THE x ∈ [l, r]. rpoly p x = 0

  • five invariants
  • p = 0
  • root-info = count-roots p
  • root-info [l, r] = 1
  • . . .
  • invariants are ensured via a subtype (typedef)
  • new type of quadruples satisfying invariants
  • lift-definition and transfer for function definitions and proofs

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 12/22

slide-28
SLIDE 28

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Real Roots of Rational Polynomial

input: non-zero polynomial over Q

  • utput: list of real algebraic numbers representing the roots

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 13/22

slide-29
SLIDE 29

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Real Roots of Rational Polynomial

input: non-zero polynomial over Q

  • utput: list of real algebraic numbers representing the roots
  • 1. factorize input polynomial over Q into pm1

1

· . . . · pmn

n

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 13/22

slide-30
SLIDE 30

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Real Roots of Rational Polynomial

input: non-zero polynomial over Q

  • utput: list of real algebraic numbers representing the roots
  • 1. factorize input polynomial over Q into pm1

1

· . . . · pmn

n

  • 2. apply the following steps on each pi

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 13/22

slide-31
SLIDE 31

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Real Roots of Rational Polynomial

input: non-zero polynomial over Q

  • utput: list of real algebraic numbers representing the roots
  • 1. factorize input polynomial over Q into pm1

1

· . . . · pmn

n

  • 2. apply the following steps on each pi
  • 3. determine root-infoi for pi and initial bounds li, ri such that

root-infoi (−∞, +∞) = root-infoi [li, ri]

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 13/22

slide-32
SLIDE 32

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Real Roots of Rational Polynomial

input: non-zero polynomial over Q

  • utput: list of real algebraic numbers representing the roots
  • 1. factorize input polynomial over Q into pm1

1

· . . . · pmn

n

  • 2. apply the following steps on each pi
  • 3. determine root-infoi for pi and initial bounds li, ri such that

root-infoi (−∞, +∞) = root-infoi [li, ri]

  • 4. perform bisection on [li, ri] to obtain intervals which all

contain a single root of pi

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 13/22

slide-33
SLIDE 33

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Example

  • input: χA
  • computation:
  • 39 − 399x + 1192x2 − 1344x3 + 512x4
  • output:

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 14/22

slide-34
SLIDE 34

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Example

  • factorization
  • computation:
  • (x − 1) · (−39 + 360x − 832x2 + 512x3)
  • output:

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 14/22

slide-35
SLIDE 35

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Example

  • factorization
  • computation:
  • (x − 1) · (−39 + 360x − 832x2 + 512x3)
  • output: (x − 1, [1, 1])

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 14/22

slide-36
SLIDE 36

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Example

  • initial bounds: 6 = degree pi · max{⌈|ci|⌉. ci coefficient of pi}
  • computation:
  • (x − 1) · (−39 + 360x − 832x2 + 512x3)
  • todo = {[−6, 6]}
  • output: (x − 1, [1, 1])

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 14/22

slide-37
SLIDE 37

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Example

  • bisection
  • computation:
  • (x − 1) · (−39 + 360x − 832x2 + 512x3)
  • todo = {[−6, 0], [0, 6]}
  • output: (x − 1, [1, 1])

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 14/22

slide-38
SLIDE 38

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Example

  • bisection
  • computation:
  • (x − 1) · (−39 + 360x − 832x2 + 512x3)
  • todo = {[0, 6]}
  • output: (x − 1, [1, 1])

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 14/22

slide-39
SLIDE 39

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Example

  • bisection
  • computation:
  • (x − 1) · (−39 + 360x − 832x2 + 512x3)
  • todo = {[0, 3], [3, 6]}
  • output: (x − 1, [1, 1])

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 14/22

slide-40
SLIDE 40

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Example

  • bisection
  • computation:
  • (x − 1) · (−39 + 360x − 832x2 + 512x3)
  • todo = {[0, 3

2], [ 3 2, 3], [3, 6]}

  • output: (x − 1, [1, 1])

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 14/22

slide-41
SLIDE 41

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Example

  • bisection
  • computation:
  • (x − 1) · (−39 + 360x − 832x2 + 512x3)
  • todo = {[0, 3

4], [ 3 4, 3 2], [ 3 2, 3], [3, 6]}

  • output: (x − 1, [1, 1])

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 14/22

slide-42
SLIDE 42

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Example

  • bisection
  • computation:
  • (x − 1) · (−39 + 360x − 832x2 + 512x3)
  • todo = {[0, 3

8], [ 3 8, 3 4], [ 3 4, 3 2], [ 3 2, 3], [3, 6]}

  • output: (x − 1, [1, 1])

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 14/22

slide-43
SLIDE 43

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Example

  • bisection
  • computation:
  • (x − 1) · (−39 + 360x − 832x2 + 512x3)
  • todo = {[ 3

8, 3 4], [ 3 4, 3 2], [ 3 2, 3], [3, 6]}

  • output: (x − 1, [1, 1]) , (pi, [0, 3

8])

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 14/22

slide-44
SLIDE 44

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Example

  • bisection
  • computation:
  • (x − 1) · (−39 + 360x − 832x2 + 512x3)
  • todo = {[ 3

4, 3 2], [ 3 2, 3], [3, 6]}

  • output: (x − 1, [1, 1]) , (pi, [0, 3

8]) , (pi, [ 3 8, 3 4])

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 14/22

slide-45
SLIDE 45

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Example

  • bisection
  • computation:
  • (x − 1) · (−39 + 360x − 832x2 + 512x3)
  • todo = {[ 3

2, 3], [3, 6]}

  • output: (x − 1, [1, 1]) , (pi, [0, 3

8]) , (pi, [ 3 8, 3 4]) , (pi, [ 3 4, 3 2])

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 14/22

slide-46
SLIDE 46

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Example

  • bisection
  • computation:
  • (x − 1) · (−39 + 360x − 832x2 + 512x3)
  • todo = {[3, 6]}
  • output: (x − 1, [1, 1]) , (pi, [0, 3

8]) , (pi, [ 3 8, 3 4]) , (pi, [ 3 4, 3 2])

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 14/22

slide-47
SLIDE 47

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Example

  • bisection
  • computation:
  • (x − 1) · (−39 + 360x − 832x2 + 512x3)
  • todo = {}
  • output: (x − 1, [1, 1]) , (pi, [0, 3

8]) , (pi, [ 3 8, 3 4]) , (pi, [ 3 4, 3 2])

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 14/22

slide-48
SLIDE 48

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Bisection Algorithm

  • bisection takes root-info as parameter for efficiency
  • does not terminate (e.g., pass λx.2)

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 15/22

slide-49
SLIDE 49

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Bisection Algorithm

  • bisection takes root-info as parameter for efficiency
  • does not terminate (e.g., pass λx.2)
  • definition as partial-function to obtain code-equations

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 15/22

slide-50
SLIDE 50

Real Algebraic Numbers Calculating Real Roots of Rational Polynomial

Bisection Algorithm

  • bisection takes root-info as parameter for efficiency
  • does not terminate (e.g., pass λx.2)
  • definition as partial-function to obtain code-equations
  • soundness via well-founded induction;
  • rder based on minimal distance between roots of pi

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 15/22

slide-51
SLIDE 51

Real Algebraic Numbers Factorizing Rational Polynomial

Factorization of Rational Polynomials

  • important for efficiency: keep polynomials small

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 16/22

slide-52
SLIDE 52

Real Algebraic Numbers Factorizing Rational Polynomial

Factorization of Rational Polynomials

  • important for efficiency: keep polynomials small
  • time/degree of representing polynomials for n

i=1

√ i factorization n = 8 n = 9 n = 10 none 2m11s/256 22m19s/512 12h19m/1024 square-free 2m14s/256 15m31s/384 9h31m/768 full 0.35s/16 0.35s/16 0.59s/16

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 16/22

slide-53
SLIDE 53

Real Algebraic Numbers Factorizing Rational Polynomial

Factorization of Rational Polynomials

  • important for efficiency: keep polynomials small
  • time/degree of representing polynomials for n

i=1

√ i factorization n = 8 n = 9 n = 10 none 2m11s/256 22m19s/512 12h19m/1024 square-free 2m14s/256 15m31s/384 9h31m/768 full 0.35s/16 0.35s/16 0.59s/16

  • algorithm

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 16/22

slide-54
SLIDE 54

Real Algebraic Numbers Factorizing Rational Polynomial

Factorization of Rational Polynomials

  • important for efficiency: keep polynomials small
  • time/degree of representing polynomials for n

i=1

√ i factorization n = 8 n = 9 n = 10 none 2m11s/256 22m19s/512 12h19m/1024 square-free 2m14s/256 15m31s/384 9h31m/768 full 0.35s/16 0.35s/16 0.59s/16

  • algorithm
  • apply certified square-free factorization

− 108 − 72x + 108x2 + 84x3 − 27x4 − 32x5 − 2x6 + 4x7 + x8 = ( − 3 + x2)2 · ( − 12 − 8x + 4x2 + 4x3 + x4)1

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 16/22

slide-55
SLIDE 55

Real Algebraic Numbers Factorizing Rational Polynomial

Factorization of Rational Polynomials

  • important for efficiency: keep polynomials small
  • time/degree of representing polynomials for n

i=1

√ i factorization n = 8 n = 9 n = 10 none 2m11s/256 22m19s/512 12h19m/1024 square-free 2m14s/256 15m31s/384 9h31m/768 full 0.35s/16 0.35s/16 0.59s/16

  • algorithm
  • apply certified square-free factorization

− 108 − 72x + 108x2 + 84x3 − 27x4 − 32x5 − 2x6 + 4x7 + x8 = ( − 3 + x2)2 · ( − 12 − 8x + 4x2 + 4x3 + x4)1

  • invoke oracle on each factor

−12 − 8x + 4x2 + 4x3 + x4 oracle = (−2 + x2) · (6 + 4x + x2)

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 16/22

slide-56
SLIDE 56

Real Algebraic Numbers Factorizing Rational Polynomial

Factorization of Rational Polynomials

  • important for efficiency: keep polynomials small
  • time/degree of representing polynomials for n

i=1

√ i factorization n = 8 n = 9 n = 10 none 2m11s/256 22m19s/512 12h19m/1024 square-free 2m14s/256 15m31s/384 9h31m/768 full 0.35s/16 0.35s/16 0.59s/16

  • algorithm
  • apply certified square-free factorization

− 108 − 72x + 108x2 + 84x3 − 27x4 − 32x5 − 2x6 + 4x7 + x8 = ( − 3 + x2)2 · ( − 12 − 8x + 4x2 + 4x3 + x4)1

  • invoke oracle on each factor

−12 − 8x + 4x2 + 4x3 + x4 oracle = (−2 + x2) · (6 + 4x + x2)

  • check equality at runtime, not irreducibility

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 16/22

slide-57
SLIDE 57

Real Algebraic Numbers Factorizing Rational Polynomial

Simplification of Representation

Consider p(x) = −108−72x +108x2 +84x3 −27x4 −32x5 −2x6 +4x7 +x8 THE root of p in [1, 1.5] = THE root of (−3 + x2) · (6 + 4x + x2) · (−2 + x2) in [1, 1.5] = THE root of −2 + x2 in [1, 1.5] (= √ 2)

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 17/22

slide-58
SLIDE 58

Real Algebraic Numbers Factorizing Rational Polynomial

Comparison of Real Algebraic Numbers

  • 1. decide whether (p, [l, r]) and (q, [l′, r′]) encode same number

THE root of p in [l, r] = THE root of q in [l′, r′] ⇐ ⇒ gcd p q has real root in [l, r] ∩ [l′, r′]

  • 2. if not, tighten bounds of both numbers via bisection until

intervals are disjoint (bisection algorithm again defined by partial-function)

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 18/22

slide-59
SLIDE 59

Real Algebraic Numbers Arithmetic on Real Algebraic Numbers

Arithmetic on Real Algebraic Numbers

how to perform operations like +, −, ×, /,

n

√·, etc. on algebraic numbers (p, [l, r]) and (q, [l′, r′])?

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 19/22

slide-60
SLIDE 60

Real Algebraic Numbers Arithmetic on Real Algebraic Numbers

Arithmetic on Real Algebraic Numbers

how to perform operations like +, −, ×, /,

n

√·, etc. on algebraic numbers (p, [l, r]) and (q, [l′, r′])?

  • 1. determine polynomial
  • negation: p(−x)
  • n

√·: p(xn)

  • addition: resultant(p(x − y), q(y))

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 19/22

slide-61
SLIDE 61

Real Algebraic Numbers Arithmetic on Real Algebraic Numbers

Arithmetic on Real Algebraic Numbers

how to perform operations like +, −, ×, /,

n

√·, etc. on algebraic numbers (p, [l, r]) and (q, [l′, r′])?

  • 1. determine polynomial
  • negation: p(−x)
  • n

√·: p(xn)

  • addition: resultant(p(x − y), q(y))
  • 2. compute initial interval, e.g. [l + l′, r + r′] for addition

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 19/22

slide-62
SLIDE 62

Real Algebraic Numbers Arithmetic on Real Algebraic Numbers

Arithmetic on Real Algebraic Numbers

how to perform operations like +, −, ×, /,

n

√·, etc. on algebraic numbers (p, [l, r]) and (q, [l′, r′])?

  • 1. determine polynomial
  • negation: p(−x)
  • n

√·: p(xn)

  • addition: resultant(p(x − y), q(y))
  • 2. compute initial interval, e.g. [l + l′, r + r′] for addition
  • 3. tighten intervals [l, r] and [l′, r′] until resulting interval

contains unique root

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 19/22

slide-63
SLIDE 63

Real Algebraic Numbers Arithmetic on Real Algebraic Numbers

Arithmetic on Real Algebraic Numbers

how to perform operations like +, −, ×, /,

n

√·, etc. on algebraic numbers (p, [l, r]) and (q, [l′, r′])?

  • 1. determine polynomial
  • negation: p(−x)
  • n

√·: p(xn)

  • addition: resultant(p(x − y), q(y))
  • 2. compute initial interval, e.g. [l + l′, r + r′] for addition
  • 3. tighten intervals [l, r] and [l′, r′] until resulting interval

contains unique root

  • 4. optimize representation

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 19/22

slide-64
SLIDE 64

Real Algebraic Numbers Arithmetic on Real Algebraic Numbers

Increase Efficiency, Representation – Part 2

  • factorizations in between to simplify representations
  • efficient (not optimal) computation of resultants and GCDs
  • tuned algorithms on polynomials
  • special treatment for rational numbers

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 20/22

slide-65
SLIDE 65

Real Algebraic Numbers Arithmetic on Real Algebraic Numbers

Increase Efficiency, Representation – Part 2

  • factorizations in between to simplify representations
  • efficient (not optimal) computation of resultants and GCDs
  • tuned algorithms on polynomials
  • special treatment for rational numbers

datatype real_alg_3 = Rational rat | Irrational "quadruple with invariants" typedef real_alg_4 = "real_alg_3 with invariant" definition real_of_4 :: real_alg_4 => real quotient_type real_alg = real_alg_4 / "% x y. real_of_4 x = real_of_4 y"

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 20/22

slide-66
SLIDE 66

Complex Algebraic Numbers

Complex Algebraic Numbers in Isabelle

  • missing: equivalent of Sturm’s method for C

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 21/22

slide-67
SLIDE 67

Complex Algebraic Numbers

Complex Algebraic Numbers in Isabelle

  • missing: equivalent of Sturm’s method for C
  • take existing Cartesian representation: (Re(x), Im(x))

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 21/22

slide-68
SLIDE 68

Complex Algebraic Numbers

Complex Algebraic Numbers in Isabelle

  • missing: equivalent of Sturm’s method for C
  • take existing Cartesian representation: (Re(x), Im(x))
  • only new difficulty: find complex roots, e.g., of p = 1 + x + x3

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 21/22

slide-69
SLIDE 69

Complex Algebraic Numbers

Complex Algebraic Numbers in Isabelle

  • missing: equivalent of Sturm’s method for C
  • take existing Cartesian representation: (Re(x), Im(x))
  • only new difficulty: find complex roots, e.g., of p = 1 + x + x3
  • basic idea:
  • complex roots of rational polynomials come in complex

conjugate pairs ⇒ if x is root of p then ¯ x is root of p

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 21/22

slide-70
SLIDE 70

Complex Algebraic Numbers

Complex Algebraic Numbers in Isabelle

  • missing: equivalent of Sturm’s method for C
  • take existing Cartesian representation: (Re(x), Im(x))
  • only new difficulty: find complex roots, e.g., of p = 1 + x + x3
  • basic idea:
  • complex roots of rational polynomials come in complex

conjugate pairs ⇒ if x is root of p then ¯ x is root of p ⇒ Re(x) = 1

2(x + ¯

x) is root of the polynomial for 1

2 ⊙ (p ⊕ p)

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 21/22

slide-71
SLIDE 71

Complex Algebraic Numbers

Complex Algebraic Numbers in Isabelle

  • missing: equivalent of Sturm’s method for C
  • take existing Cartesian representation: (Re(x), Im(x))
  • only new difficulty: find complex roots, e.g., of p = 1 + x + x3
  • basic idea:
  • complex roots of rational polynomials come in complex

conjugate pairs ⇒ if x is root of p then ¯ x is root of p ⇒ Re(x) = 1

2(x + ¯

x) is root of the polynomial for 1

2 ⊙ (p ⊕ p)

⇒ Im(x) = 1

2i (x − ¯

x) is root of the polynomial for

1 2i ⊙ (p ⊖ p)

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 21/22

slide-72
SLIDE 72

Complex Algebraic Numbers

Complex Algebraic Numbers in Isabelle

  • missing: equivalent of Sturm’s method for C
  • take existing Cartesian representation: (Re(x), Im(x))
  • only new difficulty: find complex roots, e.g., of p = 1 + x + x3
  • basic idea:
  • complex roots of rational polynomials come in complex

conjugate pairs ⇒ if x is root of p then ¯ x is root of p ⇒ Re(x) = 1

2(x + ¯

x) is root of the polynomial for 1

2 ⊙ (p ⊕ p)

⇒ Im(x) = 1

2i (x − ¯

x) is root of the polynomial for

1 2i ⊙ (p ⊖ p)

⇒ compute all these roots

Re(x) =

  • SOME x. 8 − 24x − 88x3 + 96x4 + 288x5 + 384x6 + 768x7 + 512x9 = 0
  • Im(x) =
  • SOME x.

961 4096 x2 − 279 512 x4 + 453 256 x6 − 85 32 x8 + 27 8 x10 − 3x12 + x14 = 0

  • Thiemann and Yamada (Univ. Innsbruck)

Algebraic Numbers in Isabelle/HOL 21/22

slide-73
SLIDE 73

Complex Algebraic Numbers

Complex Algebraic Numbers in Isabelle

  • missing: equivalent of Sturm’s method for C
  • take existing Cartesian representation: (Re(x), Im(x))
  • only new difficulty: find complex roots, e.g., of p = 1 + x + x3
  • basic idea:
  • complex roots of rational polynomials come in complex

conjugate pairs ⇒ if x is root of p then ¯ x is root of p ⇒ Re(x) = 1

2(x + ¯

x) is root of the polynomial for 1

2 ⊙ (p ⊕ p)

⇒ Im(x) = 1

2i (x − ¯

x) is root of the polynomial for

1 2i ⊙ (p ⊖ p)

⇒ compute all these roots

Re(x) =

  • SOME x.
  • −1

8 + 1 4x + x3

  • ·
  • 1 + x + x3

= 0

  • Im(x) =
  • SOME x.
  • −31

64 + 9 16x2 − 3 2x4 + x6

  • · x = 0
  • Thiemann and Yamada (Univ. Innsbruck)

Algebraic Numbers in Isabelle/HOL 21/22

slide-74
SLIDE 74

Complex Algebraic Numbers

Complex Algebraic Numbers in Isabelle

  • missing: equivalent of Sturm’s method for C
  • take existing Cartesian representation: (Re(x), Im(x))
  • only new difficulty: find complex roots, e.g., of p = 1 + x + x3
  • basic idea:
  • complex roots of rational polynomials come in complex

conjugate pairs ⇒ if x is root of p then ¯ x is root of p ⇒ Re(x) = 1

2(x + ¯

x) is root of the polynomial for 1

2 ⊙ (p ⊕ p)

⇒ Im(x) = 1

2i (x − ¯

x) is root of the polynomial for

1 2i ⊙ (p ⊖ p)

⇒ compute all these roots

Re(x) =

  • SOME x.
  • −1

8 + 1 4x + x3

  • ·
  • 1 + x + x3

= 0

  • Im(x) =
  • SOME x.
  • −31

64 + 9 16x2 − 3 2x4 + x6

  • · x = 0
  • and filter: for all candidates z = Re(x) + Im(x)i, test p(z) = 0

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 21/22

slide-75
SLIDE 75

Complex Algebraic Numbers

Summary

  • formalization of real and complex algebraic numbers,

implementing R and C +, −, ×, /,

n

√·, ⌊·⌋, =, <, i, Re, Im, show

  • factorization algorithms for rational polynomials over Q, R, C
  • heavily relying on Sturm’s method and matrix library
  • based on factorization oracle (S. Joosten @ Isabelle workshop)
  • ∼ 20.000 loc, available in archive of formal proofs

Thiemann and Yamada (Univ. Innsbruck) Algebraic Numbers in Isabelle/HOL 22/22