Zulip Chat Archive

Stream: new members

Topic: Should I expect show_term output to type-check?


Jason Orendorff (Jun 19 2020 at 13:53):

If I add by show_term to the beginning of this proof, the output looks fairly sensible, but it fails to type-check in a couple places. Is that expected? https://gist.github.com/jorendorff/8229ce03eb29e6031602f4003bfbf153

Jason Orendorff (Jun 19 2020 at 13:54):

Both errors are around eq.rec, which I guess has special elaborator support. I wasn't able to fix either one just by adding type-annotations; one I was able to fix by adding a call to iff_of_eq and a type annotation

Jason Orendorff (Jun 19 2020 at 13:54):

the other one, I gave up

Reid Barton (Jun 19 2020 at 13:58):

Did it try to use dot notation for eq.rec?

Scott Morrison (Jun 19 2020 at 14:48):

The general answer is unfortunately "No, you should not expect output from the pretty printer to always round-trip. There's no perfect balance between readable output and correct output." But special cases may be fixable!

Jason Orendorff (Jun 19 2020 at 14:59):

Did it try to use dot notation for eq.rec?

No, that wasn't the problem. Here's the output, with comments telling what the errors were https://gist.github.com/jorendorff/8229ce03eb29e6031602f4003bfbf153#file-uniqueness_show_term_output-lean

Kevin Buzzard (Jun 19 2020 at 15:00):

I find those sorts of puzzles quite messy to solve. You can probably get everything compiling if you tell Lean the types of a few terms (i.e. replace x with (x : X)) but if you don't understand the proof properly it's difficult to fathom out what the terms are (for me, at least)

Jason Orendorff (Jun 19 2020 at 15:01):

I was really surprised that I wasn't able to fix these errors using type annotations.

Kevin Buzzard (Jun 19 2020 at 15:01):

If you set_option pp.all true you are much more likely to get something which survives the round trip -- and also much more likely to get something which is unwieldy and incomprehensible

Jason Orendorff (Jun 19 2020 at 15:02):

oh! but i can be selective... thanks

Kevin Buzzard (Jun 19 2020 at 15:02):

if you can see the wood from the trees

Jason Orendorff (Jun 19 2020 at 15:02):

it actually translates pretty cleanly, because almost all of my proof uses extremely simple tactics

Jason Orendorff (Jun 19 2020 at 15:02):

I think I'll try again with the type annotations; I was tired when I tried it last night

Jason Orendorff (Jun 19 2020 at 15:03):

(probably 97% of the problem honestly)

Reid Barton (Jun 19 2020 at 15:03):

This is basically the stupidity of the stupid triangle in action

Reid Barton (Jun 19 2020 at 15:03):

rw is just better than the Lean elaborator

Kevin Buzzard (Jun 19 2020 at 15:15):

@Jason Orendorff do you know about the widgety VS Code extension? This makes your job a lot easier.

Kevin Buzzard (Jun 19 2020 at 15:21):

The widget version of the VS Code extension shows you the expected type of everything in that pp.all mess.

Kevin Buzzard (Jun 19 2020 at 15:28):

I pasted in the @eq.rec stuff in the two places where you had an error, and now I get another error in a new place :-(

Jason Orendorff (Jun 19 2020 at 15:28):

heh!!

Jason Orendorff (Jun 19 2020 at 15:28):

The first one is big

Kevin Buzzard (Jun 19 2020 at 15:28):

stupid computer

Jason Orendorff (Jun 19 2020 at 15:29):

pasting it worked for me just now

Kevin Buzzard (Jun 19 2020 at 15:29):

Nice! I might well have slipped up then.

Jason Orendorff (Jun 19 2020 at 15:56):

hmm, even the fully expanded version times out on codewars.com, but that's a separate issue...

Kevin Buzzard (Jun 19 2020 at 15:57):

Give an upvote to the codewars version upgrade which will make everything twice as fast :-)

Jason Orendorff (Jun 19 2020 at 15:58):

is that ... an issue somewhere that i can vote on, or...?

Kevin Buzzard (Jun 19 2020 at 15:58):

I think it was mentioned in #Codewars

Jalex Stark (Jun 19 2020 at 16:51):

making things faster is a good exercise :slight_smile:

Reid Barton (Jun 19 2020 at 17:12):

I'm very surprised that the original proof times out

Jason Orendorff (Jun 19 2020 at 18:30):

Submitting an empty program times out! Apparently it is timing out trying to check mathlib's basic topology definitions and lemmas

Reid Barton (Jun 19 2020 at 18:31):

Well then

Jason Orendorff (Jun 19 2020 at 18:31):

Details in https://github.com/codewars/codewars-runner-cli/issues/824#issuecomment-646731296


Last updated: Dec 20 2023 at 11:08 UTC