Skip to content

Actually abstracting large nat constants#22254

Draft
proux01 wants to merge 1 commit into
rocq-prover:masterfrom
proux01:abstract-large-nat
Draft

Actually abstracting large nat constants#22254
proux01 wants to merge 1 commit into
rocq-prover:masterfrom
proux01:abstract-large-nat

Conversation

@proux01

@proux01 proux01 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Instead of parsing large nat constants as Nat.of_uint <decimal encoding> and just leaving the term unevaluated and ready to blow up at next computation or unification, we hide the definition of Nat.of_uint behind a module type, thus preventing any accidental blowup. The actual definition can still be recovered by a simple rewriting.

(* previously *)
Goal 12000 = 6000 + 6000.
(* Warning: To avoid stack overflow, large numbers in nat are interpreted as applications of Nat.of_num_uint. [abstract-large-number,numbers,default] [x3] *)
Proof.
(* Nat.of_num_uint 12000%uint = Nat.of_uint 6000%uint + Nat.of_uint 6000%uint *)
vm_compute.
(* 12000 = 12000 *)
reflexivity.
Qed.

(* this PR *)
Goal 12000 = 6000 + 6000.
Proof.
(* Nat.Of_uint.locked 12000%uint = Nat.Of_uint.locked 6000%uint + Nat.Of_uint.locked 6000%uint *)
vm_compute.
(* essentially no change *)
Fail reflexivity.
Search Nat.Of_uint.locked.
(* Nat.Of_uint.unlock: Nat.Of_uint.locked = Nat.of_uint *)
rewrite Nat.Of_uint.unlock.
(* Nat.of_uint 12000%uint = Nat.of_uint 6000%uint + Nat.of_uint 6000%uint *)
vm_compute.
(* 12000 = 12000 *)
reflexivity.
Qed.
  • Added / updated test-suite.
  • Added changelog.
  • Added / updated documentation.
    • Documented any new / changed user messages.
    • Updated documented syntax by running make doc_gram_rsts.

Overlays (to be merged before the current PR)

  • TODO coqutil
  • TODO engine_bench
  • TODO paramcoq
  • TODO equations tests
  • TODO mathcomp tests

@proux01 proux01 added the request: full CI Use this label when you want your next push to trigger a full CI. label Jul 10, 2026
@coqbot-app coqbot-app Bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label Jul 10, 2026
@proux01 proux01 added the request: full CI Use this label when you want your next push to trigger a full CI. label Jul 10, 2026
@proux01 proux01 force-pushed the abstract-large-nat branch from b796c3b to eda7495 Compare July 10, 2026 12:25
@coqbot-app coqbot-app Bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label Jul 10, 2026
@proux01 proux01 added the part: core library Corelib in theories/ label Jul 13, 2026
@proux01 proux01 changed the title [WIP] Test actually abstracting large nat constants Actually abstracting large nat constants Jul 13, 2026
@proux01

proux01 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

@silene you're probably the expert here, do you think we should do this? If yes, I'll complete the PR / do the few overlays and cleanup the adhoc abstract after and warning after options of Number Notation, for which this was the only use. Otherwise, let's just drop this experiment.

@silene

silene commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

I am not convinced. I understand where this is coming from, but I am not sure there is a proper solution. It might be better to not fix it, so that users encounter hard failures as early as possible, rather than to hide the issue and delay it further and further. It is important that users understand that there is an inherent cost to using unary integers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part: core library Corelib in theories/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants