lean4-htt/library/init/char.lean
Leonardo de Moura dfd2a23cd4 feat(frontends/lean): use #"c" instead of 'c' for character literals
The new notation is the same one used in Standard ML.
It will also allow us to use ' in the beginning of identifiers like Standard ML.
2016-11-17 11:35:54 -08:00

31 lines
725 B
Text

/-
Copyright (c) 2016 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
-/
prelude
import init.fin
open nat
def char_sz : nat := succ 255
def char := fin char_sz
namespace char
/- We cannot use tactic dec_trivial here because the tactic framework has not been defined yet. -/
private lemma zero_lt_char_sz : 0 < char_sz :=
zero_lt_succ _
@[pattern] def of_nat (n : nat) : char :=
if H : n < char_sz then fin.mk n H else fin.mk 0 zero_lt_char_sz
def to_nat (c : char) : nat :=
fin.val c
end char
instance : decidable_eq char :=
have decidable_eq (fin char_sz), from fin.decidable_eq _,
this
instance : inhabited char :=
⟨#"A"⟩