Generating Mathematical Structure Hierarchies using Coq-ELPI Cyril - - PowerPoint PPT Presentation

generating mathematical structure hierarchies using coq
SMART_READER_LITE
LIVE PREVIEW

Generating Mathematical Structure Hierarchies using Coq-ELPI Cyril - - PowerPoint PPT Presentation

Generating Mathematical Structure Hierarchies using Coq-ELPI Cyril Cohen (Inria) , Kazuhiko Sakaguchi, Enrico Tassi FoMM, Pittsburgh, USA January 6th, 2020 Cohen, Sakaguchi, Tassi Structure Hierarchies in Coq-ELPI January 6th, 2020 1


slide-1
SLIDE 1

Generating Mathematical Structure Hierarchies using Coq-ELPI

Cyril Cohen (Inria), Kazuhiko Sakaguchi, Enrico Tassi

FoMM, Pittsburgh, USA

January 6th, 2020

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 1

slide-2
SLIDE 2

Structures in Mathematics

  • A carrier in Set / Type,
  • A set of constants in the carrier, and operations,
  • Proofs of the axioms of the structure

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 2

slide-3
SLIDE 3

Structures in Mathematics

  • A carrier in Set / Type,
  • A set of constants in the carrier, and operations,
  • Proofs of the axioms of the structure

Record is_ring A := mk_ring { zero : A; add : A -> A -> A; opp : A -> A;

  • ne : A;

mul : A -> A -> A; addrA : associative add; addrC : commutative add; add0r : left_id zero add; addNr : left_inverse zero opp add; mulrA : associative mul; mul1r : left_id one mul; mulr1 : right_id

  • ne mul;

mulrDl : left_distributive mul add; mulrDr : right_distributive mul add; }.

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 2

slide-4
SLIDE 4

Structures in formalization

Purpose:

  • factor theorems across instances, using the theory of each

structure,

  • automatically find which structures hold on which types.

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 3

slide-5
SLIDE 5

Structures in formalization

Purpose:

  • factor theorems across instances, using the theory of each

structure,

  • automatically find which structures hold on which types.

Requirements:

  • declare a new instance,

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 3

slide-6
SLIDE 6

Structures in formalization

Purpose:

  • factor theorems across instances, using the theory of each

structure,

  • automatically find which structures hold on which types.

Requirements:

  • declare a new instance,
  • declare a new structure
  • above, below or in the middle
  • handle diamonds (e.g. monoid, group, commutative or not),
  • by amending existing code, or not,

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 3

slide-7
SLIDE 7

Structures in formalization

Purpose:

  • factor theorems across instances, using the theory of each

structure,

  • automatically find which structures hold on which types.

Requirements:

  • declare a new instance,
  • declare a new structure
  • above, below or in the middle
  • handle diamonds (e.g. monoid, group, commutative or not),
  • by amending existing code, or not,
  • predictability of inferred instance,

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 3

slide-8
SLIDE 8

Structures in formalization

Purpose:

  • factor theorems across instances, using the theory of each

structure,

  • automatically find which structures hold on which types.

Requirements:

  • declare a new instance,
  • declare a new structure
  • above, below or in the middle
  • handle diamonds (e.g. monoid, group, commutative or not),
  • by amending existing code, or not,
  • predictability of inferred instance,
  • robustness of user code with regard to new declarations.x

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 3

slide-9
SLIDE 9

Structures relating to each other

Examples:

  • Monoid ← Group ← Ring ← Field ← ...
  • Euclidean Spaces → Normed Spaces → Complete Space →

Metric Spaces → Topological Spaces → ...

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 4

slide-10
SLIDE 10

Structures relating to each other

Examples:

  • Monoid ← Group ← Ring ← Field ← ...
  • Euclidean Spaces → Normed Spaces → Complete Space →

Metric Spaces → Topological Spaces → ... Going through arrows must be automated.

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 4

slide-11
SLIDE 11

Structures relating to each other

Examples:

  • Monoid ← Group ← Ring ← Field ← ...
  • Euclidean Spaces → Normed Spaces → Complete Space →

Metric Spaces → Topological Spaces → ... Going through arrows must be automated. Two kinds arrows:

  • Extensions: add operations, axioms or combine structures
  • Entailment/Induction/Deduction/Generalization.

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 4

slide-12
SLIDE 12

More examples ”Calculus” structures ”Algebraic” structures

PartialOrder Lattice TotalOrder AddGroup Lmodule (Com)(Unit)Ring IntegralDomain Field OrderedDomain OrderedField RealClosedField ArchimedeanField TopologicalSpace UniformSpace Complete NormedAddGroup NormedModule CompleteNormedModule

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 5

slide-13
SLIDE 13

Structure extension

  • Compositional: no need to start from scratch every time. (E.g.

the product of two groups is a group, the product of two rings is a ring),

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 6

slide-14
SLIDE 14

Structure extension

  • Compositional: no need to start from scratch every time. (E.g.

the product of two groups is a group, the product of two rings is a ring),

  • Noisy: changes the internal definition of a structure. (E.g.

Defining an commutative monoid from a monoid, we get already get one unnecessary axiom),

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 6

slide-15
SLIDE 15

Structure extension

  • Compositional: no need to start from scratch every time. (E.g.

the product of two groups is a group, the product of two rings is a ring),

  • Noisy: changes the internal definition of a structure. (E.g.

Defining an commutative monoid from a monoid, we get already get one unnecessary axiom),

  • Non-robust: possible breakage of user code when new

intermediate structures are added,

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 6

slide-16
SLIDE 16

Structure extension

  • Compositional: no need to start from scratch every time. (E.g.

the product of two groups is a group, the product of two rings is a ring),

  • Noisy: changes the internal definition of a structure. (E.g.

Defining an commutative monoid from a monoid, we get already get one unnecessary axiom),

  • Non-robust: possible breakage of user code when new

intermediate structures are added,

  • Not all arrows!

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 6

slide-17
SLIDE 17

Structure extension

  • Compositional: no need to start from scratch every time. (E.g.

the product of two groups is a group, the product of two rings is a ring),

  • Noisy: changes the internal definition of a structure. (E.g.

Defining an commutative monoid from a monoid, we get already get one unnecessary axiom),

  • Non-robust: possible breakage of user code when new

intermediate structures are added,

  • Not all arrows! Really?

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 6

slide-18
SLIDE 18

Structure entailment

  • More flexible: no need to cut structures into smaller bits.
  • Cover the case of all arrows, including extensions.

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 7

slide-19
SLIDE 19

Structure entailment

  • More flexible: no need to cut structures into smaller bits.
  • Cover the case of all arrows, including extensions.
  • Major breakage when arbitrary entailment is automatic;

e.g. given two normed spaces, and making their Cartesian product, in order to obtain the resulting topology, one can either:

  • first consider the normed space product, then derive the

corresponding topological space, or

  • first derive the topological spaces and then consider the

topological space product.

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 7

slide-20
SLIDE 20

Our Design

The best of two the worlds:

  • Extension, through mixins for internal declaration and

automatic inference

  • Entailment, through factory for any other use.

Factories require mixins and can produces others. (e.g. a full axiomatic can provide all the pieces)

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 8

slide-21
SLIDE 21

Our Design

The best of two the worlds:

  • Extension, through mixins for internal declaration and

automatic inference

  • Entailment, through factory for any other use.

Factories require mixins and can produces others. (e.g. a full axiomatic can provide all the pieces) We generate and generalize the design from Packaging Mathematical Structures (Garillot et al.) and Canonical Structures for the working Coq user (Mahboubi and Tassi).

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 8

slide-22
SLIDE 22

Our Design

The best of two the worlds:

  • Extension, through mixins for internal declaration and

automatic inference

  • Entailment, through factory for any other use.

Factories require mixins and can produces others. (e.g. a full axiomatic can provide all the pieces) We generate and generalize the design from Packaging Mathematical Structures (Garillot et al.) and Canonical Structures for the working Coq user (Mahboubi and Tassi). We follow a fully bundled approach, where carriers are packaged together with their axiomatic.

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 8

slide-23
SLIDE 23

Hiearchy builder at work

Five commands:

  • declare_mixin FactoryModuleName TypeName Factories.
  • declare_factory FactoryModuleName TypeName Factories.
  • end Functions.
  • structure ModuleName Factories.
  • instance Carrier Factories.

Demo https://github.com/math-comp/hierarchy-builder

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 9

slide-24
SLIDE 24

Conclusion

  • High-level commands to declare structures and instances,

easy to use.

  • Predictable outcome of inference,
  • Takes into account the evolution of knowledge
  • which is formalized, and
  • which the user has.

The two knowledge do not need to be correlated.

  • Robustness with regard to new declaration and even changes of

internal implementation.

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 10

slide-25
SLIDE 25

Conclusion

  • High-level commands to declare structures and instances,

easy to use.

  • Predictable outcome of inference,
  • Takes into account the evolution of knowledge
  • which is formalized, and
  • which the user has.

The two knowledge do not need to be correlated.

  • Robustness with regard to new declaration and even changes of

internal implementation. Also, Coq-ELPI turned out to be a very comfortable meta-programming language for this.

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 10

slide-26
SLIDE 26

Future work on Hierarchy Builder

  • Adding support for parameters.
  • Generating hierarchies of morphisms from structures.
  • Generating hierarchies of subobjects from structures.
  • Supporting multiple instances on the same carrier.
  • Replacing all uses in math-comp and extensions.
  • Get better error messages.

Cohen, Sakaguchi, Tassi – Structure Hierarchies in Coq-ELPI – January 6th, 2020 11