Zulip Chat Archive
Stream: new members
Topic: Why named vs implicit arguments in function declarations?
Castedo Ellerman (Feb 04 2026 at 14:55):
Learning from textbook Logic and Mechanized Reasoning I read
inductive Lit where
| tr : Lit
| fls : Lit
| pos : String → Lit
| neg : String → Lit
inductive NnfForm where
| lit (l : Lit) : NnfForm
...
Why not
| neg (s : String): Lit
or
| lit : Lit → NnfForm
?
Is it just a subjective judgement call whether a named argument makes it easier to read (and error messages realted to it)? Am I using the terms "named argument" and "implicit argument" correctly?
Eric Wieser (Feb 04 2026 at 15:56):
"implicit argument" means {s : String}, I think probably "anonymous" is a better name for what you mean
Moritz R (Feb 04 2026 at 16:43):
I can only answer from the perspective of the code actions that generate match and induction cases. These will try to use the names (like s) supplied in the definiton.
Moritz R (Feb 04 2026 at 16:43):
These Codeactions are in Batteries (and by import of Batteries, also in mathlib)
Moritz R (Feb 04 2026 at 16:43):
e.g.
Moritz R (Feb 04 2026 at 16:45):
import Batteries
inductive Lit where
| tr : Lit
| fls : Lit
| pos (s : String) : Lit
| neg : String → Lit
def bla (t : Lit) :=
match t with -- put your cursor directly after `with`, click the lightbulb (or the corresponding vscode-shortcut) and generate the patterns.
Moritz R (Feb 04 2026 at 16:45):
gives
Moritz R (Feb 04 2026 at 16:45):
import Batteries
inductive Lit where
| tr : Lit
| fls : Lit
| pos (s : String) : Lit
| neg : String → Lit
def bla (t : Lit) :=
match t with
| .tr => _
| .fls => _
| .pos s => _
| .neg _ => _ -- put your cursor directly after `with`, click the lightbulb (or the corresponding vscode-shortcut) and generate the patterns.
Moritz R (Feb 04 2026 at 16:46):
Notice the s at .pos and the _ at .neg
Moritz R (Feb 04 2026 at 16:48):
So for arguments that should have a standard name when doing induction/match, i would say give them a name
Last updated: Feb 28 2026 at 14:05 UTC