| Did you know ... | Search Documentation: |
| Pack starlog -- NESTED_CONCATENATION_SUMMARY.md |
Complete all combinations and configurations of:
starlog_call(Result is find([A,C], starlog_call([A:a:C] is [a:a:c]))).
Enhanced the Starlog library to support nested concatenation in dual expressions by improving the concat_dual predicate in starlog_expand.pl.
Added two new cases to concat_dual (lines 642-656 in starlog_expand.pl):
(A:(a:C)) is (b:(a:c))(a:C) is (a:c) to constrain C((a:A):b) is ((a:C):b)(a:A) is (a:C) to constrain A and C
The solution leverages the existing solve_nested_concat_dual predicate which recursively handles nested patterns. The key insight is that when we have:
(A:a:C) is (b:a:c)(A:(a:C)) is (b:(a:c))(a:C) and (a:c) are concat expressionstests/test_find_nested_concat.pl)[A:a:C] is [a:a:c] → Result = [a,c][A:x:C] is [y:x:z] → Result = [y,z][A:b:C:d] is [a:b:c:d] → Result = [a,c][a:B:C] is [a:b:c] → Result = [b,c](A:a:C) is (b:a:c) → A=b, C=c[a:b:c] is [A:b:C] → A=a, C=c[A:b:C:d:E] is [a:b:c:d:e] → Result = [a,c,e][A:"_":C] is ["hello":"_":"world"] → Result = ["hello","world"]
10. Nested atom: `[A•m•C] is [x•m•y]` → Result = [x,y]
All 10 tests pass ✓
All 10 existing tests in tests/test_find.pl continue to pass ✓
demo_find_nested_concat.pl)Created comprehensive demo showing:
:) and atom (•) operatorsEnhanced documentation in two sections:
✓ [A:a:C] is [a:a:c] - Multiple variables with fixed middle values
✓ [A:b:C:d] is [a:b:c:d] - Four-way concatenation
✓ [A:"-":C:"-":E] is ["x":"-":"y":"-":"z"] - Five-way with separators
✓ `[A•x•C] is [y•x•z]` - Atom concatenation
✓ (A:a:C) is (b:a:c) - Direct (not in list)
✓ [a:b:c] is [A:b:C] - Variables on right side
✗ [A:B:c] is [a:b:c] - Two consecutive variables (instantiation error)
✗ [A:B:C] is [a:b:c] - All variables (instantiation error)
These fail because there's insufficient information to determine how to split the concatenated result. At least one bound value is needed in each concat operation to constrain the solution.
starlog_expand.pl - Enhanced concat_dual predicate (26 lines added)tests/test_find_nested_concat.pl - New test suite (125 lines)demo_find_nested_concat.pl - New demo (116 lines)README.md - Documentation updates (34 lines)
Total: ~300 lines of new code and documentationfind(Template, Goal))