Modifies the structure instance elaborator to
1. Fill in missing fields from sources in strict left-to-right order. In
`{a, b with}`, sometimes the elaborator
would ignore `a` even if both `a` and `b` provided the same field,
depending on what subobject fields they had.
2. Use the sources, or subobjects of the sources, to fill in entire
subobjects of the target structure as much as possible.
Currently, a field cannot be filled directly by a source itself
resulting in the term being eta expanded.
This change avoids this unnecessary and surprisingly costly extra eta
expansion.
Adds two new tests to illustrate the performance benefit (one courtesy
@semorrison). These are currently failing on master and succeed on this
branch.
There is one additional test to exercise the changes to the elaboration
of structure instances.
Changes to make mathlib build are in leanprover-community/mathlib4#9843
Closes #2451
9 lines
354 B
Text
9 lines
354 B
Text
structure A := (a b : Nat)
|
|
structure B extends A := (c : Nat)
|
|
structure C := (a b c : Nat)
|
|
structure D := (toA : A) (c : Nat)
|
|
|
|
def foo (s : C) : B := {s with} -- works in lean 4, works in lean 3
|
|
-- def bar (s : D) : B := {s with} -- no longer works after #2478
|
|
-- Should fields of non-subobject fields be treated as fields
|
|
-- of the original structure?
|