-
Notifications
You must be signed in to change notification settings - Fork 28
Fix: Done refactoring rte-helpers #361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
blackhammer116
wants to merge
4
commits into
iCog-Labs-Dev:ref/PeTTa
Choose a base branch
from
blackhammer116:ref/PeTTa
base: ref/PeTTa
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5781752
Fix: Done refactoring rte-helpers
blackhammer116 2487304
Fix: Refactored delete inconsistent handle file
blackhammer116 1daa259
Fix: Refactored Cut-unnecessary-or functions
blackhammer116 4a422c6
Fix: Refactored Cut-unnecessary-and also modified general helpers and…
blackhammer116 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,32 +14,43 @@ | |
| ;; Only AND nodes have guard sets. | ||
| ;; Example: (AND (NOT A) (NOT B) A) -> ( (NOT A) (NOT B) A) | ||
| (= (getGuardSet $exp) | ||
| (if-decons-expr-custom $exp $h $t | ||
| (if (== $h OR) | ||
| () | ||
| (getLiterals $exp)) | ||
| $exp)) | ||
| (if (== (get-metatype $exp) Expression) | ||
| (let ($h $t) (decons-atom $exp) | ||
| (eval (if-decons-expr-custom $exp $h $t | ||
| (if (== $h OR) | ||
| () | ||
| (getLiterals $exp)) | ||
| $exp)) | ||
| ) | ||
| $exp) | ||
| ) | ||
|
|
||
|
|
||
| ;; A function similar to the getGuardSet function but returns a | ||
| ;; non deterministic list instead of a collapsed atom. | ||
| ;; Example: (AND (NOT A) (NOT B) A) -> [(NOT A), (NOT B), A] | ||
| (= (getGuardSetND $exp) | ||
| (if-decons-expr-custom $exp $h $t | ||
| (if (== $h OR) | ||
| (empty) | ||
| (getLiteralsND $exp)) | ||
| $exp)) | ||
| (if (or (not (== $exp ())) (== (get-metatype $exp) Expression)) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing here. Check it out if it works with |
||
| (let* | ||
| ( | ||
| (($h $t) (decons-atom $exp)) | ||
| ($then (if (== $h OR) (empty) (getLiteralsND $exp))) | ||
| ($result (if-decons-expr-custom $exp $h $t $then $exp)) | ||
| ) | ||
| $result | ||
| ) | ||
| $exp | ||
| ) | ||
| ) | ||
|
|
||
| (= (addLiterals $exp $elements) | ||
| (let* | ||
| ( | ||
| ($op (car-atom $exp)) | ||
| ($guardSet (getLiterals $exp)) | ||
| ($newGuardSet (unionAtom $guardSet $elements)) | ||
| ($newGuardSet (union-atom $guardSet $elements)) | ||
| ($newGuardSet' (collapse (unique (superpose $newGuardSet)))) | ||
| ($updatedSubExpression (unionAtom $newGuardSet' (getChildrenExp $exp))) | ||
|
|
||
| ($updatedSubExpression (union-atom $newGuardSet' (getChildrenExp $exp))) | ||
| ($newExp (cons-atom $op $updatedSubExpression)) | ||
| ) | ||
| $newExp | ||
|
|
@@ -75,8 +86,8 @@ | |
| ( | ||
| ($op (car-atom $exp)) | ||
| ($oldChildren (getChildrenExp $exp)) | ||
| ($newChildren (concatTuple $oldChildren $children)) | ||
| ($updatedSubExpression (concatTuple (getLiterals $exp) $newChildren)) | ||
| ($newChildren (eval (concatTuple $oldChildren $children))) | ||
| ($updatedSubExpression (eval (concatTuple (getLiterals $exp) $newChildren))) | ||
| ($newExp (cons-atom $op $updatedSubExpression)) | ||
|
|
||
| ; (() (println! (OldChildren: $oldChildren))) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| !(import! &self ../../../utilities/general-helpers) | ||
| !(import! &self ../rte-helpers) | ||
| !(import! &self ../cut-unnecessary-or) | ||
|
|
||
| ;Test 01: OR expressions with one child - orCut will be applied | ||
| !(assertEqual | ||
| (orCut (AND B (OR (AND (NOT D)))) (OR (AND (NOT D)))) | ||
| ((AND B (NOT D)) () True) | ||
| ) | ||
|
|
||
| !(assertEqual | ||
| (orCut (AND C (OR A)) (OR A)) | ||
| ((AND C A) () True) | ||
| ) | ||
|
|
||
| !(assertEqual | ||
| (orCut (AND H (OR (AND A B (AND A B))) (NOT E)) (OR (AND A B (AND A B)))) | ||
| ((AND H (NOT E) A B (AND A B)) () True) | ||
| ) | ||
|
|
||
| !(assertEqual | ||
| (orCut (AND (OR (AND A (NOT A) (OR A B )))) (OR (AND A (NOT A) (OR A B )))) | ||
| ((AND A (NOT A) (OR A B)) () True) | ||
| ) | ||
|
|
||
| !(assertEqual | ||
| (orCut (AND (OR (AND A (OR A (NOT B))))) (OR (AND A (OR A (NOT B))))) | ||
| ((AND A (OR A (NOT B))) () True) | ||
| ) | ||
|
|
||
| ;Test 02:OR expression with more than one children - orCut won't be applied | ||
| !(assertEqual | ||
| (orCut (AND (OR A B)) (OR A B)) | ||
| ((AND (OR A B)) (OR A B) False) | ||
| ) | ||
| ;Test 03: AND and NOT expressions - orCut won't be applied | ||
| !(assertEqual | ||
| (orCut (OR (AND (AND A (OR A (NOT B))))) (AND (AND A (OR A (NOT B))))) | ||
| ((OR (AND (AND A (OR A (NOT B))))) (AND (AND A (OR A (NOT B)))) False) | ||
| ) | ||
| !(assertEqual | ||
| (orCut (AND (NOT (AND A (OR A (NOT B))))) (NOT (AND A (OR A (NOT B))))) | ||
| ((AND (NOT (AND A (OR A (NOT B))))) (NOT (AND A (OR A (NOT B)))) False) | ||
| ) | ||
|
|
||
| !(assertEqual (orCut (AND A B (OR C D)) ()) ((AND A B (OR C D)) () False)) |
47 changes: 0 additions & 47 deletions
47
reduct/boolean-reduct/tests/cut-unnecessary-or-testold.metta
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So check this one out.