lean4-htt/library/init/data/char/lemmas.lean
Leonardo de Moura 1ad1080f11 refactor(library): keep only basic nat theorems
All theorems are proved without using the tactic framework.
Thus, we can define `fin/uint32/uint64` types and their operations
before we define the tactic framework.
2018-04-11 16:47:54 -07:00

21 lines
809 B
Text

prelude
import init.meta init.logic init.data.nat.basic
import init.data.char.basic
namespace char
lemma val_of_nat_eq_of_is_valid {n : nat} : is_valid_char n → (of_nat n).val = n :=
by intro h; unfold of_nat; rw [dif_pos h]
lemma val_of_nat_eq_of_not_is_valid {n : nat} : ¬ is_valid_char n → (of_nat n).val = 0 :=
by intro h; unfold of_nat; rw [dif_neg h]
lemma of_nat_eq_of_not_is_valid {n : nat} : ¬ is_valid_char n → of_nat n = of_nat 0 :=
by intro h; apply eq_of_veq; rw [val_of_nat_eq_of_not_is_valid h]; reflexivity
lemma of_nat_ne_of_ne {n₁ n₂ : nat} (h₁ : n₁ ≠ n₂) (h₂ : is_valid_char n₁) (h₃ : is_valid_char n₂) : of_nat n₁ ≠ of_nat n₂ :=
begin
apply ne_of_vne,
rw [val_of_nat_eq_of_is_valid h₂, val_of_nat_eq_of_is_valid h₃],
assumption
end
end char