# What's a general rule for this little lambda calculus identity?

I've been fiddling around with a project that does some normalization of lambda calculus(-like) expressions and I stumbled upon that

(λ λ ... λ n (n-1) ... 2 1)


(De Brujin notation) is just the identity. I've generalized this a little to realize I can do stuff like

(λ λ λ λ 4 2 1) = (λ λ 2)


So basically if you can identify some character in your expression which is just the variable index n, and all variable indices to the left of that point are greater than n, and to the right is just descending down the variable indices one at a time to index 1 then you can eliminate all the indices to the right of that character (including that character) and then eliminate the _λ_s from the head of the expression and decrease the remaining indices appropriately.

This feels too haphazard to be the simplest form of this identity though. There must be a cleaner way to express this, and possibly a more general rule.