This PR modifies the `structure` syntax so that parents can be named, like in ```lean structure S extends toParent : P ``` **Breaking change:** The syntax is also modified so that the resultant type comes *before* the `extends` clause, for example `structure S : Prop extends P`. This is necessary to prevent a parsing ambiguity, but also this is the natural place for the resultant type. Implements RFC #7099. Will need followup PRs for cleanup after a stage0 update.
39 lines
662 B
Text
39 lines
662 B
Text
structure Foo.A where
|
|
x : Nat
|
|
|
|
structure Boo.A extends Foo.A where
|
|
y : Nat
|
|
|
|
structure B extends toA_1 : Boo.A where
|
|
z : Nat
|
|
|
|
def f1 (x y z : Nat) : B :=
|
|
{ x, y, z }
|
|
|
|
theorem ex1 (x y z : Nat) : f1 x y z = ⟨⟨⟨x⟩, y⟩, z⟩ :=
|
|
rfl
|
|
|
|
theorem ex2 (x y z : Nat) : f1 x y z = B.mk (Boo.A.mk (Foo.A.mk x) y) z :=
|
|
rfl
|
|
|
|
#check { x := 0, y := 1, z := 2 : B }
|
|
|
|
structure Foo.C where
|
|
x : Nat
|
|
y : Nat
|
|
|
|
structure Boo.C where
|
|
x : Nat
|
|
z : Nat
|
|
|
|
structure D extends Foo.C, toC_1 : Boo.C
|
|
|
|
def f2 (x y z : Nat) : D :=
|
|
{ x, y, z }
|
|
|
|
theorem ex3 (x y z : Nat) : f2 x y z = D.mk ⟨x, y⟩ z :=
|
|
rfl
|
|
|
|
#check { x := 0, y := 1, z := 2 : D }
|
|
|
|
#print D.toC_1
|