Commit 33d00349 authored by Hans-Peter Deifel's avatar Hans-Peter Deifel 🐢

polynomial: Sort edge labels before printing

Edge labels contain the indices into the current product, and since we're
walking through factors in from left to right, we also want those indices to
appear in the correct order.

This bug doesn't appear when printing the parsed encoding directly, since edge
labels are usually sorted after parsing. But after our new minimization work,
this will not be a valid assumption anymore.
parent 9c8dcff8
......@@ -303,7 +303,7 @@ printSumPoint (Sum sum) f1 edges =
printProductPoint :: Product () -> F1 Polynomial -> [(Label Polynomial, Build.Builder)] -> Build.Builder
printProductPoint (Product prod) f1 edges' =
let inner = sepFold ", " id (snd (mapAccumL printFactor (0, edges') prod))
let inner = sepFold ", " id (snd (mapAccumL printFactor (0, List.sort edges') prod))
in if NonEmpty.length prod /= 1 then "(" <> inner <> ")" else inner
where
printFactor :: (Int, [(Label Polynomial, Build.Builder)])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment