Skip to content
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

[Bug] Structure transformation #47

Open
maxeeem opened this issue Nov 1, 2023 · 6 comments
Open

[Bug] Structure transformation #47

maxeeem opened this issue Nov 1, 2023 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@maxeeem
Copy link
Collaborator

maxeeem commented Nov 1, 2023

Describe the bug
Structure transformation is currently not handled correctly.

See this test case from OpenNARS

        'Structure transformation

        'Bright is similar to smart. 
        <bright <-> smart>. %0.90;0.90% 

        'Is bright thing a type of smart thing?
        <[smart] --> [bright]>?

        6

        'Bright thing is a type of smart thing. 
        ''outputMustContain('<[bright] <-> [smart]>. %0.90;0.90%')
        ''outputMustContain('<[smart] --> [bright]>. %0.90;0.66%')

To Reproduce
Launch console python -m pynars.Console and type

<bright <-> smart>. %0.90;0.90%
<[smart] --> [bright]>?
6

Expected behavior
The system should be able to derive the following statements:

<[bright] <-> [smart]>. %0.90;0.90%
<[smart] --> [bright]>. %0.90;0.66%
@maxeeem maxeeem added the bug Something isn't working label Nov 1, 2023
@bowen-xu bowen-xu self-assigned this Nov 5, 2023
@bowen-xu
Copy link
Collaborator

bowen-xu commented Nov 23, 2023

The following rules are missing

<S <-> B>.
[S] 
|-
<[S] <-> [P]>.
<S <-> P>.
{S} 
|-
<{S} <-> {P}>.
<A <-> B>.
<A --> B>?
|-
<A--> B>.

@bowen-xu bowen-xu mentioned this issue Nov 23, 2023
@maxeeem
Copy link
Collaborator Author

maxeeem commented Nov 27, 2023

@bowen-xu I'm not sure additional rules are necessary. This should be handled by structural inference by applying the theorems. We already have some of them https://github.com/bowen-xu/PyNARS/blob/ebff7b965b834334b3612f5431bad20057b3f4cf/pynars/NAL/Theorems/StructuralRules.py#L979

So perhaps just need to check that all of them are in place and that control mechanism correctly applies them.

@bowen-xu
Copy link
Collaborator

@bowen-xu I'm not sure additional rules are necessary. This should be handled by structural inference by applying the theorems. We already have some of them

https://github.com/bowen-xu/PyNARS/blob/ebff7b965b834334b3612f5431bad20057b3f4cf/pynars/NAL/Theorems/StructuralRules.py#L979

So perhaps just need to check that all of them are in place and that control mechanism correctly applies them.

Yes, the functions have alreadly been there. So we just need to link them to the rule table. See in pr https://github.com/bowen-xu/PyNARS/pull/81

https://github.com/bowen-xu/PyNARS/blob/4000e823388c2dd48cc1b4e1e2e50982b4f13f26/pynars/NARS/InferenceEngine/GeneralEngine/Rules/NAL2.py#L203-L240

@maxeeem
Copy link
Collaborator Author

maxeeem commented Nov 28, 2023

@bowen-xu I guess maybe I'm a little lost and not able to see the connection between the functions. When is the theorem used? I don't see it referenced anywhere if I do a search on the whole codebase, for example equivalence_theorem4. Can you please explain how theorems and rules are connected?

And in the new rules, where does the second premise come from? [S] or {S} for example?

@bowen-xu
Copy link
Collaborator

@maxeeem I thought equivalence_theorem4 is a special case of implication_theorem5, so that it calls function _structural__bi_composition__0 when meeting {<S <-> P>., [S]} (as 3.0.4 does). In implication_theorem5 it calls function bi_composition, while in equivalence_theorem4 it can do the same thing (although currently it doesn't call bi_composition but is implemented by seperated code).

But maybe you're right; I should make the code more clear by directly calling equivalence_theorem4 for example.

@bowen-xu
Copy link
Collaborator

bowen-xu commented Nov 28, 2023

[S] is the name of concept [S]. It would be passed to the inference engine when there is no belief in the concept's beliefs-table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants