Skip to content

Commit b6727e9

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 6706319 commit b6727e9

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

machine_learning/ttentails.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@
1111
import ast
1212
import operator
1313

14-
OPS = {
15-
ast.And: operator.and_,
16-
ast.Or: operator.or_,
17-
ast.Not: operator.not_
18-
}
14+
OPS = {ast.And: operator.and_, ast.Or: operator.or_, ast.Not: operator.not_}
15+
1916

2017
def safe_eval(expr: str, model: dict[str, bool]) -> bool:
2118
"""Safely evaluate propositional logic expression using ast."""
@@ -39,6 +36,7 @@ def _eval(node):
3936

4037
return _eval(tree)
4138

39+
4240
def tt_entails(kb: list[str], query: str, symbols: list[str]) -> bool:
4341
"""
4442
Check if the knowledge base entails the query using truth tables.
@@ -59,7 +57,9 @@ def tt_entails(kb: list[str], query: str, symbols: list[str]) -> bool:
5957
model: dict[str, bool] = dict(zip(symbols, values))
6058
# Check if KB is true under this model
6159
# # If query is false in this model, KB does not entail query
62-
if all(safe_eval(sentence, model) for sentence in kb) and not safe_eval(query, model):
60+
if all(safe_eval(sentence, model) for sentence in kb) and not safe_eval(
61+
query, model
62+
):
6363
return False
6464
return True
6565

0 commit comments

Comments
 (0)