lean4-htt/tests/lean/run/1202.lean
Joe Hendrix 8293fd4e09
feat: cleanups to ACI and Identity classes (#3195)
This makes changes to the definitions of Associativity, Commutativity,
Idempotence and Identity classes to be more aligned with Mathlib's
versions.

The changes are:
*  Move classes are moved from `Lean` to root namespace.
* Drop `Is` prefix from names.
* Rename `IsNeutral` to `LawfulIdentity` and add Left and Right
subclasses.
* Change neutral/identity element to outParam.
* Introduce `HasIdentity` for operations not intended for proofs to
implement

The identity changes are to make this compatible with
[Mathlib](718042db9d/Mathlib/Init/Algebra/Classes.lean)
and to enable nicer fold operations in Std that can use type classes to
infer the identity/initial element on binary operations.

---------

Co-authored-by: Kyle Miller <kmill31415@gmail.com>
2024-01-24 21:46:58 +00:00

17 lines
508 B
Text

opaque f : Bool → Bool → Bool
axiom f_comm (a b : Bool) : f a b = f b a
axiom f_assoc (a b c : Bool) : f (f a b) c = f a (f b c)
open Std
instance : Commutative f := ⟨f_comm⟩
instance : Associative f := ⟨f_assoc⟩
example (a b c : Bool) : f (f a b) c = f (f a c) b :=
by ac_rfl -- good
example (a b c : Bool) : (f (f a b) c = f (f a c) b) ∧ true :=
And.intro (by ac_rfl) rfl -- good
example (a b c : Bool) : (f (f a b) c = f (f a c) b) ∧ true := by
apply And.intro
. ac_rfl
. rfl