-
-
Save mcdoll/dfdaffa35e5b66c442b910384b9086fe to your computer and use it in GitHub Desktop.
Structures vs defs
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
-- Version with structure | |
structure spoint (a : Type*) (b : Type*) := (x : a → a) (y : b) | |
namespace spoint | |
variables {a : Type*} | |
variables {b : Type*} | |
variables (A : spoint a b) | |
def is_eq (A : spoint a b) : Prop := A.x = id | |
#check A.is_eq | |
end spoint | |
structure spoint_two (a : Type*) extends spoint a a | |
namespace spoint_two | |
variables {a : Type*} | |
variables (A : spoint_two a) | |
#check A.to_spoint.is_eq | |
end spoint_two | |
-- Version with def | |
def dpoint (a : Type*) := a → a | |
namespace dpoint | |
variables (a : Type*) | |
variables (b : dpoint a) | |
def is_eq (b : dpoint a) : Prop := b = id | |
-- #check b.is_eq -- does not type-check | |
end dpoint | |
def dpoint_two (a : Type*) := a → a | |
namespace dpoint_two | |
variables (a : Type*) | |
variables (b : dpoint_two a) | |
end dpoint_two |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment