-
Notifications
You must be signed in to change notification settings - Fork 5
/
duplication_semantics_he_798.metta
55 lines (44 loc) · 1.5 KB
/
duplication_semantics_he_798.metta
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
; Test File: Duplication Semantics in MeTTa
; Bug Report: https://github.com/trueagi-io/hyperon-experimental/issues/798
; Example 1: Asserting Multiple Identical Atoms
; --------------------------------------------
!(add-atom &self (is ball red))
!(add-atom &self (is ball red))
!(add-atom &self (is ball red))
!(add-atom &self (is ball red))
!(add-atom &self (is ball red))
; Test: Match returns all duplicates
!(assertEqualToResult
(match &self (is ball $color) $color)
(red red red red red))
; Example 2: Removing a Duplicated Atom
; -------------------------------------
!(remove-atom &self (is ball red))
; Test: All duplicates are removed
!(assertEqualToResult
(match &self (is ball $color) $color)
())
; Example 3: Space-Specific Behavior
; ----------------------------------
; Assert the same atom in a space again
!(add-atom &self (is ball red))
!(add-atom &self (is ball red))
; Test: Verify duplicates exist
!(assertEqualToResult
(match &self (is ball $color) $color)
(red red))
; Remove one instance
!(remove-atom &self (is ball red))
; Test: Current implementation removes all duplicates
!(assertEqualToResult
(match &self (is ball $color) $color)
())
; Example 4: Probabilistic Use Case
; ---------------------------------
!(add-atom &self (observation ball red))
!(add-atom &self (observation ball red))
!(add-atom &self (observation ball red))
; Test: Count duplicates for probabilistic reasoning
!(assertEqualToResult
(match &self (observation ball $color) $color)
(red red red))