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

[Merged by Bors] - feat({ Tactic + test }/MoveAdd): make And/Or left-associative #8607

Closed
wants to merge 5 commits into from

Conversation

adomani
Copy link
Collaborator

@adomani adomani commented Nov 24, 2023

In this Zulip discussion it was pointed out that move_oper always assumes right-associativity also for And/Or.

This PR makes move_oper left-associative on And/Or.

Affected files:

Tactic/MoveAdd
test/MoveAdd

Open in Gitpod

@adomani adomani added t-meta Tactics, attributes or user commands awaiting-review labels Nov 24, 2023
@adomani adomani changed the title feat(Tactic/MoveAdd): make And/Or left-associative feat({ Tactic + test }/MoveAdd): make And/Or left-associative Nov 24, 2023
@robertylewis robertylewis added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review labels Nov 26, 2023
@adomani adomani added awaiting-review and removed awaiting-author A reviewer has asked the author a question or requested changes labels Nov 27, 2023
| [a] => a
| a::as =>
if left_assoc? then
Expr.app (prepOp.app a) (sumList prepOp true as)
Copy link
Member

@eric-wieser eric-wieser Nov 27, 2023

Choose a reason for hiding this comment

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

Or alternatively (untested):

Suggested change
Expr.app (prepOp.app a) (sumList prepOp true as)
as.foldr (fun x y => Expr.app (prepOp.app x) y) a

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried this, but I think that it does not work: the a should really be the last element of the list. At least, this is what my understanding of foldr does. So, there may be some more idiomatic way of doing this, but the following would be closer to what it should be:

  | l@(a::as) =>
    if left_assoc? then
      (l.dropLast).foldr (fun x y => Expr.app (prepOp.app x) y) l.getLast!

@robertylewis
Copy link
Member

Thanks, and sorry for the delay!

bors merge

@github-actions github-actions bot added ready-to-merge This PR has been sent to bors. and removed awaiting-review labels Dec 12, 2023
mathlib-bors bot pushed a commit that referenced this pull request Dec 12, 2023
In this [Zulip discussion](https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/move_oper.20.20HAnd.2EhAnd.3F/near/403820462) it was pointed out that `move_oper` always assumes right-associativity also for `And/Or`.

This PR makes `move_oper` left-associative on `And/Or`.

Affected files:
```bash
Tactic/MoveAdd
test/MoveAdd
```
@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Dec 12, 2023

Build failed (retrying...):

mathlib-bors bot pushed a commit that referenced this pull request Dec 12, 2023
In this [Zulip discussion](https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/move_oper.20.20HAnd.2EhAnd.3F/near/403820462) it was pointed out that `move_oper` always assumes right-associativity also for `And/Or`.

This PR makes `move_oper` left-associative on `And/Or`.

Affected files:
```bash
Tactic/MoveAdd
test/MoveAdd
```
@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Dec 12, 2023

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat({ Tactic + test }/MoveAdd): make And/Or left-associative [Merged by Bors] - feat({ Tactic + test }/MoveAdd): make And/Or left-associative Dec 12, 2023
@mathlib-bors mathlib-bors bot closed this Dec 12, 2023
@mathlib-bors mathlib-bors bot deleted the adomani/left_assoc_and_or_move_add branch December 12, 2023 20:43
awueth pushed a commit that referenced this pull request Dec 19, 2023
In this [Zulip discussion](https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/move_oper.20.20HAnd.2EhAnd.3F/near/403820462) it was pointed out that `move_oper` always assumes right-associativity also for `And/Or`.

This PR makes `move_oper` left-associative on `And/Or`.

Affected files:
```bash
Tactic/MoveAdd
test/MoveAdd
```
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. t-meta Tactics, attributes or user commands
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants