[Merged by Bors] - fix: cc tactic can't unify def-eq instances in OfNat.ofNat#13403
Closed
[Merged by Bors] - fix: cc tactic can't unify def-eq instances in OfNat.ofNat#13403
cc tactic can't unify def-eq instances in OfNat.ofNat#13403Conversation
1 task
Vierkantor
approved these changes
Jun 14, 2024
Contributor
Vierkantor
left a comment
There was a problem hiding this comment.
Looks good to me, thanks for the detailed explanations!
bors r+
mathlib-bors bot
pushed a commit
that referenced
this pull request
Jun 14, 2024
This issue is consisted of one problem and one bug.
**Problem: `cc` treats an `OfNat.ofNat` term as an atomic value in the default config**
In the default `CCConfig`, the `values` field is set to `true` so `cc` treats an `OfNat.ofNat` term as an atomic and it doesn't unify `OfNat` instances.
This problem can be solved simply by setting `values := false` by default.
**Bug: `cc` tries to disprove `@OfNat α (nat_lit n) i₁ ≠ @OfNat α (nat_lit n) i₂` where `α` is `ℕ` or `ℤ` and `i₁` & `i₂` is not alpha-equivalent but def_eq**
`cc` tactic has a mechanism to disprove equality between two different values of `ℕ`, `ℤ`, `Char` & `String`, in the function `propagateEqUp`. This mechanism is trigered when the root representations of two values are not alpha-equivalent, so this example fails.
```lean
local instance instOfNatNat' (n : ℕ) : OfNat ℕ n where
ofNat := n
example : @OfNat.ofNat ℕ (nat_lit 0) (instOfNatNat _) =
@OfNat.ofNat ℕ (nat_lit 0) (instOfNatNat' _) := by
cc
/-
application type mismatch
(bne_iff_ne 0 0).1 (Eq.refl true)
argument has type
true = true
but function has type
(0 != 0) = true → 0 ≠ 0
-/
```
So we strengthen the condition in `propagateEqUp`. For the detail, refer to docs in this function.
Contributor
|
Build failed (retrying...): |
mathlib-bors bot
pushed a commit
that referenced
this pull request
Jun 14, 2024
This issue is consisted of one problem and one bug.
**Problem: `cc` treats an `OfNat.ofNat` term as an atomic value in the default config**
In the default `CCConfig`, the `values` field is set to `true` so `cc` treats an `OfNat.ofNat` term as an atomic and it doesn't unify `OfNat` instances.
This problem can be solved simply by setting `values := false` by default.
**Bug: `cc` tries to disprove `@OfNat α (nat_lit n) i₁ ≠ @OfNat α (nat_lit n) i₂` where `α` is `ℕ` or `ℤ` and `i₁` & `i₂` is not alpha-equivalent but def_eq**
`cc` tactic has a mechanism to disprove equality between two different values of `ℕ`, `ℤ`, `Char` & `String`, in the function `propagateEqUp`. This mechanism is trigered when the root representations of two values are not alpha-equivalent, so this example fails.
```lean
local instance instOfNatNat' (n : ℕ) : OfNat ℕ n where
ofNat := n
example : @OfNat.ofNat ℕ (nat_lit 0) (instOfNatNat _) =
@OfNat.ofNat ℕ (nat_lit 0) (instOfNatNat' _) := by
cc
/-
application type mismatch
(bne_iff_ne 0 0).1 (Eq.refl true)
argument has type
true = true
but function has type
(0 != 0) = true → 0 ≠ 0
-/
```
So we strengthen the condition in `propagateEqUp`. For the detail, refer to docs in this function.
Contributor
|
Pull request successfully merged into master. Build succeeded: |
cc tactic can't unify def-eq instances in OfNat.ofNatcc tactic can't unify def-eq instances in OfNat.ofNat
AntoineChambert-Loir
pushed a commit
that referenced
this pull request
Jun 20, 2024
This issue is consisted of one problem and one bug.
**Problem: `cc` treats an `OfNat.ofNat` term as an atomic value in the default config**
In the default `CCConfig`, the `values` field is set to `true` so `cc` treats an `OfNat.ofNat` term as an atomic and it doesn't unify `OfNat` instances.
This problem can be solved simply by setting `values := false` by default.
**Bug: `cc` tries to disprove `@OfNat α (nat_lit n) i₁ ≠ @OfNat α (nat_lit n) i₂` where `α` is `ℕ` or `ℤ` and `i₁` & `i₂` is not alpha-equivalent but def_eq**
`cc` tactic has a mechanism to disprove equality between two different values of `ℕ`, `ℤ`, `Char` & `String`, in the function `propagateEqUp`. This mechanism is trigered when the root representations of two values are not alpha-equivalent, so this example fails.
```lean
local instance instOfNatNat' (n : ℕ) : OfNat ℕ n where
ofNat := n
example : @OfNat.ofNat ℕ (nat_lit 0) (instOfNatNat _) =
@OfNat.ofNat ℕ (nat_lit 0) (instOfNatNat' _) := by
cc
/-
application type mismatch
(bne_iff_ne 0 0).1 (Eq.refl true)
argument has type
true = true
but function has type
(0 != 0) = true → 0 ≠ 0
-/
```
So we strengthen the condition in `propagateEqUp`. For the detail, refer to docs in this function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This issue is consisted of one problem and one bug.
Problem:
cctreats anOfNat.ofNatterm as an atomic value in the default configIn the default
CCConfig, thevaluesfield is set totruesocctreats anOfNat.ofNatterm as an atomic and it doesn't unifyOfNatinstances.This problem can be solved simply by setting
values := falseby default.Bug:
cctries to disprove@OfNat α (nat_lit n) i₁ ≠ @OfNat α (nat_lit n) i₂whereαisℕorℤandi₁&i₂is not alpha-equivalent but def_eqcctactic has a mechanism to disprove equality between two different values ofℕ,ℤ,Char&String, in the functionpropagateEqUp. This mechanism is trigered when the root representations of two values are not alpha-equivalent, so this example fails.So we strengthen the condition in
propagateEqUp. For the detail, refer to docs in this function.Resolves #13362