Skip to content

[Merged by Bors] - chore: clean up evalNot norm_num extension#9532

Closed
dwrensha wants to merge 5 commits intomasterfrom
norm-num-eval-not-cleanup
Closed

[Merged by Bors] - chore: clean up evalNot norm_num extension#9532
dwrensha wants to merge 5 commits intomasterfrom
norm-num-eval-not-cleanup

Conversation

@dwrensha
Copy link
Copy Markdown
Member

@dwrensha dwrensha commented Jan 7, 2024


Open in Gitpod

guard <|← withNewMCtxDepth <| isDefEq α q(Prop)
let .isBool b p ← derive q($a) | failure
haveI' : u =QL 0 := ⟨⟩; haveI' : $α =Q Prop := ⟨⟩
haveI' : $e =Q ¬ $a := ⟨⟩
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@gebner are these haveI' lines serving any purpose? You added them in #5975, and even at that time the code successfully typechecked without them.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah, we are trying return a value of type NormNum.Result e, and we do it by analyzing a. The $e =Q ¬ $a thing is so that the typechecker knows how e relates to a.

But then how does this code still work even when I delete these lines? Does that mean there's a bug in Qq?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

(I re-added the lines in 27adfeb, because this seems to me more likely to be a bug in Qq than a problem with the code here.)

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 would have expected that either $e =Q ¬ $a or the cast have p : Q($a) := p would be sufficient. But it seems from d94bd42 that we don't need either. So I'm in favour of removing these again.

On the other hand, I must admit that placating Qq is still a deeply magical process to me so I'm inclined to accept any variation of the code that compiles and looks plausible. So I'll let you decide.

@dwrensha dwrensha added awaiting-review t-meta Tactics, attributes or user commands labels Jan 7, 2024
Copy link
Copy Markdown
Contributor

@Vierkantor Vierkantor left a comment

Choose a reason for hiding this comment

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

Nice cleanup!

bors d+

guard <|← withNewMCtxDepth <| isDefEq α q(Prop)
let .isBool b p ← derive q($a) | failure
haveI' : u =QL 0 := ⟨⟩; haveI' : $α =Q Prop := ⟨⟩
haveI' : $e =Q ¬ $a := ⟨⟩
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 would have expected that either $e =Q ¬ $a or the cast have p : Q($a) := p would be sufficient. But it seems from d94bd42 that we don't need either. So I'm in favour of removing these again.

On the other hand, I must admit that placating Qq is still a deeply magical process to me so I'm inclined to accept any variation of the code that compiles and looks plausible. So I'll let you decide.

@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Feb 6, 2024

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

@ghost ghost added delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). and removed awaiting-review labels Feb 6, 2024
@dwrensha
Copy link
Copy Markdown
Member Author

dwrensha commented Feb 6, 2024

bors r+

mathlib-bors bot pushed a commit that referenced this pull request Feb 6, 2024
* Uses `deriveBool`, which was added in #3892, and allows removal of some `have` lines.
* Changes an `if then else` into a match. This is more readable in my opinion.
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Feb 6, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title chore: clean up evalNot norm_num extension [Merged by Bors] - chore: clean up evalNot norm_num extension Feb 6, 2024
@mathlib-bors mathlib-bors bot closed this Feb 6, 2024
@mathlib-bors mathlib-bors bot deleted the norm-num-eval-not-cleanup branch February 6, 2024 16:08
atarnoam pushed a commit that referenced this pull request Feb 9, 2024
* Uses `deriveBool`, which was added in #3892, and allows removal of some `have` lines.
* Changes an `if then else` into a match. This is more readable in my opinion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). t-meta Tactics, attributes or user commands

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants