lean4-htt/tests/lean/run/1123.lean
Leonardo de Moura 2df35360ee
feat: validate reducibility attribute setting (#4052)
and new option `set_option allowUnsafeReductibility true` to override
validation.

---------

Co-authored-by: Mario Carneiro <di.gama@gmail.com>
2024-05-03 13:44:42 +00:00

48 lines
1.6 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.

class OpAssoc (op : ααα) : Prop where
protected op_assoc (x y z) : op (op x y) z = op x (op y z)
abbrev op_assoc (op : ααα) [self : OpAssoc op] := self.op_assoc
structure SemigroupSig (α) where
op : ααα
structure SemiringSig (α) where
add : ααα
mul : ααα
def SemiringSig.toAddSemigroupSig (s : SemiringSig α) : SemigroupSig α where
op := s.add
def SemiringSig.toMulSemigroupSig (s : SemiringSig α) : SemigroupSig α where
op := s.mul
unif_hint (s : SemiringSig α) (t : SemigroupSig α) where
t =?= s.toAddSemigroupSig ⊢ t.op =?= s.add
unif_hint (s : SemiringSig α) (t : SemigroupSig α) where
t =?= s.toMulSemigroupSig ⊢ t.op =?= s.mul
class Semigroup (s : SemigroupSig α) : Prop where
protected op_assoc (x y z) : s.op (s.op x y) z = s.op x (s.op y z)
instance Semirgoup.toOpAssoc (s : SemigroupSig α) [Semigroup s] : OpAssoc (no_index s.op) := ⟨Semigroup.op_assoc⟩
class Semiring (s : SemiringSig α) : Prop where
protected add_assoc (x y z) : s.add (s.add x y) z = s.add x (s.add y z)
protected mul_assoc (x y z) : s.mul (s.mul x y) z = s.mul x (s.mul y z)
instance Semiring.toAddSemigroup (s : SemiringSig α) [Semiring s] : Semigroup (no_index s.toAddSemigroupSig) where
op_assoc := Semiring.add_assoc
instance Semiring.toMulSemigroup (s : SemiringSig α) [Semiring s] : Semigroup (no_index s.toMulSemigroupSig) where
op_assoc := Semiring.mul_assoc
section Test
variable (s : SemiringSig α) [Semiring s]
local infix:70 " ⋆ " => s.mul
example (w x y z : α) : (w ⋆ x) ⋆ (y ⋆ z) = w ⋆ ((x ⋆ y) ⋆ z) := by
repeat rw [op_assoc (.⋆.)]
end Test