Skip to content
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

Merged
merged 5 commits into from Aug 30, 2019
Merged

Conversation

fpvandoorn
Copy link
Member

  • 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 {{ ... }}

TO CONTRIBUTORS:

Make sure you have:

  • reviewed and applied the coding style: coding, naming
  • reviewed and applied the documentation requirements
  • for tactics:
  • make sure definitions and lemmas are put in the right files
  • make sure definitions and lemmas are not redundant

Zulip

For reviewers: code review check list

- 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 `{{ ... }}`
@fpvandoorn fpvandoorn requested a review from a team as a code owner August 28, 2019 21:36
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 :=
Copy link
Collaborator

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?

Copy link
Member Author

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 -/

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful! No objections here!

@cipher1024 cipher1024 added the ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) label Aug 30, 2019
@mergify mergify bot merged commit 2db7fa4 into master Aug 30, 2019
@mergify mergify bot deleted the sanity_improvements branch August 30, 2019 16:14
anrddh pushed a commit to anrddh/mathlib that referenced this pull request May 15, 2020
* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants