Skip to content

Commit

Permalink
builtin_entities.py: attach the scope-method to I14["mathematical pro…
Browse files Browse the repository at this point in the history
…position"]

instead of I5["implication proposition"]
  • Loading branch information
cknoll committed Dec 6, 2023
1 parent 68be99b commit 703cb06
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/pyerk/builtin_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,12 +471,7 @@ def instance_of(cls_entity, r1: str = None, r2: str = None, qualifiers: List[Ite
)


I15 = create_builtin_item(
key_str="I15",
R1__has_label="implication proposition",
R2__has_description="proposition, where the premise (if-part) implies the assertion (then-part)",
R3__is_subclass_of=I14["mathematical proposition"],
)
# I15 is defined below


I16 = create_builtin_item(
Expand Down Expand Up @@ -1263,7 +1258,7 @@ def _rule__scope(self: Item, scope_name: str):
return cm


I15["implication proposition"].add_method(_proposition__scope, name="scope")
I14["mathematical proposition"].add_method(_proposition__scope, name="scope")


def _get_subscopes(self):
Expand All @@ -1274,7 +1269,7 @@ def _get_subscopes(self):
return scope_rels


I15["implication proposition"].add_method(_get_subscopes, name="get_subscopes")
I14["mathematical proposition"].add_method(_get_subscopes, name="get_subscopes")
I16["scope"].add_method(_get_subscopes, name="get_subscopes")


Expand All @@ -1299,7 +1294,7 @@ def _get_subscope(self, name: str):
return res[0]


I15["implication proposition"].add_method(_get_subscope, name="get_subscope")
I14["mathematical proposition"].add_method(_get_subscope, name="get_subscope")
I16["scope"].add_method(_get_subscope, name="get_subscope")


Expand Down Expand Up @@ -1329,6 +1324,14 @@ def _get_items_for_scope(self):
I16["scope"].add_method(_get_items_for_scope, name="get_items_for_scope")


I15 = create_builtin_item(
key_str="I15",
R1__has_label="implication proposition",
R2__has_description="proposition, where the premise (if-part) implies the assertion (then-part)",
R3__is_subclass_of=I14["mathematical proposition"],
)


I17 = create_builtin_item(
key_str="I17",
R1__has_label="equivalence proposition",
Expand Down
21 changes: 21 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,27 @@ def test_d16__IntegerRangeElement(self):
M_ij = ma.I3240["matrix element"](cm.M, i, j)
cm.new_equation(lhs=M_ij, rhs=ma.I5000["scalar zero"])

def test_e01__I14_subclass_scopes(self):
# test whether the scope method is inherited correctly
with p.uri_context(uri=TEST_BASE_URI, prefix="ut"):
prop = p.instance_of(p.I17["equivalence proposition"])
scp1 = prop.scope("setting")
scp2 = prop.scope("premise")
scp3 = prop.scope("assertion")

I1000 = p.create_item(
R1__has_label="Cayley-Hamilton theorem",
R4__is_instance_of=p.I15["implication proposition"],
)

scp1 = I1000.scope("setting")

I1001 = p.create_item(
R1__has_label="Cayley-Hamilton theorem",
R4__is_instance_of=p.I17["equivalence proposition"],
)
scp1 = I1001.scope("setting")


class Test_02_ruleengine(HouskeeperMixin, unittest.TestCase):
def setUp(self):
Expand Down

0 comments on commit 703cb06

Please sign in to comment.