Skip to content

Commit

Permalink
Added search utility and boolean algebra for representing predicate l…
Browse files Browse the repository at this point in the history
…ogic

Signed-off-by: Ayush Joshi <[email protected]>
  • Loading branch information
joshiayush committed Nov 14, 2023
1 parent b8c57d8 commit 66cd599
Show file tree
Hide file tree
Showing 5 changed files with 447 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
from bs4 import BeautifulSoup
from urllib.parse import urlparse

from .stats import corrcoef
from .stats import (cov, corrcoef)
from .mathematical_functions import proportion
from .boolalg import (
Sentence, Symbol, Not, And, Or, Implication, Biconditional, model_check
)

from .neighbors import KNeighborsClassifier
from .naive_bayes import GaussianNaiveBayes
Expand Down Expand Up @@ -76,7 +79,6 @@ def _PreprocessReadme(fpath: Union[str, pathlib.Path]) -> str:
'Introduction-to-ML.md',
'Descending-into-ML.md',
'Reducing-Loss.md',
'Introduction-to-TensorFlow.md',
'Generalization.md',
'Training-and-Test-Sets.md',
'Validation-Set.md',
Expand Down
37 changes: 37 additions & 0 deletions ai/boolalg/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2023 The AI Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# pylint: disable=too-many-function-args, invalid-name, missing-module-docstring
# pylint: disable=missing-class-docstring

"""Symbolic Propositional Logic for Knowledge representation.
>>> from ai import (Symbol, And, Or, Not, Implication)
...
>>> rain = Symbol("rain")
>>> hagrid = Symbol("hagrid")
>>> dumbledore = Symbol("dumbledore")
...
>>> knowledge = And(
>>> Implication(Not(rain), hagrid),
>>> Or(hagrid, dumbledore),
>>> Not(And(hagrid, dumbledore)),
>>> dumbledore
>>> )
...
>>> print(model_check(knowledge, rain))
"""

from .logic import (
Sentence, Symbol, Not, And, Or, Implication, Biconditional, model_check
)
Loading

0 comments on commit 66cd599

Please sign in to comment.