It is clear that for any list $x$, Reverse[Reverse[x]]=x. I want to have Mathematica tell me that this is true. I have tried entering

Reverse[Reverse[x]] == x

Mathematica responds with "Nonatomic expression expected at position 1 in Reverse[x]." I suppose because Mathematica can only apply Reverse to lists.

How can I get Mathematica to tell me that

Reverse[Reverse[x]] == x

is true?

  • 3
    $\begingroup$ Reverse is an active function. There is no built-in symbolic representation of Reverse upon which analysis can be carried out. I have found that you can use Mathematica's analysis capabilities on symbols which in the documentation are noted as being "suitable for symbolic manipulation." $\endgroup$ – QuantumDot Apr 21 '16 at 12:48

I think that there is a fundamental misunderstanding here.

In Mathematica certain expressions are meant to represent mathematica statements. x > 1 is an example of this. Other expressions are simply program code, which is run by the system, like in any other programming language. An example is Table[x, {x,10}]. Sometimes there is a level of overlap between these, e.g. in Abs[x] > 0, Abs[x] represents the absolute value of some variable, but Abs is also a function that will be run and return the result of a computation, e.g. Abs[{-1.2, -0.5, 0.6, 0.9}].

Now Reverse is purely a programming construct. It is never used to represent any mathematical statement. What you are asking is not within the builtin capabilities of Mathematica. It is not able to take a general program and prove things about its behaviour. It also does not have special features to work with lists as mathematical entities, similar to how it can work with complex numbers, Boolean values or variables representing them (and recently even with symbolic tensors).

So to sum up, it is not possible to get Mathematica to tell us that Reverse[Reverse[x]] == x in any reasonable manner. Reverse is a programming construct which expects a certain kind of input which cannot be a symbol.

|improve this answer|||||
  • $\begingroup$ That's a quite interesting question due to the subtle matter you've explained. Notice that OP has never used mathematics reference. And it's ok to ask about Equality or being the Same within WolframLanguage/Mathematica world. And OP statement is not True in this world. It's up to OP to restrict assumptions better. $\endgroup$ – Kuba Apr 21 '16 at 9:51
  • $\begingroup$ I think this is the reason the developers introduced Inactive in version 10: so that symbols like Reverse can be deactivated for symbolic manipulation. Do you agree with my comment to OP? $\endgroup$ – QuantumDot Apr 21 '16 at 13:07
  • $\begingroup$ @QuantumDot Well, it can be inactivated, but Mathematica still doesn't have any functionality to prove things about how code runs, and I think Reverse is still meant to be a programming construct and not meant to represent maths ... $\endgroup$ – Szabolcs Apr 21 '16 at 13:16

Hypothesis: It is clear that for any List x, Reverse[Reverse[x]]=x

Disproof by Counterexample:

Let's el1:

(This is an UpValue for el1 so one can't argue we are messing with List itself. And there are no restrictions about lists contents.)

List[el1, rest___] ^:= List[rest] 


list = {1, 2, el1}


Reverse@Reverse@list === list


So your statement is incorrect for Lists in general. You may want to restrict that to e.g finite sequences of integers and ask again :)

|improve this answer|||||
  • $\begingroup$ Yes, I was only thinking of finite sequences. Thanks for pointing out the unstated assumption. $\endgroup$ – spinoza Apr 21 '16 at 19:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.