Zulip Chat Archive
Stream: new members
Topic: How to run a old lean3 project?
chenjulang (Jan 11 2024 at 10:35):
How to run a old lean3 project? Or how to translate it into lean4 to run?
Like this: https://github.com/kendfrey/rubiks-cube-group
Ruben Van de Velde (Jan 11 2024 at 10:36):
https://leanprover-community.github.io/leanproject.html
chenjulang (Jan 11 2024 at 10:44):
I dont know how to solve this:
image.png
chenjulang (Jan 11 2024 at 10:52):
I'm going to translate the files into lean4 myself...
Kevin Buzzard (Jan 11 2024 at 11:19):
You know about the program which attempts to do this automatically? https://github.com/leanprover-community/mathport (but if you cannot compile the project on your machine, you might also have problems using mathport)
chenjulang (Jan 11 2024 at 14:39):
I'll try , thank you :heart:
chenjulang (Jan 12 2024 at 06:59):
I tried oneshot, but failed at this command"make lean3-source":
image.png
chenjulang (Jan 12 2024 at 07:01):
Any one succeed before? If you have time, these 4 files needs help:
chenjulang (Jan 12 2024 at 07:01):
array_group.lean
array_perm_group.lean
fin_group.lean
rubiks_cube.lean
Mauricio Collares (Jan 12 2024 at 07:17):
brew install gmp
could help with that, but Lean 3 probably wants x86 GMP, so you probably need to use x86 brew
chenjulang (Jan 12 2024 at 07:17):
I'll try
chenjulang (Jan 12 2024 at 07:19):
yeah, Still Error
image.png
i dont know how
Mario Carneiro (Jan 12 2024 at 07:34):
@chenjulang I tried porting your files myself, but import algebra.group
fails. Step 0 of mathport is to upgrade to the latest lean 3
chenjulang (Jan 12 2024 at 07:35):
em..
chenjulang (Jan 12 2024 at 07:36):
i could not find the way to uninstall my lean4 and install lean3
Mario Carneiro (Jan 12 2024 at 07:41):
no need, they coexist
Mario Carneiro (Jan 12 2024 at 07:42):
the procedure for updating lean 3 is to set your lean-toolchain
to match that of mathlib
Mario Carneiro (Jan 12 2024 at 07:43):
(and make a project if you haven't already, leanproject new foo
should do it IIRC)
Ruben Van de Velde (Jan 12 2024 at 07:47):
I'll see if I can upgrade mathlib3 in the next little bit
chenjulang (Jan 12 2024 at 07:48):
em... I got a new problem with "leanproject new foo":
image.png
Mario Carneiro (Jan 12 2024 at 07:49):
leanproject +version new foo
where version
is the appropriate version of lean 3
Mario Carneiro (Jan 12 2024 at 07:49):
er, no leanproject
isn't an elan wrapper
Mario Carneiro (Jan 12 2024 at 07:50):
elan toolchain override <version>
in the folder you are running the command in I guess?
chenjulang (Jan 12 2024 at 07:52):
no idea..
image.png
Mario Carneiro (Jan 12 2024 at 07:53):
version
should be leanprover-community/lean:3.51.1
Mario Carneiro (Jan 12 2024 at 07:54):
elan override set leanprover-community/lean:3.51.1
leanproject new foo
elan override unset
cd foo
leanproject build
chenjulang (Jan 12 2024 at 07:55):
OK, i'll try
chenjulang (Jan 12 2024 at 07:58):
I Failed in the first step :sweat_smile: : "elan toolchain override set leanprover-community/lean:3.51.1"
image.png
Mario Carneiro (Jan 12 2024 at 08:00):
sorry, my fault, it's just elan override
not elan toolchain override
chenjulang (Jan 12 2024 at 08:00):
OK
chenjulang (Jan 12 2024 at 08:02):
elan override set 3.51.1 ?
image.png
chenjulang (Jan 12 2024 at 08:02):
downloading...
chenjulang (Jan 12 2024 at 08:06):
A problem, it is downloading from lean4 by default?:
image.png
Mario Carneiro (Jan 12 2024 at 08:08):
I think the first one looked the most promising
chenjulang (Jan 12 2024 at 08:09):
image.png
I failed ,but when i list, i have installed lean3 somehow?
Mauricio Collares (Jan 12 2024 at 08:09):
Mario Carneiro said:
elan toolchain override set leanprover-community/lean:3.51.1 leanproject new foo elan toolchain override unset cd foo leanproject build
Did you try the exact commands Mario suggested?
chenjulang (Jan 12 2024 at 08:10):
No, the first line gets a error.
Mario Carneiro (Jan 12 2024 at 08:10):
minus the toolchain
part
Mario Carneiro (Jan 12 2024 at 08:11):
elan override set leanprover-community/lean:3.51.1
didn't fail
Mario Carneiro (Jan 12 2024 at 08:11):
it wasn't able to parse the version for display purposes, but that doesn't really matter
chenjulang (Jan 12 2024 at 08:11):
OK
Mario Carneiro (Jan 12 2024 at 08:12):
@Sebastian Ullrich did elan lose the ability to parse lean 3 version strings?
chenjulang (Jan 12 2024 at 08:13):
I Failed the second step :laughing: "leanproject new foo"..
image.png
Mario Carneiro (Jan 12 2024 at 08:15):
ah okay so that's the same issue as with mathport, it seems like you can't run lean at all, you are missing some system dependencies?
chenjulang (Jan 12 2024 at 08:15):
I can run lean4 projects , in this M1 Macbook ,by the way
Mario Carneiro (Jan 12 2024 at 08:16):
does lean --version
work?
Mauricio Collares (Jan 12 2024 at 08:16):
Presumably you've used Lean 3 on this machine (to write the files you want to port, for example). Do you have to do anything special to use it without getting an error message like the one above? Or are the files written by someone else?
chenjulang (Jan 12 2024 at 08:16):
someone else
Mauricio Collares (Jan 12 2024 at 08:16):
Ah, got it
chenjulang (Jan 12 2024 at 08:17):
i never use lean3
chenjulang (Jan 12 2024 at 08:17):
:joy:
chenjulang (Jan 12 2024 at 08:17):
image.png
I can use lean4.
Mauricio Collares (Jan 12 2024 at 08:17):
Follow these instructions to install x86 brew: https://gist.github.com/progrium/b286cd8c82ce0825b2eb3b0b3a0720a0
Mauricio Collares (Jan 12 2024 at 08:17):
Then use x86 brew to install gmp
chenjulang (Jan 12 2024 at 08:17):
OK
Mario Carneiro (Jan 12 2024 at 08:18):
are you on an M1 mac?
chenjulang (Jan 12 2024 at 08:18):
YES
Mario Carneiro (Jan 12 2024 at 08:19):
you may find https://leanprover-community.github.io/lean3/install/macos.html useful
Mario Carneiro (Jan 12 2024 at 08:19):
Specifically, elan – which is installed as part of the above instructions – will not be able to fetch Lean binaries on these devices if installed the normal way.
oh
chenjulang (Jan 12 2024 at 08:20):
So?I'm confused
Mario Carneiro (Jan 12 2024 at 08:20):
follow the instructions there, in the "M1 macs" section
chenjulang (Jan 12 2024 at 08:21):
OK, do i need to intall x86 brew? by the way?
Mauricio Collares (Jan 12 2024 at 08:21):
Does mathport have a gitpod config set up? Might be easier for a one-time effort
Mauricio Collares (Jan 12 2024 at 08:22):
chenjulang said:
OK, do i need to intall x86 brew? by the way?
Yes, but but Mario's instructions do that too and they're more detailed. Just follow his instructions and ignore mine.
Mario Carneiro (Jan 12 2024 at 08:22):
I think @Eric Wieser might have set something like that up? I'm a total noob wrt docker / gitpod stuff
chenjulang (Jan 12 2024 at 08:23):
Mauricio Collares said:
chenjulang said:
OK, do i need to intall x86 brew? by the way?
Yes, but but Mario's instructions do that too and they're more detailed. Just follow his instructions and ignore mine.
thanks
Mario Carneiro (Jan 12 2024 at 08:24):
(also it's a bad day to try mathport, the last mathlib4 upgrade broke so I'm temporarily without a working setup until the next nightly)
chenjulang (Jan 12 2024 at 08:26):
Oh , bad luck
Ruben Van de Velde (Jan 12 2024 at 08:30):
https://github.com/Ruben-VandeVelde/rubiks-cube-group has it updated to latest mathlib3
chenjulang (Jan 12 2024 at 09:45):
Now i have intalled gmp . I can succeed in command "make lean3-source".
But in the last step "make oneshot", still problem:
" failed to resolve 'init'"
image.png
chenjulang (Jan 12 2024 at 09:51):
For example , i try to translate "mathlib/archive/wiedijk_100_theorems
/solution_of_cubic.lean" in lean3 into Lean4, and get this error again:
image.png
Ruben Van de Velde (Jan 12 2024 at 09:56):
That's not the problem. The problem is all the build errors above that. Did you use the code and mathlib version I linked?
chenjulang (Jan 12 2024 at 09:56):
Oh, i only use the code
chenjulang (Jan 12 2024 at 09:57):
But how to use the "mathlib version" you linked?
Eric Wieser (Jan 12 2024 at 09:58):
While not relevant to the current issues, you might find https://github.com/leanprover-community/ProofWidgets4/blob/main/ProofWidgets/Demos/Rubiks.lean interesting
chenjulang (Jan 12 2024 at 09:58):
Yeah , i knew it
chenjulang (Jan 12 2024 at 09:58):
But no proofs in that repository, only html
chenjulang (Jan 12 2024 at 10:04):
I thought mathport only needs a single file to translate into lean4, right?
image.png
So how to use the mathlib you linked?
[Quoting…]
chenjulang (Jan 12 2024 at 10:13):
I'll try again
chenjulang (Jan 12 2024 at 10:51):
Now i succeed translating the single files, but some compilation errors occurred:
image.png
chenjulang (Jan 12 2024 at 10:53):
the "imports" always lacks "Mathlib."
image.png
chenjulang (Jan 12 2024 at 10:57):
I'll try whole project translating.
Mauricio Collares (Jan 12 2024 at 12:44):
Mathport output definitely requires some manual fixing
Mario Carneiro (Jan 12 2024 at 16:46):
yeah, if you got it to produce lean 4 looking files then mathport succeeded, any remaining errors that occur in the file have to be handled manually
Mario Carneiro (Jan 12 2024 at 16:46):
there is a regex in mathlib4 that does some easy fixups to mathport output (which should be upstreamed)
Last updated: May 02 2025 at 03:31 UTC