Typeclasses for commuting heterogeneous operations #
The three classes in this file are for two-argument functions where one input is of type α,
the output is of type β and the other input is of type α or β.
They express the property that permuting arguments of type α does not change the result.
Main definitions #
IsSymmOp: forop : α → α → β,op a b = op b a.LeftCommutative: forop : α → β → β,op a₁ (op a₂ b) = op a₂ (op a₁ b).RightCommutative: forop : β → α → β,op (op b a₁) a₂ = op (op b a₂) a₁.
LeftCommutative op where op : α → β → β says that op is a left-commutative operation,
i.e. op a₁ (op a₂ b) = op a₂ (op a₁ b).
A left-commutative operation satisfies
op a₁ (op a₂ b) = op a₂ (op a₁ b).
Instances
RightCommutative op where op : β → α → β says that op is a right-commutative operation,
i.e. op (op b a₁) a₂ = op (op b a₂) a₁.
Instances
@[instance 100]
instance instRightCommutativeOfLeftCommutative {α : Sort u} {β : Sort v} {f : α → β → β} [h : LeftCommutative f] :
RightCommutative fun (x : β) (y : α) => f y x
instance instLeftCommutativeOfRightCommutative {α : Sort u} {β : Sort v} {f : β → α → β} [h : RightCommutative f] :
LeftCommutative fun (x : α) (y : β) => f y x
instance instLeftCommutativeOfCommutativeOfAssociative {α : Sort u} {f : α → α → α} [hc : Std.Commutative f] [ha : Std.Associative f] :
instance instRightCommutativeOfCommutativeOfAssociative {α : Sort u} {f : α → α → α} [hc : Std.Commutative f] [ha : Std.Associative f] :