-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo_list_dual_expressions.pl
More file actions
121 lines (94 loc) · 6.6 KB
/
Copy pathdemo_list_dual_expressions.pl
File metadata and controls
121 lines (94 loc) · 6.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
% demo_list_dual_expressions.pl
% Demonstration of list dual expressions without append operator
% Feature: Complete [A:...a] is [b:...B] and [A•a:c] is [b•B:c]
:- use_module(starlog).
demo_basic_string :-
write('╔════════════════════════════════════════════╗'), nl,
write('║ Basic String Concatenation in Lists ║'), nl,
write('╚════════════════════════════════════════════╝'), nl, nl,
write('Pattern: [A:a] is [b:B]'), nl,
write('Meaning: List with concat expr on both sides'), nl,
write('Solution: A + a = b + B (bidirectional)'), nl, nl,
([A:a] is [b:B]),
format('Result: A = ~w, B = ~w~n', [A, B]),
write('Verification: A:a = b:B ✓'), nl, nl.
demo_basic_atom :-
write('╔════════════════════════════════════════════╗'), nl,
write('║ Basic Atom Concatenation in Lists ║'), nl,
write('╚════════════════════════════════════════════╝'), nl, nl,
write('Pattern: [A•a] is [b•B]'), nl,
write('Meaning: Same as string but with atom concat'), nl, nl,
([A•a] is [b•B]),
format('Result: A = ~w, B = ~w~n', [A, B]),
write('Verification: A•a = b•B ✓'), nl, nl.
demo_mixed_operators :-
write('╔════════════════════════════════════════════╗'), nl,
write('║ Mixed Operators in Single Element ║'), nl,
write('╚════════════════════════════════════════════╝'), nl, nl,
write('Pattern: [(A•a):c] is [(b•B):c]'), nl,
write('Meaning: Nested concat with both • and :'), nl,
write('First compute A•a and b•B, then concat with c'), nl, nl,
([(A•a):c] is [(b•B):c]),
format('Result: A = ~w, B = ~w~n', [A, B]),
write('Verification: (A•a):c = (b•B):c ✓'), nl, nl.
demo_multiple_elements :-
write('╔════════════════════════════════════════════╗'), nl,
write('║ Multiple Elements with Concat ║'), nl,
write('╚════════════════════════════════════════════╝'), nl, nl,
write('Pattern: [A•q, x] is [p•q, x]'), nl,
write('Meaning: First element has concat, second is literal'), nl,
write('Note: suffixes must match (q = q) for solution'), nl, nl,
([A•q, x] is [p•q, x]),
format('Result: A = ~w~n', [A]),
write('Verification: [A•q, x] = [p•q, x] ✓'), nl, nl.
demo_multiple_concat :-
write('╔════════════════════════════════════════════╗'), nl,
write('║ Multiple Concat Elements ║'), nl,
write('╚════════════════════════════════════════════╝'), nl, nl,
write('Pattern: [A•a, B•b] is [p•a, r•b]'), nl,
write('Meaning: Each element paired bidirectionally'), nl,
write('First: A•a = p•a → A = p'), nl,
write('Second: B•b = r•b → B = r'), nl, nl,
([A•a, B•b] is [p•a, r•b]),
format('Result: A = ~w, B = ~w~n', [A, B]),
write('Verification: Both equations solved! ✓'), nl, nl.
demo_longer_chains :-
write('╔════════════════════════════════════════════╗'), nl,
write('║ Longer Concatenation Chains ║'), nl,
write('╚════════════════════════════════════════════╝'), nl, nl,
write('Pattern: [A:x:y] is [p:x:y]'), nl,
write('Meaning: Nested concat A:x:y = p:x:y'), nl,
write('Since x:y matches, A must equal p'), nl, nl,
([A:x:y] is [p:x:y]),
format('Result: A = ~w~n', [A]),
write('Verification: Nested concat solved! ✓'), nl, nl.
demo_use_cases :-
write('╔════════════════════════════════════════════╗'), nl,
write('║ Real-World Use Cases ║'), nl,
write('╚════════════════════════════════════════════╝'), nl, nl,
write('1. Template Matching'), nl,
write(' Pattern: [Prefix:suffix] is [known_value]'), nl,
write(' Extracts Prefix from a string with known suffix'), nl, nl,
write('2. Dual Constraints'), nl,
write(' Pattern: [A:b, C:d] is [Result1, Result2]'), nl,
write(' Solves multiple concat equations simultaneously'), nl, nl,
write('3. Mixed Operator Parsing'), nl,
write(' Pattern: [(Atom•suffix):string_part]'), nl,
write(' Combines atom and string operations'), nl, nl.
main :-
write(''), nl,
write('═══════════════════════════════════════════════════════════════'), nl,
write(' List Dual Expressions Demonstration'), nl,
write(' Feature: [A:a] is [b:B] and [A•a:c] is [b•B:c]'), nl,
write('═══════════════════════════════════════════════════════════════'), nl, nl,
demo_basic_string,
demo_basic_atom,
demo_mixed_operators,
demo_multiple_elements,
demo_multiple_concat,
demo_longer_chains,
demo_use_cases,
write('═══════════════════════════════════════════════════════════════'), nl,
write('All demonstrations completed successfully! ✓'), nl,
write('═══════════════════════════════════════════════════════════════'), nl.
:- initialization(main, main).