Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -25,29 +25,34 @@ class BasicAgent:
|
|
25 |
to be put in the list is a number or a string."""
|
26 |
)
|
27 |
|
28 |
-
# Operation table for the set S = {a, b, c, d, e}
|
29 |
-
self.operation_table = {
|
30 |
-
'a': {'a': 'a', 'b': 'b', 'c': 'c', 'd': 'b', 'e': 'd'},
|
31 |
-
'b': {'a': 'b', 'b': 'c', 'c': 'a', 'd': 'e', 'e': 'c'},
|
32 |
-
'c': {'a': 'c', 'b': 'a', 'c': 'b', 'd': 'b', 'e': 'a'},
|
33 |
-
'd': {'a': 'b', 'b': 'e', 'c': 'b', 'd': 'e', 'e': 'd'},
|
34 |
-
'e': {'a': 'd', 'b': 'b', 'c': 'a', 'd': 'd', 'e': 'c'}
|
35 |
-
}
|
36 |
|
37 |
def check_commutativity(self):
|
38 |
S = ['a', 'b', 'c', 'd', 'e']
|
39 |
counter_example_elements = set()
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
# Check for commutativity violations
|
42 |
for x in S:
|
43 |
for y in S:
|
44 |
-
if self.operation_table[x][y] != self.operation_table[y][x]:
|
45 |
counter_example_elements.add(x)
|
46 |
counter_example_elements.add(y)
|
47 |
|
48 |
# Return the sorted list of elements involved in violations
|
49 |
return sorted(counter_example_elements)
|
50 |
|
|
|
51 |
|
52 |
def maybe_reversed(self, text: str) -> bool:
|
53 |
words = text.split()
|
|
|
25 |
to be put in the list is a number or a string."""
|
26 |
)
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
def check_commutativity(self):
|
30 |
S = ['a', 'b', 'c', 'd', 'e']
|
31 |
counter_example_elements = set()
|
32 |
|
33 |
+
# Define a map for converting letters to table indices
|
34 |
+
index = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4}
|
35 |
+
|
36 |
+
# Operation table (example)
|
37 |
+
self.operation_table = [
|
38 |
+
['a', 'b', 'c', 'b', 'd'], # a * a, a * b, a * c, a * d, a * e
|
39 |
+
['b', 'c', 'a', 'e', 'c'], # b * a, b * b, b * c, b * d, b * e
|
40 |
+
['c', 'a', 'b', 'b', 'a'], # c * a, c * b, c * c, c * d, c * e
|
41 |
+
['b', 'e', 'b', 'e', 'd'], # d * a, d * b, d * c, d * d, d * e
|
42 |
+
['d', 'b', 'a', 'd', 'c'] # e * a, e * b, e * c, e * d, e * e
|
43 |
+
]
|
44 |
+
|
45 |
# Check for commutativity violations
|
46 |
for x in S:
|
47 |
for y in S:
|
48 |
+
if self.operation_table[index[x]][index[y]] != self.operation_table[index[y]][index[x]]:
|
49 |
counter_example_elements.add(x)
|
50 |
counter_example_elements.add(y)
|
51 |
|
52 |
# Return the sorted list of elements involved in violations
|
53 |
return sorted(counter_example_elements)
|
54 |
|
55 |
+
|
56 |
|
57 |
def maybe_reversed(self, text: str) -> bool:
|
58 |
words = text.split()
|