-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: delaboration collapses parent projections (#3326)
When projection functions are delaborated, intermediate parent projections are no longer printed. For example, rather than pretty printing as `o.toB.toA.x` with these `toB` and `toA` parent projections, it pretty prints as `o.x`. This feature is being upstreamed from mathlib.
- Loading branch information
Showing
7 changed files
with
162 additions
and
20 deletions.
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,93 @@ | ||
/-! | ||
# Delaboration of projection functions | ||
-/ | ||
|
||
structure A where | ||
x : Nat | ||
|
||
structure B extends A where | ||
y : Nat | ||
|
||
structure C extends B where | ||
z : Nat | ||
|
||
variable (a : A) (b : B) (c : C) | ||
|
||
section | ||
/-! | ||
Checking projection delaboration, including parent projection collapse. | ||
-/ | ||
|
||
#check a.x | ||
#check b.x | ||
#check c.x | ||
|
||
#check b.y | ||
#check c.y | ||
|
||
#check c.z | ||
|
||
end | ||
|
||
section | ||
/-! | ||
Checking `pp.structureProjections` can turn off this delaborator. | ||
-/ | ||
|
||
set_option pp.structureProjections false | ||
|
||
#check a.x | ||
#check b.x | ||
#check c.x | ||
|
||
#check b.y | ||
#check c.y | ||
|
||
#check c.z | ||
|
||
end | ||
|
||
structure Fin' extends Fin 5 | ||
|
||
structure Fin'' (n : Nat) extends Fin n | ||
|
||
structure D (n : Nat) extends A | ||
|
||
variable (x : Fin 5) (y : Fin') (z : Fin'' 5) (d : D 5) | ||
|
||
section | ||
/-! | ||
Checking handling of parameters. | ||
-/ | ||
|
||
#check x.val | ||
#check y.val | ||
#check z.val | ||
#check d.x | ||
|
||
end | ||
|
||
section | ||
/-! | ||
Check handling of parameters when `pp.explicit` is true. | ||
-/ | ||
set_option pp.explicit true | ||
|
||
#check c.x | ||
#check x.val | ||
#check y.val | ||
#check z.val | ||
#check d.x | ||
|
||
end | ||
|
||
structure Fn (α β : Type) where | ||
toFun : α → β | ||
|
||
variable (f : Fn Nat Int) | ||
|
||
/-! | ||
Check overapplication. | ||
-/ | ||
|
||
#check f.toFun 0 |
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,22 @@ | ||
a.x : Nat | ||
b.x : Nat | ||
c.x : Nat | ||
b.y : Nat | ||
c.y : Nat | ||
c.z : Nat | ||
A.x a : Nat | ||
A.x (B.toA b) : Nat | ||
A.x (B.toA (C.toB c)) : Nat | ||
B.y b : Nat | ||
B.y (C.toB c) : Nat | ||
C.z c : Nat | ||
x.val : Nat | ||
y.val : Nat | ||
z.val : Nat | ||
d.x : Nat | ||
c.x : Nat | ||
@Fin.val 5 x : Nat | ||
@Fin.val 5 y.toFin : Nat | ||
@Fin.val 5 (@Fin''.toFin 5 z) : Nat | ||
(@D.toA 5 d).x : Nat | ||
f.toFun 0 : Int |
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,2 +1,2 @@ | ||
@[reducible] def D.toC : D → C := | ||
fun self => { toA := self.toB.toA, w := self.w } | ||
fun self => { toA := self.toA, w := self.w } |
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,4 +1,4 @@ | ||
{ toA_1 := { toA := { x := 0 }, y := 1 }, z := 2 } : B | ||
{ toC := { x := 0, y := 1 }, z := 2 } : D | ||
@[reducible] def D.toC_1 : D → Boo.C := | ||
fun self => { x := self.toC.x, z := self.z } | ||
fun self => { x := self.x, z := self.z } |