From 952e10325fb053e895d5cd89e7c02e65eb19c064 Mon Sep 17 00:00:00 2001 From: Zander Kotze <59666243+ZanderCowboy@users.noreply.github.com> Date: Tue, 10 Oct 2023 07:16:28 +0000 Subject: [PATCH 01/29] Create pylint.yml --- .github/workflows/pylint.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/pylint.yml diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml new file mode 100644 index 0000000..383e65c --- /dev/null +++ b/.github/workflows/pylint.yml @@ -0,0 +1,23 @@ +name: Pylint + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pylint + - name: Analysing the code with pylint + run: | + pylint $(git ls-files '*.py') From 9f2e25ab35aef6828bd3bac8de1b083c686aeaac Mon Sep 17 00:00:00 2001 From: Zander Kotze <59666243+ZanderCowboy@users.noreply.github.com> Date: Tue, 10 Oct 2023 07:19:53 +0000 Subject: [PATCH 02/29] Update pylint.yml --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 383e65c..c9c962e 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} From c01868a8dcb199784569cc1f42baf3287ba046c3 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Tue, 10 Oct 2023 10:50:00 +0200 Subject: [PATCH 03/29] Added very_good_analysis to pubspec.yaml --- frontend/pubspec.lock | 62 ++++++++++++++++++++++++------------------- frontend/pubspec.yaml | 26 +++--------------- 2 files changed, 38 insertions(+), 50 deletions(-) diff --git a/frontend/pubspec.lock b/frontend/pubspec.lock index c078ef7..b35e7d8 100644 --- a/frontend/pubspec.lock +++ b/frontend/pubspec.lock @@ -5,10 +5,10 @@ packages: dependency: transitive description: name: async - sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted - version: "2.10.0" + version: "2.11.0" boolean_selector: dependency: transitive description: @@ -21,10 +21,10 @@ packages: dependency: transitive description: name: characters - sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" clock: dependency: transitive description: @@ -37,10 +37,10 @@ packages: dependency: transitive description: name: collection - sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.17.2" cupertino_icons: dependency: "direct main" description: @@ -75,14 +75,6 @@ packages: description: flutter source: sdk version: "0.0.0" - js: - dependency: transitive - description: - name: js - sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" - url: "https://pub.dev" - source: hosted - version: "0.6.5" lints: dependency: transitive description: @@ -95,34 +87,34 @@ packages: dependency: transitive description: name: matcher - sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" url: "https://pub.dev" source: hosted - version: "0.12.13" + version: "0.12.16" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.5.0" meta: dependency: transitive description: name: meta - sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" path: dependency: transitive description: name: path - sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.8.3" sky_engine: dependency: transitive description: flutter @@ -132,10 +124,10 @@ packages: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" stack_trace: dependency: transitive description: @@ -172,10 +164,10 @@ packages: dependency: transitive description: name: test_api - sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" url: "https://pub.dev" source: hosted - version: "0.4.16" + version: "0.6.0" vector_math: dependency: transitive description: @@ -184,5 +176,21 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + very_good_analysis: + dependency: "direct dev" + description: + name: very_good_analysis + sha256: "9ae7f3a3bd5764fb021b335ca28a34f040cd0ab6eec00a1b213b445dae58a4b8" + url: "https://pub.dev" + source: hosted + version: "5.1.0" + web: + dependency: transitive + description: + name: web + sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + url: "https://pub.dev" + source: hosted + version: "0.1.4-beta" sdks: - dart: ">=2.19.6 <3.0.0" + dart: ">=3.1.0-185.0.dev <4.0.0" diff --git a/frontend/pubspec.yaml b/frontend/pubspec.yaml index a05e574..a5783f3 100644 --- a/frontend/pubspec.yaml +++ b/frontend/pubspec.yaml @@ -1,21 +1,7 @@ name: frontend description: A new Flutter project. -# The following line prevents the package from being accidentally published to -# pub.dev using `flutter pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev +publish_to: 'none' -# The following defines the version and build number for your application. -# A version number is three numbers separated by dots, like 1.2.43 -# followed by an optional build number separated by a +. -# Both the version and the builder number may be overridden in flutter -# build by specifying --build-name and --build-number, respectively. -# In Android, build-name is used as versionName while build-number used as versionCode. -# Read more about Android versioning at https://developer.android.com/studio/publish/versioning -# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. -# Read more about iOS versioning at -# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -# In Windows, build-name is used as the major, minor, and patch parts -# of the product and file versions while build-number is used as the build suffix. version: 1.0.0+1 environment: @@ -30,15 +16,12 @@ environment: dependencies: flutter: sdk: flutter - - - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 dev_dependencies: flutter_test: sdk: flutter + # The "flutter_lints" package below contains a set of recommended lints to # encourage good coding practices. The lint set provided by the package is @@ -46,16 +29,13 @@ dev_dependencies: # package. See that file for information about deactivating specific lint # rules and activating additional ones. flutter_lints: ^2.0.0 + very_good_analysis: ^5.1.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec # The following section is specific to Flutter packages. flutter: - - # The following line ensures that the Material Icons font is - # included with your application, so that you can use the icons in - # the material Icons class. uses-material-design: true # To add assets to your application, add an assets section, like this: From 35d612fe0a7ea686fa62e239800d3700ddf053c3 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Tue, 10 Oct 2023 10:50:32 +0200 Subject: [PATCH 04/29] Added very_good_analysis to pubspec.yaml --- .vscode/settings.json | 3 +++ frontend/analysis_options.yaml | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..457f44d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.analysis.typeCheckingMode": "basic" +} \ No newline at end of file diff --git a/frontend/analysis_options.yaml b/frontend/analysis_options.yaml index 61b6c4d..7c10e91 100644 --- a/frontend/analysis_options.yaml +++ b/frontend/analysis_options.yaml @@ -7,7 +7,8 @@ # The following line activates a set of recommended lints for Flutter apps, # packages, and plugins designed to encourage good coding practices. -include: package:flutter_lints/flutter.yaml +# include: package:flutter_lints/flutter.yaml +include: package:very_good_analysis/analysis_options.yaml linter: # The lint rules applied to this project can be customized in the From 27b55b81f1b9b29219a9605ba3e24111c3fb44a1 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Tue, 10 Oct 2023 15:05:07 +0200 Subject: [PATCH 05/29] Added SonarLint to .iml files. --- backend/backend.iml | 3 +++ engine/engine.iml | 3 +++ frontend/android/frontend_android.iml | 3 +++ frontend/frontend.iml | 4 ++++ 4 files changed, 13 insertions(+) diff --git a/backend/backend.iml b/backend/backend.iml index 6db0c46..837f56c 100644 --- a/backend/backend.iml +++ b/backend/backend.iml @@ -8,4 +8,7 @@ + + \ No newline at end of file diff --git a/engine/engine.iml b/engine/engine.iml index fcbe024..c6a59a8 100644 --- a/engine/engine.iml +++ b/engine/engine.iml @@ -6,4 +6,7 @@ + + \ No newline at end of file diff --git a/frontend/android/frontend_android.iml b/frontend/android/frontend_android.iml index e779e48..217c97e 100644 --- a/frontend/android/frontend_android.iml +++ b/frontend/android/frontend_android.iml @@ -24,4 +24,7 @@ + + \ No newline at end of file diff --git a/frontend/frontend.iml b/frontend/frontend.iml index 6756fa3..8cdb61b 100644 --- a/frontend/frontend.iml +++ b/frontend/frontend.iml @@ -14,5 +14,9 @@ + + + + \ No newline at end of file From eb7f079ef5d49428eec42518987a5b28242af9ac Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Tue, 10 Oct 2023 15:09:45 +0200 Subject: [PATCH 06/29] Fixed linting issues. --- engine/Components/CreateConditionals.py | 63 ------ engine/Components/CreateElements.py | 24 --- engine/Components/FindVariables.py | 44 ---- engine/Components/PrintDetails.py | 27 --- engine/Components/RegularExpression.py | 52 ----- engine/Components/create_conditionals.py | 66 ++++++ engine/Components/create_elements.py | 27 +++ engine/Components/find_variables.py | 47 +++++ engine/Components/print_details.py | 30 +++ engine/Components/regular_expression.py | 65 ++++++ engine/Computation/EvaluateStatement.py | 189 ------------------ engine/Computation/PropositionalRules.py | 137 ------------- engine/Computation/evaluate_statement.py | 189 ++++++++++++++++++ engine/Computation/propositional_rules.py | 145 ++++++++++++++ .../{SimulateMain.py => simulate_main.py} | 6 +- 15 files changed, 572 insertions(+), 539 deletions(-) delete mode 100644 engine/Components/CreateConditionals.py delete mode 100644 engine/Components/CreateElements.py delete mode 100644 engine/Components/FindVariables.py delete mode 100644 engine/Components/PrintDetails.py delete mode 100644 engine/Components/RegularExpression.py create mode 100644 engine/Components/create_conditionals.py create mode 100644 engine/Components/create_elements.py create mode 100644 engine/Components/find_variables.py create mode 100644 engine/Components/print_details.py create mode 100644 engine/Components/regular_expression.py delete mode 100644 engine/Computation/EvaluateStatement.py delete mode 100644 engine/Computation/PropositionalRules.py create mode 100644 engine/Computation/evaluate_statement.py create mode 100644 engine/Computation/propositional_rules.py rename engine/Simulator/{SimulateMain.py => simulate_main.py} (94%) diff --git a/engine/Components/CreateConditionals.py b/engine/Components/CreateConditionals.py deleted file mode 100644 index eb21524..0000000 --- a/engine/Components/CreateConditionals.py +++ /dev/null @@ -1,63 +0,0 @@ -from Components.Constants import OPEN_ARROW, DASH, CLOSE_ARROW, COND_ELEM, BICOND_ELEM, PRE_CHECK -from Logging.logging_config import logger - - -def create_conditionals(array_of_elements: list) -> list: - """ - Creates the conditional -> from ['-', '>'] and - biconditional <-> from ['<', '-', '>']. - - :rtype: list - :param array_of_elements: takes a statement with individual pieces in an array. - :return: Returns a new array with connectives as one element. - """ - logger.debug("Creating one-piece conditionals from single elements.") - - # Do a search for '-', and if found continue, o.w. return. - logger.debug("Searching for a '-' in array_of_elements=%s", array_of_elements) - end_of_line = False - for i, char in enumerate(array_of_elements): - if i == len(array_of_elements) - 1: - end_of_line = True - if char not in PRE_CHECK: # no symbols present - if end_of_line: - logger.debug("Search for conditionals finished and none were found, returning.") - return array_of_elements - continue - elif char in PRE_CHECK: - break - - logger.debug("Conditional symbols were found in %s", array_of_elements) - conditional_symbol = False - biconditional_symbol = False - for i in range(len(array_of_elements)): - if i == len(array_of_elements): - break - - char = array_of_elements[i] - if char == OPEN_ARROW: # checks to see if we have a biconditional - if array_of_elements[i + 1] == DASH and array_of_elements[i + 2] == CLOSE_ARROW: - array_of_elements.pop(i) - array_of_elements.pop(i) - array_of_elements.pop(i) - array_of_elements.insert(i, BICOND_ELEM) - continue - - # if we have a conditional - elif (char == DASH and array_of_elements[i + 1] == CLOSE_ARROW and - biconditional_symbol is False): # if we have a conditional - array_of_elements.pop(i) - array_of_elements.pop(i) - array_of_elements.insert(i, COND_ELEM) - continue - elif char == CLOSE_ARROW and conditional_symbol is False: - continue - else: # other characters - if conditional_symbol is False and biconditional_symbol is False: - pass - conditional_symbol = False - biconditional_symbol = False - - logger.debug("array_of_elements=%s", array_of_elements) - logger.debug("Finished creating conditionals.") - return array_of_elements diff --git a/engine/Components/CreateElements.py b/engine/Components/CreateElements.py deleted file mode 100644 index f2d92cb..0000000 --- a/engine/Components/CreateElements.py +++ /dev/null @@ -1,24 +0,0 @@ -from Logging.logging_config import logger - - -def create_array_of_elements(statement: str) -> list: - """ - This takes a statement as a string and returns an array of elements - For example: - "(P^Q)" => ['(', 'P', '^', 'Q', ')'] - - :rtype: list - :param statement: string - :return: Returns an array of elements - """ - logger.debug("Creating an array from a string...") - logger.debug("Calling create_array_of_elements(%s)", statement) - - array_of_elements = [] - for i in range(len(statement)): - char = statement[i] - array_of_elements.append(char) - - logger.debug("array_of_elements=%s", array_of_elements) - logger.debug("Finished creating array.") - return array_of_elements diff --git a/engine/Components/FindVariables.py b/engine/Components/FindVariables.py deleted file mode 100644 index 7193e7c..0000000 --- a/engine/Components/FindVariables.py +++ /dev/null @@ -1,44 +0,0 @@ -from Components.Constants import VALID_BRACKETS, VALID_CONNECTIVES -from Logging.logging_config import logger - - -def find_variables(statement: str) -> list: - """ - Runs through the statement to determine all the variables given in the - statement. - - :rtype: list - :param statement: given user statement - :return: Returns an array variables - """ - logger.info("Finding variables in statement...") - - # todo Check if all whitespaces are removed. If so, continue o.w. call clean_whitespaces() - - logger.debug("statement=%s", statement) - variables_array = [] - variables_string = "" - non_variable_characters = VALID_BRACKETS + VALID_CONNECTIVES - for i in range(len(statement)): - duplicate = False - char = statement[i] - - if char not in non_variable_characters: # if char is not a bracket or a connective - # Testing for duplicates - duplicate_int = statement.find(char, i + 1) - var_str_find = variables_string.find(char) - if len(variables_array) > 0 and duplicate_int > 0 and var_str_find >= 0: - duplicate = True - if duplicate_int == -1: # no initial or more occurrences - if var_str_find >= 0: - continue - if len(variables_array) == 0 or duplicate is False: - variables_array.append(char) - variables_string += char - elif duplicate: - continue - - logger.debug("variables_array=%s", variables_array) - logger.info("Found all variables in statement.") - logger.info("*** Variables:\t%s ***", variables_array) - return variables_array diff --git a/engine/Components/PrintDetails.py b/engine/Components/PrintDetails.py deleted file mode 100644 index 4b395e2..0000000 --- a/engine/Components/PrintDetails.py +++ /dev/null @@ -1,27 +0,0 @@ -from Logging.logging_config import logger - - -def print_details(name: str, *args): - """ - This is a generalized print function for logs. It takes a section name - followed by (name,value) tuples. For example, - - print_details("TEST", ("some_name", some_value)) where 'some_value' can be - passed. - - :param name: Required: A name for the details section, CAPITALIZED. - :param args: Optional: Any number of parameters as tuples that can be - printed - :return: - """ - logger.debug("Printing details...") - - max_length = 60 - len_name = len(name) - amount_stars = max_length - len_name - star_line = "*" * int(amount_stars/2) + " " + name.upper() + " " + "*" * int(amount_stars/2) - - logger.info(star_line) - for arg_name, arg_value in args: - logger.info("-> %s: \t%s", arg_name, arg_value) - logger.info(star_line) diff --git a/engine/Components/RegularExpression.py b/engine/Components/RegularExpression.py deleted file mode 100644 index f7a8b59..0000000 --- a/engine/Components/RegularExpression.py +++ /dev/null @@ -1,52 +0,0 @@ -import re - -from Logging.logging_config import logger - - -def validate_input(input_string: str) -> bool: - logger.debug("Calling validate_input(%s)...", input_string) - - # pattern = r"^(?:[a-zA-Z](?:_\d+)?|[a-zA-Z])$|[\^v!<>-]" - pattern = r"^(?:[a-zA-Z](?:_\d+)?|[a-zA-Z])$|[\^v!<>-]" - result = re.fullmatch(pattern, input_string) is not None - - logger.debug("Checked against a regex. result(is it valid?)=%s.", result) - return result - - -# todo Create Unit Test -# Test cases -test_cases = [ - "^", - "v", - "P", - "P_1", - "P_2", - "a", - "a_123", - "123", - "@", - "#", - "%", - "A", - "B_42", - "C_", # questionable - "P^Q", - "PvQ", - "P->Q", - "P<->Q", - "R_10", - "X-Y", - "Z_99", - "0", - "5", - "P@Q", - "abc", # No - "def_", - "_xyz", - "<", - ">", - "R-5", - "S^6", - "T_7", -] diff --git a/engine/Components/create_conditionals.py b/engine/Components/create_conditionals.py new file mode 100644 index 0000000..b5494b5 --- /dev/null +++ b/engine/Components/create_conditionals.py @@ -0,0 +1,66 @@ +""" +Insert +""" +from components.constants import OPEN_ARROW, DASH, CLOSE_ARROW, COND_ELEM, BICOND_ELEM, PRE_CHECK +from engine_logging.logging_config import logger + + +def create_conditionals(array_of_elements: list) -> list: + """ + Creates the conditional -> from ['-', '>'] and + biconditional <-> from ['<', '-', '>']. + + :rtype: list + :param array_of_elements: takes a statement with individual pieces in an array. + :return: Returns a new array with connectives as one element. + """ + logger.debug("Creating one-piece conditionals from single elements.") + + # Do a search for '-', and if found continue, o.w. return. + logger.debug("Searching for a '-' in array_of_elements=%s", array_of_elements) + end_of_line = False + for i, char in enumerate(array_of_elements): + if i == len(array_of_elements) - 1: + end_of_line = True + if char not in PRE_CHECK: # no symbols present + if end_of_line: + logger.debug("Search for conditionals finished and none were found, returning.") + return array_of_elements + continue + elif char in PRE_CHECK: + break + + logger.debug("Conditional symbols were found in %s", array_of_elements) + conditional_symbol = False + biconditional_symbol = False + for i in range(len(array_of_elements)): + if i == len(array_of_elements): + break + + char = array_of_elements[i] + if char == OPEN_ARROW: # checks to see if we have a biconditional + if array_of_elements[i + 1] == DASH and array_of_elements[i + 2] == CLOSE_ARROW: + array_of_elements.pop(i) + array_of_elements.pop(i) + array_of_elements.pop(i) + array_of_elements.insert(i, BICOND_ELEM) + continue + + # if we have a conditional + elif (char == DASH and array_of_elements[i + 1] == CLOSE_ARROW and + biconditional_symbol is False): # if we have a conditional + array_of_elements.pop(i) + array_of_elements.pop(i) + array_of_elements.insert(i, COND_ELEM) + continue + elif char == CLOSE_ARROW and conditional_symbol is False: + continue + else: # other characters + if conditional_symbol is False and biconditional_symbol is False: + pass + conditional_symbol = False + biconditional_symbol = False + + logger.debug("array_of_elements=%s", array_of_elements) + logger.debug("Finished creating conditionals.") + return array_of_elements diff --git a/engine/Components/create_elements.py b/engine/Components/create_elements.py new file mode 100644 index 0000000..7370841 --- /dev/null +++ b/engine/Components/create_elements.py @@ -0,0 +1,27 @@ +""" +Insert +""" +from engine_logging.logging_config import logger + + +def create_array_of_elements(statement: str) -> list: + """ + This takes a statement as a string and returns an array of elements + For example: + "(P^Q)" => ['(', 'P', '^', 'Q', ')'] + + :rtype: list + :param statement: string + :return: Returns an array of elements + """ + + logger.debug("Creating an array from a string...") + logger.debug("Calling create_array_of_elements(%s)", statement) + + array_of_elements = [] + for _, char in enumerate(statement): + array_of_elements.append(char) + + logger.debug("array_of_elements=%s", array_of_elements) + logger.debug("Finished creating array.") + return array_of_elements diff --git a/engine/Components/find_variables.py b/engine/Components/find_variables.py new file mode 100644 index 0000000..bbdd48a --- /dev/null +++ b/engine/Components/find_variables.py @@ -0,0 +1,47 @@ +""" +Insert +""" +from engine_logging import logger +from components import VALID_BRACKETS, VALID_CONNECTIVES + + +def find_variables(statement: str) -> list: + """ + Runs through the statement to determine all the variables given in the + statement. + + :rtype: list + :param statement: given user statement + :return: Returns an array variables + """ + logger.info("Finding variables in statement...") + + # todo Check if all whitespaces are removed. If so, continue o.w. call clean_whitespaces() + + logger.debug("statement=%s", statement) + variables_array = [] + variables_string = "" + non_variable_characters = VALID_BRACKETS + VALID_CONNECTIVES + i: int + for i, char in enumerate(statement): + duplicate = False + + if char not in non_variable_characters: # if char is not a bracket or a connective + # Testing for duplicates + duplicate_int = statement.find(char, i + 1) + var_str_find = variables_string.find(char) + if len(variables_array) > 0 and duplicate_int > 0 and var_str_find >= 0: + duplicate = True + if duplicate_int == -1: # no initial or more occurrences + if var_str_find >= 0: + continue + if len(variables_array) == 0 or duplicate is False: + variables_array.append(char) + variables_string += char + elif duplicate: + continue + + logger.debug("variables_array=%s", variables_array) + logger.info("Found all variables in statement.") + logger.info("*** Variables:\t%s ***", variables_array) + return variables_array diff --git a/engine/Components/print_details.py b/engine/Components/print_details.py new file mode 100644 index 0000000..640ae23 --- /dev/null +++ b/engine/Components/print_details.py @@ -0,0 +1,30 @@ +""" +Insert +""" +from engine_logging.logging_config import logger + + +def print_details(name: str, *args): + """ + This is a generalized print function for logs. It takes a section name + followed by (name,value) tuples. For example, + + print_details("TEST", ("some_name", some_value)) where 'some_value' can be + passed. + + :param name: Required: A name for the details section, CAPITALIZED. + :param args: Optional: Any number of parameters as tuples that can be + printed + :return: + """ + logger.debug("Printing details...") + + max_length = 60 + len_name = len(name) + amount_stars = max_length - len_name + star_line = "*" * int(amount_stars/2) + " " + name.upper() + " " + "*" * int(amount_stars/2) + + logger.info(star_line) + for arg_name, arg_value in args: + logger.info("-> %s: \t%s", arg_name, arg_value) + logger.info(star_line) diff --git a/engine/Components/regular_expression.py b/engine/Components/regular_expression.py new file mode 100644 index 0000000..ca6954a --- /dev/null +++ b/engine/Components/regular_expression.py @@ -0,0 +1,65 @@ +"""_summary_ + +Returns: + _type_: _description_ +""" +import re + +from engine_logging import logger + + +def validate_input(input_string: str) -> bool: + """_summary_ + + Args: + input_string (str): _description_ + + Returns: + bool: _description_ + """ + logger.debug("Calling validate_input(%s)...", input_string) + + # pattern = r"^(?:[a-zA-Z](?:_\d+)?|[a-zA-Z])$|[\^v!<>-]" + pattern = r"^(?:[a-zA-Z](?:_\d+)?|[a-zA-Z])$|[\^v!<>-]" + result = re.fullmatch(pattern, input_string) is not None + + logger.debug("Checked against a regex. result(is it valid?)=%s.", result) + return result + + +# todo Create Unit Test +# Test cases +test_cases = [ + "^", + "v", + "P", + "P_1", + "P_2", + "a", + "a_123", + "123", + "@", + "#", + "%", + "A", + "B_42", + "C_", # questionable + "P^Q", + "PvQ", + "P->Q", + "P<->Q", + "R_10", + "X-Y", + "Z_99", + "0", + "5", + "P@Q", + "abc", # No + "def_", + "_xyz", + "<", + ">", + "R-5", + "S^6", + "T_7", +] diff --git a/engine/Computation/EvaluateStatement.py b/engine/Computation/EvaluateStatement.py deleted file mode 100644 index 64dc8b8..0000000 --- a/engine/Computation/EvaluateStatement.py +++ /dev/null @@ -1,189 +0,0 @@ -from math import log2 - -from Computation.SwitchConnectives import switch_case -from Computation.TableMatrix.CreateTableMatrix import create_matrix -from Logging.logging_config import logger - - -def evaluate_array_as_tree(number_of_variables, variables_as_array, elements_in_tree): - """ - This is used to take an array of elements in a tree-like structure, and - evaluates the elements from the bottom up, using a recursive internal - function. - - :param number_of_variables: Number of variables in statement - :param variables_as_array: Variables as array - :param elements_in_tree: Statement with elements in tree-like structure - :returns: Returns an array with the last evaluation, a matrix containing - all evaluations and an array with all variables, including auxiliary ones. - """ - logger.info("Starting evaluation of array of elements...") - - counter = 0 - matrix = create_matrix(number_of_variables) - - logger.debug("In evaluate_array_as_tree(): \nelements_in_tree=%s, \ncounter=%d, \nmatrix=%s, " - "\nvariables_as_array=%s", elements_in_tree, counter, matrix, variables_as_array) - returned_array, final_variable_combined, returned_matrix, all_variables = ( - evaluate_array(elements_in_tree, counter, matrix, variables_as_array)) - - all_variables.append(final_variable_combined[0]) - - logger.debug("returned_array=%s, returned_matrix=%s, all_variables=%s", returned_array, returned_matrix, all_variables) - logger.debug("Finished evaluating array.") - return returned_array, returned_matrix, all_variables - - -def evaluate_array(array: list, counter: int, matrix: list, variables: list): - """ - This acts as inner recursive function to evaluate an array. - - :param array: Array with elements in a tree structure - :param counter: Counter to keep track of recursive calls - :param matrix: Matrix used by evaluation - :param variables: List of variables in statement - :return: returned_array, final_variable_combined, returned_matrix, all_variables - """ - logger.debug("Calling evaluate_array(%s, %d, %s, %s)...", array, counter, matrix, variables) - - # todo Fix bug for ((!Q) -> (!P)) - # if negation is encountered, add placeholder value in front - if len(array) == 2: - blank = '_' - array = [blank, array[0], array[1]] - - left_array = array[0] - connective = array[1] - right_array = array[2] - - # induction case - # ******************* LEFT ************************ - if len(left_array) != 1: - temp_left_array = left_array - - counter += 1 - array_evaluated, left_array, placeholder, placeholder = evaluate_array(temp_left_array, counter, matrix, variables) - counter -= 1 - variables = add_array_to_matrix(matrix, array_evaluated, variables, left_array) - - # ******************* RIGHT ************************ - if len(right_array) != 1: - temp_right_array = right_array - - counter += 1 - array_evaluated, right_array, placeholder, placeholder = evaluate_array(temp_right_array, counter, matrix, variables) - counter -= 1 - variables = add_array_to_matrix(matrix, array_evaluated, variables, right_array) - - # ******************** BASE CASE ************************ - final_variable_combined = [] - - if len(left_array) == 1 and len(right_array) == 1: - # find variables for left and right - left_variable = left_array[0] - right_variable = right_array[0] - - left_variable_position = -1 - right_variable_position = -1 - - # get position for variable in list of variables as a string - for i, item in enumerate(variables): - if left_variable == item: - left_variable_position = i - break - for i, item in enumerate(variables): - if right_variable == item: - right_variable_position = i - break - - # call matrix for each variable, and assign to temp - temp_left = [] - temp_right = [] - for i in range(0, 2 ** int(log2(len(matrix)))): - row_in_matrix = matrix[i] - temp_left.append(row_in_matrix[left_variable_position]) - temp_right.append(row_in_matrix[right_variable_position]) - returned_array = switch_case(connective, temp_left, temp_right) - - # get array item for combined variable - if len(left_array) == 1 and len(right_array) == 1: - temp_array = [left_array, connective, right_array] - final_variable_combined = set_new_array_elem(temp_array) - - if len(final_variable_combined) == 1 and counter == 0: - # append returned_array to matrix - for i in range(len(returned_array)): - entry_in_return_array = returned_array[i] - matrix[i].append(entry_in_return_array) - - logger.debug("In evaluate_array(): \nreturned_array=%s, \nfinal_variable_combined=%s, \nmatrix=%s, \nvariables=%s", - returned_array, final_variable_combined, matrix, variables) - logger.debug("Evaluation of array in evaluate_array() is done.") - return returned_array, final_variable_combined, matrix, variables - - -def set_new_array_elem(temp_array): - """ - This is used to set a new array-element from a temporary array of elements - after calculations were done. - For example: - [['T'], 'v', ['P^Q']] => ['Tv(P^Q)'] - - :param temp_array: An array that contains 3 parts - :return: Returns an array with a single combined entry - """ - logger.debug("Calling set_new_array_elem(%s)...", temp_array) - - left_part = temp_array[0] - connective = temp_array[1] - right_part = temp_array[2] - - new_string = "" - - # look at left part - if left_part[0] == '_': - pass - elif len(left_part[0]) == 1: - new_string += left_part[0] - elif len(left_part[0]) > 1: - temp_part = "(" + left_part[0] + ")" - new_string += temp_part - - # middle part - new_string += connective - - # look at right part - if len(right_part[0]) == 1: - new_string += right_part[0] - elif len(right_part[0]) > 1: - temp_part = "(" + right_part[0] + ")" - new_string += temp_part - new_array = [new_string] - - logger.debug("new_array=%s", new_array) - logger.debug("Finished setting new array element.") - return new_array - - -def add_array_to_matrix(matrix, array_evaluated, variables, variable_entry): - """ - This iterates over a matrix row-by-row and appends the new values in an - evaluated array to the end of it. - - :param matrix: Matrix where the values should be added - :param array_evaluated: Evaluated array to append to matrix - :param variables: Variables in statement - :param variable_entry: Auxiliary entry to add to array of variables - :return: Returns an updated array of variables - """ - logger.debug("Calling add_array_to_matrix(%s, %s, %s, %s)...", matrix, array_evaluated, variables, variable_entry) - - for i in range(len(matrix)): - row_entry = matrix[i] - entry_to_add = array_evaluated[i] - row_entry.append(entry_to_add) - variables.append(variable_entry[0]) # append new 'variable' to array of variables - - logger.debug("variables=%s", variables) - logger.debug("Added array to matrix.") - return variables diff --git a/engine/Computation/PropositionalRules.py b/engine/Computation/PropositionalRules.py deleted file mode 100644 index 506486e..0000000 --- a/engine/Computation/PropositionalRules.py +++ /dev/null @@ -1,137 +0,0 @@ -# This file is to give the rules to calculate the propositional logic. -from math import log2 -from Components.Constants import TRUE, FALSE -from Logging.logging_config import logger - - -# todo double negation cancel out -# todo 'negation', 'for all', 'there exists' bind most tightly; then disj and -# conj; then impl. (which is right-associative) - -class UnequalArraysExcept(Exception): - pass - - -def conjunction(left, right): - """ - AND - :param right: - :param left: - :return: - """ - logger.debug("Calling conjunction(%s, %s)...", left, right) - - if len(left) != len(right): # if they are not equal, raise and skip the rest - logger.exception("The left '%s' and right '%s' arrays are unequal! Exiting.", left, right) - raise UnequalArraysExcept("The left and right arrays are unequal. Please investigate.") - - num = int(log2(len(left))) - new_row_values = [] - for i in range(0, 2 ** num): - if left[i] == TRUE and right[i] == TRUE: - new_row_values.append(TRUE) - else: - new_row_values.append(FALSE) - - logger.debug("new_row_values=%s", new_row_values) - logger.debug("Returning with new row values.") - return new_row_values - - -def disjunction(left, right): - """ - OR - :param right: - :param left: - :return: - """ - logger.debug("Calling disjunction(%s, %s)...", left, right) - - if len(left) != len(right): # if they are not equal, raise and skip the rest - logger.exception("The left '%s' and right '%s' arrays are unequal! Exiting.", left, right) - raise UnequalArraysExcept("The left and right arrays are unequal. Please investigate.") - - num = int(log2(len(left))) - new_row_values = [] - for i in range(0, 2 ** num): - if left[i] == FALSE and right[i] == FALSE: - new_row_values.append(FALSE) - else: - new_row_values.append(TRUE) - - logger.debug("new_row_values=%s", new_row_values) - logger.debug("Returning with new row values.") - return new_row_values - - -def negation(left): - """ - NEGATION - :param left: - :return: - """ - logger.debug("Calling negation(%s)...", left) - - num = int(log2(len(left))) - new_row_values = [] - for i in range(0, 2 ** num): - if left[i] == TRUE: - new_row_values.append(FALSE) - elif left[i] == FALSE: - new_row_values.append(TRUE) - - logger.debug("new_row_values=%s", new_row_values) - logger.debug("Returning with new row values.") - return new_row_values - - -def conditional(left, right): - """ - IMPLICATION - :param left: - :param right: - :return: - """ - logger.debug("Calling conditional(%s, %s)...", left, right) - - if len(left) != len(right): # if they are not equal, raise and skip the rest - logger.exception("The left '%s' and right '%s' arrays are unequal! Exiting.", left, right) - raise UnequalArraysExcept("The left and right arrays are unequal. Please investigate.") - - num = int(log2(len(left))) - new_row_values = [] - for i in range(0, 2 ** num): - if left[i] == TRUE and right[i] == FALSE: - new_row_values.append(FALSE) - else: - new_row_values.append(TRUE) - - logger.debug("new_row_values=%s", new_row_values) - logger.debug("Returning with new row values.") - return new_row_values - - -def biconditional(left, right): - """ - iff - :param left: - :param right: - :return: - """ - logger.debug("Calling biconditional(%s, %s)...", left, right) - - if len(left) != len(right): # if they are not equal, raise and skip the rest - logger.exception("The left '%s' and right '%s' arrays are unequal! Exiting.", left, right) - raise UnequalArraysExcept("The left and right arrays are unequal. Please investigate.") - - num = int(log2(len(left))) - new_row_values = [] - for i in range(0, 2 ** num): - if left[i] == right[i]: - new_row_values.append(TRUE) - else: - new_row_values.append(FALSE) - - logger.debug("new_row_values=%s", new_row_values) - logger.debug("Returning with new row values.") - return new_row_values diff --git a/engine/Computation/evaluate_statement.py b/engine/Computation/evaluate_statement.py new file mode 100644 index 0000000..4f6946f --- /dev/null +++ b/engine/Computation/evaluate_statement.py @@ -0,0 +1,189 @@ +from math import log2 + +from Computation.SwitchConnectives import switch_case +from Computation.TableMatrix.CreateTableMatrix import create_matrix +from engine_logging.logging_config import logger + + +def evaluate_array_as_tree(number_of_variables, variables_as_array, elements_in_tree): + """ + This is used to take an array of elements in a tree-like structure, and + evaluates the elements from the bottom up, using a recursive internal + function. + + :param number_of_variables: Number of variables in statement + :param variables_as_array: Variables as array + :param elements_in_tree: Statement with elements in tree-like structure + :returns: Returns an array with the last evaluation, a matrix containing + all evaluations and an array with all variables, including auxiliary ones. + """ + logger.info("Starting evaluation of array of elements...") + + counter = 0 + matrix = create_matrix(number_of_variables) + + logger.debug("In evaluate_array_as_tree(): \nelements_in_tree=%s, \ncounter=%d, \nmatrix=%s, " + "\nvariables_as_array=%s", elements_in_tree, counter, matrix, variables_as_array) + returned_array, final_variable_combined, returned_matrix, all_variables = ( + evaluate_array(elements_in_tree, counter, matrix, variables_as_array)) + + all_variables.append(final_variable_combined[0]) + + logger.debug("returned_array=%s, returned_matrix=%s, all_variables=%s", returned_array, returned_matrix, all_variables) + logger.debug("Finished evaluating array.") + return returned_array, returned_matrix, all_variables + + +def evaluate_array(array: list, counter: int, matrix: list, variables: list): + """ + This acts as inner recursive function to evaluate an array. + + :param array: Array with elements in a tree structure + :param counter: Counter to keep track of recursive calls + :param matrix: Matrix used by evaluation + :param variables: List of variables in statement + :return: returned_array, final_variable_combined, returned_matrix, all_variables + """ + logger.debug("Calling evaluate_array(%s, %d, %s, %s)...", array, counter, matrix, variables) + + # todo Fix bug for ((!Q) -> (!P)) + # if negation is encountered, add placeholder value in front + if len(array) == 2: + blank = '_' + array = [blank, array[0], array[1]] + + left_array = array[0] + connective = array[1] + right_array = array[2] + + # induction case + # ******************* LEFT ************************ + if len(left_array) != 1: + temp_left_array = left_array + + counter += 1 + array_evaluated, left_array, _, _ = evaluate_array(temp_left_array, counter, matrix, variables) + counter -= 1 + variables = add_array_to_matrix(matrix, array_evaluated, variables, left_array) + + # ******************* RIGHT ************************ + if len(right_array) != 1: + temp_right_array = right_array + + counter += 1 + array_evaluated, right_array, _, _ = evaluate_array(temp_right_array, counter, matrix, variables) + counter -= 1 + variables = add_array_to_matrix(matrix, array_evaluated, variables, right_array) + + # ******************** BASE CASE ************************ + final_variable_combined = [] + + if len(left_array) == 1 and len(right_array) == 1: + # find variables for left and right + left_variable = left_array[0] + right_variable = right_array[0] + + left_variable_position = -1 + right_variable_position = -1 + + # get position for variable in list of variables as a string + for i, item in enumerate(variables): + if left_variable == item: + left_variable_position = i + break + for i, item in enumerate(variables): + if right_variable == item: + right_variable_position = i + break + + # call matrix for each variable, and assign to temp + temp_left = [] + temp_right = [] + for i in range(0, 2 ** int(log2(len(matrix)))): + row_in_matrix = matrix[i] + temp_left.append(row_in_matrix[left_variable_position]) + temp_right.append(row_in_matrix[right_variable_position]) + returned_array = switch_case(connective, temp_left, temp_right) + + # get array item for combined variable + if len(left_array) == 1 and len(right_array) == 1: + temp_array = [left_array, connective, right_array] + final_variable_combined = set_new_array_elem(temp_array) + + if len(final_variable_combined) == 1 and counter == 0: + # append returned_array to matrix + for i in range(len(returned_array)): + entry_in_return_array = returned_array[i] + matrix[i].append(entry_in_return_array) + + logger.debug("In evaluate_array(): \nreturned_array=%s, \nfinal_variable_combined=%s, \nmatrix=%s, \nvariables=%s", + returned_array, final_variable_combined, matrix, variables) + logger.debug("Evaluation of array in evaluate_array() is done.") + return returned_array, final_variable_combined, matrix, variables + + +def set_new_array_elem(temp_array): + """ + This is used to set a new array-element from a temporary array of elements + after calculations were done. + For example: + [['T'], 'v', ['P^Q']] => ['Tv(P^Q)'] + + :param temp_array: An array that contains 3 parts + :return: Returns an array with a single combined entry + """ + logger.debug("Calling set_new_array_elem(%s)...", temp_array) + + left_part = temp_array[0] + connective = temp_array[1] + right_part = temp_array[2] + + new_string = "" + + # look at left part + if left_part[0] == '_': + pass + elif len(left_part[0]) == 1: + new_string += left_part[0] + elif len(left_part[0]) > 1: + temp_part = "(" + left_part[0] + ")" + new_string += temp_part + + # middle part + new_string += connective + + # look at right part + if len(right_part[0]) == 1: + new_string += right_part[0] + elif len(right_part[0]) > 1: + temp_part = "(" + right_part[0] + ")" + new_string += temp_part + new_array = [new_string] + + logger.debug("new_array=%s", new_array) + logger.debug("Finished setting new array element.") + return new_array + + +def add_array_to_matrix(matrix, array_evaluated, variables, variable_entry): + """ + This iterates over a matrix row-by-row and appends the new values in an + evaluated array to the end of it. + + :param matrix: Matrix where the values should be added + :param array_evaluated: Evaluated array to append to matrix + :param variables: Variables in statement + :param variable_entry: Auxiliary entry to add to array of variables + :return: Returns an updated array of variables + """ + logger.debug("Calling add_array_to_matrix(%s, %s, %s, %s)...", matrix, array_evaluated, variables, variable_entry) + + for i in range(len(matrix)): + row_entry = matrix[i] + entry_to_add = array_evaluated[i] + row_entry.append(entry_to_add) + variables.append(variable_entry[0]) # append new 'variable' to array of variables + + logger.debug("variables=%s", variables) + logger.debug("Added array to matrix.") + return variables diff --git a/engine/Computation/propositional_rules.py b/engine/Computation/propositional_rules.py new file mode 100644 index 0000000..463bc83 --- /dev/null +++ b/engine/Computation/propositional_rules.py @@ -0,0 +1,145 @@ +""" +Insert +""" +# This file is to give the rules to calculate the propositional logic. +from math import log2 +from engine_logging import logger +from components import TRUE, FALSE + + +# todo double negation cancel out +# todo 'negation', 'for all', 'there exists' bind most tightly; then disj and +# conj; then impl. (which is right-associative) + +UNEQUAL_LEFT_AND_RIGHT_ARRAYS = ("The left '%s' and right '%s' arrays are " + "unequal! Exiting.") +UNEQUAL_LEFT_AND_RIGHT_ARRAYS_EXCEPT = ("The left and right arrays are unequal. " + "Please investigate.") + + +class UnequalArraysExcept(Exception): + """ + Insert + """ + pass + + +def conjunction(left, right): + """ + AND + :param right: + :param left: + :return: + """ + logger.debug("Calling conjunction(%s, %s)...", left, right) + if len(left) != len(right): # if they are not equal, raise and skip the rest + logger.exception(UNEQUAL_LEFT_AND_RIGHT_ARRAYS, left, right) + raise UnequalArraysExcept(UNEQUAL_LEFT_AND_RIGHT_ARRAYS_EXCEPT) + + num = int(log2(len(left))) + new_row_values = [] + for i in range(0, 2 ** num): + if left[i] == TRUE and right[i] == TRUE: + new_row_values.append(TRUE) + else: + new_row_values.append(FALSE) + + logger.debug("new_row_values=%s", new_row_values) + logger.debug("Returning with new row values.") + return new_row_values + + +def disjunction(left, right): + """ + OR + :param right: + :param left: + :return: + """ + logger.debug("Calling disjunction(%s, %s)...", left, right) + if len(left) != len(right): # if they are not equal, raise and skip the rest + logger.exception(UNEQUAL_LEFT_AND_RIGHT_ARRAYS, left, right) + raise UnequalArraysExcept(UNEQUAL_LEFT_AND_RIGHT_ARRAYS_EXCEPT) + + num = int(log2(len(left))) + new_row_values = [] + for i in range(0, 2 ** num): + if left[i] == FALSE and right[i] == FALSE: + new_row_values.append(FALSE) + else: + new_row_values.append(TRUE) + + logger.debug("new_row_values=%s", new_row_values) + logger.debug("Returning with new row values.") + return new_row_values + + +def negation(left): + """ + NEGATION + :param left: + :return: + """ + logger.debug("Calling negation(%s)...", left) + num = int(log2(len(left))) + new_row_values = [] + for i in range(0, 2 ** num): + if left[i] == TRUE: + new_row_values.append(FALSE) + elif left[i] == FALSE: + new_row_values.append(TRUE) + + logger.debug("new_row_values=%s", new_row_values) + logger.debug("Returning with new row values.") + return new_row_values + + +def conditional(left, right): + """ + IMPLICATION + :param left: + :param right: + :return: + """ + logger.debug("Calling conditional(%s, %s)...", left, right) + + if len(left) != len(right): # if they are not equal, raise and skip the rest + logger.exception(UNEQUAL_LEFT_AND_RIGHT_ARRAYS, left, right) + raise UnequalArraysExcept(UNEQUAL_LEFT_AND_RIGHT_ARRAYS_EXCEPT) + + num = int(log2(len(left))) + new_row_values = [] + for i in range(0, 2 ** num): + if left[i] == TRUE and right[i] == FALSE: + new_row_values.append(FALSE) + else: + new_row_values.append(TRUE) + + logger.debug("new_row_values=%s", new_row_values) + logger.debug("Returning with new row values.") + return new_row_values + + +def biconditional(left, right): + """ + iff + :param left: + :param right: + :return: + """ + logger.debug("Calling biconditional(%s, %s)...", left, right) + if len(left) != len(right): # if they are not equal, raise and skip the rest + logger.exception(UNEQUAL_LEFT_AND_RIGHT_ARRAYS, left, right) + raise UnequalArraysExcept(UNEQUAL_LEFT_AND_RIGHT_ARRAYS_EXCEPT) + + num = int(log2(len(left))) + new_row_values = [] + for i in range(0, 2 ** num): + if left[i] == right[i]: + new_row_values.append(TRUE) + else: + new_row_values.append(FALSE) + + logger.debug("new_row_values=%s", new_row_values) + logger.debug("Returning with new row values.") + return new_row_values diff --git a/engine/Simulator/SimulateMain.py b/engine/Simulator/simulate_main.py similarity index 94% rename from engine/Simulator/SimulateMain.py rename to engine/Simulator/simulate_main.py index f748157..ee245f9 100644 --- a/engine/Simulator/SimulateMain.py +++ b/engine/Simulator/simulate_main.py @@ -1,7 +1,7 @@ -from Components.PrintDetails import print_details -from Computation.EvaluateStatement import * +from components.print_details import print_details +from Computation.evaluate_statement import * from Computation.TableMatrix.DisplayMatrix import display_matrix -from Logging.logging_config import logger +from engine_logging.logging_config import logger from Parser.Checks.CheckBrackets import check_left_and_right_brackets from Parser.Checks.CheckForIllegalCharacters import check_for_illegal_characters from Parser.Checks.CheckBrackets import UnequalBracketsExcept From cfa55fb7e5d287d685c4469e7e622ef4c6bcbd40 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Tue, 10 Oct 2023 16:17:50 +0200 Subject: [PATCH 07/29] Fixed linting issues. --- engine/Components/Constants.py | 6 +- engine/Components/Sanitizer.py | 126 +++++++++--------- engine/Components/Verifier.py | 4 +- engine/Components/__init__.py | 7 + engine/Components/create_conditionals.py | 6 +- engine/Components/create_elements.py | 6 +- engine/Components/find_variables.py | 6 +- engine/Components/print_details.py | 3 +- engine/Computation/SwitchConnectives.py | 45 ------- .../TableMatrix/CreateTableMatrix.py | 3 +- .../Computation/TableMatrix/DisplayMatrix.py | 3 +- .../Computation/TableMatrix/RecursiveTable.py | 5 +- engine/Computation/evaluate_statement.py | 7 +- engine/Computation/propositional_rules.py | 12 +- engine/Computation/switch_connectives.py | 110 +++++++++++++++ engine/Logging/__init__.py | 1 - engine/Main.py | 5 +- engine/Parser/Checks/CheckBrackets.py | 50 +++---- .../Checks/CheckForIllegalCharacters.py | 6 +- engine/Parser/Parse/AnalyzeFunction.py | 22 +-- engine/Parser/Parse/ParseFunction.py | 10 +- engine/Simulator/UserInput.py | 7 +- engine/Simulator/input_statements.py | 2 +- engine/engine_logging/__init__.py | 5 + .../logging_config.py | 20 +-- 25 files changed, 297 insertions(+), 180 deletions(-) delete mode 100644 engine/Computation/SwitchConnectives.py create mode 100644 engine/Computation/switch_connectives.py delete mode 100644 engine/Logging/__init__.py create mode 100644 engine/engine_logging/__init__.py rename engine/{Logging => engine_logging}/logging_config.py (74%) diff --git a/engine/Components/Constants.py b/engine/Components/Constants.py index 5d4bd53..42e87ae 100644 --- a/engine/Components/Constants.py +++ b/engine/Components/Constants.py @@ -1,3 +1,5 @@ +"""_summary_ +""" # Global Variables # todo Change to UPPER CASE, for constants @@ -18,7 +20,7 @@ WHITE_SPACES = " " -# Constants used in CreateConditionals.py +# Constants used in create_conditionals.py OPEN_ARROW = '<' DASH = '-' CLOSE_ARROW = '>' @@ -26,7 +28,6 @@ BICOND_ELEM = "<->" PRE_CHECK = ['<', '-', '>'] - # todo What are illegal characters # What are illegal characters # numbers @@ -39,4 +40,3 @@ # Disjunction: v | || # Conditional: -> => →(Alt 26) # Biconditional: <-> <=> - diff --git a/engine/Components/Sanitizer.py b/engine/Components/Sanitizer.py index 95ce1e4..efbefba 100644 --- a/engine/Components/Sanitizer.py +++ b/engine/Components/Sanitizer.py @@ -1,84 +1,88 @@ +"""_summary_ + +Returns: + _type_: _description_ +""" # todo Changes statement to something that we can use # todo Change to something that the system can use # todo Add brackets # todo Change connectives to one common set # todo Change lower case letters to upper case -from Components.Constants import * -from Logging.logging_config import logger +from engine_logging import logger +from components import LEFT_BRACKETS, RIGHT_BRACKETS, UNARY_CONNECTIVES, BINARY_CONNECTIVES # for example: change & to ^, | to v # todo Refactor to sanitize statement -def add_brackets(statement): - """ - Adds outer brackets to any statement - :param statement: - :return: - """ - pass - new_string = "" +def add_brackets(): + """ + Adds outer brackets to any statement + :param: + :return: + """ + new_string = "" - return new_string + return new_string def clean_whitespaces(statement: str) -> str: - """ - This clears a statement of all whitespaces that are present. - :param statement: given statement - :return: returns a statement with whitespaces removed - """ - logger.debug("Calling clean_whitespaces(%s)...", statement) + """ + This clears a statement of all whitespaces that are present. + :param statement: given statement + :return: returns a statement with whitespaces removed + """ + logger.debug("Calling clean_whitespaces(%s)...", statement) - logger.debug("Finished removing whitespaces: statement=%s", statement.replace(" ", "")) - return statement.replace(" ", "") + logger.debug("Finished removing whitespaces: statement=%s", statement.replace(" ", "")) + return statement.replace(" ", "") def remove_brackets_around_variables(arr: list, variables: list) -> list: - """ - This removes brackets around single variables in an array, e.g., (P) => P - :param arr: - :param variables: Array of variables from statement. - :return: Returns an array without brackets around variables. - """ - logger.debug("Removing brackets around standalone variables...") - - for i in range(0, len(arr) - 2): - if arr[i] in variables: - left_of_variable = arr[i - 1] - right_of_variable = arr[i + 1] - if left_of_variable in LEFT_BRACKETS and right_of_variable in RIGHT_BRACKETS: - arr.pop(i - 1) - arr.pop(i) - # todo Add another loop to make sure that no 'single brackets' are found - - logger.debug("arr=%s", arr) - logger.debug("Finished removing all brackets around variables.") - return arr + """ + This removes brackets around single variables in an array, e.g., (P) => P + :param arr: + :param variables: Array of variables from statement. + :return: Returns an array without brackets around variables. + """ + logger.debug("Removing brackets around standalone variables...") + + for i in range(0, len(arr) - 2): + if arr[i] in variables: + left_of_variable = arr[i - 1] + right_of_variable = arr[i + 1] + if left_of_variable in LEFT_BRACKETS and right_of_variable in RIGHT_BRACKETS: + arr.pop(i - 1) + arr.pop(i) + # todo Add another loop to make sure that no 'single brackets' are found + + logger.debug("arr=%s", arr) + logger.debug("Finished removing all brackets around variables.") + return arr def add_brackets_around_unary_connectives(arr: list, variables: list) -> list: - """ - This adds brackets around unary connectives. - :param arr: - :param variables: Array of variables from statement. - :return: Returns an array with brackets around unary connectives. - """ - logger.debug("Adding brackets around unary connectives...") - - for i in range(len(arr)): - if arr[i] in UNARY_CONNECTIVES: # we have a unary connective - if arr[i+1] in variables: # unary connective is next to a variable - if arr[i-1] in LEFT_BRACKETS and arr[i+2] in RIGHT_BRACKETS: # there is brackets around it - # good case - continue - elif arr[i-1] in BINARY_CONNECTIVES or arr[i+2] in BINARY_CONNECTIVES: # there is no brackets around it - arr.insert(i, '(') - arr.insert(i+3, ')') - # todo Add a final check to makes sure that no unary connectives was missed. - - logger.debug("arr=%s", arr) - logger.debug("Finished adding brackets around all unary connectives.") - return arr + """ + This adds brackets around unary connectives. + :param arr: + :param variables: Array of variables from statement. + :return: Returns an array with brackets around unary connectives. + """ + logger.debug("Adding brackets around unary connectives...") + for i, _ in enumerate(arr): + # we have a unary connective and unary connective is next to a variable + if arr[i] in UNARY_CONNECTIVES and arr[i+1] in variables: + # there is brackets around it + if arr[i-1] in LEFT_BRACKETS and arr[i+2] in RIGHT_BRACKETS: + # good case + continue + if arr[i-1] in BINARY_CONNECTIVES or arr[i+2] in BINARY_CONNECTIVES: # there is no brackets around it + arr.insert(i, '(') + arr.insert(i+3, ')') + # todo Add a final check to makes sure that no unary connectives was missed. + + logger.debug("arr=%s", arr) + logger.debug("Finished adding brackets around all unary connectives.") + return arr diff --git a/engine/Components/Verifier.py b/engine/Components/Verifier.py index 93881f5..1594822 100644 --- a/engine/Components/Verifier.py +++ b/engine/Components/Verifier.py @@ -1,4 +1,6 @@ +"""_summary_ +""" # todo Check connectives # todo Suggest list of connectives -# todo From Sanitizer.py, check code and if not, return to user input or ErrorHandler.py +# todo From sanitizer.py, check code and if not, return to user input or ErrorHandler.py # todo If Verifier.py is valid, proceed diff --git a/engine/Components/__init__.py b/engine/Components/__init__.py index 8a1a818..f450b9d 100644 --- a/engine/Components/__init__.py +++ b/engine/Components/__init__.py @@ -1 +1,8 @@ +"""_summary_ +""" # EMPTY FILE - __init__.py +from .constants import LEFT_BRACKETS, RIGHT_BRACKETS, BINARY_CONNECTIVES, UNARY_CONNECTIVES +from .constants import TRUE, FALSE +from .constants import VALID_BRACKETS, VALID_CONNECTIVES +from .constants import WHITE_SPACES +from .constants import OPEN_ARROW, DASH, CLOSE_ARROW, COND_ELEM, BICOND_ELEM, PRE_CHECK diff --git a/engine/Components/create_conditionals.py b/engine/Components/create_conditionals.py index b5494b5..493c6a5 100644 --- a/engine/Components/create_conditionals.py +++ b/engine/Components/create_conditionals.py @@ -1,5 +1,7 @@ -""" -Insert +"""_summary_ + +Returns: + _type_: _description_ """ from components.constants import OPEN_ARROW, DASH, CLOSE_ARROW, COND_ELEM, BICOND_ELEM, PRE_CHECK from engine_logging.logging_config import logger diff --git a/engine/Components/create_elements.py b/engine/Components/create_elements.py index 7370841..fc3deb5 100644 --- a/engine/Components/create_elements.py +++ b/engine/Components/create_elements.py @@ -1,5 +1,7 @@ -""" -Insert +"""_summary_ + +Returns: + _type_: _description_ """ from engine_logging.logging_config import logger diff --git a/engine/Components/find_variables.py b/engine/Components/find_variables.py index bbdd48a..54a8ea3 100644 --- a/engine/Components/find_variables.py +++ b/engine/Components/find_variables.py @@ -1,5 +1,7 @@ -""" -Insert +"""_summary_ + +Returns: + _type_: _description_ """ from engine_logging import logger from components import VALID_BRACKETS, VALID_CONNECTIVES diff --git a/engine/Components/print_details.py b/engine/Components/print_details.py index 640ae23..963ffd2 100644 --- a/engine/Components/print_details.py +++ b/engine/Components/print_details.py @@ -1,5 +1,4 @@ -""" -Insert +"""_summary_ """ from engine_logging.logging_config import logger diff --git a/engine/Computation/SwitchConnectives.py b/engine/Computation/SwitchConnectives.py deleted file mode 100644 index 2ce4d19..0000000 --- a/engine/Computation/SwitchConnectives.py +++ /dev/null @@ -1,45 +0,0 @@ -from Computation.PropositionalRules import * -from Logging.logging_config import logger - - -def switch_case(case, temp_left, temp_right): - logger.debug("Entering switch_case(%s, %s, %s)...", case, temp_left, temp_right) - switch_dict = { - '^': conj, - 'v': disj, - '!': neg, - '->': cond, - '<->': bicond - } - return switch_dict.get(case, default_case)(temp_left, temp_right) - - -def conj(left, right): - logger.debug("In conj. case...") - return conjunction(left, right) - - -def disj(left, right): - logger.debug("In disj. case...") - return disjunction(left, right) - - -# todo Refactor neg() to remove 'right' parameter -def neg(left, right): - logger.debug("In neg. case...") - return negation(left) - - -def cond(left, right): - logger.debug("In cond. case...") - return conditional(left, right) - - -def bicond(left, right): - logger.debug("In bicond. case...") - return biconditional(left, right) - - -def default_case(): - logger.debug("In default case...") - return "Default case executed." diff --git a/engine/Computation/TableMatrix/CreateTableMatrix.py b/engine/Computation/TableMatrix/CreateTableMatrix.py index 925acbb..058c20e 100644 --- a/engine/Computation/TableMatrix/CreateTableMatrix.py +++ b/engine/Computation/TableMatrix/CreateTableMatrix.py @@ -1,5 +1,6 @@ +""" Insert """ from Computation.TableMatrix.RecursiveTable import recursive_table -from Logging.logging_config import logger +from engine_logging.logging_config import logger def create_matrix(num_of_var: int) -> list: diff --git a/engine/Computation/TableMatrix/DisplayMatrix.py b/engine/Computation/TableMatrix/DisplayMatrix.py index eca49a5..81d658a 100644 --- a/engine/Computation/TableMatrix/DisplayMatrix.py +++ b/engine/Computation/TableMatrix/DisplayMatrix.py @@ -1,4 +1,5 @@ -from Logging.logging_config import logger +""" Insert """ +from engine_logging.logging_config import logger def display_matrix(number_of_variables: int, returned_matrix: list, all_variables: list) -> None: diff --git a/engine/Computation/TableMatrix/RecursiveTable.py b/engine/Computation/TableMatrix/RecursiveTable.py index 3439fef..fc4e2e4 100644 --- a/engine/Computation/TableMatrix/RecursiveTable.py +++ b/engine/Computation/TableMatrix/RecursiveTable.py @@ -1,5 +1,6 @@ -from Components.Constants import TRUE, FALSE -from Logging.logging_config import logger +""" Insert """ +from components.constants import TRUE, FALSE +from engine_logging.logging_config import logger def recursive_table(n): diff --git a/engine/Computation/evaluate_statement.py b/engine/Computation/evaluate_statement.py index 4f6946f..a5edbe3 100644 --- a/engine/Computation/evaluate_statement.py +++ b/engine/Computation/evaluate_statement.py @@ -1,6 +1,11 @@ +"""_summary_ + +Returns: + _type_: _description_ +""" from math import log2 -from Computation.SwitchConnectives import switch_case +from Computation.switch_connectives import switch_case from Computation.TableMatrix.CreateTableMatrix import create_matrix from engine_logging.logging_config import logger diff --git a/engine/Computation/propositional_rules.py b/engine/Computation/propositional_rules.py index 463bc83..3fa3d78 100644 --- a/engine/Computation/propositional_rules.py +++ b/engine/Computation/propositional_rules.py @@ -1,5 +1,13 @@ -""" -Insert +"""_summary_ + +Raises: + UnequalArraysExcept: _description_ + UnequalArraysExcept: _description_ + UnequalArraysExcept: _description_ + UnequalArraysExcept: _description_ + +Returns: + _type_: _description_ """ # This file is to give the rules to calculate the propositional logic. from math import log2 diff --git a/engine/Computation/switch_connectives.py b/engine/Computation/switch_connectives.py new file mode 100644 index 0000000..913ee90 --- /dev/null +++ b/engine/Computation/switch_connectives.py @@ -0,0 +1,110 @@ +"""_summary_ + +Returns: + _type_: _description_ +""" +from Computation.propositional_rules import * +from engine_logging.logging_config import logger + + +def switch_case(case, temp_left, temp_right): + """_summary_ + + Args: + case (_type_): _description_ + temp_left (_type_): _description_ + temp_right (_type_): _description_ + + Returns: + _type_: _description_ + """ + logger.debug("Entering switch_case(%s, %s, %s)...", case, temp_left, temp_right) + switch_dict = { + '^': conj, + 'v': disj, + '!': neg, + '->': cond, + '<->': bicond + } + return switch_dict.get(case, default_case)(temp_left, temp_right) + + +def conj(left, right): + """_summary_ + + Args: + left (_type_): _description_ + right (_type_): _description_ + + Returns: + _type_: _description_ + """ + logger.debug("In conj. case...") + return conjunction(left, right) + + +def disj(left, right): + """_summary_ + + Args: + left (_type_): _description_ + right (_type_): _description_ + + Returns: + _type_: _description_ + """ + logger.debug("In disj. case...") + return disjunction(left, right) + + +# todo Refactor neg() to remove 'right' parameter +def neg(left, _): + """_summary_ + + Args: + left (_type_): _description_ + right (_type_): _description_ + + Returns: + _type_: _description_ + """ + logger.debug("In neg. case...") + return negation(left) + + +def cond(left, right): + """_summary_ + + Args: + left (_type_): _description_ + right (_type_): _description_ + + Returns: + _type_: _description_ + """ + logger.debug("In cond. case...") + return conditional(left, right) + + +def bicond(left, right): + """_summary_ + + Args: + left (_type_): _description_ + right (_type_): _description_ + + Returns: + _type_: _description_ + """ + logger.debug("In bicond. case...") + return biconditional(left, right) + + +def default_case(): + """_summary_ + + Returns: + _type_: _description_ + """ + logger.debug("In default case...") + return "Default case executed." diff --git a/engine/Logging/__init__.py b/engine/Logging/__init__.py deleted file mode 100644 index 8a1a818..0000000 --- a/engine/Logging/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# EMPTY FILE - __init__.py diff --git a/engine/Main.py b/engine/Main.py index 12eedf2..3c813c7 100644 --- a/engine/Main.py +++ b/engine/Main.py @@ -1,5 +1,6 @@ -from Logging.logging_config import logger -from Simulator.SimulateMain import simulate_main +""" Insert """ +from engine_logging import logger +from Simulator.simulate_main import simulate_main logger.info("Starting Engine...") diff --git a/engine/Parser/Checks/CheckBrackets.py b/engine/Parser/Checks/CheckBrackets.py index 5042616..8b53024 100644 --- a/engine/Parser/Checks/CheckBrackets.py +++ b/engine/Parser/Checks/CheckBrackets.py @@ -1,34 +1,34 @@ -from Components.Constants import LEFT_BRACKETS, RIGHT_BRACKETS -from Logging.logging_config import logger +""" Insert """ +from components.constants import LEFT_BRACKETS, RIGHT_BRACKETS +from engine_logging.logging_config import logger class UnequalBracketsExcept(Exception): - pass + pass def check_left_and_right_brackets(statement): - """ - This function checks if the number of opening and closing brackets are equal. - :param statement: the given string statement - :return: Returns a True if the left and right brackets are equal - """ - logger.debug("Calling check_left_and_right_brackets(%s)...", statement) - - count = 0 - for i in range(len(statement)): - if statement[i] in LEFT_BRACKETS: - count += 1 - elif statement[i] in RIGHT_BRACKETS: - count -= 1 - - if count == 0: - logger.info("PASS: The number of left and right brackets are equal.") - return True - - logger.exception("FAIL: Unequal number of left and right brackets. " - "Please check: count=%d", count) - raise UnequalBracketsExcept("Input statement must have an equal number " - "of opening and closing brackets") + """ + This function checks if the number of opening and closing brackets are equal. + :param statement: the given string statement + :return: Returns a True if the left and right brackets are equal + """ + logger.debug("Calling check_left_and_right_brackets(%s)...", statement) + + count = 0 + for i in range(len(statement)): + if statement[i] in LEFT_BRACKETS: + count += 1 + elif statement[i] in RIGHT_BRACKETS: + count -= 1 + + if count == 0: + logger.info("PASS: The number of left and right brackets are equal.") + return True + logger.exception("FAIL: Unequal number of left and right brackets. " + "Please check: count=%d", count) + raise UnequalBracketsExcept("Input statement must have an equal number " + "of opening and closing brackets") # todo Add to Unit Test # check_brackets tests diff --git a/engine/Parser/Checks/CheckForIllegalCharacters.py b/engine/Parser/Checks/CheckForIllegalCharacters.py index f082e98..b34a580 100644 --- a/engine/Parser/Checks/CheckForIllegalCharacters.py +++ b/engine/Parser/Checks/CheckForIllegalCharacters.py @@ -1,6 +1,6 @@ -from Components.RegularExpression import validate_input -from Components.Constants import * -from Logging.logging_config import logger +from components.regular_expression import validate_input +from components.constants import * +from engine_logging.logging_config import logger class IllegalCharactersException(Exception): diff --git a/engine/Parser/Parse/AnalyzeFunction.py b/engine/Parser/Parse/AnalyzeFunction.py index 4e0102e..95bf279 100644 --- a/engine/Parser/Parse/AnalyzeFunction.py +++ b/engine/Parser/Parse/AnalyzeFunction.py @@ -1,9 +1,14 @@ -from Components.CreateConditionals import create_conditionals -from Components.CreateElements import create_array_of_elements -from Components.FindVariables import find_variables -from Components.Sanitizer import clean_whitespaces -from Logging.logging_config import logger -from Components.PrintDetails import print_details +"""_summary_ + +Returns: + _type_: _description_ +""" +import components.create_conditionals +from components.create_elements import create_array_of_elements +from components.find_variables import find_variables +from components.sanitizer import clean_whitespaces +from components.print_details import print_details +from engine_logging.logging_config import logger def analyze_statement(statement: str) -> [int, list, list]: @@ -31,9 +36,10 @@ def analyze_statement(statement: str) -> [int, list, list]: logger.info("The statement is converted to an array and any conditionals " "are sanitized.") array_of_elements: list = create_array_of_elements(statement) - array_of_elements = create_conditionals(array_of_elements) + array_of_elements = components.create_conditionals.create_conditionals(array_of_elements) - logger.debug("In analyze_statement(): \nlen(variables_arr)=%d, \nvariables_arr=%s, \narray_of_elements=%s", + logger.debug("In analyze_statement(): \nlen(variables_arr)=%d, " + "\nvariables_arr=%s, \narray_of_elements=%s", len(variables_arr), variables_arr, array_of_elements) print_details("ANALYSIS", ("Number of Variables", len(variables_arr)), diff --git a/engine/Parser/Parse/ParseFunction.py b/engine/Parser/Parse/ParseFunction.py index 16d3e23..e039e6b 100644 --- a/engine/Parser/Parse/ParseFunction.py +++ b/engine/Parser/Parse/ParseFunction.py @@ -1,9 +1,9 @@ -from Components.Constants import * -from Components.Sanitizer import add_brackets_around_unary_connectives -from Components.Sanitizer import remove_brackets_around_variables -from Logging.logging_config import logger +from components.constants import * +from components.sanitizer import add_brackets_around_unary_connectives +from components.sanitizer import remove_brackets_around_variables +from engine_logging.logging_config import logger from Parser.Checks.CheckBrackets import check_left_and_right_brackets -from Components.PrintDetails import print_details +from components.print_details import print_details def parse_array(elements: list, variables: list) -> list: diff --git a/engine/Simulator/UserInput.py b/engine/Simulator/UserInput.py index 2d03fea..ea19223 100644 --- a/engine/Simulator/UserInput.py +++ b/engine/Simulator/UserInput.py @@ -1,4 +1,9 @@ -from Logging.logging_config import logger +"""_summary_ + +Returns: + _type_: _description_ +""" +from engine_logging.logging_config import logger from Parser.Parse.AnalyzeFunction import analyze_statement from Parser.Parse.ParseFunction import parse_array diff --git a/engine/Simulator/input_statements.py b/engine/Simulator/input_statements.py index e88c4dd..c55173c 100644 --- a/engine/Simulator/input_statements.py +++ b/engine/Simulator/input_statements.py @@ -1,4 +1,4 @@ -# Test cases that is used in SimulateMain.py +# Test cases that is used in simulate_main.py test_cases = [ # "(P <-> (P <-> (P <-> (P <-> P))))", # "(P ^ Q)", # valid diff --git a/engine/engine_logging/__init__.py b/engine/engine_logging/__init__.py new file mode 100644 index 0000000..ad95c75 --- /dev/null +++ b/engine/engine_logging/__init__.py @@ -0,0 +1,5 @@ +""" +Insert +""" +# EMPTY FILE - __init__.py +from .logging_config import logger diff --git a/engine/Logging/logging_config.py b/engine/engine_logging/logging_config.py similarity index 74% rename from engine/Logging/logging_config.py rename to engine/engine_logging/logging_config.py index 0d7c1b6..422f701 100644 --- a/engine/Logging/logging_config.py +++ b/engine/engine_logging/logging_config.py @@ -1,3 +1,5 @@ +""" Insert +""" import logging import os @@ -12,15 +14,15 @@ os.makedirs(log_folder) if os.path.exists(log_file): - for i in range(MAX_LOG_FILES - 1, 0, -1): # starts from 9 moving down to 0 - current_file = f'{log_file}.{i}' - next_file = f'{log_file}.{i + 1}' - - if os.path.exists(current_file): - if os.path.exists(log_file + '.' + str(MAX_LOG_FILES)): - os.remove(log_file + '.' + str(MAX_LOG_FILES)) # this will be next_file - os.rename(current_file, next_file) - os.rename(log_file, f'{log_file}.1') + for i in range(MAX_LOG_FILES - 1, 0, -1): # starts from 9 moving down to 0 + current_file = f'{log_file}.{i}' + next_file = f'{log_file}.{i + 1}' + + if os.path.exists(current_file): + if os.path.exists(log_file + '.' + str(MAX_LOG_FILES)): + os.remove(log_file + '.' + str(MAX_LOG_FILES)) # this will be next_file + os.rename(current_file, next_file) + os.rename(log_file, f'{log_file}.1') # Configure the logger From 8131c368d16c008754b619b437fa91194b83be4d Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Tue, 10 Oct 2023 16:18:35 +0200 Subject: [PATCH 08/29] Fixed linting issues. --- frontend/lib/main.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/lib/main.dart b/frontend/lib/main.dart index 008fa38..6595048 100644 --- a/frontend/lib/main.dart +++ b/frontend/lib/main.dart @@ -30,7 +30,7 @@ class MyApp extends StatelessWidget { } class MyHomePage extends StatefulWidget { - const MyHomePage({super.key, required this.title}); + const MyHomePage({required this.title, super.key}); // This widget is the home page of your application. It is stateful, meaning // that it has a State object (defined below) that contains fields that affect From fd2e42e40db632494c7160839dbc1cef897fb7bd Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Wed, 11 Oct 2023 10:44:58 +0200 Subject: [PATCH 09/29] Renamed files to snake_case --- .../TableMatrix => computation}/__init__.py | 0 .../evaluate_statement.py | 0 .../propositional_rules.py | 0 .../switch_connectives.py | 0 .../table_matrix}/__init__.py | 0 .../table_matrix/create_table_matrix.py} | 0 .../table_matrix/display_matrix.py} | 0 .../table_matrix/recursive_table.py} | 0 .../{Examples => examples}/[debug]engine.log | 0 .../{Examples => examples}/[info]engine.log | 0 engine/examples/keep_these/engine.log.1 | 44 + engine/examples/keep_these/engine.log.2 | 20 + engine/examples/keep_these/engine.log.3 | 1203 +++++++++++++++++ engine/examples/keep_these/engine.log.4 | 1203 +++++++++++++++++ engine/{Main.py => main.py} | 0 engine/{Parser => parser}/README.md | 0 .../TreeLikeStructure.drawio | 0 .../{Parser => parser}/TreeLikeStructure.png | Bin engine/{Parser/Checks => parser}/__init__.py | 0 .../Parse => parser/checks}/__init__.py | 0 .../checks/check_brackets.py} | 0 .../checks/check_for_illegal_characters.py} | 0 .../Validate => parser/parse}/__init__.py | 0 .../parse/analyze_function.py} | 0 .../parse/parse_function.py} | 0 .../Validate => parser/validate}/README.md | 0 .../{Parser => parser/validate}/__init__.py | 0 engine/{Simulator => simulator}/__init__.py | 0 .../input_statements.py | 0 .../{Simulator => simulator}/simulate_main.py | 0 .../simulate_server.py} | 0 .../UserInput.py => simulator/user_input.py} | 0 32 files changed, 2470 insertions(+) rename engine/{Computation/TableMatrix => computation}/__init__.py (100%) rename engine/{Computation => computation}/evaluate_statement.py (100%) rename engine/{Computation => computation}/propositional_rules.py (100%) rename engine/{Computation => computation}/switch_connectives.py (100%) rename engine/{Computation => computation/table_matrix}/__init__.py (100%) rename engine/{Computation/TableMatrix/CreateTableMatrix.py => computation/table_matrix/create_table_matrix.py} (100%) rename engine/{Computation/TableMatrix/DisplayMatrix.py => computation/table_matrix/display_matrix.py} (100%) rename engine/{Computation/TableMatrix/RecursiveTable.py => computation/table_matrix/recursive_table.py} (100%) rename engine/{Examples => examples}/[debug]engine.log (100%) rename engine/{Examples => examples}/[info]engine.log (100%) create mode 100644 engine/examples/keep_these/engine.log.1 create mode 100644 engine/examples/keep_these/engine.log.2 create mode 100644 engine/examples/keep_these/engine.log.3 create mode 100644 engine/examples/keep_these/engine.log.4 rename engine/{Main.py => main.py} (100%) rename engine/{Parser => parser}/README.md (100%) rename engine/{Parser => parser}/TreeLikeStructure.drawio (100%) rename engine/{Parser => parser}/TreeLikeStructure.png (100%) rename engine/{Parser/Checks => parser}/__init__.py (100%) rename engine/{Parser/Parse => parser/checks}/__init__.py (100%) rename engine/{Parser/Checks/CheckBrackets.py => parser/checks/check_brackets.py} (100%) rename engine/{Parser/Checks/CheckForIllegalCharacters.py => parser/checks/check_for_illegal_characters.py} (100%) rename engine/{Parser/Validate => parser/parse}/__init__.py (100%) rename engine/{Parser/Parse/AnalyzeFunction.py => parser/parse/analyze_function.py} (100%) rename engine/{Parser/Parse/ParseFunction.py => parser/parse/parse_function.py} (100%) rename engine/{Parser/Validate => parser/validate}/README.md (100%) rename engine/{Parser => parser/validate}/__init__.py (100%) rename engine/{Simulator => simulator}/__init__.py (100%) rename engine/{Simulator => simulator}/input_statements.py (100%) rename engine/{Simulator => simulator}/simulate_main.py (100%) rename engine/{Simulator/SimulateServer.py => simulator/simulate_server.py} (100%) rename engine/{Simulator/UserInput.py => simulator/user_input.py} (100%) diff --git a/engine/Computation/TableMatrix/__init__.py b/engine/computation/__init__.py similarity index 100% rename from engine/Computation/TableMatrix/__init__.py rename to engine/computation/__init__.py diff --git a/engine/Computation/evaluate_statement.py b/engine/computation/evaluate_statement.py similarity index 100% rename from engine/Computation/evaluate_statement.py rename to engine/computation/evaluate_statement.py diff --git a/engine/Computation/propositional_rules.py b/engine/computation/propositional_rules.py similarity index 100% rename from engine/Computation/propositional_rules.py rename to engine/computation/propositional_rules.py diff --git a/engine/Computation/switch_connectives.py b/engine/computation/switch_connectives.py similarity index 100% rename from engine/Computation/switch_connectives.py rename to engine/computation/switch_connectives.py diff --git a/engine/Computation/__init__.py b/engine/computation/table_matrix/__init__.py similarity index 100% rename from engine/Computation/__init__.py rename to engine/computation/table_matrix/__init__.py diff --git a/engine/Computation/TableMatrix/CreateTableMatrix.py b/engine/computation/table_matrix/create_table_matrix.py similarity index 100% rename from engine/Computation/TableMatrix/CreateTableMatrix.py rename to engine/computation/table_matrix/create_table_matrix.py diff --git a/engine/Computation/TableMatrix/DisplayMatrix.py b/engine/computation/table_matrix/display_matrix.py similarity index 100% rename from engine/Computation/TableMatrix/DisplayMatrix.py rename to engine/computation/table_matrix/display_matrix.py diff --git a/engine/Computation/TableMatrix/RecursiveTable.py b/engine/computation/table_matrix/recursive_table.py similarity index 100% rename from engine/Computation/TableMatrix/RecursiveTable.py rename to engine/computation/table_matrix/recursive_table.py diff --git a/engine/Examples/[debug]engine.log b/engine/examples/[debug]engine.log similarity index 100% rename from engine/Examples/[debug]engine.log rename to engine/examples/[debug]engine.log diff --git a/engine/Examples/[info]engine.log b/engine/examples/[info]engine.log similarity index 100% rename from engine/Examples/[info]engine.log rename to engine/examples/[info]engine.log diff --git a/engine/examples/keep_these/engine.log.1 b/engine/examples/keep_these/engine.log.1 new file mode 100644 index 0000000..e0d8ba4 --- /dev/null +++ b/engine/examples/keep_these/engine.log.1 @@ -0,0 +1,44 @@ +2023-10-10 15:22:17,211 - INFO - - Starting Engine... +2023-10-10 15:22:17,211 - INFO - simulate_main - Statement: (T v (P ^ Q)) +2023-10-10 15:22:17,211 - INFO - simulate_main - Before proceeding, doing checks for unequal brackets and illegal characters. +2023-10-10 15:22:17,211 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-10-10 15:22:17,211 - INFO - check_for_illegal_characters - PASS: There were no illegal characters found. +2023-10-10 15:22:17,211 - INFO - simulate_main - All checks are valid, proceeding with extracting information from statement. +2023-10-10 15:22:17,211 - INFO - user_input - Processing statement... +2023-10-10 15:22:17,211 - INFO - analyze_statement - Starting to analyze statement... +2023-10-10 15:22:17,211 - INFO - analyze_statement - The statement is sanitized from any whitespaces. +2023-10-10 15:22:17,211 - INFO - find_variables - Finding variables in statement... +2023-10-10 15:22:17,211 - INFO - find_variables - Found all variables in statement. +2023-10-10 15:22:17,211 - INFO - find_variables - *** Variables: ['T', 'P', 'Q'] *** +2023-10-10 15:22:17,211 - INFO - analyze_statement - The statement is converted to an array and any conditionals are sanitized. +2023-10-10 15:22:17,211 - INFO - print_details - ************************** ANALYSIS ************************** +2023-10-10 15:22:17,211 - INFO - print_details - -> Number of Variables: 3 +2023-10-10 15:22:17,211 - INFO - print_details - -> Variables: ['T', 'P', 'Q'] +2023-10-10 15:22:17,212 - INFO - print_details - -> Array of Elements: ['(', 'T', 'v', '(', 'P', '^', 'Q', ')', ')'] +2023-10-10 15:22:17,212 - INFO - print_details - ************************** ANALYSIS ************************** +2023-10-10 15:22:17,212 - INFO - analyze_statement - Analyzing concluded. +2023-10-10 15:22:17,212 - INFO - parse_array - Starting to parse array... +2023-10-10 15:22:17,212 - INFO - parse_array - Final checks are ran before parsing concludes. +2023-10-10 15:22:17,212 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-10-10 15:22:17,212 - INFO - print_details - *************************** PARSE *************************** +2023-10-10 15:22:17,212 - INFO - print_details - -> Parsed Array: [['T'], 'v', [['P'], '^', ['Q']]] +2023-10-10 15:22:17,212 - INFO - print_details - *************************** PARSE *************************** +2023-10-10 15:22:17,212 - INFO - parse_array - Finished parsing array. +2023-10-10 15:22:17,213 - INFO - user_input - Gathered all information needed including variables and parsed array. +2023-10-10 15:22:17,213 - INFO - print_details - ************************** SUMMARY ************************** +2023-10-10 15:22:17,213 - INFO - print_details - -> number_of_variables: 3 +2023-10-10 15:22:17,213 - INFO - print_details - -> variables_as_array: ['T', 'P', 'Q'] +2023-10-10 15:22:17,213 - INFO - print_details - -> provided_statement: (T v (P ^ Q)) +2023-10-10 15:22:17,213 - INFO - print_details - -> elements_in_tree: [['T'], 'v', [['P'], '^', ['Q']]] +2023-10-10 15:22:17,213 - INFO - print_details - ************************** SUMMARY ************************** +2023-10-10 15:22:17,213 - INFO - evaluate_array_as_tree - Starting evaluation of array of elements... +2023-10-10 15:22:17,213 - INFO - create_matrix - Finished creating the initial 'truth' matrix. +2023-10-10 15:22:17,213 - INFO - create_matrix - *** Initial Matrix: [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']] *** +2023-10-10 15:22:17,213 - INFO - print_details - ************************** EVALUATE ************************** +2023-10-10 15:22:17,213 - INFO - print_details - -> Statement: (T v (P ^ Q)) +2023-10-10 15:22:17,213 - INFO - print_details - -> Final Calculated Array: ['T', 'T', 'T', 'T', 'T', 'F', 'F', 'F'] +2023-10-10 15:22:17,213 - INFO - print_details - -> All Variables: ['T', 'P', 'Q', 'P^Q', 'Tv(P^Q)'] +2023-10-10 15:22:17,213 - INFO - print_details - -> Final Matrix: [['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'T'], ['T', 'F', 'T', 'F', 'T'], ['T', 'F', 'F', 'F', 'T'], ['F', 'T', 'T', 'T', 'T'], ['F', 'T', 'F', 'F', 'F'], ['F', 'F', 'T', 'F', 'F'], ['F', 'F', 'F', 'F', 'F']] +2023-10-10 15:22:17,213 - INFO - print_details - ************************** EVALUATE ************************** +2023-10-10 15:22:17,213 - INFO - simulate_main - Finished evaluating statement. +2023-10-10 15:22:17,214 - INFO - - Exiting Engine... diff --git a/engine/examples/keep_these/engine.log.2 b/engine/examples/keep_these/engine.log.2 new file mode 100644 index 0000000..839c50c --- /dev/null +++ b/engine/examples/keep_these/engine.log.2 @@ -0,0 +1,20 @@ +2023-10-10 15:20:31,934 - INFO - - Starting Engine... +2023-10-10 15:20:31,934 - INFO - simulate_main - Statement: (T v (P ^ Q)) +2023-10-10 15:20:31,935 - INFO - simulate_main - Before proceeding, doing checks for unequal brackets and illegal characters. +2023-10-10 15:20:31,935 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-10-10 15:20:31,935 - INFO - check_for_illegal_characters - PASS: There were no illegal characters found. +2023-10-10 15:20:31,935 - INFO - simulate_main - All checks are valid, proceeding with extracting information from statement. +2023-10-10 15:20:31,935 - INFO - user_input - Processing statement... +2023-10-10 15:20:31,935 - INFO - analyze_statement - Starting to analyze statement... +2023-10-10 15:20:31,935 - INFO - analyze_statement - The statement is sanitized from any whitespaces. +2023-10-10 15:20:31,935 - INFO - find_variables - Finding variables in statement... +2023-10-10 15:20:31,935 - INFO - find_variables - Found all variables in statement. +2023-10-10 15:20:31,936 - INFO - find_variables - *** Variables: ['T', 'P', 'Q'] *** +2023-10-10 15:20:31,936 - INFO - analyze_statement - The statement is converted to an array and any conditionals are sanitized. +2023-10-10 15:20:31,936 - INFO - print_details - ************************** ANALYSIS ************************** +2023-10-10 15:20:31,936 - INFO - print_details - -> Number of Variables: 3 +2023-10-10 15:20:31,936 - INFO - print_details - -> Variables: ['T', 'P', 'Q'] +2023-10-10 15:20:31,936 - INFO - print_details - -> Array of Elements: ['(', 'T', 'v', '(', 'P', '^', 'Q', ')', ')'] +2023-10-10 15:20:31,936 - INFO - print_details - ************************** ANALYSIS ************************** +2023-10-10 15:20:31,936 - INFO - analyze_statement - Analyzing concluded. +2023-10-10 15:20:31,936 - INFO - parse_array - Starting to parse array... diff --git a/engine/examples/keep_these/engine.log.3 b/engine/examples/keep_these/engine.log.3 new file mode 100644 index 0000000..2011eaa --- /dev/null +++ b/engine/examples/keep_these/engine.log.3 @@ -0,0 +1,1203 @@ +2023-10-10 00:25:30,256 - INFO - - Starting Engine... +2023-10-10 00:25:30,257 - DEBUG - simulate_main - Calling simulate_main()... +2023-10-10 00:25:30,257 - INFO - simulate_main - Statement: (T v (P -> Q)) +2023-10-10 00:25:30,257 - INFO - simulate_main - Before proceeding, doing checks for unequal brackets and illegal characters. +2023-10-10 00:25:30,257 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets((T v (P -> Q)))... +2023-10-10 00:25:30,257 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-10-10 00:25:30,257 - DEBUG - check_for_illegal_characters - Calling check_for_illegal_characters((T v (P -> Q))) +2023-10-10 00:25:30,258 - DEBUG - check_for_illegal_characters - ******************** starting input validation ******************* +2023-10-10 00:25:30,258 - DEBUG - validate_input - Calling validate_input(T)... +2023-10-10 00:25:30,258 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,258 - DEBUG - validate_input - Calling validate_input(v)... +2023-10-10 00:25:30,258 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,258 - DEBUG - validate_input - Calling validate_input(P)... +2023-10-10 00:25:30,258 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,259 - DEBUG - validate_input - Calling validate_input(-)... +2023-10-10 00:25:30,259 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,259 - DEBUG - validate_input - Calling validate_input(>)... +2023-10-10 00:25:30,259 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,259 - DEBUG - validate_input - Calling validate_input(Q)... +2023-10-10 00:25:30,259 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,259 - DEBUG - check_for_illegal_characters - ******************** finished input validation ******************* +2023-10-10 00:25:30,259 - INFO - check_for_illegal_characters - PASS: There were no illegal characters found. +2023-10-10 00:25:30,259 - INFO - simulate_main - All checks are valid, proceeding with extracting information from statement. +2023-10-10 00:25:30,259 - INFO - user_input - Processing statement... +2023-10-10 00:25:30,259 - DEBUG - user_input - statement=(T v (P -> Q)) +2023-10-10 00:25:30,260 - INFO - analyze_statement - Starting to analyze statement... +2023-10-10 00:25:30,260 - INFO - analyze_statement - The statement is sanitized from any whitespaces. +2023-10-10 00:25:30,260 - DEBUG - analyze_statement - All whitespaces need to be removed, proceeding. +2023-10-10 00:25:30,260 - DEBUG - clean_whitespaces - Calling clean_whitespaces((T v (P -> Q)))... +2023-10-10 00:25:30,260 - DEBUG - clean_whitespaces - Finished removing whitespaces: statement=(Tv(P->Q)) +2023-10-10 00:25:30,260 - DEBUG - analyze_statement - Finished removing any whitespaces found in statement. Proceeding with finding variables. +2023-10-10 00:25:30,260 - INFO - find_variables - Finding variables in statement... +2023-10-10 00:25:30,261 - DEBUG - find_variables - statement=(Tv(P->Q)) +2023-10-10 00:25:30,261 - DEBUG - find_variables - variables_array=['T', 'P', 'Q'] +2023-10-10 00:25:30,261 - INFO - find_variables - Found all variables in statement. +2023-10-10 00:25:30,261 - INFO - find_variables - *** Variables: ['T', 'P', 'Q'] *** +2023-10-10 00:25:30,261 - DEBUG - analyze_statement - variables_arr=['T', 'P', 'Q'] +2023-10-10 00:25:30,261 - INFO - analyze_statement - The statement is converted to an array and any conditionals are sanitized. +2023-10-10 00:25:30,261 - DEBUG - create_array_of_elements - Creating an array from a string... +2023-10-10 00:25:30,261 - DEBUG - create_array_of_elements - Calling create_array_of_elements((Tv(P->Q))) +2023-10-10 00:25:30,262 - DEBUG - create_array_of_elements - array_of_elements=['(', 'T', 'v', '(', 'P', '-', '>', 'Q', ')', ')'] +2023-10-10 00:25:30,262 - DEBUG - create_array_of_elements - Finished creating array. +2023-10-10 00:25:30,262 - DEBUG - check_conditionals - Calling check_conditionals(['(', 'T', 'v', '(', 'P', '-', '>', 'Q', ')', ')'], ['T', 'P', 'Q'])... +2023-10-10 00:25:30,262 - INFO - check_conditionals - PASS: Any conditional symbols present, are in the desired form. +2023-10-10 00:25:30,262 - DEBUG - create_conditionals - Creating one-piece conditionals from single elements. +2023-10-10 00:25:30,262 - DEBUG - create_conditionals - Searching for a '-' in array_of_elements=['(', 'T', 'v', '(', 'P', '-', '>', 'Q', ')', ')'] +2023-10-10 00:25:30,263 - DEBUG - create_conditionals - Conditional symbols were found in ['(', 'T', 'v', '(', 'P', '-', '>', 'Q', ')', ')'] +2023-10-10 00:25:30,263 - DEBUG - create_conditionals - array_of_elements=['(', 'T', 'v', '(', 'P', '->', 'Q', ')', ')'] +2023-10-10 00:25:30,263 - DEBUG - create_conditionals - Finished creating conditionals. +2023-10-10 00:25:30,263 - DEBUG - analyze_statement - In analyze_statement(): +len(variables_arr)=3, +variables_arr=['T', 'P', 'Q'], +array_of_elements=['(', 'T', 'v', '(', 'P', '->', 'Q', ')', ')'] +2023-10-10 00:25:30,263 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,264 - INFO - print_details - ************************** ANALYSIS ************************** +2023-10-10 00:25:30,264 - INFO - print_details - -> Number of Variables: 3 +2023-10-10 00:25:30,264 - INFO - print_details - -> Variables: ['T', 'P', 'Q'] +2023-10-10 00:25:30,264 - INFO - print_details - -> Array of Elements: ['(', 'T', 'v', '(', 'P', '->', 'Q', ')', ')'] +2023-10-10 00:25:30,264 - INFO - print_details - ************************** ANALYSIS ************************** +2023-10-10 00:25:30,264 - INFO - analyze_statement - Analyzing concluded. +2023-10-10 00:25:30,265 - INFO - parse_array - Starting to parse array... +2023-10-10 00:25:30,265 - DEBUG - remove_brackets_around_variables - Removing brackets around standalone variables... +2023-10-10 00:25:30,265 - DEBUG - remove_brackets_around_variables - arr=['(', 'T', 'v', '(', 'P', '->', 'Q', ')', ')'] +2023-10-10 00:25:30,265 - DEBUG - remove_brackets_around_variables - Finished removing all brackets around variables. +2023-10-10 00:25:30,265 - DEBUG - parse_array - In parse_array(): elements_second=['(', 'T', 'v', '(', 'P', '->', 'Q', ')', ')'] +2023-10-10 00:25:30,265 - DEBUG - add_brackets_around_unary_connectives - Adding brackets around unary connectives... +2023-10-10 00:25:30,265 - DEBUG - add_brackets_around_unary_connectives - arr=['(', 'T', 'v', '(', 'P', '->', 'Q', ')', ')'] +2023-10-10 00:25:30,266 - DEBUG - add_brackets_around_unary_connectives - Finished adding brackets around all unary connectives. +2023-10-10 00:25:30,266 - DEBUG - parse_array - In parse_array(): elements_second=['(', 'T', 'v', '(', 'P', '->', 'Q', ')', ')'] +2023-10-10 00:25:30,266 - INFO - parse_array - Final checks are ran before parsing concludes. +2023-10-10 00:25:30,266 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets(['(', 'T', 'v', '(', 'P', '->', 'Q', ')', ')'])... +2023-10-10 00:25:30,266 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-10-10 00:25:30,266 - DEBUG - parse - Calling parse(['(', 'T', 'v', '(', 'P', '->', 'Q', ')', ')'])... +2023-10-10 00:25:30,266 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', 'T', 'v', '(', 'P', '->', 'Q', ')', ')'])... +2023-10-10 00:25:30,266 - DEBUG - remove_outer_brackets - array=['T', 'v', '(', 'P', '->', 'Q', ')'] +2023-10-10 00:25:30,267 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-10-10 00:25:30,267 - DEBUG - parse - In parse(): arr=['T', 'v', '(', 'P', '->', 'Q', ')'] +2023-10-10 00:25:30,267 - DEBUG - find_connective - Calling find_connectives(['T', 'v', '(', 'P', '->', 'Q', ')'])... +2023-10-10 00:25:30,267 - DEBUG - find_connective - In find_connective(): elem=v, i=1 +2023-10-10 00:25:30,267 - DEBUG - find_connective - Found connective. +2023-10-10 00:25:30,267 - DEBUG - parse - Calling parse(['(', 'P', '->', 'Q', ')'])... +2023-10-10 00:25:30,268 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', 'P', '->', 'Q', ')'])... +2023-10-10 00:25:30,268 - DEBUG - remove_outer_brackets - array=['P', '->', 'Q'] +2023-10-10 00:25:30,268 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-10-10 00:25:30,268 - DEBUG - parse - In parse(): arr=['P', '->', 'Q'] +2023-10-10 00:25:30,268 - DEBUG - find_connective - Calling find_connectives(['P', '->', 'Q'])... +2023-10-10 00:25:30,268 - DEBUG - find_connective - In find_connective(): elem=->, i=1 +2023-10-10 00:25:30,268 - DEBUG - find_connective - Found connective. +2023-10-10 00:25:30,269 - DEBUG - parse - temp_array=[['P'], '->', ['Q']] +2023-10-10 00:25:30,269 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-10-10 00:25:30,269 - DEBUG - parse - temp_array=[['T'], 'v', [['P'], '->', ['Q']]] +2023-10-10 00:25:30,269 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-10-10 00:25:30,269 - DEBUG - parse_array - tree_structured_array=[['T'], 'v', [['P'], '->', ['Q']]] +2023-10-10 00:25:30,269 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,269 - INFO - print_details - *************************** PARSE *************************** +2023-10-10 00:25:30,270 - INFO - print_details - -> Parsed Array: [['T'], 'v', [['P'], '->', ['Q']]] +2023-10-10 00:25:30,270 - INFO - print_details - *************************** PARSE *************************** +2023-10-10 00:25:30,270 - INFO - parse_array - Finished parsing array. +2023-10-10 00:25:30,270 - DEBUG - user_input - In user_input(): +number_of_variables=3, +variables_as_array=['T', 'P', 'Q'], +statement=(T v (P -> Q)), +new_elements=[['T'], 'v', [['P'], '->', ['Q']]]. +2023-10-10 00:25:30,270 - INFO - user_input - Gathered all information needed including variables and parsed array. +2023-10-10 00:25:30,271 - DEBUG - simulate_main - In simulate_main(): +number_of_variables=3, +variables_as_array=['T', 'P', 'Q'], +provided_statement=(T v (P -> Q)), +elements_in_tree=[['T'], 'v', [['P'], '->', ['Q']]] +2023-10-10 00:25:30,271 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,271 - INFO - print_details - ************************** SUMMARY ************************** +2023-10-10 00:25:30,271 - INFO - print_details - -> number_of_variables: 3 +2023-10-10 00:25:30,271 - INFO - print_details - -> variables_as_array: ['T', 'P', 'Q'] +2023-10-10 00:25:30,271 - INFO - print_details - -> provided_statement: (T v (P -> Q)) +2023-10-10 00:25:30,272 - INFO - print_details - -> elements_in_tree: [['T'], 'v', [['P'], '->', ['Q']]] +2023-10-10 00:25:30,272 - INFO - print_details - ************************** SUMMARY ************************** +2023-10-10 00:25:30,272 - INFO - evaluate_array_as_tree - Starting evaluation of array of elements... +2023-10-10 00:25:30,272 - DEBUG - create_matrix - Creating initial matrix... +2023-10-10 00:25:30,272 - DEBUG - recursive_table - Creating table entries recursively... +2023-10-10 00:25:30,272 - DEBUG - recursive_table - n=3 +2023-10-10 00:25:30,272 - DEBUG - recursive_table - Creating table entries recursively... +2023-10-10 00:25:30,273 - DEBUG - recursive_table - n=2 +2023-10-10 00:25:30,273 - DEBUG - recursive_table - Creating table entries recursively... +2023-10-10 00:25:30,273 - DEBUG - recursive_table - n=1 +2023-10-10 00:25:30,273 - DEBUG - recursive_table - array_table=['T', 'F'] +2023-10-10 00:25:30,273 - DEBUG - recursive_table - Finished creating array of table entries. +2023-10-10 00:25:30,273 - DEBUG - recursive_table - array_table=['TT', 'TF', 'FT', 'FF'] +2023-10-10 00:25:30,273 - DEBUG - recursive_table - Finished creating array of table entries. +2023-10-10 00:25:30,273 - DEBUG - recursive_table - array_table=['TTT', 'TTF', 'TFT', 'TFF', 'FTT', 'FTF', 'FFT', 'FFF'] +2023-10-10 00:25:30,274 - DEBUG - recursive_table - Finished creating array of table entries. +2023-10-10 00:25:30,274 - DEBUG - create_matrix - In create_matrix(): new_matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']] +2023-10-10 00:25:30,274 - INFO - create_matrix - Finished creating the initial 'truth' matrix. +2023-10-10 00:25:30,274 - INFO - create_matrix - *** Initial Matrix: [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']] *** +2023-10-10 00:25:30,274 - DEBUG - evaluate_array_as_tree - In evaluate_array_as_tree(): +elements_in_tree=[['T'], 'v', [['P'], '->', ['Q']]], +counter=0, +matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], +variables_as_array=['T', 'P', 'Q'] +2023-10-10 00:25:30,275 - DEBUG - evaluate_array - Calling evaluate_array([['T'], 'v', [['P'], '->', ['Q']]], 0, [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['T', 'P', 'Q'])... +2023-10-10 00:25:30,275 - DEBUG - evaluate_array - Calling evaluate_array([['P'], '->', ['Q']], 1, [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['T', 'P', 'Q'])... +2023-10-10 00:25:30,275 - DEBUG - switch_case - Entering switch_case(->, ['T', 'T', 'F', 'F', 'T', 'T', 'F', 'F'], ['T', 'F', 'T', 'F', 'T', 'F', 'T', 'F'])... +2023-10-10 00:25:30,275 - DEBUG - cond - In cond. case... +2023-10-10 00:25:30,276 - DEBUG - conditional - Calling conditional(['T', 'T', 'F', 'F', 'T', 'T', 'F', 'F'], ['T', 'F', 'T', 'F', 'T', 'F', 'T', 'F'])... +2023-10-10 00:25:30,276 - DEBUG - conditional - new_row_values=['T', 'F', 'T', 'T', 'T', 'F', 'T', 'T'] +2023-10-10 00:25:30,276 - DEBUG - conditional - Returning with new row values. +2023-10-10 00:25:30,276 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['P'], '->', ['Q']])... +2023-10-10 00:25:30,276 - DEBUG - set_new_array_elem - new_array=['P->Q'] +2023-10-10 00:25:30,276 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-10-10 00:25:30,277 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'F', 'T', 'T', 'T', 'F', 'T', 'T'], +final_variable_combined=['P->Q'], +matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], +variables=['T', 'P', 'Q'] +2023-10-10 00:25:30,277 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-10-10 00:25:30,277 - DEBUG - add_array_to_matrix - Calling add_array_to_matrix([['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['T', 'F', 'T', 'T', 'T', 'F', 'T', 'T'], ['T', 'P', 'Q'], ['P->Q'])... +2023-10-10 00:25:30,278 - DEBUG - add_array_to_matrix - variables=['T', 'P', 'Q', 'P->Q'] +2023-10-10 00:25:30,278 - DEBUG - add_array_to_matrix - Added array to matrix. +2023-10-10 00:25:30,278 - DEBUG - switch_case - Entering switch_case(v, ['T', 'T', 'T', 'T', 'F', 'F', 'F', 'F'], ['T', 'F', 'T', 'T', 'T', 'F', 'T', 'T'])... +2023-10-10 00:25:30,278 - DEBUG - disj - In disj. case... +2023-10-10 00:25:30,278 - DEBUG - disjunction - Calling disjunction(['T', 'T', 'T', 'T', 'F', 'F', 'F', 'F'], ['T', 'F', 'T', 'T', 'T', 'F', 'T', 'T'])... +2023-10-10 00:25:30,278 - DEBUG - disjunction - new_row_values=['T', 'T', 'T', 'T', 'T', 'F', 'T', 'T'] +2023-10-10 00:25:30,279 - DEBUG - disjunction - Returning with new row values. +2023-10-10 00:25:30,279 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['T'], 'v', ['P->Q']])... +2023-10-10 00:25:30,279 - DEBUG - set_new_array_elem - new_array=['Tv(P->Q)'] +2023-10-10 00:25:30,279 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-10-10 00:25:30,279 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'T', 'T', 'T', 'T', 'F', 'T', 'T'], +final_variable_combined=['Tv(P->Q)'], +matrix=[['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'T'], ['T', 'F', 'T', 'T', 'T'], ['T', 'F', 'F', 'T', 'T'], ['F', 'T', 'T', 'T', 'T'], ['F', 'T', 'F', 'F', 'F'], ['F', 'F', 'T', 'T', 'T'], ['F', 'F', 'F', 'T', 'T']], +variables=['T', 'P', 'Q', 'P->Q'] +2023-10-10 00:25:30,280 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-10-10 00:25:30,280 - DEBUG - evaluate_array_as_tree - returned_array=['T', 'T', 'T', 'T', 'T', 'F', 'T', 'T'], returned_matrix=[['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'T'], ['T', 'F', 'T', 'T', 'T'], ['T', 'F', 'F', 'T', 'T'], ['F', 'T', 'T', 'T', 'T'], ['F', 'T', 'F', 'F', 'F'], ['F', 'F', 'T', 'T', 'T'], ['F', 'F', 'F', 'T', 'T']], all_variables=['T', 'P', 'Q', 'P->Q', 'Tv(P->Q)'] +2023-10-10 00:25:30,280 - DEBUG - evaluate_array_as_tree - Finished evaluating array. +2023-10-10 00:25:30,280 - DEBUG - simulate_main - In simulate_main(): +final_value_array=['T', 'T', 'T', 'T', 'T', 'F', 'T', 'T'], +returned_matrix=[['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'T'], ['T', 'F', 'T', 'T', 'T'], ['T', 'F', 'F', 'T', 'T'], ['F', 'T', 'T', 'T', 'T'], ['F', 'T', 'F', 'F', 'F'], ['F', 'F', 'T', 'T', 'T'], ['F', 'F', 'F', 'T', 'T']], +all_variables=['T', 'P', 'Q', 'P->Q', 'Tv(P->Q)'] +2023-10-10 00:25:30,281 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,281 - INFO - print_details - ************************** EVALUATE ************************** +2023-10-10 00:25:30,281 - INFO - print_details - -> Statement: (T v (P -> Q)) +2023-10-10 00:25:30,281 - INFO - print_details - -> Final Calculated Array: ['T', 'T', 'T', 'T', 'T', 'F', 'T', 'T'] +2023-10-10 00:25:30,281 - INFO - print_details - -> All Variables: ['T', 'P', 'Q', 'P->Q', 'Tv(P->Q)'] +2023-10-10 00:25:30,281 - INFO - print_details - -> Final Matrix: [['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'T'], ['T', 'F', 'T', 'T', 'T'], ['T', 'F', 'F', 'T', 'T'], ['F', 'T', 'T', 'T', 'T'], ['F', 'T', 'F', 'F', 'F'], ['F', 'F', 'T', 'T', 'T'], ['F', 'F', 'F', 'T', 'T']] +2023-10-10 00:25:30,282 - INFO - print_details - ************************** EVALUATE ************************** +2023-10-10 00:25:30,282 - INFO - simulate_main - Finished evaluating statement. +2023-10-10 00:25:30,282 - DEBUG - display_matrix - Displaying matrix to console... +2023-10-10 00:25:30,282 - DEBUG - get_number_of_spaces - Calling get_number_of_spaces(3, 1, ['T', 'P', 'Q', 'P->Q', 'Tv(P->Q)'])... +2023-10-10 00:25:30,282 - DEBUG - get_number_of_spaces - total_space=32 +2023-10-10 00:25:30,283 - DEBUG - get_number_of_spaces - Finished calculating the total space. +2023-10-10 00:25:30,284 - DEBUG - simulate_main - Returning from simulate_main()... +2023-10-10 00:25:30,284 - INFO - simulate_main - Statement: ((T ^ Q) v (P ^ Q)) +2023-10-10 00:25:30,284 - INFO - simulate_main - Before proceeding, doing checks for unequal brackets and illegal characters. +2023-10-10 00:25:30,284 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets(((T ^ Q) v (P ^ Q)))... +2023-10-10 00:25:30,284 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-10-10 00:25:30,285 - DEBUG - check_for_illegal_characters - Calling check_for_illegal_characters(((T ^ Q) v (P ^ Q))) +2023-10-10 00:25:30,285 - DEBUG - check_for_illegal_characters - ******************** starting input validation ******************* +2023-10-10 00:25:30,285 - DEBUG - validate_input - Calling validate_input(T)... +2023-10-10 00:25:30,285 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,285 - DEBUG - validate_input - Calling validate_input(^)... +2023-10-10 00:25:30,285 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,285 - DEBUG - validate_input - Calling validate_input(Q)... +2023-10-10 00:25:30,286 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,286 - DEBUG - validate_input - Calling validate_input(v)... +2023-10-10 00:25:30,286 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,286 - DEBUG - validate_input - Calling validate_input(P)... +2023-10-10 00:25:30,286 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,286 - DEBUG - validate_input - Calling validate_input(^)... +2023-10-10 00:25:30,286 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,287 - DEBUG - validate_input - Calling validate_input(Q)... +2023-10-10 00:25:30,287 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,287 - DEBUG - check_for_illegal_characters - ******************** finished input validation ******************* +2023-10-10 00:25:30,287 - INFO - check_for_illegal_characters - PASS: There were no illegal characters found. +2023-10-10 00:25:30,287 - INFO - simulate_main - All checks are valid, proceeding with extracting information from statement. +2023-10-10 00:25:30,287 - INFO - user_input - Processing statement... +2023-10-10 00:25:30,288 - DEBUG - user_input - statement=((T ^ Q) v (P ^ Q)) +2023-10-10 00:25:30,288 - INFO - analyze_statement - Starting to analyze statement... +2023-10-10 00:25:30,288 - INFO - analyze_statement - The statement is sanitized from any whitespaces. +2023-10-10 00:25:30,288 - DEBUG - analyze_statement - All whitespaces need to be removed, proceeding. +2023-10-10 00:25:30,288 - DEBUG - clean_whitespaces - Calling clean_whitespaces(((T ^ Q) v (P ^ Q)))... +2023-10-10 00:25:30,289 - DEBUG - clean_whitespaces - Finished removing whitespaces: statement=((T^Q)v(P^Q)) +2023-10-10 00:25:30,289 - DEBUG - analyze_statement - Finished removing any whitespaces found in statement. Proceeding with finding variables. +2023-10-10 00:25:30,289 - INFO - find_variables - Finding variables in statement... +2023-10-10 00:25:30,289 - DEBUG - find_variables - statement=((T^Q)v(P^Q)) +2023-10-10 00:25:30,289 - DEBUG - find_variables - variables_array=['T', 'Q', 'P'] +2023-10-10 00:25:30,289 - INFO - find_variables - Found all variables in statement. +2023-10-10 00:25:30,290 - INFO - find_variables - *** Variables: ['T', 'Q', 'P'] *** +2023-10-10 00:25:30,290 - DEBUG - analyze_statement - variables_arr=['T', 'Q', 'P'] +2023-10-10 00:25:30,290 - INFO - analyze_statement - The statement is converted to an array and any conditionals are sanitized. +2023-10-10 00:25:30,290 - DEBUG - create_array_of_elements - Creating an array from a string... +2023-10-10 00:25:30,290 - DEBUG - create_array_of_elements - Calling create_array_of_elements(((T^Q)v(P^Q))) +2023-10-10 00:25:30,290 - DEBUG - create_array_of_elements - array_of_elements=['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'] +2023-10-10 00:25:30,291 - DEBUG - create_array_of_elements - Finished creating array. +2023-10-10 00:25:30,291 - DEBUG - check_conditionals - Calling check_conditionals(['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'], ['T', 'Q', 'P'])... +2023-10-10 00:25:30,291 - INFO - check_conditionals - PASS: Any conditional symbols present, are in the desired form. +2023-10-10 00:25:30,291 - DEBUG - create_conditionals - Creating one-piece conditionals from single elements. +2023-10-10 00:25:30,291 - DEBUG - create_conditionals - Searching for a '-' in array_of_elements=['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'] +2023-10-10 00:25:30,292 - DEBUG - create_conditionals - Search for conditionals finished and none were found, returning. +2023-10-10 00:25:30,292 - DEBUG - analyze_statement - In analyze_statement(): +len(variables_arr)=3, +variables_arr=['T', 'Q', 'P'], +array_of_elements=['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'] +2023-10-10 00:25:30,292 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,293 - INFO - print_details - ************************** ANALYSIS ************************** +2023-10-10 00:25:30,293 - INFO - print_details - -> Number of Variables: 3 +2023-10-10 00:25:30,293 - INFO - print_details - -> Variables: ['T', 'Q', 'P'] +2023-10-10 00:25:30,293 - INFO - print_details - -> Array of Elements: ['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'] +2023-10-10 00:25:30,293 - INFO - print_details - ************************** ANALYSIS ************************** +2023-10-10 00:25:30,293 - INFO - analyze_statement - Analyzing concluded. +2023-10-10 00:25:30,295 - INFO - parse_array - Starting to parse array... +2023-10-10 00:25:30,295 - DEBUG - remove_brackets_around_variables - Removing brackets around standalone variables... +2023-10-10 00:25:30,295 - DEBUG - remove_brackets_around_variables - arr=['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'] +2023-10-10 00:25:30,295 - DEBUG - remove_brackets_around_variables - Finished removing all brackets around variables. +2023-10-10 00:25:30,295 - DEBUG - parse_array - In parse_array(): elements_second=['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'] +2023-10-10 00:25:30,296 - DEBUG - add_brackets_around_unary_connectives - Adding brackets around unary connectives... +2023-10-10 00:25:30,296 - DEBUG - add_brackets_around_unary_connectives - arr=['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'] +2023-10-10 00:25:30,296 - DEBUG - add_brackets_around_unary_connectives - Finished adding brackets around all unary connectives. +2023-10-10 00:25:30,296 - DEBUG - parse_array - In parse_array(): elements_second=['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'] +2023-10-10 00:25:30,296 - INFO - parse_array - Final checks are ran before parsing concludes. +2023-10-10 00:25:30,297 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets(['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'])... +2023-10-10 00:25:30,297 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-10-10 00:25:30,297 - DEBUG - parse - Calling parse(['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'])... +2023-10-10 00:25:30,297 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'])... +2023-10-10 00:25:30,297 - DEBUG - remove_outer_brackets - array=['(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')'] +2023-10-10 00:25:30,297 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-10-10 00:25:30,298 - DEBUG - parse - In parse(): arr=['(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')'] +2023-10-10 00:25:30,298 - DEBUG - find_connective - Calling find_connectives(['(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')'])... +2023-10-10 00:25:30,298 - DEBUG - find_connective - In find_connective(): elem=v, i=5 +2023-10-10 00:25:30,298 - DEBUG - find_connective - Found connective. +2023-10-10 00:25:30,298 - DEBUG - parse - Calling parse(['(', 'T', '^', 'Q', ')'])... +2023-10-10 00:25:30,298 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', 'T', '^', 'Q', ')'])... +2023-10-10 00:25:30,299 - DEBUG - remove_outer_brackets - array=['T', '^', 'Q'] +2023-10-10 00:25:30,299 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-10-10 00:25:30,299 - DEBUG - parse - In parse(): arr=['T', '^', 'Q'] +2023-10-10 00:25:30,299 - DEBUG - find_connective - Calling find_connectives(['T', '^', 'Q'])... +2023-10-10 00:25:30,299 - DEBUG - find_connective - In find_connective(): elem=^, i=1 +2023-10-10 00:25:30,299 - DEBUG - find_connective - Found connective. +2023-10-10 00:25:30,299 - DEBUG - parse - temp_array=[['T'], '^', ['Q']] +2023-10-10 00:25:30,300 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-10-10 00:25:30,300 - DEBUG - parse - Calling parse(['(', 'P', '^', 'Q', ')'])... +2023-10-10 00:25:30,300 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', 'P', '^', 'Q', ')'])... +2023-10-10 00:25:30,300 - DEBUG - remove_outer_brackets - array=['P', '^', 'Q'] +2023-10-10 00:25:30,300 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-10-10 00:25:30,300 - DEBUG - parse - In parse(): arr=['P', '^', 'Q'] +2023-10-10 00:25:30,300 - DEBUG - find_connective - Calling find_connectives(['P', '^', 'Q'])... +2023-10-10 00:25:30,300 - DEBUG - find_connective - In find_connective(): elem=^, i=1 +2023-10-10 00:25:30,300 - DEBUG - find_connective - Found connective. +2023-10-10 00:25:30,300 - DEBUG - parse - temp_array=[['P'], '^', ['Q']] +2023-10-10 00:25:30,300 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-10-10 00:25:30,300 - DEBUG - parse - temp_array=[[['T'], '^', ['Q']], 'v', [['P'], '^', ['Q']]] +2023-10-10 00:25:30,301 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-10-10 00:25:30,301 - DEBUG - parse_array - tree_structured_array=[[['T'], '^', ['Q']], 'v', [['P'], '^', ['Q']]] +2023-10-10 00:25:30,301 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,301 - INFO - print_details - *************************** PARSE *************************** +2023-10-10 00:25:30,302 - INFO - print_details - -> Parsed Array: [[['T'], '^', ['Q']], 'v', [['P'], '^', ['Q']]] +2023-10-10 00:25:30,302 - INFO - print_details - *************************** PARSE *************************** +2023-10-10 00:25:30,302 - INFO - parse_array - Finished parsing array. +2023-10-10 00:25:30,302 - DEBUG - user_input - In user_input(): +number_of_variables=3, +variables_as_array=['T', 'Q', 'P'], +statement=((T ^ Q) v (P ^ Q)), +new_elements=[[['T'], '^', ['Q']], 'v', [['P'], '^', ['Q']]]. +2023-10-10 00:25:30,302 - INFO - user_input - Gathered all information needed including variables and parsed array. +2023-10-10 00:25:30,302 - DEBUG - simulate_main - In simulate_main(): +number_of_variables=3, +variables_as_array=['T', 'Q', 'P'], +provided_statement=((T ^ Q) v (P ^ Q)), +elements_in_tree=[[['T'], '^', ['Q']], 'v', [['P'], '^', ['Q']]] +2023-10-10 00:25:30,303 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,303 - INFO - print_details - ************************** SUMMARY ************************** +2023-10-10 00:25:30,303 - INFO - print_details - -> number_of_variables: 3 +2023-10-10 00:25:30,303 - INFO - print_details - -> variables_as_array: ['T', 'Q', 'P'] +2023-10-10 00:25:30,303 - INFO - print_details - -> provided_statement: ((T ^ Q) v (P ^ Q)) +2023-10-10 00:25:30,303 - INFO - print_details - -> elements_in_tree: [[['T'], '^', ['Q']], 'v', [['P'], '^', ['Q']]] +2023-10-10 00:25:30,304 - INFO - print_details - ************************** SUMMARY ************************** +2023-10-10 00:25:30,304 - INFO - evaluate_array_as_tree - Starting evaluation of array of elements... +2023-10-10 00:25:30,304 - DEBUG - create_matrix - Creating initial matrix... +2023-10-10 00:25:30,304 - DEBUG - recursive_table - Creating table entries recursively... +2023-10-10 00:25:30,304 - DEBUG - recursive_table - n=3 +2023-10-10 00:25:30,304 - DEBUG - recursive_table - Creating table entries recursively... +2023-10-10 00:25:30,304 - DEBUG - recursive_table - n=2 +2023-10-10 00:25:30,305 - DEBUG - recursive_table - Creating table entries recursively... +2023-10-10 00:25:30,305 - DEBUG - recursive_table - n=1 +2023-10-10 00:25:30,305 - DEBUG - recursive_table - array_table=['T', 'F'] +2023-10-10 00:25:30,305 - DEBUG - recursive_table - Finished creating array of table entries. +2023-10-10 00:25:30,305 - DEBUG - recursive_table - array_table=['TT', 'TF', 'FT', 'FF'] +2023-10-10 00:25:30,306 - DEBUG - recursive_table - Finished creating array of table entries. +2023-10-10 00:25:30,306 - DEBUG - recursive_table - array_table=['TTT', 'TTF', 'TFT', 'TFF', 'FTT', 'FTF', 'FFT', 'FFF'] +2023-10-10 00:25:30,306 - DEBUG - recursive_table - Finished creating array of table entries. +2023-10-10 00:25:30,306 - DEBUG - create_matrix - In create_matrix(): new_matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']] +2023-10-10 00:25:30,306 - INFO - create_matrix - Finished creating the initial 'truth' matrix. +2023-10-10 00:25:30,306 - INFO - create_matrix - *** Initial Matrix: [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']] *** +2023-10-10 00:25:30,306 - DEBUG - evaluate_array_as_tree - In evaluate_array_as_tree(): +elements_in_tree=[[['T'], '^', ['Q']], 'v', [['P'], '^', ['Q']]], +counter=0, +matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], +variables_as_array=['T', 'Q', 'P'] +2023-10-10 00:25:30,307 - DEBUG - evaluate_array - Calling evaluate_array([[['T'], '^', ['Q']], 'v', [['P'], '^', ['Q']]], 0, [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['T', 'Q', 'P'])... +2023-10-10 00:25:30,307 - DEBUG - evaluate_array - Calling evaluate_array([['T'], '^', ['Q']], 1, [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['T', 'Q', 'P'])... +2023-10-10 00:25:30,307 - DEBUG - switch_case - Entering switch_case(^, ['T', 'T', 'T', 'T', 'F', 'F', 'F', 'F'], ['T', 'T', 'F', 'F', 'T', 'T', 'F', 'F'])... +2023-10-10 00:25:30,307 - DEBUG - conj - In conj. case... +2023-10-10 00:25:30,307 - DEBUG - conjunction - Calling conjunction(['T', 'T', 'T', 'T', 'F', 'F', 'F', 'F'], ['T', 'T', 'F', 'F', 'T', 'T', 'F', 'F'])... +2023-10-10 00:25:30,308 - DEBUG - conjunction - new_row_values=['T', 'T', 'F', 'F', 'F', 'F', 'F', 'F'] +2023-10-10 00:25:30,308 - DEBUG - conjunction - Returning with new row values. +2023-10-10 00:25:30,308 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['T'], '^', ['Q']])... +2023-10-10 00:25:30,308 - DEBUG - set_new_array_elem - new_array=['T^Q'] +2023-10-10 00:25:30,308 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-10-10 00:25:30,308 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'T', 'F', 'F', 'F', 'F', 'F', 'F'], +final_variable_combined=['T^Q'], +matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], +variables=['T', 'Q', 'P'] +2023-10-10 00:25:30,309 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-10-10 00:25:30,309 - DEBUG - add_array_to_matrix - Calling add_array_to_matrix([['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['T', 'T', 'F', 'F', 'F', 'F', 'F', 'F'], ['T', 'Q', 'P'], ['T^Q'])... +2023-10-10 00:25:30,309 - DEBUG - add_array_to_matrix - variables=['T', 'Q', 'P', 'T^Q'] +2023-10-10 00:25:30,309 - DEBUG - add_array_to_matrix - Added array to matrix. +2023-10-10 00:25:30,309 - DEBUG - evaluate_array - Calling evaluate_array([['P'], '^', ['Q']], 1, [['T', 'T', 'T', 'T'], ['T', 'T', 'F', 'T'], ['T', 'F', 'T', 'F'], ['T', 'F', 'F', 'F'], ['F', 'T', 'T', 'F'], ['F', 'T', 'F', 'F'], ['F', 'F', 'T', 'F'], ['F', 'F', 'F', 'F']], ['T', 'Q', 'P', 'T^Q'])... +2023-10-10 00:25:30,309 - DEBUG - switch_case - Entering switch_case(^, ['T', 'F', 'T', 'F', 'T', 'F', 'T', 'F'], ['T', 'T', 'F', 'F', 'T', 'T', 'F', 'F'])... +2023-10-10 00:25:30,310 - DEBUG - conj - In conj. case... +2023-10-10 00:25:30,310 - DEBUG - conjunction - Calling conjunction(['T', 'F', 'T', 'F', 'T', 'F', 'T', 'F'], ['T', 'T', 'F', 'F', 'T', 'T', 'F', 'F'])... +2023-10-10 00:25:30,310 - DEBUG - conjunction - new_row_values=['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'] +2023-10-10 00:25:30,310 - DEBUG - conjunction - Returning with new row values. +2023-10-10 00:25:30,310 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['P'], '^', ['Q']])... +2023-10-10 00:25:30,310 - DEBUG - set_new_array_elem - new_array=['P^Q'] +2023-10-10 00:25:30,310 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-10-10 00:25:30,311 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'], +final_variable_combined=['P^Q'], +matrix=[['T', 'T', 'T', 'T'], ['T', 'T', 'F', 'T'], ['T', 'F', 'T', 'F'], ['T', 'F', 'F', 'F'], ['F', 'T', 'T', 'F'], ['F', 'T', 'F', 'F'], ['F', 'F', 'T', 'F'], ['F', 'F', 'F', 'F']], +variables=['T', 'Q', 'P', 'T^Q'] +2023-10-10 00:25:30,312 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-10-10 00:25:30,312 - DEBUG - add_array_to_matrix - Calling add_array_to_matrix([['T', 'T', 'T', 'T'], ['T', 'T', 'F', 'T'], ['T', 'F', 'T', 'F'], ['T', 'F', 'F', 'F'], ['F', 'T', 'T', 'F'], ['F', 'T', 'F', 'F'], ['F', 'F', 'T', 'F'], ['F', 'F', 'F', 'F']], ['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'], ['T', 'Q', 'P', 'T^Q'], ['P^Q'])... +2023-10-10 00:25:30,312 - DEBUG - add_array_to_matrix - variables=['T', 'Q', 'P', 'T^Q', 'P^Q'] +2023-10-10 00:25:30,312 - DEBUG - add_array_to_matrix - Added array to matrix. +2023-10-10 00:25:30,313 - DEBUG - switch_case - Entering switch_case(v, ['T', 'T', 'F', 'F', 'F', 'F', 'F', 'F'], ['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'])... +2023-10-10 00:25:30,313 - DEBUG - disj - In disj. case... +2023-10-10 00:25:30,313 - DEBUG - disjunction - Calling disjunction(['T', 'T', 'F', 'F', 'F', 'F', 'F', 'F'], ['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'])... +2023-10-10 00:25:30,313 - DEBUG - disjunction - new_row_values=['T', 'T', 'F', 'F', 'T', 'F', 'F', 'F'] +2023-10-10 00:25:30,314 - DEBUG - disjunction - Returning with new row values. +2023-10-10 00:25:30,314 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['T^Q'], 'v', ['P^Q']])... +2023-10-10 00:25:30,314 - DEBUG - set_new_array_elem - new_array=['(T^Q)v(P^Q)'] +2023-10-10 00:25:30,314 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-10-10 00:25:30,314 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'T', 'F', 'F', 'T', 'F', 'F', 'F'], +final_variable_combined=['(T^Q)v(P^Q)'], +matrix=[['T', 'T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'T', 'F', 'T'], ['T', 'F', 'T', 'F', 'F', 'F'], ['T', 'F', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'F', 'T', 'T'], ['F', 'T', 'F', 'F', 'F', 'F'], ['F', 'F', 'T', 'F', 'F', 'F'], ['F', 'F', 'F', 'F', 'F', 'F']], +variables=['T', 'Q', 'P', 'T^Q', 'P^Q'] +2023-10-10 00:25:30,315 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-10-10 00:25:30,315 - DEBUG - evaluate_array_as_tree - returned_array=['T', 'T', 'F', 'F', 'T', 'F', 'F', 'F'], returned_matrix=[['T', 'T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'T', 'F', 'T'], ['T', 'F', 'T', 'F', 'F', 'F'], ['T', 'F', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'F', 'T', 'T'], ['F', 'T', 'F', 'F', 'F', 'F'], ['F', 'F', 'T', 'F', 'F', 'F'], ['F', 'F', 'F', 'F', 'F', 'F']], all_variables=['T', 'Q', 'P', 'T^Q', 'P^Q', '(T^Q)v(P^Q)'] +2023-10-10 00:25:30,315 - DEBUG - evaluate_array_as_tree - Finished evaluating array. +2023-10-10 00:25:30,315 - DEBUG - simulate_main - In simulate_main(): +final_value_array=['T', 'T', 'F', 'F', 'T', 'F', 'F', 'F'], +returned_matrix=[['T', 'T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'T', 'F', 'T'], ['T', 'F', 'T', 'F', 'F', 'F'], ['T', 'F', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'F', 'T', 'T'], ['F', 'T', 'F', 'F', 'F', 'F'], ['F', 'F', 'T', 'F', 'F', 'F'], ['F', 'F', 'F', 'F', 'F', 'F']], +all_variables=['T', 'Q', 'P', 'T^Q', 'P^Q', '(T^Q)v(P^Q)'] +2023-10-10 00:25:30,316 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,316 - INFO - print_details - ************************** EVALUATE ************************** +2023-10-10 00:25:30,316 - INFO - print_details - -> Statement: ((T ^ Q) v (P ^ Q)) +2023-10-10 00:25:30,316 - INFO - print_details - -> Final Calculated Array: ['T', 'T', 'F', 'F', 'T', 'F', 'F', 'F'] +2023-10-10 00:25:30,316 - INFO - print_details - -> All Variables: ['T', 'Q', 'P', 'T^Q', 'P^Q', '(T^Q)v(P^Q)'] +2023-10-10 00:25:30,316 - INFO - print_details - -> Final Matrix: [['T', 'T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'T', 'F', 'T'], ['T', 'F', 'T', 'F', 'F', 'F'], ['T', 'F', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'F', 'T', 'T'], ['F', 'T', 'F', 'F', 'F', 'F'], ['F', 'F', 'T', 'F', 'F', 'F'], ['F', 'F', 'F', 'F', 'F', 'F']] +2023-10-10 00:25:30,316 - INFO - print_details - ************************** EVALUATE ************************** +2023-10-10 00:25:30,317 - INFO - simulate_main - Finished evaluating statement. +2023-10-10 00:25:30,317 - DEBUG - display_matrix - Displaying matrix to console... +2023-10-10 00:25:30,317 - DEBUG - get_number_of_spaces - Calling get_number_of_spaces(3, 2, ['T', 'Q', 'P', 'T^Q', 'P^Q', '(T^Q)v(P^Q)'])... +2023-10-10 00:25:30,317 - DEBUG - get_number_of_spaces - total_space=40 +2023-10-10 00:25:30,318 - DEBUG - get_number_of_spaces - Finished calculating the total space. +2023-10-10 00:25:30,319 - DEBUG - simulate_main - Returning from simulate_main()... +2023-10-10 00:25:30,319 - INFO - simulate_main - Statement: (S ^ (R ^ Q)) +2023-10-10 00:25:30,319 - INFO - simulate_main - Before proceeding, doing checks for unequal brackets and illegal characters. +2023-10-10 00:25:30,320 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets((S ^ (R ^ Q)))... +2023-10-10 00:25:30,320 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-10-10 00:25:30,320 - DEBUG - check_for_illegal_characters - Calling check_for_illegal_characters((S ^ (R ^ Q))) +2023-10-10 00:25:30,320 - DEBUG - check_for_illegal_characters - ******************** starting input validation ******************* +2023-10-10 00:25:30,320 - DEBUG - validate_input - Calling validate_input(S)... +2023-10-10 00:25:30,320 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,320 - DEBUG - validate_input - Calling validate_input(^)... +2023-10-10 00:25:30,320 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,320 - DEBUG - validate_input - Calling validate_input(R)... +2023-10-10 00:25:30,321 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,321 - DEBUG - validate_input - Calling validate_input(^)... +2023-10-10 00:25:30,321 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,322 - DEBUG - validate_input - Calling validate_input(Q)... +2023-10-10 00:25:30,322 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,322 - DEBUG - check_for_illegal_characters - ******************** finished input validation ******************* +2023-10-10 00:25:30,322 - INFO - check_for_illegal_characters - PASS: There were no illegal characters found. +2023-10-10 00:25:30,322 - INFO - simulate_main - All checks are valid, proceeding with extracting information from statement. +2023-10-10 00:25:30,322 - INFO - user_input - Processing statement... +2023-10-10 00:25:30,323 - DEBUG - user_input - statement=(S ^ (R ^ Q)) +2023-10-10 00:25:30,323 - INFO - analyze_statement - Starting to analyze statement... +2023-10-10 00:25:30,323 - INFO - analyze_statement - The statement is sanitized from any whitespaces. +2023-10-10 00:25:30,323 - DEBUG - analyze_statement - All whitespaces need to be removed, proceeding. +2023-10-10 00:25:30,323 - DEBUG - clean_whitespaces - Calling clean_whitespaces((S ^ (R ^ Q)))... +2023-10-10 00:25:30,323 - DEBUG - clean_whitespaces - Finished removing whitespaces: statement=(S^(R^Q)) +2023-10-10 00:25:30,323 - DEBUG - analyze_statement - Finished removing any whitespaces found in statement. Proceeding with finding variables. +2023-10-10 00:25:30,324 - INFO - find_variables - Finding variables in statement... +2023-10-10 00:25:30,324 - DEBUG - find_variables - statement=(S^(R^Q)) +2023-10-10 00:25:30,324 - DEBUG - find_variables - variables_array=['S', 'R', 'Q'] +2023-10-10 00:25:30,324 - INFO - find_variables - Found all variables in statement. +2023-10-10 00:25:30,324 - INFO - find_variables - *** Variables: ['S', 'R', 'Q'] *** +2023-10-10 00:25:30,325 - DEBUG - analyze_statement - variables_arr=['S', 'R', 'Q'] +2023-10-10 00:25:30,325 - INFO - analyze_statement - The statement is converted to an array and any conditionals are sanitized. +2023-10-10 00:25:30,325 - DEBUG - create_array_of_elements - Creating an array from a string... +2023-10-10 00:25:30,325 - DEBUG - create_array_of_elements - Calling create_array_of_elements((S^(R^Q))) +2023-10-10 00:25:30,325 - DEBUG - create_array_of_elements - array_of_elements=['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'] +2023-10-10 00:25:30,326 - DEBUG - create_array_of_elements - Finished creating array. +2023-10-10 00:25:30,326 - DEBUG - check_conditionals - Calling check_conditionals(['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'], ['S', 'R', 'Q'])... +2023-10-10 00:25:30,326 - INFO - check_conditionals - PASS: Any conditional symbols present, are in the desired form. +2023-10-10 00:25:30,326 - DEBUG - create_conditionals - Creating one-piece conditionals from single elements. +2023-10-10 00:25:30,326 - DEBUG - create_conditionals - Searching for a '-' in array_of_elements=['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'] +2023-10-10 00:25:30,326 - DEBUG - create_conditionals - Search for conditionals finished and none were found, returning. +2023-10-10 00:25:30,327 - DEBUG - analyze_statement - In analyze_statement(): +len(variables_arr)=3, +variables_arr=['S', 'R', 'Q'], +array_of_elements=['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'] +2023-10-10 00:25:30,327 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,327 - INFO - print_details - ************************** ANALYSIS ************************** +2023-10-10 00:25:30,327 - INFO - print_details - -> Number of Variables: 3 +2023-10-10 00:25:30,327 - INFO - print_details - -> Variables: ['S', 'R', 'Q'] +2023-10-10 00:25:30,328 - INFO - print_details - -> Array of Elements: ['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'] +2023-10-10 00:25:30,328 - INFO - print_details - ************************** ANALYSIS ************************** +2023-10-10 00:25:30,328 - INFO - analyze_statement - Analyzing concluded. +2023-10-10 00:25:30,328 - INFO - parse_array - Starting to parse array... +2023-10-10 00:25:30,328 - DEBUG - remove_brackets_around_variables - Removing brackets around standalone variables... +2023-10-10 00:25:30,328 - DEBUG - remove_brackets_around_variables - arr=['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'] +2023-10-10 00:25:30,329 - DEBUG - remove_brackets_around_variables - Finished removing all brackets around variables. +2023-10-10 00:25:30,329 - DEBUG - parse_array - In parse_array(): elements_second=['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'] +2023-10-10 00:25:30,329 - DEBUG - add_brackets_around_unary_connectives - Adding brackets around unary connectives... +2023-10-10 00:25:30,329 - DEBUG - add_brackets_around_unary_connectives - arr=['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'] +2023-10-10 00:25:30,329 - DEBUG - add_brackets_around_unary_connectives - Finished adding brackets around all unary connectives. +2023-10-10 00:25:30,329 - DEBUG - parse_array - In parse_array(): elements_second=['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'] +2023-10-10 00:25:30,329 - INFO - parse_array - Final checks are ran before parsing concludes. +2023-10-10 00:25:30,329 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets(['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'])... +2023-10-10 00:25:30,330 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-10-10 00:25:30,330 - DEBUG - parse - Calling parse(['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'])... +2023-10-10 00:25:30,330 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'])... +2023-10-10 00:25:30,330 - DEBUG - remove_outer_brackets - array=['S', '^', '(', 'R', '^', 'Q', ')'] +2023-10-10 00:25:30,330 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-10-10 00:25:30,330 - DEBUG - parse - In parse(): arr=['S', '^', '(', 'R', '^', 'Q', ')'] +2023-10-10 00:25:30,330 - DEBUG - find_connective - Calling find_connectives(['S', '^', '(', 'R', '^', 'Q', ')'])... +2023-10-10 00:25:30,330 - DEBUG - find_connective - In find_connective(): elem=^, i=1 +2023-10-10 00:25:30,330 - DEBUG - find_connective - Found connective. +2023-10-10 00:25:30,330 - DEBUG - parse - Calling parse(['(', 'R', '^', 'Q', ')'])... +2023-10-10 00:25:30,331 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', 'R', '^', 'Q', ')'])... +2023-10-10 00:25:30,331 - DEBUG - remove_outer_brackets - array=['R', '^', 'Q'] +2023-10-10 00:25:30,331 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-10-10 00:25:30,332 - DEBUG - parse - In parse(): arr=['R', '^', 'Q'] +2023-10-10 00:25:30,332 - DEBUG - find_connective - Calling find_connectives(['R', '^', 'Q'])... +2023-10-10 00:25:30,332 - DEBUG - find_connective - In find_connective(): elem=^, i=1 +2023-10-10 00:25:30,332 - DEBUG - find_connective - Found connective. +2023-10-10 00:25:30,332 - DEBUG - parse - temp_array=[['R'], '^', ['Q']] +2023-10-10 00:25:30,332 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-10-10 00:25:30,333 - DEBUG - parse - temp_array=[['S'], '^', [['R'], '^', ['Q']]] +2023-10-10 00:25:30,333 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-10-10 00:25:30,333 - DEBUG - parse_array - tree_structured_array=[['S'], '^', [['R'], '^', ['Q']]] +2023-10-10 00:25:30,333 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,333 - INFO - print_details - *************************** PARSE *************************** +2023-10-10 00:25:30,333 - INFO - print_details - -> Parsed Array: [['S'], '^', [['R'], '^', ['Q']]] +2023-10-10 00:25:30,333 - INFO - print_details - *************************** PARSE *************************** +2023-10-10 00:25:30,334 - INFO - parse_array - Finished parsing array. +2023-10-10 00:25:30,334 - DEBUG - user_input - In user_input(): +number_of_variables=3, +variables_as_array=['S', 'R', 'Q'], +statement=(S ^ (R ^ Q)), +new_elements=[['S'], '^', [['R'], '^', ['Q']]]. +2023-10-10 00:25:30,334 - INFO - user_input - Gathered all information needed including variables and parsed array. +2023-10-10 00:25:30,334 - DEBUG - simulate_main - In simulate_main(): +number_of_variables=3, +variables_as_array=['S', 'R', 'Q'], +provided_statement=(S ^ (R ^ Q)), +elements_in_tree=[['S'], '^', [['R'], '^', ['Q']]] +2023-10-10 00:25:30,334 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,335 - INFO - print_details - ************************** SUMMARY ************************** +2023-10-10 00:25:30,335 - INFO - print_details - -> number_of_variables: 3 +2023-10-10 00:25:30,335 - INFO - print_details - -> variables_as_array: ['S', 'R', 'Q'] +2023-10-10 00:25:30,335 - INFO - print_details - -> provided_statement: (S ^ (R ^ Q)) +2023-10-10 00:25:30,335 - INFO - print_details - -> elements_in_tree: [['S'], '^', [['R'], '^', ['Q']]] +2023-10-10 00:25:30,335 - INFO - print_details - ************************** SUMMARY ************************** +2023-10-10 00:25:30,335 - INFO - evaluate_array_as_tree - Starting evaluation of array of elements... +2023-10-10 00:25:30,335 - DEBUG - create_matrix - Creating initial matrix... +2023-10-10 00:25:30,336 - DEBUG - recursive_table - Creating table entries recursively... +2023-10-10 00:25:30,336 - DEBUG - recursive_table - n=3 +2023-10-10 00:25:30,336 - DEBUG - recursive_table - Creating table entries recursively... +2023-10-10 00:25:30,336 - DEBUG - recursive_table - n=2 +2023-10-10 00:25:30,336 - DEBUG - recursive_table - Creating table entries recursively... +2023-10-10 00:25:30,336 - DEBUG - recursive_table - n=1 +2023-10-10 00:25:30,337 - DEBUG - recursive_table - array_table=['T', 'F'] +2023-10-10 00:25:30,337 - DEBUG - recursive_table - Finished creating array of table entries. +2023-10-10 00:25:30,337 - DEBUG - recursive_table - array_table=['TT', 'TF', 'FT', 'FF'] +2023-10-10 00:25:30,337 - DEBUG - recursive_table - Finished creating array of table entries. +2023-10-10 00:25:30,337 - DEBUG - recursive_table - array_table=['TTT', 'TTF', 'TFT', 'TFF', 'FTT', 'FTF', 'FFT', 'FFF'] +2023-10-10 00:25:30,337 - DEBUG - recursive_table - Finished creating array of table entries. +2023-10-10 00:25:30,338 - DEBUG - create_matrix - In create_matrix(): new_matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']] +2023-10-10 00:25:30,338 - INFO - create_matrix - Finished creating the initial 'truth' matrix. +2023-10-10 00:25:30,338 - INFO - create_matrix - *** Initial Matrix: [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']] *** +2023-10-10 00:25:30,338 - DEBUG - evaluate_array_as_tree - In evaluate_array_as_tree(): +elements_in_tree=[['S'], '^', [['R'], '^', ['Q']]], +counter=0, +matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], +variables_as_array=['S', 'R', 'Q'] +2023-10-10 00:25:30,339 - DEBUG - evaluate_array - Calling evaluate_array([['S'], '^', [['R'], '^', ['Q']]], 0, [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['S', 'R', 'Q'])... +2023-10-10 00:25:30,339 - DEBUG - evaluate_array - Calling evaluate_array([['R'], '^', ['Q']], 1, [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['S', 'R', 'Q'])... +2023-10-10 00:25:30,339 - DEBUG - switch_case - Entering switch_case(^, ['T', 'T', 'F', 'F', 'T', 'T', 'F', 'F'], ['T', 'F', 'T', 'F', 'T', 'F', 'T', 'F'])... +2023-10-10 00:25:30,340 - DEBUG - conj - In conj. case... +2023-10-10 00:25:30,340 - DEBUG - conjunction - Calling conjunction(['T', 'T', 'F', 'F', 'T', 'T', 'F', 'F'], ['T', 'F', 'T', 'F', 'T', 'F', 'T', 'F'])... +2023-10-10 00:25:30,340 - DEBUG - conjunction - new_row_values=['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'] +2023-10-10 00:25:30,340 - DEBUG - conjunction - Returning with new row values. +2023-10-10 00:25:30,340 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['R'], '^', ['Q']])... +2023-10-10 00:25:30,340 - DEBUG - set_new_array_elem - new_array=['R^Q'] +2023-10-10 00:25:30,340 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-10-10 00:25:30,340 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'], +final_variable_combined=['R^Q'], +matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], +variables=['S', 'R', 'Q'] +2023-10-10 00:25:30,340 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-10-10 00:25:30,340 - DEBUG - add_array_to_matrix - Calling add_array_to_matrix([['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'], ['S', 'R', 'Q'], ['R^Q'])... +2023-10-10 00:25:30,341 - DEBUG - add_array_to_matrix - variables=['S', 'R', 'Q', 'R^Q'] +2023-10-10 00:25:30,341 - DEBUG - add_array_to_matrix - Added array to matrix. +2023-10-10 00:25:30,341 - DEBUG - switch_case - Entering switch_case(^, ['T', 'T', 'T', 'T', 'F', 'F', 'F', 'F'], ['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'])... +2023-10-10 00:25:30,342 - DEBUG - conj - In conj. case... +2023-10-10 00:25:30,342 - DEBUG - conjunction - Calling conjunction(['T', 'T', 'T', 'T', 'F', 'F', 'F', 'F'], ['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'])... +2023-10-10 00:25:30,342 - DEBUG - conjunction - new_row_values=['T', 'F', 'F', 'F', 'F', 'F', 'F', 'F'] +2023-10-10 00:25:30,342 - DEBUG - conjunction - Returning with new row values. +2023-10-10 00:25:30,342 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['S'], '^', ['R^Q']])... +2023-10-10 00:25:30,342 - DEBUG - set_new_array_elem - new_array=['S^(R^Q)'] +2023-10-10 00:25:30,343 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-10-10 00:25:30,343 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'F', 'F', 'F', 'F', 'F', 'F', 'F'], +final_variable_combined=['S^(R^Q)'], +matrix=[['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'F'], ['T', 'F', 'T', 'F', 'F'], ['T', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'T', 'F'], ['F', 'T', 'F', 'F', 'F'], ['F', 'F', 'T', 'F', 'F'], ['F', 'F', 'F', 'F', 'F']], +variables=['S', 'R', 'Q', 'R^Q'] +2023-10-10 00:25:30,344 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-10-10 00:25:30,344 - DEBUG - evaluate_array_as_tree - returned_array=['T', 'F', 'F', 'F', 'F', 'F', 'F', 'F'], returned_matrix=[['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'F'], ['T', 'F', 'T', 'F', 'F'], ['T', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'T', 'F'], ['F', 'T', 'F', 'F', 'F'], ['F', 'F', 'T', 'F', 'F'], ['F', 'F', 'F', 'F', 'F']], all_variables=['S', 'R', 'Q', 'R^Q', 'S^(R^Q)'] +2023-10-10 00:25:30,344 - DEBUG - evaluate_array_as_tree - Finished evaluating array. +2023-10-10 00:25:30,344 - DEBUG - simulate_main - In simulate_main(): +final_value_array=['T', 'F', 'F', 'F', 'F', 'F', 'F', 'F'], +returned_matrix=[['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'F'], ['T', 'F', 'T', 'F', 'F'], ['T', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'T', 'F'], ['F', 'T', 'F', 'F', 'F'], ['F', 'F', 'T', 'F', 'F'], ['F', 'F', 'F', 'F', 'F']], +all_variables=['S', 'R', 'Q', 'R^Q', 'S^(R^Q)'] +2023-10-10 00:25:30,345 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,345 - INFO - print_details - ************************** EVALUATE ************************** +2023-10-10 00:25:30,345 - INFO - print_details - -> Statement: (S ^ (R ^ Q)) +2023-10-10 00:25:30,345 - INFO - print_details - -> Final Calculated Array: ['T', 'F', 'F', 'F', 'F', 'F', 'F', 'F'] +2023-10-10 00:25:30,345 - INFO - print_details - -> All Variables: ['S', 'R', 'Q', 'R^Q', 'S^(R^Q)'] +2023-10-10 00:25:30,345 - INFO - print_details - -> Final Matrix: [['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'F'], ['T', 'F', 'T', 'F', 'F'], ['T', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'T', 'F'], ['F', 'T', 'F', 'F', 'F'], ['F', 'F', 'T', 'F', 'F'], ['F', 'F', 'F', 'F', 'F']] +2023-10-10 00:25:30,346 - INFO - print_details - ************************** EVALUATE ************************** +2023-10-10 00:25:30,346 - INFO - simulate_main - Finished evaluating statement. +2023-10-10 00:25:30,346 - DEBUG - display_matrix - Displaying matrix to console... +2023-10-10 00:25:30,346 - DEBUG - get_number_of_spaces - Calling get_number_of_spaces(3, 1, ['S', 'R', 'Q', 'R^Q', 'S^(R^Q)'])... +2023-10-10 00:25:30,346 - DEBUG - get_number_of_spaces - total_space=30 +2023-10-10 00:25:30,347 - DEBUG - get_number_of_spaces - Finished calculating the total space. +2023-10-10 00:25:30,348 - DEBUG - simulate_main - Returning from simulate_main()... +2023-10-10 00:25:30,348 - INFO - simulate_main - Statement: (P v Q) +2023-10-10 00:25:30,348 - INFO - simulate_main - Before proceeding, doing checks for unequal brackets and illegal characters. +2023-10-10 00:25:30,348 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets((P v Q))... +2023-10-10 00:25:30,348 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-10-10 00:25:30,348 - DEBUG - check_for_illegal_characters - Calling check_for_illegal_characters((P v Q)) +2023-10-10 00:25:30,349 - DEBUG - check_for_illegal_characters - ******************** starting input validation ******************* +2023-10-10 00:25:30,349 - DEBUG - validate_input - Calling validate_input(P)... +2023-10-10 00:25:30,349 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,349 - DEBUG - validate_input - Calling validate_input(v)... +2023-10-10 00:25:30,349 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,349 - DEBUG - validate_input - Calling validate_input(Q)... +2023-10-10 00:25:30,349 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,349 - DEBUG - check_for_illegal_characters - ******************** finished input validation ******************* +2023-10-10 00:25:30,350 - INFO - check_for_illegal_characters - PASS: There were no illegal characters found. +2023-10-10 00:25:30,350 - INFO - simulate_main - All checks are valid, proceeding with extracting information from statement. +2023-10-10 00:25:30,350 - INFO - user_input - Processing statement... +2023-10-10 00:25:30,350 - DEBUG - user_input - statement=(P v Q) +2023-10-10 00:25:30,350 - INFO - analyze_statement - Starting to analyze statement... +2023-10-10 00:25:30,350 - INFO - analyze_statement - The statement is sanitized from any whitespaces. +2023-10-10 00:25:30,350 - DEBUG - analyze_statement - All whitespaces need to be removed, proceeding. +2023-10-10 00:25:30,351 - DEBUG - clean_whitespaces - Calling clean_whitespaces((P v Q))... +2023-10-10 00:25:30,351 - DEBUG - clean_whitespaces - Finished removing whitespaces: statement=(PvQ) +2023-10-10 00:25:30,351 - DEBUG - analyze_statement - Finished removing any whitespaces found in statement. Proceeding with finding variables. +2023-10-10 00:25:30,351 - INFO - find_variables - Finding variables in statement... +2023-10-10 00:25:30,351 - DEBUG - find_variables - statement=(PvQ) +2023-10-10 00:25:30,351 - DEBUG - find_variables - variables_array=['P', 'Q'] +2023-10-10 00:25:30,351 - INFO - find_variables - Found all variables in statement. +2023-10-10 00:25:30,351 - INFO - find_variables - *** Variables: ['P', 'Q'] *** +2023-10-10 00:25:30,351 - DEBUG - analyze_statement - variables_arr=['P', 'Q'] +2023-10-10 00:25:30,352 - INFO - analyze_statement - The statement is converted to an array and any conditionals are sanitized. +2023-10-10 00:25:30,352 - DEBUG - create_array_of_elements - Creating an array from a string... +2023-10-10 00:25:30,352 - DEBUG - create_array_of_elements - Calling create_array_of_elements((PvQ)) +2023-10-10 00:25:30,352 - DEBUG - create_array_of_elements - array_of_elements=['(', 'P', 'v', 'Q', ')'] +2023-10-10 00:25:30,352 - DEBUG - create_array_of_elements - Finished creating array. +2023-10-10 00:25:30,352 - DEBUG - check_conditionals - Calling check_conditionals(['(', 'P', 'v', 'Q', ')'], ['P', 'Q'])... +2023-10-10 00:25:30,352 - INFO - check_conditionals - PASS: Any conditional symbols present, are in the desired form. +2023-10-10 00:25:30,353 - DEBUG - create_conditionals - Creating one-piece conditionals from single elements. +2023-10-10 00:25:30,353 - DEBUG - create_conditionals - Searching for a '-' in array_of_elements=['(', 'P', 'v', 'Q', ')'] +2023-10-10 00:25:30,353 - DEBUG - create_conditionals - Search for conditionals finished and none were found, returning. +2023-10-10 00:25:30,353 - DEBUG - analyze_statement - In analyze_statement(): +len(variables_arr)=2, +variables_arr=['P', 'Q'], +array_of_elements=['(', 'P', 'v', 'Q', ')'] +2023-10-10 00:25:30,353 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,354 - INFO - print_details - ************************** ANALYSIS ************************** +2023-10-10 00:25:30,354 - INFO - print_details - -> Number of Variables: 2 +2023-10-10 00:25:30,354 - INFO - print_details - -> Variables: ['P', 'Q'] +2023-10-10 00:25:30,354 - INFO - print_details - -> Array of Elements: ['(', 'P', 'v', 'Q', ')'] +2023-10-10 00:25:30,354 - INFO - print_details - ************************** ANALYSIS ************************** +2023-10-10 00:25:30,354 - INFO - analyze_statement - Analyzing concluded. +2023-10-10 00:25:30,354 - INFO - parse_array - Starting to parse array... +2023-10-10 00:25:30,355 - DEBUG - remove_brackets_around_variables - Removing brackets around standalone variables... +2023-10-10 00:25:30,355 - DEBUG - remove_brackets_around_variables - arr=['(', 'P', 'v', 'Q', ')'] +2023-10-10 00:25:30,355 - DEBUG - remove_brackets_around_variables - Finished removing all brackets around variables. +2023-10-10 00:25:30,355 - DEBUG - parse_array - In parse_array(): elements_second=['(', 'P', 'v', 'Q', ')'] +2023-10-10 00:25:30,355 - DEBUG - add_brackets_around_unary_connectives - Adding brackets around unary connectives... +2023-10-10 00:25:30,355 - DEBUG - add_brackets_around_unary_connectives - arr=['(', 'P', 'v', 'Q', ')'] +2023-10-10 00:25:30,356 - DEBUG - add_brackets_around_unary_connectives - Finished adding brackets around all unary connectives. +2023-10-10 00:25:30,356 - DEBUG - parse_array - In parse_array(): elements_second=['(', 'P', 'v', 'Q', ')'] +2023-10-10 00:25:30,356 - INFO - parse_array - Final checks are ran before parsing concludes. +2023-10-10 00:25:30,356 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets(['(', 'P', 'v', 'Q', ')'])... +2023-10-10 00:25:30,356 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-10-10 00:25:30,356 - DEBUG - parse - Calling parse(['(', 'P', 'v', 'Q', ')'])... +2023-10-10 00:25:30,356 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', 'P', 'v', 'Q', ')'])... +2023-10-10 00:25:30,356 - DEBUG - remove_outer_brackets - array=['P', 'v', 'Q'] +2023-10-10 00:25:30,357 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-10-10 00:25:30,357 - DEBUG - parse - In parse(): arr=['P', 'v', 'Q'] +2023-10-10 00:25:30,357 - DEBUG - find_connective - Calling find_connectives(['P', 'v', 'Q'])... +2023-10-10 00:25:30,357 - DEBUG - find_connective - In find_connective(): elem=v, i=1 +2023-10-10 00:25:30,357 - DEBUG - find_connective - Found connective. +2023-10-10 00:25:30,357 - DEBUG - parse - temp_array=[['P'], 'v', ['Q']] +2023-10-10 00:25:30,357 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-10-10 00:25:30,358 - DEBUG - parse_array - tree_structured_array=[['P'], 'v', ['Q']] +2023-10-10 00:25:30,358 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,358 - INFO - print_details - *************************** PARSE *************************** +2023-10-10 00:25:30,358 - INFO - print_details - -> Parsed Array: [['P'], 'v', ['Q']] +2023-10-10 00:25:30,358 - INFO - print_details - *************************** PARSE *************************** +2023-10-10 00:25:30,358 - INFO - parse_array - Finished parsing array. +2023-10-10 00:25:30,359 - DEBUG - user_input - In user_input(): +number_of_variables=2, +variables_as_array=['P', 'Q'], +statement=(P v Q), +new_elements=[['P'], 'v', ['Q']]. +2023-10-10 00:25:30,359 - INFO - user_input - Gathered all information needed including variables and parsed array. +2023-10-10 00:25:30,359 - DEBUG - simulate_main - In simulate_main(): +number_of_variables=2, +variables_as_array=['P', 'Q'], +provided_statement=(P v Q), +elements_in_tree=[['P'], 'v', ['Q']] +2023-10-10 00:25:30,360 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,360 - INFO - print_details - ************************** SUMMARY ************************** +2023-10-10 00:25:30,360 - INFO - print_details - -> number_of_variables: 2 +2023-10-10 00:25:30,361 - INFO - print_details - -> variables_as_array: ['P', 'Q'] +2023-10-10 00:25:30,361 - INFO - print_details - -> provided_statement: (P v Q) +2023-10-10 00:25:30,361 - INFO - print_details - -> elements_in_tree: [['P'], 'v', ['Q']] +2023-10-10 00:25:30,361 - INFO - print_details - ************************** SUMMARY ************************** +2023-10-10 00:25:30,361 - INFO - evaluate_array_as_tree - Starting evaluation of array of elements... +2023-10-10 00:25:30,362 - DEBUG - create_matrix - Creating initial matrix... +2023-10-10 00:25:30,362 - DEBUG - recursive_table - Creating table entries recursively... +2023-10-10 00:25:30,362 - DEBUG - recursive_table - n=2 +2023-10-10 00:25:30,362 - DEBUG - recursive_table - Creating table entries recursively... +2023-10-10 00:25:30,362 - DEBUG - recursive_table - n=1 +2023-10-10 00:25:30,362 - DEBUG - recursive_table - array_table=['T', 'F'] +2023-10-10 00:25:30,362 - DEBUG - recursive_table - Finished creating array of table entries. +2023-10-10 00:25:30,363 - DEBUG - recursive_table - array_table=['TT', 'TF', 'FT', 'FF'] +2023-10-10 00:25:30,363 - DEBUG - recursive_table - Finished creating array of table entries. +2023-10-10 00:25:30,363 - DEBUG - create_matrix - In create_matrix(): new_matrix=[['T', 'T'], ['T', 'F'], ['F', 'T'], ['F', 'F']] +2023-10-10 00:25:30,363 - INFO - create_matrix - Finished creating the initial 'truth' matrix. +2023-10-10 00:25:30,363 - INFO - create_matrix - *** Initial Matrix: [['T', 'T'], ['T', 'F'], ['F', 'T'], ['F', 'F']] *** +2023-10-10 00:25:30,363 - DEBUG - evaluate_array_as_tree - In evaluate_array_as_tree(): +elements_in_tree=[['P'], 'v', ['Q']], +counter=0, +matrix=[['T', 'T'], ['T', 'F'], ['F', 'T'], ['F', 'F']], +variables_as_array=['P', 'Q'] +2023-10-10 00:25:30,364 - DEBUG - evaluate_array - Calling evaluate_array([['P'], 'v', ['Q']], 0, [['T', 'T'], ['T', 'F'], ['F', 'T'], ['F', 'F']], ['P', 'Q'])... +2023-10-10 00:25:30,364 - DEBUG - switch_case - Entering switch_case(v, ['T', 'T', 'F', 'F'], ['T', 'F', 'T', 'F'])... +2023-10-10 00:25:30,364 - DEBUG - disj - In disj. case... +2023-10-10 00:25:30,364 - DEBUG - disjunction - Calling disjunction(['T', 'T', 'F', 'F'], ['T', 'F', 'T', 'F'])... +2023-10-10 00:25:30,364 - DEBUG - disjunction - new_row_values=['T', 'T', 'T', 'F'] +2023-10-10 00:25:30,364 - DEBUG - disjunction - Returning with new row values. +2023-10-10 00:25:30,364 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['P'], 'v', ['Q']])... +2023-10-10 00:25:30,364 - DEBUG - set_new_array_elem - new_array=['PvQ'] +2023-10-10 00:25:30,365 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-10-10 00:25:30,365 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'T', 'T', 'F'], +final_variable_combined=['PvQ'], +matrix=[['T', 'T', 'T'], ['T', 'F', 'T'], ['F', 'T', 'T'], ['F', 'F', 'F']], +variables=['P', 'Q'] +2023-10-10 00:25:30,365 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-10-10 00:25:30,365 - DEBUG - evaluate_array_as_tree - returned_array=['T', 'T', 'T', 'F'], returned_matrix=[['T', 'T', 'T'], ['T', 'F', 'T'], ['F', 'T', 'T'], ['F', 'F', 'F']], all_variables=['P', 'Q', 'PvQ'] +2023-10-10 00:25:30,365 - DEBUG - evaluate_array_as_tree - Finished evaluating array. +2023-10-10 00:25:30,366 - DEBUG - simulate_main - In simulate_main(): +final_value_array=['T', 'T', 'T', 'F'], +returned_matrix=[['T', 'T', 'T'], ['T', 'F', 'T'], ['F', 'T', 'T'], ['F', 'F', 'F']], +all_variables=['P', 'Q', 'PvQ'] +2023-10-10 00:25:30,366 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,366 - INFO - print_details - ************************** EVALUATE ************************** +2023-10-10 00:25:30,366 - INFO - print_details - -> Statement: (P v Q) +2023-10-10 00:25:30,366 - INFO - print_details - -> Final Calculated Array: ['T', 'T', 'T', 'F'] +2023-10-10 00:25:30,367 - INFO - print_details - -> All Variables: ['P', 'Q', 'PvQ'] +2023-10-10 00:25:30,367 - INFO - print_details - -> Final Matrix: [['T', 'T', 'T'], ['T', 'F', 'T'], ['F', 'T', 'T'], ['F', 'F', 'F']] +2023-10-10 00:25:30,367 - INFO - print_details - ************************** EVALUATE ************************** +2023-10-10 00:25:30,367 - INFO - simulate_main - Finished evaluating statement. +2023-10-10 00:25:30,367 - DEBUG - display_matrix - Displaying matrix to console... +2023-10-10 00:25:30,367 - DEBUG - get_number_of_spaces - Calling get_number_of_spaces(2, 0, ['P', 'Q', 'PvQ'])... +2023-10-10 00:25:30,368 - DEBUG - get_number_of_spaces - total_space=16 +2023-10-10 00:25:30,368 - DEBUG - get_number_of_spaces - Finished calculating the total space. +2023-10-10 00:25:30,368 - DEBUG - simulate_main - Returning from simulate_main()... +2023-10-10 00:25:30,369 - INFO - simulate_main - Statement: (P -> (Q ^ R)) +2023-10-10 00:25:30,369 - INFO - simulate_main - Before proceeding, doing checks for unequal brackets and illegal characters. +2023-10-10 00:25:30,369 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets((P -> (Q ^ R)))... +2023-10-10 00:25:30,369 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-10-10 00:25:30,369 - DEBUG - check_for_illegal_characters - Calling check_for_illegal_characters((P -> (Q ^ R))) +2023-10-10 00:25:30,369 - DEBUG - check_for_illegal_characters - ******************** starting input validation ******************* +2023-10-10 00:25:30,369 - DEBUG - validate_input - Calling validate_input(P)... +2023-10-10 00:25:30,370 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,370 - DEBUG - validate_input - Calling validate_input(-)... +2023-10-10 00:25:30,370 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,370 - DEBUG - validate_input - Calling validate_input(>)... +2023-10-10 00:25:30,370 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,370 - DEBUG - validate_input - Calling validate_input(Q)... +2023-10-10 00:25:30,371 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,371 - DEBUG - validate_input - Calling validate_input(^)... +2023-10-10 00:25:30,371 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,371 - DEBUG - validate_input - Calling validate_input(R)... +2023-10-10 00:25:30,371 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,371 - DEBUG - check_for_illegal_characters - ******************** finished input validation ******************* +2023-10-10 00:25:30,371 - INFO - check_for_illegal_characters - PASS: There were no illegal characters found. +2023-10-10 00:25:30,372 - INFO - simulate_main - All checks are valid, proceeding with extracting information from statement. +2023-10-10 00:25:30,372 - INFO - user_input - Processing statement... +2023-10-10 00:25:30,372 - DEBUG - user_input - statement=(P -> (Q ^ R)) +2023-10-10 00:25:30,372 - INFO - analyze_statement - Starting to analyze statement... +2023-10-10 00:25:30,372 - INFO - analyze_statement - The statement is sanitized from any whitespaces. +2023-10-10 00:25:30,372 - DEBUG - analyze_statement - All whitespaces need to be removed, proceeding. +2023-10-10 00:25:30,373 - DEBUG - clean_whitespaces - Calling clean_whitespaces((P -> (Q ^ R)))... +2023-10-10 00:25:30,373 - DEBUG - clean_whitespaces - Finished removing whitespaces: statement=(P->(Q^R)) +2023-10-10 00:25:30,373 - DEBUG - analyze_statement - Finished removing any whitespaces found in statement. Proceeding with finding variables. +2023-10-10 00:25:30,373 - INFO - find_variables - Finding variables in statement... +2023-10-10 00:25:30,373 - DEBUG - find_variables - statement=(P->(Q^R)) +2023-10-10 00:25:30,373 - DEBUG - find_variables - variables_array=['P', 'Q', 'R'] +2023-10-10 00:25:30,374 - INFO - find_variables - Found all variables in statement. +2023-10-10 00:25:30,374 - INFO - find_variables - *** Variables: ['P', 'Q', 'R'] *** +2023-10-10 00:25:30,374 - DEBUG - analyze_statement - variables_arr=['P', 'Q', 'R'] +2023-10-10 00:25:30,374 - INFO - analyze_statement - The statement is converted to an array and any conditionals are sanitized. +2023-10-10 00:25:30,374 - DEBUG - create_array_of_elements - Creating an array from a string... +2023-10-10 00:25:30,374 - DEBUG - create_array_of_elements - Calling create_array_of_elements((P->(Q^R))) +2023-10-10 00:25:30,374 - DEBUG - create_array_of_elements - array_of_elements=['(', 'P', '-', '>', '(', 'Q', '^', 'R', ')', ')'] +2023-10-10 00:25:30,375 - DEBUG - create_array_of_elements - Finished creating array. +2023-10-10 00:25:30,375 - DEBUG - check_conditionals - Calling check_conditionals(['(', 'P', '-', '>', '(', 'Q', '^', 'R', ')', ')'], ['P', 'Q', 'R'])... +2023-10-10 00:25:30,375 - INFO - check_conditionals - PASS: Any conditional symbols present, are in the desired form. +2023-10-10 00:25:30,375 - DEBUG - create_conditionals - Creating one-piece conditionals from single elements. +2023-10-10 00:25:30,375 - DEBUG - create_conditionals - Searching for a '-' in array_of_elements=['(', 'P', '-', '>', '(', 'Q', '^', 'R', ')', ')'] +2023-10-10 00:25:30,375 - DEBUG - create_conditionals - Conditional symbols were found in ['(', 'P', '-', '>', '(', 'Q', '^', 'R', ')', ')'] +2023-10-10 00:25:30,375 - DEBUG - create_conditionals - array_of_elements=['(', 'P', '->', '(', 'Q', '^', 'R', ')', ')'] +2023-10-10 00:25:30,376 - DEBUG - create_conditionals - Finished creating conditionals. +2023-10-10 00:25:30,376 - DEBUG - analyze_statement - In analyze_statement(): +len(variables_arr)=3, +variables_arr=['P', 'Q', 'R'], +array_of_elements=['(', 'P', '->', '(', 'Q', '^', 'R', ')', ')'] +2023-10-10 00:25:30,376 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,376 - INFO - print_details - ************************** ANALYSIS ************************** +2023-10-10 00:25:30,376 - INFO - print_details - -> Number of Variables: 3 +2023-10-10 00:25:30,376 - INFO - print_details - -> Variables: ['P', 'Q', 'R'] +2023-10-10 00:25:30,376 - INFO - print_details - -> Array of Elements: ['(', 'P', '->', '(', 'Q', '^', 'R', ')', ')'] +2023-10-10 00:25:30,377 - INFO - print_details - ************************** ANALYSIS ************************** +2023-10-10 00:25:30,377 - INFO - analyze_statement - Analyzing concluded. +2023-10-10 00:25:30,377 - INFO - parse_array - Starting to parse array... +2023-10-10 00:25:30,377 - DEBUG - remove_brackets_around_variables - Removing brackets around standalone variables... +2023-10-10 00:25:30,377 - DEBUG - remove_brackets_around_variables - arr=['(', 'P', '->', '(', 'Q', '^', 'R', ')', ')'] +2023-10-10 00:25:30,377 - DEBUG - remove_brackets_around_variables - Finished removing all brackets around variables. +2023-10-10 00:25:30,377 - DEBUG - parse_array - In parse_array(): elements_second=['(', 'P', '->', '(', 'Q', '^', 'R', ')', ')'] +2023-10-10 00:25:30,378 - DEBUG - add_brackets_around_unary_connectives - Adding brackets around unary connectives... +2023-10-10 00:25:30,378 - DEBUG - add_brackets_around_unary_connectives - arr=['(', 'P', '->', '(', 'Q', '^', 'R', ')', ')'] +2023-10-10 00:25:30,378 - DEBUG - add_brackets_around_unary_connectives - Finished adding brackets around all unary connectives. +2023-10-10 00:25:30,378 - DEBUG - parse_array - In parse_array(): elements_second=['(', 'P', '->', '(', 'Q', '^', 'R', ')', ')'] +2023-10-10 00:25:30,378 - INFO - parse_array - Final checks are ran before parsing concludes. +2023-10-10 00:25:30,378 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets(['(', 'P', '->', '(', 'Q', '^', 'R', ')', ')'])... +2023-10-10 00:25:30,378 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-10-10 00:25:30,378 - DEBUG - parse - Calling parse(['(', 'P', '->', '(', 'Q', '^', 'R', ')', ')'])... +2023-10-10 00:25:30,379 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', 'P', '->', '(', 'Q', '^', 'R', ')', ')'])... +2023-10-10 00:25:30,379 - DEBUG - remove_outer_brackets - array=['P', '->', '(', 'Q', '^', 'R', ')'] +2023-10-10 00:25:30,379 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-10-10 00:25:30,379 - DEBUG - parse - In parse(): arr=['P', '->', '(', 'Q', '^', 'R', ')'] +2023-10-10 00:25:30,379 - DEBUG - find_connective - Calling find_connectives(['P', '->', '(', 'Q', '^', 'R', ')'])... +2023-10-10 00:25:30,379 - DEBUG - find_connective - In find_connective(): elem=->, i=1 +2023-10-10 00:25:30,379 - DEBUG - find_connective - Found connective. +2023-10-10 00:25:30,380 - DEBUG - parse - Calling parse(['(', 'Q', '^', 'R', ')'])... +2023-10-10 00:25:30,380 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', 'Q', '^', 'R', ')'])... +2023-10-10 00:25:30,380 - DEBUG - remove_outer_brackets - array=['Q', '^', 'R'] +2023-10-10 00:25:30,380 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-10-10 00:25:30,380 - DEBUG - parse - In parse(): arr=['Q', '^', 'R'] +2023-10-10 00:25:30,380 - DEBUG - find_connective - Calling find_connectives(['Q', '^', 'R'])... +2023-10-10 00:25:30,380 - DEBUG - find_connective - In find_connective(): elem=^, i=1 +2023-10-10 00:25:30,381 - DEBUG - find_connective - Found connective. +2023-10-10 00:25:30,381 - DEBUG - parse - temp_array=[['Q'], '^', ['R']] +2023-10-10 00:25:30,381 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-10-10 00:25:30,381 - DEBUG - parse - temp_array=[['P'], '->', [['Q'], '^', ['R']]] +2023-10-10 00:25:30,381 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-10-10 00:25:30,381 - DEBUG - parse_array - tree_structured_array=[['P'], '->', [['Q'], '^', ['R']]] +2023-10-10 00:25:30,381 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,382 - INFO - print_details - *************************** PARSE *************************** +2023-10-10 00:25:30,382 - INFO - print_details - -> Parsed Array: [['P'], '->', [['Q'], '^', ['R']]] +2023-10-10 00:25:30,382 - INFO - print_details - *************************** PARSE *************************** +2023-10-10 00:25:30,382 - INFO - parse_array - Finished parsing array. +2023-10-10 00:25:30,382 - DEBUG - user_input - In user_input(): +number_of_variables=3, +variables_as_array=['P', 'Q', 'R'], +statement=(P -> (Q ^ R)), +new_elements=[['P'], '->', [['Q'], '^', ['R']]]. +2023-10-10 00:25:30,382 - INFO - user_input - Gathered all information needed including variables and parsed array. +2023-10-10 00:25:30,383 - DEBUG - simulate_main - In simulate_main(): +number_of_variables=3, +variables_as_array=['P', 'Q', 'R'], +provided_statement=(P -> (Q ^ R)), +elements_in_tree=[['P'], '->', [['Q'], '^', ['R']]] +2023-10-10 00:25:30,383 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,383 - INFO - print_details - ************************** SUMMARY ************************** +2023-10-10 00:25:30,383 - INFO - print_details - -> number_of_variables: 3 +2023-10-10 00:25:30,383 - INFO - print_details - -> variables_as_array: ['P', 'Q', 'R'] +2023-10-10 00:25:30,383 - INFO - print_details - -> provided_statement: (P -> (Q ^ R)) +2023-10-10 00:25:30,384 - INFO - print_details - -> elements_in_tree: [['P'], '->', [['Q'], '^', ['R']]] +2023-10-10 00:25:30,384 - INFO - print_details - ************************** SUMMARY ************************** +2023-10-10 00:25:30,384 - INFO - evaluate_array_as_tree - Starting evaluation of array of elements... +2023-10-10 00:25:30,384 - DEBUG - create_matrix - Creating initial matrix... +2023-10-10 00:25:30,384 - DEBUG - recursive_table - Creating table entries recursively... +2023-10-10 00:25:30,384 - DEBUG - recursive_table - n=3 +2023-10-10 00:25:30,384 - DEBUG - recursive_table - Creating table entries recursively... +2023-10-10 00:25:30,385 - DEBUG - recursive_table - n=2 +2023-10-10 00:25:30,385 - DEBUG - recursive_table - Creating table entries recursively... +2023-10-10 00:25:30,385 - DEBUG - recursive_table - n=1 +2023-10-10 00:25:30,385 - DEBUG - recursive_table - array_table=['T', 'F'] +2023-10-10 00:25:30,385 - DEBUG - recursive_table - Finished creating array of table entries. +2023-10-10 00:25:30,385 - DEBUG - recursive_table - array_table=['TT', 'TF', 'FT', 'FF'] +2023-10-10 00:25:30,385 - DEBUG - recursive_table - Finished creating array of table entries. +2023-10-10 00:25:30,386 - DEBUG - recursive_table - array_table=['TTT', 'TTF', 'TFT', 'TFF', 'FTT', 'FTF', 'FFT', 'FFF'] +2023-10-10 00:25:30,386 - DEBUG - recursive_table - Finished creating array of table entries. +2023-10-10 00:25:30,386 - DEBUG - create_matrix - In create_matrix(): new_matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']] +2023-10-10 00:25:30,386 - INFO - create_matrix - Finished creating the initial 'truth' matrix. +2023-10-10 00:25:30,386 - INFO - create_matrix - *** Initial Matrix: [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']] *** +2023-10-10 00:25:30,386 - DEBUG - evaluate_array_as_tree - In evaluate_array_as_tree(): +elements_in_tree=[['P'], '->', [['Q'], '^', ['R']]], +counter=0, +matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], +variables_as_array=['P', 'Q', 'R'] +2023-10-10 00:25:30,387 - DEBUG - evaluate_array - Calling evaluate_array([['P'], '->', [['Q'], '^', ['R']]], 0, [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['P', 'Q', 'R'])... +2023-10-10 00:25:30,387 - DEBUG - evaluate_array - Calling evaluate_array([['Q'], '^', ['R']], 1, [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['P', 'Q', 'R'])... +2023-10-10 00:25:30,387 - DEBUG - switch_case - Entering switch_case(^, ['T', 'T', 'F', 'F', 'T', 'T', 'F', 'F'], ['T', 'F', 'T', 'F', 'T', 'F', 'T', 'F'])... +2023-10-10 00:25:30,387 - DEBUG - conj - In conj. case... +2023-10-10 00:25:30,387 - DEBUG - conjunction - Calling conjunction(['T', 'T', 'F', 'F', 'T', 'T', 'F', 'F'], ['T', 'F', 'T', 'F', 'T', 'F', 'T', 'F'])... +2023-10-10 00:25:30,388 - DEBUG - conjunction - new_row_values=['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'] +2023-10-10 00:25:30,388 - DEBUG - conjunction - Returning with new row values. +2023-10-10 00:25:30,388 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['Q'], '^', ['R']])... +2023-10-10 00:25:30,388 - DEBUG - set_new_array_elem - new_array=['Q^R'] +2023-10-10 00:25:30,388 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-10-10 00:25:30,388 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'], +final_variable_combined=['Q^R'], +matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], +variables=['P', 'Q', 'R'] +2023-10-10 00:25:30,389 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-10-10 00:25:30,389 - DEBUG - add_array_to_matrix - Calling add_array_to_matrix([['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'], ['P', 'Q', 'R'], ['Q^R'])... +2023-10-10 00:25:30,389 - DEBUG - add_array_to_matrix - variables=['P', 'Q', 'R', 'Q^R'] +2023-10-10 00:25:30,389 - DEBUG - add_array_to_matrix - Added array to matrix. +2023-10-10 00:25:30,389 - DEBUG - switch_case - Entering switch_case(->, ['T', 'T', 'T', 'T', 'F', 'F', 'F', 'F'], ['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'])... +2023-10-10 00:25:30,390 - DEBUG - cond - In cond. case... +2023-10-10 00:25:30,390 - DEBUG - conditional - Calling conditional(['T', 'T', 'T', 'T', 'F', 'F', 'F', 'F'], ['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'])... +2023-10-10 00:25:30,390 - DEBUG - conditional - new_row_values=['T', 'F', 'F', 'F', 'T', 'T', 'T', 'T'] +2023-10-10 00:25:30,390 - DEBUG - conditional - Returning with new row values. +2023-10-10 00:25:30,390 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['P'], '->', ['Q^R']])... +2023-10-10 00:25:30,390 - DEBUG - set_new_array_elem - new_array=['P->(Q^R)'] +2023-10-10 00:25:30,390 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-10-10 00:25:30,391 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'F', 'F', 'F', 'T', 'T', 'T', 'T'], +final_variable_combined=['P->(Q^R)'], +matrix=[['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'F'], ['T', 'F', 'T', 'F', 'F'], ['T', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'T', 'T'], ['F', 'T', 'F', 'F', 'T'], ['F', 'F', 'T', 'F', 'T'], ['F', 'F', 'F', 'F', 'T']], +variables=['P', 'Q', 'R', 'Q^R'] +2023-10-10 00:25:30,391 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-10-10 00:25:30,391 - DEBUG - evaluate_array_as_tree - returned_array=['T', 'F', 'F', 'F', 'T', 'T', 'T', 'T'], returned_matrix=[['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'F'], ['T', 'F', 'T', 'F', 'F'], ['T', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'T', 'T'], ['F', 'T', 'F', 'F', 'T'], ['F', 'F', 'T', 'F', 'T'], ['F', 'F', 'F', 'F', 'T']], all_variables=['P', 'Q', 'R', 'Q^R', 'P->(Q^R)'] +2023-10-10 00:25:30,391 - DEBUG - evaluate_array_as_tree - Finished evaluating array. +2023-10-10 00:25:30,391 - DEBUG - simulate_main - In simulate_main(): +final_value_array=['T', 'F', 'F', 'F', 'T', 'T', 'T', 'T'], +returned_matrix=[['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'F'], ['T', 'F', 'T', 'F', 'F'], ['T', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'T', 'T'], ['F', 'T', 'F', 'F', 'T'], ['F', 'F', 'T', 'F', 'T'], ['F', 'F', 'F', 'F', 'T']], +all_variables=['P', 'Q', 'R', 'Q^R', 'P->(Q^R)'] +2023-10-10 00:25:30,392 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,392 - INFO - print_details - ************************** EVALUATE ************************** +2023-10-10 00:25:30,392 - INFO - print_details - -> Statement: (P -> (Q ^ R)) +2023-10-10 00:25:30,393 - INFO - print_details - -> Final Calculated Array: ['T', 'F', 'F', 'F', 'T', 'T', 'T', 'T'] +2023-10-10 00:25:30,393 - INFO - print_details - -> All Variables: ['P', 'Q', 'R', 'Q^R', 'P->(Q^R)'] +2023-10-10 00:25:30,393 - INFO - print_details - -> Final Matrix: [['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'F'], ['T', 'F', 'T', 'F', 'F'], ['T', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'T', 'T'], ['F', 'T', 'F', 'F', 'T'], ['F', 'F', 'T', 'F', 'T'], ['F', 'F', 'F', 'F', 'T']] +2023-10-10 00:25:30,393 - INFO - print_details - ************************** EVALUATE ************************** +2023-10-10 00:25:30,393 - INFO - simulate_main - Finished evaluating statement. +2023-10-10 00:25:30,393 - DEBUG - display_matrix - Displaying matrix to console... +2023-10-10 00:25:30,394 - DEBUG - get_number_of_spaces - Calling get_number_of_spaces(3, 1, ['P', 'Q', 'R', 'Q^R', 'P->(Q^R)'])... +2023-10-10 00:25:30,394 - DEBUG - get_number_of_spaces - total_space=31 +2023-10-10 00:25:30,394 - DEBUG - get_number_of_spaces - Finished calculating the total space. +2023-10-10 00:25:30,395 - DEBUG - simulate_main - Returning from simulate_main()... +2023-10-10 00:25:30,395 - INFO - simulate_main - Statement: ((P -> Q) <-> ((!Q) -> (!P))) +2023-10-10 00:25:30,396 - INFO - simulate_main - Before proceeding, doing checks for unequal brackets and illegal characters. +2023-10-10 00:25:30,396 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets(((P -> Q) <-> ((!Q) -> (!P))))... +2023-10-10 00:25:30,396 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-10-10 00:25:30,396 - DEBUG - check_for_illegal_characters - Calling check_for_illegal_characters(((P -> Q) <-> ((!Q) -> (!P)))) +2023-10-10 00:25:30,396 - DEBUG - check_for_illegal_characters - ******************** starting input validation ******************* +2023-10-10 00:25:30,396 - DEBUG - validate_input - Calling validate_input(P)... +2023-10-10 00:25:30,396 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,397 - DEBUG - validate_input - Calling validate_input(-)... +2023-10-10 00:25:30,397 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,397 - DEBUG - validate_input - Calling validate_input(>)... +2023-10-10 00:25:30,397 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,397 - DEBUG - validate_input - Calling validate_input(Q)... +2023-10-10 00:25:30,397 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,397 - DEBUG - validate_input - Calling validate_input(<)... +2023-10-10 00:25:30,397 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,398 - DEBUG - validate_input - Calling validate_input(-)... +2023-10-10 00:25:30,398 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,398 - DEBUG - validate_input - Calling validate_input(>)... +2023-10-10 00:25:30,398 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,398 - DEBUG - validate_input - Calling validate_input(!)... +2023-10-10 00:25:30,398 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,398 - DEBUG - validate_input - Calling validate_input(Q)... +2023-10-10 00:25:30,399 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,399 - DEBUG - validate_input - Calling validate_input(-)... +2023-10-10 00:25:30,399 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,399 - DEBUG - validate_input - Calling validate_input(>)... +2023-10-10 00:25:30,399 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,399 - DEBUG - validate_input - Calling validate_input(!)... +2023-10-10 00:25:30,399 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,400 - DEBUG - validate_input - Calling validate_input(P)... +2023-10-10 00:25:30,400 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-10-10 00:25:30,400 - DEBUG - check_for_illegal_characters - ******************** finished input validation ******************* +2023-10-10 00:25:30,400 - INFO - check_for_illegal_characters - PASS: There were no illegal characters found. +2023-10-10 00:25:30,400 - INFO - simulate_main - All checks are valid, proceeding with extracting information from statement. +2023-10-10 00:25:30,400 - INFO - user_input - Processing statement... +2023-10-10 00:25:30,401 - DEBUG - user_input - statement=((P -> Q) <-> ((!Q) -> (!P))) +2023-10-10 00:25:30,401 - INFO - analyze_statement - Starting to analyze statement... +2023-10-10 00:25:30,401 - INFO - analyze_statement - The statement is sanitized from any whitespaces. +2023-10-10 00:25:30,402 - DEBUG - analyze_statement - All whitespaces need to be removed, proceeding. +2023-10-10 00:25:30,402 - DEBUG - clean_whitespaces - Calling clean_whitespaces(((P -> Q) <-> ((!Q) -> (!P))))... +2023-10-10 00:25:30,402 - DEBUG - clean_whitespaces - Finished removing whitespaces: statement=((P->Q)<->((!Q)->(!P))) +2023-10-10 00:25:30,402 - DEBUG - analyze_statement - Finished removing any whitespaces found in statement. Proceeding with finding variables. +2023-10-10 00:25:30,403 - INFO - find_variables - Finding variables in statement... +2023-10-10 00:25:30,403 - DEBUG - find_variables - statement=((P->Q)<->((!Q)->(!P))) +2023-10-10 00:25:30,403 - DEBUG - find_variables - variables_array=['P', 'Q'] +2023-10-10 00:25:30,403 - INFO - find_variables - Found all variables in statement. +2023-10-10 00:25:30,403 - INFO - find_variables - *** Variables: ['P', 'Q'] *** +2023-10-10 00:25:30,404 - DEBUG - analyze_statement - variables_arr=['P', 'Q'] +2023-10-10 00:25:30,404 - INFO - analyze_statement - The statement is converted to an array and any conditionals are sanitized. +2023-10-10 00:25:30,404 - DEBUG - create_array_of_elements - Creating an array from a string... +2023-10-10 00:25:30,404 - DEBUG - create_array_of_elements - Calling create_array_of_elements(((P->Q)<->((!Q)->(!P)))) +2023-10-10 00:25:30,404 - DEBUG - create_array_of_elements - array_of_elements=['(', '(', 'P', '-', '>', 'Q', ')', '<', '-', '>', '(', '(', '!', 'Q', ')', '-', '>', '(', '!', 'P', ')', ')', ')'] +2023-10-10 00:25:30,404 - DEBUG - create_array_of_elements - Finished creating array. +2023-10-10 00:25:30,405 - DEBUG - check_conditionals - Calling check_conditionals(['(', '(', 'P', '-', '>', 'Q', ')', '<', '-', '>', '(', '(', '!', 'Q', ')', '-', '>', '(', '!', 'P', ')', ')', ')'], ['P', 'Q'])... +2023-10-10 00:25:30,405 - INFO - check_conditionals - PASS: Any conditional symbols present, are in the desired form. +2023-10-10 00:25:30,405 - DEBUG - create_conditionals - Creating one-piece conditionals from single elements. +2023-10-10 00:25:30,405 - DEBUG - create_conditionals - Searching for a '-' in array_of_elements=['(', '(', 'P', '-', '>', 'Q', ')', '<', '-', '>', '(', '(', '!', 'Q', ')', '-', '>', '(', '!', 'P', ')', ')', ')'] +2023-10-10 00:25:30,405 - DEBUG - create_conditionals - Conditional symbols were found in ['(', '(', 'P', '-', '>', 'Q', ')', '<', '-', '>', '(', '(', '!', 'Q', ')', '-', '>', '(', '!', 'P', ')', ')', ')'] +2023-10-10 00:25:30,405 - DEBUG - create_conditionals - array_of_elements=['(', '(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')', ')'] +2023-10-10 00:25:30,406 - DEBUG - create_conditionals - Finished creating conditionals. +2023-10-10 00:25:30,406 - DEBUG - analyze_statement - In analyze_statement(): +len(variables_arr)=2, +variables_arr=['P', 'Q'], +array_of_elements=['(', '(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')', ')'] +2023-10-10 00:25:30,406 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,406 - INFO - print_details - ************************** ANALYSIS ************************** +2023-10-10 00:25:30,406 - INFO - print_details - -> Number of Variables: 2 +2023-10-10 00:25:30,406 - INFO - print_details - -> Variables: ['P', 'Q'] +2023-10-10 00:25:30,407 - INFO - print_details - -> Array of Elements: ['(', '(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')', ')'] +2023-10-10 00:25:30,407 - INFO - print_details - ************************** ANALYSIS ************************** +2023-10-10 00:25:30,407 - INFO - analyze_statement - Analyzing concluded. +2023-10-10 00:25:30,407 - INFO - parse_array - Starting to parse array... +2023-10-10 00:25:30,407 - DEBUG - remove_brackets_around_variables - Removing brackets around standalone variables... +2023-10-10 00:25:30,407 - DEBUG - remove_brackets_around_variables - arr=['(', '(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')', ')'] +2023-10-10 00:25:30,407 - DEBUG - remove_brackets_around_variables - Finished removing all brackets around variables. +2023-10-10 00:25:30,408 - DEBUG - parse_array - In parse_array(): elements_second=['(', '(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')', ')'] +2023-10-10 00:25:30,408 - DEBUG - add_brackets_around_unary_connectives - Adding brackets around unary connectives... +2023-10-10 00:25:30,408 - DEBUG - add_brackets_around_unary_connectives - arr=['(', '(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')', ')'] +2023-10-10 00:25:30,408 - DEBUG - add_brackets_around_unary_connectives - Finished adding brackets around all unary connectives. +2023-10-10 00:25:30,408 - DEBUG - parse_array - In parse_array(): elements_second=['(', '(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')', ')'] +2023-10-10 00:25:30,408 - INFO - parse_array - Final checks are ran before parsing concludes. +2023-10-10 00:25:30,409 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets(['(', '(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')', ')'])... +2023-10-10 00:25:30,409 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-10-10 00:25:30,409 - DEBUG - parse - Calling parse(['(', '(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')', ')'])... +2023-10-10 00:25:30,409 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', '(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')', ')'])... +2023-10-10 00:25:30,409 - DEBUG - remove_outer_brackets - array=['(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')'] +2023-10-10 00:25:30,409 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-10-10 00:25:30,410 - DEBUG - parse - In parse(): arr=['(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')'] +2023-10-10 00:25:30,410 - DEBUG - find_connective - Calling find_connectives(['(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')'])... +2023-10-10 00:25:30,410 - DEBUG - find_connective - In find_connective(): elem=<->, i=5 +2023-10-10 00:25:30,410 - DEBUG - find_connective - Found connective. +2023-10-10 00:25:30,410 - DEBUG - parse - Calling parse(['(', 'P', '->', 'Q', ')'])... +2023-10-10 00:25:30,410 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', 'P', '->', 'Q', ')'])... +2023-10-10 00:25:30,411 - DEBUG - remove_outer_brackets - array=['P', '->', 'Q'] +2023-10-10 00:25:30,411 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-10-10 00:25:30,411 - DEBUG - parse - In parse(): arr=['P', '->', 'Q'] +2023-10-10 00:25:30,411 - DEBUG - find_connective - Calling find_connectives(['P', '->', 'Q'])... +2023-10-10 00:25:30,411 - DEBUG - find_connective - In find_connective(): elem=->, i=1 +2023-10-10 00:25:30,411 - DEBUG - find_connective - Found connective. +2023-10-10 00:25:30,412 - DEBUG - parse - temp_array=[['P'], '->', ['Q']] +2023-10-10 00:25:30,412 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-10-10 00:25:30,412 - DEBUG - parse - Calling parse(['(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')'])... +2023-10-10 00:25:30,412 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')'])... +2023-10-10 00:25:30,412 - DEBUG - remove_outer_brackets - array=['(', '!', 'Q', ')', '->', '(', '!', 'P', ')'] +2023-10-10 00:25:30,412 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-10-10 00:25:30,412 - DEBUG - parse - In parse(): arr=['(', '!', 'Q', ')', '->', '(', '!', 'P', ')'] +2023-10-10 00:25:30,413 - DEBUG - find_connective - Calling find_connectives(['(', '!', 'Q', ')', '->', '(', '!', 'P', ')'])... +2023-10-10 00:25:30,413 - DEBUG - find_connective - In find_connective(): elem=->, i=4 +2023-10-10 00:25:30,413 - DEBUG - find_connective - Found connective. +2023-10-10 00:25:30,413 - DEBUG - parse - Calling parse(['(', '!', 'Q', ')'])... +2023-10-10 00:25:30,413 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', '!', 'Q', ')'])... +2023-10-10 00:25:30,413 - DEBUG - remove_outer_brackets - array=['!', 'Q'] +2023-10-10 00:25:30,413 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-10-10 00:25:30,414 - DEBUG - parse - In parse(): arr=['!', 'Q'] +2023-10-10 00:25:30,414 - DEBUG - parse - temp_arr=['!', 'Q'] +2023-10-10 00:25:30,414 - DEBUG - parse - Returning with parsed list of unary connectives. +2023-10-10 00:25:30,414 - DEBUG - parse - Calling parse(['(', '!', 'P', ')'])... +2023-10-10 00:25:30,414 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', '!', 'P', ')'])... +2023-10-10 00:25:30,414 - DEBUG - remove_outer_brackets - array=['!', 'P'] +2023-10-10 00:25:30,414 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-10-10 00:25:30,414 - DEBUG - parse - In parse(): arr=['!', 'P'] +2023-10-10 00:25:30,415 - DEBUG - parse - temp_arr=['!', 'P'] +2023-10-10 00:25:30,415 - DEBUG - parse - Returning with parsed list of unary connectives. +2023-10-10 00:25:30,415 - DEBUG - parse - temp_array=[['!', 'Q'], '->', ['!', 'P']] +2023-10-10 00:25:30,415 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-10-10 00:25:30,415 - DEBUG - parse - temp_array=[[['P'], '->', ['Q']], '<->', [['!', 'Q'], '->', ['!', 'P']]] +2023-10-10 00:25:30,415 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-10-10 00:25:30,416 - DEBUG - parse_array - tree_structured_array=[[['P'], '->', ['Q']], '<->', [['!', 'Q'], '->', ['!', 'P']]] +2023-10-10 00:25:30,416 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,416 - INFO - print_details - *************************** PARSE *************************** +2023-10-10 00:25:30,416 - INFO - print_details - -> Parsed Array: [[['P'], '->', ['Q']], '<->', [['!', 'Q'], '->', ['!', 'P']]] +2023-10-10 00:25:30,416 - INFO - print_details - *************************** PARSE *************************** +2023-10-10 00:25:30,416 - INFO - parse_array - Finished parsing array. +2023-10-10 00:25:30,417 - DEBUG - user_input - In user_input(): +number_of_variables=2, +variables_as_array=['P', 'Q'], +statement=((P -> Q) <-> ((!Q) -> (!P))), +new_elements=[[['P'], '->', ['Q']], '<->', [['!', 'Q'], '->', ['!', 'P']]]. +2023-10-10 00:25:30,417 - INFO - user_input - Gathered all information needed including variables and parsed array. +2023-10-10 00:25:30,417 - DEBUG - simulate_main - In simulate_main(): +number_of_variables=2, +variables_as_array=['P', 'Q'], +provided_statement=((P -> Q) <-> ((!Q) -> (!P))), +elements_in_tree=[[['P'], '->', ['Q']], '<->', [['!', 'Q'], '->', ['!', 'P']]] +2023-10-10 00:25:30,417 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,418 - INFO - print_details - ************************** SUMMARY ************************** +2023-10-10 00:25:30,418 - INFO - print_details - -> number_of_variables: 2 +2023-10-10 00:25:30,418 - INFO - print_details - -> variables_as_array: ['P', 'Q'] +2023-10-10 00:25:30,418 - INFO - print_details - -> provided_statement: ((P -> Q) <-> ((!Q) -> (!P))) +2023-10-10 00:25:30,418 - INFO - print_details - -> elements_in_tree: [[['P'], '->', ['Q']], '<->', [['!', 'Q'], '->', ['!', 'P']]] +2023-10-10 00:25:30,418 - INFO - print_details - ************************** SUMMARY ************************** +2023-10-10 00:25:30,418 - INFO - evaluate_array_as_tree - Starting evaluation of array of elements... +2023-10-10 00:25:30,418 - DEBUG - create_matrix - Creating initial matrix... +2023-10-10 00:25:30,419 - DEBUG - recursive_table - Creating table entries recursively... +2023-10-10 00:25:30,419 - DEBUG - recursive_table - n=2 +2023-10-10 00:25:30,419 - DEBUG - recursive_table - Creating table entries recursively... +2023-10-10 00:25:30,419 - DEBUG - recursive_table - n=1 +2023-10-10 00:25:30,419 - DEBUG - recursive_table - array_table=['T', 'F'] +2023-10-10 00:25:30,419 - DEBUG - recursive_table - Finished creating array of table entries. +2023-10-10 00:25:30,419 - DEBUG - recursive_table - array_table=['TT', 'TF', 'FT', 'FF'] +2023-10-10 00:25:30,419 - DEBUG - recursive_table - Finished creating array of table entries. +2023-10-10 00:25:30,420 - DEBUG - create_matrix - In create_matrix(): new_matrix=[['T', 'T'], ['T', 'F'], ['F', 'T'], ['F', 'F']] +2023-10-10 00:25:30,420 - INFO - create_matrix - Finished creating the initial 'truth' matrix. +2023-10-10 00:25:30,420 - INFO - create_matrix - *** Initial Matrix: [['T', 'T'], ['T', 'F'], ['F', 'T'], ['F', 'F']] *** +2023-10-10 00:25:30,420 - DEBUG - evaluate_array_as_tree - In evaluate_array_as_tree(): +elements_in_tree=[[['P'], '->', ['Q']], '<->', [['!', 'Q'], '->', ['!', 'P']]], +counter=0, +matrix=[['T', 'T'], ['T', 'F'], ['F', 'T'], ['F', 'F']], +variables_as_array=['P', 'Q'] +2023-10-10 00:25:30,420 - DEBUG - evaluate_array - Calling evaluate_array([[['P'], '->', ['Q']], '<->', [['!', 'Q'], '->', ['!', 'P']]], 0, [['T', 'T'], ['T', 'F'], ['F', 'T'], ['F', 'F']], ['P', 'Q'])... +2023-10-10 00:25:30,421 - DEBUG - evaluate_array - Calling evaluate_array([['P'], '->', ['Q']], 1, [['T', 'T'], ['T', 'F'], ['F', 'T'], ['F', 'F']], ['P', 'Q'])... +2023-10-10 00:25:30,421 - DEBUG - switch_case - Entering switch_case(->, ['T', 'T', 'F', 'F'], ['T', 'F', 'T', 'F'])... +2023-10-10 00:25:30,421 - DEBUG - cond - In cond. case... +2023-10-10 00:25:30,421 - DEBUG - conditional - Calling conditional(['T', 'T', 'F', 'F'], ['T', 'F', 'T', 'F'])... +2023-10-10 00:25:30,422 - DEBUG - conditional - new_row_values=['T', 'F', 'T', 'T'] +2023-10-10 00:25:30,422 - DEBUG - conditional - Returning with new row values. +2023-10-10 00:25:30,422 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['P'], '->', ['Q']])... +2023-10-10 00:25:30,422 - DEBUG - set_new_array_elem - new_array=['P->Q'] +2023-10-10 00:25:30,422 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-10-10 00:25:30,422 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'F', 'T', 'T'], +final_variable_combined=['P->Q'], +matrix=[['T', 'T'], ['T', 'F'], ['F', 'T'], ['F', 'F']], +variables=['P', 'Q'] +2023-10-10 00:25:30,423 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-10-10 00:25:30,423 - DEBUG - add_array_to_matrix - Calling add_array_to_matrix([['T', 'T'], ['T', 'F'], ['F', 'T'], ['F', 'F']], ['T', 'F', 'T', 'T'], ['P', 'Q'], ['P->Q'])... +2023-10-10 00:25:30,423 - DEBUG - add_array_to_matrix - variables=['P', 'Q', 'P->Q'] +2023-10-10 00:25:30,423 - DEBUG - add_array_to_matrix - Added array to matrix. +2023-10-10 00:25:30,424 - DEBUG - evaluate_array - Calling evaluate_array([['!', 'Q'], '->', ['!', 'P']], 1, [['T', 'T', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'F', 'T']], ['P', 'Q', 'P->Q'])... +2023-10-10 00:25:30,424 - DEBUG - evaluate_array - Calling evaluate_array(['!', 'Q'], 2, [['T', 'T', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'F', 'T']], ['P', 'Q', 'P->Q'])... +2023-10-10 00:25:30,424 - DEBUG - switch_case - Entering switch_case(!, ['T', 'F', 'T', 'T'], ['T', 'F', 'T', 'F'])... +2023-10-10 00:25:30,424 - DEBUG - neg - In neg. case... +2023-10-10 00:25:30,424 - DEBUG - negation - Calling negation(['T', 'F', 'T', 'T'])... +2023-10-10 00:25:30,425 - DEBUG - negation - new_row_values=['F', 'T', 'F', 'F'] +2023-10-10 00:25:30,425 - DEBUG - negation - Returning with new row values. +2023-10-10 00:25:30,425 - DEBUG - set_new_array_elem - Calling set_new_array_elem(['_', '!', 'Q'])... +2023-10-10 00:25:30,425 - DEBUG - set_new_array_elem - new_array=['!Q'] +2023-10-10 00:25:30,425 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-10-10 00:25:30,425 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['F', 'T', 'F', 'F'], +final_variable_combined=['!Q'], +matrix=[['T', 'T', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'F', 'T']], +variables=['P', 'Q', 'P->Q'] +2023-10-10 00:25:30,426 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-10-10 00:25:30,426 - DEBUG - add_array_to_matrix - Calling add_array_to_matrix([['T', 'T', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'F', 'T']], ['F', 'T', 'F', 'F'], ['P', 'Q', 'P->Q'], ['!Q'])... +2023-10-10 00:25:30,426 - DEBUG - add_array_to_matrix - variables=['P', 'Q', 'P->Q', '!Q'] +2023-10-10 00:25:30,426 - DEBUG - add_array_to_matrix - Added array to matrix. +2023-10-10 00:25:30,426 - DEBUG - evaluate_array - Calling evaluate_array(['!', 'P'], 2, [['T', 'T', 'T', 'F'], ['T', 'F', 'F', 'T'], ['F', 'T', 'T', 'F'], ['F', 'F', 'T', 'F']], ['P', 'Q', 'P->Q', '!Q'])... +2023-10-10 00:25:30,426 - DEBUG - switch_case - Entering switch_case(!, ['F', 'T', 'F', 'F'], ['T', 'T', 'F', 'F'])... +2023-10-10 00:25:30,426 - DEBUG - neg - In neg. case... +2023-10-10 00:25:30,427 - DEBUG - negation - Calling negation(['F', 'T', 'F', 'F'])... +2023-10-10 00:25:30,427 - DEBUG - negation - new_row_values=['T', 'F', 'T', 'T'] +2023-10-10 00:25:30,427 - DEBUG - negation - Returning with new row values. +2023-10-10 00:25:30,427 - DEBUG - set_new_array_elem - Calling set_new_array_elem(['_', '!', 'P'])... +2023-10-10 00:25:30,427 - DEBUG - set_new_array_elem - new_array=['!P'] +2023-10-10 00:25:30,427 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-10-10 00:25:30,427 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'F', 'T', 'T'], +final_variable_combined=['!P'], +matrix=[['T', 'T', 'T', 'F'], ['T', 'F', 'F', 'T'], ['F', 'T', 'T', 'F'], ['F', 'F', 'T', 'F']], +variables=['P', 'Q', 'P->Q', '!Q'] +2023-10-10 00:25:30,428 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-10-10 00:25:30,428 - DEBUG - add_array_to_matrix - Calling add_array_to_matrix([['T', 'T', 'T', 'F'], ['T', 'F', 'F', 'T'], ['F', 'T', 'T', 'F'], ['F', 'F', 'T', 'F']], ['T', 'F', 'T', 'T'], ['P', 'Q', 'P->Q', '!Q'], ['!P'])... +2023-10-10 00:25:30,428 - DEBUG - add_array_to_matrix - variables=['P', 'Q', 'P->Q', '!Q', '!P'] +2023-10-10 00:25:30,428 - DEBUG - add_array_to_matrix - Added array to matrix. +2023-10-10 00:25:30,428 - DEBUG - switch_case - Entering switch_case(->, ['F', 'T', 'F', 'F'], ['T', 'F', 'T', 'T'])... +2023-10-10 00:25:30,429 - DEBUG - cond - In cond. case... +2023-10-10 00:25:30,429 - DEBUG - conditional - Calling conditional(['F', 'T', 'F', 'F'], ['T', 'F', 'T', 'T'])... +2023-10-10 00:25:30,429 - DEBUG - conditional - new_row_values=['T', 'F', 'T', 'T'] +2023-10-10 00:25:30,429 - DEBUG - conditional - Returning with new row values. +2023-10-10 00:25:30,429 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['!Q'], '->', ['!P']])... +2023-10-10 00:25:30,430 - DEBUG - set_new_array_elem - new_array=['(!Q)->(!P)'] +2023-10-10 00:25:30,430 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-10-10 00:25:30,430 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'F', 'T', 'T'], +final_variable_combined=['(!Q)->(!P)'], +matrix=[['T', 'T', 'T', 'F', 'T'], ['T', 'F', 'F', 'T', 'F'], ['F', 'T', 'T', 'F', 'T'], ['F', 'F', 'T', 'F', 'T']], +variables=['P', 'Q', 'P->Q', '!Q', '!P'] +2023-10-10 00:25:30,430 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-10-10 00:25:30,430 - DEBUG - add_array_to_matrix - Calling add_array_to_matrix([['T', 'T', 'T', 'F', 'T'], ['T', 'F', 'F', 'T', 'F'], ['F', 'T', 'T', 'F', 'T'], ['F', 'F', 'T', 'F', 'T']], ['T', 'F', 'T', 'T'], ['P', 'Q', 'P->Q', '!Q', '!P'], ['(!Q)->(!P)'])... +2023-10-10 00:25:30,430 - DEBUG - add_array_to_matrix - variables=['P', 'Q', 'P->Q', '!Q', '!P', '(!Q)->(!P)'] +2023-10-10 00:25:30,430 - DEBUG - add_array_to_matrix - Added array to matrix. +2023-10-10 00:25:30,430 - DEBUG - switch_case - Entering switch_case(<->, ['T', 'F', 'T', 'T'], ['T', 'F', 'T', 'T'])... +2023-10-10 00:25:30,430 - DEBUG - bicond - In bicond. case... +2023-10-10 00:25:30,430 - DEBUG - biconditional - Calling biconditional(['T', 'F', 'T', 'T'], ['T', 'F', 'T', 'T'])... +2023-10-10 00:25:30,431 - DEBUG - biconditional - new_row_values=['T', 'T', 'T', 'T'] +2023-10-10 00:25:30,431 - DEBUG - biconditional - Returning with new row values. +2023-10-10 00:25:30,431 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['P->Q'], '<->', ['(!Q)->(!P)']])... +2023-10-10 00:25:30,432 - DEBUG - set_new_array_elem - new_array=['(P->Q)<->((!Q)->(!P))'] +2023-10-10 00:25:30,432 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-10-10 00:25:30,432 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'T', 'T', 'T'], +final_variable_combined=['(P->Q)<->((!Q)->(!P))'], +matrix=[['T', 'T', 'T', 'F', 'T', 'T', 'T'], ['T', 'F', 'F', 'T', 'F', 'F', 'T'], ['F', 'T', 'T', 'F', 'T', 'T', 'T'], ['F', 'F', 'T', 'F', 'T', 'T', 'T']], +variables=['P', 'Q', 'P->Q', '!Q', '!P', '(!Q)->(!P)'] +2023-10-10 00:25:30,432 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-10-10 00:25:30,432 - DEBUG - evaluate_array_as_tree - returned_array=['T', 'T', 'T', 'T'], returned_matrix=[['T', 'T', 'T', 'F', 'T', 'T', 'T'], ['T', 'F', 'F', 'T', 'F', 'F', 'T'], ['F', 'T', 'T', 'F', 'T', 'T', 'T'], ['F', 'F', 'T', 'F', 'T', 'T', 'T']], all_variables=['P', 'Q', 'P->Q', '!Q', '!P', '(!Q)->(!P)', '(P->Q)<->((!Q)->(!P))'] +2023-10-10 00:25:30,433 - DEBUG - evaluate_array_as_tree - Finished evaluating array. +2023-10-10 00:25:30,433 - DEBUG - simulate_main - In simulate_main(): +final_value_array=['T', 'T', 'T', 'T'], +returned_matrix=[['T', 'T', 'T', 'F', 'T', 'T', 'T'], ['T', 'F', 'F', 'T', 'F', 'F', 'T'], ['F', 'T', 'T', 'F', 'T', 'T', 'T'], ['F', 'F', 'T', 'F', 'T', 'T', 'T']], +all_variables=['P', 'Q', 'P->Q', '!Q', '!P', '(!Q)->(!P)', '(P->Q)<->((!Q)->(!P))'] +2023-10-10 00:25:30,433 - DEBUG - print_details - Printing details... +2023-10-10 00:25:30,433 - INFO - print_details - ************************** EVALUATE ************************** +2023-10-10 00:25:30,433 - INFO - print_details - -> Statement: ((P -> Q) <-> ((!Q) -> (!P))) +2023-10-10 00:25:30,434 - INFO - print_details - -> Final Calculated Array: ['T', 'T', 'T', 'T'] +2023-10-10 00:25:30,434 - INFO - print_details - -> All Variables: ['P', 'Q', 'P->Q', '!Q', '!P', '(!Q)->(!P)', '(P->Q)<->((!Q)->(!P))'] +2023-10-10 00:25:30,434 - INFO - print_details - -> Final Matrix: [['T', 'T', 'T', 'F', 'T', 'T', 'T'], ['T', 'F', 'F', 'T', 'F', 'F', 'T'], ['F', 'T', 'T', 'F', 'T', 'T', 'T'], ['F', 'F', 'T', 'F', 'T', 'T', 'T']] +2023-10-10 00:25:30,434 - INFO - print_details - ************************** EVALUATE ************************** +2023-10-10 00:25:30,434 - INFO - simulate_main - Finished evaluating statement. +2023-10-10 00:25:30,434 - DEBUG - display_matrix - Displaying matrix to console... +2023-10-10 00:25:30,435 - DEBUG - get_number_of_spaces - Calling get_number_of_spaces(2, 4, ['P', 'Q', 'P->Q', '!Q', '!P', '(!Q)->(!P)', '(P->Q)<->((!Q)->(!P))'])... +2023-10-10 00:25:30,435 - DEBUG - get_number_of_spaces - total_space=64 +2023-10-10 00:25:30,435 - DEBUG - get_number_of_spaces - Finished calculating the total space. +2023-10-10 00:25:30,436 - DEBUG - simulate_main - Returning from simulate_main()... +2023-10-10 00:25:30,436 - INFO - - Exiting Engine... diff --git a/engine/examples/keep_these/engine.log.4 b/engine/examples/keep_these/engine.log.4 new file mode 100644 index 0000000..a25c6b0 --- /dev/null +++ b/engine/examples/keep_these/engine.log.4 @@ -0,0 +1,1203 @@ +2023-08-30 12:12:18,571 - INFO - - Starting Engine... +2023-08-30 12:12:18,571 - DEBUG - simulate_main - Calling simulate_main()... +2023-08-30 12:12:18,571 - INFO - simulate_main - Statement: (T v (P -> Q)) +2023-08-30 12:12:18,571 - INFO - simulate_main - Before proceeding, doing checks for unequal brackets and illegal characters. +2023-08-30 12:12:18,571 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets((T v (P -> Q)))... +2023-08-30 12:12:18,571 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-08-30 12:12:18,571 - DEBUG - check_for_illegal_characters - Calling check_for_illegal_characters((T v (P -> Q))) +2023-08-30 12:12:18,571 - DEBUG - check_for_illegal_characters - ******************** starting input validation ******************* +2023-08-30 12:12:18,571 - DEBUG - validate_input - Calling validate_input(T)... +2023-08-30 12:12:18,572 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,572 - DEBUG - validate_input - Calling validate_input(v)... +2023-08-30 12:12:18,572 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,572 - DEBUG - validate_input - Calling validate_input(P)... +2023-08-30 12:12:18,572 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,572 - DEBUG - validate_input - Calling validate_input(-)... +2023-08-30 12:12:18,572 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,572 - DEBUG - validate_input - Calling validate_input(>)... +2023-08-30 12:12:18,572 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,572 - DEBUG - validate_input - Calling validate_input(Q)... +2023-08-30 12:12:18,572 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,572 - DEBUG - check_for_illegal_characters - ******************** finished input validation ******************* +2023-08-30 12:12:18,572 - INFO - check_for_illegal_characters - PASS: There were no illegal characters found. +2023-08-30 12:12:18,572 - INFO - simulate_main - All checks are valid, proceeding with extracting information from statement. +2023-08-30 12:12:18,572 - INFO - user_input - Processing statement... +2023-08-30 12:12:18,572 - DEBUG - user_input - statement=(T v (P -> Q)) +2023-08-30 12:12:18,573 - INFO - analyze_statement - Starting to analyze statement... +2023-08-30 12:12:18,573 - INFO - analyze_statement - The statement is sanitized from any whitespaces. +2023-08-30 12:12:18,573 - DEBUG - analyze_statement - All whitespaces need to be removed, proceeding. +2023-08-30 12:12:18,573 - DEBUG - clean_whitespaces - Calling clean_whitespaces((T v (P -> Q)))... +2023-08-30 12:12:18,573 - DEBUG - clean_whitespaces - Finished removing whitespaces: statement=(Tv(P->Q)) +2023-08-30 12:12:18,573 - DEBUG - analyze_statement - Finished removing any whitespaces found in statement. Proceeding with finding variables. +2023-08-30 12:12:18,573 - INFO - find_variables - Finding variables in statement... +2023-08-30 12:12:18,573 - DEBUG - find_variables - statement=(Tv(P->Q)) +2023-08-30 12:12:18,573 - DEBUG - find_variables - variables_array=['T', 'P', 'Q'] +2023-08-30 12:12:18,573 - INFO - find_variables - Found all variables in statement. +2023-08-30 12:12:18,573 - INFO - find_variables - *** Variables: ['T', 'P', 'Q'] *** +2023-08-30 12:12:18,573 - DEBUG - analyze_statement - variables_arr=['T', 'P', 'Q'] +2023-08-30 12:12:18,573 - INFO - analyze_statement - The statement is converted to an array and any conditionals are sanitized. +2023-08-30 12:12:18,573 - DEBUG - create_array_of_elements - Creating an array from a string... +2023-08-30 12:12:18,573 - DEBUG - create_array_of_elements - Calling create_array_of_elements((Tv(P->Q))) +2023-08-30 12:12:18,573 - DEBUG - create_array_of_elements - array_of_elements=['(', 'T', 'v', '(', 'P', '-', '>', 'Q', ')', ')'] +2023-08-30 12:12:18,573 - DEBUG - create_array_of_elements - Finished creating array. +2023-08-30 12:12:18,573 - DEBUG - check_conditionals - Calling check_conditionals(['(', 'T', 'v', '(', 'P', '-', '>', 'Q', ')', ')'], ['T', 'P', 'Q'])... +2023-08-30 12:12:18,573 - INFO - check_conditionals - PASS: Any conditional symbols present, are in the desired form. +2023-08-30 12:12:18,573 - DEBUG - create_conditionals - Creating one-piece conditionals from single elements. +2023-08-30 12:12:18,574 - DEBUG - create_conditionals - Searching for a '-' in array_of_elements=['(', 'T', 'v', '(', 'P', '-', '>', 'Q', ')', ')'] +2023-08-30 12:12:18,574 - DEBUG - create_conditionals - Conditional symbols were found in ['(', 'T', 'v', '(', 'P', '-', '>', 'Q', ')', ')'] +2023-08-30 12:12:18,574 - DEBUG - create_conditionals - array_of_elements=['(', 'T', 'v', '(', 'P', '->', 'Q', ')', ')'] +2023-08-30 12:12:18,574 - DEBUG - create_conditionals - Finished creating conditionals. +2023-08-30 12:12:18,574 - DEBUG - analyze_statement - In analyze_statement(): +len(variables_arr)=3, +variables_arr=['T', 'P', 'Q'], +array_of_elements=['(', 'T', 'v', '(', 'P', '->', 'Q', ')', ')'] +2023-08-30 12:12:18,574 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,574 - INFO - print_details - ************************** ANALYSIS ************************** +2023-08-30 12:12:18,574 - INFO - print_details - -> Number of Variables: 3 +2023-08-30 12:12:18,574 - INFO - print_details - -> Variables: ['T', 'P', 'Q'] +2023-08-30 12:12:18,574 - INFO - print_details - -> Array of Elements: ['(', 'T', 'v', '(', 'P', '->', 'Q', ')', ')'] +2023-08-30 12:12:18,574 - INFO - print_details - ************************** ANALYSIS ************************** +2023-08-30 12:12:18,574 - INFO - analyze_statement - Analyzing concluded. +2023-08-30 12:12:18,574 - INFO - parse_array - Starting to parse array... +2023-08-30 12:12:18,574 - DEBUG - remove_brackets_around_variables - Removing brackets around standalone variables... +2023-08-30 12:12:18,574 - DEBUG - remove_brackets_around_variables - arr=['(', 'T', 'v', '(', 'P', '->', 'Q', ')', ')'] +2023-08-30 12:12:18,574 - DEBUG - remove_brackets_around_variables - Finished removing all brackets around variables. +2023-08-30 12:12:18,574 - DEBUG - parse_array - In parse_array(): elements_second=['(', 'T', 'v', '(', 'P', '->', 'Q', ')', ')'] +2023-08-30 12:12:18,574 - DEBUG - add_brackets_around_unary_connectives - Adding brackets around unary connectives... +2023-08-30 12:12:18,574 - DEBUG - add_brackets_around_unary_connectives - arr=['(', 'T', 'v', '(', 'P', '->', 'Q', ')', ')'] +2023-08-30 12:12:18,574 - DEBUG - add_brackets_around_unary_connectives - Finished adding brackets around all unary connectives. +2023-08-30 12:12:18,575 - DEBUG - parse_array - In parse_array(): elements_second=['(', 'T', 'v', '(', 'P', '->', 'Q', ')', ')'] +2023-08-30 12:12:18,575 - INFO - parse_array - Final checks are ran before parsing concludes. +2023-08-30 12:12:18,575 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets(['(', 'T', 'v', '(', 'P', '->', 'Q', ')', ')'])... +2023-08-30 12:12:18,575 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-08-30 12:12:18,575 - DEBUG - parse - Calling parse(['(', 'T', 'v', '(', 'P', '->', 'Q', ')', ')'])... +2023-08-30 12:12:18,575 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', 'T', 'v', '(', 'P', '->', 'Q', ')', ')'])... +2023-08-30 12:12:18,575 - DEBUG - remove_outer_brackets - array=['T', 'v', '(', 'P', '->', 'Q', ')'] +2023-08-30 12:12:18,575 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-08-30 12:12:18,575 - DEBUG - parse - In parse(): arr=['T', 'v', '(', 'P', '->', 'Q', ')'] +2023-08-30 12:12:18,575 - DEBUG - find_connective - Calling find_connectives(['T', 'v', '(', 'P', '->', 'Q', ')'])... +2023-08-30 12:12:18,575 - DEBUG - find_connective - In find_connective(): elem=v, i=1 +2023-08-30 12:12:18,575 - DEBUG - find_connective - Found connective. +2023-08-30 12:12:18,575 - DEBUG - parse - Calling parse(['(', 'P', '->', 'Q', ')'])... +2023-08-30 12:12:18,575 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', 'P', '->', 'Q', ')'])... +2023-08-30 12:12:18,575 - DEBUG - remove_outer_brackets - array=['P', '->', 'Q'] +2023-08-30 12:12:18,575 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-08-30 12:12:18,575 - DEBUG - parse - In parse(): arr=['P', '->', 'Q'] +2023-08-30 12:12:18,575 - DEBUG - find_connective - Calling find_connectives(['P', '->', 'Q'])... +2023-08-30 12:12:18,575 - DEBUG - find_connective - In find_connective(): elem=->, i=1 +2023-08-30 12:12:18,576 - DEBUG - find_connective - Found connective. +2023-08-30 12:12:18,576 - DEBUG - parse - temp_array=[['P'], '->', ['Q']] +2023-08-30 12:12:18,576 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-08-30 12:12:18,576 - DEBUG - parse - temp_array=[['T'], 'v', [['P'], '->', ['Q']]] +2023-08-30 12:12:18,576 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-08-30 12:12:18,576 - DEBUG - parse_array - tree_structured_array=[['T'], 'v', [['P'], '->', ['Q']]] +2023-08-30 12:12:18,576 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,576 - INFO - print_details - *************************** PARSE *************************** +2023-08-30 12:12:18,576 - INFO - print_details - -> Parsed Array: [['T'], 'v', [['P'], '->', ['Q']]] +2023-08-30 12:12:18,576 - INFO - print_details - *************************** PARSE *************************** +2023-08-30 12:12:18,576 - INFO - parse_array - Finished parsing array. +2023-08-30 12:12:18,576 - DEBUG - user_input - In user_input(): +number_of_variables=3, +variables_as_array=['T', 'P', 'Q'], +statement=(T v (P -> Q)), +new_elements=[['T'], 'v', [['P'], '->', ['Q']]]. +2023-08-30 12:12:18,576 - INFO - user_input - Gathered all information needed including variables and parsed array. +2023-08-30 12:12:18,576 - DEBUG - simulate_main - In simulate_main(): +number_of_variables=3, +variables_as_array=['T', 'P', 'Q'], +provided_statement=(T v (P -> Q)), +elements_in_tree=[['T'], 'v', [['P'], '->', ['Q']]] +2023-08-30 12:12:18,576 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,576 - INFO - print_details - ************************** SUMMARY ************************** +2023-08-30 12:12:18,576 - INFO - print_details - -> number_of_variables: 3 +2023-08-30 12:12:18,576 - INFO - print_details - -> variables_as_array: ['T', 'P', 'Q'] +2023-08-30 12:12:18,576 - INFO - print_details - -> provided_statement: (T v (P -> Q)) +2023-08-30 12:12:18,576 - INFO - print_details - -> elements_in_tree: [['T'], 'v', [['P'], '->', ['Q']]] +2023-08-30 12:12:18,577 - INFO - print_details - ************************** SUMMARY ************************** +2023-08-30 12:12:18,577 - INFO - evaluate_array_as_tree - Starting evaluation of array of elements... +2023-08-30 12:12:18,577 - DEBUG - create_matrix - Creating initial matrix... +2023-08-30 12:12:18,577 - DEBUG - recursive_table - Creating table entries recursively... +2023-08-30 12:12:18,577 - DEBUG - recursive_table - n=3 +2023-08-30 12:12:18,577 - DEBUG - recursive_table - Creating table entries recursively... +2023-08-30 12:12:18,577 - DEBUG - recursive_table - n=2 +2023-08-30 12:12:18,577 - DEBUG - recursive_table - Creating table entries recursively... +2023-08-30 12:12:18,577 - DEBUG - recursive_table - n=1 +2023-08-30 12:12:18,577 - DEBUG - recursive_table - array_table=['T', 'F'] +2023-08-30 12:12:18,577 - DEBUG - recursive_table - Finished creating array of table entries. +2023-08-30 12:12:18,577 - DEBUG - recursive_table - array_table=['TT', 'TF', 'FT', 'FF'] +2023-08-30 12:12:18,577 - DEBUG - recursive_table - Finished creating array of table entries. +2023-08-30 12:12:18,577 - DEBUG - recursive_table - array_table=['TTT', 'TTF', 'TFT', 'TFF', 'FTT', 'FTF', 'FFT', 'FFF'] +2023-08-30 12:12:18,577 - DEBUG - recursive_table - Finished creating array of table entries. +2023-08-30 12:12:18,577 - DEBUG - create_matrix - In create_matrix(): new_matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']] +2023-08-30 12:12:18,577 - INFO - create_matrix - Finished creating the initial 'truth' matrix. +2023-08-30 12:12:18,577 - INFO - create_matrix - *** Initial Matrix: [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']] *** +2023-08-30 12:12:18,577 - DEBUG - evaluate_array_as_tree - In evaluate_array_as_tree(): +elements_in_tree=[['T'], 'v', [['P'], '->', ['Q']]], +counter=0, +matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], +variables_as_array=['T', 'P', 'Q'] +2023-08-30 12:12:18,578 - DEBUG - evaluate_array - Calling evaluate_array([['T'], 'v', [['P'], '->', ['Q']]], 0, [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['T', 'P', 'Q'])... +2023-08-30 12:12:18,578 - DEBUG - evaluate_array - Calling evaluate_array([['P'], '->', ['Q']], 1, [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['T', 'P', 'Q'])... +2023-08-30 12:12:18,578 - DEBUG - switch_case - Entering switch_case(->, ['T', 'T', 'F', 'F', 'T', 'T', 'F', 'F'], ['T', 'F', 'T', 'F', 'T', 'F', 'T', 'F'])... +2023-08-30 12:12:18,578 - DEBUG - cond - In cond. case... +2023-08-30 12:12:18,578 - DEBUG - conditional - Calling conditional(['T', 'T', 'F', 'F', 'T', 'T', 'F', 'F'], ['T', 'F', 'T', 'F', 'T', 'F', 'T', 'F'])... +2023-08-30 12:12:18,578 - DEBUG - conditional - new_row_values=['T', 'F', 'T', 'T', 'T', 'F', 'T', 'T'] +2023-08-30 12:12:18,578 - DEBUG - conditional - Returning with new row values. +2023-08-30 12:12:18,578 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['P'], '->', ['Q']])... +2023-08-30 12:12:18,578 - DEBUG - set_new_array_elem - new_array=['P->Q'] +2023-08-30 12:12:18,578 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-08-30 12:12:18,578 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'F', 'T', 'T', 'T', 'F', 'T', 'T'], +final_variable_combined=['P->Q'], +matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], +variables=['T', 'P', 'Q'] +2023-08-30 12:12:18,578 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-08-30 12:12:18,578 - DEBUG - add_array_to_matrix - Calling add_array_to_matrix([['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['T', 'F', 'T', 'T', 'T', 'F', 'T', 'T'], ['T', 'P', 'Q'], ['P->Q'])... +2023-08-30 12:12:18,578 - DEBUG - add_array_to_matrix - variables=['T', 'P', 'Q', 'P->Q'] +2023-08-30 12:12:18,578 - DEBUG - add_array_to_matrix - Added array to matrix. +2023-08-30 12:12:18,578 - DEBUG - switch_case - Entering switch_case(v, ['T', 'T', 'T', 'T', 'F', 'F', 'F', 'F'], ['T', 'F', 'T', 'T', 'T', 'F', 'T', 'T'])... +2023-08-30 12:12:18,578 - DEBUG - disj - In disj. case... +2023-08-30 12:12:18,578 - DEBUG - disjunction - Calling disjunction(['T', 'T', 'T', 'T', 'F', 'F', 'F', 'F'], ['T', 'F', 'T', 'T', 'T', 'F', 'T', 'T'])... +2023-08-30 12:12:18,579 - DEBUG - disjunction - new_row_values=['T', 'T', 'T', 'T', 'T', 'F', 'T', 'T'] +2023-08-30 12:12:18,579 - DEBUG - disjunction - Returning with new row values. +2023-08-30 12:12:18,579 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['T'], 'v', ['P->Q']])... +2023-08-30 12:12:18,579 - DEBUG - set_new_array_elem - new_array=['Tv(P->Q)'] +2023-08-30 12:12:18,579 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-08-30 12:12:18,579 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'T', 'T', 'T', 'T', 'F', 'T', 'T'], +final_variable_combined=['Tv(P->Q)'], +matrix=[['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'T'], ['T', 'F', 'T', 'T', 'T'], ['T', 'F', 'F', 'T', 'T'], ['F', 'T', 'T', 'T', 'T'], ['F', 'T', 'F', 'F', 'F'], ['F', 'F', 'T', 'T', 'T'], ['F', 'F', 'F', 'T', 'T']], +variables=['T', 'P', 'Q', 'P->Q'] +2023-08-30 12:12:18,579 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-08-30 12:12:18,579 - DEBUG - evaluate_array_as_tree - returned_array=['T', 'T', 'T', 'T', 'T', 'F', 'T', 'T'], returned_matrix=[['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'T'], ['T', 'F', 'T', 'T', 'T'], ['T', 'F', 'F', 'T', 'T'], ['F', 'T', 'T', 'T', 'T'], ['F', 'T', 'F', 'F', 'F'], ['F', 'F', 'T', 'T', 'T'], ['F', 'F', 'F', 'T', 'T']], all_variables=['T', 'P', 'Q', 'P->Q', 'Tv(P->Q)'] +2023-08-30 12:12:18,579 - DEBUG - evaluate_array_as_tree - Finished evaluating array. +2023-08-30 12:12:18,579 - DEBUG - simulate_main - In simulate_main(): +final_value_array=['T', 'T', 'T', 'T', 'T', 'F', 'T', 'T'], +returned_matrix=[['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'T'], ['T', 'F', 'T', 'T', 'T'], ['T', 'F', 'F', 'T', 'T'], ['F', 'T', 'T', 'T', 'T'], ['F', 'T', 'F', 'F', 'F'], ['F', 'F', 'T', 'T', 'T'], ['F', 'F', 'F', 'T', 'T']], +all_variables=['T', 'P', 'Q', 'P->Q', 'Tv(P->Q)'] +2023-08-30 12:12:18,579 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,579 - INFO - print_details - ************************** EVALUATE ************************** +2023-08-30 12:12:18,579 - INFO - print_details - -> Statement: (T v (P -> Q)) +2023-08-30 12:12:18,579 - INFO - print_details - -> Final Calculated Array: ['T', 'T', 'T', 'T', 'T', 'F', 'T', 'T'] +2023-08-30 12:12:18,579 - INFO - print_details - -> All Variables: ['T', 'P', 'Q', 'P->Q', 'Tv(P->Q)'] +2023-08-30 12:12:18,579 - INFO - print_details - -> Final Matrix: [['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'T'], ['T', 'F', 'T', 'T', 'T'], ['T', 'F', 'F', 'T', 'T'], ['F', 'T', 'T', 'T', 'T'], ['F', 'T', 'F', 'F', 'F'], ['F', 'F', 'T', 'T', 'T'], ['F', 'F', 'F', 'T', 'T']] +2023-08-30 12:12:18,579 - INFO - print_details - ************************** EVALUATE ************************** +2023-08-30 12:12:18,579 - INFO - simulate_main - Finished evaluating statement. +2023-08-30 12:12:18,580 - DEBUG - display_matrix - Displaying matrix to console... +2023-08-30 12:12:18,580 - DEBUG - get_number_of_spaces - Calling get_number_of_spaces(3, 1, ['T', 'P', 'Q', 'P->Q', 'Tv(P->Q)'])... +2023-08-30 12:12:18,580 - DEBUG - get_number_of_spaces - total_space=32 +2023-08-30 12:12:18,580 - DEBUG - get_number_of_spaces - Finished calculating the total space. +2023-08-30 12:12:18,580 - DEBUG - simulate_main - Returning from simulate_main()... +2023-08-30 12:12:18,580 - INFO - simulate_main - Statement: ((T ^ Q) v (P ^ Q)) +2023-08-30 12:12:18,580 - INFO - simulate_main - Before proceeding, doing checks for unequal brackets and illegal characters. +2023-08-30 12:12:18,580 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets(((T ^ Q) v (P ^ Q)))... +2023-08-30 12:12:18,580 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-08-30 12:12:18,580 - DEBUG - check_for_illegal_characters - Calling check_for_illegal_characters(((T ^ Q) v (P ^ Q))) +2023-08-30 12:12:18,580 - DEBUG - check_for_illegal_characters - ******************** starting input validation ******************* +2023-08-30 12:12:18,580 - DEBUG - validate_input - Calling validate_input(T)... +2023-08-30 12:12:18,580 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,580 - DEBUG - validate_input - Calling validate_input(^)... +2023-08-30 12:12:18,580 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,580 - DEBUG - validate_input - Calling validate_input(Q)... +2023-08-30 12:12:18,581 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,581 - DEBUG - validate_input - Calling validate_input(v)... +2023-08-30 12:12:18,581 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,581 - DEBUG - validate_input - Calling validate_input(P)... +2023-08-30 12:12:18,581 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,581 - DEBUG - validate_input - Calling validate_input(^)... +2023-08-30 12:12:18,581 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,581 - DEBUG - validate_input - Calling validate_input(Q)... +2023-08-30 12:12:18,581 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,581 - DEBUG - check_for_illegal_characters - ******************** finished input validation ******************* +2023-08-30 12:12:18,581 - INFO - check_for_illegal_characters - PASS: There were no illegal characters found. +2023-08-30 12:12:18,581 - INFO - simulate_main - All checks are valid, proceeding with extracting information from statement. +2023-08-30 12:12:18,581 - INFO - user_input - Processing statement... +2023-08-30 12:12:18,581 - DEBUG - user_input - statement=((T ^ Q) v (P ^ Q)) +2023-08-30 12:12:18,581 - INFO - analyze_statement - Starting to analyze statement... +2023-08-30 12:12:18,581 - INFO - analyze_statement - The statement is sanitized from any whitespaces. +2023-08-30 12:12:18,581 - DEBUG - analyze_statement - All whitespaces need to be removed, proceeding. +2023-08-30 12:12:18,581 - DEBUG - clean_whitespaces - Calling clean_whitespaces(((T ^ Q) v (P ^ Q)))... +2023-08-30 12:12:18,581 - DEBUG - clean_whitespaces - Finished removing whitespaces: statement=((T^Q)v(P^Q)) +2023-08-30 12:12:18,581 - DEBUG - analyze_statement - Finished removing any whitespaces found in statement. Proceeding with finding variables. +2023-08-30 12:12:18,582 - INFO - find_variables - Finding variables in statement... +2023-08-30 12:12:18,582 - DEBUG - find_variables - statement=((T^Q)v(P^Q)) +2023-08-30 12:12:18,582 - DEBUG - find_variables - variables_array=['T', 'Q', 'P'] +2023-08-30 12:12:18,582 - INFO - find_variables - Found all variables in statement. +2023-08-30 12:12:18,582 - INFO - find_variables - *** Variables: ['T', 'Q', 'P'] *** +2023-08-30 12:12:18,582 - DEBUG - analyze_statement - variables_arr=['T', 'Q', 'P'] +2023-08-30 12:12:18,582 - INFO - analyze_statement - The statement is converted to an array and any conditionals are sanitized. +2023-08-30 12:12:18,582 - DEBUG - create_array_of_elements - Creating an array from a string... +2023-08-30 12:12:18,582 - DEBUG - create_array_of_elements - Calling create_array_of_elements(((T^Q)v(P^Q))) +2023-08-30 12:12:18,582 - DEBUG - create_array_of_elements - array_of_elements=['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'] +2023-08-30 12:12:18,582 - DEBUG - create_array_of_elements - Finished creating array. +2023-08-30 12:12:18,582 - DEBUG - check_conditionals - Calling check_conditionals(['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'], ['T', 'Q', 'P'])... +2023-08-30 12:12:18,582 - INFO - check_conditionals - PASS: Any conditional symbols present, are in the desired form. +2023-08-30 12:12:18,582 - DEBUG - create_conditionals - Creating one-piece conditionals from single elements. +2023-08-30 12:12:18,582 - DEBUG - create_conditionals - Searching for a '-' in array_of_elements=['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'] +2023-08-30 12:12:18,582 - DEBUG - create_conditionals - Search for conditionals finished and none were found, returning. +2023-08-30 12:12:18,582 - DEBUG - analyze_statement - In analyze_statement(): +len(variables_arr)=3, +variables_arr=['T', 'Q', 'P'], +array_of_elements=['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'] +2023-08-30 12:12:18,582 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,582 - INFO - print_details - ************************** ANALYSIS ************************** +2023-08-30 12:12:18,582 - INFO - print_details - -> Number of Variables: 3 +2023-08-30 12:12:18,583 - INFO - print_details - -> Variables: ['T', 'Q', 'P'] +2023-08-30 12:12:18,583 - INFO - print_details - -> Array of Elements: ['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'] +2023-08-30 12:12:18,583 - INFO - print_details - ************************** ANALYSIS ************************** +2023-08-30 12:12:18,583 - INFO - analyze_statement - Analyzing concluded. +2023-08-30 12:12:18,583 - INFO - parse_array - Starting to parse array... +2023-08-30 12:12:18,583 - DEBUG - remove_brackets_around_variables - Removing brackets around standalone variables... +2023-08-30 12:12:18,583 - DEBUG - remove_brackets_around_variables - arr=['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'] +2023-08-30 12:12:18,583 - DEBUG - remove_brackets_around_variables - Finished removing all brackets around variables. +2023-08-30 12:12:18,583 - DEBUG - parse_array - In parse_array(): elements_second=['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'] +2023-08-30 12:12:18,583 - DEBUG - add_brackets_around_unary_connectives - Adding brackets around unary connectives... +2023-08-30 12:12:18,583 - DEBUG - add_brackets_around_unary_connectives - arr=['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'] +2023-08-30 12:12:18,583 - DEBUG - add_brackets_around_unary_connectives - Finished adding brackets around all unary connectives. +2023-08-30 12:12:18,583 - DEBUG - parse_array - In parse_array(): elements_second=['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'] +2023-08-30 12:12:18,583 - INFO - parse_array - Final checks are ran before parsing concludes. +2023-08-30 12:12:18,583 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets(['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'])... +2023-08-30 12:12:18,583 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-08-30 12:12:18,583 - DEBUG - parse - Calling parse(['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'])... +2023-08-30 12:12:18,584 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', '(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')', ')'])... +2023-08-30 12:12:18,584 - DEBUG - remove_outer_brackets - array=['(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')'] +2023-08-30 12:12:18,584 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-08-30 12:12:18,584 - DEBUG - parse - In parse(): arr=['(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')'] +2023-08-30 12:12:18,584 - DEBUG - find_connective - Calling find_connectives(['(', 'T', '^', 'Q', ')', 'v', '(', 'P', '^', 'Q', ')'])... +2023-08-30 12:12:18,584 - DEBUG - find_connective - In find_connective(): elem=v, i=5 +2023-08-30 12:12:18,584 - DEBUG - find_connective - Found connective. +2023-08-30 12:12:18,584 - DEBUG - parse - Calling parse(['(', 'T', '^', 'Q', ')'])... +2023-08-30 12:12:18,584 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', 'T', '^', 'Q', ')'])... +2023-08-30 12:12:18,584 - DEBUG - remove_outer_brackets - array=['T', '^', 'Q'] +2023-08-30 12:12:18,584 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-08-30 12:12:18,584 - DEBUG - parse - In parse(): arr=['T', '^', 'Q'] +2023-08-30 12:12:18,584 - DEBUG - find_connective - Calling find_connectives(['T', '^', 'Q'])... +2023-08-30 12:12:18,584 - DEBUG - find_connective - In find_connective(): elem=^, i=1 +2023-08-30 12:12:18,584 - DEBUG - find_connective - Found connective. +2023-08-30 12:12:18,584 - DEBUG - parse - temp_array=[['T'], '^', ['Q']] +2023-08-30 12:12:18,584 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-08-30 12:12:18,584 - DEBUG - parse - Calling parse(['(', 'P', '^', 'Q', ')'])... +2023-08-30 12:12:18,585 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', 'P', '^', 'Q', ')'])... +2023-08-30 12:12:18,585 - DEBUG - remove_outer_brackets - array=['P', '^', 'Q'] +2023-08-30 12:12:18,585 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-08-30 12:12:18,585 - DEBUG - parse - In parse(): arr=['P', '^', 'Q'] +2023-08-30 12:12:18,585 - DEBUG - find_connective - Calling find_connectives(['P', '^', 'Q'])... +2023-08-30 12:12:18,585 - DEBUG - find_connective - In find_connective(): elem=^, i=1 +2023-08-30 12:12:18,585 - DEBUG - find_connective - Found connective. +2023-08-30 12:12:18,585 - DEBUG - parse - temp_array=[['P'], '^', ['Q']] +2023-08-30 12:12:18,585 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-08-30 12:12:18,585 - DEBUG - parse - temp_array=[[['T'], '^', ['Q']], 'v', [['P'], '^', ['Q']]] +2023-08-30 12:12:18,585 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-08-30 12:12:18,585 - DEBUG - parse_array - tree_structured_array=[[['T'], '^', ['Q']], 'v', [['P'], '^', ['Q']]] +2023-08-30 12:12:18,585 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,585 - INFO - print_details - *************************** PARSE *************************** +2023-08-30 12:12:18,585 - INFO - print_details - -> Parsed Array: [[['T'], '^', ['Q']], 'v', [['P'], '^', ['Q']]] +2023-08-30 12:12:18,585 - INFO - print_details - *************************** PARSE *************************** +2023-08-30 12:12:18,585 - INFO - parse_array - Finished parsing array. +2023-08-30 12:12:18,585 - DEBUG - user_input - In user_input(): +number_of_variables=3, +variables_as_array=['T', 'Q', 'P'], +statement=((T ^ Q) v (P ^ Q)), +new_elements=[[['T'], '^', ['Q']], 'v', [['P'], '^', ['Q']]]. +2023-08-30 12:12:18,586 - INFO - user_input - Gathered all information needed including variables and parsed array. +2023-08-30 12:12:18,586 - DEBUG - simulate_main - In simulate_main(): +number_of_variables=3, +variables_as_array=['T', 'Q', 'P'], +provided_statement=((T ^ Q) v (P ^ Q)), +elements_in_tree=[[['T'], '^', ['Q']], 'v', [['P'], '^', ['Q']]] +2023-08-30 12:12:18,586 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,586 - INFO - print_details - ************************** SUMMARY ************************** +2023-08-30 12:12:18,586 - INFO - print_details - -> number_of_variables: 3 +2023-08-30 12:12:18,586 - INFO - print_details - -> variables_as_array: ['T', 'Q', 'P'] +2023-08-30 12:12:18,586 - INFO - print_details - -> provided_statement: ((T ^ Q) v (P ^ Q)) +2023-08-30 12:12:18,586 - INFO - print_details - -> elements_in_tree: [[['T'], '^', ['Q']], 'v', [['P'], '^', ['Q']]] +2023-08-30 12:12:18,586 - INFO - print_details - ************************** SUMMARY ************************** +2023-08-30 12:12:18,586 - INFO - evaluate_array_as_tree - Starting evaluation of array of elements... +2023-08-30 12:12:18,586 - DEBUG - create_matrix - Creating initial matrix... +2023-08-30 12:12:18,586 - DEBUG - recursive_table - Creating table entries recursively... +2023-08-30 12:12:18,586 - DEBUG - recursive_table - n=3 +2023-08-30 12:12:18,586 - DEBUG - recursive_table - Creating table entries recursively... +2023-08-30 12:12:18,586 - DEBUG - recursive_table - n=2 +2023-08-30 12:12:18,586 - DEBUG - recursive_table - Creating table entries recursively... +2023-08-30 12:12:18,586 - DEBUG - recursive_table - n=1 +2023-08-30 12:12:18,587 - DEBUG - recursive_table - array_table=['T', 'F'] +2023-08-30 12:12:18,587 - DEBUG - recursive_table - Finished creating array of table entries. +2023-08-30 12:12:18,587 - DEBUG - recursive_table - array_table=['TT', 'TF', 'FT', 'FF'] +2023-08-30 12:12:18,587 - DEBUG - recursive_table - Finished creating array of table entries. +2023-08-30 12:12:18,587 - DEBUG - recursive_table - array_table=['TTT', 'TTF', 'TFT', 'TFF', 'FTT', 'FTF', 'FFT', 'FFF'] +2023-08-30 12:12:18,587 - DEBUG - recursive_table - Finished creating array of table entries. +2023-08-30 12:12:18,587 - DEBUG - create_matrix - In create_matrix(): new_matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']] +2023-08-30 12:12:18,587 - INFO - create_matrix - Finished creating the initial 'truth' matrix. +2023-08-30 12:12:18,587 - INFO - create_matrix - *** Initial Matrix: [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']] *** +2023-08-30 12:12:18,587 - DEBUG - evaluate_array_as_tree - In evaluate_array_as_tree(): +elements_in_tree=[[['T'], '^', ['Q']], 'v', [['P'], '^', ['Q']]], +counter=0, +matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], +variables_as_array=['T', 'Q', 'P'] +2023-08-30 12:12:18,587 - DEBUG - evaluate_array - Calling evaluate_array([[['T'], '^', ['Q']], 'v', [['P'], '^', ['Q']]], 0, [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['T', 'Q', 'P'])... +2023-08-30 12:12:18,587 - DEBUG - evaluate_array - Calling evaluate_array([['T'], '^', ['Q']], 1, [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['T', 'Q', 'P'])... +2023-08-30 12:12:18,587 - DEBUG - switch_case - Entering switch_case(^, ['T', 'T', 'T', 'T', 'F', 'F', 'F', 'F'], ['T', 'T', 'F', 'F', 'T', 'T', 'F', 'F'])... +2023-08-30 12:12:18,587 - DEBUG - conj - In conj. case... +2023-08-30 12:12:18,587 - DEBUG - conjunction - Calling conjunction(['T', 'T', 'T', 'T', 'F', 'F', 'F', 'F'], ['T', 'T', 'F', 'F', 'T', 'T', 'F', 'F'])... +2023-08-30 12:12:18,587 - DEBUG - conjunction - new_row_values=['T', 'T', 'F', 'F', 'F', 'F', 'F', 'F'] +2023-08-30 12:12:18,587 - DEBUG - conjunction - Returning with new row values. +2023-08-30 12:12:18,587 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['T'], '^', ['Q']])... +2023-08-30 12:12:18,587 - DEBUG - set_new_array_elem - new_array=['T^Q'] +2023-08-30 12:12:18,588 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-08-30 12:12:18,588 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'T', 'F', 'F', 'F', 'F', 'F', 'F'], +final_variable_combined=['T^Q'], +matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], +variables=['T', 'Q', 'P'] +2023-08-30 12:12:18,588 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-08-30 12:12:18,588 - DEBUG - add_array_to_matrix - Calling add_array_to_matrix([['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['T', 'T', 'F', 'F', 'F', 'F', 'F', 'F'], ['T', 'Q', 'P'], ['T^Q'])... +2023-08-30 12:12:18,588 - DEBUG - add_array_to_matrix - variables=['T', 'Q', 'P', 'T^Q'] +2023-08-30 12:12:18,588 - DEBUG - add_array_to_matrix - Added array to matrix. +2023-08-30 12:12:18,588 - DEBUG - evaluate_array - Calling evaluate_array([['P'], '^', ['Q']], 1, [['T', 'T', 'T', 'T'], ['T', 'T', 'F', 'T'], ['T', 'F', 'T', 'F'], ['T', 'F', 'F', 'F'], ['F', 'T', 'T', 'F'], ['F', 'T', 'F', 'F'], ['F', 'F', 'T', 'F'], ['F', 'F', 'F', 'F']], ['T', 'Q', 'P', 'T^Q'])... +2023-08-30 12:12:18,588 - DEBUG - switch_case - Entering switch_case(^, ['T', 'F', 'T', 'F', 'T', 'F', 'T', 'F'], ['T', 'T', 'F', 'F', 'T', 'T', 'F', 'F'])... +2023-08-30 12:12:18,588 - DEBUG - conj - In conj. case... +2023-08-30 12:12:18,588 - DEBUG - conjunction - Calling conjunction(['T', 'F', 'T', 'F', 'T', 'F', 'T', 'F'], ['T', 'T', 'F', 'F', 'T', 'T', 'F', 'F'])... +2023-08-30 12:12:18,588 - DEBUG - conjunction - new_row_values=['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'] +2023-08-30 12:12:18,588 - DEBUG - conjunction - Returning with new row values. +2023-08-30 12:12:18,588 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['P'], '^', ['Q']])... +2023-08-30 12:12:18,588 - DEBUG - set_new_array_elem - new_array=['P^Q'] +2023-08-30 12:12:18,588 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-08-30 12:12:18,588 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'], +final_variable_combined=['P^Q'], +matrix=[['T', 'T', 'T', 'T'], ['T', 'T', 'F', 'T'], ['T', 'F', 'T', 'F'], ['T', 'F', 'F', 'F'], ['F', 'T', 'T', 'F'], ['F', 'T', 'F', 'F'], ['F', 'F', 'T', 'F'], ['F', 'F', 'F', 'F']], +variables=['T', 'Q', 'P', 'T^Q'] +2023-08-30 12:12:18,588 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-08-30 12:12:18,588 - DEBUG - add_array_to_matrix - Calling add_array_to_matrix([['T', 'T', 'T', 'T'], ['T', 'T', 'F', 'T'], ['T', 'F', 'T', 'F'], ['T', 'F', 'F', 'F'], ['F', 'T', 'T', 'F'], ['F', 'T', 'F', 'F'], ['F', 'F', 'T', 'F'], ['F', 'F', 'F', 'F']], ['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'], ['T', 'Q', 'P', 'T^Q'], ['P^Q'])... +2023-08-30 12:12:18,589 - DEBUG - add_array_to_matrix - variables=['T', 'Q', 'P', 'T^Q', 'P^Q'] +2023-08-30 12:12:18,589 - DEBUG - add_array_to_matrix - Added array to matrix. +2023-08-30 12:12:18,589 - DEBUG - switch_case - Entering switch_case(v, ['T', 'T', 'F', 'F', 'F', 'F', 'F', 'F'], ['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'])... +2023-08-30 12:12:18,589 - DEBUG - disj - In disj. case... +2023-08-30 12:12:18,589 - DEBUG - disjunction - Calling disjunction(['T', 'T', 'F', 'F', 'F', 'F', 'F', 'F'], ['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'])... +2023-08-30 12:12:18,589 - DEBUG - disjunction - new_row_values=['T', 'T', 'F', 'F', 'T', 'F', 'F', 'F'] +2023-08-30 12:12:18,589 - DEBUG - disjunction - Returning with new row values. +2023-08-30 12:12:18,589 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['T^Q'], 'v', ['P^Q']])... +2023-08-30 12:12:18,589 - DEBUG - set_new_array_elem - new_array=['(T^Q)v(P^Q)'] +2023-08-30 12:12:18,589 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-08-30 12:12:18,589 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'T', 'F', 'F', 'T', 'F', 'F', 'F'], +final_variable_combined=['(T^Q)v(P^Q)'], +matrix=[['T', 'T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'T', 'F', 'T'], ['T', 'F', 'T', 'F', 'F', 'F'], ['T', 'F', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'F', 'T', 'T'], ['F', 'T', 'F', 'F', 'F', 'F'], ['F', 'F', 'T', 'F', 'F', 'F'], ['F', 'F', 'F', 'F', 'F', 'F']], +variables=['T', 'Q', 'P', 'T^Q', 'P^Q'] +2023-08-30 12:12:18,589 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-08-30 12:12:18,589 - DEBUG - evaluate_array_as_tree - returned_array=['T', 'T', 'F', 'F', 'T', 'F', 'F', 'F'], returned_matrix=[['T', 'T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'T', 'F', 'T'], ['T', 'F', 'T', 'F', 'F', 'F'], ['T', 'F', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'F', 'T', 'T'], ['F', 'T', 'F', 'F', 'F', 'F'], ['F', 'F', 'T', 'F', 'F', 'F'], ['F', 'F', 'F', 'F', 'F', 'F']], all_variables=['T', 'Q', 'P', 'T^Q', 'P^Q', '(T^Q)v(P^Q)'] +2023-08-30 12:12:18,589 - DEBUG - evaluate_array_as_tree - Finished evaluating array. +2023-08-30 12:12:18,589 - DEBUG - simulate_main - In simulate_main(): +final_value_array=['T', 'T', 'F', 'F', 'T', 'F', 'F', 'F'], +returned_matrix=[['T', 'T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'T', 'F', 'T'], ['T', 'F', 'T', 'F', 'F', 'F'], ['T', 'F', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'F', 'T', 'T'], ['F', 'T', 'F', 'F', 'F', 'F'], ['F', 'F', 'T', 'F', 'F', 'F'], ['F', 'F', 'F', 'F', 'F', 'F']], +all_variables=['T', 'Q', 'P', 'T^Q', 'P^Q', '(T^Q)v(P^Q)'] +2023-08-30 12:12:18,589 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,589 - INFO - print_details - ************************** EVALUATE ************************** +2023-08-30 12:12:18,589 - INFO - print_details - -> Statement: ((T ^ Q) v (P ^ Q)) +2023-08-30 12:12:18,589 - INFO - print_details - -> Final Calculated Array: ['T', 'T', 'F', 'F', 'T', 'F', 'F', 'F'] +2023-08-30 12:12:18,589 - INFO - print_details - -> All Variables: ['T', 'Q', 'P', 'T^Q', 'P^Q', '(T^Q)v(P^Q)'] +2023-08-30 12:12:18,590 - INFO - print_details - -> Final Matrix: [['T', 'T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'T', 'F', 'T'], ['T', 'F', 'T', 'F', 'F', 'F'], ['T', 'F', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'F', 'T', 'T'], ['F', 'T', 'F', 'F', 'F', 'F'], ['F', 'F', 'T', 'F', 'F', 'F'], ['F', 'F', 'F', 'F', 'F', 'F']] +2023-08-30 12:12:18,590 - INFO - print_details - ************************** EVALUATE ************************** +2023-08-30 12:12:18,590 - INFO - simulate_main - Finished evaluating statement. +2023-08-30 12:12:18,590 - DEBUG - display_matrix - Displaying matrix to console... +2023-08-30 12:12:18,590 - DEBUG - get_number_of_spaces - Calling get_number_of_spaces(3, 2, ['T', 'Q', 'P', 'T^Q', 'P^Q', '(T^Q)v(P^Q)'])... +2023-08-30 12:12:18,590 - DEBUG - get_number_of_spaces - total_space=40 +2023-08-30 12:12:18,590 - DEBUG - get_number_of_spaces - Finished calculating the total space. +2023-08-30 12:12:18,590 - DEBUG - simulate_main - Returning from simulate_main()... +2023-08-30 12:12:18,590 - INFO - simulate_main - Statement: (S ^ (R ^ Q)) +2023-08-30 12:12:18,590 - INFO - simulate_main - Before proceeding, doing checks for unequal brackets and illegal characters. +2023-08-30 12:12:18,590 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets((S ^ (R ^ Q)))... +2023-08-30 12:12:18,590 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-08-30 12:12:18,590 - DEBUG - check_for_illegal_characters - Calling check_for_illegal_characters((S ^ (R ^ Q))) +2023-08-30 12:12:18,590 - DEBUG - check_for_illegal_characters - ******************** starting input validation ******************* +2023-08-30 12:12:18,590 - DEBUG - validate_input - Calling validate_input(S)... +2023-08-30 12:12:18,590 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,590 - DEBUG - validate_input - Calling validate_input(^)... +2023-08-30 12:12:18,591 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,591 - DEBUG - validate_input - Calling validate_input(R)... +2023-08-30 12:12:18,591 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,591 - DEBUG - validate_input - Calling validate_input(^)... +2023-08-30 12:12:18,591 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,591 - DEBUG - validate_input - Calling validate_input(Q)... +2023-08-30 12:12:18,591 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,591 - DEBUG - check_for_illegal_characters - ******************** finished input validation ******************* +2023-08-30 12:12:18,591 - INFO - check_for_illegal_characters - PASS: There were no illegal characters found. +2023-08-30 12:12:18,591 - INFO - simulate_main - All checks are valid, proceeding with extracting information from statement. +2023-08-30 12:12:18,591 - INFO - user_input - Processing statement... +2023-08-30 12:12:18,591 - DEBUG - user_input - statement=(S ^ (R ^ Q)) +2023-08-30 12:12:18,591 - INFO - analyze_statement - Starting to analyze statement... +2023-08-30 12:12:18,591 - INFO - analyze_statement - The statement is sanitized from any whitespaces. +2023-08-30 12:12:18,591 - DEBUG - analyze_statement - All whitespaces need to be removed, proceeding. +2023-08-30 12:12:18,591 - DEBUG - clean_whitespaces - Calling clean_whitespaces((S ^ (R ^ Q)))... +2023-08-30 12:12:18,591 - DEBUG - clean_whitespaces - Finished removing whitespaces: statement=(S^(R^Q)) +2023-08-30 12:12:18,591 - DEBUG - analyze_statement - Finished removing any whitespaces found in statement. Proceeding with finding variables. +2023-08-30 12:12:18,591 - INFO - find_variables - Finding variables in statement... +2023-08-30 12:12:18,591 - DEBUG - find_variables - statement=(S^(R^Q)) +2023-08-30 12:12:18,591 - DEBUG - find_variables - variables_array=['S', 'R', 'Q'] +2023-08-30 12:12:18,592 - INFO - find_variables - Found all variables in statement. +2023-08-30 12:12:18,592 - INFO - find_variables - *** Variables: ['S', 'R', 'Q'] *** +2023-08-30 12:12:18,592 - DEBUG - analyze_statement - variables_arr=['S', 'R', 'Q'] +2023-08-30 12:12:18,592 - INFO - analyze_statement - The statement is converted to an array and any conditionals are sanitized. +2023-08-30 12:12:18,592 - DEBUG - create_array_of_elements - Creating an array from a string... +2023-08-30 12:12:18,592 - DEBUG - create_array_of_elements - Calling create_array_of_elements((S^(R^Q))) +2023-08-30 12:12:18,592 - DEBUG - create_array_of_elements - array_of_elements=['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'] +2023-08-30 12:12:18,592 - DEBUG - create_array_of_elements - Finished creating array. +2023-08-30 12:12:18,592 - DEBUG - check_conditionals - Calling check_conditionals(['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'], ['S', 'R', 'Q'])... +2023-08-30 12:12:18,592 - INFO - check_conditionals - PASS: Any conditional symbols present, are in the desired form. +2023-08-30 12:12:18,592 - DEBUG - create_conditionals - Creating one-piece conditionals from single elements. +2023-08-30 12:12:18,592 - DEBUG - create_conditionals - Searching for a '-' in array_of_elements=['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'] +2023-08-30 12:12:18,592 - DEBUG - create_conditionals - Search for conditionals finished and none were found, returning. +2023-08-30 12:12:18,592 - DEBUG - analyze_statement - In analyze_statement(): +len(variables_arr)=3, +variables_arr=['S', 'R', 'Q'], +array_of_elements=['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'] +2023-08-30 12:12:18,592 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,592 - INFO - print_details - ************************** ANALYSIS ************************** +2023-08-30 12:12:18,592 - INFO - print_details - -> Number of Variables: 3 +2023-08-30 12:12:18,592 - INFO - print_details - -> Variables: ['S', 'R', 'Q'] +2023-08-30 12:12:18,592 - INFO - print_details - -> Array of Elements: ['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'] +2023-08-30 12:12:18,592 - INFO - print_details - ************************** ANALYSIS ************************** +2023-08-30 12:12:18,592 - INFO - analyze_statement - Analyzing concluded. +2023-08-30 12:12:18,592 - INFO - parse_array - Starting to parse array... +2023-08-30 12:12:18,593 - DEBUG - remove_brackets_around_variables - Removing brackets around standalone variables... +2023-08-30 12:12:18,593 - DEBUG - remove_brackets_around_variables - arr=['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'] +2023-08-30 12:12:18,593 - DEBUG - remove_brackets_around_variables - Finished removing all brackets around variables. +2023-08-30 12:12:18,593 - DEBUG - parse_array - In parse_array(): elements_second=['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'] +2023-08-30 12:12:18,593 - DEBUG - add_brackets_around_unary_connectives - Adding brackets around unary connectives... +2023-08-30 12:12:18,593 - DEBUG - add_brackets_around_unary_connectives - arr=['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'] +2023-08-30 12:12:18,593 - DEBUG - add_brackets_around_unary_connectives - Finished adding brackets around all unary connectives. +2023-08-30 12:12:18,593 - DEBUG - parse_array - In parse_array(): elements_second=['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'] +2023-08-30 12:12:18,593 - INFO - parse_array - Final checks are ran before parsing concludes. +2023-08-30 12:12:18,593 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets(['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'])... +2023-08-30 12:12:18,593 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-08-30 12:12:18,593 - DEBUG - parse - Calling parse(['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'])... +2023-08-30 12:12:18,593 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', 'S', '^', '(', 'R', '^', 'Q', ')', ')'])... +2023-08-30 12:12:18,593 - DEBUG - remove_outer_brackets - array=['S', '^', '(', 'R', '^', 'Q', ')'] +2023-08-30 12:12:18,593 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-08-30 12:12:18,593 - DEBUG - parse - In parse(): arr=['S', '^', '(', 'R', '^', 'Q', ')'] +2023-08-30 12:12:18,593 - DEBUG - find_connective - Calling find_connectives(['S', '^', '(', 'R', '^', 'Q', ')'])... +2023-08-30 12:12:18,593 - DEBUG - find_connective - In find_connective(): elem=^, i=1 +2023-08-30 12:12:18,593 - DEBUG - find_connective - Found connective. +2023-08-30 12:12:18,593 - DEBUG - parse - Calling parse(['(', 'R', '^', 'Q', ')'])... +2023-08-30 12:12:18,594 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', 'R', '^', 'Q', ')'])... +2023-08-30 12:12:18,594 - DEBUG - remove_outer_brackets - array=['R', '^', 'Q'] +2023-08-30 12:12:18,594 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-08-30 12:12:18,594 - DEBUG - parse - In parse(): arr=['R', '^', 'Q'] +2023-08-30 12:12:18,594 - DEBUG - find_connective - Calling find_connectives(['R', '^', 'Q'])... +2023-08-30 12:12:18,594 - DEBUG - find_connective - In find_connective(): elem=^, i=1 +2023-08-30 12:12:18,594 - DEBUG - find_connective - Found connective. +2023-08-30 12:12:18,594 - DEBUG - parse - temp_array=[['R'], '^', ['Q']] +2023-08-30 12:12:18,594 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-08-30 12:12:18,594 - DEBUG - parse - temp_array=[['S'], '^', [['R'], '^', ['Q']]] +2023-08-30 12:12:18,594 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-08-30 12:12:18,594 - DEBUG - parse_array - tree_structured_array=[['S'], '^', [['R'], '^', ['Q']]] +2023-08-30 12:12:18,594 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,594 - INFO - print_details - *************************** PARSE *************************** +2023-08-30 12:12:18,594 - INFO - print_details - -> Parsed Array: [['S'], '^', [['R'], '^', ['Q']]] +2023-08-30 12:12:18,594 - INFO - print_details - *************************** PARSE *************************** +2023-08-30 12:12:18,594 - INFO - parse_array - Finished parsing array. +2023-08-30 12:12:18,594 - DEBUG - user_input - In user_input(): +number_of_variables=3, +variables_as_array=['S', 'R', 'Q'], +statement=(S ^ (R ^ Q)), +new_elements=[['S'], '^', [['R'], '^', ['Q']]]. +2023-08-30 12:12:18,594 - INFO - user_input - Gathered all information needed including variables and parsed array. +2023-08-30 12:12:18,594 - DEBUG - simulate_main - In simulate_main(): +number_of_variables=3, +variables_as_array=['S', 'R', 'Q'], +provided_statement=(S ^ (R ^ Q)), +elements_in_tree=[['S'], '^', [['R'], '^', ['Q']]] +2023-08-30 12:12:18,595 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,595 - INFO - print_details - ************************** SUMMARY ************************** +2023-08-30 12:12:18,595 - INFO - print_details - -> number_of_variables: 3 +2023-08-30 12:12:18,595 - INFO - print_details - -> variables_as_array: ['S', 'R', 'Q'] +2023-08-30 12:12:18,595 - INFO - print_details - -> provided_statement: (S ^ (R ^ Q)) +2023-08-30 12:12:18,595 - INFO - print_details - -> elements_in_tree: [['S'], '^', [['R'], '^', ['Q']]] +2023-08-30 12:12:18,595 - INFO - print_details - ************************** SUMMARY ************************** +2023-08-30 12:12:18,595 - INFO - evaluate_array_as_tree - Starting evaluation of array of elements... +2023-08-30 12:12:18,595 - DEBUG - create_matrix - Creating initial matrix... +2023-08-30 12:12:18,595 - DEBUG - recursive_table - Creating table entries recursively... +2023-08-30 12:12:18,595 - DEBUG - recursive_table - n=3 +2023-08-30 12:12:18,595 - DEBUG - recursive_table - Creating table entries recursively... +2023-08-30 12:12:18,595 - DEBUG - recursive_table - n=2 +2023-08-30 12:12:18,595 - DEBUG - recursive_table - Creating table entries recursively... +2023-08-30 12:12:18,595 - DEBUG - recursive_table - n=1 +2023-08-30 12:12:18,595 - DEBUG - recursive_table - array_table=['T', 'F'] +2023-08-30 12:12:18,595 - DEBUG - recursive_table - Finished creating array of table entries. +2023-08-30 12:12:18,595 - DEBUG - recursive_table - array_table=['TT', 'TF', 'FT', 'FF'] +2023-08-30 12:12:18,595 - DEBUG - recursive_table - Finished creating array of table entries. +2023-08-30 12:12:18,595 - DEBUG - recursive_table - array_table=['TTT', 'TTF', 'TFT', 'TFF', 'FTT', 'FTF', 'FFT', 'FFF'] +2023-08-30 12:12:18,595 - DEBUG - recursive_table - Finished creating array of table entries. +2023-08-30 12:12:18,595 - DEBUG - create_matrix - In create_matrix(): new_matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']] +2023-08-30 12:12:18,596 - INFO - create_matrix - Finished creating the initial 'truth' matrix. +2023-08-30 12:12:18,596 - INFO - create_matrix - *** Initial Matrix: [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']] *** +2023-08-30 12:12:18,596 - DEBUG - evaluate_array_as_tree - In evaluate_array_as_tree(): +elements_in_tree=[['S'], '^', [['R'], '^', ['Q']]], +counter=0, +matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], +variables_as_array=['S', 'R', 'Q'] +2023-08-30 12:12:18,596 - DEBUG - evaluate_array - Calling evaluate_array([['S'], '^', [['R'], '^', ['Q']]], 0, [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['S', 'R', 'Q'])... +2023-08-30 12:12:18,596 - DEBUG - evaluate_array - Calling evaluate_array([['R'], '^', ['Q']], 1, [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['S', 'R', 'Q'])... +2023-08-30 12:12:18,596 - DEBUG - switch_case - Entering switch_case(^, ['T', 'T', 'F', 'F', 'T', 'T', 'F', 'F'], ['T', 'F', 'T', 'F', 'T', 'F', 'T', 'F'])... +2023-08-30 12:12:18,596 - DEBUG - conj - In conj. case... +2023-08-30 12:12:18,596 - DEBUG - conjunction - Calling conjunction(['T', 'T', 'F', 'F', 'T', 'T', 'F', 'F'], ['T', 'F', 'T', 'F', 'T', 'F', 'T', 'F'])... +2023-08-30 12:12:18,596 - DEBUG - conjunction - new_row_values=['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'] +2023-08-30 12:12:18,596 - DEBUG - conjunction - Returning with new row values. +2023-08-30 12:12:18,596 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['R'], '^', ['Q']])... +2023-08-30 12:12:18,596 - DEBUG - set_new_array_elem - new_array=['R^Q'] +2023-08-30 12:12:18,596 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-08-30 12:12:18,596 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'], +final_variable_combined=['R^Q'], +matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], +variables=['S', 'R', 'Q'] +2023-08-30 12:12:18,596 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-08-30 12:12:18,596 - DEBUG - add_array_to_matrix - Calling add_array_to_matrix([['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'], ['S', 'R', 'Q'], ['R^Q'])... +2023-08-30 12:12:18,596 - DEBUG - add_array_to_matrix - variables=['S', 'R', 'Q', 'R^Q'] +2023-08-30 12:12:18,596 - DEBUG - add_array_to_matrix - Added array to matrix. +2023-08-30 12:12:18,597 - DEBUG - switch_case - Entering switch_case(^, ['T', 'T', 'T', 'T', 'F', 'F', 'F', 'F'], ['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'])... +2023-08-30 12:12:18,597 - DEBUG - conj - In conj. case... +2023-08-30 12:12:18,597 - DEBUG - conjunction - Calling conjunction(['T', 'T', 'T', 'T', 'F', 'F', 'F', 'F'], ['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'])... +2023-08-30 12:12:18,597 - DEBUG - conjunction - new_row_values=['T', 'F', 'F', 'F', 'F', 'F', 'F', 'F'] +2023-08-30 12:12:18,597 - DEBUG - conjunction - Returning with new row values. +2023-08-30 12:12:18,597 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['S'], '^', ['R^Q']])... +2023-08-30 12:12:18,597 - DEBUG - set_new_array_elem - new_array=['S^(R^Q)'] +2023-08-30 12:12:18,597 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-08-30 12:12:18,597 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'F', 'F', 'F', 'F', 'F', 'F', 'F'], +final_variable_combined=['S^(R^Q)'], +matrix=[['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'F'], ['T', 'F', 'T', 'F', 'F'], ['T', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'T', 'F'], ['F', 'T', 'F', 'F', 'F'], ['F', 'F', 'T', 'F', 'F'], ['F', 'F', 'F', 'F', 'F']], +variables=['S', 'R', 'Q', 'R^Q'] +2023-08-30 12:12:18,597 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-08-30 12:12:18,597 - DEBUG - evaluate_array_as_tree - returned_array=['T', 'F', 'F', 'F', 'F', 'F', 'F', 'F'], returned_matrix=[['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'F'], ['T', 'F', 'T', 'F', 'F'], ['T', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'T', 'F'], ['F', 'T', 'F', 'F', 'F'], ['F', 'F', 'T', 'F', 'F'], ['F', 'F', 'F', 'F', 'F']], all_variables=['S', 'R', 'Q', 'R^Q', 'S^(R^Q)'] +2023-08-30 12:12:18,597 - DEBUG - evaluate_array_as_tree - Finished evaluating array. +2023-08-30 12:12:18,597 - DEBUG - simulate_main - In simulate_main(): +final_value_array=['T', 'F', 'F', 'F', 'F', 'F', 'F', 'F'], +returned_matrix=[['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'F'], ['T', 'F', 'T', 'F', 'F'], ['T', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'T', 'F'], ['F', 'T', 'F', 'F', 'F'], ['F', 'F', 'T', 'F', 'F'], ['F', 'F', 'F', 'F', 'F']], +all_variables=['S', 'R', 'Q', 'R^Q', 'S^(R^Q)'] +2023-08-30 12:12:18,598 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,598 - INFO - print_details - ************************** EVALUATE ************************** +2023-08-30 12:12:18,598 - INFO - print_details - -> Statement: (S ^ (R ^ Q)) +2023-08-30 12:12:18,598 - INFO - print_details - -> Final Calculated Array: ['T', 'F', 'F', 'F', 'F', 'F', 'F', 'F'] +2023-08-30 12:12:18,598 - INFO - print_details - -> All Variables: ['S', 'R', 'Q', 'R^Q', 'S^(R^Q)'] +2023-08-30 12:12:18,598 - INFO - print_details - -> Final Matrix: [['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'F'], ['T', 'F', 'T', 'F', 'F'], ['T', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'T', 'F'], ['F', 'T', 'F', 'F', 'F'], ['F', 'F', 'T', 'F', 'F'], ['F', 'F', 'F', 'F', 'F']] +2023-08-30 12:12:18,598 - INFO - print_details - ************************** EVALUATE ************************** +2023-08-30 12:12:18,598 - INFO - simulate_main - Finished evaluating statement. +2023-08-30 12:12:18,598 - DEBUG - display_matrix - Displaying matrix to console... +2023-08-30 12:12:18,598 - DEBUG - get_number_of_spaces - Calling get_number_of_spaces(3, 1, ['S', 'R', 'Q', 'R^Q', 'S^(R^Q)'])... +2023-08-30 12:12:18,598 - DEBUG - get_number_of_spaces - total_space=30 +2023-08-30 12:12:18,598 - DEBUG - get_number_of_spaces - Finished calculating the total space. +2023-08-30 12:12:18,598 - DEBUG - simulate_main - Returning from simulate_main()... +2023-08-30 12:12:18,598 - INFO - simulate_main - Statement: (P v Q) +2023-08-30 12:12:18,598 - INFO - simulate_main - Before proceeding, doing checks for unequal brackets and illegal characters. +2023-08-30 12:12:18,599 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets((P v Q))... +2023-08-30 12:12:18,599 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-08-30 12:12:18,599 - DEBUG - check_for_illegal_characters - Calling check_for_illegal_characters((P v Q)) +2023-08-30 12:12:18,599 - DEBUG - check_for_illegal_characters - ******************** starting input validation ******************* +2023-08-30 12:12:18,599 - DEBUG - validate_input - Calling validate_input(P)... +2023-08-30 12:12:18,599 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,599 - DEBUG - validate_input - Calling validate_input(v)... +2023-08-30 12:12:18,599 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,599 - DEBUG - validate_input - Calling validate_input(Q)... +2023-08-30 12:12:18,599 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,599 - DEBUG - check_for_illegal_characters - ******************** finished input validation ******************* +2023-08-30 12:12:18,599 - INFO - check_for_illegal_characters - PASS: There were no illegal characters found. +2023-08-30 12:12:18,599 - INFO - simulate_main - All checks are valid, proceeding with extracting information from statement. +2023-08-30 12:12:18,599 - INFO - user_input - Processing statement... +2023-08-30 12:12:18,599 - DEBUG - user_input - statement=(P v Q) +2023-08-30 12:12:18,599 - INFO - analyze_statement - Starting to analyze statement... +2023-08-30 12:12:18,599 - INFO - analyze_statement - The statement is sanitized from any whitespaces. +2023-08-30 12:12:18,599 - DEBUG - analyze_statement - All whitespaces need to be removed, proceeding. +2023-08-30 12:12:18,599 - DEBUG - clean_whitespaces - Calling clean_whitespaces((P v Q))... +2023-08-30 12:12:18,599 - DEBUG - clean_whitespaces - Finished removing whitespaces: statement=(PvQ) +2023-08-30 12:12:18,600 - DEBUG - analyze_statement - Finished removing any whitespaces found in statement. Proceeding with finding variables. +2023-08-30 12:12:18,600 - INFO - find_variables - Finding variables in statement... +2023-08-30 12:12:18,600 - DEBUG - find_variables - statement=(PvQ) +2023-08-30 12:12:18,600 - DEBUG - find_variables - variables_array=['P', 'Q'] +2023-08-30 12:12:18,600 - INFO - find_variables - Found all variables in statement. +2023-08-30 12:12:18,600 - INFO - find_variables - *** Variables: ['P', 'Q'] *** +2023-08-30 12:12:18,600 - DEBUG - analyze_statement - variables_arr=['P', 'Q'] +2023-08-30 12:12:18,600 - INFO - analyze_statement - The statement is converted to an array and any conditionals are sanitized. +2023-08-30 12:12:18,600 - DEBUG - create_array_of_elements - Creating an array from a string... +2023-08-30 12:12:18,600 - DEBUG - create_array_of_elements - Calling create_array_of_elements((PvQ)) +2023-08-30 12:12:18,600 - DEBUG - create_array_of_elements - array_of_elements=['(', 'P', 'v', 'Q', ')'] +2023-08-30 12:12:18,600 - DEBUG - create_array_of_elements - Finished creating array. +2023-08-30 12:12:18,600 - DEBUG - check_conditionals - Calling check_conditionals(['(', 'P', 'v', 'Q', ')'], ['P', 'Q'])... +2023-08-30 12:12:18,600 - INFO - check_conditionals - PASS: Any conditional symbols present, are in the desired form. +2023-08-30 12:12:18,600 - DEBUG - create_conditionals - Creating one-piece conditionals from single elements. +2023-08-30 12:12:18,600 - DEBUG - create_conditionals - Searching for a '-' in array_of_elements=['(', 'P', 'v', 'Q', ')'] +2023-08-30 12:12:18,600 - DEBUG - create_conditionals - Search for conditionals finished and none were found, returning. +2023-08-30 12:12:18,600 - DEBUG - analyze_statement - In analyze_statement(): +len(variables_arr)=2, +variables_arr=['P', 'Q'], +array_of_elements=['(', 'P', 'v', 'Q', ')'] +2023-08-30 12:12:18,600 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,600 - INFO - print_details - ************************** ANALYSIS ************************** +2023-08-30 12:12:18,600 - INFO - print_details - -> Number of Variables: 2 +2023-08-30 12:12:18,601 - INFO - print_details - -> Variables: ['P', 'Q'] +2023-08-30 12:12:18,601 - INFO - print_details - -> Array of Elements: ['(', 'P', 'v', 'Q', ')'] +2023-08-30 12:12:18,601 - INFO - print_details - ************************** ANALYSIS ************************** +2023-08-30 12:12:18,601 - INFO - analyze_statement - Analyzing concluded. +2023-08-30 12:12:18,601 - INFO - parse_array - Starting to parse array... +2023-08-30 12:12:18,601 - DEBUG - remove_brackets_around_variables - Removing brackets around standalone variables... +2023-08-30 12:12:18,601 - DEBUG - remove_brackets_around_variables - arr=['(', 'P', 'v', 'Q', ')'] +2023-08-30 12:12:18,601 - DEBUG - remove_brackets_around_variables - Finished removing all brackets around variables. +2023-08-30 12:12:18,601 - DEBUG - parse_array - In parse_array(): elements_second=['(', 'P', 'v', 'Q', ')'] +2023-08-30 12:12:18,601 - DEBUG - add_brackets_around_unary_connectives - Adding brackets around unary connectives... +2023-08-30 12:12:18,601 - DEBUG - add_brackets_around_unary_connectives - arr=['(', 'P', 'v', 'Q', ')'] +2023-08-30 12:12:18,601 - DEBUG - add_brackets_around_unary_connectives - Finished adding brackets around all unary connectives. +2023-08-30 12:12:18,601 - DEBUG - parse_array - In parse_array(): elements_second=['(', 'P', 'v', 'Q', ')'] +2023-08-30 12:12:18,601 - INFO - parse_array - Final checks are ran before parsing concludes. +2023-08-30 12:12:18,601 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets(['(', 'P', 'v', 'Q', ')'])... +2023-08-30 12:12:18,601 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-08-30 12:12:18,601 - DEBUG - parse - Calling parse(['(', 'P', 'v', 'Q', ')'])... +2023-08-30 12:12:18,601 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', 'P', 'v', 'Q', ')'])... +2023-08-30 12:12:18,601 - DEBUG - remove_outer_brackets - array=['P', 'v', 'Q'] +2023-08-30 12:12:18,601 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-08-30 12:12:18,602 - DEBUG - parse - In parse(): arr=['P', 'v', 'Q'] +2023-08-30 12:12:18,602 - DEBUG - find_connective - Calling find_connectives(['P', 'v', 'Q'])... +2023-08-30 12:12:18,602 - DEBUG - find_connective - In find_connective(): elem=v, i=1 +2023-08-30 12:12:18,602 - DEBUG - find_connective - Found connective. +2023-08-30 12:12:18,602 - DEBUG - parse - temp_array=[['P'], 'v', ['Q']] +2023-08-30 12:12:18,602 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-08-30 12:12:18,602 - DEBUG - parse_array - tree_structured_array=[['P'], 'v', ['Q']] +2023-08-30 12:12:18,602 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,602 - INFO - print_details - *************************** PARSE *************************** +2023-08-30 12:12:18,602 - INFO - print_details - -> Parsed Array: [['P'], 'v', ['Q']] +2023-08-30 12:12:18,602 - INFO - print_details - *************************** PARSE *************************** +2023-08-30 12:12:18,602 - INFO - parse_array - Finished parsing array. +2023-08-30 12:12:18,602 - DEBUG - user_input - In user_input(): +number_of_variables=2, +variables_as_array=['P', 'Q'], +statement=(P v Q), +new_elements=[['P'], 'v', ['Q']]. +2023-08-30 12:12:18,602 - INFO - user_input - Gathered all information needed including variables and parsed array. +2023-08-30 12:12:18,602 - DEBUG - simulate_main - In simulate_main(): +number_of_variables=2, +variables_as_array=['P', 'Q'], +provided_statement=(P v Q), +elements_in_tree=[['P'], 'v', ['Q']] +2023-08-30 12:12:18,602 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,602 - INFO - print_details - ************************** SUMMARY ************************** +2023-08-30 12:12:18,602 - INFO - print_details - -> number_of_variables: 2 +2023-08-30 12:12:18,602 - INFO - print_details - -> variables_as_array: ['P', 'Q'] +2023-08-30 12:12:18,602 - INFO - print_details - -> provided_statement: (P v Q) +2023-08-30 12:12:18,602 - INFO - print_details - -> elements_in_tree: [['P'], 'v', ['Q']] +2023-08-30 12:12:18,602 - INFO - print_details - ************************** SUMMARY ************************** +2023-08-30 12:12:18,602 - INFO - evaluate_array_as_tree - Starting evaluation of array of elements... +2023-08-30 12:12:18,602 - DEBUG - create_matrix - Creating initial matrix... +2023-08-30 12:12:18,602 - DEBUG - recursive_table - Creating table entries recursively... +2023-08-30 12:12:18,602 - DEBUG - recursive_table - n=2 +2023-08-30 12:12:18,602 - DEBUG - recursive_table - Creating table entries recursively... +2023-08-30 12:12:18,602 - DEBUG - recursive_table - n=1 +2023-08-30 12:12:18,602 - DEBUG - recursive_table - array_table=['T', 'F'] +2023-08-30 12:12:18,602 - DEBUG - recursive_table - Finished creating array of table entries. +2023-08-30 12:12:18,602 - DEBUG - recursive_table - array_table=['TT', 'TF', 'FT', 'FF'] +2023-08-30 12:12:18,603 - DEBUG - recursive_table - Finished creating array of table entries. +2023-08-30 12:12:18,603 - DEBUG - create_matrix - In create_matrix(): new_matrix=[['T', 'T'], ['T', 'F'], ['F', 'T'], ['F', 'F']] +2023-08-30 12:12:18,603 - INFO - create_matrix - Finished creating the initial 'truth' matrix. +2023-08-30 12:12:18,603 - INFO - create_matrix - *** Initial Matrix: [['T', 'T'], ['T', 'F'], ['F', 'T'], ['F', 'F']] *** +2023-08-30 12:12:18,603 - DEBUG - evaluate_array_as_tree - In evaluate_array_as_tree(): +elements_in_tree=[['P'], 'v', ['Q']], +counter=0, +matrix=[['T', 'T'], ['T', 'F'], ['F', 'T'], ['F', 'F']], +variables_as_array=['P', 'Q'] +2023-08-30 12:12:18,603 - DEBUG - evaluate_array - Calling evaluate_array([['P'], 'v', ['Q']], 0, [['T', 'T'], ['T', 'F'], ['F', 'T'], ['F', 'F']], ['P', 'Q'])... +2023-08-30 12:12:18,603 - DEBUG - switch_case - Entering switch_case(v, ['T', 'T', 'F', 'F'], ['T', 'F', 'T', 'F'])... +2023-08-30 12:12:18,603 - DEBUG - disj - In disj. case... +2023-08-30 12:12:18,604 - DEBUG - disjunction - Calling disjunction(['T', 'T', 'F', 'F'], ['T', 'F', 'T', 'F'])... +2023-08-30 12:12:18,604 - DEBUG - disjunction - new_row_values=['T', 'T', 'T', 'F'] +2023-08-30 12:12:18,604 - DEBUG - disjunction - Returning with new row values. +2023-08-30 12:12:18,604 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['P'], 'v', ['Q']])... +2023-08-30 12:12:18,604 - DEBUG - set_new_array_elem - new_array=['PvQ'] +2023-08-30 12:12:18,604 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-08-30 12:12:18,604 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'T', 'T', 'F'], +final_variable_combined=['PvQ'], +matrix=[['T', 'T', 'T'], ['T', 'F', 'T'], ['F', 'T', 'T'], ['F', 'F', 'F']], +variables=['P', 'Q'] +2023-08-30 12:12:18,604 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-08-30 12:12:18,604 - DEBUG - evaluate_array_as_tree - returned_array=['T', 'T', 'T', 'F'], returned_matrix=[['T', 'T', 'T'], ['T', 'F', 'T'], ['F', 'T', 'T'], ['F', 'F', 'F']], all_variables=['P', 'Q', 'PvQ'] +2023-08-30 12:12:18,604 - DEBUG - evaluate_array_as_tree - Finished evaluating array. +2023-08-30 12:12:18,604 - DEBUG - simulate_main - In simulate_main(): +final_value_array=['T', 'T', 'T', 'F'], +returned_matrix=[['T', 'T', 'T'], ['T', 'F', 'T'], ['F', 'T', 'T'], ['F', 'F', 'F']], +all_variables=['P', 'Q', 'PvQ'] +2023-08-30 12:12:18,604 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,604 - INFO - print_details - ************************** EVALUATE ************************** +2023-08-30 12:12:18,604 - INFO - print_details - -> Statement: (P v Q) +2023-08-30 12:12:18,604 - INFO - print_details - -> Final Calculated Array: ['T', 'T', 'T', 'F'] +2023-08-30 12:12:18,604 - INFO - print_details - -> All Variables: ['P', 'Q', 'PvQ'] +2023-08-30 12:12:18,604 - INFO - print_details - -> Final Matrix: [['T', 'T', 'T'], ['T', 'F', 'T'], ['F', 'T', 'T'], ['F', 'F', 'F']] +2023-08-30 12:12:18,604 - INFO - print_details - ************************** EVALUATE ************************** +2023-08-30 12:12:18,604 - INFO - simulate_main - Finished evaluating statement. +2023-08-30 12:12:18,604 - DEBUG - display_matrix - Displaying matrix to console... +2023-08-30 12:12:18,605 - DEBUG - get_number_of_spaces - Calling get_number_of_spaces(2, 0, ['P', 'Q', 'PvQ'])... +2023-08-30 12:12:18,605 - DEBUG - get_number_of_spaces - total_space=16 +2023-08-30 12:12:18,605 - DEBUG - get_number_of_spaces - Finished calculating the total space. +2023-08-30 12:12:18,605 - DEBUG - simulate_main - Returning from simulate_main()... +2023-08-30 12:12:18,605 - INFO - simulate_main - Statement: (P -> (Q ^ R)) +2023-08-30 12:12:18,605 - INFO - simulate_main - Before proceeding, doing checks for unequal brackets and illegal characters. +2023-08-30 12:12:18,605 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets((P -> (Q ^ R)))... +2023-08-30 12:12:18,605 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-08-30 12:12:18,605 - DEBUG - check_for_illegal_characters - Calling check_for_illegal_characters((P -> (Q ^ R))) +2023-08-30 12:12:18,605 - DEBUG - check_for_illegal_characters - ******************** starting input validation ******************* +2023-08-30 12:12:18,605 - DEBUG - validate_input - Calling validate_input(P)... +2023-08-30 12:12:18,605 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,605 - DEBUG - validate_input - Calling validate_input(-)... +2023-08-30 12:12:18,605 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,605 - DEBUG - validate_input - Calling validate_input(>)... +2023-08-30 12:12:18,605 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,605 - DEBUG - validate_input - Calling validate_input(Q)... +2023-08-30 12:12:18,605 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,606 - DEBUG - validate_input - Calling validate_input(^)... +2023-08-30 12:12:18,606 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,606 - DEBUG - validate_input - Calling validate_input(R)... +2023-08-30 12:12:18,606 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,606 - DEBUG - check_for_illegal_characters - ******************** finished input validation ******************* +2023-08-30 12:12:18,606 - INFO - check_for_illegal_characters - PASS: There were no illegal characters found. +2023-08-30 12:12:18,606 - INFO - simulate_main - All checks are valid, proceeding with extracting information from statement. +2023-08-30 12:12:18,606 - INFO - user_input - Processing statement... +2023-08-30 12:12:18,606 - DEBUG - user_input - statement=(P -> (Q ^ R)) +2023-08-30 12:12:18,606 - INFO - analyze_statement - Starting to analyze statement... +2023-08-30 12:12:18,606 - INFO - analyze_statement - The statement is sanitized from any whitespaces. +2023-08-30 12:12:18,606 - DEBUG - analyze_statement - All whitespaces need to be removed, proceeding. +2023-08-30 12:12:18,606 - DEBUG - clean_whitespaces - Calling clean_whitespaces((P -> (Q ^ R)))... +2023-08-30 12:12:18,606 - DEBUG - clean_whitespaces - Finished removing whitespaces: statement=(P->(Q^R)) +2023-08-30 12:12:18,606 - DEBUG - analyze_statement - Finished removing any whitespaces found in statement. Proceeding with finding variables. +2023-08-30 12:12:18,606 - INFO - find_variables - Finding variables in statement... +2023-08-30 12:12:18,606 - DEBUG - find_variables - statement=(P->(Q^R)) +2023-08-30 12:12:18,606 - DEBUG - find_variables - variables_array=['P', 'Q', 'R'] +2023-08-30 12:12:18,606 - INFO - find_variables - Found all variables in statement. +2023-08-30 12:12:18,606 - INFO - find_variables - *** Variables: ['P', 'Q', 'R'] *** +2023-08-30 12:12:18,607 - DEBUG - analyze_statement - variables_arr=['P', 'Q', 'R'] +2023-08-30 12:12:18,607 - INFO - analyze_statement - The statement is converted to an array and any conditionals are sanitized. +2023-08-30 12:12:18,607 - DEBUG - create_array_of_elements - Creating an array from a string... +2023-08-30 12:12:18,607 - DEBUG - create_array_of_elements - Calling create_array_of_elements((P->(Q^R))) +2023-08-30 12:12:18,607 - DEBUG - create_array_of_elements - array_of_elements=['(', 'P', '-', '>', '(', 'Q', '^', 'R', ')', ')'] +2023-08-30 12:12:18,607 - DEBUG - create_array_of_elements - Finished creating array. +2023-08-30 12:12:18,607 - DEBUG - check_conditionals - Calling check_conditionals(['(', 'P', '-', '>', '(', 'Q', '^', 'R', ')', ')'], ['P', 'Q', 'R'])... +2023-08-30 12:12:18,607 - INFO - check_conditionals - PASS: Any conditional symbols present, are in the desired form. +2023-08-30 12:12:18,607 - DEBUG - create_conditionals - Creating one-piece conditionals from single elements. +2023-08-30 12:12:18,607 - DEBUG - create_conditionals - Searching for a '-' in array_of_elements=['(', 'P', '-', '>', '(', 'Q', '^', 'R', ')', ')'] +2023-08-30 12:12:18,607 - DEBUG - create_conditionals - Conditional symbols were found in ['(', 'P', '-', '>', '(', 'Q', '^', 'R', ')', ')'] +2023-08-30 12:12:18,607 - DEBUG - create_conditionals - array_of_elements=['(', 'P', '->', '(', 'Q', '^', 'R', ')', ')'] +2023-08-30 12:12:18,607 - DEBUG - create_conditionals - Finished creating conditionals. +2023-08-30 12:12:18,607 - DEBUG - analyze_statement - In analyze_statement(): +len(variables_arr)=3, +variables_arr=['P', 'Q', 'R'], +array_of_elements=['(', 'P', '->', '(', 'Q', '^', 'R', ')', ')'] +2023-08-30 12:12:18,607 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,607 - INFO - print_details - ************************** ANALYSIS ************************** +2023-08-30 12:12:18,607 - INFO - print_details - -> Number of Variables: 3 +2023-08-30 12:12:18,607 - INFO - print_details - -> Variables: ['P', 'Q', 'R'] +2023-08-30 12:12:18,607 - INFO - print_details - -> Array of Elements: ['(', 'P', '->', '(', 'Q', '^', 'R', ')', ')'] +2023-08-30 12:12:18,607 - INFO - print_details - ************************** ANALYSIS ************************** +2023-08-30 12:12:18,608 - INFO - analyze_statement - Analyzing concluded. +2023-08-30 12:12:18,608 - INFO - parse_array - Starting to parse array... +2023-08-30 12:12:18,608 - DEBUG - remove_brackets_around_variables - Removing brackets around standalone variables... +2023-08-30 12:12:18,608 - DEBUG - remove_brackets_around_variables - arr=['(', 'P', '->', '(', 'Q', '^', 'R', ')', ')'] +2023-08-30 12:12:18,608 - DEBUG - remove_brackets_around_variables - Finished removing all brackets around variables. +2023-08-30 12:12:18,608 - DEBUG - parse_array - In parse_array(): elements_second=['(', 'P', '->', '(', 'Q', '^', 'R', ')', ')'] +2023-08-30 12:12:18,608 - DEBUG - add_brackets_around_unary_connectives - Adding brackets around unary connectives... +2023-08-30 12:12:18,608 - DEBUG - add_brackets_around_unary_connectives - arr=['(', 'P', '->', '(', 'Q', '^', 'R', ')', ')'] +2023-08-30 12:12:18,608 - DEBUG - add_brackets_around_unary_connectives - Finished adding brackets around all unary connectives. +2023-08-30 12:12:18,608 - DEBUG - parse_array - In parse_array(): elements_second=['(', 'P', '->', '(', 'Q', '^', 'R', ')', ')'] +2023-08-30 12:12:18,608 - INFO - parse_array - Final checks are ran before parsing concludes. +2023-08-30 12:12:18,608 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets(['(', 'P', '->', '(', 'Q', '^', 'R', ')', ')'])... +2023-08-30 12:12:18,608 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-08-30 12:12:18,608 - DEBUG - parse - Calling parse(['(', 'P', '->', '(', 'Q', '^', 'R', ')', ')'])... +2023-08-30 12:12:18,608 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', 'P', '->', '(', 'Q', '^', 'R', ')', ')'])... +2023-08-30 12:12:18,608 - DEBUG - remove_outer_brackets - array=['P', '->', '(', 'Q', '^', 'R', ')'] +2023-08-30 12:12:18,608 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-08-30 12:12:18,608 - DEBUG - parse - In parse(): arr=['P', '->', '(', 'Q', '^', 'R', ')'] +2023-08-30 12:12:18,608 - DEBUG - find_connective - Calling find_connectives(['P', '->', '(', 'Q', '^', 'R', ')'])... +2023-08-30 12:12:18,608 - DEBUG - find_connective - In find_connective(): elem=->, i=1 +2023-08-30 12:12:18,608 - DEBUG - find_connective - Found connective. +2023-08-30 12:12:18,609 - DEBUG - parse - Calling parse(['(', 'Q', '^', 'R', ')'])... +2023-08-30 12:12:18,609 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', 'Q', '^', 'R', ')'])... +2023-08-30 12:12:18,609 - DEBUG - remove_outer_brackets - array=['Q', '^', 'R'] +2023-08-30 12:12:18,609 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-08-30 12:12:18,609 - DEBUG - parse - In parse(): arr=['Q', '^', 'R'] +2023-08-30 12:12:18,609 - DEBUG - find_connective - Calling find_connectives(['Q', '^', 'R'])... +2023-08-30 12:12:18,609 - DEBUG - find_connective - In find_connective(): elem=^, i=1 +2023-08-30 12:12:18,609 - DEBUG - find_connective - Found connective. +2023-08-30 12:12:18,609 - DEBUG - parse - temp_array=[['Q'], '^', ['R']] +2023-08-30 12:12:18,609 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-08-30 12:12:18,609 - DEBUG - parse - temp_array=[['P'], '->', [['Q'], '^', ['R']]] +2023-08-30 12:12:18,609 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-08-30 12:12:18,609 - DEBUG - parse_array - tree_structured_array=[['P'], '->', [['Q'], '^', ['R']]] +2023-08-30 12:12:18,609 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,609 - INFO - print_details - *************************** PARSE *************************** +2023-08-30 12:12:18,609 - INFO - print_details - -> Parsed Array: [['P'], '->', [['Q'], '^', ['R']]] +2023-08-30 12:12:18,609 - INFO - print_details - *************************** PARSE *************************** +2023-08-30 12:12:18,609 - INFO - parse_array - Finished parsing array. +2023-08-30 12:12:18,609 - DEBUG - user_input - In user_input(): +number_of_variables=3, +variables_as_array=['P', 'Q', 'R'], +statement=(P -> (Q ^ R)), +new_elements=[['P'], '->', [['Q'], '^', ['R']]]. +2023-08-30 12:12:18,609 - INFO - user_input - Gathered all information needed including variables and parsed array. +2023-08-30 12:12:18,609 - DEBUG - simulate_main - In simulate_main(): +number_of_variables=3, +variables_as_array=['P', 'Q', 'R'], +provided_statement=(P -> (Q ^ R)), +elements_in_tree=[['P'], '->', [['Q'], '^', ['R']]] +2023-08-30 12:12:18,610 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,610 - INFO - print_details - ************************** SUMMARY ************************** +2023-08-30 12:12:18,610 - INFO - print_details - -> number_of_variables: 3 +2023-08-30 12:12:18,610 - INFO - print_details - -> variables_as_array: ['P', 'Q', 'R'] +2023-08-30 12:12:18,610 - INFO - print_details - -> provided_statement: (P -> (Q ^ R)) +2023-08-30 12:12:18,610 - INFO - print_details - -> elements_in_tree: [['P'], '->', [['Q'], '^', ['R']]] +2023-08-30 12:12:18,610 - INFO - print_details - ************************** SUMMARY ************************** +2023-08-30 12:12:18,610 - INFO - evaluate_array_as_tree - Starting evaluation of array of elements... +2023-08-30 12:12:18,610 - DEBUG - create_matrix - Creating initial matrix... +2023-08-30 12:12:18,610 - DEBUG - recursive_table - Creating table entries recursively... +2023-08-30 12:12:18,610 - DEBUG - recursive_table - n=3 +2023-08-30 12:12:18,610 - DEBUG - recursive_table - Creating table entries recursively... +2023-08-30 12:12:18,610 - DEBUG - recursive_table - n=2 +2023-08-30 12:12:18,610 - DEBUG - recursive_table - Creating table entries recursively... +2023-08-30 12:12:18,610 - DEBUG - recursive_table - n=1 +2023-08-30 12:12:18,610 - DEBUG - recursive_table - array_table=['T', 'F'] +2023-08-30 12:12:18,610 - DEBUG - recursive_table - Finished creating array of table entries. +2023-08-30 12:12:18,610 - DEBUG - recursive_table - array_table=['TT', 'TF', 'FT', 'FF'] +2023-08-30 12:12:18,610 - DEBUG - recursive_table - Finished creating array of table entries. +2023-08-30 12:12:18,610 - DEBUG - recursive_table - array_table=['TTT', 'TTF', 'TFT', 'TFF', 'FTT', 'FTF', 'FFT', 'FFF'] +2023-08-30 12:12:18,610 - DEBUG - recursive_table - Finished creating array of table entries. +2023-08-30 12:12:18,611 - DEBUG - create_matrix - In create_matrix(): new_matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']] +2023-08-30 12:12:18,611 - INFO - create_matrix - Finished creating the initial 'truth' matrix. +2023-08-30 12:12:18,611 - INFO - create_matrix - *** Initial Matrix: [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']] *** +2023-08-30 12:12:18,611 - DEBUG - evaluate_array_as_tree - In evaluate_array_as_tree(): +elements_in_tree=[['P'], '->', [['Q'], '^', ['R']]], +counter=0, +matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], +variables_as_array=['P', 'Q', 'R'] +2023-08-30 12:12:18,611 - DEBUG - evaluate_array - Calling evaluate_array([['P'], '->', [['Q'], '^', ['R']]], 0, [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['P', 'Q', 'R'])... +2023-08-30 12:12:18,611 - DEBUG - evaluate_array - Calling evaluate_array([['Q'], '^', ['R']], 1, [['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['P', 'Q', 'R'])... +2023-08-30 12:12:18,611 - DEBUG - switch_case - Entering switch_case(^, ['T', 'T', 'F', 'F', 'T', 'T', 'F', 'F'], ['T', 'F', 'T', 'F', 'T', 'F', 'T', 'F'])... +2023-08-30 12:12:18,611 - DEBUG - conj - In conj. case... +2023-08-30 12:12:18,611 - DEBUG - conjunction - Calling conjunction(['T', 'T', 'F', 'F', 'T', 'T', 'F', 'F'], ['T', 'F', 'T', 'F', 'T', 'F', 'T', 'F'])... +2023-08-30 12:12:18,611 - DEBUG - conjunction - new_row_values=['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'] +2023-08-30 12:12:18,611 - DEBUG - conjunction - Returning with new row values. +2023-08-30 12:12:18,611 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['Q'], '^', ['R']])... +2023-08-30 12:12:18,611 - DEBUG - set_new_array_elem - new_array=['Q^R'] +2023-08-30 12:12:18,611 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-08-30 12:12:18,611 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'], +final_variable_combined=['Q^R'], +matrix=[['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], +variables=['P', 'Q', 'R'] +2023-08-30 12:12:18,611 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-08-30 12:12:18,611 - DEBUG - add_array_to_matrix - Calling add_array_to_matrix([['T', 'T', 'T'], ['T', 'T', 'F'], ['T', 'F', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'T', 'F'], ['F', 'F', 'T'], ['F', 'F', 'F']], ['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'], ['P', 'Q', 'R'], ['Q^R'])... +2023-08-30 12:12:18,612 - DEBUG - add_array_to_matrix - variables=['P', 'Q', 'R', 'Q^R'] +2023-08-30 12:12:18,612 - DEBUG - add_array_to_matrix - Added array to matrix. +2023-08-30 12:12:18,612 - DEBUG - switch_case - Entering switch_case(->, ['T', 'T', 'T', 'T', 'F', 'F', 'F', 'F'], ['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'])... +2023-08-30 12:12:18,612 - DEBUG - cond - In cond. case... +2023-08-30 12:12:18,612 - DEBUG - conditional - Calling conditional(['T', 'T', 'T', 'T', 'F', 'F', 'F', 'F'], ['T', 'F', 'F', 'F', 'T', 'F', 'F', 'F'])... +2023-08-30 12:12:18,612 - DEBUG - conditional - new_row_values=['T', 'F', 'F', 'F', 'T', 'T', 'T', 'T'] +2023-08-30 12:12:18,612 - DEBUG - conditional - Returning with new row values. +2023-08-30 12:12:18,612 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['P'], '->', ['Q^R']])... +2023-08-30 12:12:18,612 - DEBUG - set_new_array_elem - new_array=['P->(Q^R)'] +2023-08-30 12:12:18,612 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-08-30 12:12:18,612 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'F', 'F', 'F', 'T', 'T', 'T', 'T'], +final_variable_combined=['P->(Q^R)'], +matrix=[['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'F'], ['T', 'F', 'T', 'F', 'F'], ['T', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'T', 'T'], ['F', 'T', 'F', 'F', 'T'], ['F', 'F', 'T', 'F', 'T'], ['F', 'F', 'F', 'F', 'T']], +variables=['P', 'Q', 'R', 'Q^R'] +2023-08-30 12:12:18,612 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-08-30 12:12:18,612 - DEBUG - evaluate_array_as_tree - returned_array=['T', 'F', 'F', 'F', 'T', 'T', 'T', 'T'], returned_matrix=[['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'F'], ['T', 'F', 'T', 'F', 'F'], ['T', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'T', 'T'], ['F', 'T', 'F', 'F', 'T'], ['F', 'F', 'T', 'F', 'T'], ['F', 'F', 'F', 'F', 'T']], all_variables=['P', 'Q', 'R', 'Q^R', 'P->(Q^R)'] +2023-08-30 12:12:18,612 - DEBUG - evaluate_array_as_tree - Finished evaluating array. +2023-08-30 12:12:18,612 - DEBUG - simulate_main - In simulate_main(): +final_value_array=['T', 'F', 'F', 'F', 'T', 'T', 'T', 'T'], +returned_matrix=[['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'F'], ['T', 'F', 'T', 'F', 'F'], ['T', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'T', 'T'], ['F', 'T', 'F', 'F', 'T'], ['F', 'F', 'T', 'F', 'T'], ['F', 'F', 'F', 'F', 'T']], +all_variables=['P', 'Q', 'R', 'Q^R', 'P->(Q^R)'] +2023-08-30 12:12:18,612 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,612 - INFO - print_details - ************************** EVALUATE ************************** +2023-08-30 12:12:18,612 - INFO - print_details - -> Statement: (P -> (Q ^ R)) +2023-08-30 12:12:18,612 - INFO - print_details - -> Final Calculated Array: ['T', 'F', 'F', 'F', 'T', 'T', 'T', 'T'] +2023-08-30 12:12:18,612 - INFO - print_details - -> All Variables: ['P', 'Q', 'R', 'Q^R', 'P->(Q^R)'] +2023-08-30 12:12:18,613 - INFO - print_details - -> Final Matrix: [['T', 'T', 'T', 'T', 'T'], ['T', 'T', 'F', 'F', 'F'], ['T', 'F', 'T', 'F', 'F'], ['T', 'F', 'F', 'F', 'F'], ['F', 'T', 'T', 'T', 'T'], ['F', 'T', 'F', 'F', 'T'], ['F', 'F', 'T', 'F', 'T'], ['F', 'F', 'F', 'F', 'T']] +2023-08-30 12:12:18,613 - INFO - print_details - ************************** EVALUATE ************************** +2023-08-30 12:12:18,613 - INFO - simulate_main - Finished evaluating statement. +2023-08-30 12:12:18,613 - DEBUG - display_matrix - Displaying matrix to console... +2023-08-30 12:12:18,613 - DEBUG - get_number_of_spaces - Calling get_number_of_spaces(3, 1, ['P', 'Q', 'R', 'Q^R', 'P->(Q^R)'])... +2023-08-30 12:12:18,613 - DEBUG - get_number_of_spaces - total_space=31 +2023-08-30 12:12:18,613 - DEBUG - get_number_of_spaces - Finished calculating the total space. +2023-08-30 12:12:18,613 - DEBUG - simulate_main - Returning from simulate_main()... +2023-08-30 12:12:18,613 - INFO - simulate_main - Statement: ((P -> Q) <-> ((!Q) -> (!P))) +2023-08-30 12:12:18,613 - INFO - simulate_main - Before proceeding, doing checks for unequal brackets and illegal characters. +2023-08-30 12:12:18,613 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets(((P -> Q) <-> ((!Q) -> (!P))))... +2023-08-30 12:12:18,613 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-08-30 12:12:18,613 - DEBUG - check_for_illegal_characters - Calling check_for_illegal_characters(((P -> Q) <-> ((!Q) -> (!P)))) +2023-08-30 12:12:18,613 - DEBUG - check_for_illegal_characters - ******************** starting input validation ******************* +2023-08-30 12:12:18,613 - DEBUG - validate_input - Calling validate_input(P)... +2023-08-30 12:12:18,613 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,613 - DEBUG - validate_input - Calling validate_input(-)... +2023-08-30 12:12:18,613 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,614 - DEBUG - validate_input - Calling validate_input(>)... +2023-08-30 12:12:18,614 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,614 - DEBUG - validate_input - Calling validate_input(Q)... +2023-08-30 12:12:18,614 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,614 - DEBUG - validate_input - Calling validate_input(<)... +2023-08-30 12:12:18,614 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,614 - DEBUG - validate_input - Calling validate_input(-)... +2023-08-30 12:12:18,614 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,614 - DEBUG - validate_input - Calling validate_input(>)... +2023-08-30 12:12:18,614 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,614 - DEBUG - validate_input - Calling validate_input(!)... +2023-08-30 12:12:18,614 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,614 - DEBUG - validate_input - Calling validate_input(Q)... +2023-08-30 12:12:18,614 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,614 - DEBUG - validate_input - Calling validate_input(-)... +2023-08-30 12:12:18,614 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,614 - DEBUG - validate_input - Calling validate_input(>)... +2023-08-30 12:12:18,614 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,614 - DEBUG - validate_input - Calling validate_input(!)... +2023-08-30 12:12:18,615 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,615 - DEBUG - validate_input - Calling validate_input(P)... +2023-08-30 12:12:18,615 - DEBUG - validate_input - Checked against a regex. result(is it valid?)=True. +2023-08-30 12:12:18,615 - DEBUG - check_for_illegal_characters - ******************** finished input validation ******************* +2023-08-30 12:12:18,615 - INFO - check_for_illegal_characters - PASS: There were no illegal characters found. +2023-08-30 12:12:18,615 - INFO - simulate_main - All checks are valid, proceeding with extracting information from statement. +2023-08-30 12:12:18,615 - INFO - user_input - Processing statement... +2023-08-30 12:12:18,615 - DEBUG - user_input - statement=((P -> Q) <-> ((!Q) -> (!P))) +2023-08-30 12:12:18,615 - INFO - analyze_statement - Starting to analyze statement... +2023-08-30 12:12:18,615 - INFO - analyze_statement - The statement is sanitized from any whitespaces. +2023-08-30 12:12:18,615 - DEBUG - analyze_statement - All whitespaces need to be removed, proceeding. +2023-08-30 12:12:18,615 - DEBUG - clean_whitespaces - Calling clean_whitespaces(((P -> Q) <-> ((!Q) -> (!P))))... +2023-08-30 12:12:18,615 - DEBUG - clean_whitespaces - Finished removing whitespaces: statement=((P->Q)<->((!Q)->(!P))) +2023-08-30 12:12:18,615 - DEBUG - analyze_statement - Finished removing any whitespaces found in statement. Proceeding with finding variables. +2023-08-30 12:12:18,615 - INFO - find_variables - Finding variables in statement... +2023-08-30 12:12:18,615 - DEBUG - find_variables - statement=((P->Q)<->((!Q)->(!P))) +2023-08-30 12:12:18,615 - DEBUG - find_variables - variables_array=['P', 'Q'] +2023-08-30 12:12:18,615 - INFO - find_variables - Found all variables in statement. +2023-08-30 12:12:18,615 - INFO - find_variables - *** Variables: ['P', 'Q'] *** +2023-08-30 12:12:18,615 - DEBUG - analyze_statement - variables_arr=['P', 'Q'] +2023-08-30 12:12:18,615 - INFO - analyze_statement - The statement is converted to an array and any conditionals are sanitized. +2023-08-30 12:12:18,615 - DEBUG - create_array_of_elements - Creating an array from a string... +2023-08-30 12:12:18,616 - DEBUG - create_array_of_elements - Calling create_array_of_elements(((P->Q)<->((!Q)->(!P)))) +2023-08-30 12:12:18,616 - DEBUG - create_array_of_elements - array_of_elements=['(', '(', 'P', '-', '>', 'Q', ')', '<', '-', '>', '(', '(', '!', 'Q', ')', '-', '>', '(', '!', 'P', ')', ')', ')'] +2023-08-30 12:12:18,616 - DEBUG - create_array_of_elements - Finished creating array. +2023-08-30 12:12:18,616 - DEBUG - check_conditionals - Calling check_conditionals(['(', '(', 'P', '-', '>', 'Q', ')', '<', '-', '>', '(', '(', '!', 'Q', ')', '-', '>', '(', '!', 'P', ')', ')', ')'], ['P', 'Q'])... +2023-08-30 12:12:18,616 - INFO - check_conditionals - PASS: Any conditional symbols present, are in the desired form. +2023-08-30 12:12:18,616 - DEBUG - create_conditionals - Creating one-piece conditionals from single elements. +2023-08-30 12:12:18,616 - DEBUG - create_conditionals - Searching for a '-' in array_of_elements=['(', '(', 'P', '-', '>', 'Q', ')', '<', '-', '>', '(', '(', '!', 'Q', ')', '-', '>', '(', '!', 'P', ')', ')', ')'] +2023-08-30 12:12:18,616 - DEBUG - create_conditionals - Conditional symbols were found in ['(', '(', 'P', '-', '>', 'Q', ')', '<', '-', '>', '(', '(', '!', 'Q', ')', '-', '>', '(', '!', 'P', ')', ')', ')'] +2023-08-30 12:12:18,616 - DEBUG - create_conditionals - array_of_elements=['(', '(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')', ')'] +2023-08-30 12:12:18,616 - DEBUG - create_conditionals - Finished creating conditionals. +2023-08-30 12:12:18,616 - DEBUG - analyze_statement - In analyze_statement(): +len(variables_arr)=2, +variables_arr=['P', 'Q'], +array_of_elements=['(', '(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')', ')'] +2023-08-30 12:12:18,616 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,616 - INFO - print_details - ************************** ANALYSIS ************************** +2023-08-30 12:12:18,616 - INFO - print_details - -> Number of Variables: 2 +2023-08-30 12:12:18,616 - INFO - print_details - -> Variables: ['P', 'Q'] +2023-08-30 12:12:18,616 - INFO - print_details - -> Array of Elements: ['(', '(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')', ')'] +2023-08-30 12:12:18,616 - INFO - print_details - ************************** ANALYSIS ************************** +2023-08-30 12:12:18,616 - INFO - analyze_statement - Analyzing concluded. +2023-08-30 12:12:18,616 - INFO - parse_array - Starting to parse array... +2023-08-30 12:12:18,616 - DEBUG - remove_brackets_around_variables - Removing brackets around standalone variables... +2023-08-30 12:12:18,616 - DEBUG - remove_brackets_around_variables - arr=['(', '(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')', ')'] +2023-08-30 12:12:18,617 - DEBUG - remove_brackets_around_variables - Finished removing all brackets around variables. +2023-08-30 12:12:18,617 - DEBUG - parse_array - In parse_array(): elements_second=['(', '(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')', ')'] +2023-08-30 12:12:18,617 - DEBUG - add_brackets_around_unary_connectives - Adding brackets around unary connectives... +2023-08-30 12:12:18,617 - DEBUG - add_brackets_around_unary_connectives - arr=['(', '(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')', ')'] +2023-08-30 12:12:18,617 - DEBUG - add_brackets_around_unary_connectives - Finished adding brackets around all unary connectives. +2023-08-30 12:12:18,617 - DEBUG - parse_array - In parse_array(): elements_second=['(', '(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')', ')'] +2023-08-30 12:12:18,617 - INFO - parse_array - Final checks are ran before parsing concludes. +2023-08-30 12:12:18,617 - DEBUG - check_left_and_right_brackets - Calling check_left_and_right_brackets(['(', '(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')', ')'])... +2023-08-30 12:12:18,617 - INFO - check_left_and_right_brackets - PASS: The number of left and right brackets are equal. +2023-08-30 12:12:18,617 - DEBUG - parse - Calling parse(['(', '(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')', ')'])... +2023-08-30 12:12:18,617 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', '(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')', ')'])... +2023-08-30 12:12:18,617 - DEBUG - remove_outer_brackets - array=['(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')'] +2023-08-30 12:12:18,617 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-08-30 12:12:18,617 - DEBUG - parse - In parse(): arr=['(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')'] +2023-08-30 12:12:18,617 - DEBUG - find_connective - Calling find_connectives(['(', 'P', '->', 'Q', ')', '<->', '(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')'])... +2023-08-30 12:12:18,617 - DEBUG - find_connective - In find_connective(): elem=<->, i=5 +2023-08-30 12:12:18,617 - DEBUG - find_connective - Found connective. +2023-08-30 12:12:18,617 - DEBUG - parse - Calling parse(['(', 'P', '->', 'Q', ')'])... +2023-08-30 12:12:18,617 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', 'P', '->', 'Q', ')'])... +2023-08-30 12:12:18,617 - DEBUG - remove_outer_brackets - array=['P', '->', 'Q'] +2023-08-30 12:12:18,617 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-08-30 12:12:18,618 - DEBUG - parse - In parse(): arr=['P', '->', 'Q'] +2023-08-30 12:12:18,618 - DEBUG - find_connective - Calling find_connectives(['P', '->', 'Q'])... +2023-08-30 12:12:18,618 - DEBUG - find_connective - In find_connective(): elem=->, i=1 +2023-08-30 12:12:18,618 - DEBUG - find_connective - Found connective. +2023-08-30 12:12:18,618 - DEBUG - parse - temp_array=[['P'], '->', ['Q']] +2023-08-30 12:12:18,618 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-08-30 12:12:18,618 - DEBUG - parse - Calling parse(['(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')'])... +2023-08-30 12:12:18,618 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', '(', '!', 'Q', ')', '->', '(', '!', 'P', ')', ')'])... +2023-08-30 12:12:18,618 - DEBUG - remove_outer_brackets - array=['(', '!', 'Q', ')', '->', '(', '!', 'P', ')'] +2023-08-30 12:12:18,618 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-08-30 12:12:18,618 - DEBUG - parse - In parse(): arr=['(', '!', 'Q', ')', '->', '(', '!', 'P', ')'] +2023-08-30 12:12:18,618 - DEBUG - find_connective - Calling find_connectives(['(', '!', 'Q', ')', '->', '(', '!', 'P', ')'])... +2023-08-30 12:12:18,618 - DEBUG - find_connective - In find_connective(): elem=->, i=4 +2023-08-30 12:12:18,618 - DEBUG - find_connective - Found connective. +2023-08-30 12:12:18,618 - DEBUG - parse - Calling parse(['(', '!', 'Q', ')'])... +2023-08-30 12:12:18,618 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', '!', 'Q', ')'])... +2023-08-30 12:12:18,618 - DEBUG - remove_outer_brackets - array=['!', 'Q'] +2023-08-30 12:12:18,618 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-08-30 12:12:18,618 - DEBUG - parse - In parse(): arr=['!', 'Q'] +2023-08-30 12:12:18,618 - DEBUG - parse - temp_arr=['!', 'Q'] +2023-08-30 12:12:18,619 - DEBUG - parse - Returning with parsed list of unary connectives. +2023-08-30 12:12:18,619 - DEBUG - parse - Calling parse(['(', '!', 'P', ')'])... +2023-08-30 12:12:18,619 - DEBUG - remove_outer_brackets - Calling remove_outer_brackets(['(', '!', 'P', ')'])... +2023-08-30 12:12:18,619 - DEBUG - remove_outer_brackets - array=['!', 'P'] +2023-08-30 12:12:18,619 - DEBUG - remove_outer_brackets - Finished removing outer brackets. +2023-08-30 12:12:18,619 - DEBUG - parse - In parse(): arr=['!', 'P'] +2023-08-30 12:12:18,619 - DEBUG - parse - temp_arr=['!', 'P'] +2023-08-30 12:12:18,619 - DEBUG - parse - Returning with parsed list of unary connectives. +2023-08-30 12:12:18,619 - DEBUG - parse - temp_array=[['!', 'Q'], '->', ['!', 'P']] +2023-08-30 12:12:18,619 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-08-30 12:12:18,619 - DEBUG - parse - temp_array=[[['P'], '->', ['Q']], '<->', [['!', 'Q'], '->', ['!', 'P']]] +2023-08-30 12:12:18,619 - DEBUG - parse - Returning with parsed list for binary connectives. +2023-08-30 12:12:18,619 - DEBUG - parse_array - tree_structured_array=[[['P'], '->', ['Q']], '<->', [['!', 'Q'], '->', ['!', 'P']]] +2023-08-30 12:12:18,619 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,619 - INFO - print_details - *************************** PARSE *************************** +2023-08-30 12:12:18,619 - INFO - print_details - -> Parsed Array: [[['P'], '->', ['Q']], '<->', [['!', 'Q'], '->', ['!', 'P']]] +2023-08-30 12:12:18,619 - INFO - print_details - *************************** PARSE *************************** +2023-08-30 12:12:18,619 - INFO - parse_array - Finished parsing array. +2023-08-30 12:12:18,619 - DEBUG - user_input - In user_input(): +number_of_variables=2, +variables_as_array=['P', 'Q'], +statement=((P -> Q) <-> ((!Q) -> (!P))), +new_elements=[[['P'], '->', ['Q']], '<->', [['!', 'Q'], '->', ['!', 'P']]]. +2023-08-30 12:12:18,619 - INFO - user_input - Gathered all information needed including variables and parsed array. +2023-08-30 12:12:18,619 - DEBUG - simulate_main - In simulate_main(): +number_of_variables=2, +variables_as_array=['P', 'Q'], +provided_statement=((P -> Q) <-> ((!Q) -> (!P))), +elements_in_tree=[[['P'], '->', ['Q']], '<->', [['!', 'Q'], '->', ['!', 'P']]] +2023-08-30 12:12:18,619 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,620 - INFO - print_details - ************************** SUMMARY ************************** +2023-08-30 12:12:18,620 - INFO - print_details - -> number_of_variables: 2 +2023-08-30 12:12:18,620 - INFO - print_details - -> variables_as_array: ['P', 'Q'] +2023-08-30 12:12:18,620 - INFO - print_details - -> provided_statement: ((P -> Q) <-> ((!Q) -> (!P))) +2023-08-30 12:12:18,620 - INFO - print_details - -> elements_in_tree: [[['P'], '->', ['Q']], '<->', [['!', 'Q'], '->', ['!', 'P']]] +2023-08-30 12:12:18,620 - INFO - print_details - ************************** SUMMARY ************************** +2023-08-30 12:12:18,620 - INFO - evaluate_array_as_tree - Starting evaluation of array of elements... +2023-08-30 12:12:18,620 - DEBUG - create_matrix - Creating initial matrix... +2023-08-30 12:12:18,620 - DEBUG - recursive_table - Creating table entries recursively... +2023-08-30 12:12:18,620 - DEBUG - recursive_table - n=2 +2023-08-30 12:12:18,620 - DEBUG - recursive_table - Creating table entries recursively... +2023-08-30 12:12:18,620 - DEBUG - recursive_table - n=1 +2023-08-30 12:12:18,620 - DEBUG - recursive_table - array_table=['T', 'F'] +2023-08-30 12:12:18,620 - DEBUG - recursive_table - Finished creating array of table entries. +2023-08-30 12:12:18,620 - DEBUG - recursive_table - array_table=['TT', 'TF', 'FT', 'FF'] +2023-08-30 12:12:18,620 - DEBUG - recursive_table - Finished creating array of table entries. +2023-08-30 12:12:18,620 - DEBUG - create_matrix - In create_matrix(): new_matrix=[['T', 'T'], ['T', 'F'], ['F', 'T'], ['F', 'F']] +2023-08-30 12:12:18,620 - INFO - create_matrix - Finished creating the initial 'truth' matrix. +2023-08-30 12:12:18,620 - INFO - create_matrix - *** Initial Matrix: [['T', 'T'], ['T', 'F'], ['F', 'T'], ['F', 'F']] *** +2023-08-30 12:12:18,620 - DEBUG - evaluate_array_as_tree - In evaluate_array_as_tree(): +elements_in_tree=[[['P'], '->', ['Q']], '<->', [['!', 'Q'], '->', ['!', 'P']]], +counter=0, +matrix=[['T', 'T'], ['T', 'F'], ['F', 'T'], ['F', 'F']], +variables_as_array=['P', 'Q'] +2023-08-30 12:12:18,620 - DEBUG - evaluate_array - Calling evaluate_array([[['P'], '->', ['Q']], '<->', [['!', 'Q'], '->', ['!', 'P']]], 0, [['T', 'T'], ['T', 'F'], ['F', 'T'], ['F', 'F']], ['P', 'Q'])... +2023-08-30 12:12:18,621 - DEBUG - evaluate_array - Calling evaluate_array([['P'], '->', ['Q']], 1, [['T', 'T'], ['T', 'F'], ['F', 'T'], ['F', 'F']], ['P', 'Q'])... +2023-08-30 12:12:18,621 - DEBUG - switch_case - Entering switch_case(->, ['T', 'T', 'F', 'F'], ['T', 'F', 'T', 'F'])... +2023-08-30 12:12:18,621 - DEBUG - cond - In cond. case... +2023-08-30 12:12:18,621 - DEBUG - conditional - Calling conditional(['T', 'T', 'F', 'F'], ['T', 'F', 'T', 'F'])... +2023-08-30 12:12:18,621 - DEBUG - conditional - new_row_values=['T', 'F', 'T', 'T'] +2023-08-30 12:12:18,621 - DEBUG - conditional - Returning with new row values. +2023-08-30 12:12:18,621 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['P'], '->', ['Q']])... +2023-08-30 12:12:18,621 - DEBUG - set_new_array_elem - new_array=['P->Q'] +2023-08-30 12:12:18,621 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-08-30 12:12:18,621 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'F', 'T', 'T'], +final_variable_combined=['P->Q'], +matrix=[['T', 'T'], ['T', 'F'], ['F', 'T'], ['F', 'F']], +variables=['P', 'Q'] +2023-08-30 12:12:18,621 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-08-30 12:12:18,621 - DEBUG - add_array_to_matrix - Calling add_array_to_matrix([['T', 'T'], ['T', 'F'], ['F', 'T'], ['F', 'F']], ['T', 'F', 'T', 'T'], ['P', 'Q'], ['P->Q'])... +2023-08-30 12:12:18,621 - DEBUG - add_array_to_matrix - variables=['P', 'Q', 'P->Q'] +2023-08-30 12:12:18,621 - DEBUG - add_array_to_matrix - Added array to matrix. +2023-08-30 12:12:18,621 - DEBUG - evaluate_array - Calling evaluate_array([['!', 'Q'], '->', ['!', 'P']], 1, [['T', 'T', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'F', 'T']], ['P', 'Q', 'P->Q'])... +2023-08-30 12:12:18,621 - DEBUG - evaluate_array - Calling evaluate_array(['!', 'Q'], 2, [['T', 'T', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'F', 'T']], ['P', 'Q', 'P->Q'])... +2023-08-30 12:12:18,621 - DEBUG - switch_case - Entering switch_case(!, ['T', 'F', 'T', 'T'], ['T', 'F', 'T', 'F'])... +2023-08-30 12:12:18,621 - DEBUG - neg - In neg. case... +2023-08-30 12:12:18,621 - DEBUG - negation - Calling negation(['T', 'F', 'T', 'T'])... +2023-08-30 12:12:18,621 - DEBUG - negation - new_row_values=['F', 'T', 'F', 'F'] +2023-08-30 12:12:18,621 - DEBUG - negation - Returning with new row values. +2023-08-30 12:12:18,622 - DEBUG - set_new_array_elem - Calling set_new_array_elem(['_', '!', 'Q'])... +2023-08-30 12:12:18,622 - DEBUG - set_new_array_elem - new_array=['!Q'] +2023-08-30 12:12:18,622 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-08-30 12:12:18,622 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['F', 'T', 'F', 'F'], +final_variable_combined=['!Q'], +matrix=[['T', 'T', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'F', 'T']], +variables=['P', 'Q', 'P->Q'] +2023-08-30 12:12:18,622 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-08-30 12:12:18,622 - DEBUG - add_array_to_matrix - Calling add_array_to_matrix([['T', 'T', 'T'], ['T', 'F', 'F'], ['F', 'T', 'T'], ['F', 'F', 'T']], ['F', 'T', 'F', 'F'], ['P', 'Q', 'P->Q'], ['!Q'])... +2023-08-30 12:12:18,622 - DEBUG - add_array_to_matrix - variables=['P', 'Q', 'P->Q', '!Q'] +2023-08-30 12:12:18,622 - DEBUG - add_array_to_matrix - Added array to matrix. +2023-08-30 12:12:18,622 - DEBUG - evaluate_array - Calling evaluate_array(['!', 'P'], 2, [['T', 'T', 'T', 'F'], ['T', 'F', 'F', 'T'], ['F', 'T', 'T', 'F'], ['F', 'F', 'T', 'F']], ['P', 'Q', 'P->Q', '!Q'])... +2023-08-30 12:12:18,622 - DEBUG - switch_case - Entering switch_case(!, ['F', 'T', 'F', 'F'], ['T', 'T', 'F', 'F'])... +2023-08-30 12:12:18,622 - DEBUG - neg - In neg. case... +2023-08-30 12:12:18,622 - DEBUG - negation - Calling negation(['F', 'T', 'F', 'F'])... +2023-08-30 12:12:18,622 - DEBUG - negation - new_row_values=['T', 'F', 'T', 'T'] +2023-08-30 12:12:18,622 - DEBUG - negation - Returning with new row values. +2023-08-30 12:12:18,622 - DEBUG - set_new_array_elem - Calling set_new_array_elem(['_', '!', 'P'])... +2023-08-30 12:12:18,622 - DEBUG - set_new_array_elem - new_array=['!P'] +2023-08-30 12:12:18,622 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-08-30 12:12:18,622 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'F', 'T', 'T'], +final_variable_combined=['!P'], +matrix=[['T', 'T', 'T', 'F'], ['T', 'F', 'F', 'T'], ['F', 'T', 'T', 'F'], ['F', 'F', 'T', 'F']], +variables=['P', 'Q', 'P->Q', '!Q'] +2023-08-30 12:12:18,622 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-08-30 12:12:18,622 - DEBUG - add_array_to_matrix - Calling add_array_to_matrix([['T', 'T', 'T', 'F'], ['T', 'F', 'F', 'T'], ['F', 'T', 'T', 'F'], ['F', 'F', 'T', 'F']], ['T', 'F', 'T', 'T'], ['P', 'Q', 'P->Q', '!Q'], ['!P'])... +2023-08-30 12:12:18,623 - DEBUG - add_array_to_matrix - variables=['P', 'Q', 'P->Q', '!Q', '!P'] +2023-08-30 12:12:18,623 - DEBUG - add_array_to_matrix - Added array to matrix. +2023-08-30 12:12:18,623 - DEBUG - switch_case - Entering switch_case(->, ['F', 'T', 'F', 'F'], ['T', 'F', 'T', 'T'])... +2023-08-30 12:12:18,623 - DEBUG - cond - In cond. case... +2023-08-30 12:12:18,623 - DEBUG - conditional - Calling conditional(['F', 'T', 'F', 'F'], ['T', 'F', 'T', 'T'])... +2023-08-30 12:12:18,623 - DEBUG - conditional - new_row_values=['T', 'F', 'T', 'T'] +2023-08-30 12:12:18,623 - DEBUG - conditional - Returning with new row values. +2023-08-30 12:12:18,623 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['!Q'], '->', ['!P']])... +2023-08-30 12:12:18,623 - DEBUG - set_new_array_elem - new_array=['(!Q)->(!P)'] +2023-08-30 12:12:18,623 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-08-30 12:12:18,623 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'F', 'T', 'T'], +final_variable_combined=['(!Q)->(!P)'], +matrix=[['T', 'T', 'T', 'F', 'T'], ['T', 'F', 'F', 'T', 'F'], ['F', 'T', 'T', 'F', 'T'], ['F', 'F', 'T', 'F', 'T']], +variables=['P', 'Q', 'P->Q', '!Q', '!P'] +2023-08-30 12:12:18,623 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-08-30 12:12:18,623 - DEBUG - add_array_to_matrix - Calling add_array_to_matrix([['T', 'T', 'T', 'F', 'T'], ['T', 'F', 'F', 'T', 'F'], ['F', 'T', 'T', 'F', 'T'], ['F', 'F', 'T', 'F', 'T']], ['T', 'F', 'T', 'T'], ['P', 'Q', 'P->Q', '!Q', '!P'], ['(!Q)->(!P)'])... +2023-08-30 12:12:18,623 - DEBUG - add_array_to_matrix - variables=['P', 'Q', 'P->Q', '!Q', '!P', '(!Q)->(!P)'] +2023-08-30 12:12:18,623 - DEBUG - add_array_to_matrix - Added array to matrix. +2023-08-30 12:12:18,623 - DEBUG - switch_case - Entering switch_case(<->, ['T', 'F', 'T', 'T'], ['T', 'F', 'T', 'T'])... +2023-08-30 12:12:18,623 - DEBUG - bicond - In bicond. case... +2023-08-30 12:12:18,623 - DEBUG - biconditional - Calling biconditional(['T', 'F', 'T', 'T'], ['T', 'F', 'T', 'T'])... +2023-08-30 12:12:18,623 - DEBUG - biconditional - new_row_values=['T', 'T', 'T', 'T'] +2023-08-30 12:12:18,623 - DEBUG - biconditional - Returning with new row values. +2023-08-30 12:12:18,623 - DEBUG - set_new_array_elem - Calling set_new_array_elem([['P->Q'], '<->', ['(!Q)->(!P)']])... +2023-08-30 12:12:18,624 - DEBUG - set_new_array_elem - new_array=['(P->Q)<->((!Q)->(!P))'] +2023-08-30 12:12:18,624 - DEBUG - set_new_array_elem - Finished setting new array element. +2023-08-30 12:12:18,624 - DEBUG - evaluate_array - In evaluate_array(): +returned_array=['T', 'T', 'T', 'T'], +final_variable_combined=['(P->Q)<->((!Q)->(!P))'], +matrix=[['T', 'T', 'T', 'F', 'T', 'T', 'T'], ['T', 'F', 'F', 'T', 'F', 'F', 'T'], ['F', 'T', 'T', 'F', 'T', 'T', 'T'], ['F', 'F', 'T', 'F', 'T', 'T', 'T']], +variables=['P', 'Q', 'P->Q', '!Q', '!P', '(!Q)->(!P)'] +2023-08-30 12:12:18,624 - DEBUG - evaluate_array - Evaluation of array in evaluate_array() is done. +2023-08-30 12:12:18,624 - DEBUG - evaluate_array_as_tree - returned_array=['T', 'T', 'T', 'T'], returned_matrix=[['T', 'T', 'T', 'F', 'T', 'T', 'T'], ['T', 'F', 'F', 'T', 'F', 'F', 'T'], ['F', 'T', 'T', 'F', 'T', 'T', 'T'], ['F', 'F', 'T', 'F', 'T', 'T', 'T']], all_variables=['P', 'Q', 'P->Q', '!Q', '!P', '(!Q)->(!P)', '(P->Q)<->((!Q)->(!P))'] +2023-08-30 12:12:18,624 - DEBUG - evaluate_array_as_tree - Finished evaluating array. +2023-08-30 12:12:18,624 - DEBUG - simulate_main - In simulate_main(): +final_value_array=['T', 'T', 'T', 'T'], +returned_matrix=[['T', 'T', 'T', 'F', 'T', 'T', 'T'], ['T', 'F', 'F', 'T', 'F', 'F', 'T'], ['F', 'T', 'T', 'F', 'T', 'T', 'T'], ['F', 'F', 'T', 'F', 'T', 'T', 'T']], +all_variables=['P', 'Q', 'P->Q', '!Q', '!P', '(!Q)->(!P)', '(P->Q)<->((!Q)->(!P))'] +2023-08-30 12:12:18,624 - DEBUG - print_details - Printing details... +2023-08-30 12:12:18,624 - INFO - print_details - ************************** EVALUATE ************************** +2023-08-30 12:12:18,624 - INFO - print_details - -> Statement: ((P -> Q) <-> ((!Q) -> (!P))) +2023-08-30 12:12:18,624 - INFO - print_details - -> Final Calculated Array: ['T', 'T', 'T', 'T'] +2023-08-30 12:12:18,624 - INFO - print_details - -> All Variables: ['P', 'Q', 'P->Q', '!Q', '!P', '(!Q)->(!P)', '(P->Q)<->((!Q)->(!P))'] +2023-08-30 12:12:18,624 - INFO - print_details - -> Final Matrix: [['T', 'T', 'T', 'F', 'T', 'T', 'T'], ['T', 'F', 'F', 'T', 'F', 'F', 'T'], ['F', 'T', 'T', 'F', 'T', 'T', 'T'], ['F', 'F', 'T', 'F', 'T', 'T', 'T']] +2023-08-30 12:12:18,624 - INFO - print_details - ************************** EVALUATE ************************** +2023-08-30 12:12:18,624 - INFO - simulate_main - Finished evaluating statement. +2023-08-30 12:12:18,624 - DEBUG - display_matrix - Displaying matrix to console... +2023-08-30 12:12:18,624 - DEBUG - get_number_of_spaces - Calling get_number_of_spaces(2, 4, ['P', 'Q', 'P->Q', '!Q', '!P', '(!Q)->(!P)', '(P->Q)<->((!Q)->(!P))'])... +2023-08-30 12:12:18,624 - DEBUG - get_number_of_spaces - total_space=64 +2023-08-30 12:12:18,624 - DEBUG - get_number_of_spaces - Finished calculating the total space. +2023-08-30 12:12:18,625 - DEBUG - simulate_main - Returning from simulate_main()... +2023-08-30 12:12:18,625 - INFO - - Exiting Engine... diff --git a/engine/Main.py b/engine/main.py similarity index 100% rename from engine/Main.py rename to engine/main.py diff --git a/engine/Parser/README.md b/engine/parser/README.md similarity index 100% rename from engine/Parser/README.md rename to engine/parser/README.md diff --git a/engine/Parser/TreeLikeStructure.drawio b/engine/parser/TreeLikeStructure.drawio similarity index 100% rename from engine/Parser/TreeLikeStructure.drawio rename to engine/parser/TreeLikeStructure.drawio diff --git a/engine/Parser/TreeLikeStructure.png b/engine/parser/TreeLikeStructure.png similarity index 100% rename from engine/Parser/TreeLikeStructure.png rename to engine/parser/TreeLikeStructure.png diff --git a/engine/Parser/Checks/__init__.py b/engine/parser/__init__.py similarity index 100% rename from engine/Parser/Checks/__init__.py rename to engine/parser/__init__.py diff --git a/engine/Parser/Parse/__init__.py b/engine/parser/checks/__init__.py similarity index 100% rename from engine/Parser/Parse/__init__.py rename to engine/parser/checks/__init__.py diff --git a/engine/Parser/Checks/CheckBrackets.py b/engine/parser/checks/check_brackets.py similarity index 100% rename from engine/Parser/Checks/CheckBrackets.py rename to engine/parser/checks/check_brackets.py diff --git a/engine/Parser/Checks/CheckForIllegalCharacters.py b/engine/parser/checks/check_for_illegal_characters.py similarity index 100% rename from engine/Parser/Checks/CheckForIllegalCharacters.py rename to engine/parser/checks/check_for_illegal_characters.py diff --git a/engine/Parser/Validate/__init__.py b/engine/parser/parse/__init__.py similarity index 100% rename from engine/Parser/Validate/__init__.py rename to engine/parser/parse/__init__.py diff --git a/engine/Parser/Parse/AnalyzeFunction.py b/engine/parser/parse/analyze_function.py similarity index 100% rename from engine/Parser/Parse/AnalyzeFunction.py rename to engine/parser/parse/analyze_function.py diff --git a/engine/Parser/Parse/ParseFunction.py b/engine/parser/parse/parse_function.py similarity index 100% rename from engine/Parser/Parse/ParseFunction.py rename to engine/parser/parse/parse_function.py diff --git a/engine/Parser/Validate/README.md b/engine/parser/validate/README.md similarity index 100% rename from engine/Parser/Validate/README.md rename to engine/parser/validate/README.md diff --git a/engine/Parser/__init__.py b/engine/parser/validate/__init__.py similarity index 100% rename from engine/Parser/__init__.py rename to engine/parser/validate/__init__.py diff --git a/engine/Simulator/__init__.py b/engine/simulator/__init__.py similarity index 100% rename from engine/Simulator/__init__.py rename to engine/simulator/__init__.py diff --git a/engine/Simulator/input_statements.py b/engine/simulator/input_statements.py similarity index 100% rename from engine/Simulator/input_statements.py rename to engine/simulator/input_statements.py diff --git a/engine/Simulator/simulate_main.py b/engine/simulator/simulate_main.py similarity index 100% rename from engine/Simulator/simulate_main.py rename to engine/simulator/simulate_main.py diff --git a/engine/Simulator/SimulateServer.py b/engine/simulator/simulate_server.py similarity index 100% rename from engine/Simulator/SimulateServer.py rename to engine/simulator/simulate_server.py diff --git a/engine/Simulator/UserInput.py b/engine/simulator/user_input.py similarity index 100% rename from engine/Simulator/UserInput.py rename to engine/simulator/user_input.py From a484b50e3da272530cd955419a0e203ff5ca6e8a Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Wed, 11 Oct 2023 10:47:53 +0200 Subject: [PATCH 10/29] Fixed linting issues. --- engine/Components/Verifier.py | 2 +- engine/computation/evaluate_statement.py | 4 +- engine/computation/switch_connectives.py | 2 +- .../table_matrix/create_table_matrix.py | 2 +- engine/engine_logging/logging_config.py | 2 +- engine/main.py | 2 +- engine/parser/parse/parse_function.py | 3 +- engine/simulator/simulate_main.py | 19 +++---- engine/simulator/simulate_server.py | 10 ++-- engine/simulator/user_input.py | 4 +- frontend/lib/main.dart | 50 +------------------ 11 files changed, 27 insertions(+), 73 deletions(-) diff --git a/engine/Components/Verifier.py b/engine/Components/Verifier.py index 1594822..008d2bb 100644 --- a/engine/Components/Verifier.py +++ b/engine/Components/Verifier.py @@ -3,4 +3,4 @@ # todo Check connectives # todo Suggest list of connectives # todo From sanitizer.py, check code and if not, return to user input or ErrorHandler.py -# todo If Verifier.py is valid, proceed +# todo If verifier.py is valid, proceed diff --git a/engine/computation/evaluate_statement.py b/engine/computation/evaluate_statement.py index a5edbe3..f791a38 100644 --- a/engine/computation/evaluate_statement.py +++ b/engine/computation/evaluate_statement.py @@ -5,8 +5,8 @@ """ from math import log2 -from Computation.switch_connectives import switch_case -from Computation.TableMatrix.CreateTableMatrix import create_matrix +from computation.switch_connectives import switch_case +from computation.table_matrix.create_table_matrix import create_matrix from engine_logging.logging_config import logger diff --git a/engine/computation/switch_connectives.py b/engine/computation/switch_connectives.py index 913ee90..3dd847c 100644 --- a/engine/computation/switch_connectives.py +++ b/engine/computation/switch_connectives.py @@ -3,7 +3,7 @@ Returns: _type_: _description_ """ -from Computation.propositional_rules import * +from computation.propositional_rules import * from engine_logging.logging_config import logger diff --git a/engine/computation/table_matrix/create_table_matrix.py b/engine/computation/table_matrix/create_table_matrix.py index 058c20e..340ccbc 100644 --- a/engine/computation/table_matrix/create_table_matrix.py +++ b/engine/computation/table_matrix/create_table_matrix.py @@ -1,5 +1,5 @@ """ Insert """ -from Computation.TableMatrix.RecursiveTable import recursive_table +from computation.table_matrix.recursive_table import recursive_table from engine_logging.logging_config import logger diff --git a/engine/engine_logging/logging_config.py b/engine/engine_logging/logging_config.py index 422f701..4715d6e 100644 --- a/engine/engine_logging/logging_config.py +++ b/engine/engine_logging/logging_config.py @@ -6,7 +6,7 @@ MAX_LOG_FILES = 10 LOG_FILE_NAME = 'engine.log' -log_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'Output') +log_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'output') log_file = os.path.join(log_folder, LOG_FILE_NAME) # Create the Output directory if it doesn't exist diff --git a/engine/main.py b/engine/main.py index 3c813c7..faf764d 100644 --- a/engine/main.py +++ b/engine/main.py @@ -1,6 +1,6 @@ """ Insert """ from engine_logging import logger -from Simulator.simulate_main import simulate_main +from simulator.simulate_main import simulate_main logger.info("Starting Engine...") diff --git a/engine/parser/parse/parse_function.py b/engine/parser/parse/parse_function.py index e039e6b..90acdce 100644 --- a/engine/parser/parse/parse_function.py +++ b/engine/parser/parse/parse_function.py @@ -1,8 +1,9 @@ +""" Insert """ from components.constants import * from components.sanitizer import add_brackets_around_unary_connectives from components.sanitizer import remove_brackets_around_variables from engine_logging.logging_config import logger -from Parser.Checks.CheckBrackets import check_left_and_right_brackets +from parser.checks.check_brackets import check_left_and_right_brackets from components.print_details import print_details diff --git a/engine/simulator/simulate_main.py b/engine/simulator/simulate_main.py index ee245f9..452487a 100644 --- a/engine/simulator/simulate_main.py +++ b/engine/simulator/simulate_main.py @@ -1,18 +1,19 @@ +""" Insert """ from components.print_details import print_details -from Computation.evaluate_statement import * -from Computation.TableMatrix.DisplayMatrix import display_matrix +from computation.evaluate_statement import * +from computation.table_matrix.display_matrix import display_matrix from engine_logging.logging_config import logger -from Parser.Checks.CheckBrackets import check_left_and_right_brackets -from Parser.Checks.CheckForIllegalCharacters import check_for_illegal_characters -from Parser.Checks.CheckBrackets import UnequalBracketsExcept -from Parser.Checks.CheckForIllegalCharacters import IllegalCharactersException -from Simulator.UserInput import user_input -from Simulator.input_statements import * +from parser.checks.check_brackets import check_left_and_right_brackets +from parser.checks.check_for_illegal_characters import check_for_illegal_characters +from parser.checks.check_brackets import UnequalBracketsExcept +from parser.checks.check_for_illegal_characters import IllegalCharactersException +from simulator.user_input import user_input +from simulator.input_statements import * def simulate_main(): """ - This simulates Main.py + This simulates main.py """ logger.debug("Calling simulate_main()...") diff --git a/engine/simulator/simulate_server.py b/engine/simulator/simulate_server.py index 0c5e5e9..1ab04b8 100644 --- a/engine/simulator/simulate_server.py +++ b/engine/simulator/simulate_server.py @@ -1,17 +1,17 @@ """ This can be used to simulate the calls that are made by the GRPC Server """ -from Parser.Checks import CheckBrackets, CheckForIllegalCharacters -from Parser.Checks.CheckBrackets import UnequalBracketsExcept -from Parser.Checks.CheckForIllegalCharacters import IllegalCharactersException +from parser.checks import check_brackets, check_for_illegal_characters +from parser.checks.check_brackets import UnequalBracketsExcept +from parser.checks.check_for_illegal_characters import IllegalCharactersException # from input_statements import statement # Part 1: Checks for brackets and characters try: statement = [] - if (CheckBrackets.check_left_and_right_brackets(statement) and - CheckForIllegalCharacters.check_for_illegal_characters(statement)): + if (check_brackets.check_left_and_right_brackets(statement) and + check_for_illegal_characters.check_for_illegal_characters(statement)): pass except UnequalBracketsExcept as ce: print("Unequal Brackets Exception: ", ce) diff --git a/engine/simulator/user_input.py b/engine/simulator/user_input.py index ea19223..6b41f2d 100644 --- a/engine/simulator/user_input.py +++ b/engine/simulator/user_input.py @@ -4,8 +4,8 @@ _type_: _description_ """ from engine_logging.logging_config import logger -from Parser.Parse.AnalyzeFunction import analyze_statement -from Parser.Parse.ParseFunction import parse_array +from parser.parse.analyze_function import analyze_statement +from parser.parse.parse_function import parse_array def user_input(statement: str) -> [int, list, str, list]: diff --git a/frontend/lib/main.dart b/frontend/lib/main.dart index 6595048..86784d5 100644 --- a/frontend/lib/main.dart +++ b/frontend/lib/main.dart @@ -7,21 +7,11 @@ void main() { class MyApp extends StatelessWidget { const MyApp({super.key}); - // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( - // This is the theme of your application. - // - // Try running your application with "flutter run". You'll see the - // application has a blue toolbar. Then, without quitting the app, try - // changing the primarySwatch below to Colors.green and then invoke - // "hot reload" (press "r" in the console where you ran "flutter run", - // or simply save your changes to "hot reload" in a Flutter IDE). - // Notice that the counter didn't reset back to zero; the application - // is not restarted. primarySwatch: Colors.blue, ), home: const MyHomePage(title: 'Flutter Demo Home Page'), @@ -32,15 +22,6 @@ class MyApp extends StatelessWidget { class MyHomePage extends StatefulWidget { const MyHomePage({required this.title, super.key}); - // This widget is the home page of your application. It is stateful, meaning - // that it has a State object (defined below) that contains fields that affect - // how it looks. - - // This class is the configuration for the state. It holds the values (in this - // case the title) provided by the parent (in this case the App widget) and - // used by the build method of the State. Fields in a Widget subclass are - // always marked "final". - final String title; @override @@ -52,47 +33,18 @@ class _MyHomePageState extends State { void _incrementCounter() { setState(() { - // This call to setState tells the Flutter framework that something has - // changed in this State, which causes it to rerun the build method below - // so that the display can reflect the updated values. If we changed - // _counter without calling setState(), then the build method would not be - // called again, and so nothing would appear to happen. _counter++; }); } @override Widget build(BuildContext context) { - // This method is rerun every time setState is called, for instance as done - // by the _incrementCounter method above. - // - // The Flutter framework has been optimized to make rerunning build methods - // fast, so that you can just rebuild anything that needs updating rather - // than having to individually change instances of widgets. return Scaffold( appBar: AppBar( - // Here we take the value from the MyHomePage object that was created by - // the App.build method, and use it to set our appbar title. title: Text(widget.title), ), body: Center( - // Center is a layout widget. It takes a single child and positions it - // in the middle of the parent. child: Column( - // Column is also a layout widget. It takes a list of children and - // arranges them vertically. By default, it sizes itself to fit its - // children horizontally, and tries to be as tall as its parent. - // - // Invoke "debug painting" (press "p" in the console, choose the - // "Toggle Debug Paint" action from the Flutter Inspector in Android - // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) - // to see the wireframe for each widget. - // - // Column has various properties to control how it sizes itself and - // how it positions its children. Here we use mainAxisAlignment to - // center the children vertically; the main axis here is the vertical - // axis because Columns are vertical (the cross axis would be - // horizontal). mainAxisAlignment: MainAxisAlignment.center, children: [ const Text( @@ -109,7 +61,7 @@ class _MyHomePageState extends State { onPressed: _incrementCounter, tooltip: 'Increment', child: const Icon(Icons.add), - ), // This trailing comma makes auto-formatting nicer for build methods. + ), ); } } From 2c21a8d1bb5a78cf7c70575bb5bded58617d4edd Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Wed, 11 Oct 2023 11:03:16 +0200 Subject: [PATCH 11/29] Fixed linting issues. --- engine/engine_logging/logging_config.py | 2 +- engine/parser/checks/__init__.py | 4 + engine/parser/checks/check_brackets.py | 5 ++ engine/simulator/simulate_main.py | 100 ++++++++++++------------ engine/simulator/simulate_server.py | 22 +++--- 5 files changed, 73 insertions(+), 60 deletions(-) diff --git a/engine/engine_logging/logging_config.py b/engine/engine_logging/logging_config.py index 4715d6e..d05a832 100644 --- a/engine/engine_logging/logging_config.py +++ b/engine/engine_logging/logging_config.py @@ -11,7 +11,7 @@ # Create the Output directory if it doesn't exist if not os.path.exists(log_folder): - os.makedirs(log_folder) + os.makedirs(log_folder) if os.path.exists(log_file): for i in range(MAX_LOG_FILES - 1, 0, -1): # starts from 9 moving down to 0 diff --git a/engine/parser/checks/__init__.py b/engine/parser/checks/__init__.py index 8a1a818..fc2a65d 100644 --- a/engine/parser/checks/__init__.py +++ b/engine/parser/checks/__init__.py @@ -1 +1,5 @@ # EMPTY FILE - __init__.py +from .check_brackets import check_left_and_right_brackets +from .check_brackets import UnequalBracketsExcept +from .check_for_illegal_characters import check_for_illegal_characters +from .check_for_illegal_characters import IllegalCharactersException diff --git a/engine/parser/checks/check_brackets.py b/engine/parser/checks/check_brackets.py index 8b53024..042a2d5 100644 --- a/engine/parser/checks/check_brackets.py +++ b/engine/parser/checks/check_brackets.py @@ -4,6 +4,11 @@ class UnequalBracketsExcept(Exception): + """_summary_ + + Args: + Exception (_type_): _description_ + """ pass diff --git a/engine/simulator/simulate_main.py b/engine/simulator/simulate_main.py index 452487a..0dd1d26 100644 --- a/engine/simulator/simulate_main.py +++ b/engine/simulator/simulate_main.py @@ -1,70 +1,70 @@ """ Insert """ -from components.print_details import print_details +from engine_logging.logging_config import logger from computation.evaluate_statement import * from computation.table_matrix.display_matrix import display_matrix -from engine_logging.logging_config import logger from parser.checks.check_brackets import check_left_and_right_brackets -from parser.checks.check_for_illegal_characters import check_for_illegal_characters from parser.checks.check_brackets import UnequalBracketsExcept +from parser.checks.check_for_illegal_characters import check_for_illegal_characters from parser.checks.check_for_illegal_characters import IllegalCharactersException from simulator.user_input import user_input from simulator.input_statements import * +from components.print_details import print_details def simulate_main(): - """ - This simulates main.py - """ - logger.debug("Calling simulate_main()...") + """ + This simulates main.py + """ + logger.debug("Calling simulate_main()...") - for idx, statement in enumerate(test_cases, start=1): - logger.info("Statement:\t%s", statement) + for _, statement in enumerate(test_cases, start=1): + logger.info("Statement:\t%s", statement) - # First complete all checks - try: - logger.info("Before proceeding, doing checks for unequal brackets and " - "illegal characters.") - if (check_left_and_right_brackets(statement) and - check_for_illegal_characters(statement)): - pass - except UnequalBracketsExcept as ce: - logger.exception("Unequal Brackets Exception: ", ce) - continue - except IllegalCharactersException as ice: - logger.exception("Illegal Characters Exception: ", ice) - continue - else: - pass + # First complete all checks + try: + logger.info("Before proceeding, doing checks for unequal brackets and " + "illegal characters.") + if (check_left_and_right_brackets(statement) and + check_for_illegal_characters(statement)): + pass + except UnequalBracketsExcept as ce: + logger.exception("Unequal Brackets Exception: ", ce) + continue + except IllegalCharactersException as ice: + logger.exception("Illegal Characters Exception: ", ice) + continue + else: + pass - # todo Look into why statement is sent to user_input() and then - # returned again + # todo Look into why statement is sent to user_input() and then + # returned again - logger.info("All checks are valid, proceeding with extracting " - "information from statement.") - number_of_variables, variables_as_array, provided_statement, elements_in_tree = ( - user_input(statement)) - logger.debug("In simulate_main(): \nnumber_of_variables=%d, \nvariables_as_array=%s, " - "\nprovided_statement=%s, \nelements_in_tree=%s", - number_of_variables, variables_as_array, provided_statement, elements_in_tree) + logger.info("All checks are valid, proceeding with extracting " + "information from statement.") + number_of_variables, variables_as_array, provided_statement, elements_in_tree = ( + user_input(statement)) + logger.debug("In simulate_main(): \nnumber_of_variables=%d, \nvariables_as_array=%s, " + "\nprovided_statement=%s, \nelements_in_tree=%s", + number_of_variables, variables_as_array, provided_statement, elements_in_tree) - print_details("SUMMARY", - ("number_of_variables", number_of_variables), - ("variables_as_array", variables_as_array), - ("provided_statement", provided_statement), - ("elements_in_tree", elements_in_tree)) + print_details("SUMMARY", + ("number_of_variables", number_of_variables), + ("variables_as_array", variables_as_array), + ("provided_statement", provided_statement), + ("elements_in_tree", elements_in_tree)) - final_value_array, returned_matrix, all_variables = ( - evaluate_array_as_tree(number_of_variables, variables_as_array, elements_in_tree)) - logger.debug("In simulate_main(): \nfinal_value_array=%s, \nreturned_matrix=%s, \nall_variables=%s", - final_value_array, returned_matrix, all_variables) + final_value_array, returned_matrix, all_variables = ( + evaluate_array_as_tree(number_of_variables, variables_as_array, elements_in_tree)) + logger.debug("In simulate_main(): \nfinal_value_array=%s, \nreturned_matrix=%s, \nall_variables=%s", + final_value_array, returned_matrix, all_variables) - print_details("EVALUATE", ("Statement", statement), - ("Final Calculated Array", final_value_array), - ("All Variables", all_variables), - ("Final Matrix", returned_matrix)) - logger.info("Finished evaluating statement.") + print_details("EVALUATE", ("Statement", statement), + ("Final Calculated Array", final_value_array), + ("All Variables", all_variables), + ("Final Matrix", returned_matrix)) + logger.info("Finished evaluating statement.") - # todo Ticket: Add and Modify Code for Console Output - display_matrix(number_of_variables, returned_matrix, all_variables) + # todo Ticket: Add and Modify Code for Console Output + display_matrix(number_of_variables, returned_matrix, all_variables) - logger.debug("Returning from simulate_main()...") + logger.debug("Returning from simulate_main()...") diff --git a/engine/simulator/simulate_server.py b/engine/simulator/simulate_server.py index 1ab04b8..35eac2b 100644 --- a/engine/simulator/simulate_server.py +++ b/engine/simulator/simulate_server.py @@ -1,24 +1,28 @@ """ This can be used to simulate the calls that are made by the GRPC Server """ -from parser.checks import check_brackets, check_for_illegal_characters +# from parser.checks import check_brackets, check_for_illegal_characters +# from parser.checks.check_brackets import UnequalBracketsExcept +# from parser.checks.check_for_illegal_characters import IllegalCharactersException +# from input_statements import statement +from parser.checks import check_brackets +from parser.checks import check_for_illegal_characters from parser.checks.check_brackets import UnequalBracketsExcept from parser.checks.check_for_illegal_characters import IllegalCharactersException -# from input_statements import statement # Part 1: Checks for brackets and characters try: - statement = [] - if (check_brackets.check_left_and_right_brackets(statement) and - check_for_illegal_characters.check_for_illegal_characters(statement)): - pass + statement = [] + if (check_brackets.check_left_and_right_brackets(statement) and + check_for_illegal_characters.check_for_illegal_characters(statement)): + pass except UnequalBracketsExcept as ce: - print("Unequal Brackets Exception: ", ce) + print("Unequal Brackets Exception: ", ce) except IllegalCharactersException as ice: - print("Illegal Characters Exception: ", ice) + print("Illegal Characters Exception: ", ice) else: - print("No exception occurred!") + print("No exception occurred!") # Main From fa704c708a563762fb56f4ae65a15af0085c47dc Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Wed, 11 Oct 2023 20:42:30 +0200 Subject: [PATCH 12/29] Removed python 3.8 from pylint --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index c9c962e..0f0e51e 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} From 384174d5620fae9c2e240332e3965915ff1ba4f8 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Wed, 11 Oct 2023 20:42:37 +0200 Subject: [PATCH 13/29] Fixed linting issues. --- .../table_matrix/display_matrix.py | 213 +++++++++--------- .../table_matrix/recursive_table.py | 62 ++--- .../checks/check_for_illegal_characters.py | 42 ++-- 3 files changed, 162 insertions(+), 155 deletions(-) diff --git a/engine/computation/table_matrix/display_matrix.py b/engine/computation/table_matrix/display_matrix.py index 81d658a..0691aad 100644 --- a/engine/computation/table_matrix/display_matrix.py +++ b/engine/computation/table_matrix/display_matrix.py @@ -3,110 +3,117 @@ def display_matrix(number_of_variables: int, returned_matrix: list, all_variables: list) -> None: - logger.debug("Displaying matrix to console...") - - auxiliary_variables = [] # Holds all the placeholder variables - for i in range(number_of_variables, len(all_variables) - 1): - auxiliary_variables.append(all_variables[i]) - number_of_aux_variables = len(auxiliary_variables) - - # prints part for variables - print("| ", end='') - for j in range(number_of_variables): - if j != number_of_variables-1: - print(all_variables[j] + " | ", end='') - else: - print(all_variables[j] + " || ", end='') - - # prints auxiliary variables - index_between_auxiliary_variables_and_last = number_of_variables + len(auxiliary_variables) - for j in range(number_of_variables, index_between_auxiliary_variables_and_last): - if j != index_between_auxiliary_variables_and_last - 1: - print(all_variables[j] + " | ", end='') - else: - print(all_variables[j] + " || ", end='') - - # prints last column - print(all_variables[-1] + " || ", end='') - - print('\n', end='') - - count_characters = get_number_of_spaces(number_of_variables, number_of_aux_variables, all_variables) - print("=" * count_characters) - - # prints the T/F values for each row in matrix - for i in range(len(returned_matrix)): - row = returned_matrix[i] - - print("| ", end='') - - # prints part for variables - for j in range(number_of_variables): - if j != number_of_variables-1: - print(row[j] + " | ", end='') - else: - print(row[j] + " || ", end='') - - # prints auxiliary variables - index_between_auxiliary_variables_and_last = number_of_variables + len(auxiliary_variables) - for j in range(number_of_variables, index_between_auxiliary_variables_and_last): - if j != index_between_auxiliary_variables_and_last - 1: - print(row[j] + " | ", end='') - else: - temp_length = len(all_variables[j]) - add_len = 0 - if temp_length % 2 == 1: # odd - add_len = temp_length/2 + 1 - add_space = '' - for k in range(int(add_len)): - add_space += ' ' - print(row[j] + add_space + " || ", end='') - - # prints last column - temp_length = len(all_variables[-1]) - add_len = 0 - if temp_length % 2 == 1: # odd - add_len = temp_length/2 + 1 - elif temp_length % 2 == 0: # even - add_len = temp_length/2 - add_space = '' - for k in range(int(add_len)): - add_space += ' ' - print(row[-1] + add_space + " || ", end='') - print('\n', end='') - - print("=" * count_characters) + """ + + :param number_of_variables: + :param returned_matrix: + :param all_variables: + :return: + """ + logger.debug("Displaying matrix to console...") + + auxiliary_variables = [] # Holds all the placeholder variables + for i in range(number_of_variables, len(all_variables) - 1): + auxiliary_variables.append(all_variables[i]) + number_of_aux_variables = len(auxiliary_variables) + + # prints part for variables + print("| ", end='') + for j in range(number_of_variables): + if j != number_of_variables-1: + print(all_variables[j] + " | ", end='') + else: + print(all_variables[j] + " || ", end='') + + # prints auxiliary variables + index_between_auxiliary_variables_and_last = number_of_variables + len(auxiliary_variables) + for j in range(number_of_variables, index_between_auxiliary_variables_and_last): + if j != index_between_auxiliary_variables_and_last - 1: + print(all_variables[j] + " | ", end='') + else: + print(all_variables[j] + " || ", end='') + + # prints last column + print(all_variables[-1] + " || ", end='') + + print('\n', end='') + + count_characters = get_number_of_spaces(number_of_variables, number_of_aux_variables, all_variables) + print("=" * count_characters) + + # prints the T/F values for each row in matrix + for i in range(len(returned_matrix)): + row = returned_matrix[i] + + print("| ", end='') + + # prints part for variables + for j in range(number_of_variables): + if j != number_of_variables-1: + print(row[j] + " | ", end='') + else: + print(row[j] + " || ", end='') + + # prints auxiliary variables + index_between_auxiliary_variables_and_last = number_of_variables + len(auxiliary_variables) + for j in range(number_of_variables, index_between_auxiliary_variables_and_last): + if j != index_between_auxiliary_variables_and_last - 1: + print(row[j] + " | ", end='') + else: + temp_length = len(all_variables[j]) + add_len = 0 + if temp_length % 2 == 1: # odd + add_len = temp_length/2 + 1 + add_space = '' + for k in range(int(add_len)): + add_space += ' ' + print(row[j] + add_space + " || ", end='') + + # prints last column + temp_length = len(all_variables[-1]) + add_len = 0 + if temp_length % 2 == 1: # odd + add_len = temp_length/2 + 1 + elif temp_length % 2 == 0: # even + add_len = temp_length/2 + add_space = '' + for k in range(int(add_len)): + add_space += ' ' + print(row[-1] + add_space + " || ", end='') + print('\n', end='') + + print("=" * count_characters) # todo Finish Function def get_number_of_spaces(number_of_variables: int, nr_auxiliary_variables: int, all_variables: list) -> int: - logger.debug("Calling get_number_of_spaces(%d, %d, %s)...", number_of_variables, nr_auxiliary_variables, all_variables) - - space = 3 - total_space = 0 - - initial_space = 1 - total_space += initial_space - spaces_for_variables = space * number_of_variables - total_space += spaces_for_variables - spaces_for_single_sep = number_of_variables - 1 - total_space += spaces_for_single_sep - - length_of_aux_strings = 0 - for i in range(number_of_variables, len(all_variables) - 1): - temp_length = len(all_variables[i]) - length_of_aux_strings += temp_length - length_of_aux_strings += nr_auxiliary_variables * 2 - spaces_for_aux_variables = length_of_aux_strings - total_space += spaces_for_aux_variables - spaces_for_single_sep = nr_auxiliary_variables - 1 - total_space += spaces_for_single_sep - - space_for_last_variable = len(all_variables[-1]) - total_space += space_for_last_variable - spaces_for_double_sep = 6 - total_space += spaces_for_double_sep - - logger.debug("total_space=%d", total_space) - logger.debug("Finished calculating the total space.") - return total_space + logger.debug("Calling get_number_of_spaces(%d, %d, %s)...", number_of_variables, nr_auxiliary_variables, all_variables) + + space = 3 + total_space = 0 + + initial_space = 1 + total_space += initial_space + spaces_for_variables = space * number_of_variables + total_space += spaces_for_variables + spaces_for_single_sep = number_of_variables - 1 + total_space += spaces_for_single_sep + + length_of_aux_strings = 0 + for i in range(number_of_variables, len(all_variables) - 1): + temp_length = len(all_variables[i]) + length_of_aux_strings += temp_length + length_of_aux_strings += nr_auxiliary_variables * 2 + spaces_for_aux_variables = length_of_aux_strings + total_space += spaces_for_aux_variables + spaces_for_single_sep = nr_auxiliary_variables - 1 + total_space += spaces_for_single_sep + + space_for_last_variable = len(all_variables[-1]) + total_space += space_for_last_variable + spaces_for_double_sep = 6 + total_space += spaces_for_double_sep + + logger.debug("total_space=%d", total_space) + logger.debug("Finished calculating the total space.") + return total_space diff --git a/engine/computation/table_matrix/recursive_table.py b/engine/computation/table_matrix/recursive_table.py index fc4e2e4..a78d6f0 100644 --- a/engine/computation/table_matrix/recursive_table.py +++ b/engine/computation/table_matrix/recursive_table.py @@ -4,38 +4,38 @@ def recursive_table(n): - """ - Creates a list of T's and F's recursively, given the number of variables - For example: - recursive_table(1) => ['T', 'F'] and - recursive_table(3) => - ['TTT', 'TTF', 'TFT', 'TFF', 'FTT', 'FTF', 'FFT', 'FFF'] + """ + Creates a list of T's and F's recursively, given the number of variables + For example: + recursive_table(1) => ['T', 'F'] and + recursive_table(3) => + ['TTT', 'TTF', 'TFT', 'TFF', 'FTT', 'FTF', 'FFT', 'FFF'] - :param n: (int) Number of variables - :return: Returns an array table with T/F values - """ - logger.debug("Creating table entries recursively...") + :param n: (int) Number of variables + :return: Returns an array table with T/F values + """ + logger.debug("Creating table entries recursively...") - logger.debug("n=%d", n) - array_table = [] - if n == 1: - array_table = [TRUE, FALSE] - elif n != 1: - array_table = recursive_table(n - 1) - temp_table = array_table.copy() - for j in range(0, int(2 ** n / 2)): - if j % 2 == 0: # even - array_table.insert(j * 2, temp_table[j]) - elif j % 2 == 1: # odd - array_table.insert(j * 2, temp_table[j]) + logger.debug("n=%d", n) + array_table = [] + if n == 1: + array_table = [TRUE, FALSE] + elif n != 1: + array_table = recursive_table(n - 1) + temp_table = array_table.copy() + for j in range(0, int(2 ** n / 2)): + if j % 2 == 0: # even + array_table.insert(j * 2, temp_table[j]) + elif j % 2 == 1: # odd + array_table.insert(j * 2, temp_table[j]) - if n > 1: - for i in range(0, 2 ** n): - if i % 2 == 0: # even - array_table[i] = str(array_table[i]) + TRUE - elif i % 2 == 1: # odd - array_table[i] = str(array_table[i]) + FALSE + if n > 1: + for i in range(0, 2 ** n): + if i % 2 == 0: # even + array_table[i] = str(array_table[i]) + TRUE + elif i % 2 == 1: # odd + array_table[i] = str(array_table[i]) + FALSE - logger.debug("array_table=%s", array_table) - logger.debug("Finished creating array of table entries.") - return array_table + logger.debug("array_table=%s", array_table) + logger.debug("Finished creating array of table entries.") + return array_table diff --git a/engine/parser/checks/check_for_illegal_characters.py b/engine/parser/checks/check_for_illegal_characters.py index b34a580..59dd5e5 100644 --- a/engine/parser/checks/check_for_illegal_characters.py +++ b/engine/parser/checks/check_for_illegal_characters.py @@ -4,28 +4,28 @@ class IllegalCharactersException(Exception): - pass + pass def check_for_illegal_characters(statement): - """ - Checks for illegal characters in the given statement - :param statement: (string) - :return: returns true in case statement is clear of illegal characters and - raises an exception if not. - """ - logger.debug("Calling check_for_illegal_characters(%s)", statement) - logger.debug("******************** starting input validation *******************") - for i in range(len(statement)): - char = statement[i] - if char in LEFT_BRACKETS or char in RIGHT_BRACKETS or char in WHITE_SPACES: - continue - if validate_input(char): - continue - else: - logger.exception("FAIL: String contains illegal characters, please inspect: char=%s", char) - raise IllegalCharactersException("Exception: String contains illegal characters.") - logger.debug("******************** finished input validation *******************") + """ + Checks for illegal characters in the given statement + :param statement: (string) + :return: returns true in case statement is clear of illegal characters and + raises an exception if not. + """ + logger.debug("Calling check_for_illegal_characters(%s)", statement) + logger.debug("******************** starting input validation *******************") + for i in range(len(statement)): + char = statement[i] + if char in LEFT_BRACKETS or char in RIGHT_BRACKETS or char in WHITE_SPACES: + continue + if validate_input(char): + continue + else: + logger.exception("FAIL: String contains illegal characters, please inspect: char=%s", char) + raise IllegalCharactersException("Exception: String contains illegal characters.") + logger.debug("******************** finished input validation *******************") - logger.info("PASS: There were no illegal characters found.") - return True # returns True in case no fowl characters are found + logger.info("PASS: There were no illegal characters found.") + return True # returns True in case no fowl characters are found From 6bce59b038eaa1c2ab33bcae7f5a612bf7d3d348 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Wed, 11 Oct 2023 21:08:27 +0200 Subject: [PATCH 14/29] Fixed linting issues. --- engine/Components/Sanitizer.py | 4 +++- engine/Components/create_conditionals.py | 17 ++++++++--------- engine/computation/evaluate_statement.py | 5 ++--- .../table_matrix/create_table_matrix.py | 2 +- .../computation/table_matrix/display_matrix.py | 13 +++++++++++-- engine/parser/checks/__init__.py | 1 + engine/parser/checks/check_brackets.py | 6 +++--- .../checks/check_for_illegal_characters.py | 18 +++++++++++++++--- engine/parser/parse/analyze_function.py | 2 +- engine/parser/parse/parse_function.py | 5 ++--- engine/simulator/input_statements.py | 4 ++-- 11 files changed, 49 insertions(+), 28 deletions(-) diff --git a/engine/Components/Sanitizer.py b/engine/Components/Sanitizer.py index efbefba..b875238 100644 --- a/engine/Components/Sanitizer.py +++ b/engine/Components/Sanitizer.py @@ -78,7 +78,9 @@ def add_brackets_around_unary_connectives(arr: list, variables: list) -> list: if arr[i-1] in LEFT_BRACKETS and arr[i+2] in RIGHT_BRACKETS: # good case continue - if arr[i-1] in BINARY_CONNECTIVES or arr[i+2] in BINARY_CONNECTIVES: # there is no brackets around it + + # there is no brackets around it + if arr[i-1] in BINARY_CONNECTIVES or arr[i+2] in BINARY_CONNECTIVES: arr.insert(i, '(') arr.insert(i+3, ')') # todo Add a final check to makes sure that no unary connectives was missed. diff --git a/engine/Components/create_conditionals.py b/engine/Components/create_conditionals.py index 493c6a5..c6be404 100644 --- a/engine/Components/create_conditionals.py +++ b/engine/Components/create_conditionals.py @@ -35,11 +35,10 @@ def create_conditionals(array_of_elements: list) -> list: logger.debug("Conditional symbols were found in %s", array_of_elements) conditional_symbol = False biconditional_symbol = False - for i in range(len(array_of_elements)): + for i, char in enumerate(array_of_elements): if i == len(array_of_elements): break - char = array_of_elements[i] if char == OPEN_ARROW: # checks to see if we have a biconditional if array_of_elements[i + 1] == DASH and array_of_elements[i + 2] == CLOSE_ARROW: array_of_elements.pop(i) @@ -49,19 +48,19 @@ def create_conditionals(array_of_elements: list) -> list: continue # if we have a conditional - elif (char == DASH and array_of_elements[i + 1] == CLOSE_ARROW and + if (char == DASH and array_of_elements[i + 1] == CLOSE_ARROW and biconditional_symbol is False): # if we have a conditional array_of_elements.pop(i) array_of_elements.pop(i) array_of_elements.insert(i, COND_ELEM) continue - elif char == CLOSE_ARROW and conditional_symbol is False: + if char == CLOSE_ARROW and conditional_symbol is False: continue - else: # other characters - if conditional_symbol is False and biconditional_symbol is False: - pass - conditional_symbol = False - biconditional_symbol = False + # other characters + if conditional_symbol is False and biconditional_symbol is False: + pass + conditional_symbol = False + biconditional_symbol = False logger.debug("array_of_elements=%s", array_of_elements) logger.debug("Finished creating conditionals.") diff --git a/engine/computation/evaluate_statement.py b/engine/computation/evaluate_statement.py index f791a38..6556117 100644 --- a/engine/computation/evaluate_statement.py +++ b/engine/computation/evaluate_statement.py @@ -117,7 +117,7 @@ def evaluate_array(array: list, counter: int, matrix: list, variables: list): if len(final_variable_combined) == 1 and counter == 0: # append returned_array to matrix - for i in range(len(returned_array)): + for i, entry_in_return_array in enumerate(returned_array): entry_in_return_array = returned_array[i] matrix[i].append(entry_in_return_array) @@ -183,8 +183,7 @@ def add_array_to_matrix(matrix, array_evaluated, variables, variable_entry): """ logger.debug("Calling add_array_to_matrix(%s, %s, %s, %s)...", matrix, array_evaluated, variables, variable_entry) - for i in range(len(matrix)): - row_entry = matrix[i] + for i, row_entry in enumerate(matrix): entry_to_add = array_evaluated[i] row_entry.append(entry_to_add) variables.append(variable_entry[0]) # append new 'variable' to array of variables diff --git a/engine/computation/table_matrix/create_table_matrix.py b/engine/computation/table_matrix/create_table_matrix.py index 340ccbc..6b18caa 100644 --- a/engine/computation/table_matrix/create_table_matrix.py +++ b/engine/computation/table_matrix/create_table_matrix.py @@ -29,7 +29,7 @@ def create_matrix(num_of_var: int) -> list: new_matrix = [] - row_entries = [0] * num_of_var + row_entries = [] * num_of_var for i in range(2 ** num_of_var): get_row_values = str(table_entries[i]) for j in range(0, num_of_var): diff --git a/engine/computation/table_matrix/display_matrix.py b/engine/computation/table_matrix/display_matrix.py index 0691aad..c1ab0fd 100644 --- a/engine/computation/table_matrix/display_matrix.py +++ b/engine/computation/table_matrix/display_matrix.py @@ -42,8 +42,7 @@ def display_matrix(number_of_variables: int, returned_matrix: list, all_variable print("=" * count_characters) # prints the T/F values for each row in matrix - for i in range(len(returned_matrix)): - row = returned_matrix[i] + for i, row in enumerate(returned_matrix): print("| ", end='') @@ -87,6 +86,16 @@ def display_matrix(number_of_variables: int, returned_matrix: list, all_variable # todo Finish Function def get_number_of_spaces(number_of_variables: int, nr_auxiliary_variables: int, all_variables: list) -> int: + """_summary_ + + Args: + number_of_variables (int): _description_ + nr_auxiliary_variables (int): _description_ + all_variables (list): _description_ + + Returns: + int: _description_ + """ logger.debug("Calling get_number_of_spaces(%d, %d, %s)...", number_of_variables, nr_auxiliary_variables, all_variables) space = 3 diff --git a/engine/parser/checks/__init__.py b/engine/parser/checks/__init__.py index fc2a65d..7bb103a 100644 --- a/engine/parser/checks/__init__.py +++ b/engine/parser/checks/__init__.py @@ -1,3 +1,4 @@ +""" Insert """ # EMPTY FILE - __init__.py from .check_brackets import check_left_and_right_brackets from .check_brackets import UnequalBracketsExcept diff --git a/engine/parser/checks/check_brackets.py b/engine/parser/checks/check_brackets.py index 042a2d5..74ce4f1 100644 --- a/engine/parser/checks/check_brackets.py +++ b/engine/parser/checks/check_brackets.py @@ -21,10 +21,10 @@ def check_left_and_right_brackets(statement): logger.debug("Calling check_left_and_right_brackets(%s)...", statement) count = 0 - for i in range(len(statement)): - if statement[i] in LEFT_BRACKETS: + for _, char in enumerate(statement): + if char in LEFT_BRACKETS: count += 1 - elif statement[i] in RIGHT_BRACKETS: + elif char in RIGHT_BRACKETS: count -= 1 if count == 0: diff --git a/engine/parser/checks/check_for_illegal_characters.py b/engine/parser/checks/check_for_illegal_characters.py index 59dd5e5..f40f053 100644 --- a/engine/parser/checks/check_for_illegal_characters.py +++ b/engine/parser/checks/check_for_illegal_characters.py @@ -1,9 +1,22 @@ +"""_summary_ + +Raises: + IllegalCharactersException: _description_ + +Returns: + _type_: _description_ +""" from components.regular_expression import validate_input -from components.constants import * +from components.constants import LEFT_BRACKETS, RIGHT_BRACKETS, WHITE_SPACES from engine_logging.logging_config import logger class IllegalCharactersException(Exception): + """_summary_ + + Args: + Exception (_type_): _description_ + """ pass @@ -16,8 +29,7 @@ def check_for_illegal_characters(statement): """ logger.debug("Calling check_for_illegal_characters(%s)", statement) logger.debug("******************** starting input validation *******************") - for i in range(len(statement)): - char = statement[i] + for _, char in enumerate(statement): if char in LEFT_BRACKETS or char in RIGHT_BRACKETS or char in WHITE_SPACES: continue if validate_input(char): diff --git a/engine/parser/parse/analyze_function.py b/engine/parser/parse/analyze_function.py index 95bf279..b34cc2a 100644 --- a/engine/parser/parse/analyze_function.py +++ b/engine/parser/parse/analyze_function.py @@ -11,7 +11,7 @@ from engine_logging.logging_config import logger -def analyze_statement(statement: str) -> [int, list, list]: +def analyze_statement(statement: str): """ Analyzes statement to determine the number of variables, and split into an array of elements diff --git a/engine/parser/parse/parse_function.py b/engine/parser/parse/parse_function.py index 90acdce..fa84601 100644 --- a/engine/parser/parse/parse_function.py +++ b/engine/parser/parse/parse_function.py @@ -7,7 +7,7 @@ from components.print_details import print_details -def parse_array(elements: list, variables: list) -> list: +def parse_array(elements: list, variables: list): """ This takes an array of elements and variables, completes some sanitizing and checks and then calls an internal parse function to complete the parsing. @@ -119,8 +119,7 @@ def find_connective(arr): count = 0 in_bracket = False - for i in range(len(arr)): - elem = arr[i] + for i, elem in enumerate(arr): if elem in LEFT_BRACKETS: in_bracket = True count += 1 diff --git a/engine/simulator/input_statements.py b/engine/simulator/input_statements.py index c55173c..6899c37 100644 --- a/engine/simulator/input_statements.py +++ b/engine/simulator/input_statements.py @@ -1,3 +1,4 @@ +""" Insert """ # Test cases that is used in simulate_main.py test_cases = [ # "(P <-> (P <-> (P <-> (P <-> P))))", @@ -12,7 +13,7 @@ # "(S ^ (R ^ Q))", # valid # "((R ^ (Q v (!P))) <-> (((R ^ Q) v (R ^ P)) ^ T))", # valid # "((R ^ (Q v (P))) <-> (((R ^ Q) v (R ^ P)) ^ T))", # valid - + # "R ^ (Q v !P) <-> (R ^ Q) v (R ^ P) ^ T" # valid, but binding rules # should be applied. # "((!R) ^ P)", # valid @@ -38,4 +39,3 @@ # "(P_1 ^ P_2)", # "(Q ^ (R_20 -> T_2))" ] - From e121a3176b7fd5edf938d11d4bcc5598ca376b51 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Wed, 11 Oct 2023 21:48:36 +0200 Subject: [PATCH 15/29] Fixed linting issues. --- engine/Components/create_conditionals.py | 2 +- engine/Components/regular_expression.py | 1 - engine/computation/evaluate_statement.py | 17 +++++++----- engine/computation/propositional_rules.py | 26 +++++++++---------- engine/computation/switch_connectives.py | 3 ++- .../table_matrix/display_matrix.py | 26 +++++++++++-------- .../checks/check_for_illegal_characters.py | 7 ++--- engine/parser/parse/parse_function.py | 7 ++--- engine/simulator/simulate_main.py | 14 +++++----- engine/simulator/user_input.py | 4 +-- 10 files changed, 58 insertions(+), 49 deletions(-) diff --git a/engine/Components/create_conditionals.py b/engine/Components/create_conditionals.py index c6be404..1dd831a 100644 --- a/engine/Components/create_conditionals.py +++ b/engine/Components/create_conditionals.py @@ -29,7 +29,7 @@ def create_conditionals(array_of_elements: list) -> list: logger.debug("Search for conditionals finished and none were found, returning.") return array_of_elements continue - elif char in PRE_CHECK: + if char in PRE_CHECK: break logger.debug("Conditional symbols were found in %s", array_of_elements) diff --git a/engine/Components/regular_expression.py b/engine/Components/regular_expression.py index ca6954a..c688972 100644 --- a/engine/Components/regular_expression.py +++ b/engine/Components/regular_expression.py @@ -19,7 +19,6 @@ def validate_input(input_string: str) -> bool: """ logger.debug("Calling validate_input(%s)...", input_string) - # pattern = r"^(?:[a-zA-Z](?:_\d+)?|[a-zA-Z])$|[\^v!<>-]" pattern = r"^(?:[a-zA-Z](?:_\d+)?|[a-zA-Z])$|[\^v!<>-]" result = re.fullmatch(pattern, input_string) is not None diff --git a/engine/computation/evaluate_statement.py b/engine/computation/evaluate_statement.py index 6556117..4a24594 100644 --- a/engine/computation/evaluate_statement.py +++ b/engine/computation/evaluate_statement.py @@ -34,7 +34,8 @@ def evaluate_array_as_tree(number_of_variables, variables_as_array, elements_in_ all_variables.append(final_variable_combined[0]) - logger.debug("returned_array=%s, returned_matrix=%s, all_variables=%s", returned_array, returned_matrix, all_variables) + logger.debug("returned_array=%s, returned_matrix=%s, " + "all_variables=%s", returned_array, returned_matrix, all_variables) logger.debug("Finished evaluating array.") return returned_array, returned_matrix, all_variables @@ -51,7 +52,6 @@ def evaluate_array(array: list, counter: int, matrix: list, variables: list): """ logger.debug("Calling evaluate_array(%s, %d, %s, %s)...", array, counter, matrix, variables) - # todo Fix bug for ((!Q) -> (!P)) # if negation is encountered, add placeholder value in front if len(array) == 2: blank = '_' @@ -67,7 +67,8 @@ def evaluate_array(array: list, counter: int, matrix: list, variables: list): temp_left_array = left_array counter += 1 - array_evaluated, left_array, _, _ = evaluate_array(temp_left_array, counter, matrix, variables) + array_evaluated, left_array, _, _ = evaluate_array(temp_left_array, + counter, matrix, variables) counter -= 1 variables = add_array_to_matrix(matrix, array_evaluated, variables, left_array) @@ -76,7 +77,8 @@ def evaluate_array(array: list, counter: int, matrix: list, variables: list): temp_right_array = right_array counter += 1 - array_evaluated, right_array, _, _ = evaluate_array(temp_right_array, counter, matrix, variables) + array_evaluated, right_array, _, _ = evaluate_array(temp_right_array, + counter, matrix, variables) counter -= 1 variables = add_array_to_matrix(matrix, array_evaluated, variables, right_array) @@ -118,10 +120,10 @@ def evaluate_array(array: list, counter: int, matrix: list, variables: list): if len(final_variable_combined) == 1 and counter == 0: # append returned_array to matrix for i, entry_in_return_array in enumerate(returned_array): - entry_in_return_array = returned_array[i] matrix[i].append(entry_in_return_array) - logger.debug("In evaluate_array(): \nreturned_array=%s, \nfinal_variable_combined=%s, \nmatrix=%s, \nvariables=%s", + logger.debug("In evaluate_array(): \nreturned_array=%s, \nfinal_variable_combined=%s, " + "\nmatrix=%s, \nvariables=%s", returned_array, final_variable_combined, matrix, variables) logger.debug("Evaluation of array in evaluate_array() is done.") return returned_array, final_variable_combined, matrix, variables @@ -181,7 +183,8 @@ def add_array_to_matrix(matrix, array_evaluated, variables, variable_entry): :param variable_entry: Auxiliary entry to add to array of variables :return: Returns an updated array of variables """ - logger.debug("Calling add_array_to_matrix(%s, %s, %s, %s)...", matrix, array_evaluated, variables, variable_entry) + logger.debug("Calling add_array_to_matrix(%s, %s, %s, %s)...", + matrix, array_evaluated, variables, variable_entry) for i, row_entry in enumerate(matrix): entry_to_add = array_evaluated[i] diff --git a/engine/computation/propositional_rules.py b/engine/computation/propositional_rules.py index 3fa3d78..3996e4f 100644 --- a/engine/computation/propositional_rules.py +++ b/engine/computation/propositional_rules.py @@ -15,14 +15,12 @@ from components import TRUE, FALSE -# todo double negation cancel out -# todo 'negation', 'for all', 'there exists' bind most tightly; then disj and -# conj; then impl. (which is right-associative) - UNEQUAL_LEFT_AND_RIGHT_ARRAYS = ("The left '%s' and right '%s' arrays are " "unequal! Exiting.") UNEQUAL_LEFT_AND_RIGHT_ARRAYS_EXCEPT = ("The left and right arrays are unequal. " "Please investigate.") +NEW_ROW_VALUES = "new_row_values=%s" +RETURN_NEW_ROW_VALUES_MESSAGE = "Returning with new row values." class UnequalArraysExcept(Exception): @@ -52,8 +50,8 @@ def conjunction(left, right): else: new_row_values.append(FALSE) - logger.debug("new_row_values=%s", new_row_values) - logger.debug("Returning with new row values.") + logger.debug(NEW_ROW_VALUES, new_row_values) + logger.debug(RETURN_NEW_ROW_VALUES_MESSAGE) return new_row_values @@ -77,8 +75,8 @@ def disjunction(left, right): else: new_row_values.append(TRUE) - logger.debug("new_row_values=%s", new_row_values) - logger.debug("Returning with new row values.") + logger.debug(NEW_ROW_VALUES, new_row_values) + logger.debug(RETURN_NEW_ROW_VALUES_MESSAGE) return new_row_values @@ -97,8 +95,8 @@ def negation(left): elif left[i] == FALSE: new_row_values.append(TRUE) - logger.debug("new_row_values=%s", new_row_values) - logger.debug("Returning with new row values.") + logger.debug(NEW_ROW_VALUES, new_row_values) + logger.debug(RETURN_NEW_ROW_VALUES_MESSAGE) return new_row_values @@ -123,8 +121,8 @@ def conditional(left, right): else: new_row_values.append(TRUE) - logger.debug("new_row_values=%s", new_row_values) - logger.debug("Returning with new row values.") + logger.debug(NEW_ROW_VALUES, new_row_values) + logger.debug(RETURN_NEW_ROW_VALUES_MESSAGE) return new_row_values @@ -148,6 +146,6 @@ def biconditional(left, right): else: new_row_values.append(FALSE) - logger.debug("new_row_values=%s", new_row_values) - logger.debug("Returning with new row values.") + logger.debug(NEW_ROW_VALUES, new_row_values) + logger.debug(RETURN_NEW_ROW_VALUES_MESSAGE) return new_row_values diff --git a/engine/computation/switch_connectives.py b/engine/computation/switch_connectives.py index 3dd847c..5968e40 100644 --- a/engine/computation/switch_connectives.py +++ b/engine/computation/switch_connectives.py @@ -3,7 +3,8 @@ Returns: _type_: _description_ """ -from computation.propositional_rules import * +from computation.propositional_rules import (conjunction, disjunction, negation, + conditional, biconditional) from engine_logging.logging_config import logger diff --git a/engine/computation/table_matrix/display_matrix.py b/engine/computation/table_matrix/display_matrix.py index c1ab0fd..8b6da9a 100644 --- a/engine/computation/table_matrix/display_matrix.py +++ b/engine/computation/table_matrix/display_matrix.py @@ -26,9 +26,9 @@ def display_matrix(number_of_variables: int, returned_matrix: list, all_variable print(all_variables[j] + " || ", end='') # prints auxiliary variables - index_between_auxiliary_variables_and_last = number_of_variables + len(auxiliary_variables) - for j in range(number_of_variables, index_between_auxiliary_variables_and_last): - if j != index_between_auxiliary_variables_and_last - 1: + index_between_aux_variables_and_last = number_of_variables + len(auxiliary_variables) + for j in range(number_of_variables, index_between_aux_variables_and_last): + if j != index_between_aux_variables_and_last - 1: print(all_variables[j] + " | ", end='') else: print(all_variables[j] + " || ", end='') @@ -38,7 +38,8 @@ def display_matrix(number_of_variables: int, returned_matrix: list, all_variable print('\n', end='') - count_characters = get_number_of_spaces(number_of_variables, number_of_aux_variables, all_variables) + count_characters = get_number_of_spaces(number_of_variables, + number_of_aux_variables, all_variables) print("=" * count_characters) # prints the T/F values for each row in matrix @@ -54,9 +55,10 @@ def display_matrix(number_of_variables: int, returned_matrix: list, all_variable print(row[j] + " || ", end='') # prints auxiliary variables - index_between_auxiliary_variables_and_last = number_of_variables + len(auxiliary_variables) - for j in range(number_of_variables, index_between_auxiliary_variables_and_last): - if j != index_between_auxiliary_variables_and_last - 1: + index_between_aux_variables_and_last = (number_of_variables + + len(auxiliary_variables)) + for j in range(number_of_variables, index_between_aux_variables_and_last): + if j != index_between_aux_variables_and_last - 1: print(row[j] + " | ", end='') else: temp_length = len(all_variables[j]) @@ -64,7 +66,7 @@ def display_matrix(number_of_variables: int, returned_matrix: list, all_variable if temp_length % 2 == 1: # odd add_len = temp_length/2 + 1 add_space = '' - for k in range(int(add_len)): + for _ in range(int(add_len)): add_space += ' ' print(row[j] + add_space + " || ", end='') @@ -76,7 +78,7 @@ def display_matrix(number_of_variables: int, returned_matrix: list, all_variable elif temp_length % 2 == 0: # even add_len = temp_length/2 add_space = '' - for k in range(int(add_len)): + for _ in range(int(add_len)): add_space += ' ' print(row[-1] + add_space + " || ", end='') print('\n', end='') @@ -85,7 +87,8 @@ def display_matrix(number_of_variables: int, returned_matrix: list, all_variable # todo Finish Function -def get_number_of_spaces(number_of_variables: int, nr_auxiliary_variables: int, all_variables: list) -> int: +def get_number_of_spaces(number_of_variables: int, nr_auxiliary_variables: int, + all_variables: list) -> int: """_summary_ Args: @@ -96,7 +99,8 @@ def get_number_of_spaces(number_of_variables: int, nr_auxiliary_variables: int, Returns: int: _description_ """ - logger.debug("Calling get_number_of_spaces(%d, %d, %s)...", number_of_variables, nr_auxiliary_variables, all_variables) + logger.debug("Calling get_number_of_spaces(%d, %d, %s)...", number_of_variables, + nr_auxiliary_variables, all_variables) space = 3 total_space = 0 diff --git a/engine/parser/checks/check_for_illegal_characters.py b/engine/parser/checks/check_for_illegal_characters.py index f40f053..5d8f4c1 100644 --- a/engine/parser/checks/check_for_illegal_characters.py +++ b/engine/parser/checks/check_for_illegal_characters.py @@ -34,9 +34,10 @@ def check_for_illegal_characters(statement): continue if validate_input(char): continue - else: - logger.exception("FAIL: String contains illegal characters, please inspect: char=%s", char) - raise IllegalCharactersException("Exception: String contains illegal characters.") + logger.exception("FAIL: String contains illegal characters, please " + "inspect: char=%s", char) + raise IllegalCharactersException("Exception: String contains illegal " + "characters.") logger.debug("******************** finished input validation *******************") logger.info("PASS: There were no illegal characters found.") diff --git a/engine/parser/parse/parse_function.py b/engine/parser/parse/parse_function.py index fa84601..1a664b0 100644 --- a/engine/parser/parse/parse_function.py +++ b/engine/parser/parse/parse_function.py @@ -1,10 +1,11 @@ """ Insert """ -from components.constants import * +from parser.checks.check_brackets import check_left_and_right_brackets +from components.constants import (UNARY_CONNECTIVES, LEFT_BRACKETS, + RIGHT_BRACKETS, BINARY_CONNECTIVES) from components.sanitizer import add_brackets_around_unary_connectives from components.sanitizer import remove_brackets_around_variables -from engine_logging.logging_config import logger -from parser.checks.check_brackets import check_left_and_right_brackets from components.print_details import print_details +from engine_logging.logging_config import logger def parse_array(elements: list, variables: list): diff --git a/engine/simulator/simulate_main.py b/engine/simulator/simulate_main.py index 0dd1d26..52c59ce 100644 --- a/engine/simulator/simulate_main.py +++ b/engine/simulator/simulate_main.py @@ -1,14 +1,14 @@ """ Insert """ -from engine_logging.logging_config import logger -from computation.evaluate_statement import * -from computation.table_matrix.display_matrix import display_matrix from parser.checks.check_brackets import check_left_and_right_brackets from parser.checks.check_brackets import UnequalBracketsExcept from parser.checks.check_for_illegal_characters import check_for_illegal_characters from parser.checks.check_for_illegal_characters import IllegalCharactersException +from computation.evaluate_statement import evaluate_array_as_tree +from computation.table_matrix.display_matrix import display_matrix from simulator.user_input import user_input -from simulator.input_statements import * +from simulator.input_statements import test_cases from components.print_details import print_details +from engine_logging.logging_config import logger def simulate_main(): @@ -45,7 +45,8 @@ def simulate_main(): user_input(statement)) logger.debug("In simulate_main(): \nnumber_of_variables=%d, \nvariables_as_array=%s, " "\nprovided_statement=%s, \nelements_in_tree=%s", - number_of_variables, variables_as_array, provided_statement, elements_in_tree) + number_of_variables, variables_as_array, provided_statement, + elements_in_tree) print_details("SUMMARY", ("number_of_variables", number_of_variables), @@ -55,7 +56,8 @@ def simulate_main(): final_value_array, returned_matrix, all_variables = ( evaluate_array_as_tree(number_of_variables, variables_as_array, elements_in_tree)) - logger.debug("In simulate_main(): \nfinal_value_array=%s, \nreturned_matrix=%s, \nall_variables=%s", + logger.debug("In simulate_main(): \nfinal_value_array=%s, " + "\nreturned_matrix=%s, \nall_variables=%s", final_value_array, returned_matrix, all_variables) print_details("EVALUATE", ("Statement", statement), diff --git a/engine/simulator/user_input.py b/engine/simulator/user_input.py index 6b41f2d..e1d57f1 100644 --- a/engine/simulator/user_input.py +++ b/engine/simulator/user_input.py @@ -3,12 +3,12 @@ Returns: _type_: _description_ """ -from engine_logging.logging_config import logger from parser.parse.analyze_function import analyze_statement from parser.parse.parse_function import parse_array +from engine_logging.logging_config import logger -def user_input(statement: str) -> [int, list, str, list]: +def user_input(statement: str): """ Takes a given statement, analyzes it and returns the elements and variables. :returns: (int) number of variables, From 8affe96ef42f0338be3e2298f5facba10a4988c3 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Wed, 11 Oct 2023 22:15:59 +0200 Subject: [PATCH 16/29] Cleaned up some code. --- engine/Components/Constants.py | 1 - engine/Components/Sanitizer.py | 3 --- engine/computation/switch_connectives.py | 5 +++-- engine/computation/table_matrix/create_table_matrix.py | 2 +- engine/simulator/simulate_main.py | 1 - engine/simulator/simulate_server.py | 4 ---- 6 files changed, 4 insertions(+), 12 deletions(-) diff --git a/engine/Components/Constants.py b/engine/Components/Constants.py index 42e87ae..7beba38 100644 --- a/engine/Components/Constants.py +++ b/engine/Components/Constants.py @@ -14,7 +14,6 @@ FALSE = 'F' # Constants used in the Components package -# todo Add other connectives such as &&, ||, etc. VALID_BRACKETS = "(){}[]" VALID_CONNECTIVES = "^v!<->" diff --git a/engine/Components/Sanitizer.py b/engine/Components/Sanitizer.py index b875238..bf8abb0 100644 --- a/engine/Components/Sanitizer.py +++ b/engine/Components/Sanitizer.py @@ -3,9 +3,6 @@ Returns: _type_: _description_ """ -# todo Changes statement to something that we can use -# todo Change to something that the system can use -# todo Add brackets # todo Change connectives to one common set # todo Change lower case letters to upper case diff --git a/engine/computation/switch_connectives.py b/engine/computation/switch_connectives.py index 5968e40..e11a1de 100644 --- a/engine/computation/switch_connectives.py +++ b/engine/computation/switch_connectives.py @@ -58,16 +58,17 @@ def disj(left, right): return disjunction(left, right) -# todo Refactor neg() to remove 'right' parameter def neg(left, _): """_summary_ Args: left (_type_): _description_ - right (_type_): _description_ + _ (_type_): _description_ Returns: _type_: _description_ + :param left: + :param _: """ logger.debug("In neg. case...") return negation(left) diff --git a/engine/computation/table_matrix/create_table_matrix.py b/engine/computation/table_matrix/create_table_matrix.py index 6b18caa..9525e38 100644 --- a/engine/computation/table_matrix/create_table_matrix.py +++ b/engine/computation/table_matrix/create_table_matrix.py @@ -29,7 +29,7 @@ def create_matrix(num_of_var: int) -> list: new_matrix = [] - row_entries = [] * num_of_var + row_entries = [''] * num_of_var for i in range(2 ** num_of_var): get_row_values = str(table_entries[i]) for j in range(0, num_of_var): diff --git a/engine/simulator/simulate_main.py b/engine/simulator/simulate_main.py index 52c59ce..67589b4 100644 --- a/engine/simulator/simulate_main.py +++ b/engine/simulator/simulate_main.py @@ -66,7 +66,6 @@ def simulate_main(): ("Final Matrix", returned_matrix)) logger.info("Finished evaluating statement.") - # todo Ticket: Add and Modify Code for Console Output display_matrix(number_of_variables, returned_matrix, all_variables) logger.debug("Returning from simulate_main()...") diff --git a/engine/simulator/simulate_server.py b/engine/simulator/simulate_server.py index 35eac2b..72a6829 100644 --- a/engine/simulator/simulate_server.py +++ b/engine/simulator/simulate_server.py @@ -1,10 +1,6 @@ """ This can be used to simulate the calls that are made by the GRPC Server """ -# from parser.checks import check_brackets, check_for_illegal_characters -# from parser.checks.check_brackets import UnequalBracketsExcept -# from parser.checks.check_for_illegal_characters import IllegalCharactersException -# from input_statements import statement from parser.checks import check_brackets from parser.checks import check_for_illegal_characters from parser.checks.check_brackets import UnequalBracketsExcept From 4961295efaad187eabd95d494aae37e48a55121b Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Sun, 15 Oct 2023 23:34:42 +0200 Subject: [PATCH 17/29] Fixed merge conflicts. --- engine/components/create_conditionals.py | 31 ++++------ engine/components/create_elements.py | 7 ++- engine/components/find_variables.py | 13 ++-- engine/components/print_details.py | 3 +- engine/components/regular_expression.py | 75 +++++++++++++----------- engine/computation/__init__.py | 1 - 6 files changed, 67 insertions(+), 63 deletions(-) delete mode 100644 engine/computation/__init__.py diff --git a/engine/components/create_conditionals.py b/engine/components/create_conditionals.py index 4b44675..1dd831a 100644 --- a/engine/components/create_conditionals.py +++ b/engine/components/create_conditionals.py @@ -1,13 +1,10 @@ -""" Insert """ +"""_summary_ + +Returns: + _type_: _description_ +""" +from components.constants import OPEN_ARROW, DASH, CLOSE_ARROW, COND_ELEM, BICOND_ELEM, PRE_CHECK from engine_logging.logging_config import logger -from components.constants import ( - OPEN_ARROW, - DASH, - CLOSE_ARROW, - COND_ELEM, - BICOND_ELEM, - PRE_CHECK, -) def create_conditionals(array_of_elements: list) -> list: @@ -29,9 +26,7 @@ def create_conditionals(array_of_elements: list) -> list: end_of_line = True if char not in PRE_CHECK: # no symbols present if end_of_line: - logger.debug( - "Search for conditionals finished and none were found, returning." - ) + logger.debug("Search for conditionals finished and none were found, returning.") return array_of_elements continue if char in PRE_CHECK: @@ -45,10 +40,7 @@ def create_conditionals(array_of_elements: list) -> list: break if char == OPEN_ARROW: # checks to see if we have a biconditional - if ( - array_of_elements[i + 1] == DASH - and array_of_elements[i + 2] == CLOSE_ARROW - ): + if array_of_elements[i + 1] == DASH and array_of_elements[i + 2] == CLOSE_ARROW: array_of_elements.pop(i) array_of_elements.pop(i) array_of_elements.pop(i) @@ -56,11 +48,8 @@ def create_conditionals(array_of_elements: list) -> list: continue # if we have a conditional - if ( - char == DASH - and array_of_elements[i + 1] == CLOSE_ARROW - and biconditional_symbol is False - ): # if we have a conditional + if (char == DASH and array_of_elements[i + 1] == CLOSE_ARROW and + biconditional_symbol is False): # if we have a conditional array_of_elements.pop(i) array_of_elements.pop(i) array_of_elements.insert(i, COND_ELEM) diff --git a/engine/components/create_elements.py b/engine/components/create_elements.py index 1099e12..fc3deb5 100644 --- a/engine/components/create_elements.py +++ b/engine/components/create_elements.py @@ -1,4 +1,8 @@ -""" Insert """ +"""_summary_ + +Returns: + _type_: _description_ +""" from engine_logging.logging_config import logger @@ -12,6 +16,7 @@ def create_array_of_elements(statement: str) -> list: :param statement: string :return: Returns an array of elements """ + logger.debug("Creating an array from a string...") logger.debug("Calling create_array_of_elements(%s)", statement) diff --git a/engine/components/find_variables.py b/engine/components/find_variables.py index 83afe03..54a8ea3 100644 --- a/engine/components/find_variables.py +++ b/engine/components/find_variables.py @@ -1,6 +1,10 @@ -""" Insert """ -from components.constants import VALID_BRACKETS, VALID_CONNECTIVES -from engine_logging.logging_config import logger +"""_summary_ + +Returns: + _type_: _description_ +""" +from engine_logging import logger +from components import VALID_BRACKETS, VALID_CONNECTIVES def find_variables(statement: str) -> list: @@ -14,12 +18,13 @@ def find_variables(statement: str) -> list: """ logger.info("Finding variables in statement...") - # NOTE: Check if all whitespaces are removed. If so, continue o.w. call clean_whitespaces() + # todo Check if all whitespaces are removed. If so, continue o.w. call clean_whitespaces() logger.debug("statement=%s", statement) variables_array = [] variables_string = "" non_variable_characters = VALID_BRACKETS + VALID_CONNECTIVES + i: int for i, char in enumerate(statement): duplicate = False diff --git a/engine/components/print_details.py b/engine/components/print_details.py index d91a250..963ffd2 100644 --- a/engine/components/print_details.py +++ b/engine/components/print_details.py @@ -1,4 +1,5 @@ -""" Insert """ +"""_summary_ +""" from engine_logging.logging_config import logger diff --git a/engine/components/regular_expression.py b/engine/components/regular_expression.py index 7f4af22..c688972 100644 --- a/engine/components/regular_expression.py +++ b/engine/components/regular_expression.py @@ -1,7 +1,11 @@ -""" Insert """ +"""_summary_ + +Returns: + _type_: _description_ +""" import re -from engine_logging.logging_config import logger +from engine_logging import logger def validate_input(input_string: str) -> bool: @@ -13,8 +17,8 @@ def validate_input(input_string: str) -> bool: Returns: bool: _description_ """ - logger.debug("Calling validate_input(%s)...", input_string) + pattern = r"^(?:[a-zA-Z](?:_\d+)?|[a-zA-Z])$|[\^v!<>-]" result = re.fullmatch(pattern, input_string) is not None @@ -22,38 +26,39 @@ def validate_input(input_string: str) -> bool: return result +# todo Create Unit Test # Test cases test_cases = [ - "^", - "v", - "P", - "P_1", - "P_2", - "a", - "a_123", - "123", - "@", - "#", - "%", - "A", - "B_42", - "C_", # questionable - "P^Q", - "PvQ", - "P->Q", - "P<->Q", - "R_10", - "X-Y", - "Z_99", - "0", - "5", - "P@Q", - "abc", # No - "def_", - "_xyz", - "<", - ">", - "R-5", - "S^6", - "T_7", + "^", + "v", + "P", + "P_1", + "P_2", + "a", + "a_123", + "123", + "@", + "#", + "%", + "A", + "B_42", + "C_", # questionable + "P^Q", + "PvQ", + "P->Q", + "P<->Q", + "R_10", + "X-Y", + "Z_99", + "0", + "5", + "P@Q", + "abc", # No + "def_", + "_xyz", + "<", + ">", + "R-5", + "S^6", + "T_7", ] diff --git a/engine/computation/__init__.py b/engine/computation/__init__.py deleted file mode 100644 index 8a1a818..0000000 --- a/engine/computation/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# EMPTY FILE - __init__.py From 1e81970a58730ef1332a6feab4253a533e136991 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Sun, 15 Oct 2023 23:44:53 +0200 Subject: [PATCH 18/29] Cleaned up merge from 'main' branch --- .github/workflows/pylint.yml | 1 + engine/components/constants.py | 16 +- engine/components/create_conditionals.py | 25 ++- engine/components/find_variables.py | 8 +- engine/components/print_details.py | 8 +- engine/components/regular_expression.py | 67 ++++---- engine/computation/evaluate_statement.py | 7 +- engine/engine_logging/logging_config.py | 24 +-- engine/engine_parser/parse/parse_function.py | 24 +-- engine/parser/README.md | 31 ---- engine/parser/TreeLikeStructure.drawio | 80 --------- engine/parser/TreeLikeStructure.png | Bin 32482 -> 0 bytes engine/parser/__init__.py | 1 - engine/parser/checks/__init__.py | 6 - engine/parser/checks/check_brackets.py | 44 ----- .../checks/check_for_illegal_characters.py | 44 ----- engine/parser/parse/__init__.py | 1 - engine/parser/parse/parse_function.py | 152 ------------------ engine/parser/validate/README.md | 8 - engine/simulator/input_statements.py | 70 ++++---- 20 files changed, 138 insertions(+), 479 deletions(-) delete mode 100644 engine/parser/README.md delete mode 100644 engine/parser/TreeLikeStructure.drawio delete mode 100644 engine/parser/TreeLikeStructure.png delete mode 100644 engine/parser/__init__.py delete mode 100644 engine/parser/checks/__init__.py delete mode 100644 engine/parser/checks/check_brackets.py delete mode 100644 engine/parser/checks/check_for_illegal_characters.py delete mode 100644 engine/parser/parse/__init__.py delete mode 100644 engine/parser/parse/parse_function.py delete mode 100644 engine/parser/validate/README.md diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 0f0e51e..ca9f7b6 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -1,3 +1,4 @@ +--- name: Pylint on: [push] diff --git a/engine/components/constants.py b/engine/components/constants.py index 9ca30a5..c4a476f 100644 --- a/engine/components/constants.py +++ b/engine/components/constants.py @@ -2,12 +2,12 @@ # Global Variables LEFT_BRACKETS = "({[" RIGHT_BRACKETS = ")}]" -BINARY_CONNECTIVES = ['^', 'v', '->', '<->'] -UNARY_CONNECTIVES = ['!'] +BINARY_CONNECTIVES = ["^", "v", "->", "<->"] +UNARY_CONNECTIVES = ["!"] # Constants used in the Computation package -TRUE = 'T' -FALSE = 'F' +TRUE = "T" +FALSE = "F" # Constants used in the Components package VALID_BRACKETS = "(){}[]" @@ -16,12 +16,12 @@ WHITE_SPACES = " " # Constants used in create_conditionals.py -OPEN_ARROW = '<' -DASH = '-' -CLOSE_ARROW = '>' +OPEN_ARROW = "<" +DASH = "-" +CLOSE_ARROW = ">" COND_ELEM = "->" BICOND_ELEM = "<->" -PRE_CHECK = ['<', '-', '>'] +PRE_CHECK = ["<", "-", ">"] # What are illegal characters diff --git a/engine/components/create_conditionals.py b/engine/components/create_conditionals.py index 1dd831a..09001a0 100644 --- a/engine/components/create_conditionals.py +++ b/engine/components/create_conditionals.py @@ -3,7 +3,14 @@ Returns: _type_: _description_ """ -from components.constants import OPEN_ARROW, DASH, CLOSE_ARROW, COND_ELEM, BICOND_ELEM, PRE_CHECK +from components.constants import ( + OPEN_ARROW, + DASH, + CLOSE_ARROW, + COND_ELEM, + BICOND_ELEM, + PRE_CHECK, +) from engine_logging.logging_config import logger @@ -26,7 +33,9 @@ def create_conditionals(array_of_elements: list) -> list: end_of_line = True if char not in PRE_CHECK: # no symbols present if end_of_line: - logger.debug("Search for conditionals finished and none were found, returning.") + logger.debug( + "Search for conditionals finished and none were found, returning." + ) return array_of_elements continue if char in PRE_CHECK: @@ -40,7 +49,10 @@ def create_conditionals(array_of_elements: list) -> list: break if char == OPEN_ARROW: # checks to see if we have a biconditional - if array_of_elements[i + 1] == DASH and array_of_elements[i + 2] == CLOSE_ARROW: + if ( + array_of_elements[i + 1] == DASH + and array_of_elements[i + 2] == CLOSE_ARROW + ): array_of_elements.pop(i) array_of_elements.pop(i) array_of_elements.pop(i) @@ -48,8 +60,11 @@ def create_conditionals(array_of_elements: list) -> list: continue # if we have a conditional - if (char == DASH and array_of_elements[i + 1] == CLOSE_ARROW and - biconditional_symbol is False): # if we have a conditional + if ( + char == DASH + and array_of_elements[i + 1] == CLOSE_ARROW + and biconditional_symbol is False + ): # if we have a conditional array_of_elements.pop(i) array_of_elements.pop(i) array_of_elements.insert(i, COND_ELEM) diff --git a/engine/components/find_variables.py b/engine/components/find_variables.py index 54a8ea3..1ac3ae6 100644 --- a/engine/components/find_variables.py +++ b/engine/components/find_variables.py @@ -3,8 +3,8 @@ Returns: _type_: _description_ """ -from engine_logging import logger -from components import VALID_BRACKETS, VALID_CONNECTIVES +from engine_logging.logging_config import logger +from components.constants import VALID_BRACKETS, VALID_CONNECTIVES def find_variables(statement: str) -> list: @@ -28,7 +28,9 @@ def find_variables(statement: str) -> list: for i, char in enumerate(statement): duplicate = False - if char not in non_variable_characters: # if char is not a bracket or a connective + if ( + char not in non_variable_characters + ): # if char is not a bracket or a connective # Testing for duplicates duplicate_int = statement.find(char, i + 1) var_str_find = variables_string.find(char) diff --git a/engine/components/print_details.py b/engine/components/print_details.py index 963ffd2..c27bb46 100644 --- a/engine/components/print_details.py +++ b/engine/components/print_details.py @@ -21,7 +21,13 @@ def print_details(name: str, *args): max_length = 60 len_name = len(name) amount_stars = max_length - len_name - star_line = "*" * int(amount_stars/2) + " " + name.upper() + " " + "*" * int(amount_stars/2) + star_line = ( + "*" * int(amount_stars / 2) + + " " + + name.upper() + + " " + + "*" * int(amount_stars / 2) + ) logger.info(star_line) for arg_name, arg_value in args: diff --git a/engine/components/regular_expression.py b/engine/components/regular_expression.py index c688972..e57888f 100644 --- a/engine/components/regular_expression.py +++ b/engine/components/regular_expression.py @@ -5,7 +5,7 @@ """ import re -from engine_logging import logger +from engine_logging.logging_config import logger def validate_input(input_string: str) -> bool: @@ -26,39 +26,38 @@ def validate_input(input_string: str) -> bool: return result -# todo Create Unit Test # Test cases test_cases = [ - "^", - "v", - "P", - "P_1", - "P_2", - "a", - "a_123", - "123", - "@", - "#", - "%", - "A", - "B_42", - "C_", # questionable - "P^Q", - "PvQ", - "P->Q", - "P<->Q", - "R_10", - "X-Y", - "Z_99", - "0", - "5", - "P@Q", - "abc", # No - "def_", - "_xyz", - "<", - ">", - "R-5", - "S^6", - "T_7", + "^", + "v", + "P", + "P_1", + "P_2", + "a", + "a_123", + "123", + "@", + "#", + "%", + "A", + "B_42", + "C_", # questionable + "P^Q", + "PvQ", + "P->Q", + "P<->Q", + "R_10", + "X-Y", + "Z_99", + "0", + "5", + "P@Q", + "abc", # No + "def_", + "_xyz", + "<", + ">", + "R-5", + "S^6", + "T_7", ] diff --git a/engine/computation/evaluate_statement.py b/engine/computation/evaluate_statement.py index 49fd366..57045bd 100644 --- a/engine/computation/evaluate_statement.py +++ b/engine/computation/evaluate_statement.py @@ -147,10 +147,13 @@ def evaluate_array(array: list, counter: int, matrix: list, variables: list): logger.debug("Evaluation of array in evaluate_array() is done.") return returned_array, final_variable_combined, matrix, variables - logger.debug("**** ERROR! **** \n This should not be reached. " - "Inspect evaluate_array in evaluate_statement.py") + logger.debug( + "**** ERROR! **** \n This should not be reached. " + "Inspect evaluate_array in evaluate_statement.py" + ) return None + def set_new_array_elem(temp_array): """ This is used to set a new array-element from a temporary array of elements diff --git a/engine/engine_logging/logging_config.py b/engine/engine_logging/logging_config.py index 2e946dc..73deb61 100644 --- a/engine/engine_logging/logging_config.py +++ b/engine/engine_logging/logging_config.py @@ -4,8 +4,8 @@ MAX_LOG_FILES = 10 -LOG_FILE_NAME = 'engine.log' -log_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'output') +LOG_FILE_NAME = "engine.log" +log_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "output") log_file = os.path.join(log_folder, LOG_FILE_NAME) # Create the Output directory if it doesn't exist @@ -14,27 +14,31 @@ if os.path.exists(log_file): for i in range(MAX_LOG_FILES - 1, 0, -1): # starts from 9 moving down to 0 - current_file = f'{log_file}.{i}' - next_file = f'{log_file}.{i + 1}' + current_file = f"{log_file}.{i}" + next_file = f"{log_file}.{i + 1}" if os.path.exists(current_file): - if os.path.exists(log_file + '.' + str(MAX_LOG_FILES)): - os.remove(log_file + '.' + str(MAX_LOG_FILES)) # this will be next_file + if os.path.exists(log_file + "." + str(MAX_LOG_FILES)): + os.remove(log_file + "." + str(MAX_LOG_FILES)) # this will be next_file os.rename(current_file, next_file) - os.rename(log_file, f'{log_file}.1') + os.rename(log_file, f"{log_file}.1") # Configure the logger -logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s\t- %(message)s') +logging.basicConfig( + level=logging.INFO, format="%(asctime)s - %(levelname)s\t- %(message)s" +) # logging.basicConfig(level=logging.DEBUG, # format='%(asctime)s - %(levelname)s\t- %(funcName)s - %(message)s') # Create a logger instance -logger = logging.getLogger('engine_logger') +logger = logging.getLogger("engine_logger") # Create a file handler to write logs to a file file_handler = logging.FileHandler(log_file) -file_formatter = logging.Formatter('%(asctime)s - %(levelname)s\t- %(funcName)s - %(message)s') +file_formatter = logging.Formatter( + "%(asctime)s - %(levelname)s\t- %(funcName)s - %(message)s" +) # file_formatter = logging.Formatter('%(asctime)s - %(levelname)s\t- %(message)s') file_handler.setFormatter(file_formatter) file_handler.setLevel(logging.DEBUG) diff --git a/engine/engine_parser/parse/parse_function.py b/engine/engine_parser/parse/parse_function.py index 3c22785..3c7613c 100644 --- a/engine/engine_parser/parse/parse_function.py +++ b/engine/engine_parser/parse/parse_function.py @@ -1,9 +1,4 @@ """ Insert """ -<<<<<<<< HEAD:engine/parser/parse/parse_function.py -from parser.checks.check_brackets import check_left_and_right_brackets -from components.constants import (UNARY_CONNECTIVES, LEFT_BRACKETS, - RIGHT_BRACKETS, BINARY_CONNECTIVES) -======== from engine_parser.checks.check_brackets import check_left_and_right_brackets from components.constants import ( LEFT_BRACKETS, @@ -11,9 +6,10 @@ UNARY_CONNECTIVES, BINARY_CONNECTIVES, ) ->>>>>>>> main:engine/engine_parser/parse/parse_function.py -from components.sanitizer import add_brackets_around_unary_connectives -from components.sanitizer import remove_brackets_around_variables +from components.sanitizer import ( + add_brackets_around_unary_connectives, + remove_brackets_around_variables, +) from components.print_details import print_details from engine_logging.logging_config import logger @@ -45,8 +41,10 @@ def parse_array(elements: list, variables: list): logger.info("Finished parsing array.") return tree_structured_array - logger.debug("**** ERROR! **** \n This should not be reached. " - "Inspect parse_array in parse_function.py") + logger.debug( + "**** ERROR! **** \n This should not be reached. " + "Inspect parse_array in parse_function.py" + ) return None @@ -147,6 +145,8 @@ def find_connective(arr): # Private Method logger.debug("Found connective.") return elem, i - logger.debug("**** ERROR! **** \n This should not be reached. " - "Inspect find_connective in parse_function.py") + logger.debug( + "**** ERROR! **** \n This should not be reached. " + "Inspect find_connective in parse_function.py" + ) return None diff --git a/engine/parser/README.md b/engine/parser/README.md deleted file mode 100644 index 503cdf0..0000000 --- a/engine/parser/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# Notes - -## Error Checking -This will consist of: -- Checking for invalid characters such as @, etc. -- Checking for unequal number of opening and closing brackets. - -## Parsing String into Array -This will parse the statement as a string by first analyzing the statement and -extracting elements like the number of variables as well as the variables, and -also returning an array of all 'pieces' of the statement. From there, it calls -a parsing function that turns the 'simple' array into a tree like structure, -having a central connector used for the propositional calculations, a left part -and a right part. - -![img.png](TreeLikeStructure.png) - -### String to Simple Array - -### Processing Connectives in Array - -### Restructuring Array into Tree Structured Array - -## Validating Array -This will take pieces of the parsed statement and validate it before it continues -parsing. For example, if an and connective has a left side and a right side. -Also, if we have an opening bracket -### Processing Connectives - -### Processing Brackets - diff --git a/engine/parser/TreeLikeStructure.drawio b/engine/parser/TreeLikeStructure.drawio deleted file mode 100644 index 92fb102..0000000 --- a/engine/parser/TreeLikeStructure.drawio +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/engine/parser/TreeLikeStructure.png b/engine/parser/TreeLikeStructure.png deleted file mode 100644 index 1a96b1a2447e023806dc23c358d1cba3afe5532e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32482 zcmeEtXH-*L)Zhih0zMI`Dn&s7>4?&sLPWZN6lp*tnOXCG_>z--c0aqFL-=HqjvNA4n&u$k01#ZDsebjApY_T&#%@u2|FhfGYeGG)Ger+So_~26PaB>lxO{@l z@#?=5WjEdExVVc#1`S6h|XJ*DjcV7xQd z7&{@vW*pcQ!DAidf7$yZOQtYdsZc!j!?4RCBUa+g6>YdaqG^k-Q2YR2xTjkXcd#id zWpSyiMICbWBK<448>QKpG`!Tsf>tR&H|usy8<0wZRT7Mo?;00iy2qQBB{%bpNsS{( zG~e&S>LUV%9OJ59Gk;tDAe)+)xvY}sQIdGPw#WJ=qA&m6$DJGUvRIAQkyV%xqS%66ZIo{zRkU$rOA*Dox`^rbXjmbdqB+z3MoY=Qjm$;#Z`9Qi zay=lyB=hd6t-<7=$D_Fstoo13uH^;#9@Y85`rD}-wy6l?AN7NdI8VdChKQv6r>mQJ zLK#J9F3l$`KWyo`C@;S<$LH|2?eXM~xR2%zIn?TpP)5&~TIb$MGRESKn%OzF5h|L? z>uv&w2_bS(1k3=TJ%q#ehmMcUa9UF8-H+|8CHP9b9$!;=lLuY!?B;-$3!b7xQ>I6a zjRVChV+~O18`)d<{9uphiw-3x-P$IEN|gLiMSJ$fleZA;Mga<3tQ05KQvJO&8Es{I zX*^Nf6w54JO4}mI>mJ)-AM`}H;095D=o4nC@J4-fQ}yk@(lbLiE&q&_B4z_G;#P%7 z3-ZIiUl%JLxeJKByOdTlj_(_~>iW<=W&8OZWR&|HGP{20w15-w)?8nPD7xv_<=apOYgytzG4{$tG4<3?;Y^ zQTmuetvYwa-K10`hP4^~HCL{;Nm$f00&!3h`VEUIAX+2xhprBCF%dcMIZY)nF+oaX z6W_e9@UEpLl!Z-yK^fsu%FQ**mGaJ#k|^f{<|sJSz-+@X2| znbpPG9tyF15XKz5d?3k#~aEXx^Ad#oy2T!C}wy9u4V{;o@sj<`?T>#ldOk zjeBHP1@-GFyu}m(2hspilH9&k$?KDOSzO0;P#E4+!@S4cmp9_V<9o!*>XvM}iTE0+ zv$N1^)yv#^+=*u`6+6h|J5U!pV_s0Adlf?>75hRarCPl^hDq9W)d^Yexs=PgXsO;!HZSzi8ATQy+BV0qWaUYSvN1;0 ze&|PIOlo7?4E_{*V$~ZN9bHmX59>H~x}B-I_Q*+>@n8Y2sN(X)pDvBXulnA=r^kHH zwMvsh!C2YySk@n*S)`nmFsv>9DrDCa;z{9wf)O^zt$e<(aXCJLk06(NyeX6RlKx;nEl>N%koGNtS&r7EUlo)*BidRoO&yj$zu;?C^d8$HaoHLHg<8+%H0 zx)Kgx8(~V`@yD)|`U#)yvp8ScV{JbWksB##;xy$rG519lH^Ow`!nY!E{`+n>R;}|r z&5UbH#2DJMYWtAN6Zc|qCouE#S_8_FH;HSZA9lV~)G6U}`><7Z8+2YZ9E4nuX1C*Y z)o|PPj-D>C&i}^#QY|p^QD%c&fQu>NU3phfu-FQtKzVfCh^5(y0dL_dOP*R6%VUKb zZ!F5k^2Eg2#v(P*_)X?QaUNmuVD7PP+Yi>Sja}C;?A+iPyDhdACVd{&84mGVlR%*`W%CA<|bq*KPacd1(*PartNY$5AzG(ZA z&;_bqt_ky{V6RdG64+-(xcNDGQe8@J#l!ny$wYZ+SHe}oGns8f!QOE*Z~5YF->76_ zM3*vsdyj%eFyFouQoY|&Srq0)zDlSoya@DOMHc$`%aa?fnC8dZU1!h!Ztm86PON=9 z4%Ji>p`RZd<7Bsle(blb=;zj%!a!elTEEt8fKxbi8J1s|@ELTE4TvGp=gy%JuCx#6 z>HMeh>P0uB6FyuBGv?pIM1-N(wIy1mo!I*79q%xq?`RoxM_Q2cEWHAJ&AHAjtDi?B zS$k6HQoZdWglkiUrPuWLO8ornq{K6 ztVY6TLuEB&V7~6hF%Km3pebLU-`ootn@NVJ&X-H`DyJtR#+A1WRAV?rJm5{B5Md2P z1d;Fu8gLh<7iR{qa*u9(`QA3{d|`a9^ZS?9v?A-8hp;6vH?gg>i3UMtCSWDcKQp6UMNRQMN#C)VB@Z>(t%qmP^(I89-DZfdin2==1 z%?!ELmbSj|M-nFH2*=O6_%rd-Dq3B}p`HU8G;-Vc-GC;!fMSMxLkhbo9#UZuR>ja` zZ0)WWZf9YN2(NwEJ+2p=G~HZ;Rxp_wXaubn1m!qmK3g#0nmwgwaQ<7alJ*oMA;&=_ zMzUx00$gyuh7@cHmVzobx?sX>=25j`X(yPED z3=qA7{J!2(DTTE>Qql?2-Xq@7%`cki1=gNlzWVQ7zw|CX6J?FKc`Y=aZ5 zj7iV}6rE81AdVOP)L{bZ-m!6*ss@<=@LG6B+0t+B$d7in) z!d~l9nR#&JBc5uMt6jSb+tJ|3#1X~E$ny)B_-nX3Df*XV&eujxYj4nSS+V9KheaBW zdl%a4EG(h!)@#+x_?{tJ@6|7ETsuCKI-}NBCv+ADW2FccXOyGYcTZxL=GWi9j%>D* zPyb5SBW~huglnm8>c%F+!y72ro0xtu$YK?uMo8Wg2Csu zj_6j}8}Z=<&nAWz^;uK)neDuFOMj#+TI#Y}<-(Zm_bfd zKis=(u6Jl&`CLS%%A=EGcK648n0u-?U?vC#Q)tG!dHM(|0k>uOgyUj$Ud9!@u}n<$ zEECBu%v`p+7Js5Bp=OUSzq4X!cW;QOH|foLy3Xut+}l8voFx=2!xc#0aU*eKn!;@LQZR2y)|?eIH)_CCxdxUB+&&p*0_-$4u_KIU z-}8~15B8v*@uK^%z85$=Qz0Ilj6*xC6?Gq0YQl~hD&Cs+O40E67P#|WjB)hA_Q)CZ z9Zxj}y{Q*k2UF>0#RLinO|rx1v(-JpkSRF$?Iyy=VQT}yL7ZwM=6$%WI(4Bp?~ZB1 zJZ9bOf{)`I7g5xt0OBr8QEGMk*|e+Ywp8|66>6YGBez17v|}cCUaxDY2}pCHZ%0~j zMzZc1C}yB+!)u+`tj4%B>K(ad>P2vgk9xa_?=+58{yZ3RZ4MHerT1Cj;+CVc;JsAH zN6w?y&-dc=f&=5A0H!M# zx+<||{O~L?SK02pyJwnQ5q~!lpNB)ePH5 z-ByhWl8S-$Fx)48?Yqn~ovL1B^T_+OMo0XQtc0%z{PpN&<+!Az<9MJik)3 zfiJPmH@c)<)p&*k^`ZWA?z@gi6P%o=(OhHOya<;w&IE)hiwV6 zuQ91*sY@e5^Bzmu%yRZ~L|;*pqCfUTv7lvZpUkbnJ)_09$OQQ#q@1*OkqAggo zav&|r>?fr!o*hHiuoJIt{4iYC`m#MG>VHWwPqw<@QYAwQmV(85ia+pK^h&{i?q`>- zf~*PaAv;V>jNX&P%c@u+Fh+Qyb_b@rpx2*fL9;;M5Z!FBy893O&?oz8uX}65q-*j! zw_z6oRt58iKGtwUJz=Nu(lg4JMZM&isup#$OPO4GvUbz!4gOpA_}fIug+8KZ zL!E{`!X5<1g5eD|jZ+BY)>^h|NX_9G64(7I>f9x17tnLfwe_Y8!18iYYqoUDY$<@| zs%P*ChBUq6riOU1GA4X6$$7{vx(Fo06(2`!ADXVk#kju?96Sw9jhdONtI5_&0$HUN z^sg(dh=U?FQ<*W)iLExTveVAr64{M5KUA!&bE;rMjhY$V9oc?P$JM3wBbCRTk(WZ@ z4SmNgqE8`P%&wp?J0iE)>1M~LZO@FNyyJs^q9XRn2mvcIoV9M*H#zBM=IOs4VGLAA zv1@Z}6EeSeb|}GU@w@AY_xhztlZ{W4R+t_z+uH@Sxo43r2Pks8ss|+OdJfYbd!t%1 zqqO+l6Y~0F-NP^!lhUG<<-6Y?cWi}h(Ol2Fc5cT82wHDs1sFVx`MlBONG`H3^xNtz z{N_+~BHV@N`Eto@xXYOEHIBABO4@e3tk1K~JvyCOR5;_csT{-IzJ;$-@Kzx7Aizqi zniq}ldi1L$iOWaP^}apJMRHyFqf*;!0P4tBQ(ixWtm!! z-dQ;4!Q~ID5)@3b0a;{!NnBcH?a&OQh?`(@CY*>1$if{Db8@#vF{hudyjcQjPHVyt zl5JJ$S0m%yJg8JPy}D?lvbeiFt_a^7Gq!BP9oO<1j_9gMpnzHLesLkK$4--wa$Mqc zVPCjUyEu9K8^1lz-c8o#)S?m>kM0GN4Z^`K_d8+rexMr|iiCiph?$Ef=kV@K1#iTW z*;;*33olFlh%xrXN@<*vqwmy(Ut2Hn+FT|In(!zkC#ra!53^FSDSR``Q;iF-=*hpM z(W*Q#hso!`DhzITD_OCD{a$Rj17UC1@g5UqLDqCEGvIj8Ht{5}Q`o4!d7aO}niyes z9hQPj4twA>Dnoa-Zn%4$5AB-TzF6;37olMUv#Xl*y#H;jtTdA=B-~N?+1c#Z7WTGR z?i2|XshDb3zsG~)7`oXTmU^WPb*W|pmZfd!LnE{E^fNVc#RSjN@@xL!!P3G`JEe-R zy{-K!nH_5}zihne{raQr(;TkR^2@GjvD0(zjUAW|U`ssJ$qSZQas$Wn2e0aP9`QZ2 zA{LYG{#e}PtW2!Gr(-2ub!BZebxQo zwt-u`;N?Du_05O`MwLcfOb_B&v;U9$*n}7YB3IuOi%#&p`RWV3&7;JOB9PM^vR6NT z(|Ku)IEsrbtS)KlKHiic;hQ@$)$A>~Rexq3bvWkKmv)Pff4GYotL8byA!T^j0;(dQ zH9L4zgq&KCy{)>)rNx{O^CdZ{m;>&L@4=zOh9$r+Vq)8-H9W8R@wLUy#t0Lka{vww zC2+JJLAaO>N)@`5q5u~ATX3NYFE^dTNAG_-JqvM|=;R}>kuNtJ>k{ZA%Z(c@y7*c= zoV?Gew2(5r{B{0}{Gg>Iw?U`-V`Iq|c>bIf))E7PxB5YY=MB^a43JaPh;$oFdGOlCqjGXew^g(Y3lY60SkD6DGlk1Ado>-u ziC*!%5xdzYmf9DCrZjS}>_F3??Ns&|-ZlM=`m-{xWlMRsRclcxZYgJxQ9u3&x@to6 zrfHUemsh%WhXt}=#x$u|(uNiE=q*7hJqH8G1@Si#ET%jGwmXSPF81x|OdF zs%UmaiV@rwYrS z9*Yc)k%2jSTtO!)&6zpw9p%B2{)*k!mlJ$inl%oQGn>L6{O*uxg>kH(Qd^OO9<&Vw zW_LC-hRMN9?myg({FyqRr{96VX2-|0I-;xQk|krBdJEk}I%35^0xP@3qod5oxCc;p zSK39fKvI%JJwwGZSkX?5O|pe3#j}s@HbuKI_Za6~_@*^9CLL)(vV|D1Y%CqUb6#@5 zZaa2xUen+_|3F)It)YL3twIxDv1{hM+SdHqdy5?X2#(U`v|XzUucuAM=Cm$y45?_X zCXfUWV!|)KFut2p6HA@;M6tFLTz-nRfAX63-EPgSmra7+M&uL(t$aPtJH2PKG`}Ii z<8B=YPHK!)E}|PwGYUsXdISl9GnFwo5TZ09GMsqpRu@C10Wj$^I9VxKb=xvGrivDx zy%Seqeltb|IgM~Ku-qZv>aDVsM}LNFK8a*w3$-eHkG!p@gR85sgiKVASEp2SB))q1 zC2fv<&T{(|3(u5z*i z-*5P5Nk6)lU>NAk=4c1`vY23sG{Q+gwQBwFbV1Eunk#BuMQ>&$fO zl1pB94(AC#{r!AXg0)$WNXEEnbzzXhGXe3T%igPALK|tPP#3p}yPgPa%aR?S$D$7@ z(dWLv>X;)im6`jr&%`jR3cUM6g`K}-VtW~7)|#19i7<1ysh2^TV?xNf5htXhJzF@?R65bdYYstt*=(zmHN?qDZR5f8REq{DI|l$+g9;5l ziG~M@R;k_0@oPf9tCYNnac2eyY5iqkk?a&4d3LJLEvvf)=Cg zO`+!69Y&EV;=4_^RBR>t+6?zwM&C5wm<7YlKsa511u+eXj1o?=by4CaS?YnC(1*l`AOyTJD zye~wqQf90-KJOl-V*N%}0uQzyNs%mOONa5fta-`bsF|4#5Bh_{H297{Z;#q$?7`g) z=Ed(ntnK4LhO`x(<$AR>wiK)d&=Wjkx%Y@KWcwfngjI*FtJNqLGwQ9JDG!p&gQNk> zEYetVIBsRmPQ@n*%$;ly<4T()+nFoR)gHXyCMBzRJ`#RSR{vdnlpw8JU2~f<3(;^- z$(9Fo+2L>;TY9i*o%~y09vBc|P@3*|0hwS{_Su^!kN#$K(*KpFST)*!( z_cjn@H!^)oTkyLG@amxByz3pxkC7yec!6pIOCbm-y&mp^S3j{V#%z_?Av6WHTar!U zqNePjW|~Yc!szwbfI4sW1~$eS)chSzI3uEoWm;gnn8zaM6o=-<=Uy&jQt?RAtGhyEFv9Y7c;ki6VmamKv~k%O~m0szlw-b zQ>-N`!?~Dn4n9c}+wRu!aLI#IfmY(GO|S{WV#n#>x~*mrl62HXo$JRi=qwoB>RbvEsksSN%(r+dV3(i9dX%>dgt%}$lqoqPU_gCvQdAj7UGi@6+ zH?xK|`vr>obazXVPxdaWM-+q#_V%nWW1oWOypA>IsdcNFQ%qx|9TW8j!S*quoUr^L zIyJd>(U9N3eYw|})=7j7|8&MjOm@X`+hQ>YcAjIp)Ezd?!VpCcLuK-Znvw|9TkZq| zcK;Pk)D4<91G6*Yq73a!V+!M8!(!ZHSoFSF$Mk-YsANETH}F$63p_RY6W3>V zDQob(5def-y?9nCC6JWsGf;C%T${So@|NZ0DP3irice91L%raBtY2@c zA92k&MI057qY(bVYXa@mYtE7Bnp4>R2I5-%`n5QJA=?D^BIy`oB%#j;$wH4_Zikip zi=t_rU}7+#3#tsCQ>%c7`LGR)+J4Ahci&WLBFv}8?%mFx1gYHq7ZvM*(M31TLJzm* zy=?}%`HQ8UJ&3-O!qLYdLgSw^ZhZB&Kn8U_{j zHirbZWlD&&8jL@Js`Z*N7q>KfRRSE@qc*5ez@ZAm7GZ?^UUYs9x=I+%ON`UtzCGzT z6J5M&h-BG4kI9t#+cV5BevfuYC%0ko1I#-N(4Eic1IRw2RTDF@D#2OaNP|_;B^MLh z%vn---oMz8RN5Z5i%e=J&G}!&UTf8wHH+gEjt|{j$ce2|?y6&gD!hAe+kL$eFIG~w z^kLNg)Us6ic}ie`l|=7;XyNGBqH)vFV14OUJC``Hdq%$?#FE%1(**Zh512;nD%u6- z<;-UO!-c7gF21Mrc*fc;P)>V_D(J#jDvk@=s$z{HMThrKY=3?Nt@TCQT=yc`m;@xj zzGx=JspPieX1`jbeTF|j1=omQDen{G_MeSIM9WN#e--mqzem3nh*ocJ2jbGd8w{KADglAxXcUxGNf(?xT6$QHzElC%{Oc7 z%dJ*=^kJUBpPwVpBus%F{a*A~9L4hAHi#HqWKewm#A)+k6X^4?qG9?4`>6k|dfkbA zX6C-ws}Lt_={sUU^M{Md*La(%NF!XWg8xA<@ertKL+88 zso4G*t9r6SEDMR}n<;zi;&~yYxY)qE;>0thd_1s!2wp_r{`$f{S6==~5r50@E~NXx zzwrJJ)_)yF`t~UP{})gI;9IzIW5vwVbPXGrKFk&61xQro{CGXbdI@@~z)H4c|G+K` z=;z&wTN5{|_p6rmU9|_@1JaS}T5ktI@ zvd78uZ1T35E0aI&q*gTaV-<`^Gw(w76LETh#jU`y2=P20_qG0-xkQVS4EGD7}HKc;C)z!Uq$g1h|MSpqN&Ln_eas#%whA@wNFxVILs(>yb2@RW?@k znI9GAAw;bW@4}ahsB?v}eYy7{BNhTU_hNIB)0zchIhG~oVHZX5`#JS{_Wj5R@mwEw z(O5tI27DPC;HEo41f$nf!~Eg&FnB_2wNS8lv9ieemV zNgvl)iw|w8-#3+faooXz2^+}TobnYi13p;vidyBEA>cdh;u!>~n<5-W7!4-j7cveO15xq6G1Q2- z_%H;siwa3^jSBVVZrd~2riQ^c0}8BItYu1cmr-7nK{QqMA-qxFvTcn@3(;dAK+`d} z!{QTH599iT)TMs0$ZRLj*6*!wJqqFCT=y9oxnFo4s&t?!TxVlV4SRz3zQ%GwlFc_4 zv0n&7_9^dihzgBjKMsq{9+kY_YPQmO&!K$J=+|C($x1d>0spIx?6_wfe6}LncZL)W zR@6`hv*Al+d#mMW0FN1a=Od{fc8;&@`-xvay=6|y?Qwl9UI{_STc>@cQ#$t|isPwT zok)*8g=)^XYQ)iOTPyB7fwl-S?u_b4-F1oneF<&uON*Wz5fy3^3-n&Z36zpuLWy|ax8Ckn^gIZCID(vZZmo4WV3=9a1>|OJC#td32x= zLQXpD`&2(ub;to?C-x5z)JEI<7U21Dk&Eq@2<7DtG>}Mo8=haF592IqXpUocj)0)u ziEOOEGHUbqANwaEq+_B2$cE6VrtWjlGWC!_T2+M;3VLlw$6z+Cjcn@FkF0%1kf_mR z-~j1(>F-7pu}$4m8&y=|gb8oY$*Ov>zaLV7Wlh z@f48$27Hx^f1lNsC}(rk_W^eu4QR?#er*~NUBgRcN@=%nj#fb z5}Ds(31^~wvj2&t{&guit7kF)*5gf};LBVtodA{wN->8^&qm(zOn6~F< z*&qY3R*p#c=yP3x?;!6tQ{Wbs?UdFN1NX>>K|Awibul+GxOa(Gi+~}e91QG}Xt3#G zkkyNd;}Dj-Z@V%(Q^17M;{_eUh9`OeM6V%msGR~fRktS%N6r0Dc0kWRDU0M#)6h9@ z+wJ0^kOT744e~PXJVXU{lkWzB1=R~N-@s^^ig{cX&tXK6t(V=7DPKHj9!U>u>q14v zW?`GIT_i>zk(dSk)ql`tz~-J=C9{1YNlDsff)nQK%^&hg3x7%=)+` zl^n+D1!(=Z0RM^ol1s_qL0i{Jpr4K~eJBG)CLlCab_W#gYk&G;Pp5WN+c{zad-e&m z{3h^6&rb+nz07FTK+Fa@*&Z`YTa~7lGnnUwHjKEj+6)Xw5USeyz?4I~%V*FAmS5 zYW>+cM!?1w*UTIUHmKGO+m)q_716k0q(5}l&n@r|fi5J}5fcE82qZ2shy9_nyO6_P zWn3g(yIO@3(_t%;ozSD2{`1SjK$!wzTCxcn?Itp{nI}{1oWmHjpe9VPt|;1RIjmfU z%h*ZTF^@?CCnddj9GDdD@}D^Kf!g7dcbC~2RY+xI-!q+{UGzD?Uws593ZL&h|FPgt z+8olyxLE}*TTGiz25$5SuSb_AFmj7im9sua1GKd3oR#)6qp6K4EN$Ao#@O(M|5U{s zO1x6w7|3;fJca9rQReP28Y2E^AlJpy&?%x}1QO^H$QYCOFIINvWtwYiFc|@CVC!}- zgJd1C5T37(>%grher0~42!wp=pd81Jlm>g}a&WG8Dr3X-XWcB^$G>c&16uLuhyT)b zF4#!k$AaCtXi4pSisDi0H+~E8ffa!Pe=A&PQfa%Yy3yrcJ!#Z!Z`6EM5UoVDzG;(m zQ@+co7V8$tBny)FJ?x4#*IUUII#Po`;QRh3NA~+X|Q00!p zIG6apBtEUY@ush6))kBKn@8jwCn{roi#q@565OpuwK+F95$M1(V@&Z8;M^ntJ8Yys z2UR{pkk(v1s>Thptj)sMy=y&Wo95MccKbW=U%f7DaDq{%a-$KP9dW!lsvetd1u3$r z1!p}tb%J4ct-eQ-=-*zIojHXF-7*ZuC`{MxY*#m@H+xr6+b)7NHvmL+AG8GwID*mP z0&KpM?nrRlRMH+luPs@v+(GEe{8N%1WlH3v$QqlIax=QJG-wrF2;Flek47W1Lw2mU z@X;_na&fIFi!608r7+!f00@ce38s~-c;Mzf9fTL9&LqLB@u8sqT>6fo5~PL z>t(#_nG`}M#trpV0CbB4^kx^7jANkiQ^VWEuZ2fjrTP@hYqmx$Hr{y^hm}T_@@P$V z?sVt}d$@zMt7>I!F05)(P$H$_Pb+@wB>1}i<0L(04E%l|eTs%{TDZx6V>(Qsr-{5( zig8O%r;ZPslE9*m4+WBW4gR%2vJI&tlhlFE6%TS)mb!Shnid!b@v*;n{kOLVTzQ;q zNHalym-z_5(eYpWc#Y;Z{xT6*_y&3F8n4Sp&0jq0W#{ij&v-32r_q3C3u(`M3NXrcxa#WxD{ zJ)W=JB8M|1e#N+7Y2vq$vkwpC@tWVcj&j{8t>JCd}W~l6pMeFVhS@ ztx>{Hme=4qg*RsLhUyG|M`x&>TGO}xj@W(}_8$zmxG6KG)3o>Bf^nIsHvJV`+x`_? z?e+)Tf9Hm}kfLVn8ud{9j&=W5it~bJCNYiN#swA=e?{njBiSz={+sQ;GW?&p=Fj~8 zI|=;C)_;bt{c7Z|xNwkKyZnE0|KSAvA6MqKrQ`XBn7+(DPsLwjokBF>@53ZG3j=_m z&8^`Z=-zaNB#eK5B!^QE+!QhW?sxT|a{V0T0Fa!gVFZ?};O))dB`Z|xuM`k<4J>3N zba`~5&#!^kQ5_q95&QI?h`p#tX|0Wpo8s~y+P0Sdl{8fj2~g=&mA<>qYtKp_q;Pku zqjoq$gp&zI2Eh+^Ua4h2(LcOZ$BfMpn1T%#RVm){J?vFA6s5?iolc0v>y)v9c z!jbqRbv~`LchW=ihiRyVsm3~0R^qS0%dD8|l_BO>D+Gu9Y!xC5Q@ArSoFT}`3aI*m zoyc{NR9WU!+Sj8~x#6wg{7UTn6RHX~)XbRd&bMhrz2W0O?%e>EAxDvPK))z~C!Jbt zc5CSHnhP5|TadM#>&S}_Jp#N9z^O>8Q@f?@8VE>^?>K&{I(*+#ER7~=&uKXOG zKM?i%k}q7+>st&Hc$c=2Nz!*_rmEo0BZ#AbhaD1Wq;My?xocV`DY1#%I<&!8j7cTH`RTlLxC;wP2)6#3uZb0`Frk;&=+QJe-9M9ig^r5I=WE0WY;SOV@#AUfa}_8PN>MLo^{j z+9`QdL4byN^*FCt>WR}QkgWHDH#SzD7!DMtX%@)N`n9)z-{%6qh~A;QT>p>|ne z+ZzJOgzF3Y*mfhpOUxGnlvF*cu!5f%j1)dCOKsQYTTH{nl@8c-(*QGZ6kP$TTd5!E4W;~pqp z;5CFSvv2*IQGSDY~qn{OWjEDH{B5A62B)l>x=jXb&0xP0aSx&9Uvz{P*ga1X-bcf`SZgAtbd)AUxt-E^f$C<0Cx>xw zzJu-5D@uYss4!KgNnRN)SMYiq>=9FsQ@P36cp2k>CDH;u7c!ICn#I9J2z-jOX$Ib_ zuUsR`C{fwDo|XUAYw`9Gz*&tfV?|v#bb%&anOPOEVa7Et#)D^1;z)JNDr5CqT44Dl zWtEYNxpCt}%pMwl6i8EVDua@gX@G@jRt6$6f*1HMi)-GaYWpqwqr6pdr9WswzO+-e zlc>tj)0Dtx9t97}c?t?fr6vD^t(x#KQV2LP3)`T2k&Qj~M@jMEX&@xf#+uYb15Tt^ zk8ao@n1Jq7l3OrUUCt2w3c}#V31A-7I+Tho|_#)f+q zHcZ`-)~!6k0Mh9WmTbQi3-AD$OJ-hMmoAVAb5Yv_T>YsuPFoDqD)OWP9sisH^f z6;b$nSX%2rW?(y#6dO-B}JqqOMl972-(o(tkr%;1ZOhBF{8CkWz!bfx0l>aRtA&OJ+p;|KeX!Y9x*6J48 zmdovwg$Pgrn?s5RpNgH*2W~23oa*i>g5gh6_|QTMt1k73@PN|?aOI*>*Ft1Q1aOld zoYcfoS56(}4wAY`7xEEAlS)OSUxSFss)4Wpoo6X_f}o~Cl)j&1Ki1)QAOtJNBXxe} z55VSg(Gi;mCW>yQt^tl+0 z+`)JzVD}s)=N6Tl&o}x7(~pV)UfN`hMXGL|KaAus`oU&FokGMG{2EWF2_>JLVFi3J zft{~8O2Ja!1Cm()x1|Ss_$YRc)Lnc7Mo|TWqF{0*7 zjxdXsady{FbRk>qlyP<{aT>oPbi`J_Lm}~U(2x32_CN@Ct!-ZuJewYf5un&jQ(1nL zZO=i}($@fF(@3#FRAVh9AB+sLe{u{coQ16@fRd|fOrjB%H4t_naTeD798~+;1KgKB zrE#nS-viql!2baX4u8ukg`4`Ia1V zK;jBcWgJ8fB>z!ugQZmahL$GYvL`Q$seF&bBG%CjSj5?AadmahbG#Q%2^E>%uJ%-)fEU_P1TvD$0F-|wiWDGpFv=+3GfKjZ(mycOPR08QZLW(~xt1N_$ z!GIQ#nxh9dk?YKW#p7kx{SRfugjUYodm8M35oU{Lvujxeut9m;XD@mob%7>XsFY%J zrGb0^sNxcTXj9p6^{|a&1NrF)ZkG`lmkvbGzxW~i8PIt?29r2eN&!M#KIwAX$b#W2 znRbkiBW79#9QJR7%O2~B5eM4lw|I{2&Vp0sJ~NyTt=Y$XUN_sqlZws5%X@@2~-~pL`4&_oVofX%x*u zwg5qamIrACbQbYa!ZhO| zpnjaF%HT+2KU-D_J~4P$0um_hp{h}$iIxuawDjzOhgIO(>L=>j3D?g6Ds?aAJoRUHC5XtZEtRuDaj3;42cHWLdAnbRo5F@LRNc1fRJ_& zYKjW=Xhv91g0U(4n1~Y`7N#RwrUjo;&tn11UQY@wxxB_Yt*-t?HXepbgeGuO4DvF1|oD$EM2uN5JB!f{S6@a<72Y^;6~f01R*p*uI=WJALBbBA_MEbH;ym4Hu~8+sp1WLnk* z`?OzQY`nzMqWDLlyPIggiH@{t>&!B(U7noqt)xyFdddD!GvD2_Ps6uHUwz;!i!yWD z<@xgqkmLE|?qxW6aFJowUVk1|WGq+|171DY?&ad5uN~V2JzBZl#>ezR^@N z^3N|V3zo8{bc>pASquIVcl*L#>_F?T_B~4EW98Q0u5pX&@x9jH&T)&2h9jLpV4ov~ zIs5n-5i_p;y-oM@l$lSNT&387>>5rG|3__NK6mVkaLr!`mi89*rzV=%4+MpI=QCbP zHggj#kf-em+sdOz{`o~ho?Y)cGiWIGP9wt5!9CEasp4%naxAF*_N(7+0$zOt;xvO6 z`m=Vy=X#~S>r+-x@R{6}KPDYN?c_}+V8*~1sBX}hmG4NO;)YJp&d(n^EC>H>Dk1UL zk%XLsdxMnG#*JQuEsP3%Mj=j@Hvag&(z>N{uWw($ zPIr5iNk6~rg0HOvNAKp$-qGUzKte!CkUbgLhRl|5X@en;f{%!@CU4@uaox6s|`x}IY% zQ659OGR1!w9D7xdsMP+OfnM*B$wY0j+IQsoW@7#BQ%2=5ef@7=@wOjgS}xf(Ub$pX z@U{rv^8shK?8_b{6O~S;d%Me}NFK=m_jIcN+IU5`(SheFsgq&Oc2Xy{X%V)(d-^P9 z*2;f+r%mSAP5D;uf6&|IIGfqYYHDdf>1rlLG7ded(fiYeqwSV+ZhDHKLY$C>tydL9$vM~Nu)ZSRgU{7Fh=C!uGJRM1jGP>1QjLp&_P-VH3F!Jz4v*(`#ksZ*U35ioZZ%1d#&GZ?Tw6_ zs)e$F^ZA-BJ(os?y33>(w81kXL!zVr7R?%)ZHLP~(8((4LZG!$oAO4@eYAS(yjWj> zk~u55g5%pb#+q7`M&L$!{pxfb=2H%=@UlWWXt~I>T-%r~j1YQ-5hD9kXoX=au%=;tWqa~MJscL$^)W8RcWwxh0S#3B+ z!Ro?-(K|v*j1F{jicZ<ulPL95%5%6j3=r2f% z-C&N?wT$u49Os943=6vKjQr&uKO0x)^1=urpItBr335l`a$gq&wQL}$Di*X22K+9N zt58)6n2OnAg(AiFkkM31kfh6fzs2mA!5&O+4{tt)&G}gA4+7~kE)Hvq>3v~jf+bpW z^ZiQpSv&xNLT1hWqBOqZn_*qH%#hx75s&CX9_lSt7kR!F8Lr?vm#-ytP4{hieBd;HUl=$5dwi~GE~3g7$&_@|CM zKe+-wr=xX_^Md-*Aw8Gjlw)v6Y~KR%*V#ELyg4PE&3;*~3}@-Oi;}s^dX70(l zQt6h+uxB8{p0Twx&av0tw!l1(F?esfMV-f%-o^jb8W;z=A-Lx z6SX>pN%q~Gsn!7$b4)fEbY&8L_!FcZufs>UeK!Cp#|qMAgZn$*6{vc}>E^fjTk{*Y zWvgb-reRfx4B33LTSTdW72hkN_=Ni)VBuZ6X< z7&R#qCulbrLfxDyxfVMAT}EMXnDI`!pU>+P#Y#qCM!K`SE? zlSVT(|4ovBcdRChm_l-*e5ZiHI^in%?q48}BCdhpm*zBKhbqyC=xFp&8u{w}Xf>h* z{IRQLbcAKCkBi(bTG>PclOy42K&Ta~A}v_Ny#7dGAOtP?L$yQ)*2txq_w zBeVByRY2by99gI*^rG+j-ojN7Vwxi#=qRCGCxgJVm+^SPF=^Mw9jJNDwN%2DFFmyx zoxnOT!=FFnn4qq+{*ce~NxB}B_VU7$@J1RCxfuDue&`_epP&ktxlg;ld zRyOJc-{^67>etC_NO27S&!p$L9l=1u^U33)-!X@Etu*hcFkYV_>EaIVGY=#+h?+Mz zO{ZoL6-*?%;b%hagw4~EYX0g!S&LNbS{L**GDrUKU;RREp6(3Xo4+8#g>tw_E%L%b zyn}Y*(Z9fn#_Zj`dD9D$0{VCE%kB$J_+8aCCh4x8`ouWYf?+>08mvwlTtjJ5pmMfs zYMxFg`TMGAkfUYEuO0DWJ<>66X_}`%%6}pK)qIOZzu0fxd#k{#d6m^k(%?($udtS~ zNy1cJ8(U<=#e%P`4^B#yE^B>YXP8W}XU>j{G^+_+20Pd>*_17$?k-^+QV{lJxOcx` zl7s@z$DQ^gbGhbOu0EEE*wjdDWt_ISSLGD!(O;s&K)KshBw?4exBqIW@ z7`-pOfE}=L7rt>J&TYeT@L9(fbX(udi<4}5y6(k+(^+<(1qve`ts*z@8fmt8CreIZZ zA&`H4G1I}BqO(IUWU@c?W8W9oEyJrZcd$N2Z(>Kct#V$GHt>17a_M7gNjUYZzTJfO zZOKS+4ea05MB*2aER=&Icpk38v-ET~bqd-DW?q>h13yEs2&CxEZtILpIHLm$u z##ULAJc@|s;S`TLPrF3vVpXG*Pl>jmWv7YlUGLV72MNmlI%UQB*rtzi@* zTaf?0zNAk&1uhioD32F<$V%_!qQYGfx_gaa7uz6;*bIWE{TwTb3jkPAQc$+f2&+4u z-T#;s@pa4nvPPwtzKtTU5QSgbykDDMTL;waYOH!Xu^>tpzEqfGH=giI5@l2`M7iCF z2$6Y@R#X8jt#P$P*1Z}9IaPzhMi34Tem!Ju$xn~S%-}+#dz5pge-0KQVe%buBr~k; zd75Wk>pQm{VzKJ<@{MRwQS)pwwXoaNyqo4`I^mX$4td^)kjZT$lYA1F zhVR6;u3_1<{*|_MeC7QB!}_49)iZo1V~yC~cA72Kyoza{!Q8Atal@tPN^A=e1U6=We!#6#O-+JSYBo3|w`8+ub=1Kx4<(pgf?)BdxURhzYf zNc<)oL*Kn?S@~b;(uK+~qV;lexcx5%)v#z&1Ch>-Ppvy@?Ou5*Ah|?HYzojRhrM^! zf_}0v6Ys;nz;CLy8uQD>fy95)EfLI&P}y-n5VJEPWDg4f#}H#NvWH>DSY(lYZtbK0 zj(q-z!2bKW!oc$H@X-HuH!ze~uTDOc(0tT9E-Qq)7&9$qV;J#RSogh7P7DGDO(P`Z zc*2#?!sL|0UTXbRk;xaM)c>UlPIOTt=30L8WLW$?-wW$-tO$h{d-Xpk&6oyB-0m4U z6HTav?b3;i+-+lBF#V4{P-=GCDlpOJ>(Ri3LhjlB;ME-%*HC%w!;9oD{HWy$jk}JQ z@asB6;QYVt_HWtuHcEK`8*;q#idA#ftwHy-!j+*4?^BG)B8EeZ82ufzJU1ZxTZ`ht zveaqU3+!C`GtHppv+@`e^{;DQyV@vh=JMZP6TkRs-8piQ5`F)~N*BCdm{2QJp)lYl z@3UVPVc??3QCy72DOU9Br{$iOFoPZSmn3Yk@~0)gw-05k z!n?m*%2+7-{I{?@Hd8_iuS&h#e{+W}uw&$y*O#U})|36`gA#YuS8YmHqYo^c`KxU7 zZ(-+bLRZ}Rhm6g34)o*I0<8y&lz4^ihK-9D^JU|I{7(KuowD%aosGOAcXJJ$(i5wo zj-NLDxq0cl!_T&zd@EV8maZRG8uR*2{Q7D)lkOEskKG;G9u))Q2W4g{Zd|gqA!h~D zJU!=rpV7X`!h>Pm#2D6#Bun~j`Z}2t&wnfwB6D$5*XFv_QXkhOh064%=gS7oHHYEN znSt7T5c+veBIPOZY0iq$&2_s>G;cqSzwq-vDe46WHGlcBX`e?qCr5t|Epe=LNDa>k zcpU#aGX1{G&fNX`e;5gK&XW*s$iO%HCphxM#KM85l4Mpo%j0~T();AQ_DdPNC<`7w z+IDi|r3LWj^f;LA28mbo`61k(FZ0fiQq^3!jaMq}WnTAGS72x-xLH9$SlswH`?^U- zytFfxlZY@K9}EdK0Zy&|@Y(6wLTU(?ItRB|qwi5`vZY05<`5TBDA3lo_vuFKWFF~p znTbl}%IHqTZ(TQ3B2}2^I;UAL#KV9df%Zv4l9+@mQJN#Vuewg{STG z7eXEfe9rV$liS6vDcFG!TiZU=esfv64n5FRk}CS9Rgc}5Zo6?cK2LrTx}OtO^VHFv zEyVUEYEIEVnyRXwkM^?qhPuY|l(&31i%Qv?lAWK5$DvC|*>e5)?NGy%-_Ui`A*Z(~ zSsWpDdPe&-m6z2)DlO%&W()N{V@2%hUN5jaj&A4No;%|+O$OWfthp(0S-pdv=vWck{GFe56*{n8ueNUk z_t8UDI#ETMQuM!0B}Igxt(Fqi4<+Xp_eo;Sbl4O)KT0Fe7#kPI{GA`$LoQ-la2?+U z?&aBZ$Smo7wgZ=<|&dfZ{=5@LYnYjYx3{?X@agFPSMAQ zDd{(&LN-4|=oRnR3&G@P>q+B+FI-=2V7AuZkVyH}Bo4ihlT-8bcKqfn)QlYCuJ)5J z6Hmal4@lFi-*F^mg`GP#X1~tON&L!{z`A`fM_$4~Ac%8^~JqJ6d!KRYdyj^%ozOJ6s4i;W>FTyz~A z!TnX4uv8aaC)pZH+qFtzC+yh1KQz$LrQ3++*SC@oqN(fUV~q+uoTk5`p{62H4z6=n z>6XpbE(mKt4;<{JZC=g8<)G_V>fB%P19|eA=!b*8(@)X@_6X`w4#2>R2Z{sHhE<7_ zU+hxep4By*2iLypCB9P+7R&sO9ypk0AD7EJw;7W<^T2Ro?m3iv2;V(bA^(rO*G))? zeARQq;xwn*1)^?io{>JRxf)jwmlB$$*&F4`>Zd?D4Cs5o&P<#2d_0;k&AILdZ~x+K zMfW8_>OUNKxYX`0_Vx;?6%Vy>z39H?uhw_`;&bKER$U2M`p!2toxLMS1aoY0nZ)cvb7bF?$zVOwU%HlK90uT+SE0arhtBm;AbO<*|MY(08WUjP#D6ei%D<9lqL4 z)4`;<{hF59F)x=G?Dg$yY%X_~$ZSThJKRc0%QMjZ0}}+-)}`i}I3FhT+;;L1FgaElLikGnn4hq2S9k(QZg{%WeLecygi=dzY+&hL0N*Zj#52q&!vw?o(!Lc=`1Py+;{Mdyz01>}ris;+Uk6(p!K!12}V$5^an@$QZ z%r5e|91cH^e0iFP_d%kwS24<={@u-)gGR!BBL*-7-oy~n!S|c)V@#G2KhNk3Y#0;H zB}Z04@7Hw%mElJ@P05$e0i)~IQKX()vyTe+oxS0`02*WpQ2nuw{$7{U_nZl5ISm5e z&=@|lQ%x>J*ry?Maa6;_(%iOTL-^%SBYZ7^4@WgQ@UA4$npJsNYC`TC5ps$q@K(O^ z;SL_ca8byfuQRm0?elhxc#@#gx&WtRPY4iA)4C4loe!#{9r_xnr z^C%|mpjaN@a~0`cfJmA96?n=J>UO3Aox?*Bukv3JcZDAKVJ)&3zy69`Iph?aAZ&FB zlyq56*}Fn!sR&^2Ie~Hyj(Q#1Rd&Q`_Qb?5Whko8aDD5CCy#_ZKwCkuDs}2y2^9*@@ISOy_<$Ie@&el)y^4 zJ+Cvhbf>TH3p{oZG1+LYVvh_{QEncS->Rc*9~{JfuQRoKQ{9;ek9h@db$}fa+gFKT zMNC>hT=aFhCE2Gd9-&8W!jW!gk~yhWi+m<-L-v{WhCIKfO*-l%7FR7Br6ZDLO-Q1SQzrzIUDE;B@kHB!nmw6;57PA(>sW`9;|znLsVksJD>!rIU@;Y zUyVR&2aVa!yQvm=LoWQW2+V|!Xx^%vzGqJI<6j=RLaN6X5+@JWnD@=pf+aG0N!=uq zzhq1#-B)$y4Mb8b5YQ-ZJg`bcS?PRlI-={Aakga2M1dH8Ki2cM857igP|i5G=~vp zu+H?7D~$%4R{SHLQ4uo5u84;l)3Y_zlH0;l>n_@NSKLZlZC7;afn`dHD+^_CL2lTA zO)c=Hwb+-;o{Y9G9wU@TjNp(tARP-038j&S0pw5*qc+QrKYX`nYaPfw7(R>eq!OTm zt(orCj)VRh*@v+#FT<%or(*hb_6rk^*_ z>Vys9>$7u>Vl4=?+4iL&3*zl*{T{T~DKuM(@8f!FkUD^3Y%z zU8)HNUZ%+Nm4V%4MOBH4s{$*%NA`}!oAy5t0?dw1nk_bEAYpeFnV<|Q?a@($cw>2k zAD;tbOPP6_B`Ym$CgvWI2 zh}@oo@s7S-Q~b+-`oRPm%%Q$`2~diFDH;Tv9L(VoTnIWhfW~BBWM+HA7|voW8JF%( z$)e>#UV`u_#sMXsC}<=dErR^Sio;BlujtdA%xKKB9XHsO!_)`XKIz%@m!~Rq20O=i zKw2l~qw7$|%Y^a=Ru|7SrK5#{SE9qbjZ)3VJ-l1U{+sDvqw>Bcl*0jp?)=j5yE2-d zGm_G>v)|MrI`D56sC`)-u<*ZdPHVW{=&91+dekC(-1c_KEURqXI}?!fKhX(|$+<}=;<$tv&GiF~A|!ms4W z0})=9qrodF@8RG*YbtEPwh#K|()jKs51FCP$868OfPucKN5J8Yn`+rT9Yd0R&zqx* zz>221M-o(hGeK$tj%}-RBUm&)e zhBI~aecP@ysN*qC)$y}x&btVU^&c*$C4cwofx0cjA!Po^JeBj|rgiU!;q-&})bKt> z6JYN#zX06N-9br(Qq0UIT}o;CW?|g`lL@4pYh}nP;POh9XXx_XGJ8t z2KQ?&iIl(Ca802cR!K*cSR6mif<74Ig)J2#L0~lO$D!;;FxLB?xDvirY40Vp%(e#ad$b?f&_J_D>hlO68W>`pCY+ zh~FT`j{bR)iNnGtk*}a8NRaUw?g^k43<`#s*4SEg?-x-z1ZHr4C<{5XaS54yMVt%^ zR#oy#{JDB#6k1RWSCeD;bbZzrWaZ(QOpS!c&xsw>lD)7_jkzq>uo!PV{@9=@i;@c1 z9_djfEw8>V!b#c#C*m13ig1WLowtsPsI|G$HJMt_`S{KkflxAMnUb>&mYqN5KCcY+d&`YzLdP^_cfBrFvX2mQ5igBq zkp~Iho>-D;f!(6Nn~wj{$PR_a|5rlD|2HeT;cO#f9n9j4?yP~39?60{Ge<;T#2zLs zJOQ*O+`PRo`_k;WAX8Dh6Gt~Aq5^IzZXrsoTxD+CCDWtylsiV{rG`xrq1k8&1c8~`c~zijTJ q_phVk@azAyI(YT}+dpG}A?|I3!CvKcXV0Ndnr_*(nX=L5^8W%`F~u$b diff --git a/engine/parser/__init__.py b/engine/parser/__init__.py deleted file mode 100644 index 8a1a818..0000000 --- a/engine/parser/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# EMPTY FILE - __init__.py diff --git a/engine/parser/checks/__init__.py b/engine/parser/checks/__init__.py deleted file mode 100644 index 7bb103a..0000000 --- a/engine/parser/checks/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -""" Insert """ -# EMPTY FILE - __init__.py -from .check_brackets import check_left_and_right_brackets -from .check_brackets import UnequalBracketsExcept -from .check_for_illegal_characters import check_for_illegal_characters -from .check_for_illegal_characters import IllegalCharactersException diff --git a/engine/parser/checks/check_brackets.py b/engine/parser/checks/check_brackets.py deleted file mode 100644 index 74ce4f1..0000000 --- a/engine/parser/checks/check_brackets.py +++ /dev/null @@ -1,44 +0,0 @@ -""" Insert """ -from components.constants import LEFT_BRACKETS, RIGHT_BRACKETS -from engine_logging.logging_config import logger - - -class UnequalBracketsExcept(Exception): - """_summary_ - - Args: - Exception (_type_): _description_ - """ - pass - - -def check_left_and_right_brackets(statement): - """ - This function checks if the number of opening and closing brackets are equal. - :param statement: the given string statement - :return: Returns a True if the left and right brackets are equal - """ - logger.debug("Calling check_left_and_right_brackets(%s)...", statement) - - count = 0 - for _, char in enumerate(statement): - if char in LEFT_BRACKETS: - count += 1 - elif char in RIGHT_BRACKETS: - count -= 1 - - if count == 0: - logger.info("PASS: The number of left and right brackets are equal.") - return True - logger.exception("FAIL: Unequal number of left and right brackets. " - "Please check: count=%d", count) - raise UnequalBracketsExcept("Input statement must have an equal number " - "of opening and closing brackets") - -# todo Add to Unit Test -# check_brackets tests -# test_check_brackets = ['(',')'] -# test_check_brackets = ['(','(',')',')'] -# test_check_brackets = ['(', '(',')', '(',')', ')'] -# test_check_brackets = ['(', '(',')', '(','(',')','(',')',')', ')'] -# test_check_brackets = ['(', '(',')', '(', '(',')', ')'] # False diff --git a/engine/parser/checks/check_for_illegal_characters.py b/engine/parser/checks/check_for_illegal_characters.py deleted file mode 100644 index 5d8f4c1..0000000 --- a/engine/parser/checks/check_for_illegal_characters.py +++ /dev/null @@ -1,44 +0,0 @@ -"""_summary_ - -Raises: - IllegalCharactersException: _description_ - -Returns: - _type_: _description_ -""" -from components.regular_expression import validate_input -from components.constants import LEFT_BRACKETS, RIGHT_BRACKETS, WHITE_SPACES -from engine_logging.logging_config import logger - - -class IllegalCharactersException(Exception): - """_summary_ - - Args: - Exception (_type_): _description_ - """ - pass - - -def check_for_illegal_characters(statement): - """ - Checks for illegal characters in the given statement - :param statement: (string) - :return: returns true in case statement is clear of illegal characters and - raises an exception if not. - """ - logger.debug("Calling check_for_illegal_characters(%s)", statement) - logger.debug("******************** starting input validation *******************") - for _, char in enumerate(statement): - if char in LEFT_BRACKETS or char in RIGHT_BRACKETS or char in WHITE_SPACES: - continue - if validate_input(char): - continue - logger.exception("FAIL: String contains illegal characters, please " - "inspect: char=%s", char) - raise IllegalCharactersException("Exception: String contains illegal " - "characters.") - logger.debug("******************** finished input validation *******************") - - logger.info("PASS: There were no illegal characters found.") - return True # returns True in case no fowl characters are found diff --git a/engine/parser/parse/__init__.py b/engine/parser/parse/__init__.py deleted file mode 100644 index 8a1a818..0000000 --- a/engine/parser/parse/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# EMPTY FILE - __init__.py diff --git a/engine/parser/parse/parse_function.py b/engine/parser/parse/parse_function.py deleted file mode 100644 index 3c22785..0000000 --- a/engine/parser/parse/parse_function.py +++ /dev/null @@ -1,152 +0,0 @@ -""" Insert """ -<<<<<<<< HEAD:engine/parser/parse/parse_function.py -from parser.checks.check_brackets import check_left_and_right_brackets -from components.constants import (UNARY_CONNECTIVES, LEFT_BRACKETS, - RIGHT_BRACKETS, BINARY_CONNECTIVES) -======== -from engine_parser.checks.check_brackets import check_left_and_right_brackets -from components.constants import ( - LEFT_BRACKETS, - RIGHT_BRACKETS, - UNARY_CONNECTIVES, - BINARY_CONNECTIVES, -) ->>>>>>>> main:engine/engine_parser/parse/parse_function.py -from components.sanitizer import add_brackets_around_unary_connectives -from components.sanitizer import remove_brackets_around_variables -from components.print_details import print_details -from engine_logging.logging_config import logger - - -def parse_array(elements: list, variables: list): - """ - This takes an array of elements and variables, completes some sanitizing and - checks and then calls an internal parse function to complete the parsing. - - :param elements: Array of elements in no particular structure - :param variables: Variables as found in statement - :return: Returns an array in a tree-like structure - """ - logger.info("Starting to parse array...") - - # this removes any brackets around single variables e.g., (P), (R), etc. - elements_second = remove_brackets_around_variables(elements, variables) - logger.debug("In parse_array(): elements_second=%s", elements_second) - elements_second = add_brackets_around_unary_connectives(elements_second, variables) - logger.debug("In parse_array(): elements_second=%s", elements_second) - - # first checks if brackets are equal - logger.info("Final checks are ran before parsing concludes.") - is_parsable = check_left_and_right_brackets(elements_second) - if is_parsable: - tree_structured_array = parse(elements_second) - logger.debug("tree_structured_array=%s", tree_structured_array) - print_details("PARSE", ("Parsed Array", tree_structured_array)) - logger.info("Finished parsing array.") - return tree_structured_array - - logger.debug("**** ERROR! **** \n This should not be reached. " - "Inspect parse_array in parse_function.py") - return None - - -def parse(arr): # Private Method - """ - This acts as an internal parse function, taking an array and recursively - building a tree-like array structure. - - :param arr: Takes a new analyzed statement as an array - :return: Returns building blocks of elements recursively, forming a tree - structure - """ - logger.debug("Calling parse(%s)...", arr) - - # remove outer brackets - arr = remove_outer_brackets(arr) - logger.debug("In parse(): arr=%s", arr) - - # parse the binary/unary into left, middle, and right - temp_arr = [] - if arr[0] in UNARY_CONNECTIVES: - temp_arr.append(arr[0]) - temp_arr.append(arr[1]) - logger.debug("temp_arr=%s", temp_arr) - logger.debug("Returning with parsed list of unary connectives.") - return temp_arr - - middle, position_middle = find_connective(arr) - - # ******************* LEFT ************************ - left = [] - arr_left = arr[:position_middle] - if len(arr_left) > 1: - if arr_left[0] in LEFT_BRACKETS: - left = parse(arr_left) - elif len(arr_left) == 1: - left.append(arr_left[0]) - - # ******************* RIGHT *********************** - right = [] - arr_right = arr[position_middle + 1 :] - if len(arr_right) > 1: - if arr_right[0] in LEFT_BRACKETS: - right = parse(arr_right) - elif len(arr_right) == 1: - right.append(arr_right[0]) - - temp_arr.append(left) - temp_arr.append(middle) - temp_arr.append(right) - - logger.debug("temp_array=%s", temp_arr) - logger.debug("Returning with parsed list for binary connectives.") - return temp_arr - - -def remove_outer_brackets(array): # Private Method - """ - This removes the outer brackets around an array. - :param array: An array with redundant outer brackets - :return: Returns a new array with the outer brackets removed - """ - logger.debug("Calling remove_outer_brackets(%s)...", array) - - len_of_array = len(array) - array.pop(0) - array.pop(len_of_array - 2) - - logger.debug("array=%s", array) - logger.debug("Finished removing outer brackets.") - return array - - -def find_connective(arr): # Private Method - """ - Given an array with no outer brackets, this find the connective between - the left section and the right section. Acts as an internal function. - For example: (left) conn (right) - - :param arr: Passed array to find connective - :return: Returns a string with the connective and position in the array - """ - logger.debug("Calling find_connectives(%s)...", arr) - - count = 0 - in_bracket = False - - for i, elem in enumerate(arr): - if elem in LEFT_BRACKETS: - in_bracket = True - count += 1 - if elem in RIGHT_BRACKETS and in_bracket: - if count == 1: - in_bracket = False - count -= 1 - if elem in BINARY_CONNECTIVES and not in_bracket and count == 0: - logger.debug("In find_connective(): elem=%s, i=%d", elem, i) - logger.debug("Found connective.") - return elem, i - - logger.debug("**** ERROR! **** \n This should not be reached. " - "Inspect find_connective in parse_function.py") - return None diff --git a/engine/parser/validate/README.md b/engine/parser/validate/README.md deleted file mode 100644 index 8f3059e..0000000 --- a/engine/parser/validate/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Validation Rules - -## Syntax - -## Logic Rules - -## Connectives - diff --git a/engine/simulator/input_statements.py b/engine/simulator/input_statements.py index 6899c37..0ddfa81 100644 --- a/engine/simulator/input_statements.py +++ b/engine/simulator/input_statements.py @@ -1,41 +1,37 @@ """ Insert """ # Test cases that is used in simulate_main.py test_cases = [ - # "(P <-> (P <-> (P <-> (P <-> P))))", - # "(P ^ Q)", # valid - "(T v (P ^ Q))", # valid - # "((T v P) ^ Q)", # valid - # "(T v (P -> Q))", # valid - # "(T v (P -> Q)", # invalid - # "((T ^ Q) v (P ^ Q))", # valid - # "((T ^ T) v (P ^ Q))", # valid - # "((T ^ T) v ((P ^ (T ^ Q)) ^ Q))", # valid - # "(S ^ (R ^ Q))", # valid - # "((R ^ (Q v (!P))) <-> (((R ^ Q) v (R ^ P)) ^ T))", # valid - # "((R ^ (Q v (P))) <-> (((R ^ Q) v (R ^ P)) ^ T))", # valid - - # "R ^ (Q v !P) <-> (R ^ Q) v (R ^ P) ^ T" # valid, but binding rules - # should be applied. - # "((!R) ^ P)", # valid - # "(P v Q)", # valid - # "(!P)", # valid - # "(!(P ^ (Q <-> !Q)))", # valid - - # Add more test cases here - # "(P ^ Q ^ R)", # valid - # "(P v Q v R)", # valid - # "(P ^ !Q)", # valid - # "(P -> (Q ^ R))", # valid - # "(P -> (Q v R))", # valid - # "((P ^ Q) v (R ^ S))", # valid - # "(P <-> Q)", # valid - # "(!(!P))", # valid - - # ERROR checking!!! - # "((P v Q) ^ (!R))", # valid - # "((P -> Q) <-> ((!Q) -> (!P)))", # valid - - # Edge cases - # "(P_1 ^ P_2)", - # "(Q ^ (R_20 -> T_2))" + # "(P <-> (P <-> (P <-> (P <-> P))))", + # "(P ^ Q)", # valid + "(T v (P ^ Q))", # valid + # "((T v P) ^ Q)", # valid + # "(T v (P -> Q))", # valid + # "(T v (P -> Q)", # invalid + # "((T ^ Q) v (P ^ Q))", # valid + # "((T ^ T) v (P ^ Q))", # valid + # "((T ^ T) v ((P ^ (T ^ Q)) ^ Q))", # valid + # "(S ^ (R ^ Q))", # valid + # "((R ^ (Q v (!P))) <-> (((R ^ Q) v (R ^ P)) ^ T))", # valid + # "((R ^ (Q v (P))) <-> (((R ^ Q) v (R ^ P)) ^ T))", # valid + # "R ^ (Q v !P) <-> (R ^ Q) v (R ^ P) ^ T" # valid, but binding rules + # should be applied. + # "((!R) ^ P)", # valid + # "(P v Q)", # valid + # "(!P)", # valid + # "(!(P ^ (Q <-> !Q)))", # valid + # Add more test cases here + # "(P ^ Q ^ R)", # valid + # "(P v Q v R)", # valid + # "(P ^ !Q)", # valid + # "(P -> (Q ^ R))", # valid + # "(P -> (Q v R))", # valid + # "((P ^ Q) v (R ^ S))", # valid + # "(P <-> Q)", # valid + # "(!(!P))", # valid + # ERROR checking!!! + # "((P v Q) ^ (!R))", # valid + # "((P -> Q) <-> ((!Q) -> (!P)))", # valid + # Edge cases + # "(P_1 ^ P_2)", + # "(Q ^ (R_20 -> T_2))" ] From a2c14f2bcf749331be16e38dad8fb13a42c45d7c Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Sun, 15 Oct 2023 23:48:34 +0200 Subject: [PATCH 19/29] Removed files from merge conflicts --- engine/Components/create_conditionals.py | 67 ------------------------ engine/Components/find_variables.py | 49 ----------------- engine/Components/print_details.py | 29 ---------- engine/Components/regular_expression.py | 64 ---------------------- 4 files changed, 209 deletions(-) delete mode 100644 engine/Components/create_conditionals.py delete mode 100644 engine/Components/find_variables.py delete mode 100644 engine/Components/print_details.py delete mode 100644 engine/Components/regular_expression.py diff --git a/engine/Components/create_conditionals.py b/engine/Components/create_conditionals.py deleted file mode 100644 index 1dd831a..0000000 --- a/engine/Components/create_conditionals.py +++ /dev/null @@ -1,67 +0,0 @@ -"""_summary_ - -Returns: - _type_: _description_ -""" -from components.constants import OPEN_ARROW, DASH, CLOSE_ARROW, COND_ELEM, BICOND_ELEM, PRE_CHECK -from engine_logging.logging_config import logger - - -def create_conditionals(array_of_elements: list) -> list: - """ - Creates the conditional -> from ['-', '>'] and - biconditional <-> from ['<', '-', '>']. - - :rtype: list - :param array_of_elements: takes a statement with individual pieces in an array. - :return: Returns a new array with connectives as one element. - """ - logger.debug("Creating one-piece conditionals from single elements.") - - # Do a search for '-', and if found continue, o.w. return. - logger.debug("Searching for a '-' in array_of_elements=%s", array_of_elements) - end_of_line = False - for i, char in enumerate(array_of_elements): - if i == len(array_of_elements) - 1: - end_of_line = True - if char not in PRE_CHECK: # no symbols present - if end_of_line: - logger.debug("Search for conditionals finished and none were found, returning.") - return array_of_elements - continue - if char in PRE_CHECK: - break - - logger.debug("Conditional symbols were found in %s", array_of_elements) - conditional_symbol = False - biconditional_symbol = False - for i, char in enumerate(array_of_elements): - if i == len(array_of_elements): - break - - if char == OPEN_ARROW: # checks to see if we have a biconditional - if array_of_elements[i + 1] == DASH and array_of_elements[i + 2] == CLOSE_ARROW: - array_of_elements.pop(i) - array_of_elements.pop(i) - array_of_elements.pop(i) - array_of_elements.insert(i, BICOND_ELEM) - continue - - # if we have a conditional - if (char == DASH and array_of_elements[i + 1] == CLOSE_ARROW and - biconditional_symbol is False): # if we have a conditional - array_of_elements.pop(i) - array_of_elements.pop(i) - array_of_elements.insert(i, COND_ELEM) - continue - if char == CLOSE_ARROW and conditional_symbol is False: - continue - # other characters - if conditional_symbol is False and biconditional_symbol is False: - pass - conditional_symbol = False - biconditional_symbol = False - - logger.debug("array_of_elements=%s", array_of_elements) - logger.debug("Finished creating conditionals.") - return array_of_elements diff --git a/engine/Components/find_variables.py b/engine/Components/find_variables.py deleted file mode 100644 index 54a8ea3..0000000 --- a/engine/Components/find_variables.py +++ /dev/null @@ -1,49 +0,0 @@ -"""_summary_ - -Returns: - _type_: _description_ -""" -from engine_logging import logger -from components import VALID_BRACKETS, VALID_CONNECTIVES - - -def find_variables(statement: str) -> list: - """ - Runs through the statement to determine all the variables given in the - statement. - - :rtype: list - :param statement: given user statement - :return: Returns an array variables - """ - logger.info("Finding variables in statement...") - - # todo Check if all whitespaces are removed. If so, continue o.w. call clean_whitespaces() - - logger.debug("statement=%s", statement) - variables_array = [] - variables_string = "" - non_variable_characters = VALID_BRACKETS + VALID_CONNECTIVES - i: int - for i, char in enumerate(statement): - duplicate = False - - if char not in non_variable_characters: # if char is not a bracket or a connective - # Testing for duplicates - duplicate_int = statement.find(char, i + 1) - var_str_find = variables_string.find(char) - if len(variables_array) > 0 and duplicate_int > 0 and var_str_find >= 0: - duplicate = True - if duplicate_int == -1: # no initial or more occurrences - if var_str_find >= 0: - continue - if len(variables_array) == 0 or duplicate is False: - variables_array.append(char) - variables_string += char - elif duplicate: - continue - - logger.debug("variables_array=%s", variables_array) - logger.info("Found all variables in statement.") - logger.info("*** Variables:\t%s ***", variables_array) - return variables_array diff --git a/engine/Components/print_details.py b/engine/Components/print_details.py deleted file mode 100644 index 963ffd2..0000000 --- a/engine/Components/print_details.py +++ /dev/null @@ -1,29 +0,0 @@ -"""_summary_ -""" -from engine_logging.logging_config import logger - - -def print_details(name: str, *args): - """ - This is a generalized print function for logs. It takes a section name - followed by (name,value) tuples. For example, - - print_details("TEST", ("some_name", some_value)) where 'some_value' can be - passed. - - :param name: Required: A name for the details section, CAPITALIZED. - :param args: Optional: Any number of parameters as tuples that can be - printed - :return: - """ - logger.debug("Printing details...") - - max_length = 60 - len_name = len(name) - amount_stars = max_length - len_name - star_line = "*" * int(amount_stars/2) + " " + name.upper() + " " + "*" * int(amount_stars/2) - - logger.info(star_line) - for arg_name, arg_value in args: - logger.info("-> %s: \t%s", arg_name, arg_value) - logger.info(star_line) diff --git a/engine/Components/regular_expression.py b/engine/Components/regular_expression.py deleted file mode 100644 index c688972..0000000 --- a/engine/Components/regular_expression.py +++ /dev/null @@ -1,64 +0,0 @@ -"""_summary_ - -Returns: - _type_: _description_ -""" -import re - -from engine_logging import logger - - -def validate_input(input_string: str) -> bool: - """_summary_ - - Args: - input_string (str): _description_ - - Returns: - bool: _description_ - """ - logger.debug("Calling validate_input(%s)...", input_string) - - pattern = r"^(?:[a-zA-Z](?:_\d+)?|[a-zA-Z])$|[\^v!<>-]" - result = re.fullmatch(pattern, input_string) is not None - - logger.debug("Checked against a regex. result(is it valid?)=%s.", result) - return result - - -# todo Create Unit Test -# Test cases -test_cases = [ - "^", - "v", - "P", - "P_1", - "P_2", - "a", - "a_123", - "123", - "@", - "#", - "%", - "A", - "B_42", - "C_", # questionable - "P^Q", - "PvQ", - "P->Q", - "P<->Q", - "R_10", - "X-Y", - "Z_99", - "0", - "5", - "P@Q", - "abc", # No - "def_", - "_xyz", - "<", - ">", - "R-5", - "S^6", - "T_7", -] From 1ece7b65bbddefdf66d7313418cd121aa8eee95c Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Sun, 15 Oct 2023 23:52:08 +0200 Subject: [PATCH 20/29] Fixed linting issues. --- engine/components/find_variables.py | 2 +- frontend/lib/main.dart | 5 +++ frontend/pubspec.lock | 8 +++++ frontend/pubspec.yaml | 47 ++--------------------------- 4 files changed, 16 insertions(+), 46 deletions(-) diff --git a/engine/components/find_variables.py b/engine/components/find_variables.py index 1ac3ae6..9b71a8c 100644 --- a/engine/components/find_variables.py +++ b/engine/components/find_variables.py @@ -18,7 +18,7 @@ def find_variables(statement: str) -> list: """ logger.info("Finding variables in statement...") - # todo Check if all whitespaces are removed. If so, continue o.w. call clean_whitespaces() + # NOTE: Check if all whitespaces are removed. If so, continue o.w. call clean_whitespaces() logger.debug("statement=%s", statement) variables_array = [] diff --git a/frontend/lib/main.dart b/frontend/lib/main.dart index 86784d5..5b96f11 100644 --- a/frontend/lib/main.dart +++ b/frontend/lib/main.dart @@ -4,7 +4,9 @@ void main() { runApp(const MyApp()); } +/// class MyApp extends StatelessWidget { + /// const MyApp({super.key}); @override @@ -19,9 +21,12 @@ class MyApp extends StatelessWidget { } } +/// class MyHomePage extends StatefulWidget { + /// const MyHomePage({required this.title, super.key}); + /// final String title; @override diff --git a/frontend/pubspec.lock b/frontend/pubspec.lock index f470282..b35e7d8 100644 --- a/frontend/pubspec.lock +++ b/frontend/pubspec.lock @@ -176,6 +176,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + very_good_analysis: + dependency: "direct dev" + description: + name: very_good_analysis + sha256: "9ae7f3a3bd5764fb021b335ca28a34f040cd0ab6eec00a1b213b445dae58a4b8" + url: "https://pub.dev" + source: hosted + version: "5.1.0" web: dependency: transitive description: diff --git a/frontend/pubspec.yaml b/frontend/pubspec.yaml index a5783f3..695c9ef 100644 --- a/frontend/pubspec.yaml +++ b/frontend/pubspec.yaml @@ -7,12 +7,6 @@ version: 1.0.0+1 environment: sdk: '>=2.19.6 <3.0.0' -# Dependencies specify other packages that your package needs in order to work. -# To automatically upgrade your package dependencies to the latest versions -# consider running `flutter pub upgrade --major-versions`. Alternatively, -# dependencies can be manually updated by changing the version numbers below to -# the latest version available on pub.dev. To see which dependencies have newer -# versions available, run `flutter pub outdated`. dependencies: flutter: sdk: flutter @@ -21,20 +15,9 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - - - # The "flutter_lints" package below contains a set of recommended lints to - # encourage good coding practices. The lint set provided by the package is - # activated in the `analysis_options.yaml` file located at the root of your - # package. See that file for information about deactivating specific lint - # rules and activating additional ones. - flutter_lints: ^2.0.0 very_good_analysis: ^5.1.0 - -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. + flutter_lints: ^2.0.0 + flutter: uses-material-design: true @@ -42,29 +25,3 @@ flutter: # assets: # - images/a_dot_burr.jpeg # - images/a_dot_ham.jpeg - - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # For details regarding adding assets from package dependencies, see - # https://flutter.dev/assets-and-images/#from-packages - - # To add custom fonts to your application, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts from package dependencies, - # see https://flutter.dev/custom-fonts/#from-packages From c9ac79c0673352d37117fae7ac012949b01c4358 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Mon, 16 Oct 2023 00:07:47 +0200 Subject: [PATCH 21/29] Fixed linting issues. --- CODEOWNERS | 1 + LICENSE | 4 +- README.md | 19 ++++--- backend/README.md | 2 +- engine/.gitignore | 4 +- engine/CHANGELOG.md | 21 +++++--- engine/README.md | 60 +++++++++++----------- frontend/windows/runner/flutter_window.cpp | 5 ++ 8 files changed, 66 insertions(+), 50 deletions(-) diff --git a/CODEOWNERS b/CODEOWNERS index 636f4ab..92a3e1f 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,2 +1,3 @@ # Default Reviewer + * @skulos diff --git a/LICENSE b/LICENSE index a6dbb9d..31598cb 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ -MIT License +# MIT License -Copyright (c) 2022 Hendre Hayman and Zander Kotze +Copyright (c) 2023 Zander Kotze and Hendre Hayman Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index f6d03b2..ea61731 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,37 @@ # verbose-adventure + This is 3 Way Propositional Logic Truth Table Generator that takes an input statement and returns a processed truth table. -Add a list of things that is used for the module such as intellij, python, etc. +Add a list of things that is used for the module such as intellij, python, etc. ## Dependencies ## Recommended IDE Setup -- IntelliJ + +- IntelliJ ## Project Setup + ### Engine + The engine uses Python 3.11 in a virtual environment ### Backend -The backend uses Java JDK 17 and greater. + +The backend uses Java JDK 17 and greater. ### Frontend -The frontend uses Flutter and Dart SDK. + +The frontend uses Flutter and Dart SDK. Android Studio? ### Importing into IntelliJ -Instruction to import the project into IntelliJ +Instruction to import the project into IntelliJ ## Technology Stack + - Flutter - Python - Java -- GRPC \ No newline at end of file +- GRPC diff --git a/backend/README.md b/backend/README.md index 175b668..d0352ce 100644 --- a/backend/README.md +++ b/backend/README.md @@ -3,6 +3,6 @@ A Java HTTP server with a gRPC client to talk to the Python Backend on behalf of the Flutter Frontend ## JDK version + - 17 - 20 -- diff --git a/engine/.gitignore b/engine/.gitignore index 9a5e389..a6a8c76 100644 --- a/engine/.gitignore +++ b/engine/.gitignore @@ -1,6 +1,6 @@ # Project Debugging -/Output/*.log -/Output/*.log.* +/output/*.log +/output/*.log.* # intellij /.idea diff --git a/engine/CHANGELOG.md b/engine/CHANGELOG.md index d5dc87e..132f4e7 100644 --- a/engine/CHANGELOG.md +++ b/engine/CHANGELOG.md @@ -1,18 +1,19 @@ # Changes in code ## V0.0.7 -- Created a new Logging package to contain all logging related code. + +- Created a new Logging package to contain all logging related code. - Created logging_config using Python logging, printing logs to console and files - Created log folder and files as Output/engine.log, Output/engine.log.1, etc. - Created a rotator for log files, so that a log history can be kept. - Added logging throughout the code. -- Finished some documentation. -- Refactored code, removing redundant parts. +- Finished some documentation. +- Refactored code, removing redundant parts. - Added more TODOs for later development. -- Created a new generalized printing function in PrintDetails.py used to do -'sections of output' logging +- Created a new generalized printing function in PrintDetails.py used to do 'sections of output' logging ## v0.0.6 + - Created a constants file containing all the constants that is used in the code - Created a new file CreateElements.py, moving the array creation to it and out of CreateConditionals.py @@ -29,19 +30,23 @@ - Deleted DumpFile.py and LogicCalculator.py ## v0.0.5 + - created packages: Components, Computation, GRPCServer, Parser, Simulator, Validation - refactored exiting code and moved it around - IN PROGRESS: added metadata to existing code - tested a try-catch block with Parser.Checks -- created Simulator.SimulateServer.py to simulate the input and responses generated +- created Simulator.SimulateServer.py to simulate the input and responses generated from using the GRPCServer - Moved existing code into single files, following the SOLID principle ## v0.0.2 - v0.0.4 -- Added small changes over time. + +- Added small changes over time. ## v0.0.1 + - needs restructuring ## v0.0.0 -- initial code copied from other project \ No newline at end of file + +- initial code copied from other project diff --git a/engine/README.md b/engine/README.md index 0bb21a0..fd508c3 100644 --- a/engine/README.md +++ b/engine/README.md @@ -1,71 +1,69 @@ -# verbose-adventure Engine +# Propositional Logic Calculator -This is a Python gRPC server that will calculate the final truth column that -will be sent back -** Add some details ** - -## Propositional Logic Calculator +## verbose-adventure Engine -Random Repository - -Propositional Logic Calculator. +This is a Python gRPC server that will calculate the final truth column that +will be sent back +*Add some details* ## Description + Use LogicCalculator to do all the relevant checks and calculations +## GRPCServer Package -# GRPCServer Package To follow This package is responsible for communicating with the GRPC client on the backend side but also calling the necessary packages. -### Calling sequence for the packages with a perfect flow. +### Calling sequence for the packages with a perfect flow +## SIMULATOR Package -# SIMULATOR Package This is responsible for simulating the input that is sent from the Backend. This includes the User Input and input statements. +## PARSER Package + +### Check Errors -# PARSER Package -## Check Errors - Checking for invalid characters such as @, etc. - Checking for unequal number of opening and closing brackets. This takes a string and runs through it to determine if there are any illegal characters and also checks that the number of opening and closing brackets -are equal. +are equal. -- If the string is successful, it is sent to the next section that will do the +- If the string is successful, it is sent to the next section that will do the parsing, turning it from a string into an array. - If not, an appropriate error message is send back to the GRPC Server to handle. -## Parse String -### String to Simple Array +### Parse String + +#### String to Simple Array -### Processing Connectives in Array +#### Processing Connectives in Array -### Restructuring Array into Tree Structured Array +#### Restructuring Array into Tree Structured Array +### Validation -## Validation -### Processing Connectives +#### Processing Connectives -### Processing Brackets +#### Processing Brackets +## VALIDATOR Package -# VALIDATOR Package -## Logic Rules +### Logic Rules -## Connectives +### Connectives +## COMPUTATION Package -# COMPUTATION Package -## Propositional Rules +### Propositional Rules -## +## Flow -# Flow Start with the GRPCServer - First checks as pre-flight @@ -73,4 +71,4 @@ Start with the GRPCServer - If good, proceed: - GRPCServer Parser => checks, parse, validate - If good, proceed: -- GRPCServer Compute => compute \ No newline at end of file +- GRPCServer Compute => compute diff --git a/frontend/windows/runner/flutter_window.cpp b/frontend/windows/runner/flutter_window.cpp index b25e363..955ee30 100644 --- a/frontend/windows/runner/flutter_window.cpp +++ b/frontend/windows/runner/flutter_window.cpp @@ -31,6 +31,11 @@ bool FlutterWindow::OnCreate() { this->Show(); }); + // Flutter can complete the first frame before the "show window" callback is + // registered. The following call ensures a frame is pending to ensure the + // window is shown. It is a no-op if the first frame hasn't completed yet. + flutter_controller_->ForceRedraw(); + return true; } From 2f54d6aec428b17af915b4efbb713fbe68c453c4 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Mon, 16 Oct 2023 00:08:06 +0200 Subject: [PATCH 22/29] Moved files to docs folder. --- Discussion.jpg => docs/Discussion.jpg | Bin Flowchart.drawio.svg => docs/Flowchart.drawio.svg | 0 .../Untitled Diagram.drawio | 0 .../Untitled Diagram.drawio.svg | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename Discussion.jpg => docs/Discussion.jpg (100%) rename Flowchart.drawio.svg => docs/Flowchart.drawio.svg (100%) rename Untitled Diagram.drawio => docs/Untitled Diagram.drawio (100%) rename Untitled Diagram.drawio.svg => docs/Untitled Diagram.drawio.svg (100%) diff --git a/Discussion.jpg b/docs/Discussion.jpg similarity index 100% rename from Discussion.jpg rename to docs/Discussion.jpg diff --git a/Flowchart.drawio.svg b/docs/Flowchart.drawio.svg similarity index 100% rename from Flowchart.drawio.svg rename to docs/Flowchart.drawio.svg diff --git a/Untitled Diagram.drawio b/docs/Untitled Diagram.drawio similarity index 100% rename from Untitled Diagram.drawio rename to docs/Untitled Diagram.drawio diff --git a/Untitled Diagram.drawio.svg b/docs/Untitled Diagram.drawio.svg similarity index 100% rename from Untitled Diagram.drawio.svg rename to docs/Untitled Diagram.drawio.svg From 91ebf6c0769672e0386a43a5ffe970532cc1573e Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Mon, 16 Oct 2023 00:59:12 +0200 Subject: [PATCH 23/29] Added new jobs to workflows. --- .github/workflows/linter.yml | 129 +++++++++++++++++++++++++++++++++++ .github/workflows/pylint.yml | 3 +- README.md | 10 ++- engine/CHANGELOG.md | 8 ++- frontend/README.md | 4 ++ 5 files changed, 149 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/linter.yml diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 0000000..c6b1fe3 --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,129 @@ +--- +name: Lint Code Base + +on: + push: + branches: + [main, master] + pull_request: + branches: + [main, master] + workflow_dispatch: + +jobs: + flutter: + name: Flutter Build + runs-on: ubuntu-latest + env: + FLUTTER_VERSION: "3.13.5" + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Flutter Actions + uses: subosito/flutter-action@v2 + with: + channel: stable + flutter-version: 3.13.5 + cache: true + + - run: flutter --version + - run: flutter pub get + - run: flutter analyze + + + python: + name: Python Lint + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: 3.11 + cache: 'pip' + + - name: Install dependencies + run: | + python --version + python -m pip install --upgrade pip + pip install flake8 pylint pytest + # pip install -r requirements.txt + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + - name: Analysing the code with pylint + run: | + pylint $(git ls-files '*.py') + + - name: Lint with flake8 + run: | + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + + + java: + name: Java Build and Test + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up JDK + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: 17 + # cache: 'maven' + + # - name: Build with Maven + # run: mvn -B package --file pom.xml + + - run: | + java Main.java + # ./mvnw clean install # Assuming you have a Maven wrapper script (mvnw) in your repository + # Additional steps for testing and other build tasks as needed + + + + +# run-lint: +# name: Run Lint +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# with: +# fetch-depth: 0 + +# - name: Setup Flutter SDK +# uses: flutter-actions/setup-flutter@v2 +# with: +# channel: stable +# version: 3.13.5 +# cache: true + +# - uses: subosito/flutter-action@v2 +# with: +# channel: stable +# flutter-version: 3.13.5 +# # cache: true + +# - run: flutter --version + +# - name: Install dependencies +# run: flutter pub get + +# - name: Lint Code Base +# uses: github/super-linter@v4 +# env: +# VALIDATE_ALL_CODEBASE: false +# DEFAULT_BRANCH: main +# GITHUB_TOKEN: ${{ secrets.ACTIONS_GITHUB_TOKEN }} +# # SSH_KEY: ${{ secrets.SSH_PRIVATE_KEY }} diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index ca9f7b6..f3c2085 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -8,7 +8,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.9", "3.10", "3.11"] + # python-version: ["3.9", "3.10", "3.11"] + python-version: ["3.11"] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} diff --git a/README.md b/README.md index ea61731..b77e09c 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,17 @@ This is 3 Way Propositional Logic Truth Table Generator that takes an input statement and returns a processed truth table. -Add a list of things that is used for the module such as intellij, python, etc. +[![GitHub Super-Linter](https://github.com/ZanderCowboy/verbose-adventure/actions/workflows/linter.yml/badge.svg)](https://github.com/marketplace/actions/super-linter) + +[![style: very good analysis](https://img.shields.io/badge/style-very_good_analysis-B22C89.svg)](https://pub.dev/packages/very_good_analysis) ## Dependencies ## Recommended IDE Setup - IntelliJ +- VS Code +- Android Studio (This is optional which can be used with the UI) ## Project Setup @@ -18,11 +22,11 @@ The engine uses Python 3.11 in a virtual environment ### Backend -The backend uses Java JDK 17 and greater. +The backend uses Java JDK 17 or greater. ### Frontend -The frontend uses Flutter and Dart SDK. +The frontend uses the latest version of Flutter and Dart SDK. Android Studio? ### Importing into IntelliJ diff --git a/engine/CHANGELOG.md b/engine/CHANGELOG.md index 132f4e7..3f57eca 100644 --- a/engine/CHANGELOG.md +++ b/engine/CHANGELOG.md @@ -1,6 +1,12 @@ # Changes in code -## V0.0.7 +## v0.0.8 + +- Ran pylint and fixed all linting issues. +- Fixed imports. +- Added GitHub actions for Engine. + +## v0.0.7 - Created a new Logging package to contain all logging related code. - Created logging_config using Python logging, printing logs to console and files diff --git a/frontend/README.md b/frontend/README.md index 03d619c..032a60d 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -2,6 +2,10 @@ A new Flutter project. +[![GitHub Super-Linter](https://github.com/ZanderCowboy/verbose-adventure/actions/workflows/linter.yml/badge.svg)](https://github.com/marketplace/actions/super-linter) + +[![style: very good analysis](https://img.shields.io/badge/style-very_good_analysis-B22C89.svg)](https://pub.dev/packages/very_good_analysis) + ## Getting Started This project is a starting point for a Flutter application. From 0da75e61c742191942ad41362e193abc4de1c1a8 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Mon, 16 Oct 2023 01:08:24 +0200 Subject: [PATCH 24/29] Fixed issue for 'cd' with linter.yml --- .github/workflows/linter.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index c6b1fe3..4313a03 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -29,9 +29,11 @@ jobs: flutter-version: 3.13.5 cache: true - - run: flutter --version - - run: flutter pub get - - run: flutter analyze + - run: | + cd frontend + flutter --version + flutter pub get + flutter analyze python: @@ -51,12 +53,13 @@ jobs: - name: Install dependencies run: | + cd engine python --version python -m pip install --upgrade pip pip install flake8 pylint pytest # pip install -r requirements.txt if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - + - name: Analysing the code with pylint run: | pylint $(git ls-files '*.py') @@ -87,7 +90,8 @@ jobs: # run: mvn -B package --file pom.xml - run: | - java Main.java + cd backend + javac Main.java # ./mvnw clean install # Assuming you have a Maven wrapper script (mvnw) in your repository # Additional steps for testing and other build tasks as needed From 8dc259be6286f2e8bc26db6b227577484acd667a Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Mon, 16 Oct 2023 01:19:25 +0200 Subject: [PATCH 25/29] Fixed linting issues for workflows --- .github/workflows/linter.yml | 4 ++-- frontend/pubspec.lock | 14 +++++++------- frontend/pubspec.yaml | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 4313a03..ec1ab73 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -58,7 +58,7 @@ jobs: python -m pip install --upgrade pip pip install flake8 pylint pytest # pip install -r requirements.txt - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + # if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Analysing the code with pylint run: | @@ -90,7 +90,7 @@ jobs: # run: mvn -B package --file pom.xml - run: | - cd backend + cd backend/src javac Main.java # ./mvnw clean install # Assuming you have a Maven wrapper script (mvnw) in your repository # Additional steps for testing and other build tasks as needed diff --git a/frontend/pubspec.lock b/frontend/pubspec.lock index b35e7d8..a47d5ac 100644 --- a/frontend/pubspec.lock +++ b/frontend/pubspec.lock @@ -45,10 +45,10 @@ packages: dependency: "direct main" description: name: cupertino_icons - sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be + sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d url: "https://pub.dev" source: hosted - version: "1.0.5" + version: "1.0.6" fake_async: dependency: transitive description: @@ -63,13 +63,13 @@ packages: source: sdk version: "0.0.0" flutter_lints: - dependency: "direct dev" + dependency: "direct main" description: name: flutter_lints - sha256: "2118df84ef0c3ca93f96123a616ae8540879991b8b57af2f81b76a7ada49b2a4" + sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.0.3" flutter_test: dependency: "direct dev" description: flutter @@ -79,10 +79,10 @@ packages: dependency: transitive description: name: lints - sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593" + sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.1.1" matcher: dependency: transitive description: diff --git a/frontend/pubspec.yaml b/frontend/pubspec.yaml index 695c9ef..e03d5a1 100644 --- a/frontend/pubspec.yaml +++ b/frontend/pubspec.yaml @@ -5,18 +5,18 @@ publish_to: 'none' version: 1.0.0+1 environment: - sdk: '>=2.19.6 <3.0.0' + sdk: '>=3.0.0 <4.0.0' dependencies: + cupertino_icons: ^1.0.6 flutter: sdk: flutter - cupertino_icons: ^1.0.2 + flutter_lints: ^2.0.3 dev_dependencies: flutter_test: sdk: flutter very_good_analysis: ^5.1.0 - flutter_lints: ^2.0.0 flutter: uses-material-design: true From 6e826d788f54d73bda73e95c0b2de6561d455047 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Mon, 16 Oct 2023 02:13:50 +0200 Subject: [PATCH 26/29] Fixed linting issues and tried something with dataclasses. --- engine/computation/evaluate_statement.py | 125 +++++++++++++++++-- engine/engine_parser/parse/parse_function.py | 2 +- engine/simulator/simulate_main.py | 6 +- 3 files changed, 118 insertions(+), 15 deletions(-) diff --git a/engine/computation/evaluate_statement.py b/engine/computation/evaluate_statement.py index 57045bd..40bc7c8 100644 --- a/engine/computation/evaluate_statement.py +++ b/engine/computation/evaluate_statement.py @@ -1,4 +1,5 @@ """ Insert """ +from dataclasses import dataclass from math import log2 from computation.switch_connectives import switch_case @@ -6,6 +7,18 @@ from engine_logging.logging_config import logger +@dataclass +class Pieces: + """_summary_ + """ + variables: list + left_array: list + right_array: list + connective: str + matrix: list + counter: int + + def evaluate_array_as_tree(number_of_variables, variables_as_array, elements_in_tree): """ This is used to take an array of elements in a tree-like structure, and @@ -36,7 +49,9 @@ def evaluate_array_as_tree(number_of_variables, variables_as_array, elements_in_ final_variable_combined, returned_matrix, all_variables, - ) = evaluate_array(elements_in_tree, counter, matrix, variables_as_array) + ) = evaluate_array( + elements_in_tree, counter, matrix, variables_as_array + ) # type: ignore all_variables.append(final_variable_combined[0]) @@ -76,44 +91,132 @@ def evaluate_array(array: list, counter: int, matrix: list, variables: list): # induction case # ******************* LEFT ************************ if len(left_array) != 1: - temp_left_array = left_array + # temp_left_array = left_array counter += 1 + # array_evaluated, left_array, _, _ = evaluate_array( + # temp_left_array, counter, matrix, variables + # ) array_evaluated, left_array, _, _ = evaluate_array( - temp_left_array, counter, matrix, variables + left_array, counter, matrix, variables ) counter -= 1 variables = add_array_to_matrix(matrix, array_evaluated, variables, left_array) # ******************* RIGHT ************************ if len(right_array) != 1: - temp_right_array = right_array + # temp_right_array = right_array counter += 1 + # array_evaluated, right_array, _, _ = evaluate_array( + # temp_right_array, counter, matrix, variables + # ) array_evaluated, right_array, _, _ = evaluate_array( - temp_right_array, counter, matrix, variables + right_array, counter, matrix, variables ) counter -= 1 variables = add_array_to_matrix(matrix, array_evaluated, variables, right_array) # ******************** BASE CASE ************************ + pieces = Pieces(variables=variables, left_array=left_array, right_array=right_array, + connective=connective, matrix=matrix, counter=counter) + return base_case(pieces) + # final_variable_combined = [] + + # if len(left_array) == 1 and len(right_array) == 1: + # # find variables for left and right + # left_variable = left_array[0] + # right_variable = right_array[0] + + # left_variable_position = -1 + # right_variable_position = -1 + + # # get position for variable in list of variables as a string + # for i, item in enumerate(variables): + # if left_variable == item: + # left_variable_position = i + # break + # for i, item in enumerate(variables): + # if right_variable == item: + # right_variable_position = i + # break + + # # call matrix for each variable, and assign to temp + # temp_left = [] + # temp_right = [] + # for i in range(0, 2 ** int(log2(len(matrix)))): + # row_in_matrix = matrix[i] + # temp_left.append(row_in_matrix[left_variable_position]) + # temp_right.append(row_in_matrix[right_variable_position]) + # returned_array = switch_case(connective, temp_left, temp_right) + + # # get array item for combined variable + # if len(left_array) == 1 and len(right_array) == 1: + # temp_array = [left_array, connective, right_array] + # final_variable_combined = set_new_array_elem(temp_array) + + # if len(final_variable_combined) == 1 and counter == 0: + # # append returned_array to matrix + # for i, entry_in_return_array in enumerate(returned_array): + # matrix[i].append(entry_in_return_array) + + # logger.debug( + # "In evaluate_array(): \nreturned_array=%s, \nfinal_variable_combined=%s, " + # "\nmatrix=%s, \nvariables=%s", + # returned_array, + # final_variable_combined, + # matrix, + # variables, + # ) + # logger.debug("Evaluation of array in evaluate_array() is done.") + # return returned_array, final_variable_combined, matrix, variables + + # logger.debug( + # "**** ERROR! **** \n This should not be reached. " + # "Inspect evaluate_array in evaluate_statement.py" + # ) + # return None + + +# def base_case(variables, piece: Pieces, matrix, counter): +def base_case(piece: Pieces): + """_summary_ + + Args: + variables (_type_): _description_ + left_array (_type_): _description_ + right_array (_type_): _description_ + connective (_type_): _description_ + matrix (_type_): _description_ + counter (_type_): _description_ + + Returns: + _type_: _description_ + """ + variables = piece.variables + left_array = piece.left_array + right_array = piece.right_array + connective = piece.connective + matrix = piece.matrix + counter = piece.counter + final_variable_combined = [] if len(left_array) == 1 and len(right_array) == 1: # find variables for left and right - left_variable = left_array[0] - right_variable = right_array[0] + # left_variable = left_array[0] + # right_variable = right_array[0] left_variable_position = -1 right_variable_position = -1 # get position for variable in list of variables as a string for i, item in enumerate(variables): - if left_variable == item: + if left_array[0] == item: left_variable_position = i break for i, item in enumerate(variables): - if right_variable == item: + if right_array[0] == item: right_variable_position = i break @@ -148,8 +251,8 @@ def evaluate_array(array: list, counter: int, matrix: list, variables: list): return returned_array, final_variable_combined, matrix, variables logger.debug( - "**** ERROR! **** \n This should not be reached. " - "Inspect evaluate_array in evaluate_statement.py" + "**** ERROR! **** \n This should not be reached. " + "Inspect evaluate_array in evaluate_statement.py" ) return None diff --git a/engine/engine_parser/parse/parse_function.py b/engine/engine_parser/parse/parse_function.py index 3c7613c..80f1f9d 100644 --- a/engine/engine_parser/parse/parse_function.py +++ b/engine/engine_parser/parse/parse_function.py @@ -85,7 +85,7 @@ def parse(arr): # Private Method # ******************* RIGHT *********************** right = [] - arr_right = arr[position_middle + 1 :] + arr_right = arr[position_middle + 1:] if len(arr_right) > 1: if arr_right[0] in LEFT_BRACKETS: right = parse(arr_right) diff --git a/engine/simulator/simulate_main.py b/engine/simulator/simulate_main.py index ecc1078..6143305 100644 --- a/engine/simulator/simulate_main.py +++ b/engine/simulator/simulate_main.py @@ -35,15 +35,15 @@ def simulate_main(): ) and check_for_illegal_characters(statement): pass except UnequalBracketsExcept as ce: - logger.exception("Unequal Brackets Exception: ", ce) + logger.exception("Unequal Brackets Exception: %s", ce) continue except IllegalCharactersException as ice: - logger.exception("Illegal Characters Exception: ", ice) + logger.exception("Illegal Characters Exception: %s", ice) continue else: pass - # todo Look into why statement is sent to user_input() and then + # NOTE: Look into why statement is sent to user_input() and then # returned again logger.info( From fe7a2f4625abdeb526b01a9c222ab6155ae62f6a Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Tue, 17 Oct 2023 00:21:01 +0200 Subject: [PATCH 27/29] Fixed requirements.txt issue with linter.yml --- .github/workflows/linter.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index ec1ab73..1892127 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -57,8 +57,6 @@ jobs: python --version python -m pip install --upgrade pip pip install flake8 pylint pytest - # pip install -r requirements.txt - # if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Analysing the code with pylint run: | From cbf04ae7b271da72d95d65bbb1b305ccb9b15872 Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Tue, 17 Oct 2023 00:21:26 +0200 Subject: [PATCH 28/29] Fixed linting issues. --- engine/computation/evaluate_statement.py | 84 ++----------- .../table_matrix/display_matrix.py | 118 +++++++++++------- 2 files changed, 85 insertions(+), 117 deletions(-) diff --git a/engine/computation/evaluate_statement.py b/engine/computation/evaluate_statement.py index 40bc7c8..4ea069d 100644 --- a/engine/computation/evaluate_statement.py +++ b/engine/computation/evaluate_statement.py @@ -121,65 +121,10 @@ def evaluate_array(array: list, counter: int, matrix: list, variables: list): pieces = Pieces(variables=variables, left_array=left_array, right_array=right_array, connective=connective, matrix=matrix, counter=counter) return base_case(pieces) - # final_variable_combined = [] - - # if len(left_array) == 1 and len(right_array) == 1: - # # find variables for left and right - # left_variable = left_array[0] - # right_variable = right_array[0] - - # left_variable_position = -1 - # right_variable_position = -1 - - # # get position for variable in list of variables as a string - # for i, item in enumerate(variables): - # if left_variable == item: - # left_variable_position = i - # break - # for i, item in enumerate(variables): - # if right_variable == item: - # right_variable_position = i - # break - - # # call matrix for each variable, and assign to temp - # temp_left = [] - # temp_right = [] - # for i in range(0, 2 ** int(log2(len(matrix)))): - # row_in_matrix = matrix[i] - # temp_left.append(row_in_matrix[left_variable_position]) - # temp_right.append(row_in_matrix[right_variable_position]) - # returned_array = switch_case(connective, temp_left, temp_right) - - # # get array item for combined variable - # if len(left_array) == 1 and len(right_array) == 1: - # temp_array = [left_array, connective, right_array] - # final_variable_combined = set_new_array_elem(temp_array) - - # if len(final_variable_combined) == 1 and counter == 0: - # # append returned_array to matrix - # for i, entry_in_return_array in enumerate(returned_array): - # matrix[i].append(entry_in_return_array) - - # logger.debug( - # "In evaluate_array(): \nreturned_array=%s, \nfinal_variable_combined=%s, " - # "\nmatrix=%s, \nvariables=%s", - # returned_array, - # final_variable_combined, - # matrix, - # variables, - # ) - # logger.debug("Evaluation of array in evaluate_array() is done.") - # return returned_array, final_variable_combined, matrix, variables - - # logger.debug( - # "**** ERROR! **** \n This should not be reached. " - # "Inspect evaluate_array in evaluate_statement.py" - # ) - # return None # def base_case(variables, piece: Pieces, matrix, counter): -def base_case(piece: Pieces): +def base_case(base: Pieces): """_summary_ Args: @@ -193,29 +138,23 @@ def base_case(piece: Pieces): Returns: _type_: _description_ """ - variables = piece.variables - left_array = piece.left_array - right_array = piece.right_array - connective = piece.connective - matrix = piece.matrix - counter = piece.counter + left_array = base.left_array + right_array = base.right_array + matrix = base.matrix final_variable_combined = [] if len(left_array) == 1 and len(right_array) == 1: # find variables for left and right - # left_variable = left_array[0] - # right_variable = right_array[0] - left_variable_position = -1 right_variable_position = -1 # get position for variable in list of variables as a string - for i, item in enumerate(variables): + for i, item in enumerate(base.variables): if left_array[0] == item: left_variable_position = i break - for i, item in enumerate(variables): + for i, item in enumerate(base.variables): if right_array[0] == item: right_variable_position = i break @@ -227,14 +166,15 @@ def base_case(piece: Pieces): row_in_matrix = matrix[i] temp_left.append(row_in_matrix[left_variable_position]) temp_right.append(row_in_matrix[right_variable_position]) - returned_array = switch_case(connective, temp_left, temp_right) + + returned_array = switch_case(base.connective, temp_left, temp_right) # get array item for combined variable if len(left_array) == 1 and len(right_array) == 1: - temp_array = [left_array, connective, right_array] + temp_array = [left_array, base.connective, right_array] final_variable_combined = set_new_array_elem(temp_array) - if len(final_variable_combined) == 1 and counter == 0: + if len(final_variable_combined) == 1 and base.counter == 0: # append returned_array to matrix for i, entry_in_return_array in enumerate(returned_array): matrix[i].append(entry_in_return_array) @@ -245,10 +185,10 @@ def base_case(piece: Pieces): returned_array, final_variable_combined, matrix, - variables, + base.variables, ) logger.debug("Evaluation of array in evaluate_array() is done.") - return returned_array, final_variable_combined, matrix, variables + return returned_array, final_variable_combined, matrix, base.variables logger.debug( "**** ERROR! **** \n This should not be reached. " diff --git a/engine/computation/table_matrix/display_matrix.py b/engine/computation/table_matrix/display_matrix.py index 15f0c9a..e3f2fba 100644 --- a/engine/computation/table_matrix/display_matrix.py +++ b/engine/computation/table_matrix/display_matrix.py @@ -3,7 +3,7 @@ def display_matrix( - number_of_variables: int, returned_matrix: list, all_variables: list + nr_of_vars: int, returned_matrix: list, all_variables: list ) -> None: """_summary_ @@ -14,25 +14,18 @@ def display_matrix( """ logger.debug("Displaying matrix to console...") - auxiliary_variables = [] # Holds all the placeholder variables - for i in range(number_of_variables, len(all_variables) - 1): - auxiliary_variables.append(all_variables[i]) - number_of_aux_variables = len(auxiliary_variables) + aux_vars = [] # Holds all the placeholder variables + for i in range(nr_of_vars, len(all_variables) - 1): + aux_vars.append(all_variables[i]) + number_of_aux_variables = len(aux_vars) # prints part for variables - print("| ", end="") - for j in range(number_of_variables): - if j != number_of_variables - 1: - print(all_variables[j] + " | ", end="") - else: - print(all_variables[j] + " || ", end="") + print_variables(nr_of_vars, all_variables) # prints auxiliary variables - index_between_auxiliary_variables_and_last = number_of_variables + len( - auxiliary_variables - ) - for j in range(number_of_variables, index_between_auxiliary_variables_and_last): - if j != index_between_auxiliary_variables_and_last - 1: + idx_between_aux_vars_and_last = nr_of_vars + len(aux_vars) + for j in range(nr_of_vars, idx_between_aux_vars_and_last): + if j != idx_between_aux_vars_and_last - 1: print(all_variables[j] + " | ", end="") else: print(all_variables[j] + " || ", end="") @@ -43,7 +36,7 @@ def display_matrix( print("\n", end="") count_characters = get_number_of_spaces( - number_of_variables, number_of_aux_variables, all_variables + nr_of_vars, number_of_aux_variables, all_variables ) print("=" * count_characters) @@ -52,45 +45,36 @@ def display_matrix( print("| ", end="") # prints part for variables - for j in range(number_of_variables): - if j != number_of_variables - 1: + for j in range(nr_of_vars): + if j != nr_of_vars - 1: print(row[j] + " | ", end="") else: print(row[j] + " || ", end="") # prints auxiliary variables - index_between_auxiliary_variables_and_last = number_of_variables + len( - auxiliary_variables - ) - for j in range(number_of_variables, index_between_auxiliary_variables_and_last): - if j != index_between_auxiliary_variables_and_last - 1: - print(row[j] + " | ", end="") - else: - temp_length = len(all_variables[j]) - add_len = 0 - if temp_length % 2 == 1: # odd - add_len = temp_length / 2 + 1 - add_space = "" - for _ in range(int(add_len)): - add_space += " " - print(row[j] + add_space + " || ", end="") + print_aux_vars(nr_of_vars, aux_vars, row, all_variables) # prints last column - temp_length = len(all_variables[-1]) - add_len = 0 - if temp_length % 2 == 1: # odd - add_len = temp_length / 2 + 1 - elif temp_length % 2 == 0: # even - add_len = temp_length / 2 - add_space = "" - for _ in range(int(add_len)): - add_space += " " - print(row[-1] + add_space + " || ", end="") - print("\n", end="") + print_last_column(all_variables, row) print("=" * count_characters) +def print_variables(number_of_variables, all_variables): + """_summary_ + + Args: + number_of_variables (_type_): _description_ + all_variables (_type_): _description_ + """ + print("| ", end="") + for j in range(number_of_variables): + if j != number_of_variables - 1: + print(all_variables[j] + " | ", end="") + else: + print(all_variables[j] + " || ", end="") + + def get_number_of_spaces( number_of_variables: int, nr_auxiliary_variables: int, all_variables: list ) -> int: @@ -139,3 +123,47 @@ def get_number_of_spaces( logger.debug("total_space=%d", total_space) logger.debug("Finished calculating the total space.") return total_space + + +def print_aux_vars(number_of_variables, auxiliary_variables, row, all_variables): + """_summary_ + + Args: + number_of_variables (_type_): _description_ + auxiliary_variables (_type_): _description_ + row (_type_): _description_ + all_variables (_type_): _description_ + """ + idx_between_aux_vars_and_last = number_of_variables + len(auxiliary_variables) + for j in range(number_of_variables, idx_between_aux_vars_and_last): + if j != idx_between_aux_vars_and_last - 1: + print(row[j] + " | ", end="") + else: + temp_length = len(all_variables[j]) + add_len = 0 + if temp_length % 2 == 1: # odd + add_len = temp_length / 2 + 1 + add_space = "" + for _ in range(int(add_len)): + add_space += " " + print(row[j] + add_space + " || ", end="") + + +def print_last_column(all_variables, row): + """_summary_ + + Args: + all_variables (_type_): _description_ + row (_type_): _description_ + """ + temp_length = len(all_variables[-1]) + add_len = 0 + if temp_length % 2 == 1: # odd + add_len = temp_length / 2 + 1 + elif temp_length % 2 == 0: # even + add_len = temp_length / 2 + add_space = "" + for _ in range(int(add_len)): + add_space += " " + print(row[-1] + add_space + " || ", end="") + print("\n", end="") From f48feafde1030240beb0a8ac51d7f936556c77dc Mon Sep 17 00:00:00 2001 From: ZanderCowboy Date: Tue, 17 Oct 2023 00:38:30 +0200 Subject: [PATCH 29/29] Created requirements.txt and added dependencies. --- engine/requirements.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 engine/requirements.txt diff --git a/engine/requirements.txt b/engine/requirements.txt new file mode 100644 index 0000000..d4f6307 --- /dev/null +++ b/engine/requirements.txt @@ -0,0 +1,3 @@ +flake8==6.1.0 +pylint==3.0.1 +pytest==7.4.2 \ No newline at end of file