Cadabra Computer algebra system for field theory problems
Expression comparison

## Module Description

Functions to compare and match expressions stored in Ex objects.

These can involve wildcards and dummy indices, and matching may depend on the properties attached to symbols. This is an important bit of functionality used widely throughout the Cadabra core. All substitution and component evaluation logic depends on this module.

## Classes

A generic tree comparison class which will take into account index contractions and will also keep track of a replacement list for all types of cadabra wildcards. More...

## Functions

int cadabra::subtree_compare (const Properties *, Ex::iterator one, Ex::iterator two, int mod_prel=-2, bool checksets=true, int compare_multiplier=-2, bool literal_wildcards=false)
Basic building block subtree comparison function for tensors without dummy indices, which determines whether two tensor subtrees are equal up to the names of indices. More...

## ◆ subtree_compare()

 int cadabra::subtree_compare ( const Properties * , Ex::iterator one, Ex::iterator two, int mod_prel = -2, bool checksets = true, int compare_multiplier = -2, bool literal_wildcards = false )

Basic building block subtree comparison function for tensors without dummy indices, which determines whether two tensor subtrees are equal up to the names of indices.

This uses NO property information whatsoever; when indices are compared, they are simply compared based on their name, not on the index set they may belong to. In most cases, this is NOT what you want.

In MOST cases, the use of Ex_comparator below is recommended instead, as it can do much more complicated matching and will also keep track of the relation between symbols in the pattern and symbols in the object to be matched.

Examples:

A_m                        equals  A_n                       up to index names
\diff{A*B_g*\diff{C}_k}_m  equals  \diff{A*B_h*\diff{C}_r}_s up to index names

return meaning
0 structure equal, and all indices the same name
1 structure equal, index names of one < two
-1 structure equal, index names of one > two
2 structure different, one < two
-2 structure different, one > two
Parameters
 one object two pattern mod_prel see below checksets ignored FIXME: remove compare_multiplier whether to match the multiplier field too. literal_wildcards whether to treat wildcard names as ordinary names.

The mod_prel variable determines whether parent relations are taken into account when comparing: FIXME: now that subtree_compare does not use properties anymore, a lot can be simplified.

   -3: require that parent relations match, unless indexpos=free.
-2: require that parent relations match (even when indexpos = free)
-1: do not require that parent relations match
>=0: do not require parent relations to match up to and including this level


Similar logic holds for the compare_multiplier parameter.