New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(sanity_check): improve sanity_check #1369
Conversation
- add hole command for sanity check (note: hole commands only work when an expression is expected, not when a command is expected, which is unfortunate) - print the type of the unused arguments - print whether an unused argument is a duplicate - better check to filter automatically generated declarations - do not print arguments of type `parse _` - The binding brackets from `tactic.where` are moved to `meta.expr`. The definition is changed so that strict implicit arguments are printed as `{{ ... }}`
Fun fact: I had to remove an unused argument from `decidable_chain'` for my function to work.
trace (to_fmt "/- UNUSED ARGUMENTS: -/" ++ f ++ format.line), | ||
f ← print_decls_mathlib incorrect_def_lemma, | ||
trace (to_fmt "/- INCORRECT DEF/LEMMA: -/" ++ f ++ format.line), | ||
skip | ||
|
||
@[hole_command] meta def sanity_check_hole_cmd : hole_command := |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand this right, you're simply inserting the sanity check messages inside the source file, right? Any chance we may insert it as a comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is correct. But the sanity check message returns compiling Lean code (using #print
commands). See the example below. The #print
commands are useful to quickly jump to the corresponding definition, which would be lost inside a comment.
/- Note: This command is still in development. -/
/- UNUSED ARGUMENTS: -/
-- tactic\core.lean
#print tactic.symmetry_hyp /- argument 2: (md : opt_param transparency transparency.semireducible) -/
-- meta\rb_map.lean
#print native.rb_map.find_def /- argument 4: [_inst_2 : decidable_rel has_lt.lt] -/
-- logic\basic.lean
#print imp_intro /- argument 4: (h₂ : β) -/
#print not_iff /- argument 3: [_inst_1 : decidable a] -/
#print ball_of_forall /- argument 6: (_x : q x) -/
-- data\list\defs.lean
#print list.func.neg /- argument 2: [_inst_1 : inhabited α] -/
-- category\basic.lean
#print map_seq /- argument 6: [_inst_2 : is_lawful_applicative F] (duplicate) -/
#print seq_map_assoc /- argument 6: [_inst_2 : is_lawful_applicative F] (duplicate) -/
/- INCORRECT DEF/LEMMA: -/
-- logic\basic.lean
#print imp_intro /- is a lemma/theorem, should be a def -/
#print not.elim /- is a lemma/theorem, should be a def -/
#print Exists.imp /- is a def, should be a lemma/theorem -/
#print classical.dec_rel /- is a lemma/theorem, should be a def -/
#print classical.dec_eq /- is a lemma/theorem, should be a def -/
#print classical.dec_pred /- is a lemma/theorem, should be a def -/
#print classical.dec /- is a lemma/theorem, should be a def -/
/- DUPLICATED NAMESPACES IN NAME: -/
-- tactic\core.lean
#print tactic.tactic.has_to_tactic_format /- The namespace tactic is duplicated in the name -/
#print tactic.tactic.use /- The namespace tactic is duplicated in the name -/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful! No objections here!
* feat(sanity_check): improve sanity_check - add hole command for sanity check (note: hole commands only work when an expression is expected, not when a command is expected, which is unfortunate) - print the type of the unused arguments - print whether an unused argument is a duplicate - better check to filter automatically generated declarations - do not print arguments of type `parse _` - The binding brackets from `tactic.where` are moved to `meta.expr`. The definition is changed so that strict implicit arguments are printed as `{{ ... }}` * typos * improve docstring * Also check for duplicated namespaces Fun fact: I had to remove an unused argument from `decidable_chain'` for my function to work.
parse _
tactic.where
are moved tometa.expr
. The definition is changed so that strict implicit arguments are printed as{{ ... }}
TO CONTRIBUTORS:
Make sure you have:
Zulip
For reviewers: code review check list