diff --git a/library/data/int/basic.lean b/library/data/int/basic.lean index 7ce5bd890..0292b198e 100644 --- a/library/data/int/basic.lean +++ b/library/data/int/basic.lean @@ -1,8 +1,6 @@ /- Copyright (c) 2014 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. - -Module: data.int.basic Authors: Floris van Doorn, Jeremy Avigad The integers, with addition, multiplication, and subtraction. The representation of the integers is @@ -609,10 +607,10 @@ or_of_or_of_imp_of_imp H3 (assume H : (nat_abs a) = nat.zero, nat_abs_eq_zero H) (assume H : (nat_abs b) = nat.zero, nat_abs_eq_zero H) -section +section migrate_algebra open [classes] algebra - protected definition integral_domain [instance] [reducible] : algebra.integral_domain int := + protected definition integral_domain [reducible] : algebra.integral_domain int := ⦃algebra.integral_domain, add := add, add_assoc := add.assoc, @@ -632,6 +630,7 @@ section mul_comm := mul.comm, eq_zero_or_eq_zero_of_mul_eq_zero := @eq_zero_or_eq_zero_of_mul_eq_zero⦄ + local attribute int.integral_domain [instance] definition sub (a b : ℤ) : ℤ := algebra.sub a b infix - := int.sub definition dvd (a b : ℤ) : Prop := algebra.dvd a b @@ -639,7 +638,7 @@ section migrate from algebra with int replacing sub → sub, dvd → dvd -end +end migrate_algebra /- additional properties -/ diff --git a/library/data/int/order.lean b/library/data/int/order.lean index bcf94b872..be6235b84 100644 --- a/library/data/int/order.lean +++ b/library/data/int/order.lean @@ -1,8 +1,6 @@ /- Copyright (c) 2014 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. - -Module: data.int.order Authors: Floris van Doorn, Jeremy Avigad The order relation on the integers. We show that int is an instance of linear_comm_ordered_ring @@ -218,10 +216,10 @@ lt.intro ... = of_nat (succ (succ n * m + n)) : nat.add_succ ... = 0 + succ (succ n * m + n) : zero_add)) -section +section migrate_algebra open [classes] algebra - protected definition linear_ordered_comm_ring [instance] [reducible] : + protected definition linear_ordered_comm_ring [reducible] : algebra.linear_ordered_comm_ring int := ⦃algebra.linear_ordered_comm_ring, int.integral_domain, le := le, @@ -237,12 +235,16 @@ section le_total := le.total, zero_ne_one := zero_ne_one⦄ - protected definition decidable_linear_ordered_comm_ring [instance] [reducible] : + protected definition decidable_linear_ordered_comm_ring [reducible] : algebra.decidable_linear_ordered_comm_ring int := ⦃algebra.decidable_linear_ordered_comm_ring, int.linear_ordered_comm_ring, decidable_lt := decidable_lt⦄ + local attribute int.integral_domain [instance] + local attribute int.linear_ordered_comm_ring [instance] + local attribute int.decidable_linear_ordered_comm_ring [instance] + definition ge [reducible] (a b : ℤ) := algebra.has_le.ge a b definition gt [reducible] (a b : ℤ) := algebra.has_lt.gt a b infix >= := int.ge @@ -257,7 +259,7 @@ section migrate from algebra with int replacing has_le.ge → ge, has_lt.gt → gt, sign → sign, abs → abs, dvd → dvd, sub → sub -end +end migrate_algebra /- more facts specific to int -/ diff --git a/library/data/nat/basic.lean b/library/data/nat/basic.lean index f47091978..4c2219275 100644 --- a/library/data/nat/basic.lean +++ b/library/data/nat/basic.lean @@ -290,7 +290,7 @@ nat.cases_on n section open [classes] algebra - protected definition comm_semiring [instance] [reducible] : algebra.comm_semiring nat := + protected definition comm_semiring [reducible] : algebra.comm_semiring nat := ⦃algebra.comm_semiring, add := add, add_assoc := add.assoc, @@ -312,6 +312,7 @@ end section port_algebra open [classes] algebra + local attribute comm_semiring [instance] theorem mul.left_comm : ∀a b c : ℕ, a * (b * c) = b * (a * c) := algebra.mul.left_comm theorem mul.right_comm : ∀a b c : ℕ, (a * b) * c = (a * c) * b := algebra.mul.right_comm diff --git a/library/data/nat/order.lean b/library/data/nat/order.lean index ea9bb3377..0775b27ee 100644 --- a/library/data/nat/order.lean +++ b/library/data/nat/order.lean @@ -143,8 +143,9 @@ le.intro !zero_add section open [classes] algebra + local attribute nat.comm_semiring [instance] - protected definition linear_ordered_semiring [instance] [reducible] : + protected definition linear_ordered_semiring [reducible] : algebra.linear_ordered_semiring nat := ⦃ algebra.linear_ordered_semiring, nat.comm_semiring, add_left_cancel := @add.cancel_left, @@ -164,6 +165,11 @@ section mul_le_mul_of_nonneg_right := (take a b c H1 H2, mul_le_mul_right H1 c), mul_lt_mul_of_pos_left := @mul_lt_mul_of_pos_left, mul_lt_mul_of_pos_right := @mul_lt_mul_of_pos_right ⦄ +end + +section + open [classes] algebra + local attribute nat.linear_ordered_semiring [instance] migrate from algebra with nat replacing has_le.ge → ge, has_lt.gt → gt @@ -172,6 +178,7 @@ end section port_algebra open [classes] algebra + local attribute nat.linear_ordered_semiring [instance] theorem add_pos_left : ∀{a : ℕ}, 0 < a → ∀b : ℕ, 0 < a + b := take a H b, @algebra.add_pos_of_pos_of_nonneg _ _ a b H !zero_le theorem add_pos_right : ∀{a : ℕ}, 0 < a → ∀b : ℕ, 0 < b + a := diff --git a/library/data/rat/basic.lean b/library/data/rat/basic.lean index 2e6dfe3d8..3b3304e6a 100644 --- a/library/data/rat/basic.lean +++ b/library/data/rat/basic.lean @@ -365,10 +365,10 @@ take a b, quot.rec_on_subsingleton₂ a b theorem inv_zero : inv 0 = 0 := quot.sound (prerat.inv_zero' ▸ !prerat.equiv.refl) -section +section migrate_algebra open [classes] algebra - protected definition discrete_field [instance] [reducible] : algebra.discrete_field rat := + protected definition discrete_field [reducible] : algebra.discrete_field rat := ⦃algebra.discrete_field, add := add, add_assoc := add.assoc, @@ -392,10 +392,12 @@ section inv_zero := inv_zero, has_decidable_eq := has_decidable_eq⦄ + local attribute rat.discrete_field [instance] definition divide (a b : rat) := algebra.divide a b definition dvd (a b : rat) := algebra.dvd a b migrate from algebra with rat replacing sub → rat.sub, divide → divide, dvd → dvd -end + +end migrate_algebra end rat diff --git a/library/data/rat/order.lean b/library/data/rat/order.lean index f4399d3df..152d9629f 100644 --- a/library/data/rat/order.lean +++ b/library/data/rat/order.lean @@ -202,10 +202,10 @@ have H : pos (a * b), from pos_mul (!sub_zero ▸ H1) (!sub_zero ▸ H2), definition decidable_lt [instance] : decidable_rel rat.lt := take a b, decidable_pos (b - a) -section +section migrate_algebra open [classes] algebra - protected definition discrete_linear_ordered_field [instance] [reducible] : + protected definition discrete_linear_ordered_field [reducible] : algebra.discrete_linear_ordered_field rat := ⦃algebra.discrete_linear_ordered_field, rat.discrete_field, @@ -220,10 +220,12 @@ section mul_pos := @mul_pos, decidable_lt := @decidable_lt⦄ + local attribute rat.discrete_field [instance] + local attribute rat.discrete_linear_ordered_field [instance] definition abs (n : rat) : rat := algebra.abs n definition sign (n : rat) : rat := algebra.sign n migrate from algebra with rat - replacing has_le.ge → ge, has_lt.gt → gt, sub → sub, abs → abs, sign → sign, dvd → dvd, divide → divide -end + replacing has_le.ge → ge, has_lt.gt → gt, sub → sub, abs → abs, sign → sign, dvd → dvd, divide → divide +end migrate_algebra end rat