Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the name of this generalization of idempotence?

Lots of commonly useful properties of functions have concise names. For example, associativity, commutativity, transitivity, etc.

I am making a library for use with QuickCheck that provides shorthand definitions of these properties and others.

The one I have a question about is idempotence of unary functions. A function f is idempotent iif ∀x . f x == f (f x).

There is an interesting generalization of this property for which I am struggling to find a similarly concise name. To avoid biasing peoples name choices by suggesting one, I'll name it P and provide the following definition:

A function f has the P property with respect to g iif ∀x . f x == f (g x). We can see this as a generalization of idempotence by redefining idempotence in terms of P. A function f is idempotent iif it has the P property with respect to itself.

To see that this is a useful property observe that it justifies a rewrite rule that can be used to implement a number of common optimizations. This often but not always arises when g is some sort of canonicalization function. Some examples:

  • length is P with respect to map f (for all choices of f)
  • Converting to CNF is P with respect to converting to DNF (and vice versa)
  • Unicode normalization to form NFC is P with respect to normalization to form NFD (and vice versa)
  • minimum is P with respect to nub

What would you name this property?

like image 466
Doug McClean Avatar asked Dec 01 '11 17:12

Doug McClean


1 Answers

One can say that map f is length-preserving, or that length is invariant under map fing. So how about:

  • g is f-preserving.
  • f is invariant under (applying) g.
like image 170
Prateek Avatar answered Nov 14 '22 16:11

Prateek