Fix Quot and Eq names for Lean 4 compatibility#45
Conversation
Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com>
Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com>
JasonGross
left a comment
There was a problem hiding this comment.
@copilot Changes to Lean.v are not necessary, only change the casing in leanParse.ml, not lean.ml
Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com>
I think they were necessary, declare_quot uses quot_name to get the registers |
|
I see. Okay, @copilot put back the changes to Lean.v |
Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com>
Head branch was pushed to by a user without write access
Restored changes to Lean.v and lean.ml. All three files (leanParse.ml, Lean.v, and lean.ml) are now updated because |
|
@SkySkimmer I guess we need to rename eq to Eq too? |
|
@copilot rename eq to Eq and similar to fix Add |
Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com>
Head branch was pushed to by a user without write access
|
@SkySkimmer does any of the other machinery require the same naming between Rocq and Lean? Do you have any idea why we're importing |
|
@SkySkimmer I think this is a bug in Rocq, or else an issue with how the plugin is ascribing relevance marks: From LeanImport Require Import Lean.
Lean Import "../dumps/pnni.out" 1 67843.
Goal forall n' m',
@eq Bool
(Lean_Omega_Constraint_sat'
(Lean_Omega_tidyConstraint
(Lean_Omega_Constraint_mk
(Option_some_inst1 Int
(OfNat_ofNat_inst1 Int Nat_zero (instOfNat Nat_zero)))
(Option_some_inst1 Int
(OfNat_ofNat_inst1 Int Nat_zero (instOfNat Nat_zero))))
(List_cons_inst1 Int
(OfNat_ofNat_inst1 Int (Nat_succ (Nat_succ Nat_zero))
(instOfNat (Nat_succ (Nat_succ Nat_zero))))
(List_cons_inst1 Int
(Neg_neg_inst1 Int Int_instNegInt
(OfNat_ofNat_inst1 Int (Nat_succ (Nat_succ Nat_zero))
(instOfNat (Nat_succ (Nat_succ Nat_zero)))))
(List_nil_inst1 Int))))
(Lean_Omega_tidyCoeffs
(Lean_Omega_Constraint_mk
(Option_some_inst1 Int
(OfNat_ofNat_inst1 Int Nat_zero (instOfNat Nat_zero)))
(Option_some_inst1 Int
(OfNat_ofNat_inst1 Int Nat_zero (instOfNat Nat_zero))))
(List_cons_inst1 Int
(OfNat_ofNat_inst1 Int (Nat_succ (Nat_succ Nat_zero))
(instOfNat (Nat_succ (Nat_succ Nat_zero))))
(List_cons_inst1 Int
(Neg_neg_inst1 Int Int_instNegInt
(OfNat_ofNat_inst1 Int (Nat_succ (Nat_succ Nat_zero))
(instOfNat (Nat_succ (Nat_succ Nat_zero)))))
(List_nil_inst1 Int))))
(Lean_Omega_Coeffs_ofList
(List_cons_inst1 Int (Nat_cast_inst1 Int instNatCastInt n')
(List_cons_inst1 Int (Nat_cast_inst1 Int instNatCastInt m')
(List_nil_inst1 Int)))))
Bool_true ->
@eq Bool
(Lean_Omega_Constraint_sat'
(Lean_Omega_Constraint_mk
(Option_some_inst1 Int
(OfNat_ofNat_inst1 Int Nat_zero (instOfNat Nat_zero)))
(Option_some_inst1 Int
(OfNat_ofNat_inst1 Int Nat_zero (instOfNat Nat_zero))))
(List_cons_inst1 Int
(OfNat_ofNat_inst1 Int (Nat_succ Nat_zero)
(instOfNat (Nat_succ Nat_zero)))
(List_cons_inst1 Int
(Neg_neg_inst1 Int Int_instNegInt
(OfNat_ofNat_inst1 Int (Nat_succ Nat_zero)
(instOfNat (Nat_succ Nat_zero))))
(List_nil_inst1 Int)))
(Lean_Omega_Coeffs_ofList
(List_cons_inst1 Int (Nat_cast_inst1 Int instNatCastInt n')
(List_cons_inst1 Int (Nat_cast_inst1 Int instNatCastInt m')
(List_nil_inst1 Int)))))
Bool_true.
intros n' m'.
Fail intro x; exact x. (* type mismatch *)
cbv. (* Alt: cbn. cbv [Lean_Omega_Constraint_div]. *)
intro x; exact x. (* success *)
Fail Qed. |
* Initial plan * Initial plan for fixing Quot name issue Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> * Change quot to Quot for Lean 4 compatibility Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> * Revert changes to Lean.v and lean.ml, keep only leanParse.ml change Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> * Restore Lean.v and lean.ml changes for Quot registration Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> * Rename eq to Eq for Lean 4 compatibility with backwards compat notation Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> * Work around issue in Rocq --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> Co-authored-by: Jason Gross <jgross@mit.edu>
* Initial plan * Initial plan for fixing Quot name issue Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> * Change quot to Quot for Lean 4 compatibility Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> * Revert changes to Lean.v and lean.ml, keep only leanParse.ml change Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> * Restore Lean.v and lean.ml changes for Quot registration Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> * Rename eq to Eq for Lean 4 compatibility with backwards compat notation Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> * Work around issue in Rocq --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JasonGross <396076+JasonGross@users.noreply.github.com> Co-authored-by: Jason Gross <jgross@mit.edu>
Lean 4 exports use
QuotandEq(capital letters) for quotient and equality types, but the importer was hardcoded toquotandeq(lowercase) from Lean 3. This caused "missing Quot" errors and type mismatch errors when importing Lean 4 files.Changes:
Quot changes:
quot_namefrom"quot"to"Quot"lean.quot.*tolean.Quot.*has_refcheck from"lean.quot"to"lean.Quot"Eq changes:
lean.eqtolean.Eqandlean.eq_inst1tolean.Eq_inst1Notation Eq := eq (only parsing).for backwards compatibility["eq"]to["Eq"]Tests:
pnni.vtest case using the provided Lean 4 exportExample from the failing export:
Why all these changes are needed:
The
declare_quotfunction in lean.ml constructs registration strings usingquot_name:"lean." ^ N.to_lean_string lean. Sincequot_nameis now "Quot", the Register statements in Lean.v must uselean.Quot.*to match, and thehas_refcheck must also look forlean.Quot. Similarly, the predeclared inductives lookup uses names from Lean exports, so "eq" must be changed to "Eq" to match Lean 4's naming.Errors fixed:
The parser now correctly recognizes these Quot and Eq names from Lean 4 exports and properly registers them on the Rocq side.
Fixes #44
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.