Skip to content

Numerals without int notation in prelude#2

Open
JasonGross wants to merge 26 commits intoletouzey:numeral-notation-2from
JasonGross:numerals-without-int-notation-in-prelude
Open

Numerals without int notation in prelude#2
JasonGross wants to merge 26 commits intoletouzey:numeral-notation-2from
JasonGross:numerals-without-int-notation-in-prelude

Conversation

@JasonGross
Copy link

I expect this will build on travis (though I haven't tested it all yet).

letouzey and others added 15 commits May 31, 2017 10:40
 This string contains the base-10 representation of the number (big endian)

 Note that some inner parsing stuff still uses bigints, see egramcoq.ml
 This is a portion of roglo's PR#156 introducing a Numeral Notation
 command : we deal here with inductive types via conversion fonctions
 from/to Z written in Coq.

 For an example, see plugins/syntax/NatSyntaxViaZ.v

 This commit does not include the part about printing via some ltac.
 Using ltac was meant for dealing with real numbers, let's see first what
 become PR#415 about a compact representation for real literals.
 This way, we could fully bypass bigint.ml.

 The previous mechanism of parsing/printing Z is kept for now.
 Currently, the conversion functions accepted by Numeral Notation foo
 may have the following types.

 for parsing:

   int -> foo
   int -> option foo
   uint -> foo
   uint -> option foo
   Z -> foo
   Z -> option foo

 for printing:

   foo -> int
   foo -> option int
   foo -> uint
   foo -> option uint
   foo -> Z
   foo -> option Z

 Notes:

  - The Declare ML Module is directly done in Prelude
  - When doing a Numeral Notation, having the Z datatype around
    isn't mandatory anymore (but the error messages suggest that
    it can still be used).
  - An option (abstract after ...) allows to keep large numbers in
    an abstract form such as (Nat.of_uint 123456) instead of reducing
    to (S (S (S ...))) and ending immediately with Stack Overflow.
  - After checking with Matthieu, there is now a explicit check
    and an error message in case of polymorphic inductive types
 Just because it's fun and easy. Not used by the Numeral Notation command.
 This parsing/printing method for nat should be just as fast as
 the previous dedicated code. Moreover, we could now parse large
 literals as nat numbers, by leaving them in a half-abstract form
 such as (Nat.of_uint 123456). This form is convertible to the
 closed (S (S (S ...))) form, so it shouldn't be a big deal for
 compatibility, except for if some Ltac stuff relies on (S ...) to be
 present after parsing. Of course, forcing the computation of
 a (Nat.of_uint ....) may take a while or raise a Stack Overflow.
If it's in the prelude, it conflicts with ssr's int_scope.  So we stuff
it in Numbers.DecimalNotations.
@JasonGross
Copy link
Author

Indeed, all of the cis build, though the test-suite doesn't.

- Bugs 4527, 4533, 4544 broke because we now need to import [Prelude],
  not just [Notations], to get nat syntax.  I think this is an
  acceptable change, and it's incidental to the bugs being tracked, so I've
  updated the test-suite files to not rely on it.
This restores printing compatibility with v8.6.
There is more churn than there should be because SearchPattern uses a
non-local sorting algorithm; the comparison function considers many
constants equal in priority and leaves it up to the heap structure to
break ties, which seems wrong.  This has been reported as
[bug rocq-prover#5573](https://coq.inria.fr/bugs/show_bug.cgi?id=5573).
In v8.6 and trunk, numerals are parsed up to integer equality (modulo
the difference between `-0` and `0`).  We restore this by stripping
leading zeros from the string before comparison.
```
git grep --name-only 'should goes' | xargs sed s'/should goes/should go/g' -i
```
@JasonGross JasonGross force-pushed the numerals-without-int-notation-in-prelude branch from ab0b9af to f658ac7 Compare June 1, 2017 22:47
fiat-crypto was failing to build in time, and I suspect this was the
bottleneck.
I'm not actually sure if it's needed here, but this is what gives
unit-level compatibility with v8.6 / trunk.
@JasonGross
Copy link
Author

Bump.

By the way, travis is completely happy with this: https://travis-ci.org/JasonGross/coq/builds/238632055

@letouzey letouzey force-pushed the numeral-notation-2 branch 2 times, most recently from 45a90cd to 282d54d Compare March 1, 2018 18:15
@letouzey letouzey force-pushed the numeral-notation-2 branch 5 times, most recently from 16e585c to 7e2c563 Compare March 13, 2018 10:26
@letouzey letouzey force-pushed the numeral-notation-2 branch from 70c23b4 to a780f25 Compare March 21, 2018 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants