forked from leanprover/lean4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This implements leanprover#2666, allowing manual tweaking of whether structure inheritance is flat or nested, without forcing the user to fallback to the `FlatHack` approach in https://arxiv.org/abs/2306.00617. This is documented via a docstring on the `flat` parser, which appear as a hover docstring as long as `Lean/Parser/Command` is imported.
- Loading branch information
1 parent
00359a0
commit a23b683
Showing
3 changed files
with
40 additions
and
5 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
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,24 @@ | ||
structure AddHom (α) [Add α] where | ||
toFun : α → α | ||
map_add (a b : α) : toFun (a + b) = toFun a + toFun b | ||
|
||
structure MulHom (α) [Mul α] where | ||
toFun : α → α | ||
map_mul (a b : α) : toFun (a * b) = toFun a * toFun b | ||
|
||
structure DistribHom (α) [Add α] [Mul α] extends AddHom α, MulHom α | ||
structure DistribHomFlatAdd (α) [Add α] [Mul α] extends flat AddHom α, MulHom α | ||
|
||
#print DistribHom.mk | ||
#print DistribHomFlatAdd.mk | ||
|
||
-- the flat version has less noise when in a goal view | ||
set_option pp.proofs.withType false | ||
#check {toFun := id, map_add := fun _ _ => rfl, map_mul := fun _ _ => rfl : DistribHom Nat} | ||
#check {toFun := id, map_add := fun _ _ => rfl, map_mul := fun _ _ => rfl : DistribHomFlatAdd Nat} | ||
|
||
-- marking `MulHom` as flat makes no difference, since `Add` has already been flattened. | ||
structure DistribHomFlatMul (α) [Add α] [Mul α] extends AddHom α, flat MulHom α | ||
structure DistribHomFlatBoth (α) [Add α] [Mul α] extends flat AddHom α, flat MulHom α | ||
#print DistribHomFlatMul.mk | ||
#print DistribHomFlatBoth.mk |