-
Notifications
You must be signed in to change notification settings - Fork 451
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
feat: only direct parents of classes create projections #5920
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9073cdb
feat: all direct parents of classes create projections
kmill bc06608
add test, bump up max synth heartbeats
kmill 9efe4f2
refine, restore synthInstance.maxHeartbeats
kmill 3cfd2a7
fix discretionary parent logic, add test
kmill 058219f
fixed test
kmill File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import Lean | ||
/-! | ||
# Only direct parents of classes are instances | ||
|
||
https://github.com/leanprover/lean4/issues/2905 | ||
-/ | ||
|
||
set_option structure.strictResolutionOrder true | ||
|
||
class A | ||
class B | ||
class C extends A | ||
class D extends A, B | ||
class E extends C, D | ||
|
||
/-! | ||
These were or were not instances before #5902 and still are or are not. | ||
-/ | ||
/-- info: some 1000 -/ | ||
#guard_msgs in #eval return (←Lean.Meta.getInstancePriority? `E.toC) | ||
/-- info: some 1000 -/ | ||
#guard_msgs in #eval return (←Lean.Meta.getInstancePriority? `E.toD) | ||
/-- info: none -/ | ||
#guard_msgs in #eval return (←Lean.Meta.getInstancePriority? `E.toA) | ||
|
||
/-! | ||
This was an instance before #5902 and no longer is. | ||
-/ | ||
/-- info: none -/ | ||
#guard_msgs in #eval return (←Lean.Meta.getInstancePriority? `E.toB) | ||
|
||
|
||
/-! | ||
Check that `A` is not an instance, since it is implied by the others. | ||
-/ | ||
class E' extends C, D, A | ||
|
||
/-- info: none -/ | ||
#guard_msgs in #eval return (←Lean.Meta.getInstancePriority? `E'.toA_1) | ||
/-- info: none -/ | ||
#guard_msgs in #eval return (←Lean.Meta.getInstancePriority? `E'.toB) | ||
/-- info: some 1000 -/ | ||
#guard_msgs in #eval return (←Lean.Meta.getInstancePriority? `E'.toC) | ||
/-- info: some 1000 -/ | ||
#guard_msgs in #eval return (←Lean.Meta.getInstancePriority? `E'.toD) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,29 @@ | ||
struct1.lean:9:14-9:17: error: invalid structure type, expecting 'Type _' or 'Prop' | ||
struct1.lean:12:20-12:29: error: expected structure | ||
struct1.lean:15:28-15:34: warning: duplicate parent structure 'A' | ||
struct1.lean:15:28-15:34: warning: field 'x' from 'A' has already been declared | ||
struct1.lean:15:28-15:34: error: parent field type mismatch, field 'x' from parent 'A' has type | ||
struct1.lean:15:28-15:33: warning: field 'x' from 'B' has already been declared | ||
struct1.lean:16:1-16:2: error: field 'x' has been declared in parent structure | ||
struct1.lean:17:30-17:35: warning: duplicate parent structure 'A', skipping | ||
struct1.lean:19:27-19:33: error: parent field type mismatch, field 'x' from parent 'B' has type | ||
Bool : Type | ||
but is expected to have type | ||
Nat : Type | ||
struct1.lean:18:27-18:33: error: parent field type mismatch, field 'x' from parent 'B' has type | ||
Bool : Type | ||
but is expected to have type | ||
Nat : Type | ||
struct1.lean:29:1-29:2: error: field 'x' has already been declared | ||
struct1.lean:32:1-32:2: error: field 'x' has been declared in parent structure | ||
struct1.lean:35:6-35:10: error: type mismatch | ||
struct1.lean:30:1-30:2: error: field 'x' has already been declared | ||
struct1.lean:33:1-33:2: error: field 'x' has been declared in parent structure | ||
struct1.lean:36:6-36:10: error: type mismatch | ||
true | ||
has type | ||
Bool : Type | ||
but is expected to have type | ||
Nat : Type | ||
struct1.lean:38:5-38:9: error: omit field 'x' type to set default value | ||
struct1.lean:41:12-41:16: error: type mismatch | ||
struct1.lean:39:5-39:9: error: omit field 'x' type to set default value | ||
struct1.lean:42:12-42:16: error: type mismatch | ||
true | ||
has type | ||
Bool : Type | ||
but is expected to have type | ||
Nat : Type | ||
struct1.lean:44:0-44:13: error: invalid 'private' constructor in a 'private' structure | ||
struct1.lean:47:0-47:15: error: invalid 'protected' constructor in a 'private' structure | ||
struct1.lean:50:0-50:19: error: invalid 'protected' field in a 'private' structure | ||
struct1.lean:45:0-45:13: error: invalid 'private' constructor in a 'private' structure | ||
struct1.lean:48:0-48:15: error: invalid 'protected' constructor in a 'private' structure | ||
struct1.lean:51:0-51:19: error: invalid 'protected' field in a 'private' structure | ||
S : Type | ||
S.mk2 (x : Nat) : S |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one surprises me a little; shouldn't it be an instance because the user asked for it in
extends
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(unless this emits a warning, in which case I have no objection besides the test not checking for that warning)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, there's no warning. This feature is necessary for being able to satisfy the strict C3 linearization algorithm in some cases without affecting what the actual instances are. Currently strict mode is not the default, but I hope we can refactor mathlib at some point to have a strict linearization.