Zulip Chat Archive

Stream: lean4

Topic: inferInstance v infer_instance


Kevin Buzzard (Jan 15 2024 at 21:23):

The tactic rfl is now spelt the same as the term rfl and I think historically we have plenty of justification for the claim that this is less confusing for beginners (there are several examples on this Zulip of people asking what the difference is between rfl and refl in Lean 3). Similarly the tactic sorry and the term sorry are spelt the same. Would it be a good idea to hence unify the spelling of the term inferInstance and the tactic infer_instance? This just came up in my teaching.

Henrik Böving (Jan 15 2024 at 21:27):

In principle: Since it has an underscore/two words this would go against our typical name scheme of snek case for tactics and proof stuff and camel case for proper values. I don't know if it is reasonable to make an exception here? If we do make an exception we should make it consistent, i.e. every term that has a corresponding tactic should be named the same style.

Geoffrey Irving (Jan 15 2024 at 21:27):

instance?

Henrik Böving (Jan 15 2024 at 21:27):

That's a keyword, not such a good idea

Damiano Testa (Jan 15 2024 at 21:49):

inst?

Jireh Loreaux (Jan 15 2024 at 22:28):

inst is frequently used as a variable name, so I'm not a fan of changing to that.

Eric Wieser (Jan 15 2024 at 23:51):

I think this is a nice lesson in "tactics use a different naming convention to definitions", and everything is working as intended

Yury G. Kudryashov (Jan 16 2024 at 00:23):

If you want to allow both spellings in your course or local repository, then it's easy to do.

Mario Carneiro (Jan 16 2024 at 00:33):

I think it would be better if they were called synth_instance. It is confusing that the command is called #synth but I can never remember if the tactic is called infer_instance or apply_instance or synth_instance

Mario Carneiro (Jan 16 2024 at 00:34):

(or conversely I suppose we could rename the other command to #infer)

Mario Carneiro (Jan 16 2024 at 00:35):

Come to think of it, synth could probably be used alone, without the "instance" part, resulting in a synth term/tactic and #synth command

David Thrane Christiansen (Jan 16 2024 at 10:11):

It certainly makes sense to use consistent terminology for operations. Is "synthesis" the appropriate thing to be consistent with?

As far as I know, no other system uses this terminology. Coq calls it "inference", while Haskell and Agda call it "resolution". Usually, I would expect synthesis to be something done either in the tradition of bidirectional type checking or in the field of program synthesis, which is not really the heritage of this feature.

Henrik Böving (Jan 16 2024 at 10:17):

The original reason for synthesis to surface to the user is probably that it is internally refererred to as synthesis as well, you have e.g. synthInstance tracing etc.

Mario Carneiro (Jan 16 2024 at 10:27):

Considering the abstract (CS) meanings of "synthesis" and "inference", I think that typeclass inference leans much more on the "synthesis" side than "inference" - it's constructing a term not by unification but by sticking pieces together in ~arbitrary order, with non-unique results which don't really resemble any of the inputs directly. IMO it's not too far from program synthesis

Mario Carneiro (Jan 16 2024 at 10:28):

Lean does "inference", when it infers _ in terms by unification. Seems like a good idea to keep this concept distinct from the exploratory thing that is typeclass inference

Johan Commelin (Jan 16 2024 at 10:43):

So should we start calling it "typeclass synthesis" instead?

Eric Wieser (Jan 16 2024 at 10:45):

So synthInstance and synth_instance?

Mario Carneiro (Jan 16 2024 at 11:28):

or just synth as I mentioned above

Jireh Loreaux (Jan 16 2024 at 15:48):

Just synth I think is nice, and I like the distinction between instance synthesis and inference of holes.


Last updated: May 02 2025 at 03:31 UTC