lean4-htt/library/init/algebra/classes.lean
Leonardo de Moura 55fee26b36 feat(library/class): add attribute for tracking symbols occurring in instances of type classes
For more information see:
https://github.com/leanprover/lean/wiki/Refactoring-structures
The new attribute [algebra] implements the [algebraic_class] described
in the page above.
2017-05-01 18:02:30 -07:00

66 lines
2.8 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/-
Copyright (c) 2017 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
prelude
import init.logic
universes u
@[algebra] class is_commutative (α : Type u) (op : ααα) : Prop :=
(comm : ∀ a b, op a b = op b a)
@[algebra] class is_associative (α : Type u) (op : ααα) : Prop :=
(assoc : ∀ a b c, op (op a b) c = op a (op b c))
@[algebra] class is_left_id (α : Type u) (op : ααα) (o : inout α) : Prop :=
(left_id : ∀ a, op o a = a)
@[algebra] class is_right_id (α : Type u) (op : ααα) (o : inout α) : Prop :=
(right_id : ∀ a, op a o = a)
@[algebra] class is_left_null (α : Type u) (op : ααα) (o : inout α) : Prop :=
(left_null : ∀ a, op o a = o)
@[algebra] class is_right_null (α : Type u) (op : ααα) (o : inout α) : Prop :=
(right_null : ∀ a, op a o = o)
@[algebra] class is_left_cancel (α : Type u) (op : ααα) : Prop :=
(left_cancel : ∀ a b c, op a b = op a c → b = c)
@[algebra] class is_right_cancel (α : Type u) (op : ααα) : Prop :=
(right_cancel : ∀ a b c, op a b = op c b → a = c)
@[algebra] class is_idempotent (α : Type u) (op : ααα) : Prop :=
(idempotent : ∀ a, op a a = a)
@[algebra] class is_left_distrib (α : Type u) (op₁ : ααα) (op₂ : inout ααα) : Prop :=
(left_distrib : ∀ a b c, op₁ a (op₂ b c) = op₂ (op₁ a b) (op₁ a c))
@[algebra] class is_right_distrib (α : Type u) (op₁ : ααα) (op₂ : inout ααα) : Prop :=
(right_distrib : ∀ a b c, op₁ (op₂ a b) c = op₂ (op₁ a c) (op₁ b c))
@[algebra] class is_left_inv (α : Type u) (op : ααα) (inv : inout αα) (o : inout α) : Prop :=
(left_inv : ∀ a, op (inv a) a = o)
@[algebra] class is_right_inv (α : Type u) (op : ααα) (inv : inout αα) (o : inout α) : Prop :=
(right_inv : ∀ a, op a (inv a) = o)
@[algebra] class is_cond_left_inv (α : Type u) (op : ααα) (inv : inout αα) (o : inout α) (p : inout α → Prop) : Prop :=
(left_inv : ∀ a, p a → op (inv a) a = o)
@[algebra] class is_cond_right_inv (α : Type u) (op : ααα) (inv : inout αα) (o : inout α) (p : inout α → Prop) : Prop :=
(right_inv : ∀ a, p a → op a (inv a) = o)
@[algebra] class is_distinct (α : Type u) (a : α) (b : α) : Prop :=
(distinct : a ≠ b)
/-
-- The following type class doesn't seem very useful, a regular simp lemma should work for this.
class is_inv (α : Type u) (β : Type v) (f : α → β) (g : inout β → α) : Prop :=
(inv : ∀ a, g (f a) = a)
-- The following one can also be handled using a regular simp lemma
class is_idempotent (α : Type u) (f : αα) : Prop :=
(idempotent : ∀ a, f (f a) = f a)
-/