Support cumulativity in the output for ULift - #60
Conversation
Adds support for importing Lean's ULift type using cumulativity instead of an inductive type. When the option is enabled: - ULift is mapped to a transparent definition (ULift_cumul) - ULift.up and ULift.down are mapped to identity functions - ULift.rec is mapped to trivial eliminators - Projections on ULift are replaced by identity Includes registered definitions in Lean.v, option handling in lean.ml, a minimal test dump, and a test file. Agent-Logs-Url: https://github.com/rocq-community/rocq-lean-import/sessions/ba4115fb-a151-49c7-a440-57e98bb41061 Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com>
Agent-Logs-Url: https://github.com/rocq-community/rocq-lean-import/sessions/ba4115fb-a151-49c7-a440-57e98bb41061 Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com>
| (* Handle ULift with cumulativity *) | ||
| if ulift_to_cumulativity () && i = 0 && N.equal n ulift_name | ||
| && Rocqlib.has_ref "lean.ULift.cumul" | ||
| then begin |
There was a problem hiding this comment.
there is already an API for predeclared things (get_predeclared_*), use that (generalizing it if necessary)
There was a problem hiding this comment.
Done in cae05d6. Generalized the predeclared API with get_predeclared_ind_as_def (for inductives predeclared as definitions using a .cumul suffix), predeclared_ind_as_def_kind type, and get_predeclared_ind_as_def_some/get_predeclared_ind_as_def_any lookup functions, following the same pattern as the existing get_predeclared_ind and get_predeclared_def APIs.
|
@copilot please address the PR comments and also @SkySkimmer 's suggestion in the issue to drop the flag and just condition the translation on whether or not the registrations are present |
- Remove `Set Lean ULift To Cumulativity` flag; condition on registration presence via `Rocqlib.has_ref` instead - Generalize predeclared API with `get_predeclared_ind_as_def` for inductives predeclared as definitions (with `.cumul` suffix) - Add per-instance cumulative definitions in Lean.v (instances 0-3) - Use the example.out dump from the issue as the test dump - Verify example1 has correct type via convertibility Check Agent-Logs-Url: https://github.com/rocq-community/rocq-lean-import/sessions/c14263e4-2114-4574-8fd3-68315e2e8b4d Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com>
All three requests addressed in cae05d6:
|
| Register ULift_ind_cumul_inst1 as lean.ULift_rec_inst1.cumul.ind. | ||
|
|
||
| (* Instance 2: r non-SProp, s=SProp | ||
| Lean Prop maps to Rocq SProp, but arguments may live in Set by cumulativity, |
There was a problem hiding this comment.
This seems strange, Rocq doesn't have cumulativity between SProp and Set.
There was a problem hiding this comment.
Removed all SProp cumul definitions from src/Lean.v in ead0230. Only instance 0 (both r, s non-SProp) supports the cumulative translation; SProp instances (1-3) fall through to normal inductive translation. The cumul definitions and Register commands are now provided at test time only.
|
@copilot Drop the manual Set/SProp definitions; those still need translation by inductive. The Register commands should be only in the test time, which should test in one module that without register the check fails, while in another module with register the check succeeds |
…no-cumul test - Remove all cumulative ULift definitions/registrations from src/Lean.v (SProp instances 1-3 were incorrect per review, instance 0 moved to test) - Move Register commands to tests/ulift_cumul.v (test-time only) - Add tests/ulift_no_cumul.v: verifies that without Register, ULift is an inductive (Fail Check for bare convertibility) - Update declare_ind to check per-instance cumul registration (not just i=0) - Fix Proj handler to check retyped head instead of global flag: returns identity only when type is not an inductive (transparent cumul case) Agent-Logs-Url: https://github.com/rocq-community/rocq-lean-import/sessions/869afe32-6302-41c3-bca8-7803335da0e9 Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com>
Done in ead0230:
|
|
@copilot Move the definition and register commands to a separate file (not in test-suite) like |
Move ULift cumulative definitions and Register commands from inline in the test file to a separate src/ULiftCumulativeRegistration.v that is part of the LeanImport package but not required by Lean.v. Users can Require Import it before Lean Import to activate cumulative ULift translation. Agent-Logs-Url: https://github.com/rocq-community/rocq-lean-import/sessions/1dbfd860-3100-4aa9-9319-9ff024615475 Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com>
Created |
|
@copilot fix ci |
Replace → with -> and – with - to fix "Undefined token" lexer error in CI where the Unicode arrow is not recognized by the Rocq lexer. Agent-Logs-Url: https://github.com/rocq-community/rocq-lean-import/sessions/3389edcd-4cf8-4004-92c0-4b549d195087 Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com>
|
@SkySkimmer tests pass, I am satisfied with the design. What do you think? |
|
seems ok |
* Initial plan * feat: add Set Lean ULift To Cumulativity option Adds support for importing Lean's ULift type using cumulativity instead of an inductive type. When the option is enabled: - ULift is mapped to a transparent definition (ULift_cumul) - ULift.up and ULift.down are mapped to identity functions - ULift.rec is mapped to trivial eliminators - Projections on ULift are replaced by identity Includes registered definitions in Lean.v, option handling in lean.ml, a minimal test dump, and a test file. Agent-Logs-Url: https://github.com/rocq-community/rocq-lean-import/sessions/ba4115fb-a151-49c7-a440-57e98bb41061 Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> * fix: remove incomplete comment from test file Agent-Logs-Url: https://github.com/rocq-community/rocq-lean-import/sessions/ba4115fb-a151-49c7-a440-57e98bb41061 Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> * refactor: use predeclared API, drop the flag, use example.out from issue - Remove `Set Lean ULift To Cumulativity` flag; condition on registration presence via `Rocqlib.has_ref` instead - Generalize predeclared API with `get_predeclared_ind_as_def` for inductives predeclared as definitions (with `.cumul` suffix) - Add per-instance cumulative definitions in Lean.v (instances 0-3) - Use the example.out dump from the issue as the test dump - Verify example1 has correct type via convertibility Check Agent-Logs-Url: https://github.com/rocq-community/rocq-lean-import/sessions/c14263e4-2114-4574-8fd3-68315e2e8b4d Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> * fix: remove SProp cumul defs from Lean.v, move Register to test, add no-cumul test - Remove all cumulative ULift definitions/registrations from src/Lean.v (SProp instances 1-3 were incorrect per review, instance 0 moved to test) - Move Register commands to tests/ulift_cumul.v (test-time only) - Add tests/ulift_no_cumul.v: verifies that without Register, ULift is an inductive (Fail Check for bare convertibility) - Update declare_ind to check per-instance cumul registration (not just i=0) - Fix Proj handler to check retyped head instead of global flag: returns identity only when type is not an inductive (transparent cumul case) Agent-Logs-Url: https://github.com/rocq-community/rocq-lean-import/sessions/869afe32-6302-41c3-bca8-7803335da0e9 Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> * refactor: move cumul definitions to src/ULiftCumulativeRegistration.v Move ULift cumulative definitions and Register commands from inline in the test file to a separate src/ULiftCumulativeRegistration.v that is part of the LeanImport package but not required by Lean.v. Users can Require Import it before Lean Import to activate cumulative ULift translation. Agent-Logs-Url: https://github.com/rocq-community/rocq-lean-import/sessions/1dbfd860-3100-4aa9-9319-9ff024615475 Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> * fix: replace Unicode arrow and en-dash in ULiftCumulativeRegistration.v Replace → with -> and – with - to fix "Undefined token" lexer error in CI where the Unicode arrow is not recognized by the Rocq lexer. Agent-Logs-Url: https://github.com/rocq-community/rocq-lean-import/sessions/3389edcd-4cf8-4004-92c0-4b549d195087 Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com>
* Initial plan * feat: add Set Lean ULift To Cumulativity option Adds support for importing Lean's ULift type using cumulativity instead of an inductive type. When the option is enabled: - ULift is mapped to a transparent definition (ULift_cumul) - ULift.up and ULift.down are mapped to identity functions - ULift.rec is mapped to trivial eliminators - Projections on ULift are replaced by identity Includes registered definitions in Lean.v, option handling in lean.ml, a minimal test dump, and a test file. Agent-Logs-Url: https://github.com/rocq-community/rocq-lean-import/sessions/ba4115fb-a151-49c7-a440-57e98bb41061 Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> * fix: remove incomplete comment from test file Agent-Logs-Url: https://github.com/rocq-community/rocq-lean-import/sessions/ba4115fb-a151-49c7-a440-57e98bb41061 Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> * refactor: use predeclared API, drop the flag, use example.out from issue - Remove `Set Lean ULift To Cumulativity` flag; condition on registration presence via `Rocqlib.has_ref` instead - Generalize predeclared API with `get_predeclared_ind_as_def` for inductives predeclared as definitions (with `.cumul` suffix) - Add per-instance cumulative definitions in Lean.v (instances 0-3) - Use the example.out dump from the issue as the test dump - Verify example1 has correct type via convertibility Check Agent-Logs-Url: https://github.com/rocq-community/rocq-lean-import/sessions/c14263e4-2114-4574-8fd3-68315e2e8b4d Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> * fix: remove SProp cumul defs from Lean.v, move Register to test, add no-cumul test - Remove all cumulative ULift definitions/registrations from src/Lean.v (SProp instances 1-3 were incorrect per review, instance 0 moved to test) - Move Register commands to tests/ulift_cumul.v (test-time only) - Add tests/ulift_no_cumul.v: verifies that without Register, ULift is an inductive (Fail Check for bare convertibility) - Update declare_ind to check per-instance cumul registration (not just i=0) - Fix Proj handler to check retyped head instead of global flag: returns identity only when type is not an inductive (transparent cumul case) Agent-Logs-Url: https://github.com/rocq-community/rocq-lean-import/sessions/869afe32-6302-41c3-bca8-7803335da0e9 Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> * refactor: move cumul definitions to src/ULiftCumulativeRegistration.v Move ULift cumulative definitions and Register commands from inline in the test file to a separate src/ULiftCumulativeRegistration.v that is part of the LeanImport package but not required by Lean.v. Users can Require Import it before Lean Import to activate cumulative ULift translation. Agent-Logs-Url: https://github.com/rocq-community/rocq-lean-import/sessions/1dbfd860-3100-4aa9-9319-9ff024615475 Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> * fix: replace Unicode arrow and en-dash in ULiftCumulativeRegistration.v Replace → with -> and – with - to fix "Undefined token" lexer error in CI where the Unicode arrow is not recognized by the Rocq lexer. Agent-Logs-Url: https://github.com/rocq-community/rocq-lean-import/sessions/3389edcd-4cf8-4004-92c0-4b549d195087 Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com>
get_predeclared_ind_as_deffor.cumulsuffixdeclare_indchecks per-instance cumul registrationsto_constrProj case handles transparent cumulative typesRocqlib.has_refsrc/ULiftCumulativeRegistration.v(not required byLean.v, can beRequire Imported)tests/ulift_no_cumul.v: without Register, ULift is an inductive (Fail Check)tests/ulift_cumul.v: withRequire Import ULiftCumulativeRegistration, ULift is transparent→with->inULiftCumulativeRegistration.v