# Wolfram/CodeEquivalenceUtilities

(2.0.4) current version: 3.0.0 »

Utilities for testing code equivalence

Contributed By: Richard Hennigan

CodeEquivalenceUtilities is a collection of Wolfram Language functions that can be used to test if different pieces of code are equivalent without the need for evaluation.

This allows comparison of unevaluated expressions that may have non-deterministic outputs (e.g. random values, dates, etc).

This Paclet represents the underlying technology that powers several automated code grading systems, such as the online exercises for EIWL and Wolfram Challenges.

## Installation Instructions

To install this paclet in your Wolfram Language environment, evaluate this code:
PacletInstall["Wolfram/CodeEquivalenceUtilities"]

## Examples

### Basic Examples (2)

Check if two expressions are equivalent:

 In[1]:=
 Out[1]=

View the canonical representations of expressions:

 In[2]:=
 Out[2]=
 In[3]:=
 Out[3]=

These are directly comparable:

 In[4]:=
 Out[4]=

### Scope (3)

 In[5]:=
 Out[5]=

View the sequence of transformations used to convert an expression to its canonical form:

 In[6]:=
 Out[6]=

Convert a canonical representation to a normal expression:

 In[7]:=
 Out[7]=
 In[8]:=
 Out[8]=

Evaluate:

 In[9]:=
 Out[9]=

### Neat Examples (6)

Here is a list of expressions, some of which are equivalent to others:

 In[10]:=

Find the sequence of transformations for each expression:

 In[11]:=
 Out[11]=

Generate a graph for each sequence:

 In[12]:=
 Out[12]=

Combine the graphs:

 In[13]:=

Equivalent expressions converge to the same connected component:

 In[14]:=
 Out[14]=

Group the expressions into their corresponding equivalence class:

 In[15]:=
 Out[15]=
 In[16]:=
 Out[16]=

## Version History

• 3.0.0 – 22 June 2023
• 2.7.0 – 20 January 2023
• 2.6.0 – 12 January 2023
• 2.4.1 – 07 November 2022
• 2.4.0 – 04 November 2022
• 2.3.1 – 01 November 2022
• 2.2.1 – 27 October 2022
• 2.2.0 – 06 October 2022
• 2.1.0 – 23 September 2022
• 2.0.5 – 24 August 2022
• 2.0.4 – 22 June 2022
• 2.0.3 – 09 June 2022
• 2.0.2 – 20 May 2022
• 2.0.1 – 19 May 2022
• 2.0.0 – 19 May 2022
• 1.5.0 – 21 April 2022
• 1.4.11 – 21 April 2022
• 1.3.1 – 01 December 2021