diff --git a/core/src/main/java/it/cavallium/warppi/math/rules/dsl/PatternUtils.java b/core/src/main/java/it/cavallium/warppi/math/rules/dsl/PatternUtils.java
new file mode 100644
index 00000000..7911fe5c
--- /dev/null
+++ b/core/src/main/java/it/cavallium/warppi/math/rules/dsl/PatternUtils.java
@@ -0,0 +1,72 @@
+package it.cavallium.warppi.math.rules.dsl;
+
+import it.cavallium.warppi.math.Function;
+import it.cavallium.warppi.math.FunctionOperator;
+import it.cavallium.warppi.math.functions.Subtraction;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+/**
+ * Contains helper methods which are useful for writing patterns.
+ */
+public class PatternUtils {
+ /**
+ * Gathers captured sub-functions from two matches, checking for equality
+ * of ones with the same name.
+ *
+ * @param match1 Sub-functions from one match.
+ * @param match2 Sub-functions from the other match.
+ * @return A Map
containing all sub-functions, or an empty
+ * Optional
if the same name is used to refer to
+ * non-equal sub-functions in the two matches.
+ */
+ public static Optional