Skip to content

Instantly share code, notes, and snippets.

@mcdoll
Created November 20, 2021 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcdoll/dfdaffa35e5b66c442b910384b9086fe to your computer and use it in GitHub Desktop.
Save mcdoll/dfdaffa35e5b66c442b910384b9086fe to your computer and use it in GitHub Desktop.
Structures vs defs
-- 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