Skip to content

[Merged by Bors] - feat: the 'hint' tactic#8363

Closed
kim-em wants to merge 11 commits intomasterfrom
hint_tactic
Closed

[Merged by Bors] - feat: the 'hint' tactic#8363
kim-em wants to merge 11 commits intomasterfrom
hint_tactic

Conversation

@kim-em
Copy link
Copy Markdown
Contributor

@kim-em kim-em commented Nov 12, 2023

example (h : 1 < 0) : False := by hint
example {P Q : Prop} (p : P) (f : P → Q) : Q := by hint
example {P Q R: Prop} (x : P ∧ Q ∧ R ∧ R) : Q ∧ P ∧ R := by hint
example {a b : ℚ} (h : a < b) : ¬ b < a := by hint
example : 37^2 - 35^2 = 72 * 2 := by hint
example : Nat.Prime 37 := by hint

Tries out any tactics registered using register_hint tac, and reports which ones succeed using the new "Try these: " multiple suggestion widgets. Tactics that close the goal are highlighted in green. Tactics that succeed but don't close the goal display the new subgoals in the widget. If tac produces a "Try this: " message, use that instead of tac.

I haven't hooked up aesop yet, because of leanprover-community/aesop#85. Similarly for norm_num.

I would like to parallelize this, but I don't think that needs to happen right away.


Open in Gitpod

@kim-em kim-em added awaiting-review awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. labels Nov 12, 2023
@github-actions github-actions bot removed the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Nov 12, 2023
@timotree3
Copy link
Copy Markdown
Collaborator

How does this compare with #5363?

@kim-em
Copy link
Copy Markdown
Contributor Author

kim-em commented Nov 13, 2023

How does this compare with #5363?

Oh! I had completely failed to notice that. Apologies in particular to @Komyyy.

I'm impressed how parallel parts of the implementation are. :-) My version uses the new "Try these:" widget for providing multiple suggestions (edit: oh, so does @Komyyy's), and also does some additional post-processing to stop if it finds a tactic that closes the goal, and also shows the remaining subgoals for each suggestion in the widget.

@Komyyy, how should we proceed? Can we combine these into something better than either?

@kim-em
Copy link
Copy Markdown
Contributor Author

kim-em commented Nov 13, 2023

I will immediately steal the let tac : Syntax.Tactic := ⟨tac.raw.copyHeadTailInfoFrom .missing⟩ trick, which I presume solves the unreachable tactic warning.

Edit: nope. I wonder what it is for.

@Komyyy Komyyy added WIP Work in progress and removed awaiting-review labels Nov 14, 2023
@Komyyy Komyyy mentioned this pull request Nov 14, 2023
2 tasks
@Komyyy Komyyy added awaiting-review awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. and removed WIP Work in progress labels Nov 14, 2023
@Komyyy
Copy link
Copy Markdown
Contributor

Komyyy commented Nov 14, 2023

I integrated my changes:

  1. Remove some placeholders for mathport
  2. Remove some comments for add_hint_tactic
  3. Align import
  4. Add an new process for register_hint to remove following comments
  5. Register the register_hint syntax as an exception of UnreachableTactic linter

@github-actions github-actions bot removed the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Nov 14, 2023
@kim-em
Copy link
Copy Markdown
Contributor Author

kim-em commented Nov 14, 2023

Thank you, @Komyyy, and apologies again for missing your earlier PR.

@kim-em
Copy link
Copy Markdown
Contributor Author

kim-em commented Nov 14, 2023

Okay, I have a modification to this that runs all the hint tactics in parallel, and it's lovely. I still need to move some lemmas around to get the imports to work out, so we should merge this in the meantime.

section Hint

register_hint split
register_hint intro
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should tauto be included here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

At present there is no way to remove a register_hint (without PRing to Mathlib), but it is easy to add.

Can I suggest that intentionally undershoot on this PR, and then let people try it out and revise the list?

Comment on lines +128 to +129
register_hint exact?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
register_hint exact?
register_hint exact?
register_hint constructor

I think that Lean 3 had it and in Lean 4 is maybe more useful.
I wonder whether split_ifs is also an option.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

At present there is no way to remove a register_hint (without PRing to Mathlib), but it is easy to add.

Can I suggest that intentionally undershoot on this PR, and then let people try it out and revise the list?

continue
words = line.split()
if words[0] != "import" and words[0] != "/-!" and words[0] != "#align_import":
if words[0] != "import" and words[0] != "--" and words[0] != "/-!" and words[0] != "#align_import":
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure this should this be part of this PR, but if you think it's OK I'll let it slide.

I think this is a good first version of the tactic, and I'm happy if you merged it.

bors d+

@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Nov 16, 2023

✌️ semorrison can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@kim-em
Copy link
Copy Markdown
Contributor Author

kim-em commented Nov 16, 2023

bors merge

@github-actions github-actions bot added ready-to-merge This PR has been sent to bors. and removed awaiting-review labels Nov 16, 2023
mathlib-bors bot pushed a commit that referenced this pull request Nov 16, 2023
```
example (h : 1 < 0) : False := by hint
example {P Q : Prop} (p : P) (f : P → Q) : Q := by hint
example {P Q R: Prop} (x : P ∧ Q ∧ R ∧ R) : Q ∧ P ∧ R := by hint
example {a b : ℚ} (h : a < b) : ¬ b < a := by hint
example : 37^2 - 35^2 = 72 * 2 := by hint
example : Nat.Prime 37 := by hint
```

Tries out any tactics registered using `register_hint tac`, and reports which ones succeed using the new "Try these: " multiple suggestion widgets. Tactics that close the goal are highlighted in green. Tactics that succeed but don't close the goal display the new subgoals in the widget. If `tac` produces a "Try this: " message, use that instead of `tac`.

I haven't hooked up `aesop` yet, because of leanprover-community/aesop#85. Similarly for `norm_num`.

I would like to parallelize this, but I don't think that needs to happen right away.



Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
Co-authored-by: Komyyy <pol_tta@outlook.jp>
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Nov 16, 2023

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat: the 'hint' tactic [Merged by Bors] - feat: the 'hint' tactic Nov 16, 2023
@mathlib-bors mathlib-bors bot closed this Nov 16, 2023
@mathlib-bors mathlib-bors bot deleted the hint_tactic branch November 16, 2023 02:42
alexkeizer pushed a commit that referenced this pull request Nov 17, 2023
```
example (h : 1 < 0) : False := by hint
example {P Q : Prop} (p : P) (f : P → Q) : Q := by hint
example {P Q R: Prop} (x : P ∧ Q ∧ R ∧ R) : Q ∧ P ∧ R := by hint
example {a b : ℚ} (h : a < b) : ¬ b < a := by hint
example : 37^2 - 35^2 = 72 * 2 := by hint
example : Nat.Prime 37 := by hint
```

Tries out any tactics registered using `register_hint tac`, and reports which ones succeed using the new "Try these: " multiple suggestion widgets. Tactics that close the goal are highlighted in green. Tactics that succeed but don't close the goal display the new subgoals in the widget. If `tac` produces a "Try this: " message, use that instead of `tac`.

I haven't hooked up `aesop` yet, because of leanprover-community/aesop#85. Similarly for `norm_num`.

I would like to parallelize this, but I don't think that needs to happen right away.



Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
Co-authored-by: Komyyy <pol_tta@outlook.jp>
alexkeizer pushed a commit that referenced this pull request Nov 21, 2023
```
example (h : 1 < 0) : False := by hint
example {P Q : Prop} (p : P) (f : P → Q) : Q := by hint
example {P Q R: Prop} (x : P ∧ Q ∧ R ∧ R) : Q ∧ P ∧ R := by hint
example {a b : ℚ} (h : a < b) : ¬ b < a := by hint
example : 37^2 - 35^2 = 72 * 2 := by hint
example : Nat.Prime 37 := by hint
```

Tries out any tactics registered using `register_hint tac`, and reports which ones succeed using the new "Try these: " multiple suggestion widgets. Tactics that close the goal are highlighted in green. Tactics that succeed but don't close the goal display the new subgoals in the widget. If `tac` produces a "Try this: " message, use that instead of `tac`.

I haven't hooked up `aesop` yet, because of leanprover-community/aesop#85. Similarly for `norm_num`.

I would like to parallelize this, but I don't think that needs to happen right away.



Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
Co-authored-by: Komyyy <pol_tta@outlook.jp>
grunweg pushed a commit that referenced this pull request Dec 15, 2023
```
example (h : 1 < 0) : False := by hint
example {P Q : Prop} (p : P) (f : P → Q) : Q := by hint
example {P Q R: Prop} (x : P ∧ Q ∧ R ∧ R) : Q ∧ P ∧ R := by hint
example {a b : ℚ} (h : a < b) : ¬ b < a := by hint
example : 37^2 - 35^2 = 72 * 2 := by hint
example : Nat.Prime 37 := by hint
```

Tries out any tactics registered using `register_hint tac`, and reports which ones succeed using the new "Try these: " multiple suggestion widgets. Tactics that close the goal are highlighted in green. Tactics that succeed but don't close the goal display the new subgoals in the widget. If `tac` produces a "Try this: " message, use that instead of `tac`.

I haven't hooked up `aesop` yet, because of leanprover-community/aesop#85. Similarly for `norm_num`.

I would like to parallelize this, but I don't think that needs to happen right away.



Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
Co-authored-by: Komyyy <pol_tta@outlook.jp>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge This PR has been sent to bors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants