chore(library/init): use 'instance'

This commit is contained in:
Leonardo de Moura 2016-09-23 13:59:04 -07:00
parent 823357462e
commit 001e06abdc
4 changed files with 10 additions and 12 deletions

View file

@ -24,7 +24,7 @@ open fin
instance (n : nat) : decidable_eq (fin n)
| ⟨ival, ilt⟩ ⟨jval, jlt⟩ :=
match nat.has_decidable_eq ival jval with
match nat.decidable_eq ival jval with
| is_true h₁ := is_true (eq_of_veq h₁)
| is_false h₁ := is_false (λ h₂, absurd (veq_of_eq h₂) h₁)
end

View file

@ -24,9 +24,8 @@ inductive expr
| elet : name → expr → expr → expr → expr
| macro : macro_def → ∀ n : unsigned, (fin (unsigned.to_nat n) → expr) → expr
attribute [instance]
definition expr.is_inhabited : inhabited expr :=
inhabited.mk (expr.sort level.zero)
instance : inhabited expr :=
⟨expr.sort level.zero⟩
meta_constant expr.mk_macro (d : macro_def) : list expr → expr
meta_definition expr.mk_var (n : nat) : expr :=
@ -34,10 +33,12 @@ expr.var (unsigned.of_nat n)
meta_constant expr.has_decidable_eq : decidable_eq expr
attribute [instance] expr.has_decidable_eq
meta_constant expr.alpha_eqv : expr → expr → bool
notation a ` =ₐ `:50 b:50 := expr.alpha_eqv a b = bool.tt
meta_constant expr.to_string : expr → string
attribute [instance]
meta_definition expr.has_to_string : has_to_string expr :=
has_to_string.mk expr.to_string

View file

@ -115,13 +115,12 @@ namespace nat
instance : has_mul :=
⟨nat.mul⟩
attribute [instance, priority nat.prio]
protected definition has_decidable_eq : decidable_eq
instance : decidable_eq
| zero zero := is_true rfl
| (succ x) zero := is_false (λ h, nat.no_confusion h)
| zero (succ y) := is_false (λ h, nat.no_confusion h)
| (succ x) (succ y) :=
match has_decidable_eq x y with
match decidable_eq x y with
| is_true xeqy := is_true (xeqy ▸ eq.refl (succ x))
| is_false xney := is_false (λ h, nat.no_confusion h (λ xeqy, absurd xeqy xney))
end
@ -266,8 +265,7 @@ namespace nat
theorem lt_of_succ_lt_succ {a b : } : succ a < succ b → a < b :=
le_of_succ_le_succ
attribute [instance, priority nat.prio]
protected definition decidable_le : ∀ a b : , decidable (a ≤ b)
instance decidable_le : ∀ a b : , decidable (a ≤ b)
| 0 b := is_true (zero_le b)
| (a+1) 0 := is_false (not_succ_le_zero a)
| (a+1) (b+1) :=
@ -276,8 +274,7 @@ namespace nat
| is_false h := is_false (λ a, h (le_of_succ_le_succ a))
end
attribute [instance, priority nat.prio]
protected definition decidable_lt : ∀ a b : , decidable (a < b) :=
instance decidable_lt : ∀ a b : , decidable (a < b) :=
λ a b, nat.decidable_le (succ a) b
protected theorem lt_or_ge : ∀ (a b : ), a < b a ≥ b

View file

@ -8,7 +8,7 @@ constant gcd_aux : ×
noncomputable definition gcd (x y : ) : := gcd_aux (x, y)
theorem gcd_def (x y : ) : gcd x y = @ite (y = 0) (nat.has_decidable_eq (snd (x, y)) 0) nat x (gcd y (x mod y)) :=
theorem gcd_def (x y : ) : gcd x y = @ite (y = 0) (nat.decidable_eq (snd (x, y)) 0) nat x (gcd y (x mod y)) :=
sorry
constant succ_ne_zero (a : nat) : succ a ≠ 0