Skip to content

Commit 3c9b951

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

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

machine_learning/ttentails.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import itertools
1111
from typing import List, Dict
1212

13+
1314
def tt_entails(kb: List[str], query: str, symbols: List[str]) -> bool:
1415
"""
1516
Check if the knowledge base entails the query using truth tables.
@@ -21,8 +22,8 @@ def tt_entails(kb: List[str], query: str, symbols: List[str]) -> bool:
2122
2223
Returns:
2324
bool: True if KB entails query, False otherwise
24-
25-
Example:
25+
26+
Example:
2627
tt_entails(["P or Q"], "Q", ["P","Q"])
2728
2829
"""
@@ -35,19 +36,17 @@ def tt_entails(kb: List[str], query: str, symbols: List[str]) -> bool:
3536
return False
3637
return True
3738

39+
3840
# Example usage
3941
if __name__ == "__main__":
4042
# Example 1: KB entails query → should return True
4143
symbols = ["P", "Q"]
42-
kb = ["P or Q", "not P or Q"] # KB says P or Q is True, and not P or Q is True
43-
query = "Q" # Query: Is Q True?
44+
kb = ["P or Q", "not P or Q"] # KB says P or Q is True, and not P or Q is True
45+
query = "Q" # Query: Is Q True?
4446
print("Does KB entail query? : ", tt_entails(kb, query, symbols))
45-
47+
4648
# Example 2: KB does NOT entail query → should return False
4749
symbols2 = ["P", "Q"]
48-
kb2 = ["P"] # KB says only P is True
49-
query2 = "Q" # Query asks if Q is True
50+
kb2 = ["P"] # KB says only P is True
51+
query2 = "Q" # Query asks if Q is True
5052
print("Does KB2 entail query2? : ", tt_entails(kb2, query2, symbols2))
51-
52-
53-

0 commit comments

Comments
 (0)