Towards Primitive Data Types for C : -Bits Integers and Persistent Arrays

Towards Primitive Data Types for C : -Bits Integers and Persistent Arrays

Towards primitive data types for Coq Towards primitive data types for Coq: 63-bits integers and persistent arrays1 Maxime Dénès Inria Sophia-Antipolis July 22, 2013 1This work has been funded by the FORMATH project, nr. 243847, of the FET program within the 7th Framework program of the European Commission. Maxime Dénès 1 Proofs by computation: four color theorem, Kepler conjecture, certification of prime numbers Automation: deciding identities over rings, Kleene algebras, untrusted calls to external solvers Other uses: importing proof objects from other systems, emitting assembly code But also eiciency of extracted code: floating-point arithmetic,... Typical uses: Towards primitive data types for Coq | Introduction Motivation Growing need for eicient computations in proof systems. Maxime Dénès 2 Automation: deciding identities over rings, Kleene algebras, untrusted calls to external solvers Other uses: importing proof objects from other systems, emitting assembly code But also eiciency of extracted code: floating-point arithmetic,... Towards primitive data types for Coq | Introduction Motivation Growing need for eicient computations in proof systems. Typical uses: Proofs by computation: four color theorem, Kepler conjecture, certification of prime numbers Maxime Dénès 2 Other uses: importing proof objects from other systems, emitting assembly code But also eiciency of extracted code: floating-point arithmetic,... Towards primitive data types for Coq | Introduction Motivation Growing need for eicient computations in proof systems. Typical uses: Proofs by computation: four color theorem, Kepler conjecture, certification of prime numbers Automation: deciding identities over rings, Kleene algebras, untrusted calls to external solvers Maxime Dénès 2 But also eiciency of extracted code: floating-point arithmetic,... Towards primitive data types for Coq | Introduction Motivation Growing need for eicient computations in proof systems. Typical uses: Proofs by computation: four color theorem, Kepler conjecture, certification of prime numbers Automation: deciding identities over rings, Kleene algebras, untrusted calls to external solvers Other uses: importing proof objects from other systems, emitting assembly code Maxime Dénès 2 Towards primitive data types for Coq | Introduction Motivation Growing need for eicient computations in proof systems. Typical uses: Proofs by computation: four color theorem, Kepler conjecture, certification of prime numbers Automation: deciding identities over rings, Kleene algebras, untrusted calls to external solvers Other uses: importing proof objects from other systems, emitting assembly code But also eiciency of extracted code: floating-point arithmetic,... Maxime Dénès 2 Lazy evaluation machine Bytecode-based dedicated compiler and virtual machine Compilation to native code through OCaml Towards primitive data types for Coq | Introduction From eicient evaluation... Evaluation of terms inside Coq has improved a lot over years: Maxime Dénès 3 Bytecode-based dedicated compiler and virtual machine Compilation to native code through OCaml Towards primitive data types for Coq | Introduction From eicient evaluation... Evaluation of terms inside Coq has improved a lot over years: Lazy evaluation machine Maxime Dénès 3 Compilation to native code through OCaml Towards primitive data types for Coq | Introduction From eicient evaluation... Evaluation of terms inside Coq has improved a lot over years: Lazy evaluation machine Bytecode-based dedicated compiler and virtual machine Maxime Dénès 3 Towards primitive data types for Coq | Introduction From eicient evaluation... Evaluation of terms inside Coq has improved a lot over years: Lazy evaluation machine Bytecode-based dedicated compiler and virtual machine Compilation to native code through OCaml Maxime Dénès 3 Especially important in a purely functional setting. A symptomatic case: natural numbers. In the following, I will review the solutions implemented in Coq for eicient integer arithmetic and suggest some improvements. Towards primitive data types for Coq | Introduction ...to eicient data representations But these eorts can be vain without adapted representations for data. Maxime Dénès 4 In the following, I will review the solutions implemented in Coq for eicient integer arithmetic and suggest some improvements. Towards primitive data types for Coq | Introduction ...to eicient data representations But these eorts can be vain without adapted representations for data. Especially important in a purely functional setting. A symptomatic case: natural numbers. Maxime Dénès 4 Towards primitive data types for Coq | Introduction ...to eicient data representations But these eorts can be vain without adapted representations for data. Especially important in a purely functional setting. A symptomatic case: natural numbers. In the following, I will review the solutions implemented in Coq for eicient integer arithmetic and suggest some improvements. Maxime Dénès 4 But not very loyal to the user interested in computations. Coq < Definition x := 10000. Warning: Stack overflow or segmentation fault happens when working with large numbers in nat (observed threshold may vary from 5000 to 70000 depending on your system limits and on the command executed). x is defined Towards primitive data types for Coq | Integers Numbers in Coq: Peano numbers Simple definition (nat), easy inductive reasoning. Maxime Dénès 5 Coq < Definition x := 10000. Warning: Stack overflow or segmentation fault happens when working with large numbers in nat (observed threshold may vary from 5000 to 70000 depending on your system limits and on the command executed). x is defined Towards primitive data types for Coq | Integers Numbers in Coq: Peano numbers Simple definition (nat), easy inductive reasoning. But not very loyal to the user interested in computations. Maxime Dénès 5 Towards primitive data types for Coq | Integers Numbers in Coq: Peano numbers Simple definition (nat), easy inductive reasoning. But not very loyal to the user interested in computations. Coq < Definition x := 10000. Warning: Stack overflow or segmentation fault happens when working with large numbers in nat (observed threshold may vary from 5000 to 70000 depending on your system limits and on the command executed). x is defined Maxime Dénès 5 Towards primitive data types for Coq | Integers Numbers in Coq: binary numbers Inductive positive: Set := | xI: positive -> positive | xO: positive -> positive | xH: positive. InductiveN: Set := | N0:N | Npos: positive ->N. Slight complication for uniqueness of 0, definition of positive binary numbers (positive) and then binary naturals (N). Exponential gain in space and time, but still too limited for heavy computations. Maxime Dénès 6 Well-suited to the implementation of Karatsuba’s product. Performance rely critically on the inlining of operators for small trees (height ≤ 6), hence a fairly complex implementation. Leaves were first implemented by an inductive type with 256 constructors, but in recent versions they are substituted with native 31-bits integers. Towards primitive data types for Coq | Integers Numbers in Coq: big naturals Based on a representation of numbers as binary trees (bigN). Maxime Dénès 7 Performance rely critically on the inlining of operators for small trees (height ≤ 6), hence a fairly complex implementation. Leaves were first implemented by an inductive type with 256 constructors, but in recent versions they are substituted with native 31-bits integers. Towards primitive data types for Coq | Integers Numbers in Coq: big naturals Based on a representation of numbers as binary trees (bigN). Well-suited to the implementation of Karatsuba’s product. Maxime Dénès 7 Leaves were first implemented by an inductive type with 256 constructors, but in recent versions they are substituted with native 31-bits integers. Towards primitive data types for Coq | Integers Numbers in Coq: big naturals Based on a representation of numbers as binary trees (bigN). Well-suited to the implementation of Karatsuba’s product. Performance rely critically on the inlining of operators for small trees (height ≤ 6), hence a fairly complex implementation. Maxime Dénès 7 Towards primitive data types for Coq | Integers Numbers in Coq: big naturals Based on a representation of numbers as binary trees (bigN). Well-suited to the implementation of Karatsuba’s product. Performance rely critically on the inlining of operators for small trees (height ≤ 6), hence a fairly complex implementation. Leaves were first implemented by an inductive type with 256 constructors, but in recent versions they are substituted with native 31-bits integers. Maxime Dénès 7 But during an evaluation or a conversion using the VM, it is substituted with native machine arithmetic. This machinery is called “retroknowledge”. Towards primitive data types for Coq | Integers Numbers in Coq: 31-bits integers In the current version of Coq, 31-bits integers are represented by an inductive type: Inductive digits: Type := D0| D1. Definition digits31t := Eval compute in nfun digits 31t. Inductive int31: Type := I31: digits31 int31. Maxime Dénès 8 This machinery is called “retroknowledge”. Towards primitive data types for Coq | Integers Numbers in Coq: 31-bits integers In the current version of Coq, 31-bits integers are represented by an inductive type: Inductive digits: Type := D0| D1. Definition digits31t := Eval compute in nfun digits 31t. Inductive int31: Type := I31: digits31 int31. But during an evaluation or a conversion using the VM, it is substituted

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    45 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us