@@ -22,12 +22,24 @@ class State;
2222class TypeChecker ;
2323
2424/* *
25- * Provides utilities for linearizing patterns
25+ * Utility for rewriting non-linear EO program patterns into linear patterns.
26+ *
27+ * Some target encodings, including Lean pattern matching, require each pattern
28+ * variable to occur at most once. `LinearPattern` rewrites repeated variables
29+ * by replacing later occurrences with fresh parameters and collecting equality
30+ * guards that enforce the original sharing. When a guarded case is followed
31+ * by later cases, linearization may split the original program into helper
32+ * programs so the old fall-through behavior is preserved.
33+ *
34+ * The utility is exposed as static methods because callers typically need a
35+ * one-shot transformation of an already-built program definition.
2636 */
2737class LinearPattern : public StdPlugin
2838{
2939 public:
40+ /* * Construct the linear-pattern utility plugin. */
3041 LinearPattern (State& s);
42+ /* * Destroy the linear-pattern utility plugin. */
3143 ~LinearPattern ();
3244 /* *
3345 * Linearize patterns in prog whose definition is progDef.
@@ -44,6 +56,7 @@ class LinearPattern : public StdPlugin
4456 * If condition is null, then no linearization was necessary.
4557 */
4658 static std::pair<Expr, Expr> linearizePattern (State& s, const Expr& pat);
59+ /* * Recursively replace repeated parameters and collect equality guards. */
4760 static Expr linearizeRec (State& s,
4861 const Expr& pat,
4962 std::map<Expr, size_t >& params,
0 commit comments