artdag: Phase 7 optimisation laws as confluent maude module + 11 tests
lib/artdag/optimize-rules.sx — the effect-pipeline optimisation passes (identity elim, no-op/zero-radius elim, adjacent fusion, idempotent over dedup) as a maude module. Radius algebra is _+_ [assoc comm id: 0] (NOT Peano successor rules, which are non-confluent here); mau/confluent? certifies 0 non-joinable critical pairs, so the optimised pipeline's normal form / content id is rewrite-order stable. Consumes lib/maude/confluence.sx. maude-optimize 25/25, total 183/183. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -110,3 +110,60 @@
|
||||
(artdag/dag-id mo-diamond "a")
|
||||
(keys (artdag/dag-nodes mo-diamond-rt)))
|
||||
true)
|
||||
|
||||
; ---- optimisation laws as a confluent maude module (optimize-rules.sx) ----
|
||||
; The optimised pipeline is the normal form; confluence => stable content id.
|
||||
|
||||
(artdag-test "opt module is confluent" (artdag/opt-confluent?) true)
|
||||
|
||||
(artdag-test
|
||||
"opt module has no non-joinable critical pairs"
|
||||
(len (artdag/opt-non-joinable))
|
||||
0)
|
||||
|
||||
(artdag-test
|
||||
"law: identity elimination"
|
||||
(artdag/opt-normal-form "id(src)")
|
||||
"src")
|
||||
|
||||
(artdag-test
|
||||
"law: zero-radius blur is a no-op"
|
||||
(artdag/opt-normal-form "blur(src, 0)")
|
||||
"src")
|
||||
|
||||
(artdag-test
|
||||
"law: zero-radius bright is a no-op"
|
||||
(artdag/opt-normal-form "bright(src, 0)")
|
||||
"src")
|
||||
|
||||
(artdag-test
|
||||
"law: adjacent blur fusion adds radii"
|
||||
(artdag/opt-normal-form "blur(blur(src, 1), 1)")
|
||||
"blur(src, _+_(1, 1))")
|
||||
|
||||
(artdag-test
|
||||
"fusion normal form is rewrite-order stable"
|
||||
(artdag/opt-same-form?
|
||||
"blur(blur(blur(src, 1), 1), 1)"
|
||||
"blur(blur(src, 1 + 1), 1)")
|
||||
true)
|
||||
|
||||
(artdag-test
|
||||
"laws compose: id + no-op + fusion"
|
||||
(artdag/opt-normal-form "bright(id(blur(blur(src, 1), 1)), 0)")
|
||||
"blur(src, _+_(1, 1))")
|
||||
|
||||
(artdag-test
|
||||
"law: idempotent over dedup (CSE)"
|
||||
(artdag/opt-normal-form "over(blur(src, 1), blur(src, 1))")
|
||||
"blur(src, 1)")
|
||||
|
||||
(artdag-test
|
||||
"distinct over operands do not dedup"
|
||||
(artdag/opt-same-form? "over(blur(src, 1), blur(src, 1 + 1))" "blur(src, 1)")
|
||||
false)
|
||||
|
||||
(artdag-test
|
||||
"distinct pipelines stay distinct"
|
||||
(artdag/opt-same-form? "blur(src, 1)" "bright(src, 1)")
|
||||
false)
|
||||
|
||||
Reference in New Issue
Block a user