fix(library/init): missing has_sizeof instances for subtype, char and string

This commit is contained in:
Leonardo de Moura 2017-04-15 22:48:42 -07:00
parent 210b7c8fb7
commit f6556ecdcc
3 changed files with 12 additions and 0 deletions

View file

@ -592,6 +592,12 @@ protected def list.sizeof {α : Type u} [has_sizeof α] : list α → nat
instance (α : Type u) [has_sizeof α] : has_sizeof (list α) :=
⟨list.sizeof⟩
protected def subtype.sizeof {α : Type u} [has_sizeof α] {p : α → Prop} : subtype p → nat
| ⟨a, _⟩ := sizeof a
instance {α : Type u} [has_sizeof α] (p : α → Prop) : has_sizeof (subtype p) :=
⟨subtype.sizeof⟩
lemma nat_add_zero (n : nat) : n + 0 = n := rfl
/- Combinator calculus -/

View file

@ -11,6 +11,9 @@ def char_sz : nat := succ 255
def char := fin char_sz
instance : has_sizeof char :=
⟨fin.sizeof _⟩
namespace char
/- We cannot use tactic dec_trivial here because the tactic framework has not been defined yet. -/
lemma zero_lt_char_sz : 0 < char_sz :=

View file

@ -15,6 +15,9 @@ namespace string
instance : inhabited string :=
⟨empty⟩
instance : has_sizeof string :=
⟨list.sizeof⟩
@[pattern] def str : char → string → string := list.cons
def concat (a b : string) : string :=