lean2/library/data/unit.lean
Leonardo de Moura 354b50a1f5 refactor(library/data/unit): make unit universe polymorphic
Motivation: we need it for "padding".
Example 1: defining a n-ary tuple type.
Example 2: defining cases-on for mutually recursive datatypes
2014-10-25 13:55:03 -07:00

27 lines
786 B
Text

-- Copyright (c) 2014 Microsoft Corporation. All rights reserved.
-- Released under Apache 2.0 license as described in the file LICENSE.
-- Author: Leonardo de Moura
import logic.decidable logic.inhabited
open decidable
inductive unit.{l} : Type.{l} :=
star : unit
namespace unit
notation `⋆` := star
-- remove duplication?
protected theorem equal (a b : unit) : a = b :=
rec_on a (rec_on b rfl)
protected theorem subsingleton [instance] : subsingleton unit :=
subsingleton.intro (λ a b, equal a b)
theorem eq_star (a : unit) : a = star :=
equal a star
protected definition is_inhabited [instance] : inhabited unit :=
inhabited.mk ⋆
protected definition has_decidable_eq [instance] : decidable_eq unit :=
take (a b : unit), inl (equal a b)
end unit