Skip to content

[Merged by Bors] - feat: port cc tactic (2/3)#11960

Closed
Komyyy wants to merge 48 commits intomasterfrom
port/Tactic.CC.Addition
Closed

[Merged by Bors] - feat: port cc tactic (2/3)#11960
Komyyy wants to merge 48 commits intomasterfrom
port/Tactic.CC.Addition

Conversation

@Komyyy
Copy link
Copy Markdown
Contributor

@Komyyy Komyyy commented Apr 6, 2024

In this PR, we implements process when an new equation is added to a congruence closure.
Also, Lean.Expr.relSidesIfSymm? is removed in #11162, but this def is required for cc tactic, so we recover this.


Open in Gitpod

@Komyyy Komyyy added blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) awaiting-review mathlib-port This is a port of a theory file from mathlib. t-meta Tactics, attributes or user commands awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. labels Apr 6, 2024
@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 Apr 6, 2024
@Vierkantor Vierkantor self-assigned this Apr 11, 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.

Some further comments.

Observation: many procedures iterate over a collection of objects and index through pureIsDefEq. This can likely be optimized in future PRs using keyed matching in a discrimination tree, but is not a concern for the current implementation.

@Vierkantor
Copy link
Copy Markdown
Contributor

Overall the documentation is very good, most suggestions are for style issues. Good work!

@Komyyy Komyyy added WIP Work in progress and removed awaiting-review labels May 14, 2024
@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 May 15, 2024
@Komyyy Komyyy requested a review from Vierkantor May 15, 2024 04:08
@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 May 15, 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.

Done with the review! Thank you so much for the work in porting and commenting the code.

Comment on lines +1188 to +1192
/-- Internalize `e` so that the AC module can deal with the given expression. -/
def internalizeAC (e : Expr) (parent? : Option Expr) : CCM Unit := do
let some op ← isAC e | return
let parentOp? ← parent?.casesOn (pure none) isAC
if parentOp?.any (op == ·) then return
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 what the check on lines 1191-1192 is supposed to do, could you verify?

Suggested change
/-- Internalize `e` so that the AC module can deal with the given expression. -/
def internalizeAC (e : Expr) (parent? : Option Expr) : CCM Unit := do
let some op ← isAC e | return
let parentOp? ← parent?.casesOn (pure none) isAC
if parentOp?.any (op == ·) then return
/-- Internalize `e` so that the AC module can deal with the given expression.
If the expression does not contain an AC operator, or the parent expression
is already processed by `internalizeAC`, this operation does nothing.
-/
def internalizeAC (e : Expr) (parent? : Option Expr) : CCM Unit := do
let some op ← isAC e | return
let parentOp? ← parent?.casesOn (pure none) isAC
if parentOp?.any (op == ·) then return

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.

If the binary AC operatior in parent expression is the same to one in e, stop the process.

@Vierkantor Vierkantor added awaiting-author A reviewer has asked the author a question or requested changes. and removed awaiting-review labels May 15, 2024
@Komyyy Komyyy added awaiting-review awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. and removed awaiting-author A reviewer has asked the author a question or requested changes. labels May 15, 2024
@Komyyy Komyyy requested a review from Vierkantor May 15, 2024 10:20
@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 May 15, 2024
@Vierkantor
Copy link
Copy Markdown
Contributor

Thanks! Let's get this merged 🥳

bors r+

@github-actions github-actions bot added ready-to-merge This PR has been sent to bors. and removed awaiting-review labels May 15, 2024
mathlib-bors bot pushed a commit that referenced this pull request May 15, 2024
In this PR, we implements process when an new equation is added to a congruence closure.
Also, `Lean.Expr.relSidesIfSymm?` is removed in #11162, but this def is required for `cc` tactic, so we recover this.



Co-authored-by: Pol'tta / Miyahara Kō <52843868+Komyyy@users.noreply.github.com>
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented May 15, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat: port cc tactic (2/3) [Merged by Bors] - feat: port cc tactic (2/3) May 15, 2024
@mathlib-bors mathlib-bors bot closed this May 15, 2024
@mathlib-bors mathlib-bors bot deleted the port/Tactic.CC.Addition branch May 15, 2024 13:34
callesonne pushed a commit that referenced this pull request May 16, 2024
In this PR, we implements process when an new equation is added to a congruence closure.
Also, `Lean.Expr.relSidesIfSymm?` is removed in #11162, but this def is required for `cc` tactic, so we recover this.



Co-authored-by: Pol'tta / Miyahara Kō <52843868+Komyyy@users.noreply.github.com>
grunweg pushed a commit that referenced this pull request May 17, 2024
In this PR, we implements process when an new equation is added to a congruence closure.
Also, `Lean.Expr.relSidesIfSymm?` is removed in #11162, but this def is required for `cc` tactic, so we recover this.



Co-authored-by: Pol'tta / Miyahara Kō <52843868+Komyyy@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mathlib-port This is a port of a theory file from mathlib. 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.

2 participants