Packaging Mathematical Structures F. Garillot 1 , G. Gonthier 2 , A. - - PowerPoint PPT Presentation

packaging mathematical structures
SMART_READER_LITE
LIVE PREVIEW

Packaging Mathematical Structures F. Garillot 1 , G. Gonthier 2 , A. - - PowerPoint PPT Presentation

Packaging Mathematical Structures F. Garillot 1 , G. Gonthier 2 , A. Mahboubi 3 , L. Rideau 4 1 : Microsoft Research - INRIA Joint Centre 2 : Microsoft Research 3 : INRIA Saclay-le de France 4 : INRIA Sophia-Antipolis 1 Formalizing Finite Group


slide-1
SLIDE 1

Packaging Mathematical Structures

  • F. Garillot1, G. Gonthier2,
  • A. Mahboubi3, L. Rideau4

1: Microsoft Research - INRIA Joint Centre 2: Microsoft Research 3: INRIA Saclay-Île de France 4: INRIA Sophia-Antipolis

1

slide-2
SLIDE 2

Formalizing Finite Group Algebra

the Feit-Thompson proof 2007 2008 2009 2010 2011 local analysis character theory problems

linear algebra, infinite setting combinatorics, finite setting

This paper presents our so- lutions using Coq’s de- pendent records, coercions, type inference.

2

slide-3
SLIDE 3

Packaging Mathematical Structures

Two proof examples, in depth Hierarchy details, a nice alternative to Σ-types Our algebraic hierarchy Composable mathematical structures

This talk Our paper

3

slide-4
SLIDE 4

Our Algebraic Hierarchy

Type Equality Choice Zmodule Ring Commutative Ring Unit Ring Commutative Unit Ring Integral Domain Field Decidable field Closed Field Countable Finite . . .

See A Modular Formaliza- tion Of Finite Group Theory, (TPHOLs 07)

Type SubType

See the paper, § 3.1.

4

slide-5
SLIDE 5

Our Algebraic Hierarchy

Type Equality Choice Zmodule Ring Commutative Ring Unit Ring Commutative Unit Ring Integral Domain Field Decidable field Closed Field Countable Finite . . .

See A Modular Formaliza- tion Of Finite Group Theory, (TPHOLs 07)

Type SubType

See the paper, § 3.1.

depth = 10

4-a

slide-6
SLIDE 6

Our Algebraic Hierarchy

practical purpose

(nothing here) ➘

Type Equality Choice Zmodule Ring Commutative Ring Unit Ring Commutative Unit Ring Integral Domain Field Decidable field Closed Field Countable Finite . . .

See A Modular Formaliza- tion Of Finite Group Theory, (TPHOLs 07)

Type SubType

See the paper, § 3.1.

4-b

slide-7
SLIDE 7

Our Algebraic Hierarchy

multiple inheri- tance Type Equality Choice Zmodule Ring Commutative Ring Unit Ring Commutative Unit Ring Integral Domain Field Decidable field Closed Field Countable Finite . . .

See A Modular Formaliza- tion Of Finite Group Theory, (TPHOLs 07)

Type SubType

See the paper, § 3.1.

4-c

slide-8
SLIDE 8

Our Algebraic Hierarchy

Blue nodes collapse

  • n

green in a clas- sical/untyped setting.

infinite quotients in intentional setting

Type Equality Choice Zmodule Ring Commutative Ring Unit Ring Commutative Unit Ring Integral Domain Field Decidable field Closed Field Countable Finite . . .

See A Modular Formaliza- tion Of Finite Group Theory, (TPHOLs 07)

Type SubType

See the paper, § 3.1.

4-d

slide-9
SLIDE 9

Our Algebraic Hierarchy

better composi- tionality Type Equality Choice Zmodule Ring Commutative Ring Unit Ring Commutative Unit Ring Integral Domain Field Decidable field Closed Field Countable Finite . . .

See A Modular Formaliza- tion Of Finite Group Theory, (TPHOLs 07)

Type SubType

See the paper, § 3.1.

4-e

slide-10
SLIDE 10

Our Algebraic Hierarchy

5

slide-11
SLIDE 11

Our Algebraic Hierarchy

(1) This hierarchy is populated by ground types, e.g.: Z/nZ, Fp

5-a

slide-12
SLIDE 12

Our Algebraic Hierarchy

(1) This hierarchy is populated by ground types, e.g.: Z/nZ, Fp (2) . . . and parametric types, e.g.: matrix, polynomials.

5-b

slide-13
SLIDE 13

Our Algebraic Hierarchy

(1) This hierarchy is populated by ground types, e.g.: Z/nZ, Fp (2) . . . and parametric types, e.g.: matrix, polynomials. (3) Very little computational content or theory in a Ring

5-c

slide-14
SLIDE 14

Our Algebraic Hierarchy

(1) This hierarchy is populated by ground types, e.g.: Z/nZ, Fp (2) . . . and parametric types, e.g.: matrix, polynomials. (3) Very little computational content or theory in a Ring (4) but it is a nice package that occurs several times in lemma statements.

5-d

slide-15
SLIDE 15

Our Algebraic Hierarchy

(1) This hierarchy is populated by ground types, e.g.: Z/nZ, Fp (2) . . . and parametric types, e.g.: matrix, polynomials. (3) Very little computational content or theory in a Ring (4) but it is a nice package that occurs several times in lemma statements. (5)

  • Components, objects
  • =
  • APIs, interfaces
  • 5-e
slide-16
SLIDE 16

Our Algebraic Hierarchy

(1) This hierarchy is populated by ground types, e.g.: Z/nZ, Fp (2) . . . and parametric types, e.g.: matrix, polynomials. (3) Very little computational content or theory in a Ring (4) but it is a nice package that occurs several times in lemma statements. (5)

  • Components, objects
  • =
  • APIs, interfaces
  • (6) algebraic properties ^

= interface programming

5-f

slide-17
SLIDE 17

Representing objects and structures

We want to manipulate objects:

6

slide-18
SLIDE 18

Representing objects and structures

We want to manipulate objects: (Cayley-Hamilton)

  • P(A) = 0

where P(X) = det(X • In − A)

  • 6-a
slide-19
SLIDE 19

Representing objects and structures

We want to manipulate objects: (Cayley-Hamilton)

  • P(A) = 0

where P(X) = det(X • In − A)

  • But we do not want to specify the corresponding structure:

 

The Ring of polynomials over the Ring of matrices

  • ver a general Commutative Ring.

 

6-b

slide-20
SLIDE 20

A Type class

a constant zero :

M

an operation : add :

M-> M -> M

axiom(s) verified by add on M

associative add;

. . .

ZModule (M:Type)

C elements per structure, n nested (parametric) struc- tures in which the parame- ter occurs at every element: term size in Cn How do we pass structures when enunciating lemmas ? Proofs introduce structures.

7

slide-21
SLIDE 21

A Typical structure

We fill the blanks using Canonical Structures.

  • peration on the type

Module Equality. Record mixin_of (T : Type) : Type := Mixin { op : rel T; _ : forall x y, reflect (x = y) (op x y) }. Structure type : Type := Pack { sort :> Type; mixin : mixin_of sort}. End Equality. representation type axiom(s) verified by the operation

projection

8

slide-22
SLIDE 22

A Typical structure

We fill the blanks using Canonical Structures.

Module Equality. Record mixin_of (T : Type) : Type := Mixin { : _ ; _ : _ }. Structure type : Type := Pack {sort :> Type; mixin : mixin_of sort}. End Equality.

This is generic: we use modules as namespaces only:

Notation eqType := Equality.type.

9

slide-23
SLIDE 23

Canonical Structure Composition

Most widely used: Telescopes

T MixinEq

  • pzmod

axiomszmod MixinZmod

  • pzmod

axiomszmod eqType zmodType

10

slide-24
SLIDE 24

Telescopes : Canonical Structure inference

2 + 2 Zmodule.add α 2 2 Equality.sort(Zmodule.sortα) ≡βιδ int Zmodule.sortα ≡βιδ inteqT ype Equality.sort (Zmodule.sort (intzmodT ype))

Notation type inference lookup (Equality.sort,int) ❀ inteqT ype lookup (Zmodule.sort,inteqT ype) ❀ intzmodT ype

11

slide-25
SLIDE 25

Telescopes : Canonical Structure inference

2 + 2 Zmodule.add α 2 2 Equality.sort(Zmodule.sortα) ≡βιδ int Zmodule.sortα ≡βιδ inteqT ype Equality.sort (Zmodule.sort (intzmodT ype))

Notation type inference lookup (Equality.sort,int) ❀ inteqT ype lookup (Zmodule.sort,inteqT ype) ❀ intzmodT ype

Simple packaging, but

11-a

slide-26
SLIDE 26

Telescopes : Canonical Structure inference

2 + 2 Zmodule.add α 2 2 Equality.sort(Zmodule.sortα) ≡βιδ int Zmodule.sortα ≡βιδ inteqT ype Equality.sort (Zmodule.sort (intzmodT ype))

Notation type inference lookup (Equality.sort,int) ❀ inteqT ype lookup (Zmodule.sort,inteqT ype) ❀ intzmodT ype

Simple packaging, but head constant always the same x:T is interpreted as

x:Equality.sort(Zmodule.sort T)

11-b

slide-27
SLIDE 27

Telescopes : Canonical Structure inference

2 + 2 Zmodule.add α 2 2 Equality.sort(Zmodule.sortα) ≡βιδ int Zmodule.sortα ≡βιδ inteqT ype Equality.sort (Zmodule.sort (intzmodT ype))

Notation type inference lookup (Equality.sort,int) ❀ inteqT ype lookup (Zmodule.sort,inteqT ype) ❀ intzmodT ype

Simple packaging, but head constant always the same x:T is interpreted as

x:Equality.sort(Zmodule.sort T)

we’re defining coercions/canonical projections on Equality.sort !

11-c

slide-28
SLIDE 28

Telescopes : Canonical Structure inference

2 + 2 Zmodule.add α 2 2 Equality.sort(Zmodule.sortα) ≡βιδ int Zmodule.sortα ≡βιδ inteqT ype Equality.sort (Zmodule.sort (intzmodT ype))

Notation type inference lookup (Equality.sort,int) ❀ inteqT ype lookup (Zmodule.sort,inteqT ype) ❀ intzmodT ype

Simple packaging, but head constant always the same x:T is interpreted as

x:Equality.sort(Zmodule.sort T)

we’re defining coercions/canonical projections on Equality.sort ! as is, no multiple inheritance

11-d

slide-29
SLIDE 29

Packed Classes

T ClassEq

  • peq

axiomseq MixinZmod

  • pzmod

axiomszmod Classzmod zmodType

12

slide-30
SLIDE 30

Packed Classes

T ClassEq

  • peq

axiomseq MixinZmod

  • pzmod

axiomszmod Classzmod zmodType T Classeq ϕ ϕ eqType x : T denotes x : (Zmodule.sort T α), which, thanks to ϕ, has a canonical eqType structure.

12-a

slide-31
SLIDE 31

Packed Classes

2 + 2 == 4 Equality.op γ(Zmodule.add α 2 2) 4 Zmodule.sort α ≡ int

  • Zmodule.sort intzmodType

Equality.sort γ ≡ Zmodule.sort intzmodType Equality.op (Zmodule.eqType(intzmodT ype))(Zmodule.add ...) 4

Notation lookup(Zmodule.sort,int) ❀ intzmodT ype lookup(Equality.sort,Zmodule.sort intzmodT ype) ❀ Zmodule.eqType(intzmodT ype)

4 == 2 + 2 Equality.op γ (Zmodule.add α 2 2) 4 Equality.op inteqT ype (Zmodule.add α 2 2) 4 ...

Notation lookup(Equality.sort,int) ❀ inteqT ype

≡βιδ

13

slide-32
SLIDE 32

Packed Classes

Coherent coercions, x:T interpreted as Zmodule.sort T. Multiple inheritance: Module ComUnitRing. Record class_of (R : Type) : Type := Class { base1 :> ComRing.class_of R; ext :> UnitRing.mixin_of (Ring.Pack base1 R)}. Coercion base2 R m := UnitRing.Class (@ext R m). ... End ComUnitRing.

14

slide-33
SLIDE 33

Conclusion

algebraic structure composition is interface programming representing a large hierarchy implies packaging know the work ahead, and take the time to build the tools you will need

15

slide-34
SLIDE 34

Cn

16

slide-35
SLIDE 35

Cn

A + x

16-a

slide-36
SLIDE 36

Cn

A + x add (matrix T) (zeromx T) (addmx T)

16-b

slide-37
SLIDE 37

Cn

A + x add (matrix T) (zeromx T) (addmx T)

  • ...

(addmx (poly T) (zeropx T) (addpx T) )

16-c

slide-38
SLIDE 38

Cn

A + x add (matrix T) (zeromx T) (addmx T)

  • ...

(addmx (poly T) (zeropx T) (addpx T) )

and zeromx is itself (zeromx (poly T) (zeropx T) (addpx T) ) ...

16-d