diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..17c1465c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/dist/ +/nbproject/private/ \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt old mode 100644 new mode 100755 index d511905c..9a603146 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,339 +1,21 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. +MIT License + +Copyright (c) 2019 The OpenNARS authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100755 index 00000000..1d27ec24 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +OpenNARS Declarative Core +------------------------- +![OpenNARS_Declarative_Core_Logo](https://user-images.githubusercontent.com/8284677/53459976-6ee8bb80-3a33-11e9-8ae4-2325fc587565.png) + +Intended for people wanting to implement NAL7/8 in a different way. +Users, better go to https://github.com/opennars/opennars to enjoy a system that has full NAL1-8 implemented. + +Source Code +----------- +In nars_core_java/ and nars_gui/ are the NARS core and the Swing GUI in Java. This came out of the code of Pei Wang in nars/ directory. + +nars-dist/ contains a NARS distribution (executable, examples, web page with applet), that could be zipped for releases. + +The test suite is nars_core/src/test/java/nars/main_nogui/TestReasoning0.java . + +Build +----- +There are scripts for Linux and Windows to compile and create the executable jar: +build.sh and build.bat . + +Test +---- +The unit test suite is here. It ensures non-regression of the reasoner: +nars_core/src/test/java/nars/main_nogui/TestReasoning.java +It works classically: for each XX-in.txt in directory nars-dist/Examples, it runs NARBatch, and compares actual result with reference result XX-out.txt. +To create a new test input, add the NARS input as XX-in.txt in nars-dist/Examples , run the test suite, and move result file from temporary directory +/tmp/nars_test/XX-out.txt +into nars-dist/Example . +NOTE: +Due to the sensitivity of results regarding the implementation of the reasonner, it is difficult to write robust tests. But for pure non-regression tests, the test is usable. + + +Source Code status +------------------ +See also http://code.google.com/p/open-nars/wiki/ProjectStatus +Current version has been fully tested for single capability at a time; there may still be bugs when combining capabilities. +Jean-Marc Vanel was working on this roadmap, mainly in GUI and software engineering tasks : +- reestablish a non-regression test suite +- make an independant syntax verifyer based on a grammar parser : it will give the column & line of error (there is a Scala combinator grammar) +- separe NARS in 2 modules with a Maven build : nars_gui and nars_core_java diff --git a/build.bat b/build.bat new file mode 100755 index 00000000..51dfcf0c --- /dev/null +++ b/build.bat @@ -0,0 +1,17 @@ +REM Very simple build script + +DEL classes +mkdir classes +javac -d classes -Xlint:unchecked nars_gui\src\main\java\*\*\*.java nars_core_java\src\main\java\*\*\*.java nars_core_java\*\*\*\*.java +echo 'Main-Class: nars.main.NARS' > manifest.txt +jar cvfm NARS.jar manifest.txt -C classes . +DEL manifest.txt + +echo 'You can now launch:' +echo 'java -jar NARS.jar' +echo or +echo 'java -jar NARS.jar nars-dist/Examples/Example-NAL1-in.txt --silence 90' +echo or +echo 'java -cp NARS.jar nars.main_nogui.NARSBatch nars-dist/Examples/Example-NAL1-in.txt' +echo or +echo 'java -cp "*" nars.main_nogui.Shell' diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..bce3936b --- /dev/null +++ b/build.sh @@ -0,0 +1,23 @@ +# Very simple build script + +rm -rf classes +mkdir classes +SRC=src/main/java +SRC="" +javac -d classes -Xlint:unchecked nars_gui/$SRC/*/*/*.java \ + nars_core_java/$SRC/*/*/*.java + +# javac -d classes -Xlint:unchecked nars/*/*.java +echo 'Main-Class: nars.main.NARS' > manifest.txt +jar cvfm NARS.jar manifest.txt -C classes . +rm manifest.txt + +echo '' +echo 'You can now launch:' +echo 'java -jar NARS.jar &' +echo or +echo 'java -jar NARS.jar nars-dist/Examples/Example-NAL1-edited.txt --silence 90 &' +echo or +echo 'java -cp NARS.jar nars.main_nogui.NARSBatch nars-dist/Examples/Example-NAL1-edited.txt' +echo or +echo 'java -cp "*" nars.main_nogui.Shell' diff --git a/build.xml b/build.xml new file mode 100755 index 00000000..c619ab97 --- /dev/null +++ b/build.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + Builds, tests, and runs the project open-nars. + + + diff --git a/make_release.sh b/make_release.sh new file mode 100755 index 00000000..e1c13e76 --- /dev/null +++ b/make_release.sh @@ -0,0 +1,8 @@ +#!/bin/zsh +./build.sh +cp NARS.jar nars-dist +rm -r nars-dist/javadoc/* +javadoc -d nars-dist/javadoc nars_core_java/**/*.java nars_gui/**/*.java +# if you don't have zsh installed ( try it ! ) uncomment this : +# javadoc -d nars-dist/javadoc nars_gui/src/main/java/*/*/*.java nars_core_java/src/main/java/*/*/*.java nars_core_java/src/main/java/*/*/*/*.java +zip -r NARS.zip nars-dist diff --git a/manifest.mf b/manifest.mf new file mode 100755 index 00000000..1574df4a --- /dev/null +++ b/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/nars-dist/Examples-1.3.3/Example-NAL7-abridged.txt b/nars-dist/Examples-1.3.3/Example-NAL7-abridged.txt new file mode 100755 index 00000000..a0f0c8fb --- /dev/null +++ b/nars-dist/Examples-1.3.3/Example-NAL7-abridged.txt @@ -0,0 +1,109 @@ + +********** temporal deduction/explification + IN: <<(*, #x, room_101) --> enter> =\> <(*, #x, door_101) --> open>>. %0.9% + IN: <<(*, #y, door_101) --> open> =\> <(*, #y, key_101) --> hold>>. %0.8% +14 + OUT: <<(*,#1,room_101) --> enter> =\> <(*,#1,key_101) --> hold>>. %0.72;0.58% + OUT: <<(*,#1,key_101) --> hold> =\> <(*,#1,room_101) --> enter>>. %1.00;0.37% + +********** temporal induction/comparison + IN: <<(*, #x, door_101) --> open> =/> <(*, #x, room_101) --> enter>>. %0.9% + IN: <<(*, #y, door_101) --> open> =\> <(*, #y, key_101) --> hold>>. %0.8% +14 + OUT: <<(*,#1,key_101) --> hold> =/> <(*,#1,room_101) --> enter>>. %0.90;0.39% + OUT: <<(*,#1,room_101) --> enter> =/> <(*,#1,key_101) --> hold>>. %0.80;0.42% + OUT: <<(*,#1,room_101) --> enter> <=> <(*,#1,key_101) --> hold>>. %0.73;0.44% + +********** temporal analogy + IN: <<(*, #x, door_101) --> open> =/> <(*, #x, room_101) --> enter>>. %0.95% + IN: <<(*, #x, room_101) --> enter> <=> <(*, #x, corridor_100) --> leave>>. +13 + OUT: <<(*,#1,door_101) --> open> =/> <(*,#1,corridor_100) --> leave>>. %0.95;0.81% + +********** inference on tense + IN: <<(*, #x, key_101) --> hold> =/> <(*, #x, room_101) --> enter>>. + IN: <(*, John, key_101) --> hold>. :/: +20 + + OUT: <(*,John,room_101) --> enter>. :\: %1.00;0.81% + +********** inference on tense + IN: <<(*,#x,key_101) --> hold> =/> <(*,#x,room_101) --> enter>>. + + IN: <(*,John,room_101) --> enter>. :|: +19 + OUT: <(*,John,key_101) --> hold>. :\: %1.00;0.45% + + +********** inference on tense + IN: <<(*,John,key_101) --> hold> =/> <(*,John,room_101) --> enter>>. + + IN: <(*,John,key_101) --> hold>. :|: +2 + OUT: <(*,John,room_101) --> enter>. :\: %1.00;0.81% + +********** inference on tense + IN: <<(*,John,key_101) --> hold> =/> <(*,John,room_101) --> enter>>. %1.00;0.90% + + IN: <(*,John,room_101) --> enter>. :\: %1.00;0.90% +2 + OUT: <(*,John,key_101) --> hold>. :\: %1.00;0.45% + +********** induction on events + IN: <(*,John,door_101) --> open>. :|: +1 + + IN: <(*,John,room_101) --> enter>. :|: +1 + + OUT: <<(*,John,room_101) --> enter>=\><(*,John,door_101) --> open>>. :\: %1.00;0.45% + OUT: <<(*,John,door_101) --> open>=/><(*,John,room_101) --> enter>>. :\: %1.00;0.45% + OUT: <<(*,John,door_101) --> open><(*,John,room_101) --> enter>>. :\: %1.00;0.45% + OUT: <<(*,John,room_101) --> enter>=\><(*,John,door_101) --> open>>. %1.00;0.45% + OUT: <<(*,John,door_101) --> open>=/><(*,John,room_101) --> enter>>. %1.00;0.45% + OUT: <<(*,John,door_101) --> open><(*,John,room_101) --> enter>>. %1.00;0.45% + +********** induction on events + IN: <(*,John,door_101) --> open>. :|: +1 + + IN: <(*,John,room_101) --> enter>. :|: %0% + +1 + + OUT: <<(*,John,door_101) --> open>=/><(*,John,room_101) --> enter>>. :\: %0.00;0.45% + OUT: <<(*,John,door_101) --> open><(*,John,room_101) --> enter>>. :\: %0.00;0.45% + OUT: <<(*,John,door_101) --> open>=/><(*,John,room_101) --> enter>>. %0.00;0.45% + OUT: <<(*,John,door_101) --> open><(*,John,room_101) --> enter>>. %0.00;0.45% + +********** induction on events + IN: (/,open,_,door_101)>. :|: +1 + + IN: (/,enter,_,room_101)>. :|: +1 + + OUT: <<#1 --> (/,enter,_,room_101)>=\><#1 --> (/,open,_,door_101)>>. :\: %1.00;0.45% + OUT: <<#1 --> (/,open,_,door_101)>=/><#1 --> (/,enter,_,room_101)>>. :\: %1.00;0.45% + OUT: <<#1 --> (/,open,_,door_101)><#1 --> (/,enter,_,room_101)>>. :\: %1.00;0.45% + OUT: <<#1 --> (/,enter,_,room_101)>=\><#1 --> (/,open,_,door_101)>>. %1.00;0.45% + OUT: <<#1 --> (/,open,_,door_101)>=/><#1 --> (/,enter,_,room_101)>>. %1.00;0.45% + OUT: <<#1 --> (/,open,_,door_101)><#1 --> (/,enter,_,room_101)>>. %1.00;0.45% + +********** induction on events + IN: <(*,John,key_101) --> hold>. :|: +1 + IN: <<(*,John,door_101) --> open> =/> <(*,John,room_101) --> enter>>. :|: +1 + + OUT: <(&/,<(*,John,key_101) --> hold>,<(*,John,door_101) --> open>)=/><(*,John,room_101) --> enter>>. :\: %1.00;0.45% + OUT: <(&/,<(*,John,key_101) --> hold>,<(*,John,door_101) --> open>)=/><(*,John,room_101) --> enter>>. %1.00;0.45% + +********** updating and revision + IN: <(*,John,key_101) --> hold>. :|: +1 + IN: <(*,John,key_101) --> hold>. :|: %0% +1 + IN: <(*,John,key_101) --> hold>? :|: +1 + OUT: <(*,John,key_101) --> hold>. :\: %0.09;0.48% diff --git a/nars-dist/Examples-1.3.3/Example-NAL7-complete.txt b/nars-dist/Examples-1.3.3/Example-NAL7-complete.txt new file mode 100755 index 00000000..0fd5e97c --- /dev/null +++ b/nars-dist/Examples-1.3.3/Example-NAL7-complete.txt @@ -0,0 +1,294 @@ +********** temporal deduction/explification + IN: <<(*,#1,room_101) --> enter> =\> <(*,#1,door_101) --> open>>. %0.90;0.90% {0 : 1} + + IN: <<(*,#1,door_101) --> open> =\> <(*,#1,key_101) --> hold>>. %0.80;0.90% {0 : 2} + +3 + + OUT: < (/,enter,#1,_)> =\> <(*,#1,door_101) --> open>>. %0.90;0.90% {3 : 1} + +2 + + OUT: <<(*,#1,door_101) --> open> =\> (/,hold,#1,_)>>. %0.80;0.90% {5 : 2} + +2 + + OUT: <<(*,#1,room_101) --> enter> =\> (/,open,#1,_)>>. %0.90;0.90% {7 : 1} + +3 + + OUT: < (/,open,#1,_)> =\> <(*,#1,key_101) --> hold>>. %0.80;0.90% {10 : 2} + +3 + + OUT: < (/,enter,#1,_)> =\> <(*,#1,key_101) --> hold>>. %0.72;0.58% {13 : 2;1} + + OUT: <<(*,#1,key_101) --> hold> =\> (/,enter,#1,_)>>. %1.00;0.37% {13 : 2;1} + +1 + + OUT: <<(*,#1,room_101) --> enter> =\> <(*,#1,key_101) --> hold>>. %0.72;0.58% {14 : 2;1} + + OUT: <<(*,#1,key_101) --> hold> =\> <(*,#1,room_101) --> enter>>. %1.00;0.37% {14 : 2;1} + +********** temporal induction/comparison + IN: <<(*,#1,door_101) --> open> =/> <(*,#1,room_101) --> enter>>. %0.90;0.90% {0 : 1} + + IN: <<(*,#1,door_101) --> open> =\> <(*,#1,key_101) --> hold>>. %0.80;0.90% {0 : 2} + +3 + + OUT: <<(*,#1,door_101) --> open> =/> (/,enter,#1,_)>>. %0.90;0.90% {3 : 1} + +2 + + OUT: <<(*,#1,door_101) --> open> =\> (/,hold,#1,_)>>. %0.80;0.90% {5 : 2} + +2 + + OUT: < (/,open,#1,_)> =/> <(*,#1,room_101) --> enter>>. %0.90;0.90% {7 : 1} + +3 + + OUT: < (/,open,#1,_)> =\> <(*,#1,key_101) --> hold>>. %0.80;0.90% {10 : 2} + +3 + + OUT: <<(*,#1,key_101) --> hold> =/> (/,enter,#1,_)>>. %0.90;0.39% {13 : 2;1} + + OUT: < (/,enter,#1,_)> =/> <(*,#1,key_101) --> hold>>. %0.80;0.42% {13 : 2;1} + + OUT: < (/,enter,#1,_)> <=> <(*,#1,key_101) --> hold>>. %0.73;0.44% {13 : 2;1} + + OUT: <<(*,#1,door_101) --> open> =/> (||,<(*,#1,key_101) --> hold>, (/,enter,#1,_)>)>. %0.98;0.96% {13 : 2;1} + + OUT: <<(*,#1,door_101) --> open> =/> (&&,<(*,#1,key_101) --> hold>, (/,enter,#1,_)>)>. %0.72;0.84% {13 : 2;1} + + OUT: <<(*,#1,door_101) --> open> =/> (&&,(--,<(*,#1,key_101) --> hold>), (/,enter,#1,_)>)>. %0.18;0.89% {13 : 2;1} + + OUT: <<(*,#1,door_101) --> open> =/> (&&,(--, (/,enter,#1,_)>),<(*,#1,key_101) --> hold>)>. %0.08;0.91% {13 : 2;1} + +1 + + OUT: <<(*,#1,key_101) --> hold> =/> <(*,#1,room_101) --> enter>>. %0.90;0.39% {14 : 2;1} + + OUT: <<(*,#1,room_101) --> enter> =/> <(*,#1,key_101) --> hold>>. %0.80;0.42% {14 : 2;1} + + OUT: <<(*,#1,room_101) --> enter> <=> <(*,#1,key_101) --> hold>>. %0.73;0.44% {14 : 2;1} + + OUT: < (/,open,#1,_)> =/> (||,<(*,#1,key_101) --> hold>,<(*,#1,room_101) --> enter>)>. %0.98;0.96% {14 : 2;1} + + OUT: < (/,open,#1,_)> =/> (&&,<(*,#1,key_101) --> hold>,<(*,#1,room_101) --> enter>)>. %0.72;0.84% {14 : 2;1} + + OUT: < (/,open,#1,_)> =/> (&&,(--,<(*,#1,key_101) --> hold>),<(*,#1,room_101) --> enter>)>. %0.18;0.89% {14 : 2;1} + + OUT: < (/,open,#1,_)> =/> (&&,(--,<(*,#1,room_101) --> enter>),<(*,#1,key_101) --> hold>)>. %0.08;0.91% {14 : 2;1} + +********** temporal analogy + IN: <<(*,#1,door_101) --> open> =/> <(*,#1,room_101) --> enter>>. %0.95;0.90% {0 : 1} + + IN: <<(*,#1,corridor_100) --> leave> <=> <(*,#1,room_101) --> enter>>. %1.00;0.90% {0 : 2} + +3 + + OUT: < (/,open,#1,_)> =/> <(*,#1,room_101) --> enter>>. %0.95;0.90% {3 : 1} + +2 + + OUT: <<(*,#1,room_101) --> enter> <=> (/,leave,#1,_)>>. %1.00;0.90% {5 : 2} + +2 + + OUT: <<(*,#1,door_101) --> open> =/> (/,enter,#1,_)>>. %0.95;0.90% {7 : 1} + +3 + + OUT: <<(*,#1,corridor_100) --> leave> <=> (/,enter,#1,_)>>. %1.00;0.90% {10 : 2} + +2 + + OUT: < (/,open,#1,_)> =/> <(*,#1,corridor_100) --> leave>>. %0.95;0.81% {12 : 2;1} + +1 + + OUT: <<(*,#1,door_101) --> open> =/> <(*,#1,corridor_100) --> leave>>. %0.95;0.81% {13 : 2;1} + +********** inference on tense + IN: <<(*,#1,key_101) --> hold> =/> <(*,#1,room_101) --> enter>>. %1.00;0.90% {0 : 1} + IN: <(*,John,key_101) --> hold>. :/: %1.00;0.90% {0 : 1 : 2} +2 + OUT: <<(*,#1,key_101) --> hold> =/> (/,enter,#1,_)>>. %1.00;0.90% {2 : 1} +2 + OUT: (/,hold,_,key_101)>. :\: %1.00;0.90% {4 : 1 : 2} +2 + OUT: < (/,hold,#1,_)> =/> <(*,#1,room_101) --> enter>>. %1.00;0.90% {6 : 1} +1 + OUT: (/,enter,John,_)>. %1.00;0.43% {7 : 2;1} +4 + OUT: (/,hold,John,_)>. :\: %1.00;0.90% {11 : 1 : 2} +1 + OUT: <(*,John,room_101) --> enter>. %1.00;0.43% {12 : 2;1} +3 + OUT: (/,enter,_,room_101)>. %1.00;0.43% {15 : 2;1} +1 + OUT: (/,enter,John,_)>. %1.00;0.43% {16 : 2;1} +1 + OUT: <(/,(*,John,room_101),John,_) --> (/,enter,John,_)>. %1.00;0.38% {17 : 2;1} +3 + OUT: <(*,John,room_101) --> enter>. :\: %1.00;0.81% {20 : 2 : 1;2} +********** inference on tense + IN: <<(*,#1,key_101) --> hold> =/> <(*,#1,room_101) --> enter>>. %1.00;0.90% {0 : 1} + + IN: <(*,John,room_101) --> enter>. :|: %1.00;0.90% {0 : 0 : 2} + +2 + + OUT: < (/,hold,#1,_)> =/> <(*,#1,room_101) --> enter>>. %1.00;0.90% {2 : 1} + +2 + + OUT: (/,enter,_,room_101)>. :\: %1.00;0.90% {4 : 0 : 2} + +2 + + OUT: <<(*,#1,key_101) --> hold> =/> (/,enter,#1,_)>>. %1.00;0.90% {6 : 1} + +1 + + OUT: (/,hold,John,_)>. %1.00;0.30% {7 : 2;1} + +4 + + OUT: (/,enter,John,_)>. :\: %1.00;0.90% {11 : 0 : 2} + +1 + + OUT: <(*,John,key_101) --> hold>. %1.00;0.30% {12 : 2;1} + +4 + + OUT: (/,hold,_,key_101)>. %1.00;0.30% {16 : 2;1} + +1 + + OUT: (/,hold,John,_)>. %1.00;0.30% {17 : 2;1} + +2 + + OUT: <(*,John,key_101) --> hold>. :\: %1.00;0.45% {19 : -1 : 1;2} + +********** inference on tense + IN: <<(*,John,key_101) --> hold> =/> <(*,John,room_101) --> enter>>. %1.00;0.90% {0 : 1} + + IN: <(*,John,key_101) --> hold>. :|: %1.00;0.90% {0 : 0 : 2} + +1 + + OUT: <(*,John,room_101) --> enter>. %1.00;0.43% {1 : 2;1} + +1 + + OUT: <(*,John,room_101) --> enter>. :\: %1.00;0.81% {2 : 1 : 1;2} + +********** inference on tense + IN: <<(*,John,key_101) --> hold> =/> <(*,John,room_101) --> enter>>. %1.00;0.90% {0 : 1} + + IN: <(*,John,room_101) --> enter>. :\: %1.00;0.90% {0 : -1 : 2} + +2 + + OUT: <(*,John,key_101) --> hold>. :\: %1.00;0.45% {2 : -2 : 1;2} + +********** induction on events + IN: <(*,John,door_101) --> open>. :|: %1.00;0.90% {0 : 0 : 1} + +1 + + OUT: (/,open,_,door_101)>. :\: %1.00;0.90% {1 : 0 : 1} + + IN: <(*,John,room_101) --> enter>. :|: %1.00;0.90% {1 : 1 : 2} + +1 + + OUT: <<(*,John,room_101) --> enter> =\> <(*,John,door_101) --> open>>. :\: %1.00;0.45% {2 : 1 : 1;2} + + OUT: <<(*,John,door_101) --> open> =/> <(*,John,room_101) --> enter>>. :\: %1.00;0.45% {2 : 1 : 1;2} + + OUT: <<(*,John,door_101) --> open> <(*,John,room_101) --> enter>>. :\: %1.00;0.45% {2 : 1 : 1;2} + + OUT: (/,open,John,_)>. :\: %1.00;0.90% {2 : 0 : 1} + +********** induction on events + IN: <(*,John,door_101) --> open>. :|: %1.00;0.90% {0 : 0 : 1} + +1 + + OUT: (/,open,_,door_101)>. :\: %1.00;0.90% {1 : 0 : 1} + + IN: <(*,John,room_101) --> enter>. :|: %0.00;0.90% {1 : 1 : 2} + +1 + + OUT: <<(*,John,door_101) --> open> =/> <(*,John,room_101) --> enter>>. :\: %0.00;0.45% {2 : 1 : 1;2} + + OUT: <<(*,John,door_101) --> open> <(*,John,room_101) --> enter>>. :\: %0.00;0.45% {2 : 1 : 1;2} + + OUT: (/,open,John,_)>. :\: %1.00;0.90% {2 : 0 : 1} + +********** induction on events + IN: (/,open,_,door_101)>. :|: %1.00;0.90% {0 : 0 : 1} + +1 + + IN: (/,enter,_,room_101)>. :|: %1.00;0.90% {1 : 1 : 2} + +1 + + OUT: <<#1 --> (/,enter,_,room_101)> =\> <#1 --> (/,open,_,door_101)>>. :\: %1.00;0.45% {2 : 1 : 1;2} + + OUT: <<#1 --> (/,open,_,door_101)> =/> <#1 --> (/,enter,_,room_101)>>. :\: %1.00;0.45% {2 : 1 : 1;2} + + OUT: <<#1 --> (/,open,_,door_101)> <#1 --> (/,enter,_,room_101)>>. :\: %1.00;0.45% {2 : 1 : 1;2} + + OUT: <(*,John,door_101) --> open>. :\: %1.00;0.90% {2 : 0 : 1} + +********** induction on events + IN: <(*,John,key_101) --> hold>. :|: %1.00;0.90% {0 : 0 : 1} + +1 + + OUT: (/,hold,_,key_101)>. :\: %1.00;0.90% {1 : 0 : 1} + + IN: <<(*,John,door_101) --> open> =/> <(*,John,room_101) --> enter>>. :|: %1.00;0.90% {1 : 1 : 2} + +1 + + OUT: <(&/,<(*,John,key_101) --> hold>,<(*,John,door_101) --> open>) =/> <(*,John,room_101) --> enter>>. :\: %1.00;0.45% {2 : 1 : 1;2} + + OUT: (/,hold,John,_)>. :\: %1.00;0.90% {2 : 0 : 1} + +********** updating and revision + IN: <(*,John,key_101) --> hold>. :|: %1.00;0.90% {0 : 0 : 1} + +1 + + OUT: (/,hold,_,key_101)>. :\: %1.00;0.90% {1 : 0 : 1} + + IN: <(*,John,key_101) --> hold>. :|: %0.00;0.90% {1 : 1 : 2} + +1 + + OUT: <(*,John,key_101) --> hold>. :\: %0.09;0.91% {2 : 1 : 1;2} + + OUT: < (/,hold,_,key_101)> =/> <(*,John,key_101) --> hold>>. :\: %0.00;0.45% {2 : 0 : 2;1} + + OUT: < (/,hold,_,key_101)> <(*,John,key_101) --> hold>>. :\: %0.00;0.45% {2 : 0 : 2;1} + + IN: <(*,John,key_101) --> hold>? :|: {2 : 2 : 3} + +1 + + OUT: <(*,John,key_101) --> hold>. :\: %0.00;0.90% {1 : 1 : 2} + + OUT: <(*,John,key_101) --> hold>. :\: %0.09;0.91% {2 : 1 : 1;2} + diff --git a/nars-dist/Examples-1.3.3/Example-NAL8-1-abridged.txt b/nars-dist/Examples-1.3.3/Example-NAL8-1-abridged.txt new file mode 100755 index 00000000..a396de24 --- /dev/null +++ b/nars-dist/Examples-1.3.3/Example-NAL8-1-abridged.txt @@ -0,0 +1,177 @@ +*** [01] <{t001} --> [opened]>! +*** [02] <{t001} --> door>. +*** [03] <(&/,<(*,Self,{t002}) --> hold>,<(*,Self,{t001}) --> at>,(^open,{t001})) =/> <{t001} --> [opened]>>. +*** [04] <(*, {t002}, {t001}) --> key-of>. +*** [05] <(&|,(^pick,{t002}),<(*,Self,{t002}) --> reachable>) =/> <(*,Self,{t002}) --> hold>>. +*** [06] <(&|, <(*, #x, #y(#x)) --> on>, <(*, Self, #y(#x)) --> at>) =|> <(*, Self, #x) --> reachable>>. +*** [07] <(*, {t002}, {t003}) --> on>. :|: +*** [08] <{t003} --> desk>. +*** [09] <(^go-to,#1) =/> <(*,Self,#1) --> at>>. + +********** [01 + 03 -> 10]: + IN: <{t001} --> [opened]>! + IN: <(&/,<(*,Self,{t002}) --> hold>,<(*,Self,{t001}) --> at>,(^open,{t001}))=/><{t001} --> [opened]>>. +23 + OUT: (&/,<(*,Self,{t002}) --> hold>,<(*,Self,{t001}) --> at>,(^open,{t001}))! %1.00;0.81% + +********** [10 -> 11]: + IN: (&/,<(*,Self,{t002}) --> hold>,<(*,Self,{t001}) --> at>,(^open,{t001}))! +5 + OUT: <(*,Self,{t002}) --> hold>! %1.00;0.45% + +********** [11 + 05 -> 12]: + IN: <(*,Self,{t002}) --> hold>! + IN: <(&/,<(*,Self,{t002}) --> reachable>,(^pick,{t002}))=/><(*,Self,{t002}) --> hold>>. +5 + OUT: (&/,<(*,Self,{t002}) --> reachable>,(^pick,{t002}))! %1.00;0.81% + +********** [12 -> 13]: + IN: (&/,<(*,Self,{t002}) --> reachable>,(^pick,{t002}))! +13 + OUT: <(*,Self,{t002}) --> reachable>! %1.00;0.45% + +********** [13 + 06 -> 14]: + IN: <(*,Self,{t002}) --> reachable>! + IN: <(&|,<(*,#1,#2(#1)) --> on>,<(*,Self,#2(#1)) --> at>)=|><(*,Self,#1) --> reachable>>. +16 + OUT: (&|,<(*,{t002},#1()) --> on>,<(*,Self,#1()) --> at>)! %1.00;0.81% + +********** [07 + 14 -> 15]: + IN: <(*,{t002},{t003}) --> on>. :|: + IN: (&|,<(*,{t002},#1()) --> on>,<(*,Self,#1()) --> at>)! +25 + OUT: <(*,Self,{t003}) --> at>! %1.00;0.81% + +********** [15 + 09 -> 16]: + IN: <(*,Self,{t003}) --> at>! + IN: <(^go-to,#1)=/><(*,Self,#1) --> at>>. +19 + OUT: (^go-to,{t003})! %1.00;0.81% + +********** [16 -> 17] + IN: (^go-to,{t003})! %1.00;0.90% {0 : 1} +1 +***EXECUTE: ^go-to({t003}) + OUT: (^go-to,{t003}). :|: %1.00;0.90% + +********** [17 + 09 -> 18] + IN: (^go-to,{t003}). :|: + IN: <(^go-to,#1)=/><(*,Self,#1) --> at>>. +22 + OUT: (/,at,_,{t003})>. :\: %1.00;0.81% + +********** [18 -> 19] + IN: (/,at,_,{t003})>. :\: +6 + OUT: <{t003} --> (/,at,Self,_)>. :\: %1.00;0.90% + +********** [07 -> 20] + IN: <(*,{t002},{t003}) --> on>. :|: +6 + + OUT: <{t003} --> (/,on,{t002},_)>. :\: %1.00;0.90% + +********** [19 + 20 -> 21] + IN: <{t003} --> (/,at,Self,_)>. :\: + IN: <{t003} --> (/,on,{t002},_)>. :\: +2 + OUT: (&|,<#1() --> (/,on,{t002},_)>,<#1() --> (/,at,Self,_)>). :\: %1.00;0.81% + +********** [21 -> 22] + IN: (&|,<#1() --> (/,on,{t002},_)>,<#1() --> (/,at,Self,_)>). :\: +8 + OUT: (&|,<#1() --> (/,at,Self,_)>,<(*,{t002},#1()) --> on>). :\: %1.00;0.90% + +********** [22 -> 23] + IN: (&|,<#1() --> (/,at,Self,_)>,<(*,{t002},#1()) --> on>). :\: +4 + OUT: (&|,<(*,{t002},#1()) --> on>,<(*,Self,#1()) --> at>). :\: %1.00;0.90% + +********** [23 + 06 -> 24] + IN: (&|,<(*,{t002},#1()) --> on>,<(*,Self,#1()) --> at>). :|: + IN: <(&|,<(*,#1,#2(#1)) --> on>,<(*,Self,#2(#1)) --> at>) =|> <(*,Self,#1) --> reachable>>. +1 + OUT: <(*,Self,{t002}) --> reachable>. :\: %1.00;0.81% + +********** [24 + 12 -> 25] + IN: <(*,Self,{t002}) --> reachable>. :|: + IN: (&/,<(*,Self,{t002}) --> reachable>,(^pick,{t002}))! +6 + OUT: (^pick,{t002})! %1.00;0.81% + +********** [25 -> 26] + IN: (^pick,{t002})! %1.00;0.90% {0 : 1} +1 +***EXECUTE: ^pick({t002}) + OUT: (^pick,{t002}). :|: %1.00;0.90% + +********** [24 + 05 -> 27] + IN: <(*,Self,{t002}) --> reachable>. :|: + IN: <(&/,<(*,Self,{t002}) --> reachable>,(^pick,{t002}))=/><(*,Self,{t002}) --> hold>>. +1 + OUT: <(^pick,{t002})=/><(*,Self,{t002}) --> hold>>. :\: %1.00;0.81% + +********** [26 + 27 -> 28] + IN: (^pick,{t002}). :\: + IN: <(^pick,{t002})=/><(*,Self,{t002}) --> hold>>. :\: +1 + OUT: <(*,Self,{t002}) --> hold>. :\: %1.00;0.81% + +********** [28 + 10 -> 29] + IN: <(*,Self,{t002}) --> hold>. :|: + IN: (&/,<(*,Self,{t002}) --> hold>,<(*,Self,{t001}) --> at>,(^open,{t001}))! +7 + OUT: (&/,<(*,Self,{t001}) --> at>,(^open,{t001}))! %1.00;0.81% + +********** [03 + 28 -> 30] + IN: <(&/,<(*,Self,{t002}) --> hold>,<(*,Self,{t001}) --> at>,(^open,{t001}))=/><{t001} --> [opened]>>. %1.00;0.90% {0 : 1} + IN: <(*,Self,{t002}) --> hold>. :|: +2 + OUT: <(&/,<(*,Self,{t001}) --> at>,(^open,{t001}))=/><{t001} --> [opened]>>. :\: %1.00;0.81% + +********** [29 -> 31] + IN: (&/,<(*,Self,{t001}) --> at>,(^open,{t001}))! +13 + OUT: <(*,Self,{t001}) --> at>! %1.00;0.45% + +********** [31 + 09 -> 32] + IN: <(*,Self,{t001}) --> at>! + IN: <(^go-to,#1)=/><(*,Self,#1) --> at>>. +19 + OUT: (^go-to,{t001})! %1.00;0.81% + +********** [32 -> 33] + IN: (^go-to,{t001})! +1 +***EXECUTE: ^go-to({t001}) + OUT: (^go-to,{t001}). :|: %1.00;0.90% + +********** [33 + 09 -> 34] + IN: (^go-to,{t001}). :\: + IN: <(^go-to,#1)=/><(*,Self,#1) --> at>>. +12 + OUT: <(*,Self,{t001}) --> at>. :\: %1.00;0.43% + +********** [34 + 30 -> 35] + IN: <(*,Self,{t001}) --> at>. :|: + IN: <(&/,<(*,Self,{t001}) --> at>,(^open,{t001}))=/><{t001} --> [opened]>>. :|: +3 + OUT: <(^open,{t001})=/><{t001} --> [opened]>>. :\: %1.00;0.81% + +********** [34 + 29 -> 36] + IN: <(*,Self,{t001}) --> at>. :|: + IN: (&/,<(*,Self,{t001}) --> at>,(^open,{t001}))! +6 + OUT: (^open,{t001})! %1.00;0.81% + +********** [36 -> 37] + IN: (^open,{t001})! +1 +***EXECUTE: ^open({t001}) + OUT: (^open,{t001}). :|: %1.00;0.90% + +********** [35 + 37 -> 38] + IN: <(^open,{t001})=/><{t001} --> [opened]>>. :|: + IN: (^open,{t001}). :|: +1 + OUT: <{t001} --> [opened]>. :|: %1.00;0.81% diff --git a/nars-dist/Examples-1.3.3/Example-NAL8-1-complete.txt b/nars-dist/Examples-1.3.3/Example-NAL8-1-complete.txt new file mode 100755 index 00000000..84575d8a --- /dev/null +++ b/nars-dist/Examples-1.3.3/Example-NAL8-1-complete.txt @@ -0,0 +1,589 @@ +*** [01] <{t001} --> [opened]>! +*** [02] <{t001} --> door>. +*** [03] <(&|, <(*, Self, {t002}) --> hold>, <(*, Self, {t001}) --> at>, (^open, {t001})) =/> <{t001} --> [opened]>>. +*** [04] <(*, {t002}, {t001}) --> key-of>. +*** [05] <(&|, <(*, Self, {t002}) --> reachable>, (^pick, {t002})) =/> <(*, Self, {t002}) --> hold>>. +*** [06] <(&|, <(*, #x, #y(#x)) --> on>, <(*, Self, #y(#x)) --> at>) =|> <(*, Self, #x) --> reachable>>. +*** [07] <(*, {t002}, {t003}) --> on>. :|: +*** [08] <{t003} --> desk>. +*** [09] <(^go-to, #x) =/> <(*, Self, #x) --> at>>. +********** [01 + 03 -> 10]: + IN: <{t001} --> [opened]>! %1.00;0.90% {0 : 1} + + IN: <(&/,<(*,Self,{t002}) --> hold>,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^open>) =/> <{t001} --> [opened]>>. %1.00;0.90% {0 : 2} + +1 + + OUT: <{t001} --> [opened]>? :|: {1 : 1 : 3} + +2 + + OUT: <(&/, (/,hold,_,{t002})>,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^open>) ==> <{t001} --> [opened]>>. %1.00;0.90% {3 : 2} + +2 + + OUT: <(&/,<(*,Self,{t002}) --> hold>, (/,at,_,{t001})>,<(*,{t001}) --> ^open>) ==> <{t001} --> [opened]>>. %1.00;0.90% {5 : 2} + +6 + + OUT: <(&/,<{t002} --> (/,hold,Self,_)>,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^open>) ==> <{t001} --> [opened]>>. %1.00;0.90% {11 : 2} + +8 + + OUT: (&/,<(*,Self,{t002}) --> hold>,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^open>)! %1.00;0.81% {19 : 2;1} + +********** [10 -> 11]: + IN: (&/,<(*,Self,{t002}) --> hold>,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^open>)! %1.00;0.90% {0 : 1} + +1 + + OUT: (&/,<(*,Self,{t002}) --> hold>,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^open>)? :|: {1 : 1 : 2} + +4 + + OUT: <(*,Self,{t002}) --> hold>! %1.00;0.45% {5 : 1} + +********** [11 + 05 -> 12]: + IN: <(*,Self,{t002}) --> hold>! %1.00;0.90% {0 : 1} + + IN: <(&/,<(*,Self,{t002}) --> reachable>,<(*,{t002}) --> ^pick>) =/> <(*,Self,{t002}) --> hold>>. %1.00;0.90% {0 : 2} + +1 + + OUT: <(*,Self,{t002}) --> hold>? :|: {1 : 1 : 3} + + OUT: (/,hold,_,{t002})>! %1.00;0.90% {1 : 1} + +1 + + OUT: (/,hold,_,{t002})>? :|: {2 : 2 : 4} + +1 + + OUT: (&/,<(*,Self,{t002}) --> reachable>,<(*,{t002}) --> ^pick>)? :\: {3 : 0 : 2;3} + +2 + + OUT: (&/,<(*,Self,{t002}) --> reachable>,<(*,{t002}) --> ^pick>)! %1.00;0.81% {5 : 2;1} + +********** [12 -> 13]: + IN: (&/,<(*,Self,{t002}) --> reachable>,<(*,{t002}) --> ^pick>)! %1.00;0.90% {0 : 1} + +1 + + OUT: (&/,<(*,Self,{t002}) --> reachable>,<(*,{t002}) --> ^pick>)? :|: {1 : 1 : 2} + +1 + + OUT: <(*,Self,{t002}) --> reachable>? :\: {2 : 1 : 2} + +2 + + OUT: (&/,<{t002} --> (/,reachable,Self,_)>,<(*,{t002}) --> ^pick>)! %1.00;0.90% {4 : 1} + +1 + + OUT: (&/,<{t002} --> (/,reachable,Self,_)>,<(*,{t002}) --> ^pick>)? :|: {5 : 5 : 3} + +1 + + OUT: (&/, (/,reachable,_,{t002})>,<(*,{t002}) --> ^pick>)! %1.00;0.90% {6 : 1} + +1 + + OUT: (&/, (/,reachable,_,{t002})>,<(*,{t002}) --> ^pick>)? :|: {7 : 7 : 4} + +5 + + OUT: (&/, (/,reachable,_,{t002})>,<(*,{t002}) --> ^pick>)? :\: {12 : 1 : 2} + +1 + + OUT: <(*,Self,{t002}) --> reachable>! %1.00;0.45% {13 : 1} + +********** [13 + 06 -> 14]: + IN: <(*,Self,{t002}) --> reachable>! %1.00;0.90% {0 : 1} + + IN: <(&|,<(*,#1,#2(#1)) --> on>,<(*,Self,#2(#1)) --> at>) =|> <(*,Self,#1) --> reachable>>. %1.00;0.90% {0 : 2} + +1 + + OUT: <(*,Self,{t002}) --> reachable>? :|: {1 : 1 : 3} + +1 + + OUT: <{t002} --> (/,reachable,Self,_)>! %1.00;0.90% {2 : 1} + +1 + + OUT: <{t002} --> (/,reachable,Self,_)>? :|: {3 : 3 : 4} + + OUT: (/,reachable,_,{t002})>! %1.00;0.90% {3 : 1} + +1 + + OUT: (/,reachable,_,{t002})>? :|: {4 : 4 : 5} + +5 + + OUT: <(*,Self,{t002}) --> reachable>? :\: {9 : 3 : 4} + +1 + + OUT: (/,reachable,_,{t002})>? :\: {10 : 1 : 3} + +6 + + OUT: (&|,<(*,{t002},#1()) --> on>,<(*,Self,#1()) --> at>)! %1.00;0.81% {16 : 2;1} + +********** [07 + 14 -> 15]: + IN: <(*,{t002},{t003}) --> on>. :|: %1.00;0.90% {0 : 0 : 1} + + IN: (&|,<(*,{t002},#1()) --> on>,<(*,Self,#1()) --> at>)! %1.00;0.90% {0 : 2} + +1 + + OUT: (&|,<(*,{t002},#1()) --> on>,<(*,Self,#1()) --> at>)? :|: {1 : 1 : 3} + + OUT: (&|,<(*,{t002},#1()) --> on>, (/,at,_,#1())>)! %1.00;0.90% {1 : 2} + +1 + + OUT: (&|,<(*,{t002},#1()) --> on>, (/,at,_,#1())>)? :|: {2 : 2 : 4} + +4 + + OUT: (&|,<(*,Self,#1()) --> at>,<{t002} --> (/,on,_,#1())>)! %1.00;0.90% {6 : 2} + +1 + + OUT: (&|,<(*,Self,#1()) --> at>,<{t002} --> (/,on,_,#1())>)? :|: {7 : 7 : 5} + +4 + + OUT: <{t003} --> (/,on,{t002},_)>. :\: %1.00;0.90% {11 : 0 : 1} + +4 + + OUT: (&|,<(*,{t002},#1()) --> on>, (/,at,_,#1())>)? :\: {15 : 1 : 3} + +2 + + OUT: <(*,Self,{t003}) --> at>? :\: {17 : 1 : 1;3} + +2 + + OUT: (/,at,_,{t003})>? :\: {19 : 1 : 1;3} + +2 + + OUT: <{t003} --> (/,at,Self,_)>? :\: {21 : 1 : 1;3} + +2 + + OUT: (&|,<(*,Self,#1()) --> at>,<{t002} --> (/,on,_,#1())>)? :\: {23 : 1 : 3} + +2 + + OUT: <(*,Self,{t003}) --> at>! %1.00;0.81% {25 : 1;2} + +********** [15 + 09 -> 16]: + IN: <(*,Self,{t003}) --> at>! %1.00;0.90% {0 : 1} + + IN: <<(*,#1) --> ^go-to> =/> <(*,Self,#1) --> at>>. %1.00;0.90% {0 : 2} + +1 + + OUT: <(*,Self,{t003}) --> at>? :|: {1 : 1 : 3} + + OUT: <<(*,#1) --> ^go-to> =/> (/,at,_,#1)>>. %1.00;0.90% {1 : 2} + +5 + + OUT: <{t003} --> (/,at,Self,_)>! %1.00;0.90% {6 : 1} + +1 + + OUT: <{t003} --> (/,at,Self,_)>? :|: {7 : 7 : 4} + +5 + + OUT: <(*,Self,{t003}) --> at>? :\: {12 : 7 : 4} + +1 + + OUT: (/,at,_,{t003})>! %1.00;0.90% {13 : 1} + +1 + + OUT: (/,at,_,{t003})>? :|: {14 : 14 : 5} + +4 + + OUT: (/,at,_,{t003})>? :\: {18 : 1 : 3} + +1 + + OUT: <(*,{t003}) --> ^go-to>! %1.00;0.81% {19 : 2;1} + +********** [16 -> 17] + IN: <(*,{t003}) --> ^go-to>! %1.00;0.90% {0 : 1} + +1 + + OUT: <(*,{t003}) --> ^go-to>. :|: %1.00;0.90% {1 : 1 : 2} + +********** [17 + 09 -> 18] + IN: <(*,{t003}) --> ^go-to>. :|: %1.00;0.90% {0 : 0 : 1} + + IN: <<(*,#1) --> ^go-to> =/> <(*,Self,#1) --> at>>. %1.00;0.90% {0 : 2} + +2 + + OUT: <{t003} --> (/,^go-to,_)>. :\: %1.00;0.90% {2 : 0 : 1} + +5 + + OUT: <(/,(*,{t003}),_) --> (/,^go-to,_)>. :\: %1.00;0.90% {7 : 0 : 1} + +1 + + OUT: <<(*,#1) --> ^go-to> =/> (/,at,_,#1)>>. %1.00;0.90% {8 : 2} + +4 + + OUT: <(*,Self,{t003}) --> at>. %1.00;0.43% {12 : 1;2} + +5 + + OUT: (/,at,_,{t003})>. %1.00;0.43% {17 : 1;2} + +1 + + OUT: (/,at,_,{t003})>. %1.00;0.43% {18 : 1;2} + +3 + + OUT: <{t003} --> (/,at,Self,_)>. %1.00;0.43% {21 : 1;2} + +1 + + OUT: (/,at,_,{t003})>. :\: %1.00;0.81% {22 : 1 : 2;1} + +********** [18 -> 19] + IN: (/,at,_,{t003})>. :\: %1.00;0.90% {0 : -1 : 1} + +3 + + OUT: <(*,Self,{t003}) --> at>. :\: %1.00;0.90% {3 : -1 : 1} + +3 + + OUT: <{t003} --> (/,at,Self,_)>. :\: %1.00;0.90% {6 : -1 : 1} + +********** [07 -> 20] + IN: <(*,{t002},{t003}) --> on>. :|: %1.00;0.90% {0 : 0 : 1} + +5 + + OUT: <{t002} --> (/,on,_,{t003})>. :\: %1.00;0.90% {5 : 0 : 1} + +1 + + OUT: <{t003} --> (/,on,{t002},_)>. :\: %1.00;0.90% {6 : 0 : 1} + +********** [19 + 20 -> 21] + IN: <{t003} --> (/,at,Self,_)>. :\: %1.00;0.90% {0 : -1 : 1} + + IN: <{t003} --> (/,on,{t002},_)>. :\: %1.00;0.90% {0 : -1 : 2} + +1 + + OUT: <<#1 --> (/,on,{t002},_)> =|> <#1 --> (/,at,Self,_)>>. :\: %1.00;0.45% {1 : -1 : 1;2} + + OUT: <<#1 --> (/,at,Self,_)> =|> <#1 --> (/,on,{t002},_)>>. :\: %1.00;0.45% {1 : -1 : 1;2} + + OUT: <<#1 --> (/,on,{t002},_)> <|> <#1 --> (/,at,Self,_)>>. :\: %1.00;0.45% {1 : -1 : 1;2} + +1 + + OUT: <(/,on,{t002},_) --> (/,at,Self,_)>. :\: %1.00;0.45% {2 : -1 : 2;1} + + OUT: <(/,at,Self,_) --> (/,on,{t002},_)>. :\: %1.00;0.45% {2 : -1 : 2;1} + + OUT: <(/,on,{t002},_) <-> (/,at,Self,_)>. :\: %1.00;0.45% {2 : -1 : 2;1} + + OUT: <<#1 --> (/,on,{t002},_)> =|> <#1 --> (/,at,Self,_)>>. :\: %1.00;0.45% {2 : -1 : 2;1} + + OUT: <<#1 --> (/,at,Self,_)> =|> <#1 --> (/,on,{t002},_)>>. :\: %1.00;0.45% {2 : -1 : 2;1} + + OUT: <<#1 --> (/,on,{t002},_)> <|> <#1 --> (/,at,Self,_)>>. :\: %1.00;0.45% {2 : -1 : 2;1} + + OUT: <{t003} --> (|,(/,on,{t002},_),(/,at,Self,_))>. :\: %1.00;0.99% {2 : -1 : 2;1} + + OUT: <{t003} --> (&,(/,on,{t002},_),(/,at,Self,_))>. :\: %1.00;0.81% {2 : -1 : 2;1} + + OUT: <{t003} --> (-,(/,at,Self,_),(/,on,{t002},_))>. :\: %0.00;0.90% {2 : -1 : 2;1} + + OUT: <{t003} --> (-,(/,on,{t002},_),(/,at,Self,_))>. :\: %0.00;0.90% {2 : -1 : 2;1} + + OUT: (&|,<#1() --> (/,on,{t002},_)>,<#1() --> (/,at,Self,_)>). :\: %1.00;0.81% {2 : -1 : 2;1} + +********** [21 -> 22] + IN: (&|,<#1() --> (/,on,{t002},_)>,<#1() --> (/,at,Self,_)>). :\: %1.00;0.90% {0 : -1 : 1} + +6 + + OUT: (&|,<#1() --> (/,at,Self,_)>,<{t002} --> (/,on,_,#1())>). :\: %1.00;0.90% {6 : -1 : 1} + +2 + + OUT: (&|,<#1() --> (/,at,Self,_)>,<(*,{t002},#1()) --> on>). :\: %1.00;0.90% {8 : -1 : 1} + +********** [22 -> 23] + IN: (&|,<#1() --> (/,at,Self,_)>,<(*,{t002},#1()) --> on>). :\: %1.00;0.90% {0 : -1 : 1} + +3 + + OUT: (&|,<(*,{t002},#1()) --> on>, (/,at,_,#1())>). :\: %1.00;0.90% {3 : -1 : 1} + +1 + + OUT: (&|,<(*,{t002},#1()) --> on>,<(*,Self,#1()) --> at>). :\: %1.00;0.90% {4 : -1 : 1} + +********** [23 + 06 -> 24] + IN: (&|,<(*,{t002},#1()) --> on>,<(*,Self,#1()) --> at>). :|: %1.00;0.90% {0 : 0 : 1} + + IN: <(&|,<(*,#1,#2(#1)) --> on>,<(*,Self,#2(#1)) --> at>) =|> <(*,Self,#1) --> reachable>>. %1.00;0.90% {0 : 2} + +1 + + OUT: <(*,Self,{t002}) --> reachable>. :\: %1.00;0.81% {1 : 0 : 2;1} + +********** [24 + 12 -> 25] + IN: <(*,Self,{t002}) --> reachable>. :|: %1.00;0.90% {0 : 0 : 1} + + IN: (&/,<(*,Self,{t002}) --> reachable>,<(*,{t002}) --> ^pick>)! %1.00;0.90% {0 : 2} + +1 + + OUT: (&/,<(*,Self,{t002}) --> reachable>,<(*,{t002}) --> ^pick>)? :|: {1 : 1 : 3} + +2 + + OUT: (&/,<{t002} --> (/,reachable,Self,_)>,<(*,{t002}) --> ^pick>)! %1.00;0.90% {3 : 2} + +1 + + OUT: (&/,<{t002} --> (/,reachable,Self,_)>,<(*,{t002}) --> ^pick>)? :|: {4 : 4 : 4} + +2 + + OUT: <(*,{t002}) --> ^pick>! %1.00;0.81% {6 : 1;2} + +********** [25 -> 26] + IN: <(*,{t002}) --> ^pick>! %1.00;0.90% {0 : 1} + +1 + + OUT: <(*,{t002}) --> ^pick>. :|: %1.00;0.90% {1 : 1 : 2} + +********** [24 + 05 -> 27] + IN: <(*,Self,{t002}) --> reachable>. :|: %1.00;0.90% {0 : 0 : 1} + + IN: <(&/,<(*,Self,{t002}) --> reachable>,<(*,{t002}) --> ^pick>) =/> <(*,Self,{t002}) --> hold>>. %1.00;0.90% {0 : 2} + +1 + + OUT: <<(*,{t002}) --> ^pick> =/> <(*,Self,{t002}) --> hold>>. :\: %1.00;0.81% {1 : 0 : 2;1} + +********** [26 + 27 -> 28] + IN: <(*,{t002}) --> ^pick>. :\: %1.00;0.90% {0 : -1 : 1} + + IN: <<(*,{t002}) --> ^pick> =/> <(*,Self,{t002}) --> hold>>. :\: %1.00;0.90% {0 : -1 : 2} + +1 + + OUT: <(*,Self,{t002}) --> hold>. :\: %1.00;0.81% {1 : 0 : 2;1} + +********** [28 + 10 -> 29] + IN: <(*,Self,{t002}) --> hold>. :|: %1.00;0.90% {0 : 0 : 1} + + IN: (&/,<(*,Self,{t002}) --> hold>,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^open>)! %1.00;0.90% {0 : 2} + +1 + + OUT: (&/,<(*,Self,{t002}) --> hold>,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^open>)? :|: {1 : 1 : 3} + +1 + + OUT: (&/, (/,hold,_,{t002})>,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^open>)! %1.00;0.90% {2 : 2} + +1 + + OUT: (&/, (/,hold,_,{t002})>,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^open>)? :|: {3 : 3 : 4} + +1 + + OUT: (&/,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^open>)! %1.00;0.81% {4 : 1;2} + +1 + + OUT: (&/,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^open>)? :|: {5 : 5 : 5} + +1 + + OUT: <(/,(*,Self,{t002}),_,{t002}) --> (/,hold,_,{t002})>. :\: %1.00;0.81% {6 : 0 : 1} + +1 + + OUT: (&/,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^open>)! %1.00;0.81% {7 : 1;2} + +********** [03 + 28 -> 30] + IN: <(&/,<(*,Self,{t002}) --> hold>,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^open>) =/> <{t001} --> [opened]>>. %1.00;0.90% {0 : 1} + + IN: <(*,Self,{t002}) --> hold>. :|: %1.00;0.90% {0 : 0 : 2} + +2 + + OUT: <(&/,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^open>) =/> <{t001} --> [opened]>>. :\: %1.00;0.81% {2 : 0 : 1;2} + +********** [29 -> 31] + IN: (&/,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^open>)! %1.00;0.90% {0 : 1} +1 + OUT: (&/,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^open>)? :|: {1 : 1 : 2} +1 + OUT: <(*,Self,{t001}) --> at>? :\: {2 : 1 : 2} +2 + OUT: (&/,<{t001} --> (/,at,Self,_)>,<(*,{t001}) --> ^open>)! %1.00;0.90% {4 : 1} +1 + OUT: (&/,<{t001} --> (/,at,Self,_)>,<(*,{t001}) --> ^open>)? :|: {5 : 5 : 3} +1 + OUT: (&/, (/,at,_,{t001})>,<(*,{t001}) --> ^open>)! %1.00;0.90% {6 : 1} +1 + OUT: (&/, (/,at,_,{t001})>,<(*,{t001}) --> ^open>)? :|: {7 : 7 : 4} +5 + OUT: (&/, (/,at,_,{t001})>,<(*,{t001}) --> ^open>)? :\: {12 : 1 : 2} +1 + OUT: <(*,Self,{t001}) --> at>! %1.00;0.45% {13 : 1} +********** [31 + 09 -> 32] + IN: <(*,Self,{t001}) --> at>! %1.00;0.90% {0 : 1} + + IN: <<(*,#1) --> ^go-to> =/> <(*,Self,#1) --> at>>. %1.00;0.90% {0 : 2} + +1 + + OUT: <(*,Self,{t001}) --> at>? :|: {1 : 1 : 3} + + OUT: <<(*,#1) --> ^go-to> =/> (/,at,_,#1)>>. %1.00;0.90% {1 : 2} + +5 + + OUT: <{t001} --> (/,at,Self,_)>! %1.00;0.90% {6 : 1} + +1 + + OUT: <{t001} --> (/,at,Self,_)>? :|: {7 : 7 : 4} + +5 + + OUT: <(*,Self,{t001}) --> at>? :\: {12 : 7 : 4} + +1 + + OUT: (/,at,_,{t001})>! %1.00;0.90% {13 : 1} + +1 + + OUT: (/,at,_,{t001})>? :|: {14 : 14 : 5} + +4 + + OUT: (/,at,_,{t001})>? :\: {18 : 1 : 3} + +1 + + OUT: <(*,{t001}) --> ^go-to>! %1.00;0.81% {19 : 2;1} + +********** [32 -> 33] + IN: <(*,{t001}) --> ^go-to>! %1.00;0.90% {0 : 1} + +1 + + OUT: <(*,{t001}) --> ^go-to>. :|: %1.00;0.90% {1 : 1 : 2} + +********** [33 + 09 -> 34] + IN: <(*,{t001}) --> ^go-to>. :\: %1.00;0.90% {0 : -1 : 1} + + IN: <<(*,#1) --> ^go-to> =/> <(*,Self,#1) --> at>>. %1.00;0.90% {0 : 2} + +2 + + OUT: <{t001} --> (/,^go-to,_)>. :\: %1.00;0.90% {2 : -1 : 1} + +5 + + OUT: <(/,(*,{t001}),_) --> (/,^go-to,_)>. :\: %1.00;0.90% {7 : -1 : 1} + +1 + + OUT: <<(*,#1) --> ^go-to> =/> (/,at,_,#1)>>. %1.00;0.90% {8 : 2} + +4 + + OUT: <(*,Self,{t001}) --> at>. %1.00;0.43% {12 : 1;2} + +********** [34 + 30 -> 35] + IN: <(*,Self,{t001}) --> at>. :|: %1.00;0.90% {0 : 0 : 1} + + IN: <(&/,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^open>) =/> <{t001} --> [opened]>>. :|: %1.00;0.90% {0 : 0 : 2} + +1 + + OUT: <(&/,<{t001} --> (/,at,Self,_)>,<(*,{t001}) --> ^open>) ==> <{t001} --> [opened]>>. :\: %1.00;0.90% {1 : 0 : 2} + +1 + + OUT: <(&|,(&/,<{t001} --> (/,at,Self,_)>,<(*,{t001}) --> ^open>),<(*,Self,{t001}) --> at>) =|> <{t001} --> [opened]>>. :\: %1.00;0.45% {2 : 0 : 1;2} + +1 + + OUT: <<(*,{t001}) --> ^open> =/> <{t001} --> [opened]>>. :\: %1.00;0.81% {3 : 0 : 2;1} + +********** [34 + 29 -> 36] + IN: <(*,Self,{t001}) --> at>. :|: %1.00;0.90% {0 : 0 : 1} + + IN: (&/,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^open>)! %1.00;0.90% {0 : 2} + +1 + + OUT: (&/,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^open>)? :|: {1 : 1 : 3} + +2 + + OUT: (&/,<{t001} --> (/,at,Self,_)>,<(*,{t001}) --> ^open>)! %1.00;0.90% {3 : 2} + +1 + + OUT: (&/,<{t001} --> (/,at,Self,_)>,<(*,{t001}) --> ^open>)? :|: {4 : 4 : 4} + +2 + + OUT: <(*,{t001}) --> ^open>! %1.00;0.81% {6 : 1;2} + +********** [36 -> 37] + IN: <(*,{t001}) --> ^open>! %1.00;0.90% {0 : 1} + +1 + + OUT: <(*,{t001}) --> ^open>. :|: %1.00;0.90% {1 : 1 : 2} + +********** [35 + 37 -> 38] + IN: <<(*,{t001}) --> ^open> =/> <{t001} --> [opened]>>. :|: %1.00;0.90% {0 : 0 : 1} + + IN: <(*,{t001}) --> ^open>. :|: %1.00;0.90% {0 : 0 : 2} + +1 + + OUT: <{t001} --> [opened]>. :|: %1.00;0.81% {1 : 1 : 1;2} + diff --git a/nars-dist/Examples-1.3.3/Example-NAL8-2-abridged.txt b/nars-dist/Examples-1.3.3/Example-NAL8-2-abridged.txt new file mode 100755 index 00000000..56fbebd9 --- /dev/null +++ b/nars-dist/Examples-1.3.3/Example-NAL8-2-abridged.txt @@ -0,0 +1,44 @@ +*** [01] <{t001} --> [opened]>! +*** [02] <{t001} --> door>. +*** [03] <(&/, <(*, Self, {t002}) --> hold>, <(*, Self, {t001}) --> at>, (^open, {t001})) =/> <{t001} --> [opened]>>. +*** [04] <(*, {t002}, {t001}) --> key-of>. +*** [05] <(&/, <(*, Self, {t002}) --> reachable>, (^pick, {t002})) =/> <(*, Self, {t002}) --> hold>>. +*** [06] <(&|, <(*, #x, #y(#x)) --> on>, <(*, Self, #y(#x)) --> at>) =|> <(*, Self, #x) --> reachable>>. +*** [07] <(*, {t002}, {t003}) --> on>. :|: +*** [08] <{t003} --> desk>. +*** [09] <(^go-to, #x) =/> <(*, Self, #x) --> at>>. + +********** [03 + 09 -> 10]: + IN: <(^go-to,#1) =/> <(*,Self,#1) --> at>>. + IN: <(&/,<(*,Self,{t002}) --> hold>,<(*,Self,{t001}) --> at>,(^open,{t001})) =/> <{t001} --> [opened]>>. +2 + OUT: <(&/,<(*,Self,{t002}) --> hold>,(^go-to,{t001}),(^open,{t001})) =/> <{t001} --> [opened]>>. %1.00;0.81% + +********** [10 + 05 -> 11] + IN: <(&/,<(*,Self,{t002}) --> hold>,(^go-to,{t001}),(^open,{t001})) =/> <{t001} --> [opened]>>. + IN: <(&/,<(*,Self,{t002}) --> reachable>,(^pick,{t002})) =/> <(*,Self,{t002}) --> hold>>. +14 + OUT: <(&/,<(*,Self,{t002}) --> reachable>,(^pick,{t002}),(^go-to,{t001}),(^open,{t001})) =/> <{t001} --> [opened]>>. %1.00;0.81% + +********** [06 + 07 -> 12] + IN: <(&|,<(*,#1,#2(#1)) --> on>,<(*,Self,#2(#1)) --> at>) =|> <(*,Self,#1) --> reachable>>. + IN: <(*,{t002},{t003}) --> on>. :|: +7 + OUT: <<(*,Self,{t003}) --> at> =|> <(*,Self,{t002}) --> reachable>>. :\: %1.00;0.81% + + IN: <(&|,<(*,#1,#2(#1)) --> on>,<(*,Self,#2(#1)) --> at>) =|> <(*,Self,#1) --> reachable>>. + IN: <(*,{t002},{t003}) --> on>. :|: +7 + OUT: <<(*,Self,{t003}) --> at> =|> <(*,Self,{t002}) --> reachable>>. :\: %1.00;0.81% + +********** [13 + 09 -> 14] + IN: <(&/,<(*,Self,{t003}) --> at>,(^pick,{t002}),(^go-to,{t001}),(^open,{t001})) =/> <{t001} --> [opened]>>. :|: + IN: <(^go-to,#1) =/> <(*,Self,#1) --> at>>. +16 + OUT: <(&/,(^go-to,{t003}),(^pick,{t002}),(^go-to,{t001}),(^open,{t001})) =/> <{t001} --> [opened]>>. :\: %1.00;0.81% + +********** [01 + 14 -> 15] + IN: <{t001} --> [opened]>! + IN: <(&/,(^go-to,{t003}),(^pick,{t002}),(^go-to,{t001}),(^open,{t001})) =/> <{t001} --> [opened]>>. :|: +15 + OUT: (&/,(^go-to,{t003}),(^pick,{t002}),(^go-to,{t001}),(^open,{t001}))! %1.00;0.81% diff --git a/nars-dist/Examples-1.3.3/Example-NAL8-2-complete.txt b/nars-dist/Examples-1.3.3/Example-NAL8-2-complete.txt new file mode 100755 index 00000000..ab48c626 --- /dev/null +++ b/nars-dist/Examples-1.3.3/Example-NAL8-2-complete.txt @@ -0,0 +1,131 @@ +*** [01] <{t001} --> [opened]>! +*** [02] <{t001} --> door>. +*** [03] <(&/, <(*, Self, {t002}) --> hold>, <(*, Self, {t001}) --> at>, (^open, {t001})) =/> <{t001} --> [opened]>>. +*** [04] <(*, {t002}, {t001}) --> key-of>. +*** [05] <(&/, <(*, Self, {t002}) --> reachable>, (^pick, {t002})) =/> <(*, Self, {t002}) --> hold>>. +*** [06] <(&|, <(*, #x, #y(#x)) --> on>, <(*, Self, #y(#x)) --> at>) =|> <(*, Self, #x) --> reachable>>. +*** [07] <(*, {t002}, {t003}) --> on>. :|: +*** [08] <{t003} --> desk>. +*** [09] <(^go-to, #x) =/> <(*, Self, #x) --> at>>. +********** [03 + 09 -> 10]: + IN: <<(*,#1) --> ^go-to> =/> <(*,Self,#1) --> at>>. %1.00;0.90% {0 : 1} + + IN: <(&/,<(*,Self,{t002}) --> hold>,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^open>) =/> <{t001} --> [opened]>>. %1.00;0.90% {0 : 2} + +1 + + OUT: <<(*,#1) --> ^go-to> =/> (/,at,_,#1)>>. %1.00;0.90% {1 : 1} + +1 + + OUT: <(&/,<(*,Self,{t002}) --> hold>,<(*,{t001}) --> ^go-to>,<(*,{t001}) --> ^open>) =/> <{t001} --> [opened]>>. %1.00;0.81% {2 : 2;1} + +********** [10 + 05 -> 11] + IN: <(&/,<(*,Self,{t002}) --> hold>,<(*,{t001}) --> ^go-to>,<(*,{t001}) --> ^open>) =/> <{t001} --> [opened]>>. %1.00;0.90% {0 : 1} + + IN: <(&/,<(*,Self,{t002}) --> reachable>,<(*,{t002}) --> ^pick>) =/> <(*,Self,{t002}) --> hold>>. %1.00;0.90% {0 : 2} + +10 + + OUT: <(&/, (/,hold,_,{t002})>,<(*,{t001}) --> ^go-to>,<(*,{t001}) --> ^open>) ==> <{t001} --> [opened]>>. %1.00;0.90% {10 : 1} + +1 + + OUT: <(&/,<{t002} --> (/,hold,Self,_)>,<(*,{t001}) --> ^go-to>,<(*,{t001}) --> ^open>) ==> <{t001} --> [opened]>>. %1.00;0.90% {11 : 1} + +3 + + OUT: <(&/,<(*,Self,{t002}) --> reachable>,<(*,{t002}) --> ^pick>,<(*,{t001}) --> ^go-to>,<(*,{t001}) --> ^open>) =/> <{t001} --> [opened]>>. %1.00;0.81% {14 : 2;1} + +********** [06 + 07 -> 12] + IN: <(&|,<(*,#1,#2(#1)) --> on>,<(*,Self,#2(#1)) --> at>) =|> <(*,Self,#1) --> reachable>>. %1.00;0.90% {0 : 1} + + IN: <(*,{t002},{t003}) --> on>. :|: %1.00;0.90% {0 : 0 : 2} + +4 + + OUT: <(&|,<(*,#1,#2(#1)) --> on>, (/,at,_,#2(#1))>) ==> <(*,Self,#1) --> reachable>>. %1.00;0.90% {4 : 1} + +3 + + OUT: <<(*,Self,{t003}) --> at> =|> <(*,Self,{t002}) --> reachable>>. :\: %1.00;0.81% {7 : 0 : 1;2} + +********** [11 + 12 -> 13] + IN: <(&/,<(*,Self,{t002}) --> reachable>,<(*,{t002}) --> ^pick>,<(*,{t001}) --> ^go-to>,<(*,{t001}) --> ^open>) =/> <{t001} --> [opened]>>. %1.00;0.90% {0 : 1} + + IN: <<(*,Self,{t003}) --> at> =|> <(*,Self,{t002}) --> reachable>>. :|: %1.00;0.90% {0 : 0 : 2} + +5 + + OUT: <(&/,<(*,Self,{t003}) --> at>,<(*,{t002}) --> ^pick>,<(*,{t001}) --> ^go-to>,<(*,{t001}) --> ^open>) =/> <{t001} --> [opened]>>. %1.00;0.43% {5 : 2;1} + +3 + + OUT: <(&/,<(*,Self,{t003}) --> at>,<(*,{t002}) --> ^pick>,<(*,{t001}) --> ^go-to>,<(*,{t001}) --> ^open>) =/> <{t001} --> [opened]>>. %1.00;0.43% {8 : 2;1} + +1 + + OUT: <(&/,<{t002} --> (/,reachable,Self,_)>,<(*,{t002}) --> ^pick>,<(*,{t001}) --> ^go-to>,<(*,{t001}) --> ^open>) ==> <{t001} --> [opened]>>. %1.00;0.90% {9 : 1} + +7 + + OUT: <(&/, (/,reachable,_,{t002})>,<(*,{t002}) --> ^pick>,<(*,{t001}) --> ^go-to>,<(*,{t001}) --> ^open>) ==> <{t001} --> [opened]>>. %1.00;0.90% {16 : 1} + +1 + + OUT: <(&/,<(*,Self,{t003}) --> at>,<(*,{t002}) --> ^pick>,<(*,{t001}) --> ^go-to>,<(*,{t001}) --> ^open>) =/> <{t001} --> [opened]>>. :\: %1.00;0.81% {17 : 0 : 1;2} + +********** [13 + 09 -> 14] + IN: <(&/,<(*,Self,{t003}) --> at>,<(*,{t002}) --> ^pick>,<(*,{t001}) --> ^go-to>,<(*,{t001}) --> ^open>) =/> <{t001} --> [opened]>>. :|: %1.00;0.90% {0 : 0 : 1} + + IN: <<(*,#1) --> ^go-to> =/> <(*,Self,#1) --> at>>. %1.00;0.90% {0 : 2} + +6 + + OUT: <(&/,<(*,Self,{t003}) --> at>,<(*,{t002}) --> ^pick>,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^open>) =/> <{t001} --> [opened]>>. %1.00;0.30% {6 : 1;2} + +1 + + OUT: <(&/,<{t003} --> (/,at,Self,_)>,<(*,{t002}) --> ^pick>,<(*,{t001}) --> ^go-to>,<(*,{t001}) --> ^open>) ==> <{t001} --> [opened]>>. :\: %1.00;0.90% {7 : 0 : 1} + +3 + + OUT: <<(*,#1) --> ^go-to> =/> (/,at,_,#1)>>. %1.00;0.90% {10 : 2} + +1 + + OUT: <(&/,<(*,{t003}) --> ^go-to>,<(*,{t002}) --> ^pick>,<(*,{t001}) --> ^go-to>,<(*,{t001}) --> ^open>) =/> <{t001} --> [opened]>>. %1.00;0.43% {11 : 1;2} + +4 + + OUT: <(&/, (/,at,_,{t003})>,<(*,{t002}) --> ^pick>,<(*,{t001}) --> ^go-to>,<(*,{t001}) --> ^open>) ==> <{t001} --> [opened]>>. :\: %1.00;0.90% {15 : 0 : 1} + +1 + + OUT: <(&/,<(*,{t003}) --> ^go-to>,<(*,{t002}) --> ^pick>,<(*,{t001}) --> ^go-to>,<(*,{t001}) --> ^open>) =/> <{t001} --> [opened]>>. :\: %1.00;0.81% {16 : 0 : 2;1} + +********** [01 + 14 -> 15] + IN: <{t001} --> [opened]>! %1.00;0.90% {0 : 1} + + IN: <(&/,<(*,{t003}) --> ^go-to>,<(*,{t002}) --> ^pick>,<(*,{t001}) --> ^go-to>,<(*,{t001}) --> ^open>) =/> <{t001} --> [opened]>>. :|: %1.00;0.90% {0 : 0 : 2} + +1 + + OUT: <{t001} --> [opened]>? :|: {1 : 1 : 3} + +10 + + OUT: <(&/,<{t003} --> (/,^go-to,_)>,<(*,{t002}) --> ^pick>,<(*,{t001}) --> ^go-to>,<(*,{t001}) --> ^open>) ==> <{t001} --> [opened]>>. :\: %1.00;0.90% {11 : 0 : 2} + +2 + + OUT: (&/,<(*,{t003}) --> ^go-to>,<(*,{t002}) --> ^pick>,<(*,{t001}) --> ^go-to>,<(*,{t001}) --> ^open>)? :\: {13 : 0 : 2;3} + +1 + + OUT: (&/,<(*,{t003}) --> ^go-to>,<(*,{t002}) --> ^pick>,<{t001} --> (/,^go-to,_)>,<(*,{t001}) --> ^open>)? :\: {14 : 0 : 2;3} + +2 + + OUT: (&/,<(*,{t003}) --> ^go-to>,<(*,{t002}) --> ^pick>,<(*,{t001}) --> ^go-to>,<(*,{t001}) --> ^open>)! %1.00;0.81% {16 : 2;1} + diff --git a/nars-dist/Examples-1.3.3/Example-NAL8-3-abridged.txt b/nars-dist/Examples-1.3.3/Example-NAL8-3-abridged.txt new file mode 100755 index 00000000..e970fe89 --- /dev/null +++ b/nars-dist/Examples-1.3.3/Example-NAL8-3-abridged.txt @@ -0,0 +1,53 @@ +*** [01] <{t001} --> [opened]>! +*** [02] <{t001} --> door>. +*** [03] <(&/, <(*, Self, {t002}) --> hold>, <(*, Self, {t001}) --> at>, (^open, {t001})) =/> <{t001} --> [opened]>>. +*** [04] <(*, {t002}, {t001}) --> key-of>. +*** [05] <(*, Self, {t002}) --> hold>. :|: +*** [06] <(&/, <(*, Self, {t001}) --> at>, (^break, {t001})) =/> <{t001} --> [opened]>>. +*** [07] <(*, Self, {t001}) --> at>. :|: +*** [08] <{t001} --> [damaged]>! %0; 0.95% +*** [09] <(^break, #x) =/> <#x --> [damaged]>>. + +********** [01 + 06 -> 10]: + IN: <{t001} --> [opened]>! + IN: <(&/,<(*,Self,{t001}) --> at>,(^break,{t001})) =/> <{t001} --> [opened]>>. +28 + OUT: (&/,<(*,Self,{t001}) --> at>,(^break,{t001}))! %1.00;0.81% + +********** [10 + 07 -> 11]: + IN: (&/,<(*,Self,{t001}) --> at>,(^break,{t001}))! + IN: <(*,Self,{t001}) --> at>. :|: +4 + OUT: (^break,{t001})! %1.00;0.73% + +********** [09 + 08 -> 12]: + IN: <(^break,#1) =/> <#1 --> [damaged]>>. + IN: <{t001} --> [damaged]>! +17 + OUT: (^break,{t001})! %0.00;0.86% + +********** [12 + 11 -> 13]: + IN: (^break,{t001})! %0.00;0.86% +1 + IN: (^break,{t001})! %1.00;0.73% +1 + OUT: (^break,{t001})! %0.31;0.90% + +********** [13 -> NO EXECUTION]: + IN: (^break,{t001})! %0.31;0.90% +10 + +*** [14] <(*,{t001}) --> ^break>! %1.00;0.95% + +********** [13 + 14 -> 15]: + IN: (^break,{t001})! %0.31;0.89% +1 + IN: (^break,{t001})! %1.00;0.95% +1 + OUT: (^break,{t001})! %0.79;0.96% + +********** [15 -> 16]: + IN: (^break,{t001})! %0.79;0.96% {0 : 1} +1 +***EXECUTE: ^break({t001}) + OUT: (^break,{t001}). :|: %1.00;0.90% diff --git a/nars-dist/Examples-1.3.3/Example-NAL8-3-complete.txt b/nars-dist/Examples-1.3.3/Example-NAL8-3-complete.txt new file mode 100755 index 00000000..b09b2346 --- /dev/null +++ b/nars-dist/Examples-1.3.3/Example-NAL8-3-complete.txt @@ -0,0 +1,121 @@ +*** [01] <{t001} --> [opened]>! +*** [02] <{t001} --> door>. +*** [03] <(&/, <(*, Self, {t002}) --> hold>, <(*, Self, {t001}) --> at>, (^open, {t001})) =/> <{t001} --> [opened]>>. +*** [04] <(*, {t002}, {t001}) --> key-of>. +*** [05] <(*, Self, {t002}) --> hold>. :|: +*** [06] <(&/, <(*, Self, {t001}) --> at>, (^break, {t001})) =/> <{t001} --> [opened]>>. +*** [07] <(*, Self, {t001}) --> at>. :|: +*** [08] <{t001} --> [damaged]>! %0; 0.95% +*** [09] <(^break, #x) =/> <#x --> [damaged]>>. +********** [01 + 06 -> 10]: + IN: <{t001} --> [opened]>! %1.00;0.90% {0 : 1} + + IN: <(&/,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^break>) =/> <{t001} --> [opened]>>. %1.00;0.90% {0 : 2} + +1 + + OUT: <{t001} --> [opened]>? :|: {1 : 1 : 3} + +1 + + OUT: <(&/,<{t001} --> (/,at,Self,_)>,<(*,{t001}) --> ^break>) ==> <{t001} --> [opened]>>. %1.00;0.90% {2 : 2} + +2 + + OUT: <(&/, (/,at,_,{t001})>,<(*,{t001}) --> ^break>) ==> <{t001} --> [opened]>>. %1.00;0.90% {4 : 2} + +6 + + OUT: <(&/,<(*,Self,{t001}) --> at>,<{t001} --> (/,^break,_)>) ==> <{t001} --> [opened]>>. %1.00;0.90% {10 : 2} + +16 + + OUT: (&/,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^break>)! %1.00;0.81% {26 : 2;1} + +********** [10 + 07 -> 11]: + IN: (&/,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^break>)! %1.00;0.81% {0 : 1} + + IN: <(*,Self,{t001}) --> at>. :|: %1.00;0.90% {0 : 0 : 2} + +1 + + OUT: (&/,<(*,Self,{t001}) --> at>,<(*,{t001}) --> ^break>)? :|: {1 : 1 : 3} + +1 + + OUT: (&/, (/,at,_,{t001})>,<(*,{t001}) --> ^break>)! %1.00;0.81% {2 : 1} + +1 + + OUT: (&/, (/,at,_,{t001})>,<(*,{t001}) --> ^break>)? :|: {3 : 3 : 4} + +1 + + OUT: <(*,{t001}) --> ^break>! %1.00;0.73% {4 : 2;1} + +********** [09 + 08 -> 12]: + IN: <<(*,#1) --> ^break> =/> <#1 --> [damaged]>>. {0 : 1} + IN: <{t001} --> [damaged]>! %0.00;0.95% {0 : 2} + +1 + + OUT: <{t001} --> [damaged]>? :|: {1 : 1 : 3} + +16 + + OUT: <(*,{t001}) --> ^break>! %0.00;0.86% {17 : 1;2} + +********** [12 + 11 -> 13]: + IN: <(*,{t001}) --> ^break>! %0.00;0.85% {0 : 1} + +1 + + OUT: <(*,{t001}) --> ^break>? :|: {1 : 1 : 2} + + IN: <(*,{t001}) --> ^break>! %1.00;0.72% {1 : 3} + +1 + + OUT: <(*,{t001}) --> ^break>! %0.31;0.89% {2 : 1;3} + + OUT: <{t001} --> (/,^break,_)>! %0.00;0.85% {2 : 1} + +********** [13 -> NO EXECUTION]: + IN: <(*,{t001}) --> ^break>! %0.31;0.89% {0 : 1} + +1 + + OUT: <(*,{t001}) --> ^break>? :|: {1 : 1 : 2} + +6 + + OUT: <{t001} --> (/,^break,_)>! %0.31;0.89% {7 : 1} + +1 + + OUT: <{t001} --> (/,^break,_)>? :|: {8 : 8 : 3} + +2 +*** [14] <(*,{t001}) --> ^break>! %1.00;0.95% +********** [13 + 14 -> 15]: + IN: <(*,{t001}) --> ^break>! %0.31;0.89% {0 : 1} + +1 + + OUT: <(*,{t001}) --> ^break>? :|: {1 : 1 : 2} + + IN: <(*,{t001}) --> ^break>! %1.00;0.95% {1 : 3} + +1 + + OUT: <(*,{t001}) --> ^break>! %0.79;0.96% {2 : 1;3} + + OUT: <{t001} --> (/,^break,_)>! %0.31;0.89% {2 : 1} + +********** [15 -> 16]: + IN: <(*,{t001}) --> ^break>! %0.79;0.96% {0 : 1} + +1 + + OUT: <(*,{t001}) --> ^break>. :|: %1.00;0.90% {1 : 1 : 2} + diff --git a/nars-dist/Examples-1.3.3/Example-NAL8-4-abridged.txt b/nars-dist/Examples-1.3.3/Example-NAL8-4-abridged.txt new file mode 100755 index 00000000..668627c9 --- /dev/null +++ b/nars-dist/Examples-1.3.3/Example-NAL8-4-abridged.txt @@ -0,0 +1,66 @@ +*** [01] <(*, Self, key001) --> hold>! +*** [02] <(*, Self, key001) --> hold>. :|: %0% +*** [03] <(&/, <(*, Self, key001) --> reachable>, (^pick, key001)) =/> <(*, Self, key001) --> hold>>. +*** [04] <(*, Self, key001) --> reachable>. :|: + +********** [04 + 03 -> 05]: + IN: <(*,Self,key001) --> reachable>. :|: + IN: <(&/,<(*,Self,key001) --> reachable>,(^pick,key001)) =/> <(*,Self,key001) --> hold>>. +1 + OUT: <(^pick,key001) =/> <(*,Self,key001) --> hold>>. :\: %1.00;0.81% + +********** [05 + 01 -> 06]: + IN: <(^pick,key001) =/> <(*,Self,key001) --> hold>>. :|: + IN: <(*,Self,key001) --> hold>! +3 + OUT: (^pick,key001)! %1.00;0.81% + +********** [06 -> 07]: + IN: (^pick,key001)! +1 +***EXECUTE: ^pick(key001) + OUT: (^pick,key001). :|: %1.00;0.90% + +********** [07 + 05 -> 08]: + IN: (^pick,key001). :\: + IN: <(^pick,key001) =/> <(*,Self,key001) --> hold>>. +1 + OUT: <(*,Self,key001) --> hold>. :\: %1.00;0.81% + +*** [9] <(*, Self, key001) --> hold>. :|: + +********** [08 + 09 -> 10]: + IN: <(*,Self,key001) --> hold>. :|: %1.00;0.81% +1 + IN: <(*,Self,key001) --> hold>. :|: +1 + OUT: <(*,Self,key001) --> hold>. :\: %1.00;0.91% + +********** [02 + 10 -> 11]: + IN: <(*,Self,key001) --> hold>. :|: %0% +5 + IN: <(*,Self,key001) --> hold>. :|: %1.00;0.91% +5 + IN: <(*,Self,key001) --> hold>? :|: +2 + OUT: <(*,Self,key001) --> hold>. :\: %0.92;0.48% + +********** [07 + 11 -> 12]: + IN: (^pick,key001). :\: + IN: <(*,Self,key001) --> hold>. :|: +1 + OUT: <(^pick,key001) =/> <(*,Self,key001) --> hold>>. :\: %1.00;0.45% + +********** [05 + 12 -> 13]: + IN: <(^pick,key001) =/> <(*,Self,key001) --> hold>>. :\: %1.00;0.90% + IN: <(^pick,key001) =/> <(*,Self,key001) --> hold>>. :\: %1.00;0.45% +1 + OUT: <(^pick,key001) =/> <(*,Self,key001) --> hold>>. :\: %1.00;0.91% + +********** [04 + 13 -> 14]: + IN: <(*,Self,key001) --> reachable>. :|: +1 + IN: <(^pick,key001) =/> <(*,Self,key001) --> hold>>. :|: +1 + OUT: <(&/,<(*,Self,key001) --> reachable>,(^pick,key001)) =/> <(*,Self,key001) --> hold>>. :\: %1.00;0.45% + OUT: <(&/,<(*,Self,key001) --> reachable>,(^pick,key001)) =/> <(*,Self,key001) --> hold>>. %1.00;0.45% diff --git a/nars-dist/Examples-1.3.3/Example-NAL8-4-complete.txt b/nars-dist/Examples-1.3.3/Example-NAL8-4-complete.txt new file mode 100755 index 00000000..7bf70001 --- /dev/null +++ b/nars-dist/Examples-1.3.3/Example-NAL8-4-complete.txt @@ -0,0 +1,152 @@ +*** [01] <(*, Self, key001) --> hold>! +*** [02] <(*, Self, key001) --> hold>. :|: %0% +*** [03] <(&/, <(*, Self, key001) --> reachable>, (^pick, key001)) =/> <(*, Self, key001) --> hold>>. +*** [04] <(*, Self, key001) --> reachable>. :|: +********** [04 + 03 -> 05]: + IN: <(*,Self,key001) --> reachable>. :|: %1.00;0.90% {0 : 0 : 1} + + IN: <(&/,<(*,Self,key001) --> reachable>,<(*,key001) --> ^pick>) =/> <(*,Self,key001) --> hold>>. %1.00;0.90% {0 : 2} + +1 + + OUT: <<(*,key001) --> ^pick> =/> <(*,Self,key001) --> hold>>. :\: %1.00;0.81% {1 : 0 : 2;1} + +********** [05 + 01 -> 06]: + IN: <<(*,key001) --> ^pick> =/> <(*,Self,key001) --> hold>>. :|: %1.00;0.90% {0 : 0 : 1} + + IN: <(*,Self,key001) --> hold>! %1.00;0.90% {0 : 2} + +1 + + OUT: <(*,Self,key001) --> hold>? :|: {1 : 1 : 3} + + OUT: (/,hold,_,key001)>! %1.00;0.90% {1 : 2} + +1 + + OUT: (/,hold,_,key001)>? :|: {2 : 2 : 4} + +1 + + OUT: <(*,key001) --> ^pick>! %1.00;0.81% {3 : 1;2} + +********** [06 -> 07]: + IN: <(*,key001) --> ^pick>! %1.00;0.90% {0 : 1} + +1 + + OUT: <(*,key001) --> ^pick>. :|: %1.00;0.90% {1 : 1 : 2} + +********** [07 + 05 -> 08]: + IN: <(*,key001) --> ^pick>. :\: %1.00;0.90% {0 : -1 : 1} + + IN: <<(*,key001) --> ^pick> =/> <(*,Self,key001) --> hold>>. %1.00;0.90% {0 : 2} + +1 + + OUT: <(*,Self,key001) --> hold>. :\: %1.00;0.81% {1 : 0 : 2;1} + +*** [9] <(*, Self, key001) --> hold>. +********** [08 + 9 -> 10]: + IN: <(*,Self,key001) --> hold>. :|: %1.00;0.81% {0 : 0 : 1} + +1 + + OUT: (/,hold,_,key001)>. :\: %1.00;0.81% {1 : 0 : 1} + + IN: <(*,Self,key001) --> hold>. :|: %1.00;0.90% {1 : 1 : 2} + +1 + + OUT: <(*,Self,key001) --> hold>. :\: %1.00;0.91% {2 : 1 : 1;2} + +********** [02 + 10 -> 11]: + IN: <(*,Self,key001) --> hold>. :|: %0.00;0.90% {0 : 0 : 1} + +1 + + OUT: (/,hold,_,key001)>. :\: %0.00;0.90% {1 : 0 : 1} + +1 + + OUT: (/,hold,Self,_)>. :\: %0.00;0.90% {2 : 0 : 1} + +3 + + IN: <(*,Self,key001) --> hold>. :|: %1.00;0.91% {5 : 5 : 2} + +1 + + OUT: <(*,Self,key001) --> hold>. :\: %0.92;0.92% {6 : 5 : 1;2} + +1 + + OUT: (/,hold,_,key001)>. :\: %1.00;0.91% {7 : 5 : 2} + +1 + + OUT: (/,hold,_,key001)>. :\: %0.92;0.92% {8 : 5 : 1;2} + + OUT: < (/,hold,_,key001)> =\> <(*,Self,key001) --> hold>>. :\: %0.00;0.45% {8 : 5 : 1;2} + + OUT: <<(*,Self,key001) --> hold> (/,hold,_,key001)>>. :\: %0.00;0.45% {8 : 5 : 1;2} + + OUT: (/,hold,Self,_)>. :\: %1.00;0.91% {8 : 5 : 2} + +1 + + OUT: (/,hold,Self,_)>. :\: %0.91;0.92% {9 : 5 : 1;2} + +1 + + IN: <(*,Self,key001) --> hold>? :|: {10 : 10 : 3} + +1 + + OUT: <(*,Self,key001) --> hold>. :\: %1.00;0.91% {5 : 5 : 2} + + OUT: <(*,Self,key001) --> hold>. :\: %0.92;0.92% {6 : 5 : 1;2} + +1 + + OUT: <(*,Self,key001) --> hold>. :\: %0.92;0.92% {12 : 5 : 1;2} + + OUT: <<(*,Self,key001) --> hold> =\> (/,hold,Self,_)>>. :\: %0.00;0.45% {12 : 5 : 1;2} + + OUT: < (/,hold,Self,_)> <(*,Self,key001) --> hold>>. :\: %0.00;0.45% {12 : 5 : 1;2} + +********** [07 + 11 -> 12]: + IN: <(*,key001) --> ^pick>. :\: %1.00;0.90% {0 : -1 : 1} + + IN: <(*,Self,key001) --> hold>. :|: %1.00;0.90% {0 : 0 : 2} + +1 + + OUT: <<(*,Self,key001) --> hold> =\> <(*,key001) --> ^pick>>. :\: %1.00;0.45% {1 : 0 : 1;2} + + OUT: <<(*,key001) --> ^pick> =/> <(*,Self,key001) --> hold>>. :\: %1.00;0.45% {1 : 0 : 1;2} + + OUT: <<(*,key001) --> ^pick> <(*,Self,key001) --> hold>>. :\: %1.00;0.45% {1 : 0 : 1;2} + +********** [05 + 12 -> 13]: + IN: <<(*,key001) --> ^pick> =/> <(*,Self,key001) --> hold>>. :\: %1.00;0.90% {0 : -1 : 1} + + IN: <<(*,key001) --> ^pick> =/> <(*,Self,key001) --> hold>>. :\: %1.00;0.45% {0 : -1 : 2} + +1 + + OUT: <<(*,key001) --> ^pick> =/> <(*,Self,key001) --> hold>>. :\: %1.00;0.91% {1 : -1 : 1;2} + +********** [04 + 13 -> 14]: + IN: <(*,Self,key001) --> reachable>. :|: %1.00;0.90% {0 : 0 : 1} + +1 + + OUT: (/,reachable,_,key001)>. :\: %1.00;0.90% {1 : 0 : 1} + + IN: <<(*,key001) --> ^pick> =/> <(*,Self,key001) --> hold>>. :|: %1.00;0.91% {1 : 1 : 2} + +1 + + OUT: <(&/,<(*,Self,key001) --> reachable>,<(*,key001) --> ^pick>) =/> <(*,Self,key001) --> hold>>. :\: %1.00;0.45% {2 : 1 : 1;2} + diff --git a/nars-dist/Examples-1.3.3/Example-NAL8-5-abridged.txt b/nars-dist/Examples-1.3.3/Example-NAL8-5-abridged.txt new file mode 100755 index 00000000..79e23d53 --- /dev/null +++ b/nars-dist/Examples-1.3.3/Example-NAL8-5-abridged.txt @@ -0,0 +1,67 @@ +*** [01] <(*, Self, key001) --> hold>! +*** [02] (--, <(*, Self, key001) --> hold>). :|: +*** [03] <(&/, <(*, Self, key001) --> reachable>, (^pick, key001)) =/> <(*, Self, key001) --> hold>>. +*** [04] <(*, Self, key001) --> reachable>. :|: + +********** [03 + 04 -> 05]: + IN: <(&/,<(*,Self,key001) --> reachable>,(^pick,key001)) =/> <(*,Self,key001) --> hold>>. + IN: <(*,Self,key001) --> reachable>. :|: +1 + OUT: <(^pick,key001) =/> <(*,Self,key001) --> hold>>. :\: %1.00;0.81% + +********** [05 + 01 -> 06]: + IN: <(^pick,key001) =/> <(*,Self,key001) --> hold>>. :|: %1.00;0.81% + IN: <(*,Self,key001) --> hold>! +3 + OUT: (^pick,key001)! %1.00;0.73% + +********** [06 -> 07]: + IN: (^pick,key001)! %1.00;0.73% {0 : 1} +1 +***EXECUTE: ^pick(key001) + OUT: (^pick,key001). :|: %1.00;0.90% + +********** [07 + 05 -> 08]: + IN: (^pick,key001). :|: + IN: <(^pick,key001) =/> <(*,Self,key001) --> hold>>. :|: %1.00;0.81% +1 + OUT: <(*,Self,key001) --> hold>. :|: %1.00;0.73% + +*** [09] <(*, Self, key001) --> hold>. + +********** [08 + 09 -> 10]: + IN: <(*,Self,key001) --> hold>. :|: %1.00;0.73% +1 + IN: <(*,Self,key001) --> hold>. :|: %1.00;0.90% +1 + OUT: <(*,Self,key001) --> hold>. :\: %1.00;0.91% + +********** [07 + 09 -> 11]: + IN: (^pick,key001). :|: %1.00;0.90% +1 + IN: <(*,Self,key001) --> hold>. :|: +1 + OUT: <(^pick,key001) =/> <(*,Self,key001) --> hold>>. :\: %1.00;0.45% + OUT: <(^pick,key001) =/> <(*,Self,key001) --> hold>>. %1.00;0.45% + +********** [05 + 11 -> 12]: + IN: <(^pick,key001) =/> <(*,Self,key001) --> hold>>. :|: %1.00;0.81% {0 : 0 : 1} +1 + IN: <(^pick,key001) =/> <(*,Self,key001) --> hold>>. :|: %1.00;0.45% {1 : 1 : 2} +1 + OUT: <(^pick,key001) =/> <(*,Self,key001) --> hold>>. :\: %1.00;0.62% {2 : 1 : 1;2} + +********** [04 + 12 -> 13]: + IN: <(*,Self,key001) --> reachable>. :|: +1 + IN: <(^pick,key001) =/> <(*,Self,key001) --> hold>>. :|: %1.00;0.84% +1 + OUT: <(&/,<(*,Self,key001) --> reachable>,(^pick,key001)) =/> <(*,Self,key001) --> hold>>. :\: %1.00;0.43% + OUT: <(&/,<(*,Self,key001) --> reachable>,(^pick,key001)) =/> <(*,Self,key001) --> hold>>. %1.00;0.43% + +********** [03 + 13 -> 14]: + IN: <(&/,<(*,Self,key001) --> reachable>,(^pick,key001)) =/> <(*,Self,key001) --> hold>>. %1.00;0.90% +1 + IN: <(&/,<(*,Self,key001) --> reachable>,(^pick,key001)) =/> <(*,Self,key001) --> hold>>. %1.00;0.43% +1 + OUT: <(&/,<(*,Self,key001) --> reachable>,(^pick,key001)) =/> <(*,Self,key001) --> hold>>. %1.00;0.91% diff --git a/nars-dist/Examples-1.3.3/Example-NAL8-5-complete.txt b/nars-dist/Examples-1.3.3/Example-NAL8-5-complete.txt new file mode 100755 index 00000000..c893f53a --- /dev/null +++ b/nars-dist/Examples-1.3.3/Example-NAL8-5-complete.txt @@ -0,0 +1,116 @@ +*** [01] <(*, Self, key001) --> hold>! +*** [02] (--, <(*, Self, key001) --> hold>). :|: +*** [03] <(&/, <(*, Self, key001) --> reachable>, (^pick, key001)) =/> <(*, Self, key001) --> hold>>. +*** [04] <(*, Self, key001) --> reachable>. :|: +********** [03 + 04 -> 05]: + IN: <(&/,<(*,Self,key001) --> reachable>,<(*,key001) --> ^pick>) =/> <(*,Self,key001) --> hold>>. %1.00;0.90% {0 : 1} + + IN: <(*,Self,key001) --> reachable>. :|: %1.00;0.90% {0 : 0 : 2} + +1 + + OUT: <<(*,key001) --> ^pick> =/> <(*,Self,key001) --> hold>>. :\: %1.00;0.81% {1 : 0 : 1;2} + +********** [05 + 01 -> 06]: + IN: <<(*,key001) --> ^pick> =/> <(*,Self,key001) --> hold>>. :|: %1.00;0.81% {0 : 0 : 1} + + IN: <(*,Self,key001) --> hold>! %1.00;0.90% {0 : 2} + +1 + + OUT: <(*,Self,key001) --> hold>? :|: {1 : 1 : 3} + + OUT: (/,hold,_,key001)>! %1.00;0.90% {1 : 2} + +1 + + OUT: (/,hold,_,key001)>? :|: {2 : 2 : 4} + +1 + + OUT: <(*,key001) --> ^pick>! %1.00;0.73% {3 : 1;2} + +********** [06 -> 07]: + IN: <(*,key001) --> ^pick>! %1.00;0.73% {0 : 1} + +1 + + OUT: <(*,key001) --> ^pick>. :|: %1.00;0.90% {1 : 1 : 2} + +********** [07 + 05 -> 08]: + IN: <(*,key001) --> ^pick>. :|: %1.00;0.90% {0 : 0 : 1} + + IN: <<(*,key001) --> ^pick> =/> <(*,Self,key001) --> hold>>. :|: %1.00;0.81% {0 : 0 : 2} + +1 + + OUT: <(*,Self,key001) --> hold>. :|: %1.00;0.73% {1 : 1 : 2;1} + +*** [09] <(*, Self, key001) --> hold>. +********** [08 + 09 -> 10]: + IN: <(*,Self,key001) --> hold>. :|: %1.00;0.73% {0 : 0 : 1} + +1 + + OUT: (/,hold,_,key001)>. :\: %1.00;0.73% {1 : 0 : 1} + + IN: <(*,Self,key001) --> hold>. :|: %1.00;0.90% {1 : 1 : 2} + +1 + + OUT: <(*,Self,key001) --> hold>. :\: %1.00;0.91% {2 : 1 : 1;2} + +********** [07 + 09 -> 11]: + IN: <(*,key001) --> ^pick>. :|: %1.00;0.90% {0 : 0 : 1} + +1 + + IN: <(*,Self,key001) --> hold>. :|: %1.00;0.90% {1 : 1 : 2} + +1 + + OUT: <<(*,Self,key001) --> hold> =\> <(*,key001) --> ^pick>>. :\: %1.00;0.45% {2 : 1 : 1;2} + + OUT: <<(*,key001) --> ^pick> =/> <(*,Self,key001) --> hold>>. :\: %1.00;0.45% {2 : 1 : 1;2} + + OUT: <<(*,key001) --> ^pick> <(*,Self,key001) --> hold>>. :\: %1.00;0.45% {2 : 1 : 1;2} + + OUT: (/,^pick,_)>. :\: %1.00;0.90% {2 : 0 : 1} + +********** [05 + 11 -> 12]: + IN: <<(*,key001) --> ^pick> =/> <(*,Self,key001) --> hold>>. :|: %1.00;0.81% {0 : 0 : 1} + +1 + + OUT: < (/,^pick,_)> =/> <(*,Self,key001) --> hold>>. :\: %1.00;0.81% {1 : 0 : 1} + + IN: <<(*,key001) --> ^pick> =/> <(*,Self,key001) --> hold>>. :|: %1.00;0.45% {1 : 1 : 2} + +1 + + OUT: <<(*,key001) --> ^pick> =/> <(*,Self,key001) --> hold>>. :\: %1.00;0.62% {2 : 1 : 1;2} + +********** [04 + 12 -> 13]: + IN: <(*,Self,key001) --> reachable>. :|: %1.00;0.90% {0 : 0 : 1} + +1 + + OUT: (/,reachable,_,key001)>. :\: %1.00;0.90% {1 : 0 : 1} + + IN: <<(*,key001) --> ^pick> =/> <(*,Self,key001) --> hold>>. :|: %1.00;0.84% {1 : 1 : 2} + +1 + + OUT: <(&/,<(*,Self,key001) --> reachable>,<(*,key001) --> ^pick>) =/> <(*,Self,key001) --> hold>>. :\: %1.00;0.43% {2 : 1 : 1;2} + +********** [03 + 13 -> 14]: + IN: <(&/,<(*,Self,key001) --> reachable>,<(*,key001) --> ^pick>) =/> <(*,Self,key001) --> hold>>. %1.00;0.90% {0 : 1} + +1 + + IN: <(&/,<(*,Self,key001) --> reachable>,<(*,key001) --> ^pick>) =/> <(*,Self,key001) --> hold>>. :|: %1.00;0.43% {1 : 1 : 2} + +1 + + OUT: <(&/,<(*,Self,key001) --> reachable>,<(*,key001) --> ^pick>) =/> <(*,Self,key001) --> hold>>. :\: %1.00;0.91% {2 : 1 : 1;2} + diff --git a/nars-dist/Examples/Example-MultiStep-edited.txt b/nars-dist/Examples/Example-MultiStep-edited.txt new file mode 100755 index 00000000..732afae8 --- /dev/null +++ b/nars-dist/Examples/Example-MultiStep-edited.txt @@ -0,0 +1,159 @@ +// Set "Parameter/Report Silence Level" to 100 to hide intermediate results + +*** Choice + bird>. +10 + bird>. %1.00;0.80% + bird>. %0.80;0.95% +5 + bird>? +448 + OUT: <(|,robin,(&,penguin,swan)) --> bird>. %1.00;0.68% + OUT: bird>. %0.80;0.95% +291 + OUT: bird>. %1.00;0.80% +46 + OUT: bird>. %1.00;0.90% + +*** Contradiction + beverage>. + coffee>. +(--, coffee>). +10 + coffee>? +1 + OUT: coffee>. %0.50;0.95% +9 + beverage>? +10 + beverage>? +1 + OUT: beverage>. %1.00;0.90% + +*** Confidence and revision +<{Willy} --> swimmer>. + swimmer>. +<{Willy} --> fish>? +2 + OUT: <{Willy} --> fish>. %1.00;0.45% +18 +<{Willy} --> whale>. + [black]>. +<{Willy} --> [black]>? +26 + OUT: <{Willy} --> [black]>. %1.00;0.81% +5 +<{Willy} --> [black]>. %0% +<{Willy} --> fish>. %0% +1 + OUT: <{Willy} --> [black]>. %0.00;0.90% + OUT: <{Willy} --> fish>. %0.00;0.90% +1 + OUT: <{Willy} --> [black]>. %0.32;0.93% + OUT: <{Willy} --> fish>. %0.08;0.91% + +*** Deduction chain +<{Tweety} --> robin>. + bird>. + animal>. +30 +<{Tweety} --> bird>? +1 + OUT: <{Tweety} --> bird>. %1.00;0.81% +9 +<{Tweety} --> animal>? +1 + OUT: <{Tweety} --> animal>. %1.00;0.73% + +*** Resemblance chain + dog>. %0.9% + tiger>. %0.9% + tiger>. %0.9% + lion>? +26 + OUT: lion>. %0.73;0.71% + +*** Induction and revision + swimmer>? + bird>? +10 + bird>. + swimmer>. +8 + OUT: bird>. %1.00;0.45% + OUT: swimmer>. %1.00;0.45% +2 + bird>. + swimmer>. +34 + OUT: bird>. %1.00;0.62% + OUT: swimmer>. %1.00;0.62% +6 + bird>. +(--, swimmer>). +45 + OUT: swimmer>. %0.67;0.71% + +*** Mixed inference + bird>. + swimmer>. +5 + swimmer>? +7 + OUT: swimmer>. +1 + bird>. + swimmer>. +11 + OUT: swimmer>. %1.00;0.62% +20 + [feathered]>. + [feathered]>. +20 + bird>? +10 + OUT: bird>. %1.00;0.45% +1 + swimmer>? +154 + OUT: swimmer>. %1.00;0.28% + +*** Semi-compositionality +<(&,light,[red]) --> traffic_signal>? +5 + traffic_signal>. %0.1% +<[red] --> traffic_signal>. %0.1% +4 + OUT: <(&,light,[red]) --> traffic_signal>. %0.10;0.08% +7 + OUT: <(&,light,[red]) --> traffic_signal>. %0.10;0.15% +154 + OUT: <(&,light,[red]) --> traffic_signal>. %0.19;0.81% +31 +<{light_1} --> (&,light,[red])>. +<{light_1} --> traffic_signal>. +27 + OUT: <(&,light,[red]) --> traffic_signal>. %0.32;0.84% +23 +<{light_2} --> (&,light,[red])>. +<{light_2} --> traffic_signal>. +30 + OUT: <(&,light,[red]) --> traffic_signal>. %0.41;0.85% + +*** Fuzzy concepts +<{John} --> boy>. +<{John} --> (/,taller_than,{Tom},_)>. +5 +<{Tom} --> (/,taller_than,_,boy)>? +246 + OUT: <{Tom} --> (/,taller_than,_,boy)>. %1.00;0.45% +5 +<{David} --> boy>. +(--,<{David} --> (/,taller_than,{Tom},_)>). +113 + OUT: <{Tom} --> (/,taller_than,_,boy)>. %0.50;0.62% +22 +<{Karl} --> boy>. +<{Karl} --> (/,taller_than,{Tom},_)>. +141 + OUT: <{Tom} --> (/,taller_than,_,boy)>. %0.67;0.71% diff --git a/nars-dist/Examples/Example-MultiStep-unedited.txt b/nars-dist/Examples/Example-MultiStep-unedited.txt new file mode 100755 index 00000000..0eb0281b --- /dev/null +++ b/nars-dist/Examples/Example-MultiStep-unedited.txt @@ -0,0 +1,149 @@ +*** Choice + IN: bird>. %1.00;0.90% {0 : 1} +10 + IN: bird>. %1.00;0.80% {10 : 2} + IN: bird>. %0.80;0.95% {10 : 3} +5 + IN: bird>? {15 : 4} +448 + OUT: <(|,robin,(&,penguin,swan)) --> bird>. %1.00;0.68% {338 : 3;1;2} + OUT: bird>. %0.80;0.95% {10 : 3} +291 + OUT: bird>. %1.00;0.80% {10 : 2} +46 + OUT: bird>. %1.00;0.90% {0 : 1} +*** Contradiction + IN: beverage>. %1.00;0.90% {0 : 1} + IN: coffee>. %1.00;0.90% {0 : 2} + IN: (--, coffee>). %1.00;0.90% {0 : 3} +10 + IN: coffee>? {10 : 4} +1 + OUT: coffee>. %0.50;0.95% {5 : 2;3} +9 + IN: beverage>? {20 : 5} +10 + IN: beverage>? {30 : 6} +1 + OUT: beverage>. %1.00;0.90% {0 : 1} +*** Confidence and revision + IN: <{Willy} --> swimmer>. %1.00;0.90% {0 : 1} + IN: swimmer>. %1.00;0.90% {0 : 2} + IN: <{Willy} --> fish>? {0 : 3} +2 + OUT: <{Willy} --> fish>. %1.00;0.45% {1 : 2;1} +18 + IN: <{Willy} --> whale>. %1.00;0.90% {20 : 4} + IN: [black]>. %1.00;0.90% {20 : 5} + IN: <{Willy} --> [black]>? {20 : 6} +26 + OUT: <{Willy} --> [black]>. %1.00;0.81% {45 : 5;4} +5 + IN: <{Willy} --> [black]>. %0.00;0.90% {51 : 7} + IN: <{Willy} --> fish>. %0.00;0.90% {51 : 8} +1 + OUT: <{Willy} --> [black]>. %0.00;0.90% {51 : 7} + OUT: <{Willy} --> fish>. %0.00;0.90% {51 : 8} +1 + OUT: <{Willy} --> [black]>. %0.32;0.93% {52 : 5;7;4} + OUT: <{Willy} --> fish>. %0.08;0.91% {52 : 2;8;1} +*** Deduction chain + IN: <{Tweety} --> robin>. %1.00;0.90% {0 : 1} + IN: bird>. %1.00;0.90% {0 : 2} + IN: animal>. %1.00;0.90% {0 : 3} +30 + IN: <{Tweety} --> bird>? {30 : 4} +1 + OUT: <{Tweety} --> bird>. %1.00;0.81% {1 : 2;1} +9 + IN: <{Tweety} --> animal>? {40 : 5} +1 + OUT: <{Tweety} --> animal>. %1.00;0.73% {20 : 3;1;2} +*** Resemblance chain + IN: dog>. %0.90;0.90% {0 : 1} + IN: tiger>. %0.90;0.90% {0 : 2} + IN: tiger>. %0.90;0.90% {0 : 3} + IN: lion>? {0 : 4} +26 + OUT: lion>. %0.73;0.71% {25 : 3;1;2} +*** Induction and revision + IN: swimmer>? {0 : 1} + IN: bird>? {0 : 2} +10 + IN: bird>. %1.00;0.90% {10 : 3} + IN: swimmer>. %1.00;0.90% {10 : 4} +8 + OUT: bird>. %1.00;0.45% {17 : 4;3} + OUT: swimmer>. %1.00;0.45% {17 : 4;3} +2 + IN: bird>. %1.00;0.90% {20 : 5} + IN: swimmer>. %1.00;0.90% {20 : 6} +34 + OUT: bird>. %1.00;0.62% {53 : 4;6;3;5} + OUT: swimmer>. %1.00;0.62% {53 : 4;6;3;5} +6 + IN: bird>. %1.00;0.90% {60 : 7} + IN: (--, swimmer>). %1.00;0.90% {60 : 8} +45 + OUT: swimmer>. %0.67;0.71% {104 : 4;8;6;7;3;5} +*** Mixed inference + IN: bird>. %1.00;0.90% {0 : 1} + IN: swimmer>. %1.00;0.90% {0 : 2} +5 + IN: swimmer>? {5 : 3} +7 + OUT: swimmer>. %1.00;0.45% {5 : 2;1} +1 + IN: bird>. %1.00;0.90% {13 : 4} + IN: swimmer>. %1.00;0.90% {13 : 5} +11 + OUT: swimmer>. %1.00;0.62% {23 : 2;5;1;4} +20 + IN: [feathered]>. %1.00;0.90% {44 : 6} + IN: [feathered]>. %1.00;0.90% {44 : 7} +20 + IN: bird>? {64 : 8} +10 + OUT: bird>. %1.00;0.45% {73 : 7;6} +1 + IN: swimmer>? {75 : 9} +154 + OUT: swimmer>. %1.00;0.28% {228 : 2;7;5;6;1;4} +*** Semi-compositionality + IN: <(&,light,[red]) --> traffic_signal>? {0 : 1} +5 + IN: traffic_signal>. %0.10;0.90% {5 : 2} + IN: <[red] --> traffic_signal>. %0.10;0.90% {5 : 3} +4 + OUT: <(&,light,[red]) --> traffic_signal>. %0.10;0.08% {8 : 3} +7 + OUT: <(&,light,[red]) --> traffic_signal>. %0.10;0.15% {15 : 3;2} +154 + OUT: <(&,light,[red]) --> traffic_signal>. %0.19;0.81% {169 : 3;2} +31 + IN: <{light_1} --> (&,light,[red])>. %1.00;0.90% {201 : 4} + IN: <{light_1} --> traffic_signal>. %1.00;0.90% {201 : 5} +27 + OUT: <(&,light,[red]) --> traffic_signal>. %0.32;0.84% {227 : 3;4;2;5} +23 + IN: <{light_2} --> (&,light,[red])>. %1.00;0.90% {251 : 6} + IN: <{light_2} --> traffic_signal>. %1.00;0.90% {251 : 7} +30 + OUT: <(&,light,[red]) --> traffic_signal>. %0.41;0.85% {280 : 3;6;4;7;2;5} +*** Fuzzy concepts + IN: <{John} --> boy>. %1.00;0.90% {0 : 1} + IN: <{John} --> (/,taller_than,{Tom},_)>. %1.00;0.90% {0 : 2} +5 + IN: <{Tom} --> (/,taller_than,_,boy)>? {5 : 3} +246 + OUT: <{Tom} --> (/,taller_than,_,boy)>. %1.00;0.45% {250 : 2;1} +5 + IN: <{David} --> boy>. %1.00;0.90% {256 : 4} + IN: (--,<{David} --> (/,taller_than,{Tom},_)>). %1.00;0.90% {256 : 5} +113 + OUT: <{Tom} --> (/,taller_than,_,boy)>. %0.50;0.62% {368 : 2;5;1;4} +22 + IN: <{Karl} --> boy>. %1.00;0.90% {391 : 6} + IN: <{Karl} --> (/,taller_than,{Tom},_)>. %1.00;0.90% {391 : 7} +141 + OUT: <{Tom} --> (/,taller_than,_,boy)>. %0.67;0.71% {531 : 2;7;5;6;1;4} diff --git a/nars-dist/Examples/Example-NAL1-edited.txt b/nars-dist/Examples/Example-NAL1-edited.txt new file mode 100755 index 00000000..e48baf0d --- /dev/null +++ b/nars-dist/Examples/Example-NAL1-edited.txt @@ -0,0 +1,86 @@ +********** revision + swimmer>. +// Bird is a type of swimmer. + swimmer>. %0.10;0.60% +// Bird is probably not a type of swimmer. +1 + OUT: swimmer>. %0.87;0.91% +// Bird is very likely to be a type of swimmer. + +********** deduction + animal>. +// Bird is a type of animal. + bird>. +// Robin is a type of bird. +5 + OUT: animal>. %1.00;0.81% +// Robin is a type of animal. + +********** abduction + competition>. +// Sport is a type of competition. + competition>. %0.90% +// Chess is a type of competition. +5 + OUT: chess>. %1.00;0.42% +// I guess sport is a type of chess. + OUT: sport>. %0.90;0.45% +// I guess chess is a type of sport. + +********* induction + swimmer>. %0.90% +// Swan is a type of swimmer. + bird>. +// Swan is a type of bird. +5 + OUT: swimmer>. %0.90;0.45% +// I guess bird is a type of swimmer. + OUT: bird>. %1.00;0.42% +// I guess swimmer is a type of bird. + +********** exemplification + bird>. +// Robin is a type of bird. + animal>. +// A bird is a type of animal. +5 + OUT: robin>. %1.00;0.45% +// I guess animal is a type of robin. + +********** conversion + swimmer>. +// Bird is a type of swimmer. + bird>? +// Is swimmer a type of bird? +4 + OUT: bird>. %1.00;0.47% +// I guess swimmer is a type of bird. + +********** "y/n" question + swimmer>. +// Bird is a type of swimmer. + swimmer>? +// Is bird a type of swimmer? +1 + OUT: swimmer>. %1.00;0.90% +// Bird is a type of swimmer. + +********** "wh" question + swimmer>. %1.00;0.80% +// Bird is a type of swimmer. + swimmer>? +// What is a type of swimmer? +4 + OUT: swimmer>. %1.00;0.80% +// Bird is a type of swimmer. + +********** backward inference + swimmer>. %1.00;0.80% +// Bird is a type of swimmer. + swimmer>? +// What is a type of swimmer? +4 + OUT: bird>? +// What is a type of bird? + OUT: ?1>? +// What is the type of bird? diff --git a/nars-dist/Examples/Example-NAL1-unedited.txt b/nars-dist/Examples/Example-NAL1-unedited.txt new file mode 100755 index 00000000..38f05885 --- /dev/null +++ b/nars-dist/Examples/Example-NAL1-unedited.txt @@ -0,0 +1,69 @@ +********** revision + IN: swimmer>. %1.00;0.90% {0 : 1} + IN: swimmer>. %0.10;0.60% {0 : 2} +1 + OUT: swimmer>. %0.87;0.91% {1 : 1;2} +********** deduction + IN: animal>. %1.00;0.90% {0 : 1} + IN: bird>. %1.00;0.90% {0 : 2} +5 + OUT: animal>. %1.00;0.81% {5 : 2;1} + OUT: robin>. %1.00;0.45% {5 : 2;1} +********** abduction + IN: competition>. %1.00;0.90% {0 : 1} + IN: competition>. %0.90;0.90% {0 : 2} +5 + OUT: <(|,chess,sport) --> competition>. %0.90;0.81% {5 : 2;1} + OUT: <(&,chess,sport) --> competition>. %1.00;0.81% {5 : 2;1} + OUT: < $1> ==> $1>>. %0.90;0.45% {5 : 2;1} + OUT: < $1> ==> $1>>. %1.00;0.42% {5 : 2;1} + OUT: < $1> <=> $1>>. %0.90;0.45% {5 : 2;1} + OUT: (&&, #1>, #1>). %0.90;0.81% {5 : 2;1} + OUT: chess>. %1.00;0.42% {5 : 2;1} + OUT: sport>. %0.90;0.45% {5 : 2;1} + OUT: sport>. %0.90;0.45% {5 : 2;1} +********* induction + IN: swimmer>. %0.90;0.90% {0 : 1} + IN: bird>. %1.00;0.90% {0 : 2} +5 + OUT: (|,bird,swimmer)>. %1.00;0.81% {5 : 2;1} + OUT: (&,bird,swimmer)>. %0.90;0.81% {5 : 2;1} + OUT: <<$1 --> swimmer> ==> <$1 --> bird>>. %1.00;0.42% {5 : 2;1} + OUT: <<$1 --> bird> ==> <$1 --> swimmer>>. %0.90;0.45% {5 : 2;1} + OUT: <<$1 --> bird> <=> <$1 --> swimmer>>. %0.90;0.45% {5 : 2;1} + OUT: (&&,<#1 --> bird>,<#1 --> swimmer>). %0.90;0.81% {5 : 2;1} + OUT: swimmer>. %0.90;0.45% {5 : 2;1} + OUT: bird>. %1.00;0.42% {5 : 2;1} + OUT: swimmer>. %0.90;0.45% {5 : 2;1} +********** exemplification + IN: bird>. %1.00;0.90% {0 : 1} + IN: animal>. %1.00;0.90% {0 : 2} +5 + OUT: animal>. %1.00;0.81% {5 : 2;1} + OUT: robin>. %1.00;0.45% {5 : 2;1} +********** conversion + IN: swimmer>. %1.00;0.90% {0 : 1} + IN: bird>? {0 : 2} +4 + OUT: bird>. %1.00;0.47% {4 : 1} +********** "y/n" question + IN: swimmer>. %1.00;0.90% {0 : 1} + IN: swimmer>? {0 : 2} +1 + OUT: swimmer>. %1.00;0.90% {0 : 1} +********** "wh" question + IN: swimmer>. %1.00;0.80% {0 : 1} + IN: swimmer>? {0 : 2} +4 + OUT: swimmer>. %1.00;0.80% {0 : 1} + OUT: bird>? {4 : 1;2} + OUT: ?1>? {4 : 1;2} + OUT: bird>? {4 : 1;2} +********** backward inference + IN: swimmer>. %1.00;0.80% {0 : 1} + IN: swimmer>? {0 : 2} +4 + OUT: swimmer>. %1.00;0.80% {0 : 1} + OUT: bird>? {4 : 1;2} + OUT: ?1>? {4 : 1;2} + OUT: bird>? {4 : 1;2} diff --git a/nars-dist/Examples/Example-NAL2-edited.txt b/nars-dist/Examples/Example-NAL2-edited.txt new file mode 100755 index 00000000..985ee78e --- /dev/null +++ b/nars-dist/Examples/Example-NAL2-edited.txt @@ -0,0 +1,166 @@ +********** revision + swan>. +// Robin is similar to swan. + swan>. %0.10;0.60% +// I think robin is not similar to swan. +1 + OUT: swan>. %0.87;0.91% +// Robin is probably similar to swan. + +********** comparison + swimmer>. %0.90% +// Swan is a type of swimmer. + bird>. +// Swan is a type of bird. +5 + OUT: swimmer>. %0.90;0.45% +// I guess that bird is similar to swimmer. + +********** comparison + competition>. +// Sport is a type of competition. + competition>. %0.90% +// Chess is a type of competition. +5 + OUT: sport>. %0.90;0.45% +// I guess chess is similar to sport. + +********** analogy + swimmer>. +// Swan is a type of swimmer. + swan>. +// Gull is similar to swan. +5 + OUT: swimmer>. %1.00;0.81% +// I think gull is a type of swimmer. + +********** analogy + swimmer>. +// Gull is a type of swimmer. + swan>. +// Gull is similar to a swan. +5 + OUT: swimmer>. %1.00;0.81% +// I believe a swan is a type of swimmer. + +********** resemblance + swan>. +// Robin is similar to swan. + swan>. +// Gull is similar to swan. +5 + OUT: robin>. %1.00;0.81% +// Gull is similar to robin. + +********** conversions between inheritance and similarity + bird>. +// Swan is a type of bird. + swan>. %0.10% +// Bird is not a type of swan. +3 + OUT: swan>. %0.10;0.89% +// Bird is different from swan. + +********** conversions between inheritance and similarity + bird>. +// Swan is a type of bird. + swan>. %0.10% +// Bird is different from swan. +3 + OUT: swan>. %0.10;0.74% +// Bird is probably not a type of swan. + +********** conversions between inheritance and similarity + bird>. %0.90% +// Swan is a type of bird. + swan>? +// Is bird similar to swan? +4 + OUT: swan>. %0.90;0.47% +// I guess that bird is similar to swan. + +********** conversions between inheritance and similarity + swan>. %0.90% +// a bird is similar to a swan. + bird>? +// Is swan a type of bird? +4 + OUT: bird>. %0.90;0.81% +// A swan is a type of bird. + +********** translating instance into inheritance +. +// Tweety is a bird. + IN: <{Tweety} --> bird>. %1.00;0.90% +// Tweety is a bird. + +********** translating property into inheritance +. +// Ravens are black. + IN: [black]>. %1.00;0.90% +// Ravens are black. + +********** translating instance-property into inheritance +. +// Tweety is yellow. + IN: <{Tweety} --> [yellow]>. %1.00;0.90% +// Tweety is yellow. + +********** set definition +<{Tweety} --> {Birdie}>. +// Tweety is Birdie. +7 + OUT: <{Birdie} <-> {Tweety}>. %1.00;0.90% +// Birdie is similar to Tweety. + +********** set definition +<[smart] --> [bright]>. +// Smart thing is a type of bright thing. +5 + OUT: <[bright] <-> [smart]>. %1.00;0.90% +// Bright thing is similar to smart thing. + +********** set definition +<{Birdie} <-> {Tweety}>. +// Birdie is similar to Tweety. +5 + OUT: Tweety>. %1.00;0.90% +// Birdie is similar to Tweety. + OUT: <{Tweety} --> {Birdie}>. %1.00;0.90% +// Tweety is Birdie. + +********** set definition +<[bright] <-> [smart]>. +// Bright thing is similar to smart thing. +5 + OUT: smart>. %1.00;0.90% +// Bright is similar to smart. + OUT: <[bright] --> [smart]>. %1.00;0.90% +// Bright thing is a type of smart thing. + +********** structure transformation + Tweety>. %0.90% +// Birdie is similar to Tweety +<{Birdie} <-> {Tweety}>? +// Is Birdie similar to Tweety? +2 + OUT: <{Birdie} <-> {Tweety}>. %0.90;0.90% +// Birdie is similar to Tweety. + +********** structure transformation + smart>. %0.90% +// Bright is similar to smart. +<[bright] --> [smart]>? +// Is bright thing a type of smart thing? +2 + OUT: <[bright] --> [smart]>. %0.90;0.81% +// Bright thing is a type of smart thing. + +********** backward inference + swimmer>. +// Bird is a type of swimmer. +<{?x} --> swimmer>? +// What is a swimmer? +4 + OUT: <{?1} --> bird>? +// What is a bird? diff --git a/nars-dist/Examples/Example-NAL2-unedited.txt b/nars-dist/Examples/Example-NAL2-unedited.txt new file mode 100755 index 00000000..168e905b --- /dev/null +++ b/nars-dist/Examples/Example-NAL2-unedited.txt @@ -0,0 +1,101 @@ +********** revision + IN: swan>. %1.00;0.90% {0 : 1} + IN: swan>. %0.10;0.60% {0 : 2} +1 + OUT: swan>. %0.87;0.91% {1 : 1;2} +********** comparison + IN: swimmer>. %0.90;0.90% {0 : 1} + IN: bird>. %1.00;0.90% {0 : 2} +5 + OUT: (|,bird,swimmer)>. %1.00;0.81% {5 : 2;1} + OUT: (&,bird,swimmer)>. %0.90;0.81% {5 : 2;1} + OUT: <<$1 --> swimmer> ==> <$1 --> bird>>. %1.00;0.42% {5 : 2;1} + OUT: <<$1 --> bird> ==> <$1 --> swimmer>>. %0.90;0.45% {5 : 2;1} + OUT: <<$1 --> bird> <=> <$1 --> swimmer>>. %0.90;0.45% {5 : 2;1} + OUT: (&&,<#1 --> bird>,<#1 --> swimmer>). %0.90;0.81% {5 : 2;1} + OUT: swimmer>. %0.90;0.45% {5 : 2;1} + OUT: bird>. %1.00;0.42% {5 : 2;1} + OUT: swimmer>. %0.90;0.45% {5 : 2;1} +********** comparison + IN: competition>. %1.00;0.90% {0 : 1} + IN: competition>. %0.90;0.90% {0 : 2} +5 + OUT: <(|,chess,sport) --> competition>. %0.90;0.81% {5 : 2;1} + OUT: <(&,chess,sport) --> competition>. %1.00;0.81% {5 : 2;1} + OUT: < $1> ==> $1>>. %0.90;0.45% {5 : 2;1} + OUT: < $1> ==> $1>>. %1.00;0.42% {5 : 2;1} + OUT: < $1> <=> $1>>. %0.90;0.45% {5 : 2;1} + OUT: (&&, #1>, #1>). %0.90;0.81% {5 : 2;1} + OUT: chess>. %1.00;0.42% {5 : 2;1} + OUT: sport>. %0.90;0.45% {5 : 2;1} + OUT: sport>. %0.90;0.45% {5 : 2;1} +********** analogy + IN: swimmer>. %1.00;0.90% {0 : 1} + IN: swan>. %1.00;0.90% {0 : 2} +5 + OUT: swimmer>. %1.00;0.81% {5 : 2;1} +********** analogy + IN: swimmer>. %1.00;0.90% {0 : 1} + IN: swan>. %1.00;0.90% {0 : 2} +5 + OUT: swimmer>. %1.00;0.81% {5 : 2;1} +********** resemblance + IN: swan>. %1.00;0.90% {0 : 1} + IN: swan>. %1.00;0.90% {0 : 2} +5 + OUT: robin>. %1.00;0.81% {5 : 2;1} +********** conversions between inheritance and similarity + IN: bird>. %1.00;0.90% {0 : 1} + IN: swan>. %0.10;0.90% {0 : 2} +3 + OUT: swan>. %0.10;0.81% {3 : 2;1} +********** conversions between inheritance and similarity + IN: bird>. %1.00;0.90% {0 : 1} + IN: swan>. %0.10;0.90% {0 : 2} +3 + OUT: swan>. %0.10;0.73% {3 : 2;1} +********** conversions between inheritance and similarity + IN: bird>. %0.90;0.90% {0 : 1} + IN: swan>? {0 : 2} +4 + OUT: swan>. %0.90;0.47% {4 : 1} +********** conversions between inheritance and similarity + IN: swan>. %0.90;0.90% {0 : 1} + IN: bird>? {0 : 2} +4 + OUT: bird>. %0.90;0.81% {4 : 1} +********** set definition + IN: <{Tweety} --> {Birdie}>. %1.00;0.90% {0 : 1} +7 + OUT: <{Birdie} <-> {Tweety}>. %1.00;0.90% {7 : 1} +********** set definition + IN: <[smart] --> [bright]>. %1.00;0.90% {0 : 1} +5 + OUT: <[bright] <-> [smart]>. %1.00;0.90% {5 : 1} +********** set definition + IN: <{Birdie} <-> {Tweety}>. %1.00;0.90% {0 : 1} +5 + OUT: Tweety>. %1.00;0.90% {5 : 1} + OUT: <{Tweety} --> {Birdie}>. %1.00;0.90% {5 : 1} +********** set definition + IN: <[bright] <-> [smart]>. %1.00;0.90% {0 : 1} +5 + OUT: smart>. %1.00;0.90% {5 : 1} + OUT: <[bright] --> [smart]>. %1.00;0.90% {5 : 1} +********** structure transformation + IN: Tweety>. %0.90;0.90% {0 : 1} + IN: <{Birdie} <-> {Tweety}>? {0 : 2} +2 + OUT: <{Birdie} <-> {Tweety}>. %0.90;0.90% {2 : 1} +********** structure transformation + IN: smart>. %0.90;0.90% {0 : 1} + IN: <[bright] --> [smart]>? {0 : 2} +2 + OUT: <[bright] <-> [smart]>. %0.90;0.90% {2 : 1} +********** backward inference + IN: swimmer>. %1.00;0.90% {0 : 1} + IN: <{?1} --> swimmer>? {0 : 2} +4 + OUT: <{?1} --> bird>? {4 : 1;2} + OUT: {?1}>? {4 : 1;2} + OUT: {?1}>? {4 : 1;2} diff --git a/nars-dist/Examples/Example-NAL3-edited.txt b/nars-dist/Examples/Example-NAL3-edited.txt new file mode 100755 index 00000000..d361497d --- /dev/null +++ b/nars-dist/Examples/Example-NAL3-edited.txt @@ -0,0 +1,143 @@ +********** compound composition, two premises + swimmer>. %0.90% +// Swan is a type of swimmer. + bird>. %0.80% +// Swan is a type of bird. +5 + OUT: (|,bird,swimmer)>. %0.98;0.81% +// Swan is a type of bird or a type of swimmer. + OUT: (&,bird,swimmer)>. %0.72;0.81% +// Swan is a type of swimming bird. + +********** compound composition, two premises + competition>. %0.90% +// Sport is a type of competition. + competition>. %0.80% +// Chess is a type of competition. +5 + OUT: <(|,chess,sport) --> competition>. %0.72;0.81% +// If something is either chess or sport, then it is a competition. + OUT: <(&,chess,sport) --> competition>. %0.98;0.81% +// If something is both chess and sport, then it is a competition. + +********** compound decomposition, two premises + (|,bird,swimmer)>. +// Robin is a type of bird or a type of swimmer. + swimmer>. %0.00% +// Robin is not a type of swimmer. +3 + OUT: bird>. %1.00;0.81% +// Robin is a type of bird. + +********** compound decomposition, two premises + swimmer>. %0.00% +// Robin is not a type of swimmer. + (-,mammal,swimmer)>. %0.00% +// Robin is not a nonswimming mammal. +3 + OUT: mammal>. %0.00;0.81% +// Robin is not a type of mammal. + +********** set operations + {Mars,Pluto,Venus}>. %0.90% +// PlanetX is Mars, Pluto, or Venus. + {Pluto,Saturn}>. %0.70% +// PlanetX is probably Pluto or Saturn. +3 + OUT: {Mars,Pluto,Saturn,Venus}>. %0.97;0.81% +// PlanetX is Mars, Pluto, Saturn, or Venus. + OUT: {Pluto}>. %0.63;0.81% +// PlanetX is probably Pluto. + +********** set operations + IN: {Mars,Pluto,Venus}>. %0.90% +// PlanetX is Mars, Pluto, or Venus. + IN: {Pluto,Saturn}>. %0.10% +// PlanetX is probably neither Pluto nor Saturn. +3 + OUT: {Mars,Pluto,Saturn,Venus}>. %0.91;0.81% +// PlanetX is Mars, Pluto, Saturn, or Venus. + OUT: {Mars,Venus}>. %0.81;0.81% +// PlanetX is either Mars or Venus. + +********** composition on both sides of a statement + animal>. %0.90% +// Bird is a type of animal. +<(&,bird,swimmer) --> (&,animal,swimmer)>? +// Is a swimming bird a type of swimming animal? +2 + OUT: <(&,bird,swimmer) --> (&,animal,swimmer)>. %0.90;0.73% +// A swimming bird is probably a type of swimming animal. + +********** composition on both sides of a statement + animal>. %0.90% +// Bird is a type of animal. +<(-,swimmer,animal) --> (-,swimmer,bird)>? +// Is a nonanimal swimmer a type of a nonbird swimmer? +2 + OUT: <(-,swimmer,animal) --> (-,swimmer,bird)>. %0.90;0.73% +// A nonanimal swimmer is probably a type of nonbird swimmer. + +********** compound composition, one premise + bird>. %0.90% +// Swan is a type of bird. + (|,bird,swimmer)>? +// Is a swan a type of bird or swimmer? +3 + OUT: (|,bird,swimmer)>. %0.90;0.73% +// A swan is probably a type of bird or swimmer. + +********** compound composition, one premise + bird>. %0.90% +// Swan is a type of bird. +<(&,swan,swimmer) --> bird>? +// Is swimming swan a type of bird? +2 + OUT: <(&,swan,swimmer) --> bird>. %0.90;0.73% +// Swimming swan is a type of bird. + +********** compound composition, one premise + bird>. %0.90% +// Swan is a type of bird. + (-,swimmer,bird)>? +// Is swan a type of nonbird swimmer? +3 + OUT: (-,swimmer,bird)>. %0.10;0.73% +// A swan is not a type of nonbird swimmer. + +********** compound composition, one premise + bird>. %0.90% +// Swan is a type of bird. +<(~,swimmer, swan) --> bird>? +// Is being bird what differ swimmer from swan? +2 + OUT: <(~,swimmer, swan) --> bird>. %0.10;0.73% +// What differs swimmer from swan is not being bird. + +********** compound decomposition, one premise + (&,bird,swimmer)>. %0.90% +// Robin is a type of swimming bird. +6 + OUT: bird>. %0.90;0.73% +// Robin is a type of bird. + +********** compound decomposition, one premise + (-,bird,swimmer)>. %0.90% +// Robin is a type of nonswimming bird. +6 + OUT: bird>. %0.90;0.73% +// Robin is a type of bird. + +********** compound decomposition, one premise +<(|, boy, girl) --> youth>. %0.90% +// Boys and gials are youth. +5 + OUT: youth>. %0.90;0.73% +// Boys are youth. + +********** compound decomposition, one premise +<(~, boy, girl) --> [strong]>. %0.90% +// What differs boys from gials are being strong. +5 + OUT: [strong]>. %0.90;0.73% +// Boys are strong. \ No newline at end of file diff --git a/nars-dist/Examples/Example-NAL3-unedited.txt b/nars-dist/Examples/Example-NAL3-unedited.txt new file mode 100755 index 00000000..6bcb41f3 --- /dev/null +++ b/nars-dist/Examples/Example-NAL3-unedited.txt @@ -0,0 +1,114 @@ +********** compound composition, two premises + IN: swimmer>. %0.90;0.90% {0 : 1} + IN: bird>. %0.80;0.90% {0 : 2} +5 + OUT: (|,bird,swimmer)>. %0.98;0.81% {5 : 2;1} + OUT: (&,bird,swimmer)>. %0.72;0.81% {5 : 2;1} + OUT: <<$1 --> swimmer> ==> <$1 --> bird>>. %0.80;0.42% {5 : 2;1} + OUT: <<$1 --> bird> ==> <$1 --> swimmer>>. %0.90;0.39% {5 : 2;1} + OUT: <<$1 --> bird> <=> <$1 --> swimmer>>. %0.73;0.44% {5 : 2;1} + OUT: (&&,<#1 --> bird>,<#1 --> swimmer>). %0.72;0.81% {5 : 2;1} + OUT: swimmer>. %0.90;0.39% {5 : 2;1} + OUT: bird>. %0.80;0.42% {5 : 2;1} + OUT: swimmer>. %0.73;0.44% {5 : 2;1} +********** compound composition, two premises + IN: competition>. %0.90;0.90% {0 : 1} + IN: competition>. %0.80;0.90% {0 : 2} +5 + OUT: <(|,chess,sport) --> competition>. %0.72;0.81% {5 : 2;1} + OUT: <(&,chess,sport) --> competition>. %0.98;0.81% {5 : 2;1} + OUT: < $1> ==> $1>>. %0.80;0.42% {5 : 2;1} + OUT: < $1> ==> $1>>. %0.90;0.39% {5 : 2;1} + OUT: < $1> <=> $1>>. %0.73;0.44% {5 : 2;1} + OUT: (&&, #1>, #1>). %0.72;0.81% {5 : 2;1} + OUT: chess>. %0.90;0.39% {5 : 2;1} + OUT: sport>. %0.80;0.42% {5 : 2;1} + OUT: sport>. %0.73;0.44% {5 : 2;1} +********** compound decomposition, two premises + IN: (|,bird,swimmer)>. %1.00;0.90% {0 : 1} + IN: swimmer>. %0.00;0.90% {0 : 2} +3 + OUT: bird>. %1.00;0.81% {3 : 1;2} +********** compound decomposition, two premises + IN: swimmer>. %0.00;0.90% {0 : 1} + IN: (-,mammal,swimmer)>. %0.00;0.90% {0 : 2} +3 + OUT: mammal>. %0.00;0.81% {3 : 2;1} +********** set operations + IN: {Mars,Pluto,Venus}>. %0.90;0.90% {0 : 1} + IN: {Pluto,Saturn}>. %0.70;0.90% {0 : 2} +3 + OUT: {Mars,Pluto,Saturn,Venus}>. %0.97;0.81% {3 : 1;2} + OUT: {Pluto}>. %0.63;0.81% {3 : 1;2} + OUT: <<$1 --> {Pluto,Saturn}> ==> <$1 --> {Mars,Pluto,Venus}>>. %0.90;0.36% {3 : 1;2} + OUT: <<$1 --> {Mars,Pluto,Venus}> ==> <$1 --> {Pluto,Saturn}>>. %0.70;0.42% {3 : 1;2} + OUT: <<$1 --> {Mars,Pluto,Venus}> <=> <$1 --> {Pluto,Saturn}>>. %0.65;0.44% {3 : 1;2} + OUT: (&&,<#1 --> {Mars,Pluto,Venus}>,<#1 --> {Pluto,Saturn}>). %0.63;0.81% {3 : 1;2} + OUT: <{Mars,Pluto,Venus} --> {Pluto,Saturn}>. %0.70;0.42% {3 : 1;2} + OUT: <{Pluto,Saturn} --> {Mars,Pluto,Venus}>. %0.90;0.36% {3 : 1;2} + OUT: <{Mars,Pluto,Venus} <-> {Pluto,Saturn}>. %0.65;0.44% {3 : 1;2} +********** set operations + IN: {Mars,Pluto,Venus}>. %0.90;0.90% {0 : 1} + IN: {Pluto,Saturn}>. %0.10;0.90% {0 : 2} +3 + OUT: {Mars,Pluto,Saturn,Venus}>. %0.91;0.81% {3 : 1;2} + OUT: {Mars,Venus}>. %0.81;0.81% {3 : 1;2} + OUT: <<$1 --> {Pluto,Saturn}> ==> <$1 --> {Mars,Pluto,Venus}>>. %0.90;0.07% {3 : 1;2} + OUT: <<$1 --> {Mars,Pluto,Venus}> ==> <$1 --> {Pluto,Saturn}>>. %0.10;0.42% {3 : 1;2} + OUT: <<$1 --> {Mars,Pluto,Venus}> <=> <$1 --> {Pluto,Saturn}>>. %0.10;0.42% {3 : 1;2} + OUT: (&&,<#1 --> {Mars,Pluto,Venus}>,<#1 --> {Pluto,Saturn}>). %0.09;0.81% {3 : 1;2} + OUT: <{Mars,Pluto,Venus} --> {Pluto,Saturn}>. %0.10;0.42% {3 : 1;2} + OUT: <{Pluto,Saturn} --> {Mars,Pluto,Venus}>. %0.90;0.07% {3 : 1;2} + OUT: <{Mars,Pluto,Venus} <-> {Pluto,Saturn}>. %0.10;0.42% {3 : 1;2} +********** composition on both sides of a statement + IN: animal>. %0.90;0.90% {0 : 1} + IN: <(&,bird,swimmer) --> (&,animal,swimmer)>? {0 : 2} +2 + OUT: <(&,bird,swimmer) --> animal>. %0.90;0.73% {2 : 1} + OUT: <(&,bird,swimmer) --> (&,animal,swimmer)>. %0.90;0.73% {2 : 1} +********** composition on both sides of a statement + IN: animal>. %0.90;0.90% {0 : 1} + IN: <(-,swimmer,animal) --> (-,swimmer,bird)>? {0 : 2} +2 + OUT: (-,swimmer,animal)>. %0.10;0.73% {2 : 1} + OUT: <(-,swimmer,animal) --> (-,swimmer,bird)>. %0.90;0.73% {2 : 1} +********** compound composition, one premise + IN: bird>. %0.90;0.90% {0 : 1} + IN: (|,bird,swimmer)>? {0 : 2} +3 + OUT: (|,bird,swimmer)>. %0.90;0.73% {3 : 1} + OUT: <(|,swan,swimmer) --> (|,bird,swimmer)>. %0.90;0.73% {3 : 1} +********** compound composition, one premise + IN: bird>. %0.90;0.90% {0 : 1} + IN: <(&,swan,swimmer) --> bird>? {0 : 2} +2 + OUT: <(&,swan,swimmer) --> bird>. %0.90;0.73% {2 : 1} + OUT: <(&,swan,swimmer) --> (&,bird,swimmer)>. %0.90;0.73% {2 : 1} +********** compound composition, one premise + IN: bird>. %0.90;0.90% {0 : 1} + IN: (-,swimmer,bird)>? {0 : 2} +3 + OUT: (-,swimmer,bird)>. %0.10;0.73% {3 : 1} + OUT: <(-,swimmer,bird) --> (-,swimmer,swan)>. %0.90;0.73% {3 : 1} +********** compound composition, one premise + IN: bird>. %0.90;0.90% {0 : 1} + IN: <(~,swimmer,swan) --> bird>? {0 : 2} +2 + OUT: <(~,swimmer,swan) --> bird>. %0.10;0.73% {2 : 1} + OUT: <(~,swimmer,bird) --> (~,swimmer,swan)>. %0.90;0.73% {2 : 1} +********** compound decomposition, one premise + IN: (&,bird,swimmer)>. %0.90;0.90% {0 : 1} +6 + OUT: bird>. %0.90;0.73% {6 : 1} +********** compound decomposition, one premise + IN: (-,bird,swimmer)>. %0.90;0.90% {0 : 1} +6 + OUT: bird>. %0.90;0.73% {6 : 1} +********** compound decomposition, one premise + IN: <(|,boy,girl) --> youth>. %0.90;0.90% {0 : 1} +5 + OUT: youth>. %0.90;0.73% {5 : 1} +********** compound decomposition, one premise + IN: <(~,boy,girl) --> [strong]>. %0.90;0.90% {0 : 1} +5 + OUT: [strong]>. %0.90;0.73% {5 : 1} diff --git a/nars-dist/Examples/Example-NAL4-edited.txt b/nars-dist/Examples/Example-NAL4-edited.txt new file mode 100755 index 00000000..38d8126f --- /dev/null +++ b/nars-dist/Examples/Example-NAL4-edited.txt @@ -0,0 +1,81 @@ +********** structural transformation +<(*,acid,base) --> reaction>. +// An acid and a base can have a reaction. +6 + OUT: (/,reaction,_,base)>. %1.00;0.90% +// Acid can react with base. + OUT: (/,reaction,acid,_)>. %1.00;0.90% +// A base is something that has a reaction with an acid. + +********** structural transformation + (/,reaction,_,base)>. +// Acid can react with base. +7 + OUT: <(*,acid,base) --> reaction>. %1.00;0.90% +// An acid and a base can have a reaction. + OUT: (/,reaction,acid,_)>. %1.00;0.90% +// A base is something that has a reaction with an acid. + +********** structural transformation + (/,reaction,acid,_)>. +// A base is something that has a reaction with an acid. +7 + OUT: (/,reaction,_,base)>. %1.00;0.90% +// Acid can react with base. + OUT: <(*,acid,base) --> reaction>. %1.00;0.90% +// An acid and a base can have a reaction. + +********** structural transformation + (*,acid,base)>. +// Neutralization is a relation between an acid and a base. +7 + OUT: <(\,neutralization,_,base) --> acid>. %1.00;0.90% +// Something that can neutralize a base is an acid. + OUT: <(\,neutralization,acid,_) --> base>. %1.00;0.90% +// Something that can be neutralized by an acid is a base. + +********** structural transformation +<(\,neutralization,_,base) --> acid>. +// Something that can neutralize a base is an acid. +6 + OUT: (*,acid,base)>. %1.00;0.90% +// Neutralization is a relation between an acid and a base. + OUT: <(\,neutralization,acid,_) --> base>. %1.00;0.90% +// Something that can be neutralized by an acid is a base. + +********** structural transformation +<(\,neutralization,acid,_) --> base>. +// Something that can be neutralized by an acid is a base. +6 + OUT: <(\,neutralization,_,base) --> acid>. %1.00;0.90% +// Something that can neutralize a base is an acid. + OUT: (*,acid,base)>. %1.00;0.90% +// Neutralization is a relation between an acid and a base. + +********** composition on both sides of a statement + animal>. +// Bird is a type of animal. +<(*,bird,plant) --> ?x>? +// What is the relation between a bird and a plant? +17 + OUT: <(*,bird,plant) --> (*,animal,plant)>. %1.00;0.81% +// The relation between bird and plant is a type of relation between animal and plant. + +********** composition on both sides of a statement + reaction>. +// Neutralization is a type of reaction. +<(\,neutralization,acid,_) --> ?x>? +// What can be neutralized by acid? +17 + OUT: <(\,neutralization,acid,_) --> (\,reaction,acid,_)>. %1.00;0.81% +// What can be neutralized by acid can react with acid. + +********** composition on both sides of a statement + base>. +// Soda is a type of base. +<(/,neutralization,_,base) --> ?x>? +// What is something that can neutralize a base? +17 + OUT: <(/,neutralization,_,base) --> (/,neutralization,_,soda)>. %1.00;0.81% +// What can neutraliz base can react with base. + diff --git a/nars-dist/Examples/Example-NAL4-unedited.txt b/nars-dist/Examples/Example-NAL4-unedited.txt new file mode 100755 index 00000000..0ae5baa2 --- /dev/null +++ b/nars-dist/Examples/Example-NAL4-unedited.txt @@ -0,0 +1,57 @@ +********** structural transformation + IN: <(*,acid,base) --> reaction>. %1.00;0.90% {0 : 1} +6 + OUT: (/,reaction,_,base)>. %1.00;0.90% {6 : 1} + OUT: (/,reaction,acid,_)>. %1.00;0.90% {6 : 1} +********** structural transformation + IN: (/,reaction,_,base)>. %1.00;0.90% {0 : 1} +7 + OUT: <(*,acid,base) --> reaction>. %1.00;0.90% {7 : 1} + OUT: (/,reaction,acid,_)>. %1.00;0.90% {7 : 1} +********** structural transformation + IN: (/,reaction,acid,_)>. %1.00;0.90% {0 : 1} +7 + OUT: (/,reaction,_,base)>. %1.00;0.90% {7 : 1} + OUT: <(*,acid,base) --> reaction>. %1.00;0.90% {7 : 1} +********** structural transformation + IN: (*,acid,base)>. %1.00;0.90% {0 : 1} +7 + OUT: <(\,neutralization,_,base) --> acid>. %1.00;0.90% {7 : 1} + OUT: <(\,neutralization,acid,_) --> base>. %1.00;0.90% {7 : 1} +********** structural transformation + IN: <(\,neutralization,_,base) --> acid>. %1.00;0.90% {0 : 1} +6 + OUT: (*,acid,base)>. %1.00;0.90% {6 : 1} + OUT: <(\,neutralization,acid,_) --> base>. %1.00;0.90% {6 : 1} +********** structural transformation + IN: <(\,neutralization,acid,_) --> base>. %1.00;0.90% {0 : 1} +6 + OUT: <(\,neutralization,_,base) --> acid>. %1.00;0.90% {6 : 1} + OUT: (*,acid,base)>. %1.00;0.90% {6 : 1} +********** composition on both sides of a statement + IN: animal>. %1.00;0.90% {0 : 1} + IN: <(*,bird,plant) --> ?1>? {0 : 2} +3 + OUT: (/,?1,_,plant)>? {3 : 2} + OUT: (/,?1,bird,_)>? {3 : 2} +4 + OUT: (/,?1,_,plant)>? {7 : 2} + OUT: (/,?1,bird,_)>? {7 : 2} +10 + OUT: <(*,bird,plant) --> (*,animal,plant)>. %1.00;0.81% {17 : 1} +********** composition on both sides of a statement + IN: reaction>. %1.00;0.90% {0 : 1} + IN: <(\,neutralization,acid,_) --> ?1>? {0 : 2} +3 + OUT: <(\,neutralization,_,?1) --> acid>? {3 : 2} + OUT: (*,acid,?1)>? {3 : 2} +4 + OUT: <(\,neutralization,_,?1) --> acid>? {7 : 2} + OUT: (*,acid,?1)>? {7 : 2} +10 + OUT: <(\,neutralization,acid,_) --> (\,reaction,acid,_)>. %1.00;0.81% {17 : 1} +********** composition on both sides of a statement + IN: base>. %1.00;0.90% {0 : 1} + IN: <(/,neutralization,_,base) --> ?1>? {0 : 2} +17 + OUT: <(/,neutralization,_,base) --> (/,neutralization,_,soda)>. %1.00;0.81% {17 : 1} diff --git a/nars-dist/Examples/Example-NAL5-edited.txt b/nars-dist/Examples/Example-NAL5-edited.txt new file mode 100755 index 00000000..58adba90 --- /dev/null +++ b/nars-dist/Examples/Example-NAL5-edited.txt @@ -0,0 +1,278 @@ +********** revision +< [flying]> ==> bird>>. +// If robin can fly then robin is a type of bird. +< [flying]> ==> bird>>. %0.00;0.60% +// If robin can fly then robin may not a type of bird. +1 + OUT: < [flying]> ==> bird>>. %0.86;0.91% +// If robin can fly then robin is a type of bird. + +********** deduction +< bird> ==> animal>>. +// If robin is a type of bird then robin is a type of animal. +< [flying]> ==> bird>>. +// If robin can fly then robin is a type of bird. +1 + OUT: < [flying]> ==> animal>>. %1.00;0.81% +// If robin can fly then robin is a type of animal. + +********** exemplification +< [flying]> ==> bird>>. +// If robin can fly then robin is a type of bird. +< bird> ==> animal>>. +// If robin is a type of bird then robin is a type of animal. +1 + OUT: < animal> ==> [flying]>>. %1.00;0.45% +// I guess if robin is a type of animal then robin can fly. + +********** induction +< bird> ==> animal>>. +// If robin is a type of bird then robin is a type of animal. +< bird> ==> [flying]>>. %0.80% +// If robin is a type of bird then robin can fly. +1 + OUT: < [flying]> ==> animal>>. %1.00;0.39% +// I guess if robin can fly then robin is a type of animal. + OUT: < animal> ==> [flying]>>. %0.80;0.45% +// I guess if robin is a type of animal then robin can fly. + +********** abduction +< bird> ==> animal>>. +// If robin is a type of bird then robin is a type of animal. +< [flying]> ==> animal>>. %0.8% +// If robin can fly then robin is probably a type of animal. +1 + OUT: < bird> ==> [flying]>>. %1.00;0.39% +// I guess if robin is a type of bird then robin can fly. + OUT: < [flying]> ==> bird>>. %0.80;0.45% +// I guess if robin can fly then robin is a type of bird. + +********** detachment +< bird> ==> animal>>. +// If robin is a type of bird then robin can fly. + bird>. +// Robin is a type of bird. +1 + OUT: animal>. %1.00;0.81% +// Robin is a type of animal. + +********** detachment +< bird> ==> animal>>. %0.70;0.90% +// Usually if robin is a type of bird then robin is a type of animal. + animal>. +// Robin is a type of animal. +1 + OUT: bird>. %1.00;0.36% +// I guess robin is a type of bird. + +********** comparison +< bird> ==> animal>>. +// If robin is a type of bird then robin is a type of animal. +< bird> ==> [flying]>>. %0.80% +// If robin is a type of bird then robin can fly. +1 + OUT: < animal> <=> [flying]>>. %0.80;0.45% +// I guess robin is a type of animal if and only if robin can fly. + +********** comparison +< bird> ==> animal>>. %0.70% +// If robin is a type of bird then usually robin is a type of animal. +< [flying]> ==> animal>>. +// If robin can fly then robin is a type of animal. +1 + OUT: < bird> <=> [flying]>>. %0.70;0.45% +// I guess robin is a type of bird if and only if robin can fly. + +********** analogy +< bird> ==> animal>>. +// If robin is a type of bird then robin is a type of animal. +< bird> <=> [flying]>>. %0.80% +// Usually, robin is a type of bird if and only if robin can fly. +1 + OUT: < [flying]> ==> animal>>. %0.80;0.65% +// If robin can fly then probably robin is a type of animal. + +********** analogy + bird>. +// Robin is a type of bird. +< bird> <=> [flying]>>. %0.80% +// Usually, robin is a type of bird if and only if robin can fly. +1 + OUT: [flying]>. %0.80;0.65% +// I guess usually robin can fly. + +********** resemblance +< animal> <=> bird>>. +// Robin is a type of animal if and only if robin is a type of bird. +< bird> <=> [flying]>>. %0.9% +// Robin is a type of bird if and only if robin can fly. +1 + OUT: < animal> <=> [flying]>>. %0.90;0.81% +// Robin is a type of animal if and only if robin can fly. + +********** conversions between Implication and Equivalence +< [flying]> ==> bird>>. %0.9% +// If robin can fly then robin is a type of bird. +< bird> ==> [flying]>>. %0.9% +// If robin is a type of bird then robin can fly. +1 + OUT: < bird> <=> [flying]>>. %0.81;0.81% +// Robin can fly if and only if robin is a type of bird. + +********** compound composition, two premises +< bird> ==> animal>>. +// If robin is a type of bird then robin is a type of animal. +< bird> ==> [flying]>>. %0.9% +// If robin is a type of bird then robin can fly. +1 + OUT: < bird> ==> (||, [flying]>, animal>)>. %1.00;0.81% +// If robin is a type of bird then robin is a type of animal or can fly. + OUT: < bird> ==> (&&, [flying]>, animal>)>. %0.90;0.81% +// If robin is a type of bird then usually robin is a type of animal and can fly. + +********** compound composition, two premises +< bird> ==> animal>>. +// If robin is a type of bird then robin is a type of animal. +< [flying]> ==> animal>>. %0.9% +// If robin can fly then robin is a type of animal. +1 + OUT: <(&&, [flying]>, bird>) ==> animal>>. %1.00;0.81% +// If robin can fly and is a type of bird then robin is a type of animal. + OUT: <(||, [flying]>, bird>) ==> animal>>. %0.90;0.81% +// If robin can fly or is a type of bird then robin is a type of animal. + +********** compound decomposition, two premises +< bird> ==> (&&, animal>, [flying]>)>. %0% +// If robin is a type of bird then robin is not a type of flying animal. +< bird> ==> [flying]>>. +// If robin is a type of bird then robin can fly. +1 + OUT: < bird> ==> animal>>. %0.00;0.81% +// It is unlikely that if a robin is a type of bird then robin is a type of animal. + +********** compound decomposition, two premises +(&&, [flying]>, swimmer>). %0% +// Robin cannot be both a flyer and a swimmer. + [flying]>. +// Robin can fly. +4 + OUT: swimmer>. %0.00;0.81% +// Robin cannot swim. + +********** compound decomposition, two premises +(||, [flying]>, swimmer>). +// Robin can fly or swim. + swimmer>. %0% +// Robin cannot swim. +1 + OUT: [flying]>. %1.00;0.81% + // Robin can fly. + +********** compound composition, one premises + [flying]>. +// Robin can fly. +(||, [flying]>, swimmer>)? +// Can robin fly or swim? +5 + OUT: (||, swimmer>, [flying]>). %1.00;0.81% +// Robin can fly or swim. + +********** compound decomposition, one premises +(&&, swimmer>, [flying]>). %0.9% +// Robin can fly and swim. +2 + OUT: swimmer>. %0.90;0.73% +// Robin can swim. +6 + OUT: [flying]>. %0.90;0.73% +// Robin can fly. + +********** negation +(--, [flying]>). %0.1% +// It is unlikely that robin cannot fly. +1 + OUT: [flying]>. %0.90;0.90% +// Robin can fly. + +********** negation + [flying]>. %0.9% +// Robin can fly. +(--, [flying]>)? +// Can robin fly or not? +1 + OUT: (--, [flying]>). %0.10;0.90% +// It is unlikely that robin cannot fly. + +********** contraposition +<(--, bird>) ==> [flying]>>. %0.1% +// It is unlikely that if robin is not a type of bird then robin can fly. +<(--, [flying]>) ==> bird>>? +// If robin cannot fly then is robin a type of bird? +18 + OUT: <(--, [flying]>) ==> bird>>. %0.00;0.45% +// I guess it is unlikely that if robin cannot fly then robin is a type of bird. + +********** conditional deduction +<(&&, [flying]>, [with-wings]>) ==> bird>>. +// If robin can fly and has wings then robin is a bird. + [flying]>. +// robin can fly. +3 + OUT: < [with-wings]> ==> bird>>. %1.00;0.81% +// If robin has wings then robin is a bird + +********** conditional deduction +<(&&, [chirping]>, [flying]>, [with-wings]>) ==> bird>>. +// If robin can fly, has wings, and chirps, then robin is a bird + [flying]>. +// robin can fly. +5 + OUT: <(&&, [chirping]>, [with-wings]>) ==> bird>>. %1.00;0.81% +// If robin has wings and chirps then robin is a bird. + +********** conditional deduction +<(&&, bird>, [living]>) ==> animal>>. +// If robin is a bird and it's living, then robin is an animal +< [flying]> ==> bird>>. +// If robin can fly, then robin is a bird +14 + OUT: <(&&, [flying]>, [living]>) ==> animal>>. %1.00;0.81% +// If robin is living and it can fly, then robin is an animal. + +********** conditional abduction +< [flying]> ==> bird>>. +// If robin can fly then robin is a bird. +<(&&, swimmer>, [flying]>) ==> bird>>. +// If robin both swims and flys then robin is a bird. +15 + OUT: swimmer>. %1.00;0.45% +// I guess robin swims. + +********** conditional abduction +<(&&, [with-wings]>, [chirping]>) ==> bird>>. +// If robin is has wings and chirps, then robin is a bird +<(&&, [flying]>, [with-wings]>, [chirping]>) ==> bird>>. +// If robin can fly, has wings, and chirps, then robin is a bird +8 + OUT: [flying]>. %1.00;0.45% +// I guess that robin can fly. + +********** conditional abduction +<(&&, [flying]>, [with-wings]>) ==> [living]>>. %0.9% +// If robin can fly and it has wings, then robin is living. +<(&&, [flying]>, bird>) ==> [living]>>. +// If robin can fly and robin is a bird then robin is living. +8 + OUT: < bird> ==> [with-wings]>>. %1.00;0.42% +// I guess if robin is a bird, then robin has wings. + OUT: < [with-wings]> ==> bird>>. %0.90;0.45% +// I guess if robin has wings, then robin is a bird. + +********** conditional induction +<(&&, [chirping]>, [flying]>) ==> bird>>. +// If robin can fly and robin chirps, then robin is a bird +< [flying]> ==> [with-beak]>>. %0.90% +// If robin can fly then usually robin has a beak. +11 + OUT: <(&&, [chirping]>, [with-beak]>) ==> bird>>. %1.00;0.42% +// I guess that if robin chirps and robin has a beak, then robin is a bird. diff --git a/nars-dist/Examples/Example-NAL5-unedited.txt b/nars-dist/Examples/Example-NAL5-unedited.txt new file mode 100755 index 00000000..20f12f32 --- /dev/null +++ b/nars-dist/Examples/Example-NAL5-unedited.txt @@ -0,0 +1,191 @@ +********** revision + IN: < [flying]> ==> bird>>. %1.00;0.90% {0 : 1} + IN: < [flying]> ==> bird>>. %0.00;0.60% {0 : 2} +1 + OUT: < [flying]> ==> bird>>. %0.86;0.91% {1 : 1;2} +********** deduction + IN: < bird> ==> animal>>. %1.00;0.90% {0 : 1} + IN: < [flying]> ==> bird>>. %1.00;0.90% {0 : 2} +1 + OUT: < [flying]> ==> animal>>. %1.00;0.81% {1 : 2;1} + OUT: < animal> ==> [flying]>>. %1.00;0.45% {1 : 2;1} +********** exemplification + IN: < [flying]> ==> bird>>. %1.00;0.90% {0 : 1} + IN: < bird> ==> animal>>. %1.00;0.90% {0 : 2} +1 + OUT: < [flying]> ==> animal>>. %1.00;0.81% {1 : 2;1} + OUT: < animal> ==> [flying]>>. %1.00;0.45% {1 : 2;1} +********** induction + IN: < bird> ==> animal>>. %1.00;0.90% {0 : 1} + IN: < bird> ==> [flying]>>. %0.80;0.90% {0 : 2} +1 + OUT: < bird> ==> (||, animal>, [flying]>)>. %1.00;0.81% {1 : 2;1} + OUT: < bird> ==> (&&, animal>, [flying]>)>. %0.80;0.81% {1 : 2;1} + OUT: < [flying]> ==> animal>>. %1.00;0.39% {1 : 2;1} + OUT: < animal> ==> [flying]>>. %0.80;0.45% {1 : 2;1} + OUT: < animal> <=> [flying]>>. %0.80;0.45% {1 : 2;1} +********** abduction + IN: < bird> ==> animal>>. %1.00;0.90% {0 : 1} + IN: < [flying]> ==> animal>>. %0.80;0.90% {0 : 2} +1 + OUT: <(||, bird>, [flying]>) ==> animal>>. %0.80;0.81% {1 : 2;1} + OUT: <(&&, bird>, [flying]>) ==> animal>>. %1.00;0.81% {1 : 2;1} + OUT: < bird> ==> [flying]>>. %1.00;0.39% {1 : 2;1} + OUT: < [flying]> ==> bird>>. %0.80;0.45% {1 : 2;1} + OUT: < bird> <=> [flying]>>. %0.80;0.45% {1 : 2;1} +********** detachment + IN: < bird> ==> animal>>. %1.00;0.90% {0 : 1} + IN: bird>. %1.00;0.90% {0 : 2} +1 + OUT: animal>. %1.00;0.81% {1 : 1;2} +********** detachment + IN: < bird> ==> animal>>. %0.70;0.90% {0 : 1} + IN: animal>. %1.00;0.90% {0 : 2} +1 + OUT: bird>. %1.00;0.36% {1 : 1;2} +********** comparison + IN: < bird> ==> animal>>. %1.00;0.90% {0 : 1} + IN: < bird> ==> [flying]>>. %0.80;0.90% {0 : 2} +1 + OUT: < bird> ==> (||, animal>, [flying]>)>. %1.00;0.81% {1 : 2;1} + OUT: < bird> ==> (&&, animal>, [flying]>)>. %0.80;0.81% {1 : 2;1} + OUT: < [flying]> ==> animal>>. %1.00;0.39% {1 : 2;1} + OUT: < animal> ==> [flying]>>. %0.80;0.45% {1 : 2;1} + OUT: < animal> <=> [flying]>>. %0.80;0.45% {1 : 2;1} +********** comparison + IN: < bird> ==> animal>>. %0.70;0.90% {0 : 1} + IN: < [flying]> ==> animal>>. %1.00;0.90% {0 : 2} +1 + OUT: <(||, bird>, [flying]>) ==> animal>>. %0.70;0.81% {1 : 2;1} + OUT: <(&&, bird>, [flying]>) ==> animal>>. %1.00;0.81% {1 : 2;1} + OUT: < bird> ==> [flying]>>. %0.70;0.45% {1 : 2;1} + OUT: < [flying]> ==> bird>>. %1.00;0.36% {1 : 2;1} + OUT: < bird> <=> [flying]>>. %0.70;0.45% {1 : 2;1} +********** analogy + IN: < bird> ==> animal>>. %1.00;0.90% {0 : 1} + IN: < bird> <=> [flying]>>. %0.80;0.90% {0 : 2} +1 + OUT: < [flying]> ==> animal>>. %0.80;0.65% {1 : 2;1} +********** analogy + IN: bird>. %1.00;0.90% {0 : 1} + IN: < bird> <=> [flying]>>. %0.80;0.90% {0 : 2} +1 + OUT: [flying]>. %0.80;0.65% {1 : 1;2} +********** resemblance + IN: < animal> <=> bird>>. %1.00;0.90% {0 : 1} + IN: < bird> <=> [flying]>>. %0.90;0.90% {0 : 2} +1 + OUT: < animal> <=> [flying]>>. %0.90;0.81% {1 : 2;1} +********** conversions between Implication and Equivalence + IN: < [flying]> ==> bird>>. %0.90;0.90% {0 : 1} + IN: < bird> ==> [flying]>>. %0.90;0.90% {0 : 2} +1 + OUT: < bird> <=> [flying]>>. %0.81;0.81% {1 : 2;1} +********** compound composition, two premises + IN: < bird> ==> animal>>. %1.00;0.90% {0 : 1} + IN: < bird> ==> [flying]>>. %0.90;0.90% {0 : 2} +1 + OUT: < bird> ==> (||, animal>, [flying]>)>. %1.00;0.81% {1 : 2;1} + OUT: < bird> ==> (&&, animal>, [flying]>)>. %0.90;0.81% {1 : 2;1} + OUT: < [flying]> ==> animal>>. %1.00;0.42% {1 : 2;1} + OUT: < animal> ==> [flying]>>. %0.90;0.45% {1 : 2;1} + OUT: < animal> <=> [flying]>>. %0.90;0.45% {1 : 2;1} +********** compound composition, two premises + IN: < bird> ==> animal>>. %1.00;0.90% {0 : 1} + IN: < [flying]> ==> animal>>. %0.90;0.90% {0 : 2} +1 + OUT: <(||, bird>, [flying]>) ==> animal>>. %0.90;0.81% {1 : 2;1} + OUT: <(&&, bird>, [flying]>) ==> animal>>. %1.00;0.81% {1 : 2;1} + OUT: < bird> ==> [flying]>>. %1.00;0.42% {1 : 2;1} + OUT: < [flying]> ==> bird>>. %0.90;0.45% {1 : 2;1} + OUT: < bird> <=> [flying]>>. %0.90;0.45% {1 : 2;1} +********** compound decomposition, two premises + IN: < bird> ==> (&&, animal>, [flying]>)>. %0.00;0.90% {0 : 1} + IN: < bird> ==> [flying]>>. %1.00;0.90% {0 : 2} +1 + OUT: < bird> ==> animal>>. %0.00;0.81% {1 : 2;1} +********** compound decomposition, two premises + IN: (&&, swimmer>, [flying]>). %0.00;0.90% {0 : 1} + IN: [flying]>. %1.00;0.90% {0 : 2} +2 + OUT: swimmer>. %0.00;0.00% {2 : 1;2} +1 + OUT: swimmer>. %0.00;0.00% {3 : 1} +1 + OUT: swimmer>. %0.00;0.81% {4 : 1;2} +********** compound decomposition, two premises + IN: (||, swimmer>, [flying]>). %1.00;0.90% {0 : 1} + IN: swimmer>. %0.00;0.90% {0 : 2} +1 + OUT: [flying]>. %1.00;0.81% {1 : 1;2} +********** compound composition, one premises + IN: [flying]>. %1.00;0.90% {0 : 1} + IN: (||, swimmer>, [flying]>)? {0 : 2} +1 + OUT: swimmer>? {1 : 2} +3 + OUT: <[flying] --> swimmer>? {4 : 1;2} + OUT: [flying]>? {4 : 1;2} + OUT: [flying]>? {4 : 1;2} +1 + OUT: (||, swimmer>, [flying]>). %1.00;0.81% {5 : 1} +********** compound decomposition, one premises + IN: (&&, swimmer>, [flying]>). %0.90;0.90% {0 : 1} +2 + OUT: swimmer>. %0.90;0.73% {2 : 1} +6 + OUT: [flying]>. %0.90;0.73% {8 : 1} +********** negation + IN: (--, [flying]>). %0.10;0.90% {0 : 1} +1 + OUT: [flying]>. %0.90;0.90% {1 : 1} +********** negation + IN: [flying]>. %0.90;0.90% {0 : 1} + IN: (--, [flying]>)? {0 : 2} +1 + OUT: (--, [flying]>). %0.10;0.90% {1 : 1} +********** contraposition + IN: <(--, bird>) ==> [flying]>>. %0.10;0.90% {0 : 1} + IN: <(--, [flying]>) ==> bird>>? {0 : 2} +7 + OUT: <(--, bird>) ==> [flying]>>? {7 : 2} + OUT: <(--, bird>) ==> [flying]>>? {7 : 2} + OUT: <(--, bird>) ==> [flying]>>? {7 : 2} +11 + OUT: <(--, [flying]>) ==> bird>>. %0.00;0.45% {18 : 1} +********** conditional deduction + IN: <(&&, [flying]>, [with-wings]>) ==> bird>>. %1.00;0.90% {0 : 1} + IN: [flying]>. %1.00;0.90% {0 : 2} +3 + OUT: < [with-wings]> ==> bird>>. %1.00;0.81% {3 : 2;1} +********** conditional deduction + IN: <(&&, [chirping]>, [flying]>, [with-wings]>) ==> bird>>. %1.00;0.90% {0 : 1} + IN: [flying]>. %1.00;0.90% {0 : 2} +5 + OUT: <(&&, [chirping]>, [with-wings]>) ==> bird>>. %1.00;0.81% {5 : 1;2} +********** conditional deduction + IN: <(&&, bird>, [living]>) ==> animal>>. %1.00;0.90% {0 : 1} + IN: < [flying]> ==> bird>>. %1.00;0.90% {0 : 2} +14 + OUT: <(&&, [flying]>, [living]>) ==> animal>>. %1.00;0.81% {14 : 2;1} +********** conditional abduction + IN: < [flying]> ==> bird>>. %1.00;0.90% {0 : 1} + IN: <(&&, swimmer>, [flying]>) ==> bird>>. %1.00;0.90% {0 : 2} +15 + OUT: swimmer>. %1.00;0.45% {15 : 1;2} +********** conditional abduction + IN: <(&&, [chirping]>, [with-wings]>) ==> bird>>. %1.00;0.90% {0 : 1} + IN: <(&&, [chirping]>, [flying]>, [with-wings]>) ==> bird>>. %1.00;0.90% {0 : 2} +8 + OUT: [flying]>. %1.00;0.45% {8 : 1;2} +********** conditional abduction + IN: <(&&, [flying]>, [with-wings]>) ==> [living]>>. %0.90;0.90% {0 : 1} + IN: <(&&, bird>, [flying]>) ==> [living]>>. %1.00;0.90% {0 : 2} +8 + OUT: < bird> ==> [with-wings]>>. %1.00;0.42% {8 : 2;1} + OUT: < [with-wings]> ==> bird>>. %0.90;0.45% {8 : 2;1} +********** conditional induction + IN: <(&&, [chirping]>, [flying]>) ==> bird>>. %1.00;0.90% {0 : 1} + IN: < [flying]> ==> [with-beak]>>. %0.90;0.90% {0 : 2} +11 + OUT: <(&&, [chirping]>, [with-beak]>) ==> bird>>. %1.00;0.42% {11 : 1;2} diff --git a/nars-dist/Examples/Example-NAL6-edited.txt b/nars-dist/Examples/Example-NAL6-edited.txt new file mode 100755 index 00000000..2157ab57 --- /dev/null +++ b/nars-dist/Examples/Example-NAL6-edited.txt @@ -0,0 +1,235 @@ +********** variable unification +<<$x --> bird> ==> <$x --> flyer>>. +// If something is a bird, then it is a flyer. +<<$y --> bird> ==> <$y --> flyer>>. %0.00;0.70% +// If something is a bird, then it is not a flyer. +1 + OUT: <<$1 --> bird> ==> <$1 --> flyer>>. %0.79;0.92% +// If something is a bird, then usually, it is a flyer. + +********** variable unification +<<$x --> bird> ==> <$x --> animal>>. +// If something is a bird, then it is a animal. +<<$y --> robin> ==> <$y --> bird>>. +// If something is a robin, then it is a bird. +5 + OUT: <<$1 --> robin> ==> <$1 --> animal>>. %1.00;0.81% +// If something is a robin, then it is a animal. + OUT: <<$1 --> animal> ==> <$1 --> robin>>. %1.00;0.45% + // I guess that if something is a animal, then it is a robin. + +********** variable unification +<<$x --> swan> ==> <$x --> bird>>. %1.00;0.80% +// If something is a swan, then it is a bird. +<<$y --> swan> ==> <$y --> swimmer>>. %0.80% +// If something is a swan, then it is a swimmer. +5 + OUT: <<$1 --> swan> ==> (||,<$1 --> bird>,<$1 --> swimmer>)>. %1.00;0.72% +// I believe that if something is a swan, then it is a bird or a swimmer. + OUT: <<$1 --> swan> ==> (&&,<$1 --> bird>,<$1 --> swimmer>)>. %0.80;0.72% +//I believe that if something is a swan, then usually, it is both a bird and a swimmer. + OUT: <<$1 --> swimmer> ==> <$1 --> bird>>. %1.00;0.37% +// I guess if something is a swimmer, then it is a bird. + OUT: <<$1 --> bird> ==> <$1 --> swimmer>>. %0.80;0.42% +// I guess if something is a bird, then it is a swimmer. + OUT: <<$1 --> bird> <=> <$1 --> swimmer>>. %0.80;0.42% +// I guess something is a bird, if and only if it is a swimmer. + +********** variable unification +< $x> ==> $x>>. +// What can be said about bird can also be said about robin. +< $y> ==> $y>>. %0.70;0.90% +// What can be said about swimmer usually can also be said about robin. +5 + OUT: <(&&, $1>, $1>) ==> $1>>. %1.00;0.81% +// What can be said about bird and swimmer can also be said about robin. + OUT: <(||, $1>, $1>) ==> $1>>. %0.70;0.81% +// What can be said about bird or swimmer can also be said about robin. + OUT: < $1> ==> $1>>. %1.00;0.36% +// I guess what can be said about bird can also be said about swimmer. + OUT: < $1> ==> $1>>. %0.70;0.45% +// I guess what can be said about swimmer can also be said about bird. + OUT: < $1> <=> $1>>. %0.70;0.45% +// I guess bird and swimmer share most properties. + +********** variable unification +<(&&,<$x --> flyer>,<$x --> [chirping]>) ==> <$x --> bird>>. +// If something can fly and chirp, then it is a bird. +<<$y --> [with-wings]> ==> <$y --> flyer>>. +// If something has wings, then it can fly. +1 + OUT: <(&&,<$1 --> [chirping]>,<$1 --> [with-wings]>) ==> <$1 --> bird>>. %1.00;0.81% +// If something can chirp and has wings, then it is a bird. + +********** variable unification +<(&&,<$x --> flyer>,<$x --> [chirping]>, <(*, $x, worms) --> food>) ==> <$x --> bird>>. +// If something can fly, chirp, and eats worms, then it is a bird. +<(&&,<$y --> [chirping]>,<$y --> [with-wings]>) ==> <$y --> bird>>. +// If something can chirp and has wings, then it is a bird. +4 + OUT: <(&&,<$1 --> flyer>,<(*,$1,worms) --> food>) ==> <$1 --> [with-wings]>>. %1.00;0.45% +// If something can fly and eats worms, then I guess it has wings. + OUT: <<$1 --> [with-wings]> ==> (&&,<$1 --> flyer>,<(*,$1,worms) --> food>)>. %1.00;0.45% +// I guess if something has wings, then it can fly and eats worms. + +********** variable unification +<(&&,<$x --> flyer>,<(*,$x,worms) --> food>) ==> <$x --> bird>>. +// If something can fly and eats worms, then it is a bird. +<<$y --> flyer> ==> <$y --> [with-wings]>>. +// If something can fly, then it has wings. +4 + OUT: <(&&,<$1 --> [with-wings]>,<(*,$1,worms) --> food>) ==> <$1 --> bird>>. %1.00;0.45% +// If something has wings and eats worms, then I guess it is a bird. + +****** variable elimination +<<$x --> bird> ==> <$x --> animal>>. +// If something is a bird, then it is an animal. + bird>. +// A robin is a bird. +5 + OUT: animal>. %1.00;0.81% +// A robin is an animal. + +********** variable elimination +<<$x --> bird> ==> <$x --> animal>>. +// If something is a bird, then it is an animal. + animal>. +// A tiger is an animal. +5 + OUT: bird>. %1.00;0.45% +// I guess that a tiger is a bird. + +********** variable elimination +<<$x --> animal> <=> <$x --> bird>>. +// Something is a animal if and only if it is a bird. + bird>. +// A robin is a bird. +5 + OUT: animal>. %1.00;0.81% +// A robin is a animal. + +********** variable elimination +(&&,<#x --> bird>,<#x --> swimmer>). +// Some bird can swim. + bird>. %0.90% +// Swan is a type of bird. +5 + OUT: swimmer>. %0.90;0.43% +// I guess swan can swim. + +********** variable elimination +<{Tweety} --> [with-wings]>. +// Tweety has wings. +<(&&,<$x --> [chirping]>,<$x --> [with-wings]>) ==> <$x --> bird>>. +// If something can chirp and has wings, then it is a bird. +18 + OUT: <<{Tweety} --> [chirping]> ==> <{Tweety} --> bird>>. %1.00;0.81% +// If Tweety can chirp, then it is a bird. + +********** variable elimination +<(&&,<$x --> flyer>,<$x --> [chirping]>, <(*, $x, worms) --> food>) ==> <$x --> bird>>. +// If something can fly, chirp, and eats worms, then it is a bird. +<{Tweety} --> flyer>. +// Tweety can fly. +3 + OUT: <(&&,<(*,{Tweety},worms) --> food>,<{Tweety} --> [chirping]>) ==> <{Tweety} --> bird>>. %1.00;0.81% +// If Tweety can chirp and eats worms, then it is a bird. + +********** multiple variable elimination +<(&&,<$x --> key>,<$y --> lock>) ==> <$y --> (/,open,$x,_)>>. +// Every lock can be opened by every key. +<{lock1} --> lock>. +// Lock-1 is a lock. +8 + OUT: <<$1 --> key> ==> <{lock1} --> (/,open,$1,_)>>. %1.00;0.81% +// Lock-1 can be opened by every key. + +********** multiple variable elimination +<<$x --> lock> ==> (&&,<#y --> key>,<$x --> (/,open,#y,_)>)>. +// Every lock can be opened by some key. +<{lock1} --> lock>. +// Lock-1 is a lock. +3 + OUT: (&&,<#1 --> key>,<{lock1} --> (/,open,#1,_)>). %1.00;0.81% +// Some key can open Lock-1. + +********** multiple variable elimination +(&&,<#x --> lock>,<<$y --> key> ==> <#x --> (/,open,$y,_)>>). +// There is a lock that can be opened by every key. +<{lock1} --> lock>. +// Lock-1 is a lock. +3 + OUT: <<$1 --> key> ==> <{lock1} --> (/,open,$1,_)>>. %1.00;0.43% +// I guess Lock-1 can be opened by every key. + +********** multiple variable elimination +(&&,<#x --> (/,open,#y,_)>,<#x --> lock>,<#y --> key>). +// There is a key that can open some lock. +<{lock1} --> lock>. +// Lock-1 is a lock. +1 + OUT: (&&,<#1 --> key>,<{lock1} --> (/,open,#1,_)>). %1.00;0.43% +// I guess there is a key that can open Lock-1. + +********** variable introduction + bird>. +// A swan is a bird. + swimmer>. %0.80% +// A swan is usually a swimmer. +5 + OUT: <<$1 --> bird> ==> <$1 --> swimmer>>. %0.80;0.45% +// I guess a bird is usually a swimmer. + OUT: <<$1 --> swimmer> ==> <$1 --> bird>>. %1.00;0.39% +// I guess a swimmer is a bird. + OUT: <<$1 --> bird> <=> <$1 --> swimmer>>. %0.80;0.45% +// I guess a bird is usually a swimmer, and the other way around. + OUT: (&&,<#1 --> bird>,<#1 --> swimmer>). %0.80;0.81% +// Some bird can swim. + +********** variable introduction + swimmer>. +//A gull is a swimmer. + swimmer>. %0.80% +//Usually, a swan is a swimmer. +5 + OUT: < $1> ==> $1>>. %0.80;0.45% +// I guess what can be said about gull usually can also be said about swan. + OUT: < $1> ==> $1>>. %1.00;0.39% +// I guess what can be said about swan can also be said about gull. + OUT: < $1> <=> $1>>. %0.80;0.45% +// I guess gull and swan share most properties. + OUT: (&&, #1>, #1>). %0.80;0.81% +// Gull and swan have some common property. + +********** variables introduction +<{key1} --> (/,open,_,{lock1})>. +// Key-1 opens Lock-1. +<{key1} --> key>. +// Key-1 is a key. +3 + OUT: <<$1 --> key> ==> <$1 --> (/,open,_,{lock1})>>. %1.00;0.45% +// I guess every key can open Lock-1. + OUT: (&&,<#1 --> (/,open,_,{lock1})>,<#1 --> key>). %1.00;0.81% +// Some key can open Lock-1. + +********** multiple variables introduction +<<$x --> key> ==> <{lock1} --> (/,open,$x,_)>>. +// Lock-1 can be opened by every key. +<{lock1} --> lock>. +// Lock-1 is a lock. +1 + OUT: (&&,<#1 --> lock>,<<$2 --> key> ==> <#1 --> (/,open,$2,_)>>). %1.00;0.81% +// There is a lock that can be opened by every key. + OUT: <(&&,<$1 --> key>,<$2 --> lock>) ==> <$2 --> (/,open,$1,_)>>. %1.00;0.45% +// I guess every lock can be opened by every key. + +********** multiple variables introduction +(&&,<#x --> key>,<{lock1} --> (/,open,#x,_)>). +// Lock-1 can be opened by some key. +<{lock1} --> lock>. +// Lock-1 is a lock. +1 + OUT: (&&,<#1 --> key>,<#2 --> lock>,<#2 --> (/,open,#1,_)>). %1.00;0.81% +// There is a key that can open some lock. + OUT: <<$1 --> lock> ==> (&&,<#2 --> key>,<$1 --> (/,open,#2,_)>)>. %1.00;0.45% +// I guess every lock can be opened by some key. diff --git a/nars-dist/Examples/Example-NAL6-unedited.txt b/nars-dist/Examples/Example-NAL6-unedited.txt new file mode 100755 index 00000000..e1c12cd6 --- /dev/null +++ b/nars-dist/Examples/Example-NAL6-unedited.txt @@ -0,0 +1,146 @@ +********** variable unification + IN: <<$1 --> bird> ==> <$1 --> flyer>>. %1.00;0.90% {0 : 1} + IN: <<$1 --> bird> ==> <$1 --> flyer>>. %0.00;0.70% {0 : 2} +1 + OUT: <<$1 --> bird> ==> <$1 --> flyer>>. %0.79;0.92% {1 : 1;2} +********** variable unification + IN: <<$1 --> bird> ==> <$1 --> animal>>. %1.00;0.90% {0 : 1} + IN: <<$1 --> robin> ==> <$1 --> bird>>. %1.00;0.90% {0 : 2} +5 + OUT: <<$1 --> robin> ==> <$1 --> animal>>. %1.00;0.81% {5 : 2;1} + OUT: <<$1 --> animal> ==> <$1 --> robin>>. %1.00;0.45% {5 : 2;1} +********** variable unification + IN: <<$1 --> swan> ==> <$1 --> bird>>. %1.00;0.80% {0 : 1} + IN: <<$1 --> swan> ==> <$1 --> swimmer>>. %0.80;0.90% {0 : 2} +5 + OUT: <<$1 --> swan> ==> (||,<$1 --> bird>,<$1 --> swimmer>)>. %1.00;0.72% {5 : 2;1} + OUT: <<$1 --> swan> ==> (&&,<$1 --> bird>,<$1 --> swimmer>)>. %0.80;0.72% {5 : 2;1} + OUT: <<$1 --> swimmer> ==> <$1 --> bird>>. %1.00;0.37% {5 : 2;1} + OUT: <<$1 --> bird> ==> <$1 --> swimmer>>. %0.80;0.42% {5 : 2;1} + OUT: <<$1 --> bird> <=> <$1 --> swimmer>>. %0.80;0.42% {5 : 2;1} +********** variable unification + IN: < $1> ==> $1>>. %1.00;0.90% {0 : 1} + IN: < $1> ==> $1>>. %0.70;0.90% {0 : 2} +5 + OUT: <(&&, $1>, $1>) ==> $1>>. %1.00;0.81% {5 : 2;1} + OUT: <(||, $1>, $1>) ==> $1>>. %0.70;0.81% {5 : 2;1} + OUT: < $1> ==> $1>>. %1.00;0.36% {5 : 2;1} + OUT: < $1> ==> $1>>. %0.70;0.45% {5 : 2;1} + OUT: < $1> <=> $1>>. %0.70;0.45% {5 : 2;1} +********** variable unification + IN: <(&&,<$1 --> flyer>,<$1 --> [chirping]>) ==> <$1 --> bird>>. %1.00;0.90% {0 : 1} + IN: <<$1 --> [with-wings]> ==> <$1 --> flyer>>. %1.00;0.90% {0 : 2} +1 + OUT: <(&&,<$1 --> [chirping]>,<$1 --> [with-wings]>) ==> <$1 --> bird>>. %1.00;0.81% {1 : 2;1} +********** variable unification + IN: <(&&,<$1 --> flyer>,<$1 --> [chirping]>,<(*,$1,worms) --> food>) ==> <$1 --> bird>>. %1.00;0.90% {0 : 1} + IN: <(&&,<$1 --> [chirping]>,<$1 --> [with-wings]>) ==> <$1 --> bird>>. %1.00;0.90% {0 : 2} +4 + OUT: <(&&,<$1 --> flyer>,<(*,$1,worms) --> food>) ==> <$1 --> [with-wings]>>. %1.00;0.45% {4 : 1;2} + OUT: <<$1 --> [with-wings]> ==> (&&,<$1 --> flyer>,<(*,$1,worms) --> food>)>. %1.00;0.45% {4 : 1;2} +********** variable unification + IN: <(&&,<$1 --> flyer>,<(*,$1,worms) --> food>) ==> <$1 --> bird>>. %1.00;0.90% {0 : 1} + IN: <<$1 --> flyer> ==> <$1 --> [with-wings]>>. %1.00;0.90% {0 : 2} +4 + OUT: <(&&,<$1 --> [with-wings]>,<(*,$1,worms) --> food>) ==> <$1 --> bird>>. %1.00;0.45% {4 : 1;2} +****** variable elimination + IN: <<$1 --> bird> ==> <$1 --> animal>>. %1.00;0.90% {0 : 1} + IN: bird>. %1.00;0.90% {0 : 2} +5 + OUT: animal>. %1.00;0.81% {5 : 2;1} +********** variable elimination + IN: <<$1 --> bird> ==> <$1 --> animal>>. %1.00;0.90% {0 : 1} + IN: animal>. %1.00;0.90% {0 : 2} +5 + OUT: bird>. %1.00;0.45% {5 : 2;1} +********** variable elimination + IN: <<$1 --> animal> <=> <$1 --> bird>>. %1.00;0.90% {0 : 1} + IN: bird>. %1.00;0.90% {0 : 2} +5 + OUT: animal>. %1.00;0.81% {5 : 2;1} +********** variable elimination + IN: (&&,<#1 --> bird>,<#1 --> swimmer>). %1.00;0.90% {0 : 1} + IN: bird>. %0.90;0.90% {0 : 2} +5 + OUT: swimmer>. %0.90;0.43% {5 : 2;1} +********** variable elimination + IN: <{Tweety} --> [with-wings]>. %1.00;0.90% {0 : 1} + IN: <(&&,<$1 --> [chirping]>,<$1 --> [with-wings]>) ==> <$1 --> bird>>. %1.00;0.90% {0 : 2} +18 + OUT: <<{Tweety} --> [chirping]> ==> <{Tweety} --> bird>>. %1.00;0.81% {18 : 2;1} +********** variable elimination + IN: <(&&,<$1 --> flyer>,<$1 --> [chirping]>,<(*,$1,worms) --> food>) ==> <$1 --> bird>>. %1.00;0.90% {0 : 1} + IN: <{Tweety} --> flyer>. %1.00;0.90% {0 : 2} +3 + OUT: <(&&,<{Tweety} --> [chirping]>,<(*,{Tweety},worms) --> food>) ==> <{Tweety} --> bird>>. %1.00;0.81% {3 : 1;2} +********** multiple variable elimination + IN: <(&&,<$1 --> key>,<$2 --> lock>) ==> <$2 --> (/,open,$1,_)>>. %1.00;0.90% {0 : 1} + IN: <{lock1} --> lock>. %1.00;0.90% {0 : 2} +8 + OUT: <<$1 --> key> ==> <{lock1} --> (/,open,$1,_)>>. %1.00;0.81% {8 : 1;2} +********** multiple variable elimination + IN: <<$1 --> lock> ==> (&&,<#2 --> key>,<$1 --> (/,open,#2,_)>)>. %1.00;0.90% {0 : 1} + IN: <{lock1} --> lock>. %1.00;0.90% {0 : 2} +3 + OUT: (&&,<#1 --> key>,<{lock1} --> (/,open,#1,_)>). %1.00;0.81% {3 : 2;1} +********** multiple variable elimination + IN: (&&,<#1 --> lock>,<<$2 --> key> ==> <#1 --> (/,open,$2,_)>>). %1.00;0.90% {0 : 1} + IN: <{lock1} --> lock>. %1.00;0.90% {0 : 2} +3 + OUT: <<$1 --> key> ==> <{lock1} --> (/,open,$1,_)>>. %1.00;0.43% {3 : 2;1} +********** multiple variable elimination + IN: (&&,<#1 --> lock>,<#1 --> (/,open,#2,_)>,<#2 --> key>). %1.00;0.90% {0 : 1} + IN: <{lock1} --> lock>. %1.00;0.90% {0 : 2} +1 + OUT: (&&,<#1 --> key>,<{lock1} --> (/,open,#1,_)>). %1.00;0.43% {1 : 2;1} +********** variable introduction + IN: bird>. %1.00;0.90% {0 : 1} + IN: swimmer>. %0.80;0.90% {0 : 2} +5 + OUT: (|,bird,swimmer)>. %1.00;0.81% {5 : 2;1} + OUT: (&,bird,swimmer)>. %0.80;0.81% {5 : 2;1} + OUT: <<$1 --> bird> ==> <$1 --> swimmer>>. %0.80;0.45% {5 : 2;1} + OUT: <<$1 --> swimmer> ==> <$1 --> bird>>. %1.00;0.39% {5 : 2;1} + OUT: <<$1 --> bird> <=> <$1 --> swimmer>>. %0.80;0.45% {5 : 2;1} + OUT: (&&,<#1 --> bird>,<#1 --> swimmer>). %0.80;0.81% {5 : 2;1} + OUT: bird>. %1.00;0.39% {5 : 2;1} + OUT: swimmer>. %0.80;0.45% {5 : 2;1} + OUT: swimmer>. %0.80;0.45% {5 : 2;1} +********** variable introduction + IN: swimmer>. %1.00;0.90% {0 : 1} + IN: swimmer>. %0.80;0.90% {0 : 2} +5 + OUT: <(&,gull,swan) --> swimmer>. %1.00;0.81% {5 : 2;1} + OUT: <(|,gull,swan) --> swimmer>. %0.80;0.81% {5 : 2;1} + OUT: < $1> ==> $1>>. %0.80;0.45% {5 : 2;1} + OUT: < $1> ==> $1>>. %1.00;0.39% {5 : 2;1} + OUT: < $1> <=> $1>>. %0.80;0.45% {5 : 2;1} + OUT: (&&, #1>, #1>). %0.80;0.81% {5 : 2;1} + OUT: swan>. %1.00;0.39% {5 : 2;1} + OUT: gull>. %0.80;0.45% {5 : 2;1} + OUT: swan>. %0.80;0.45% {5 : 2;1} +********** variables introduction + IN: <{key1} --> (/,open,_,{lock1})>. %1.00;0.90% {0 : 1} + IN: <{key1} --> key>. %1.00;0.90% {0 : 2} +3 + OUT: <{key1} --> (|,key,(/,open,_,{lock1}))>. %1.00;0.81% {3 : 1;2} + OUT: <{key1} --> (&,key,(/,open,_,{lock1}))>. %1.00;0.81% {3 : 1;2} + OUT: <<$1 --> key> ==> <$1 --> (/,open,_,{lock1})>>. %1.00;0.45% {3 : 1;2} + OUT: <<$1 --> (/,open,_,{lock1})> ==> <$1 --> key>>. %1.00;0.45% {3 : 1;2} + OUT: <<$1 --> key> <=> <$1 --> (/,open,_,{lock1})>>. %1.00;0.45% {3 : 1;2} + OUT: (&&,<#1 --> key>,<#1 --> (/,open,_,{lock1})>). %1.00;0.81% {3 : 1;2} + OUT: <(/,open,_,{lock1}) --> key>. %1.00;0.45% {3 : 1;2} + OUT: (/,open,_,{lock1})>. %1.00;0.45% {3 : 1;2} + OUT: (/,open,_,{lock1})>. %1.00;0.45% {3 : 1;2} +********** multiple variables introduction + IN: <<$1 --> key> ==> <{lock1} --> (/,open,$1,_)>>. %1.00;0.90% {0 : 1} + IN: <{lock1} --> lock>. %1.00;0.90% {0 : 2} +1 + OUT: (&&,<#1 --> lock>,<<$2 --> key> ==> <#1 --> (/,open,$2,_)>>). %1.00;0.81% {1 : 2;1} + OUT: <(&&,<$1 --> key>,<$2 --> lock>) ==> <$2 --> (/,open,$1,_)>>. %1.00;0.45% {1 : 2;1} +********** multiple variables introduction + IN: (&&,<#1 --> key>,<{lock1} --> (/,open,#1,_)>). %1.00;0.90% {0 : 1} + IN: <{lock1} --> lock>. %1.00;0.90% {0 : 2} +1 + OUT: (&&,<#1 --> key>,<#2 --> lock>,<#2 --> (/,open,#1,_)>). %1.00;0.81% {1 : 2;1} + OUT: <<$1 --> lock> ==> (&&,<#2 --> key>,<$1 --> (/,open,#2,_)>)>. %1.00;0.45% {1 : 2;1} diff --git a/nars-dist/Examples/Example-NLP-edited.txt b/nars-dist/Examples/Example-NLP-edited.txt new file mode 100755 index 00000000..3fba3306 --- /dev/null +++ b/nars-dist/Examples/Example-NLP-edited.txt @@ -0,0 +1,100 @@ + +*** [input sentences] +*** <(*, cat, CAT) --> REPRESENT>. +*** <(*, fish, FISH) --> REPRESENT>. +*** <(*, dog, DOG) --> REPRESENT>. +*** <(*, meat, MEAT) --> REPRESENT>. +*** <(*,(*,cat,eat,fish),<(*,CAT,FISH) --> FOOD>) --> REPRESENT>. +*** <(*,(*,dog,eat,fish),?x) --> REPRESENT>? +*** <(*,?x,<(*,DOG,FISH) --> FOOD>) --> REPRESENT>? +*** (/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>)>? +*** <(*,dog,eat,meat) --> (/,REPRESENT,_,?x)>? + +***1 [transformation] +<(*,cat,CAT) --> REPRESENT>. +6 + OUT: (/,REPRESENT,_,CAT)>. %1.00;0.90% + +***2 [transformation] +<(*,(*,cat,eat,fish),<(*,CAT,FISH) --> FOOD>) --> REPRESENT>. +7 + OUT: <(*,cat,eat,fish) --> (/,REPRESENT,_,<(*,CAT,FISH) --> FOOD>)>. %1.00;0.90% + +***3 [transformation] + IN: <(*,cat,eat,fish) --> (/,REPRESENT,_,<(*,CAT,FISH) --> FOOD>)>. +7 + OUT: (/,(/,REPRESENT,_,<(*,CAT,FISH) --> FOOD>),_,eat,fish)>. %1.00;0.90% + +***4 [induction] + (/,REPRESENT,_,CAT)>. + (/,(/,REPRESENT,_,<(*,CAT,FISH) --> FOOD>),_,eat,fish)>. +3 + OUT: <<$1 --> (/,REPRESENT,_,$2)> ==> <$1 --> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),_,eat,fish)>>. %1.00;0.45% + +***5 [deduction] +<<$1 --> (/,REPRESENT,_,$2)> ==> <$1 --> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),_,eat,fish)>>. + (/,REPRESENT,_,DOG)>. %1.00;0.90% {0 : 2} +102 + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),_,eat,fish)>. %1.00;0.81% + +***6 [transformation] + (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),_,eat,fish)>. +8 + OUT: <(*,dog,eat,fish) --> (/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>)>. %1.00;0.90% + +***7 [question answering] +<(*,dog,eat,fish) --> (/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>)>. +<(*,(*,dog,eat,fish),?x) --> REPRESENT>? +79 + OUT: <(*,(*,dog,eat,fish),<(*,DOG,FISH) --> FOOD>) --> REPRESENT>. %1.00;0.90% + +***8 [question answering] +<(*,dog,eat,fish) --> (/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>)>. +<(*,?x,<(*,DOG,FISH) --> FOOD>) --> REPRESENT>? +25 + OUT: <(*,(*,dog,eat,fish),<(*,DOG,FISH) --> FOOD>) --> REPRESENT>. %1.00;0.90% + +***9 [transformation] +<<$x --> (/,REPRESENT,_,$y)> ==> <$x --> (/,(/,REPRESENT,_,<(*,$y,FISH) --> FOOD>),_,eat,fish)>>. +5 + OUT: <<(*,$1,$2) --> REPRESENT> ==> <$1 --> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),_,eat,fish)>>. %1.00;0.90% + +***10 [transformation] +<<(*,$1,$2) --> REPRESENT> ==> <$1 --> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),_,eat,fish)>>. +8 + OUT: <<(*,$1,$2) --> REPRESENT> ==> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),$1,eat,_)>>. %1.00;0.90% + +***11 [induction] +<<(*,$1,$2) --> REPRESENT> ==> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),$1,eat,_)>>. + (/,REPRESENT,_,FISH)>. +3 + OUT: <(&&,<$1 --> (/,REPRESENT,_,$2)>,<(*,$3,$4) --> REPRESENT>) ==> <$1 --> (/,(/,REPRESENT,_,<(*,$4,$2) --> FOOD>),$3,eat,_)>>. %1.00;0.45% + +***12 [deduction] +<(&&,<$1 --> (/,REPRESENT,_,$2)>,<(*,$3,$4) --> REPRESENT>) ==> <$1 --> (/,(/,REPRESENT,_,<(*,$4,$2) --> FOOD>),$3,eat,_)>>. + (/,REPRESENT,_,DOG)>. +152 + OUT: <<$1 --> (/,REPRESENT,_,$2)> ==> (/,(/,REPRESENT,_,<(*,DOG,$2) --> FOOD>),dog,_,$1)>>. %1.00;0.81% + +***13 [deduction] + (/,REPRESENT,_,MEAT)>. +<<$1 --> (/,REPRESENT,_,$2)> ==> (/,(/,REPRESENT,_,<(*,DOG,$2) --> FOOD>),dog,_,$1)>>. +162 + OUT: (/,(/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>),_,eat,meat)>. %1.00;0.81% + +***14 [transformation] + (/,(/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>),_,eat,meat)>. +8 + OUT: <(*,dog,eat,meat) --> (/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>)>. %1.00;0.90% + +***15 [question answering] +<(*,dog,eat,meat) --> (/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>)>. + (/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>)>? +19 + OUT: <(*,dog,eat,meat) --> (/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>)>. %1.00;0.90% + +***16 [question answering] +<(*,dog,eat,meat) --> (/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>)>. +<(*,dog,eat,meat) --> (/,REPRESENT,_,?x)>? +16 + OUT: <(*,dog,eat,meat) --> (/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>)>. %1.00;0.90% diff --git a/nars-dist/Examples/Example-NLP-unedited.txt b/nars-dist/Examples/Example-NLP-unedited.txt new file mode 100755 index 00000000..ffabbeef --- /dev/null +++ b/nars-dist/Examples/Example-NLP-unedited.txt @@ -0,0 +1,383 @@ +***1 [transformation] + IN: <(*,cat,CAT) --> REPRESENT>. %1.00;0.90% {0 : 1} +6 + OUT: (/,REPRESENT,_,CAT)>. %1.00;0.90% {6 : 1} + OUT: (/,REPRESENT,cat,_)>. %1.00;0.90% {6 : 1} +***2 [transformation] + IN: <(*,(*,cat,eat,fish),<(*,CAT,FISH) --> FOOD>) --> REPRESENT>. %1.00;0.90% {0 : 1} +7 + OUT: <(*,cat,eat,fish) --> (/,REPRESENT,_,<(*,CAT,FISH) --> FOOD>)>. %1.00;0.90% {7 : 1} + OUT: <<(*,CAT,FISH) --> FOOD> --> (/,REPRESENT,(*,cat,eat,fish),_)>. %1.00;0.90% {7 : 1} +***3 [transformation] + IN: <(*,cat,eat,fish) --> (/,REPRESENT,_,<(*,CAT,FISH) --> FOOD>)>. %1.00;0.90% {0 : 1} +7 + OUT: (/,(/,REPRESENT,_,<(*,CAT,FISH) --> FOOD>),_,eat,fish)>. %1.00;0.90% {7 : 1} + OUT: (/,(/,REPRESENT,_,<(*,CAT,FISH) --> FOOD>),cat,_,fish)>. %1.00;0.90% {7 : 1} + OUT: (/,(/,REPRESENT,_,<(*,CAT,FISH) --> FOOD>),cat,eat,_)>. %1.00;0.90% {7 : 1} + OUT: <(*,(*,cat,eat,fish),<(*,CAT,FISH) --> FOOD>) --> REPRESENT>. %1.00;0.90% {7 : 1} + OUT: <<(*,CAT,FISH) --> FOOD> --> (/,REPRESENT,(*,cat,eat,fish),_)>. %1.00;0.90% {7 : 1} +***4 [induction] + IN: (/,REPRESENT,_,CAT)>. %1.00;0.90% {0 : 1} + IN: (/,(/,REPRESENT,_,<(*,CAT,FISH) --> FOOD>),_,eat,fish)>. %1.00;0.90% {0 : 2} +3 + OUT: (|,(/,REPRESENT,_,CAT),(/,(/,REPRESENT,_,<(*,CAT,FISH) --> FOOD>),_,eat,fish))>. %1.00;0.81% {3 : 1;2} + OUT: (&,(/,REPRESENT,_,CAT),(/,(/,REPRESENT,_,<(*,CAT,FISH) --> FOOD>),_,eat,fish))>. %1.00;0.81% {3 : 1;2} + OUT: <<$1 --> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),_,eat,fish)> ==> <$1 --> (/,REPRESENT,_,$2)>>. %1.00;0.45% {3 : 1;2} + OUT: <<$1 --> (/,REPRESENT,_,$2)> ==> <$1 --> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),_,eat,fish)>>. %1.00;0.45% {3 : 1;2} + OUT: <<$1 --> (/,REPRESENT,_,$2)> <=> <$1 --> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),_,eat,fish)>>. %1.00;0.45% {3 : 1;2} + OUT: (&&,<#1 --> (/,REPRESENT,_,$2)>,<#1 --> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),_,eat,fish)>). %1.00;0.81% {3 : 1;2} + OUT: <(/,REPRESENT,_,$1) --> (/,(/,REPRESENT,_,<(*,$1,FISH) --> FOOD>),_,eat,fish)>. %1.00;0.45% {3 : 1;2} + OUT: <(/,(/,REPRESENT,_,<(*,$1,FISH) --> FOOD>),_,eat,fish) --> (/,REPRESENT,_,$1)>. %1.00;0.45% {3 : 1;2} + OUT: <(/,REPRESENT,_,$1) <-> (/,(/,REPRESENT,_,<(*,$1,FISH) --> FOOD>),_,eat,fish)>. %1.00;0.45% {3 : 1;2} +***5 [deduction] + IN: <<$1 --> (/,REPRESENT,_,$2)> ==> <$1 --> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),_,eat,fish)>>. %1.00;0.90% {0 : 1} + IN: (/,REPRESENT,_,DOG)>. %1.00;0.90% {0 : 2} +3 + OUT: <<(*,$1,$2) --> REPRESENT> ==> <$1 --> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),_,eat,fish)>>. %1.00;0.90% {3 : 1} +9 + OUT: <(*,dog,DOG) --> REPRESENT>. %1.00;0.90% {12 : 2} + OUT: (/,REPRESENT,dog,_)>. %1.00;0.90% {12 : 2} +3 + OUT: <<(*,$1,$2) --> REPRESENT> ==> <$1 --> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),_,eat,fish)>>. %1.00;0.90% {15 : 1} +3 + OUT: <(*,dog,DOG) --> REPRESENT>. %1.00;0.90% {18 : 2} + OUT: (/,REPRESENT,dog,_)>. %1.00;0.90% {18 : 2} +1 + OUT: <<$1 --> (/,REPRESENT,_,$2)> ==> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),$1,_,fish)>>. %1.00;0.90% {19 : 1} +6 + OUT: <<$1 --> (/,REPRESENT,_,$2)> ==> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),$1,_,fish)>>. %1.00;0.90% {25 : 1} +1 + OUT: <(*,dog,DOG) --> REPRESENT>. %1.00;0.90% {26 : 2} + OUT: (/,REPRESENT,dog,_)>. %1.00;0.90% {26 : 2} +6 + OUT: <<$1 --> (/,REPRESENT,_,$2)> ==> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),$1,eat,_)>>. %1.00;0.90% {32 : 1} +7 + OUT: <(*,dog,DOG) --> REPRESENT>. %1.00;0.90% {39 : 2} + OUT: (/,REPRESENT,dog,_)>. %1.00;0.90% {39 : 2} +1 + OUT: <<$1 --> (/,REPRESENT,_,$2)> ==> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),$1,eat,_)>>. %1.00;0.90% {40 : 1} +1 + OUT: <<$1 --> (/,REPRESENT,_,$2)> ==> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),$1,_,fish)>>. %1.00;0.90% {41 : 1} +11 + OUT: (/,REPRESENT,dog,_)>. %1.00;0.90% {52 : 2} +1 + OUT: (/,REPRESENT,dog,_)>. %1.00;0.90% {53 : 2} +5 + OUT: <<$1 --> (/,REPRESENT,_,$2)> ==> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),$1,_,fish)>>. %1.00;0.90% {58 : 1} +4 + OUT: <(*,dog,DOG) --> REPRESENT>. %1.00;0.90% {62 : 2} +2 + OUT: <(*,dog,DOG) --> REPRESENT>. %1.00;0.90% {64 : 2} + OUT: (/,REPRESENT,dog,_)>. %1.00;0.90% {64 : 2} +6 + OUT: <<(*,$1,$2) --> REPRESENT> ==> <$1 --> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),_,eat,fish)>>. %1.00;0.90% {70 : 1} +1 + OUT: <<$1 --> (/,REPRESENT,_,$2)> ==> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),$1,eat,_)>>. %1.00;0.90% {71 : 1} +9 + OUT: <<(*,$1,$2) --> REPRESENT> ==> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),$1,_,fish)>>. %1.00;0.90% {80 : 1} +4 + OUT: <<(*,$1,$2) --> REPRESENT> ==> <$1 --> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),_,eat,fish)>>. %1.00;0.90% {84 : 1} +2 + OUT: <<$1 --> (/,REPRESENT,_,$2)> ==> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),$1,eat,_)>>. %1.00;0.90% {86 : 1} +6 + OUT: (/,REPRESENT,dog,_)>. %1.00;0.90% {92 : 2} +3 + OUT: (/,REPRESENT,dog,_)>. %1.00;0.90% {95 : 2} +7 + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),_,eat,fish)>. %1.00;0.81% {102 : 1;2} +***6 [transformation] + IN: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),_,eat,fish)>. %1.00;0.90% {0 : 1} +8 + OUT: <(*,dog,eat,fish) --> (/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>)>. %1.00;0.90% {8 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),dog,_,fish)>. %1.00;0.90% {8 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),dog,eat,_)>. %1.00;0.90% {8 : 1} +***7 [question answering] + IN: <(*,dog,eat,fish) --> (/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>)>. %1.00;0.90% {0 : 1} + IN: <(*,(*,dog,eat,fish),?1) --> REPRESENT>? {0 : 2} +5 + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),_,eat,fish)>. %1.00;0.90% {5 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),dog,_,fish)>. %1.00;0.90% {5 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),dog,eat,_)>. %1.00;0.90% {5 : 1} + OUT: <(*,(*,dog,eat,fish),<(*,DOG,FISH) --> FOOD>) --> REPRESENT>. %1.00;0.90% {5 : 1} + OUT: <<(*,DOG,FISH) --> FOOD> --> (/,REPRESENT,(*,dog,eat,fish),_)>. %1.00;0.90% {5 : 1} +3 + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),_,eat,fish)>. %1.00;0.90% {8 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),dog,_,fish)>. %1.00;0.90% {8 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),dog,eat,_)>. %1.00;0.90% {8 : 1} + OUT: <(*,(*,dog,eat,fish),<(*,DOG,FISH) --> FOOD>) --> REPRESENT>. %1.00;0.90% {8 : 1} + OUT: <<(*,DOG,FISH) --> FOOD> --> (/,REPRESENT,(*,dog,eat,fish),_)>. %1.00;0.90% {8 : 1} +8 + OUT: <(*,dog,eat,fish) --> (/,REPRESENT,_,?1)>? {16 : 2} + OUT: (/,REPRESENT,(*,dog,eat,fish),_)>? {16 : 2} +4 + OUT: <(*,(*,dog,eat,fish),<(*,DOG,FISH) --> FOOD>) --> REPRESENT>. %1.00;0.90% {20 : 1} +1 + OUT: <(*,(*,dog,eat,fish),<(*,DOG,FISH) --> FOOD>) --> REPRESENT>. %1.00;0.90% {21 : 1} +1 + OUT: <(*,dog,eat,fish) --> (/,REPRESENT,_,?1)>? {22 : 2} + OUT: (/,REPRESENT,(*,dog,eat,fish),_)>? {22 : 2} +2 + OUT: <(*,dog,eat,fish) --> (/,REPRESENT,_,?1)>? {24 : 2} + OUT: (/,REPRESENT,(*,dog,eat,fish),_)>? {24 : 2} +5 + OUT: <(*,dog,eat,fish) --> (/,REPRESENT,_,?1)>? {29 : 2} + OUT: (/,REPRESENT,(*,dog,eat,fish),_)>? {29 : 2} +15 + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),_,eat,fish)>. %1.00;0.90% {44 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),dog,_,fish)>. %1.00;0.90% {44 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),dog,eat,_)>. %1.00;0.90% {44 : 1} + OUT: <(*,(*,dog,eat,fish),<(*,DOG,FISH) --> FOOD>) --> REPRESENT>. %1.00;0.90% {44 : 1} + OUT: <<(*,DOG,FISH) --> FOOD> --> (/,REPRESENT,(*,dog,eat,fish),_)>. %1.00;0.90% {44 : 1} +1 + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),_,eat,fish)>. %1.00;0.90% {45 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),dog,_,fish)>. %1.00;0.90% {45 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),dog,eat,_)>. %1.00;0.90% {45 : 1} + OUT: <(*,(*,dog,eat,fish),<(*,DOG,FISH) --> FOOD>) --> REPRESENT>. %1.00;0.90% {45 : 1} + OUT: <<(*,DOG,FISH) --> FOOD> --> (/,REPRESENT,(*,dog,eat,fish),_)>. %1.00;0.90% {45 : 1} +1 + OUT: <(*,dog,eat,fish) --> (/,REPRESENT,_,?1)>? {46 : 2} + OUT: (/,REPRESENT,(*,dog,eat,fish),_)>? {46 : 2} +14 + OUT: <(*,(*,dog,eat,fish),<(*,DOG,FISH) --> FOOD>) --> REPRESENT>. %1.00;0.90% {60 : 1} +7 + OUT: <(*,(*,dog,eat,fish),<(*,DOG,FISH) --> FOOD>) --> REPRESENT>. %1.00;0.90% {67 : 1} +8 + OUT: <(*,dog,eat,fish) --> (/,REPRESENT,_,?1)>? {75 : 2} + OUT: (/,REPRESENT,(*,dog,eat,fish),_)>? {75 : 2} +3 + OUT: <(*,dog,eat,fish) --> (/,REPRESENT,_,?1)>? {78 : 2} + OUT: (/,REPRESENT,(*,dog,eat,fish),_)>? {78 : 2} +1 + OUT: <(*,(*,dog,eat,fish),<(*,DOG,FISH) --> FOOD>) --> REPRESENT>. %1.00;0.90% {8 : 1} + OUT: <(*,(*,dog,eat,fish),?1) --> (*,(*,dog,eat,fish),<(*,DOG,FISH) --> FOOD>)>? {79 : 1;2} + OUT: <(*,(*,dog,eat,fish),<(*,DOG,FISH) --> FOOD>) --> (*,(*,dog,eat,fish),?1)>? {79 : 1;2} + OUT: <(*,(*,dog,eat,fish),?1) <-> (*,(*,dog,eat,fish),<(*,DOG,FISH) --> FOOD>)>? {79 : 1;2} +***8 [question answering] + IN: <(*,dog,eat,fish) --> (/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>)>. %1.00;0.90% {0 : 1} + IN: <(*,?1,<(*,DOG,FISH) --> FOOD>) --> REPRESENT>? {0 : 2} +3 + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),_,eat,fish)>. %1.00;0.90% {3 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),dog,_,fish)>. %1.00;0.90% {3 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),dog,eat,_)>. %1.00;0.90% {3 : 1} + OUT: <(*,(*,dog,eat,fish),<(*,DOG,FISH) --> FOOD>) --> REPRESENT>. %1.00;0.90% {3 : 1} + OUT: <<(*,DOG,FISH) --> FOOD> --> (/,REPRESENT,(*,dog,eat,fish),_)>. %1.00;0.90% {3 : 1} +1 + OUT: (/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>)>? {4 : 2} + OUT: <<(*,DOG,FISH) --> FOOD> --> (/,REPRESENT,?1,_)>? {4 : 2} +2 + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),_,eat,fish)>. %1.00;0.90% {6 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),dog,_,fish)>. %1.00;0.90% {6 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),dog,eat,_)>. %1.00;0.90% {6 : 1} + OUT: <(*,(*,dog,eat,fish),<(*,DOG,FISH) --> FOOD>) --> REPRESENT>. %1.00;0.90% {6 : 1} + OUT: <<(*,DOG,FISH) --> FOOD> --> (/,REPRESENT,(*,dog,eat,fish),_)>. %1.00;0.90% {6 : 1} +1 + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),_,eat,fish)>. %1.00;0.90% {7 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),dog,_,fish)>. %1.00;0.90% {7 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,FISH) --> FOOD>),dog,eat,_)>. %1.00;0.90% {7 : 1} + OUT: <(*,(*,dog,eat,fish),<(*,DOG,FISH) --> FOOD>) --> REPRESENT>. %1.00;0.90% {7 : 1} + OUT: <<(*,DOG,FISH) --> FOOD> --> (/,REPRESENT,(*,dog,eat,fish),_)>. %1.00;0.90% {7 : 1} +1 + OUT: <(*,(*,dog,eat,fish),<(*,DOG,FISH) --> FOOD>) --> REPRESENT>. %1.00;0.90% {8 : 1} +17 + OUT: <(*,(*,dog,eat,fish),<(*,DOG,FISH) --> FOOD>) --> REPRESENT>. %1.00;0.90% {6 : 1} + OUT: <(*,?1,<(*,DOG,FISH) --> FOOD>) --> (*,(*,dog,eat,fish),<(*,DOG,FISH) --> FOOD>)>? {25 : 1;2} + OUT: <(*,(*,dog,eat,fish),<(*,DOG,FISH) --> FOOD>) --> (*,?1,<(*,DOG,FISH) --> FOOD>)>? {25 : 1;2} + OUT: <(*,?1,<(*,DOG,FISH) --> FOOD>) <-> (*,(*,dog,eat,fish),<(*,DOG,FISH) --> FOOD>)>? {25 : 1;2} +***9 [transformation] + IN: <<$1 --> (/,REPRESENT,_,$2)> ==> <$1 --> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),_,eat,fish)>>. %1.00;0.90% {0 : 1} +5 + OUT: <<(*,$1,$2) --> REPRESENT> ==> <$1 --> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),_,eat,fish)>>. %1.00;0.90% {5 : 1} +***10 [transformation] + IN: <<(*,$1,$2) --> REPRESENT> ==> <$1 --> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),_,eat,fish)>>. %1.00;0.90% {0 : 1} +6 + OUT: <<(*,$1,$2) --> REPRESENT> ==> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),$1,_,fish)>>. %1.00;0.90% {6 : 1} +2 + OUT: <<(*,$1,$2) --> REPRESENT> ==> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),$1,eat,_)>>. %1.00;0.90% {8 : 1} +***11 [induction] + IN: <<(*,$1,$2) --> REPRESENT> ==> (/,(/,REPRESENT,_,<(*,$2,FISH) --> FOOD>),$1,eat,_)>>. %1.00;0.90% {0 : 1} + IN: (/,REPRESENT,_,FISH)>. %1.00;0.90% {0 : 2} +3 + OUT: (&&,<#1 --> (/,REPRESENT,_,FISH)>,<<(*,$2,$3) --> REPRESENT> ==> <#1 --> (/,(/,REPRESENT,_,<(*,$3,FISH) --> FOOD>),$2,eat,_)>>). %1.00;0.81% {3 : 2;1} + OUT: <(&&,<$1 --> (/,REPRESENT,_,$2)>,<(*,$3,$4) --> REPRESENT>) ==> <$1 --> (/,(/,REPRESENT,_,<(*,$4,$2) --> FOOD>),$3,eat,_)>>. %1.00;0.45% {3 : 2;1} +***12 [deduction] + IN: <(&&,<$1 --> (/,REPRESENT,_,$2)>,<(*,$3,$4) --> REPRESENT>) ==> <$1 --> (/,(/,REPRESENT,_,<(*,$4,$2) --> FOOD>),$3,eat,_)>>. %1.00;0.90% {0 : 1} + IN: (/,REPRESENT,_,DOG)>. %1.00;0.90% {0 : 2} +3 + OUT: <(&&,<(*,$1,$2) --> REPRESENT>,<(*,$3,$4) --> REPRESENT>) ==> <$1 --> (/,(/,REPRESENT,_,<(*,$4,$2) --> FOOD>),$3,eat,_)>>. %1.00;0.90% {3 : 1} +1 + OUT: <(&&,<$1 --> (/,REPRESENT,_,$2)>,<(*,$3,$4) --> REPRESENT>) ==> (/,(/,REPRESENT,_,<(*,$4,$2) --> FOOD>),$3,_,$1)>>. %1.00;0.90% {4 : 1} +3 + OUT: <(&&,<$1 --> (/,REPRESENT,_,$2)>,<(*,$3,$4) --> REPRESENT>) ==> (/,(/,REPRESENT,_,<(*,$4,$2) --> FOOD>),$3,_,$1)>>. %1.00;0.90% {7 : 1} +10 + OUT: <(*,dog,DOG) --> REPRESENT>. %1.00;0.90% {17 : 2} + OUT: (/,REPRESENT,dog,_)>. %1.00;0.90% {17 : 2} +5 + OUT: <(&&,<$1 --> (/,REPRESENT,_,$2)>,<(*,$3,$4) --> REPRESENT>) ==> (/,(/,REPRESENT,_,<(*,$4,$2) --> FOOD>),$3,_,$1)>>. %1.00;0.90% {22 : 1} +10 + OUT: <(&&,<$1 --> (/,REPRESENT,_,$2)>,<(*,$3,$4) --> REPRESENT>) ==> (/,(/,REPRESENT,_,<(*,$4,$2) --> FOOD>),$3,_,$1)>>. %1.00;0.90% {32 : 1} +2 + OUT: <(*,dog,DOG) --> REPRESENT>. %1.00;0.90% {34 : 2} + OUT: (/,REPRESENT,dog,_)>. %1.00;0.90% {34 : 2} +16 + OUT: <(&&,<(*,$1,$2) --> REPRESENT>,<(*,$3,$4) --> REPRESENT>) ==> <$1 --> (/,(/,REPRESENT,_,<(*,$4,$2) --> FOOD>),$3,eat,_)>>. %1.00;0.90% {50 : 1} +4 + OUT: (/,REPRESENT,dog,_)>. %1.00;0.90% {54 : 2} +1 + OUT: (/,REPRESENT,dog,_)>. %1.00;0.90% {55 : 2} +4 + OUT: <(*,dog,DOG) --> REPRESENT>. %1.00;0.90% {59 : 2} +3 + OUT: <(*,dog,DOG) --> REPRESENT>. %1.00;0.90% {62 : 2} + OUT: (/,REPRESENT,dog,_)>. %1.00;0.90% {62 : 2} +1 + OUT: <(*,dog,DOG) --> REPRESENT>. %1.00;0.90% {63 : 2} + OUT: (/,REPRESENT,dog,_)>. %1.00;0.90% {63 : 2} +15 + OUT: <(&&,<(*,$1,$2) --> REPRESENT>,<(*,$3,$4) --> REPRESENT>) ==> (/,(/,REPRESENT,_,<(*,$4,$2) --> FOOD>),$3,_,$1)>>. %1.00;0.90% {78 : 1} +3 + OUT: <(*,dog,DOG) --> REPRESENT>. %1.00;0.90% {81 : 2} + OUT: (/,REPRESENT,dog,_)>. %1.00;0.90% {81 : 2} +8 + OUT: (/,REPRESENT,dog,_)>. %1.00;0.90% {89 : 2} +4 + OUT: (/,REPRESENT,dog,_)>. %1.00;0.90% {93 : 2} +5 + OUT: <(&&,<(*,$1,$2) --> REPRESENT>,<(*,$3,$4) --> REPRESENT>) ==> <$1 --> (/,(/,REPRESENT,_,<(*,$4,$2) --> FOOD>),$3,eat,_)>>. %1.00;0.90% {98 : 1} +4 + OUT: <(&&,<(*,$1,$2) --> REPRESENT>,<(*,$3,$4) --> REPRESENT>) ==> (/,(/,REPRESENT,_,<(*,$4,$2) --> FOOD>),$3,_,$1)>>. %1.00;0.90% {102 : 1} +7 + OUT: <(*,dog,DOG) --> REPRESENT>. %1.00;0.90% {109 : 2} +11 + OUT: <(*,dog,DOG) --> REPRESENT>. %1.00;0.90% {120 : 2} + OUT: (/,REPRESENT,dog,_)>. %1.00;0.90% {120 : 2} +5 + OUT: <(&&,<(*,$1,$2) --> REPRESENT>,<(*,$3,$4) --> REPRESENT>) ==> <$1 --> (/,(/,REPRESENT,_,<(*,$4,$2) --> FOOD>),$3,eat,_)>>. %1.00;0.90% {125 : 1} +6 + OUT: <(*,dog,DOG) --> REPRESENT>. %1.00;0.90% {131 : 2} + OUT: (/,REPRESENT,dog,_)>. %1.00;0.90% {131 : 2} +11 + OUT: <(*,dog,DOG) --> REPRESENT>. %1.00;0.90% {142 : 2} + OUT: (/,REPRESENT,dog,_)>. %1.00;0.90% {142 : 2} +10 + OUT: <<$1 --> (/,REPRESENT,_,$2)> ==> (/,(/,REPRESENT,_,<(*,DOG,$2) --> FOOD>),dog,_,$1)>>. %1.00;0.81% {152 : 1;2} +***13 [deduction] + IN: (/,REPRESENT,_,MEAT)>. %1.00;0.90% {0 : 1} + IN: <<$1 --> (/,REPRESENT,_,$2)> ==> (/,(/,REPRESENT,_,<(*,DOG,$2) --> FOOD>),dog,_,$1)>>. %1.00;0.90% {0 : 2} +3 + OUT: <<(*,$1,$2) --> REPRESENT> ==> (/,(/,REPRESENT,_,<(*,DOG,$2) --> FOOD>),dog,_,$1)>>. %1.00;0.90% {3 : 2} +9 + OUT: <(*,meat,MEAT) --> REPRESENT>. %1.00;0.90% {12 : 1} + OUT: (/,REPRESENT,meat,_)>. %1.00;0.90% {12 : 1} +3 + OUT: <<(*,$1,$2) --> REPRESENT> ==> (/,(/,REPRESENT,_,<(*,DOG,$2) --> FOOD>),dog,_,$1)>>. %1.00;0.90% {15 : 2} +3 + OUT: <(*,meat,MEAT) --> REPRESENT>. %1.00;0.90% {18 : 1} + OUT: (/,REPRESENT,meat,_)>. %1.00;0.90% {18 : 1} +2 + OUT: <<$1 --> (/,REPRESENT,_,$2)> ==> (/,(/,REPRESENT,_,<(*,DOG,$2) --> FOOD>),_,eat,$1)>>. %1.00;0.90% {20 : 2} +6 + OUT: <<$1 --> (/,REPRESENT,_,$2)> ==> (/,(/,REPRESENT,_,<(*,DOG,$2) --> FOOD>),_,eat,$1)>>. %1.00;0.90% {26 : 2} +2 + OUT: <(*,meat,MEAT) --> REPRESENT>. %1.00;0.90% {28 : 1} + OUT: (/,REPRESENT,meat,_)>. %1.00;0.90% {28 : 1} +8 + OUT: <(*,meat,MEAT) --> REPRESENT>. %1.00;0.90% {36 : 1} + OUT: (/,REPRESENT,meat,_)>. %1.00;0.90% {36 : 1} +10 + OUT: <<$1 --> (/,REPRESENT,_,$2)> ==> (/,(/,REPRESENT,_,<(*,DOG,$2) --> FOOD>),_,eat,$1)>>. %1.00;0.90% {46 : 2} +2 + OUT: (/,REPRESENT,meat,_)>. %1.00;0.90% {48 : 1} +1 + OUT: (/,REPRESENT,meat,_)>. %1.00;0.90% {49 : 1} +5 + OUT: <(*,meat,MEAT) --> REPRESENT>. %1.00;0.90% {54 : 1} +4 + OUT: <(*,meat,MEAT) --> REPRESENT>. %1.00;0.90% {58 : 1} + OUT: (/,REPRESENT,meat,_)>. %1.00;0.90% {58 : 1} +4 + OUT: <<(*,$1,$2) --> REPRESENT> ==> (/,(/,REPRESENT,_,<(*,DOG,$2) --> FOOD>),dog,_,$1)>>. %1.00;0.90% {62 : 2} +10 + OUT: <<$1 --> (/,REPRESENT,_,$2)> ==> (/,(/,REPRESENT,_,<(*,DOG,$2) --> FOOD>),_,eat,$1)>>. %1.00;0.90% {72 : 2} +2 + OUT: (/,REPRESENT,meat,_)>. %1.00;0.90% {74 : 1} +5 + OUT: <<(*,$1,$2) --> REPRESENT> ==> (/,(/,REPRESENT,_,<(*,DOG,$2) --> FOOD>),dog,_,$1)>>. %1.00;0.90% {79 : 2} +5 + OUT: (/,REPRESENT,meat,_)>. %1.00;0.90% {84 : 1} +3 + OUT: <<(*,$1,$2) --> REPRESENT> ==> (/,(/,REPRESENT,_,<(*,DOG,$2) --> FOOD>),_,eat,$1)>>. %1.00;0.90% {87 : 2} +4 + OUT: (/,(/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>),dog,_,meat)>. %1.00;0.81% {91 : 2;1} +8 + OUT: <<(*,$1,$2) --> REPRESENT> ==> (/,(/,REPRESENT,_,<(*,DOG,$2) --> FOOD>),_,eat,$1)>>. %1.00;0.90% {99 : 2} +1 + OUT: <(*,meat,MEAT) --> REPRESENT>. %1.00;0.90% {100 : 1} +3 + OUT: <(*,meat,MEAT) --> REPRESENT>. %1.00;0.90% {103 : 1} +3 + OUT: <(*,meat,MEAT) --> REPRESENT>. %1.00;0.90% {106 : 1} + OUT: (/,REPRESENT,meat,_)>. %1.00;0.90% {106 : 1} +11 + OUT: <(*,meat,MEAT) --> REPRESENT>. %1.00;0.90% {117 : 1} + OUT: (/,REPRESENT,meat,_)>. %1.00;0.90% {117 : 1} +11 + OUT: <(*,meat,MEAT) --> REPRESENT>. %1.00;0.90% {128 : 1} + OUT: (/,REPRESENT,meat,_)>. %1.00;0.90% {128 : 1} +6 + OUT: (/,(/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>),dog,_,meat)>. %1.00;0.81% {134 : 1;2} +5 + OUT: <(*,meat,MEAT) --> REPRESENT>. %1.00;0.90% {139 : 1} + OUT: (/,REPRESENT,meat,_)>. %1.00;0.90% {139 : 1} +10 + OUT: <<(*,$1,$2) --> REPRESENT> ==> (/,(/,REPRESENT,_,<(*,DOG,$2) --> FOOD>),_,eat,$1)>>. %1.00;0.90% {149 : 2} +7 + OUT: <(*,meat,MEAT) --> REPRESENT>. %1.00;0.90% {156 : 1} + OUT: (/,REPRESENT,meat,_)>. %1.00;0.90% {156 : 1} +6 + OUT: (/,(/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>),_,eat,meat)>. %1.00;0.81% {162 : 1;2} +***14 [transformation] + IN: (/,(/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>),_,eat,meat)>. %1.00;0.90% {0 : 1} +8 + OUT: <(*,dog,eat,meat) --> (/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>)>. %1.00;0.90% {8 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>),dog,_,meat)>. %1.00;0.90% {8 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>),dog,eat,_)>. %1.00;0.90% {8 : 1} +***15 [question answering] + IN: <(*,dog,eat,meat) --> (/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>)>. %1.00;0.90% {0 : 1} + IN: (/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>)>? {0 : 2} +4 + OUT: <(*,?1,<(*,DOG,MEAT) --> FOOD>) --> REPRESENT>? {4 : 2} + OUT: <<(*,DOG,MEAT) --> FOOD> --> (/,REPRESENT,?1,_)>? {4 : 2} +1 + OUT: (/,(/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>),_,eat,meat)>. %1.00;0.90% {5 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>),dog,_,meat)>. %1.00;0.90% {5 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>),dog,eat,_)>. %1.00;0.90% {5 : 1} + OUT: <(*,(*,dog,eat,meat),<(*,DOG,MEAT) --> FOOD>) --> REPRESENT>. %1.00;0.90% {5 : 1} + OUT: <<(*,DOG,MEAT) --> FOOD> --> (/,REPRESENT,(*,dog,eat,meat),_)>. %1.00;0.90% {5 : 1} +3 + OUT: <(*,?1,<(*,DOG,MEAT) --> FOOD>) --> REPRESENT>? {8 : 2} + OUT: <<(*,DOG,MEAT) --> FOOD> --> (/,REPRESENT,?1,_)>? {8 : 2} +11 + OUT: <(*,dog,eat,meat) --> (/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>)>. %1.00;0.90% {0 : 1} + OUT: (*,dog,eat,meat)>? {19 : 1;2} + OUT: <(*,dog,eat,meat) --> ?1>? {19 : 1;2} + OUT: (*,dog,eat,meat)>? {19 : 1;2} +***16 [question answering] + IN: <(*,dog,eat,meat) --> (/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>)>. %1.00;0.90% {0 : 1} + IN: <(*,dog,eat,meat) --> (/,REPRESENT,_,?1)>? {0 : 2} +5 + OUT: (/,(/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>),_,eat,meat)>. %1.00;0.90% {5 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>),dog,_,meat)>. %1.00;0.90% {5 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>),dog,eat,_)>. %1.00;0.90% {5 : 1} + OUT: <(*,(*,dog,eat,meat),<(*,DOG,MEAT) --> FOOD>) --> REPRESENT>. %1.00;0.90% {5 : 1} + OUT: <<(*,DOG,MEAT) --> FOOD> --> (/,REPRESENT,(*,dog,eat,meat),_)>. %1.00;0.90% {5 : 1} +3 + OUT: (/,(/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>),_,eat,meat)>. %1.00;0.90% {8 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>),dog,_,meat)>. %1.00;0.90% {8 : 1} + OUT: (/,(/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>),dog,eat,_)>. %1.00;0.90% {8 : 1} + OUT: <(*,(*,dog,eat,meat),<(*,DOG,MEAT) --> FOOD>) --> REPRESENT>. %1.00;0.90% {8 : 1} + OUT: <<(*,DOG,MEAT) --> FOOD> --> (/,REPRESENT,(*,dog,eat,meat),_)>. %1.00;0.90% {8 : 1} +8 + OUT: <(*,dog,eat,meat) --> (/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>)>. %1.00;0.90% {0 : 1} + OUT: <(/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>) --> (/,REPRESENT,_,?1)>? {16 : 1;2} + OUT: <(/,REPRESENT,_,?1) --> (/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>)>? {16 : 1;2} + OUT: <(/,REPRESENT,_,?1) <-> (/,REPRESENT,_,<(*,DOG,MEAT) --> FOOD>)>? {16 : 1;2} diff --git a/nars-dist/NARS-applet.html b/nars-dist/NARS-applet.html new file mode 100755 index 00000000..d76e27b0 --- /dev/null +++ b/nars-dist/NARS-applet.html @@ -0,0 +1,15 @@ + + + + + + NARS + + +NARS is running. To stop it, close this window. +

+If you don't see the two applet windows, most likely it is because your browser does not support Java. You can test it here. +

+ + + diff --git a/nars-dist/README.TXT b/nars-dist/README.TXT new file mode 100755 index 00000000..ac612be1 --- /dev/null +++ b/nars-dist/README.TXT @@ -0,0 +1,33 @@ +======================== +BUILD OUTPUT DESCRIPTION +======================== + +When you build an Java application project that has a main class, the IDE +automatically copies all of the JAR +files on the projects classpath to your projects dist/lib folder. The IDE +also adds each of the JAR files to the Class-Path element in the application +JAR files manifest file (MANIFEST.MF). + +To run the project from the command line, go to the dist folder and +type the following: + +java -jar "NARS.jar" + +To distribute this project, zip up the dist folder (including the lib folder) +and distribute the ZIP file. + +Notes: + +* If two JAR files on the project classpath have the same name, only the first +JAR file is copied to the lib folder. +* Only JAR files are copied to the lib folder. +If the classpath contains other types of files or folders, none of the +classpath elements are copied to the lib folder. In such a case, +you need to copy the classpath elements to the lib folder manually after the build. +* If a library on the projects classpath also has a Class-Path element +specified in the manifest,the content of the Class-Path element has to be on +the projects runtime path. +* To set a main class in a standard Java project, right-click the project node +in the Projects window and choose Properties. Then click Run and enter the +class name in the Main Class field. Alternatively, you can manually type the +class name in the manifest Main-Class element. diff --git a/nars-dist/README_USER.txt b/nars-dist/README_USER.txt new file mode 100755 index 00000000..f515011c --- /dev/null +++ b/nars-dist/README_USER.txt @@ -0,0 +1,27 @@ + +You can launch NARS by clicking the icon of NARS.jar, or in several ways from command window (shell): + +- empty reasoner: +java -jar NARS.jar + +- reasoner loaded from an experience file: +java -jar NARS.jar Examples/Example-NAL1-edited.txt --silence 90 + +- reasoner in batch: +java -cp NARS.jar nars.main_nogui.NARSBatch Examples/Example-NAL1-edited.txt + +Example experience files are in directory Examples. +- "Example-NALn-*.txt" contains single step examples for most of the inference rules defined in NAL level n. The "edited" version contains English translations, and with the unrelated information removed; the "unedited" version contains the actual input/output data recorded by the "Save Experience" function of the GUI. The files can be loaded using the "Load Experience" function of the GUI. +- "Example-MultiStep-edited" contains multi-step inference examples described in http://code.google.com/p/open-nars/wiki/MultiStepExamples +- "Example-NLP-edited" contains an example of natural language processing described in the AGI-13 paper "Natural Language Processing by Reasoning and Learning". + +An HTML user manual is here: +http://www.cis.temple.edu/~pwang/Implementation/NARS/NARS-GUI-Guide.html + +The project home page: +https://code.google.com/p/open-nars/ + +Discussion Group: +https://groups.google.com/forum/?fromgroups#!forum/open-nars + + diff --git a/nars-dist/tests/nal1/forward-in.nars b/nars-dist/tests/nal1/forward-in.nars new file mode 100755 index 00000000..522b0b89 --- /dev/null +++ b/nars-dist/tests/nal1/forward-in.nars @@ -0,0 +1,29 @@ +// Table 3.3: The Basic Syllogistic Rules +**** Deduction , Exemplification +< M --> P >. +< S --> M >. +< S --> P >? +< P --> S >? +11 +**** Induction +< M --> P >. +< M --> S >. +< S --> P >? +< P --> S >? +6 +**** Abduction +< P --> M >. +< S --> M >. +< S --> P >? +< P --> S >? +6 +**** Exemplification , Deduction +< P --> M >. +< M --> S >. +< S --> P >? +< P --> S >? +6 +**** Conversion +< P --> S >. +< S --> P >? +3 diff --git a/nars-dist/tests/nal1/revision_choice-in.nars b/nars-dist/tests/nal1/revision_choice-in.nars new file mode 100755 index 00000000..96e4bd14 --- /dev/null +++ b/nars-dist/tests/nal1/revision_choice-in.nars @@ -0,0 +1,10 @@ +**** Revision +S. +S. +S? +1 +**** Choice : no result : normal : no common term +S1. %0.50;0.90% +S2. %0.9;0.70% +S? +100 diff --git a/nars-dist/tests/nal2/similarity-in.nars b/nars-dist/tests/nal2/similarity-in.nars new file mode 100755 index 00000000..a1485cc0 --- /dev/null +++ b/nars-dist/tests/nal2/similarity-in.nars @@ -0,0 +1,37 @@ +* Comparison +P>. +S>. + P >? +6 +* Analogy +P>. +M>. + P >? +6 + +* Comparison +

M>. +M>. + P >? +6 +* Analogy +

M>. +M>. +

S>? +6 + +* Analogy +P>. +M>. + P >? +6 +* Analogy +P>. +S>. +

S >? +6 +* Resemblance +P>. +M>. + P>? +6 diff --git a/nars-dist/tests/nal4/definition-in.nars b/nars-dist/tests/nal4/definition-in.nars new file mode 100755 index 00000000..ddffab1e --- /dev/null +++ b/nars-dist/tests/nal4/definition-in.nars @@ -0,0 +1,7 @@ +// Definition 38 For two terms T1 and T2 , their product (T1 × T2 ) is a compound term defined by +// ((S1 × S2 ) → (P1 × P2 )) ≡ ((S1 → P1 ) ∧ (S2 → P2 )). +<(*,S1, S2 ) --> (*,P1, P2 )>. + P1>? + P2>? +(&&, P1>, P2>)? + diff --git a/nars-dist/tests/nal4/definition2-in.nars b/nars-dist/tests/nal4/definition2-in.nars new file mode 100755 index 00000000..ac25db0d --- /dev/null +++ b/nars-dist/tests/nal4/definition2-in.nars @@ -0,0 +1,5 @@ +// Definition 38 : For two terms T1 and T2 , their product (T1 × T2 ) is a compound term defined by +// ((S1 × S2 ) → (P1 × P2 )) ≡ ((S1 → P1 ) ∧ (S2 → P2 )). +(&&, P1>, P2>) . +<(*,S1, S2 ) --> (*,P1, P2 )> ? + diff --git a/nars-dist/tests/nal5/syllogism-in.nars b/nars-dist/tests/nal5/syllogism-in.nars new file mode 100755 index 00000000..7474c9cd --- /dev/null +++ b/nars-dist/tests/nal5/syllogism-in.nars @@ -0,0 +1,15 @@ +* + P>. +M. +P? +6 +* +

M>. +M. +P? +6 +* + P>. +M. +P? +6 diff --git a/nars-dist/tests/nal6/dependent_variable_introduction-in.nars b/nars-dist/tests/nal6/dependent_variable_introduction-in.nars new file mode 100755 index 00000000..95a0c0b0 --- /dev/null +++ b/nars-dist/tests/nal6/dependent_variable_introduction-in.nars @@ -0,0 +1,6 @@ +// Table 8.4: Sample Dependent-Variable Introduction Rule + P>. + S>. +(&&,<#x --> P >, <#x --> S>) ? +// Fint +4 diff --git a/nars-dist/tests/nal6/independent_variable_introduction-in.nars b/nars-dist/tests/nal6/independent_variable_introduction-in.nars new file mode 100755 index 00000000..e5ad5b00 --- /dev/null +++ b/nars-dist/tests/nal6/independent_variable_introduction-in.nars @@ -0,0 +1,42 @@ +// made by combining Table 8.3 and Table 3.3: Basic Syllogistic Rules + +// Table 8.3: Sample Independent-Variable Introduction Rules +**** Induction + P>. + S>. +<<$x --> S> ==> <$x --> P>>? +4 +* +**** Comparison : verbatim like in table 8.3 + P>. + S>. +<<$x --> S> <=> <$x --> P>>? +4 + +**** Abduction +< P --> M >. +< S --> M >. +<< S --> $x > ==> < P --> $x >>? +4 +**** Abduction and <=> +< P --> M >. +< S --> M >. +<< S --> $x > <=> < P --> $x >>? +4 + +**** Deduction , Exemplification : no result +< M --> P >. +< S --> M >. +<< S --> $x > ==> <$x --> P>>? +6 + +**** Exemplification , Deduction : no result +< P --> M >. +< M --> S >. +<<$x --> S> ==> < P --> $x >>? +6 + +**** Conversion : no result +< P --> S >. +<<$x --> S> ==> <$x --> P>>? +30 diff --git a/nars-dist/tests/nal6/multi-variable_introduction-in.nars b/nars-dist/tests/nal6/multi-variable_introduction-in.nars new file mode 100755 index 00000000..5123edef --- /dev/null +++ b/nars-dist/tests/nal6/multi-variable_introduction-in.nars @@ -0,0 +1,11 @@ +// Table 8.6: Sample Multi-Variable Introduction Rules +// {(#x → P ) ⇒ (M → (⊥ R #x <>)), M → S} |- +// ((#y → S) ∧ (#x → P )) ⇒ (#y → (⊥ R #x <>)) Find + +// fails !!! +< <#x --> P > ==> (/,R, #x, _ ) > >. +< M --> S>. +<(&&, <#y --> S>, <#x --> P> ) ==> <#y --> (/, R, #x, _ )> > ? +// induction + + diff --git a/nars-dist/tests/nal6/variable-elimination-in.nars b/nars-dist/tests/nal6/variable-elimination-in.nars new file mode 100755 index 00000000..84329e9d --- /dev/null +++ b/nars-dist/tests/nal6/variable-elimination-in.nars @@ -0,0 +1,45 @@ +// Table 8.2: Sample Independent-Variable Elimination Rules +* Deduction +<<#x --> S> ==> <#x --> P >>. +< M --> S >. + P >? +6 + +* Abduction +<<#x --> S> ==> <#x --> P >>. +< M --> P >. + S>? +6 + +* Induction : fails !!! +<<#x --> S> ==> <#x --> P >>. +< S --> M >. +< M --> P >? +4 + +* Exemplification : fails !!! +<<#x --> P> ==> <#x --> M >>. +< M --> S >. +< S --> P >? +4 + +// NAL2 rules + +* Analogy +<<#x --> S> <=> <#x --> P >>. + S>. + P>? +6 + +* Comparison : fails !!! +<<#x --> P> ==> <#x --> M >>. +< S --> M >. +< S <-> P >? +6 + +* Resemblance : fails !!! +<<#x --> P> <=> <#x --> M >>. +< S <-> M >. +< S <-> P >? +6 + diff --git a/nars/entity/Concept.java b/nars/entity/Concept.java deleted file mode 100644 index 04aeb2da..00000000 --- a/nars/entity/Concept.java +++ /dev/null @@ -1,493 +0,0 @@ -/* - * Concept.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.entity; - -import java.util.ArrayList; - -import nars.gui.ConceptWindow; -import nars.inference.*; -import nars.io.Record; -import nars.language.*; -import nars.main.*; -import nars.operation.Operator; -import nars.storage.*; - -/** - * A concept contains information associated with a term, including directly - * and indirectly related tasks and beliefs. - *

- * To make sure the space will be released, the only allowed reference to a concept are - * those in a ConceptBag. All other access go through the Term that names the concept. - */ -public final class Concept extends Item { - - /** The term is the unique ID of the concept */ - private Term term; - /** Question directly asked about the term */ - private Question directQuestion; - /** Goals directly requested on the term */ - private ArrayList directGoals; - /** Judgments directly made about the term */ - private ArrayList directBeliefs; - /** Whether truth value of judgments can be revised */ - private boolean revisible = true; // - /** Task links for indirect processing */ - private TaskLinkBag taskLinks; - /** Term links between the term and its components and compounds */ - private TermLinkBag termLinks; - /** Link templates of TermLink, only in concepts with CompoundTerm */ - private ArrayList termLinkTemplates; - /** Whether the term specifies an event [to be refined] */ - private boolean event = false; - /** Whether the content of the concept is being displayed */ - private boolean showing = false; - /** The display window */ - private ConceptWindow window = null; - - /* ---------- constructor and intialization ---------- */ - /** - * Constructor, called in Memory.getConcept only - * @param tm A term corresponding to the concept - */ - public Concept(Term tm) { - super(); - key = tm.toString(); - term = tm; - directQuestion = null; - directGoals = new ArrayList(); - directBeliefs = new ArrayList(); - taskLinks = new TaskLinkBag(); - termLinks = new TermLinkBag(); - if (tm instanceof CompoundTerm) { - termLinkTemplates = ((CompoundTerm) tm).prepareComponentLinks(); - checkRevisibility(); - if (tm instanceof Temporal) { - markEventComponents(); - } - } - } - - /** - * Judgments with dependent variable cannot be revised - */ - private void checkRevisibility() { - revisible = ((key.indexOf("()") < 0) && (key.indexOf("(#")) < 0); - } - - /** - * Terms in temporal compounds is event - */ - private void markEventComponents() { - Term component; - for (TermLink tLink : termLinkTemplates) { - component = tLink.getTarget(); - Concept concept = Memory.termToConcept(component); - if (concept != null) { - concept.setEvent(); - } - } - } - - /* ---------- direct processing of tasks ---------- */ - /** - * Directly process a new task. Called exactly once on each task. - * Using local information and finishing in a constant time. - * Provide feedback in the budget value of the task. - *

- * called in Memory.immediateProcess only - * @param task The task to be processed - */ - public void directProcess(Task task) { - Sentence sentence = task.getSentence(); - if (sentence instanceof Question) { - processQuestion((Question) sentence, task); - } else if (sentence instanceof Goal) { - processGoal((Goal) sentence, task); - } else { - processJudgment((Judgment) sentence, task); - } - if (showing) { - window.post(displayContent()); // show changes - } - } - - /** - * To answer a question by existing beliefs - * @param ques The question to be answered - * @param task The task to be processed - */ - private void processQuestion(Question ques, Task task) { - if (directQuestion == null) { // keep the existing one for answer information - directQuestion = ques; - } - for (Judgment judg : directBeliefs) { - MatchingRules.trySolution(directQuestion, judg, task); // look for better answer - } - } - - /** - * Direct processing a new goal - * @param goal The goal to be processed - * @param task The task to be processed - */ - private void processGoal(Goal goal, Task task) { - boolean revised = false; - if (revisible) { - revised = reviseTable(goal, task, directGoals); // revise desire - } - if (revised) { // don't process this goal, but the revised version - return; - } - for (Judgment judg : directBeliefs) { - MatchingRules.trySolution(goal, judg, task); // reality check - } - Term content = goal.getContent(); - if ((task.getPriority() >= Parameters.PRIORITY_THRESHOLD) && (content instanceof Inheritance)) { - Term pred = ((Inheritance) content).getPredicate(); - if (pred instanceof Operator) { - float netDesire = goal.getTruth().getExpectation(); - if (netDesire > Parameters.DECISION_THRESHOLD) { - ((Operator) pred).call(task); - task.setPriority(0.0f); // each call is executed once - return; - } - } - } - if (task.aboveThreshold()) { - addToTable(goal, directGoals, Parameters.MAXMUM_GOALS_LENGTH); // indirectly archiving - } - } - - /** - * To accept a new judgment as belief, and check for revisions and solutions - * @param judg The judgment to be accepted - * @param task The task to be processed - */ - private void processJudgment(Judgment judg, Task task) { - if (judg.getTense() != TemporalRules.Relation.NONE) { - setEvent(); - } - if (revisible) { - boolean revised = reviseTable(judg, task, directBeliefs); - if (!revised) { - if (isEvent()) { - TemporalRules.eventProcessing(task); - } - } - } - if (task.aboveThreshold()) { - if (directQuestion != null) { - MatchingRules.trySolution(directQuestion, judg, task); - } - for (Goal goal : directGoals) { - MatchingRules.trySolution(goal, judg, task); - } - addToTable(judg, directBeliefs, Parameters.MAXMUM_BELIEF_LENGTH); - } - } - - /** - * Revise existing beliefs or goals - * @param task The task to be processed - * @param table The table to be revised - */ - private boolean reviseTable(Judgment newSentence, Task task, ArrayList table) { - boolean revised = false; - Judgment belief; - for (int i = table.size() - 1; i >= 0; i--) { - belief = (Judgment) table.get(i); - if ((newSentence.getTense() == belief.getTense()) && belief.noOverlapping(newSentence)) { - if (isUpdate(newSentence, belief)) { - MatchingRules.update(task, belief); - table.remove(i); - } else { - revised |= MatchingRules.revision(task, belief, false); - } - } - } - return revised; - } - - /** - * Distinguish update from revision [to be refined] - * @param newBelief The new belief - * @param oldBelief The previous belief - * @return Whether the operation is update - */ - private boolean isUpdate(Judgment newBelief, Judgment oldBelief) { - if (oldBelief.getTense() != TemporalRules.Relation.WHEN) { - return false; // only update belief with present tense - } - if (newBelief.getTruth().getExpDifAbs(oldBelief.getTruth()) < 0.5) { - return false; // update means major change in expectation - } - if ((newBelief.getStamp().latest() <= oldBelief.getStamp().latest())) { - return false; // update previous experience with recent experience - } - return true; - } - - /** - * Add a new belief or goal into the table - * Sort the beliefs/goals by rank, and remove redundant or low rank one - * @param newJudgment The judgment to be processed - * @param table The table to be revised - * @param capacity The capacity of the table - */ - @SuppressWarnings("unchecked") - private void addToTable(Judgment newJudgment, ArrayList table, int capacity) { - float rank1 = BudgetFunctions.rankBelief(newJudgment); // for the new belief - Judgment judgment2; - float rank2; - int i; - for (i = 0; i < table.size(); i++) { // go through everyone - judgment2 = (Judgment) table.get(i); - rank2 = BudgetFunctions.rankBelief(judgment2); // previous belief - if (rank1 >= rank2) { - if (newJudgment.equivalentTo(judgment2)) { - return; - } - table.add(i, newJudgment); - break; - } - } - if (table.size() == capacity) { - table.remove(capacity - 1); - } else if (i == table.size()) { - table.add(newJudgment); - } - } - - /* ---------- insert Links for indirect processing ---------- */ - /** - * Insert a TaskLink into the TaskLink bag - *

- * called only from Memory.continuedProcess - * @param taskLink The termLink to be inserted - */ - public void insertTaskLink(TaskLink taskLink) { - BudgetValue budget = taskLink.getBudget(); - taskLinks.putIn(taskLink); - Memory.activateConcept(this, budget); // activate the concept - } - - /** - * Recursively build TermLinks between a compound and its components - *

- * called only from Memory.continuedProcess - * @param budget The budget of the task - */ - public void buildTermLinks(BudgetValue budget) { - Term t; - Concept concept; - TermLink termLink1, termLink2; - BudgetValue subBudget = BudgetFunctions.distributeAmongLinks(budget, termLinkTemplates.size()); - if (subBudget.aboveThreshold()) { - for (TermLink template : termLinkTemplates) { - if (template.getType() != TermLink.TRANSFORM) { - t = template.getTarget(); - concept = Memory.getConcept(t); - termLink1 = new TermLink(t, template, subBudget); - insertTermLink(termLink1); // this termLink to that - termLink2 = new TermLink(term, template, subBudget); - concept.insertTermLink(termLink2); // that termLink to this - if (t instanceof CompoundTerm) { - concept.buildTermLinks(subBudget); - } - } - } - } - } - - /** - * Insert a TermLink into the TermLink bag - *

- * called from buildTermLinks only - * @param termLink The termLink to be inserted - */ - public void insertTermLink(TermLink termLink) { - termLinks.putIn(termLink); - } - - /* ---------- access local information ---------- */ - /** - * Return the assocated term, called from Memory only - * @return The assocated term - */ - public Term getTerm() { - return term; - } - - /** - * Distinguish events from non-events - * @return Whether the concept is an event - */ - public boolean isEvent() { - return event; - } - - /** - * Mark the concept as an event - */ - public void setEvent() { - event = true; - } - - /** - * Return a string representation of the concept, called in ConceptBag only - * @return The concept name, with budget in the full version - */ - @Override - public String toString() { // called from concept bag - if (NARS.isStandAlone()) { - return (super.toString2() + " " + key); - } else { - return key; - } - } - - /** - * Recalculate the quality of the concept [to be refined] - * @return The quality value - */ - @Override - public float getQuality() { - float linkPriority = termLinks.averagePriority(); - float termComplexityFactor = 1.0f / term.getComplexity(); - return UtilityFunctions.or(linkPriority, termComplexityFactor); - } - - /** - * Return the templates for TermLinks, only called in Memory.continuedProcess - * @return The template get - */ - public ArrayList getTermLinkTemplates() { - return termLinkTemplates; - } - - /** - * Select a belief to interact with the given task in inference - *

- * get the first qualified one - *

- * only called in RuleTables.reason - * @param task The selected task - * @return The selected belief - */ - public Judgment getBelief(Task task) { - Sentence taskSentence = task.getSentence(); - Judgment belief; - for (int i = 0; i < directBeliefs.size(); i++) { - belief = directBeliefs.get(i); - if (belief.noOverlapping(taskSentence)) { - Record.append(" * Selected Belief: " + belief + "\n"); - return belief; - } - } - return null; - } - - /* ---------- main loop ---------- */ - /** - * An atomic step in a concept, only called in Memory.processConcept - */ - public void fire() { - TaskLink tLink = taskLinks.takeOut(); - if (tLink == null) { - return; - } - Memory.currentTaskLink = tLink; - Memory.currentBeliefLink = null; - Record.append(" * Selected TaskLink: " + tLink + "\n"); - Task task = tLink.getTargetTask(); - Memory.currentTask = task; - if (tLink.getType() == TermLink.TRANSFORM) { - RuleTables.transformTask(task, tLink); // to turn this into structural inference as below? - return; - } - int termLinkCount = Parameters.MAX_REASONED_TERM_LINK; - while (Memory.noResult() && (termLinkCount > 0)) { - TermLink termLink = termLinks.takeOut(tLink); - if (termLink != null) { - Record.append(" * Selected TermLink: " + termLink + "\n"); - Memory.currentBeliefLink = termLink; - RuleTables.reason(tLink, termLink); - termLinks.putBack(termLink); - termLinkCount--; - } else { - termLinkCount = 0; - } - } - taskLinks.putBack(tLink); - } - - /* ---------- display ---------- */ - /** - * Start displaying contents and links, called from ConceptWindow only - */ - public void startPlay() { - window = new ConceptWindow(this); - showing = true; - window.post(displayContent()); - taskLinks.startPlay("Task Links in " + term); - termLinks.startPlay("Term Links in " + term); - } - - /** - * Resume display, called from ConceptWindow only - */ - public void play() { - showing = true; - window.post(displayContent()); - } - - /** - * Stop display, called from ConceptWindow only - */ - public void stop() { - showing = false; - } - - /** - * Collect direct belief, questions, and goals for display - * @return String representation of direct content - */ - private String displayContent() { - StringBuffer buffer = new StringBuffer(); - if (directBeliefs.size() > 0) { - buffer.append(" Beliefs:\n"); - for (int i = 0; i < directBeliefs.size(); i++) { - buffer.append(directBeliefs.get(i) + "\n"); - } - } - if (directGoals.size() > 0) { - buffer.append("\n Goals:\n"); - for (int i = 0; i < directGoals.size(); i++) { - buffer.append(directGoals.get(i) + "\n"); - } - } - if (directQuestion != null) { - buffer.append("\n Question:\n" + directQuestion + "\n"); - } - return buffer.toString(); - } -} - diff --git a/nars/entity/Goal.java b/nars/entity/Goal.java deleted file mode 100644 index 6f0897aa..00000000 --- a/nars/entity/Goal.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Goal.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ - -package nars.entity; - -import nars.inference.TemporalRules; -import nars.language.Term; - -/** - * A Goal is an event to be realized, and may conain query variables - */ -public class Goal extends Judgment { - /** - * Constructor - *

- * A goal has no tense - * @param term The content - * @param punc The punctuation - * @param t The desire (truth) value - * @param s The stamp - */ - public Goal(Term term, char punc, TruthValue t, Stamp s) { - super(term, punc, TemporalRules.Relation.NONE, t, s); - } -} - diff --git a/nars/entity/Item.java b/nars/entity/Item.java deleted file mode 100644 index 698905b1..00000000 --- a/nars/entity/Item.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Item.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.entity; - -/** - * An item is an object that can be put into a Bag, - * to participate in the resource competation of the system. - *

- * It has a key and a budget. - */ -public abstract class Item extends BudgetValue { - - /** The key of the Item, unique in a Bag */ - protected String key; // uniquely define an Item in a bag - - /** - * Default constructor - */ - protected Item() { - super(); - } - - /** - * Constructor with initial budget - * @param v The initial budget - */ - protected Item(BudgetValue v) { - super(v); - } - - /** - * Get the current key - * @return Current key value - */ - public String getKey() { - return key; - } - - /** - * Get current BudgetValue - *

- * This method is redundant, just to make the code more readable - * @return Current BudgetValue - */ - public BudgetValue getBudget() { - return this; - } -} diff --git a/nars/entity/Judgment.java b/nars/entity/Judgment.java deleted file mode 100644 index 9cf00033..00000000 --- a/nars/entity/Judgment.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Judgment.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.entity; - -import nars.inference.TemporalRules; -import nars.io.Symbols; -import nars.language.Term; -import nars.main.Parameters; - -/** - * A Judgment is an piece of new knowledge to be absorbed. - */ -public class Judgment extends Sentence { - - /** - * Constructor - * @param term The content - * @param punc The punctuation - * @param s The tense - * @param t The truth value - * @param b The stamp - */ - public Judgment(Term term, char punc, TemporalRules.Relation s, TruthValue t, Stamp b) { - content = term; - punctuation = punc; - tense = s; - truth = t; - stamp = b; - } - - /** - * Construct a Judgment to indicate an operation just executed - * @param g The goal that trigger the execution - */ - public Judgment(Goal g) { - content = g.cloneContent(); - punctuation = Symbols.JUDGMENT_MARK; - tense = TemporalRules.Relation.BEFORE; - truth = new TruthValue(1.0f, Parameters.DEFAULT_JUDGMENT_CONFIDENCE); - stamp = new Stamp(); - } - - /** - * Check whether the judgment is equivalent to another one - *

- * The two may have different keys - * @param that The other judgment - * @return Whether the two are equivalent - */ - boolean equivalentTo(Judgment that) { - assert content.equals(that.getContent()); - return (truth.equals(that.getTruth()) && stamp.equals(that.getStamp())); - } - - /** - * Evaluate the quality of the judgment as a solution to a problem - * @param problem A goal or question - * @return The quality of the judgment as the solution - */ - public float solutionQuality(Sentence problem) { - if (problem instanceof Goal) { - return truth.getExpectation(); - } else if (problem.getContent().isConstant()) { // "yes/no" question - return truth.getConfidence(); - } else { // "what" question or goal - return truth.getExpectation() / content.getComplexity(); - } - } -} - diff --git a/nars/entity/Question.java b/nars/entity/Question.java deleted file mode 100644 index ef7d1f15..00000000 --- a/nars/entity/Question.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Question.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ - -package nars.entity; - -import nars.inference.TemporalRules; -import nars.language.Term; - -/** - * A Question is a sentence without a truth value, and may conain query variables - */ -public class Question extends Sentence { - - /** - * COnstructor - * @param term The content - * @param punc The punctuation - * @param t The tense - * @param s The stamp - */ - public Question(Term term, char punc, TemporalRules.Relation t, Stamp s) { - content = term; - punctuation = punc; - tense = t; - stamp = s; - } -} diff --git a/nars/entity/Sentence.java b/nars/entity/Sentence.java deleted file mode 100644 index e3f5734d..00000000 --- a/nars/entity/Sentence.java +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Sentence.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.entity; - -import nars.inference.TemporalRules; -import nars.io.Symbols; -import nars.language.*; -import nars.main.*; - -/** - * A Sentence is an abstract class, mainly containing a Term, a TruthValue, and a Stamp. - *

- * It is used as the premises and conclusions of all inference rules. - */ -public abstract class Sentence implements Cloneable { - - /** The content of a Sentence is a Term */ - protected Term content; - /** The punctuation also indicates the type of the Sentence: Judgment, Question, or Goal */ - protected char punctuation; - /** The tense of a Sentence can be BEFORE(past), WHEN(present), AFTER(future), or NONE */ - protected TemporalRules.Relation tense = TemporalRules.Relation.NONE; - /** The truth value of Judgment or desire value of Goal */ - protected TruthValue truth = null; - /** Partial record of the derivation path */ - protected Stamp stamp = null; - /** Whether it is an input sentence */ - protected boolean input = false; - /** For Question and Goal: best solution found so far */ - protected Judgment bestSolution = null; - - /** - * Make a Sentence from an input String. Called by StringParser. - * @param term The content of the sentence - * @param punc The puncuation (and therefore, type) of the sentence - * @param tense The tense of the sntense - * @param truth The truth value of the sentence, if it is a Judgment (or Goal) - * @param stamp The stamp of the truth value (for Judgment or Goal) - * @return the Sentence generated from the arguments - */ - public static Sentence make(Term term, char punc, TemporalRules.Relation tense, TruthValue truth, Stamp stamp) { - if (term instanceof CompoundTerm) { - ((CompoundTerm) term).renameVariables(); - } - switch (punc) { - case Symbols.JUDGMENT_MARK: - return new Judgment(term, punc, tense, truth, stamp); - case Symbols.GOAL_MARK: - return new Goal(term, punc, truth, stamp); - case Symbols.QUESTION_MARK: - return new Question(term, punc, tense, stamp); - default: - return null; - } - } - - /** - * Make a derived Sentence from a template and some initial values. Called by Memory. - * @param term The content of the sentence - * @param oldS A sample sentence providing the type of the new sentence - * @param tense The tense of the sentence - * @param truth The truth value of the sentence, if it is a Judgment (or Goal) - * @param stamp The stamp of the truth value (for Judgment or Goal) - * @return the Sentence generated from the arguments - */ - public static Sentence make(Sentence oldS, Term term, TemporalRules.Relation tense, TruthValue truth, Stamp stamp) { - if (term instanceof CompoundTerm) { - ((CompoundTerm) term).renameVariables(); - } - if (oldS instanceof Question) { - return new Question(term, Symbols.QUESTION_MARK, tense, stamp); - } - if (oldS instanceof Goal) { - return new Goal(term, Symbols.GOAL_MARK, truth, stamp); - } - return new Judgment(term, Symbols.JUDGMENT_MARK, tense, truth, stamp); - } - - /** - * Clone the Sentence - * @return The clone - */ - @Override - public Object clone() { - return make(content, punctuation, tense, truth, stamp); - } - - /** - * Get the content of the sentence - * @return The content Term - */ - public Term getContent() { - return content; - } - - /** - * Clone the content of the sentence - * @return A clone of the content Term - */ - public Term cloneContent() { - return (Term) content.clone(); - } - - /** - * Set the content Term of the Sentence - * @param t The new content - */ - public void setContent(Term t) { - content = t; - } - - /** - * Get the tense of the Sentence - * @return The tense of the Sentence - */ - public TemporalRules.Relation getTense() { - return tense; - } - - /** - * Set the tense of the Sentence - * @param t The new tense of the Sentence - */ - public void setTense(TemporalRules.Relation t) { - tense = t; - } - - /** - * Get the truth value of the sentence - * @return Truth value, null for question - */ - public TruthValue getTruth() { - return truth; - } - - /** - * Get the stamp of the sentence - * @return The stamp - */ - public Stamp getStamp() { - return stamp; - } - - /** - * Distinguish Judgment from Goal ("instanceof Judgment" doesn't work) - * @return Whether the object is a Judgment - */ - public boolean isJudgment() { - return (punctuation == Symbols.JUDGMENT_MARK); - } - - /** - * Check input sentence - * @return Whether the - */ - public boolean isInput() { - return input; - } - - /** - * The only place to change the default, called in StringParser - */ - public void setInput() { - input = true; - } - - /** - * Get the best-so-far solution for a Question or Goal - * @return The stored Judgment or null - */ - public Judgment getBestSolution() { - return bestSolution; - } - - /** - * Set the best-so-far solution for a Question or Goal - * @param judg The solution to be remembered - */ - public void setBestSolution(Judgment judg) { - bestSolution = judg; - if (input) { - Memory.report(judg, false); // report answer to input question - } - } - - /** - * Check whether one sentence has stamp overlapping with another one, and change the system cash - * @param that The sentence to be checked against - * @return Whether the two have overlapping stamps - */ - public boolean noOverlapping(Sentence that) { - Memory.currentStamp = Stamp.make(stamp, that.getStamp()); - return (Memory.currentStamp != null); - } - - /** - * Get a String representation of the sentence - * @return The String - */ - @Override - public String toString() { - StringBuffer s = new StringBuffer(); - s.append(content.getName()); - s.append(punctuation + " "); - s.append(tenseToString()); - if (truth != null) { - s.append(truth.toString()); - } - if (NARS.isStandAlone()) { - s.append(stamp.toString()); - if (bestSolution != null) { - s.append("BestSolution: " + bestSolution); - } - } - return s.toString(); - } - - /** - * Get a String representation of the sentence, with 2-digit accuracy - * @return The String - */ - public String toString2() { - StringBuffer s = new StringBuffer(); - s.append(content.getName()); - s.append(punctuation + " "); - s.append(tenseToString()); - if (truth != null) { - s.append(truth.toString2()); - } - if (NARS.isStandAlone()) { - s.append(stamp.toString()); - if (bestSolution != null) { - s.append("BestSolution: " + bestSolution); - } - } - return s.toString(); - } - - /** - * Get a String representation of the tense of the sentence - * @return The String - */ - private String tenseToString() { - if (tense == TemporalRules.Relation.BEFORE) { - return Symbols.TENSE_PAST + " "; - } - if (tense == TemporalRules.Relation.WHEN) { - return Symbols.TENSE_PRESENT + " "; - } - if (tense == TemporalRules.Relation.AFTER) { - return Symbols.TENSE_FUTURE + " "; - } - return ""; - } -} diff --git a/nars/entity/Stamp.java b/nars/entity/Stamp.java deleted file mode 100644 index 680bd1c9..00000000 --- a/nars/entity/Stamp.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Stamp.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.entity; - -import java.util.*; - -import nars.io.Symbols; -import nars.main.Parameters; -import nars.inference.*; - -/** - * Each Sentence has a get of serial numbers of a constant length attached. - * The input sentence gets a unique number. - * The derived sentences inherits from its parents, then cut at the length limit. - */ -public class Stamp implements Cloneable { - /** serial numbers */ - private long[] list; - /** current stamp length */ - private int length; - /** serial number, for the whole system */ - private static long current = 0; - - /** - * Generate a new stamp, with a new serial number, for input sentence - */ - public Stamp() { - current++; - length = 1; - list = new long[length]; - list[0] = current; - } - - /** - * Generate a new stamp for derived sentence by merging the two from parents - * the first one is no shorter than the second - * @param first The first Stamp - * @param second The second Stamp - */ - private Stamp(Stamp first, Stamp second) { - int i1, i2, j; - i1 = i2 = j = 0; - length = Math.min(first.length() + second.length(), Parameters.MAXMUM_STAMP_LENGTH); - list = new long[length]; - while (i2 < second.length() && j < length) { - list[j] = first.get(i1); - i1++; - j++; - list[j] = second.get(i2); - i2++; - j++; - } - while (i1 < first.length() && j < length) { - list[j] = first.get(i1); - i1++; - j++; - } - } - - /** - * Try to merge two Stamps, return null if have overlap - * @param first The first Stamp - * @param second The second Stamp - * @return The merged Stamp, or null - */ - public static Stamp make(Stamp first, Stamp second) { - for (int i = 0; i < first.length(); i++) { - for (int j = 0; j < second.length(); j++) { - if (first.get(i) == second.get(j)) { - return null; - } - } - } - if (first.length() > second.length()) { - return new Stamp(first, second); - } else { - return new Stamp(second, first); - } - } - - /** - * Initialize the stamp machenism of the system, called in Center - */ - public static void init() { - current = 0; - } - - /** - * Return the length of the list - * @return Length of the Stamp - */ - public int length() { - return length; - } - - /** - * Get a number from the list by index, called in this class only - * @param i The index - * @return The number at the index - */ - long get(int i) { - return list[i]; - } - - /** - * Convert the list into a set - */ - TreeSet toSet() { - TreeSet set = new TreeSet(); - for (int i = 0; i < length; i++) { - set.add(list[i]); - } - return set; - } - - /** - * Check if two stamps contains the same set of numbers - * @param that The Stamp to be compared - * @return Whether the two have contain the same elements - */ - @Override - public boolean equals(Object that) { - if (!(that instanceof Stamp)) { - return false; - } - TreeSet set1 = toSet(); - TreeSet set2 = ((Stamp) that).toSet(); - return (set1.containsAll(set2) && set2.containsAll(set1)); - } - - /** - * The hash code of Stamp - * @return The hash code - */ - @Override - public int hashCode() { - int hash = 7; - return hash; - } - - /** - * Get the latest Stamp in the list - * @return The largest number in the stamp - */ - public long latest() { - TreeSet set = toSet(); - Long number = set.last(); - return (long) number; - } - - /** - * Compare two Stamps for their temporal order - * @param that The STamp to be compared - * @return The temporal order - */ - public TemporalRules.Relation orderWith(Stamp that) { - TreeSet set1 = toSet(); - TreeSet set2 = that.toSet(); - long first1 = (long) set1.first(); - long last1 = (long) set1.last(); - long first2 = (long) set2.first(); - long last2 = (long) set2.last(); - if (last1 < first2) { - return TemporalRules.Relation.AFTER; - } - if (last2 < first1) { - return TemporalRules.Relation.BEFORE; - } - if ((first1 == first2) && (last1 == last2)) { - return TemporalRules.Relation.WHEN; - } - return null; - } - - /** - * Get a String form of the Stamp for display - * @return The Stamp as a String - */ - @Override - public String toString() { - StringBuffer buffer = new StringBuffer(Symbols.STAMP_OPENER + length + Symbols.STAMP_STARTER); - for (int i = 0; i < length; i++) { - buffer.append(Long.toString(list[i])); - if (i < (length - 1)) { - buffer.append(Symbols.STAMP_SEPARATOR); - } else { - buffer.append(Symbols.STAMP_CLOSER); - } - } - return buffer.toString(); - } -} diff --git a/nars/entity/Task.java b/nars/entity/Task.java deleted file mode 100644 index 302fc36c..00000000 --- a/nars/entity/Task.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Task.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.entity; - -import nars.inference.TemporalRules; -import nars.language.Term; -import nars.main.NARS; - -/** - * A task to be processed, consists of a Sentence and a BudgetValue - */ -public class Task extends Item { - /** The sentence of the Task */ - private Sentence sentence; - /** Whether it is derived by a structual rule */ - protected boolean structual = false; // - - /** - * Constructor - * @param s The sentence - * @param b The budget - */ - public Task(Sentence s, BudgetValue b) { - super(b); - sentence = s; - key = sentence.toString(); - } - - /** - * Get the sentence - * @return The sentence - */ - public Sentence getSentence() { - return sentence; - } - - /** - * Directly get the content of the sentence - * @return The content of the sentence - */ - public Term getContent() { - return sentence.getContent(); - } - - /** - * Directly get the tense of the sentence - * @return The tense of the sentence - */ - public TemporalRules.Relation getTense() { - return sentence.getTense(); - } - - /** - * Check if a Task is derived by a StructuralRule - * @return Whether the Task is derived by a StructuralRule - */ - public boolean isStructual() { - return structual; - } - - /** - * Record if a Task is derived by a StructuralRule - */ - public void setStructual() { - structual = true; - } - - /** - * Merge one Task into another - * @param that The other Task - */ - public void merge(Item that) { - super.merge(that); - structual = (structual || ((Task) that).isStructual()); - } - - /** - * Get a String representation of the Task - * @return The Task as a String - */ - @Override - public String toString() { - StringBuffer s = new StringBuffer(); - if (NARS.isStandAlone()) { - s.append(super.toString() + " "); - } - s.append(sentence); - return s.toString(); - } - - /** - * Get a String representation of the Task, with reduced accuracy - * @return The Task as a String, with 2-digit accuracy for the values - */ - @Override - public String toString2() { - StringBuffer s = new StringBuffer(); - if (NARS.isStandAlone()) { - s.append(super.toString2() + " "); - } - if (sentence instanceof Question) { - s.append(sentence); - } else { - s.append(((Judgment) sentence).toString2()); - } - return s.toString(); - } -} diff --git a/nars/entity/TaskLink.java b/nars/entity/TaskLink.java deleted file mode 100644 index cee1eb52..00000000 --- a/nars/entity/TaskLink.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * TaskLink.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.entity; - -import java.util.*; - -import nars.language.Term; -import nars.main.Parameters; - -/** - * Reference to a Task. - *

- * The reason to separate a Task and a TaskLink is that the same Task can be linked from - * multiple Concepts, with different BudgetValue. - */ -public class TaskLink extends TermLink { - - /** The Task linked. The "target" field in TermLink is not used here. */ - private Task targetTask; - /** Remember the TermLinks that has been used recently with this TaskLink */ - private ArrayList record; - - /** - * Constructor - *

- * only called in Memory.continuedProcess - * @param t The target Task - * @param template The TermLink template - * @param v The budget - */ - public TaskLink(Task t, TermLink template, BudgetValue v) { - super(v); - targetTask = t; - if (template == null) { - type = TermLink.SELF; - index = null; - } else { - type = template.getType(); - index = template.getIndices(); - } - record = new ArrayList(Parameters.TERM_LINK_RECORD_LENGTH); - setKey(); // as defined in TermLink - key += t.getKey(); - } - - /** - * Get the target Task - * @return The linked Task - */ - public Task getTargetTask() { - return targetTask; - } - - /** - * Get the TermLink record - * @return The list of TermLinks recently used - */ - ArrayList getRecord() { - return record; - } - - /** - * Merge one TaskLink into another - * @param that The other TaskLink - */ - public void merge(Item that) { - super.merge(that); // merge the budgets - ArrayList v = ((TaskLink) that).getRecord(); - for (int i = 0; i < v.size(); i++) { // merge the records - if (record.size() <= Parameters.TERM_LINK_RECORD_LENGTH) { - record.add(v.get(i)); - } - } - } - - /** - * To check whether a TaskLink should use a TermLink, return false if they - * interacted recently - *

- * called in TermLinkBag only - * @param termLink The TermLink to be checked - * @return Whether they are novel to each other - */ - public boolean novel(TermLink termLink) { - Term bTerm = termLink.getTarget(); - if (bTerm.equals(targetTask.getSentence().getContent())) { - return false; - } - String linkKey = termLink.getKey(); - for (String recorded : record) { - if (linkKey.equals(recorded)) { - return false; - } - } - record.add(linkKey); // add knowledge reference to record - if (record.size() > Parameters.TERM_LINK_RECORD_LENGTH) { // keep a constant length - record.remove(0); - } - return true; - } -} - diff --git a/nars/entity/TruthValue.java b/nars/entity/TruthValue.java deleted file mode 100644 index 52026591..00000000 --- a/nars/entity/TruthValue.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * TruthValue.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.entity; - -import nars.io.Symbols; - -/** - * Frequency and confidence. - */ -public class TruthValue { // implements Cloneable { - /** The charactor that marks the two ends of a truth value */ - private static final char DELIMITER = Symbols.TRUTH_VALUE_MARK; - /** The charactor that separates the factors in a truth value */ - private static final char SEPARATOR = Symbols.VALUE_SEPARATOR; - /** The frequency factor of the truth value */ - protected ShortFloat frequency; - /** The confidence factor of the truth value */ - protected ShortFloat confidence; - - /** - * Constructor with two ShortFloats - * @param f The frequency value - * @param c The confidence value - */ - public TruthValue(float f, float c) { - frequency = new ShortFloat(f); - confidence = new ShortFloat(c); - } - - /** - * Constructor with a TruthValue to clone - * @param v The truth value to be cloned - */ - public TruthValue(TruthValue v) { - frequency = new ShortFloat(v.getFrequency()); - confidence = new ShortFloat(v.getConfidence()); - } - - /** - * Get the frequency value - * @return The frequency value - */ - public float getFrequency() { - return frequency.getValue(); - } - - /** - * Get the confidence value - * @return The confidence value - */ - public float getConfidence() { - return confidence.getValue(); - } - - /** - * Calculate the expectation value of the truth value - * @return The expectation value - */ - public float getExpectation() { - return (float) (confidence.getValue() * (frequency.getValue() - 0.5) + 0.5); - } - - /** - * Calculate the absolute difference of the expectation value and that of a given truth value - * @param t The given value - * @return The absolute difference - */ - public float getExpDifAbs(TruthValue t) { - return Math.abs(getExpectation() - t.getExpectation()); - } - - /** - * Compare two truth values - * @param that The other TruthValue - * @return Whether the two are equivalent - */ - @Override - public boolean equals(Object that) { - return ((that instanceof TruthValue) - && (getFrequency() == ((TruthValue) that).getFrequency()) - && (getConfidence() == ((TruthValue) that).getConfidence())); - } - - /** - * The hash code of a TruthValue - * @return The hash code - */ - @Override - public int hashCode() { - int hash = 5; - return hash; - } - - /** - * The String representation of a TruthValue - * @return The String - */ - @Override - public String toString() { - return DELIMITER + frequency.toString() + SEPARATOR + confidence.toString() + DELIMITER; - } - - /** - * A simplified String representation of a TruthValue, where each factor is accruate to 1% - * @return The String - */ - public String toString2() { - return DELIMITER + frequency.toString2() + SEPARATOR + confidence.toString2() + DELIMITER; - } -} diff --git a/nars/gui/BagWindow.java b/nars/gui/BagWindow.java deleted file mode 100644 index 1fbf2a67..00000000 --- a/nars/gui/BagWindow.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * BagWindow.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.gui; - -import java.awt.*; -import java.awt.event.*; - -import nars.main.Parameters; -import nars.storage.Bag; - -/** - * Window display the priority distribution of items within a given bag - */ -public class BagWindow extends NarsFrame implements ActionListener, AdjustmentListener { - - /** The bag to be displayed */ - private Bag bag; - /** The lowest level displayed */ - private int showLevel; - /** Control buttons */ - private Button playButton, stopButton, closeButton; - /** Display area */ - private TextArea text; - /** Display label */ - private Label valueLabel; - /** Adjustable display level */ - private Scrollbar valueBar; - /** The location of the display area, shifted according to the number of windows openned */ - private static int counter; - - /** - * Constructor - * @param b The bag to be displayed - * @param title The title of the window - */ - public BagWindow(Bag b, String title) { - super(title); - bag = b; - showLevel = Parameters.BAG_THRESHOLD; - setBackground(MULTIPLE_WINDOW_COLOR); - GridBagLayout gridbag = new GridBagLayout(); - GridBagConstraints c = new GridBagConstraints(); - setLayout(gridbag); - - c.ipadx = 3; - c.ipady = 3; - c.insets = new Insets(5, 5, 5, 5); - c.fill = GridBagConstraints.BOTH; - c.gridwidth = GridBagConstraints.REMAINDER; - c.weightx = 1.0; - c.weighty = 1.0; - text = new TextArea(""); - text.setBackground(DISPLAY_BACKGROUND_COLOR); - text.setEditable(false); - gridbag.setConstraints(text, c); - add(text); - - c.weighty = 0.0; - c.gridwidth = 1; - valueLabel = new Label(String.valueOf(showLevel), Label.RIGHT); - gridbag.setConstraints(valueLabel, c); - add(valueLabel); - - valueBar = new Scrollbar(Scrollbar.HORIZONTAL, showLevel, 0, 1, Parameters.BAG_LEVEL); - valueBar.addAdjustmentListener(this); - gridbag.setConstraints(valueBar, c); - add(valueBar); - - playButton = new Button("Play"); - gridbag.setConstraints(playButton, c); - playButton.addActionListener(this); - add(playButton); - - stopButton = new Button("Stop"); - gridbag.setConstraints(stopButton, c); - stopButton.addActionListener(this); - add(stopButton); - - closeButton = new Button("Close"); - gridbag.setConstraints(closeButton, c); - closeButton.addActionListener(this); - add(closeButton); - - setBounds(400, 60 + counter * 20, 400, 270); - counter++; - setVisible(true); - } - - /** - * Post the bag content - * @param str The text - */ - public void post(String str) { - text.setText(str); - } - - /** - * The lowest display level - * @return The level - */ - public int showLevel() { - return showLevel; - } - - /** - * Handling button click - * @param e The ActionEvent - */ - public void actionPerformed(ActionEvent e) { - Object source = e.getSource(); - if (source == playButton) { - bag.play(); - } else if (source == stopButton) { - bag.stop(); - } else if (source == closeButton) { - bag.stop(); - dispose(); - counter--; - } - } - - /** - * Handling scrollbar movement - * @param e The AdjustmentEvent - */ - public void adjustmentValueChanged(AdjustmentEvent e) { - if (e.getSource() == valueBar) { - int v = valueBar.getValue(); - valueLabel.setText(String.valueOf(v)); - valueBar.setValue(v); - showLevel = v; - bag.play(); - } - } -} diff --git a/nars/gui/ConceptWindow.java b/nars/gui/ConceptWindow.java deleted file mode 100644 index dba5df70..00000000 --- a/nars/gui/ConceptWindow.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * ConceptWindow.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.gui; - -import java.awt.*; -import java.awt.event.*; - -import nars.entity.Concept; - -/** - * Window displaying the content of a Concept, such as beliefs, goals, and questions - */ -public class ConceptWindow extends NarsFrame implements ActionListener { - - /** Control buttons */ - private Button playButton, stopButton, closeButton; - /** Display area */ - private TextArea text; - /** The concept to be displayed */ - private Concept concept; - - /** - * Constructor - * @param concept The concept to be displayed - */ - public ConceptWindow(Concept concept) { - super(concept.getKey()); - this.concept = concept; - setBackground(MULTIPLE_WINDOW_COLOR); - GridBagLayout gridbag = new GridBagLayout(); - GridBagConstraints c = new GridBagConstraints(); - setLayout(gridbag); - - c.ipadx = 3; - c.ipady = 3; - c.insets = new Insets(5, 5, 5, 5); - c.fill = GridBagConstraints.BOTH; - c.gridwidth = GridBagConstraints.REMAINDER; - c.weightx = 1.0; - c.weighty = 1.0; - text = new TextArea(""); - text.setBackground(DISPLAY_BACKGROUND_COLOR); - text.setEditable(false); - gridbag.setConstraints(text, c); - add(text); - - c.weighty = 0.0; - c.gridwidth = 1; - playButton = new Button("Play"); - gridbag.setConstraints(playButton, c); - playButton.addActionListener(this); - add(playButton); - - stopButton = new Button("Stop"); - gridbag.setConstraints(stopButton, c); - stopButton.addActionListener(this); - add(stopButton); - - closeButton = new Button("Close"); - gridbag.setConstraints(closeButton, c); - closeButton.addActionListener(this); - add(closeButton); - - setBounds(400, 60, 400, 270); - setVisible(true); - } - - /** - * Display the content of the concept - * @param str The text to be displayed - */ - public void post(String str) { - text.setText(str); - } - - /** - * Handling button click - * @param e The ActionEvent - */ - public void actionPerformed(ActionEvent e) { - Object s = e.getSource(); - if (s == playButton) { - concept.play(); - } else if (s == stopButton) { - concept.stop(); - } else if (s == closeButton) { - concept.stop(); - dispose(); - } - } -} diff --git a/nars/gui/InferenceWindow.java b/nars/gui/InferenceWindow.java deleted file mode 100644 index 5f870596..00000000 --- a/nars/gui/InferenceWindow.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * InferenceWindow.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.gui; - -import java.awt.*; -import java.awt.event.*; -import nars.io.Record; - -/** - * Window displying inference log - */ -public class InferenceWindow extends NarsFrame implements ActionListener { - - /** Control buttons */ - private Button playButton, stopButton, hideButton; - /** Display area */ - private TextArea text; - - /** - * Constructor - */ - public InferenceWindow() { - super("Inference log"); - setBackground(SINGLE_WINDOW_COLOR); - GridBagLayout gridbag = new GridBagLayout(); - GridBagConstraints c = new GridBagConstraints(); - setLayout(gridbag); - - c.ipadx = 3; - c.ipady = 3; - c.insets = new Insets(5, 5, 5, 5); - c.fill = GridBagConstraints.BOTH; - c.gridwidth = GridBagConstraints.REMAINDER; - c.weightx = 1.0; - c.weighty = 1.0; - text = new TextArea(""); - text.setBackground(DISPLAY_BACKGROUND_COLOR); - text.setEditable(false); - gridbag.setConstraints(text, c); - add(text); - - c.weighty = 0.0; - c.gridwidth = 1; - playButton = new Button("Play"); - gridbag.setConstraints(playButton, c); - playButton.addActionListener(this); - add(playButton); - - stopButton = new Button("Stop"); - gridbag.setConstraints(stopButton, c); - stopButton.addActionListener(this); - add(stopButton); - - hideButton = new Button("Hide"); - gridbag.setConstraints(hideButton, c); - hideButton.addActionListener(this); - add(hideButton); - - setBounds(400, 200, 400, 400); - } - - /** - * Clear display - */ - public void clear() { - text.setText(""); - } - - /** - * Append a new line to display - * @param str Text to be added into display - */ - public void append(String str) { - text.append(str); - } - - /** - * Handling button click - * @param e The ActionEvent - */ - public void actionPerformed(ActionEvent e) { - Object s = e.getSource(); - if (s == playButton) { - Record.play(); - } else if (s == stopButton) { - Record.stop(); - } else if (s == hideButton) { - Record.stop(); - dispose(); - } - } - - /** - * Change background color to remind the on-going file saving - */ - public void switchBackground() { - text.setBackground(SAVING_BACKGROUND_COLOR); - } - - /** - * Reset background color after file saving - */ - public void resetBackground() { - text.setBackground(DISPLAY_BACKGROUND_COLOR); - } -} diff --git a/nars/gui/InputWindow.java b/nars/gui/InputWindow.java deleted file mode 100644 index d495c83b..00000000 --- a/nars/gui/InputWindow.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * InputWindow.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.gui; - -import java.awt.*; -import java.awt.event.*; - -import nars.io.StringParser; - -/** - * Input window, accepting user tasks - */ -public class InputWindow extends NarsFrame implements ActionListener { - - /** Control buttons */ - private Button okButton, holdButton, clearButton, closeButton; - /** Input area */ - private TextArea inputText; - /** Whether the window is ready to accept new input */ - private boolean ready; - - /** - * Constructor - */ - public InputWindow() { - super("Input Window"); - setBackground(SINGLE_WINDOW_COLOR); - GridBagLayout gridbag = new GridBagLayout(); - GridBagConstraints c = new GridBagConstraints(); - setLayout(gridbag); - c.ipadx = 3; - c.ipady = 3; - c.insets = new Insets(5, 5, 5, 5); - c.fill = GridBagConstraints.BOTH; - c.gridwidth = GridBagConstraints.REMAINDER; - c.weightx = 1.0; - c.weighty = 1.0; - inputText = new TextArea(""); - gridbag.setConstraints(inputText, c); - add(inputText); - c.weighty = 0.0; - c.gridwidth = 1; - okButton = new Button("OK"); - okButton.addActionListener(this); - gridbag.setConstraints(okButton, c); - add(okButton); - holdButton = new Button("Hold"); - holdButton.addActionListener(this); - gridbag.setConstraints(holdButton, c); - add(holdButton); - clearButton = new Button("Clear"); - clearButton.addActionListener(this); - gridbag.setConstraints(clearButton, c); - add(clearButton); - closeButton = new Button("Hide"); - closeButton.addActionListener(this); - gridbag.setConstraints(closeButton, c); - add(closeButton); - setBounds(0, 40, 400, 210); - setVisible(true); - } - - /** - * Initialize the window - */ - public void init() { - ready = false; - inputText.setText(""); - } - - /** - * Handling button click - * @param e The ActionEvent - */ - public void actionPerformed(ActionEvent e) { - Button b = (Button) e.getSource(); - if (b == okButton) { - ready = true; - } else if (b == holdButton) { - ready = false; - } else if (b == clearButton) { - inputText.setText(""); - } else if (b == closeButton) { - setVisible(false); - } - } - - /** - * Get one input lines - * @return The top line in the input window - */ - public String getLine() { - if (ready) { - String input = inputText.getText().trim(); - int cutPoint; - while (input.length() > 0) { - cutPoint = input.indexOf('\n'); - if (cutPoint < 0) { - inputText.setText(""); - return input; - } else if (cutPoint > 0) { - inputText.setText(input.substring(cutPoint + 1)); - return input.substring(0, cutPoint).trim(); - } else { // (cutPoint == 0) - input = input.substring(1, cutPoint).trim(); - } - } - ready = false; - inputText.setText(""); - } - return null; - } - - /** - * Get input lines, and send them to Memory - * @return Nember of running steps, if any - */ - public long getInput() { - while (ready) { - String input = inputText.getText(); - int EOL = input.indexOf('\n'); - if (EOL < 0) { - EOL = input.length(); - } - String line = input.substring(0, EOL).trim(); - if (input.length() > EOL) { - inputText.setText(input.substring(EOL + 1)); - } else { - inputText.setText(""); - } - if (line.length() == 0) { - ready = false; - } else { - try { - Long i = new Long(line); - return i.longValue(); - } catch (NumberFormatException e) { - StringParser.parseTask(line); - } - } - } - return 0; - } -} diff --git a/nars/gui/MainWindow.java b/nars/gui/MainWindow.java deleted file mode 100644 index 1386bdee..00000000 --- a/nars/gui/MainWindow.java +++ /dev/null @@ -1,277 +0,0 @@ -/* - * MainWindow.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.gui; - -import java.awt.*; -import java.awt.event.*; - -import nars.io.*; -import nars.main.*; - -/** - * Main window of NARS GUI - */ -public class MainWindow extends NarsFrame implements ActionListener { - - /** Experience display area */ - private TextArea ioText; - /** Control buttons */ - private Button stopButton, walkButton, runButton, exitButton; - /** Clock display field */ - private TextField timerText; - /** Label of the clock */ - private Label timerLabel; - /** System clock */ - private long timer; - /** Whether the experience is saving into a file */ - private boolean savingExp = false; - /** Input experience window */ - public static InputWindow inputWindow; - /** Window to accept a Term to be looked into */ - public static TermWindow conceptWin; - /** Windows for run-time parameter adjustment */ - public static ParameterWindow forgetTW, forgetBW, forgetCW, silentW; - - /** - * Constructor - */ - public MainWindow() { - super("NARS"); - setBackground(MAIN_WINDOW_COLOR); - MenuBar menuBar = new MenuBar(); - - Menu m = new Menu("File"); - m.add(new MenuItem("Load Experience")); - m.add(new MenuItem("Save Experience")); - m.addSeparator(); - m.add(new MenuItem("Record Inference")); - m.addActionListener(this); - menuBar.add(m); - - m = new Menu("Memory"); - m.add(new MenuItem("Initialize")); - m.addSeparator(); - m.add(new MenuItem("Load Memory")); - m.add(new MenuItem("Save Memory")); - m.addActionListener(this); - menuBar.add(m); - - m = new Menu("View"); - m.add(new MenuItem("Concepts")); - m.add(new MenuItem("Task Buffer")); - m.add(new MenuItem("Inference Log")); - m.add(new MenuItem("Concept Content")); - m.add(new MenuItem("Input Window")); - m.addActionListener(this); - menuBar.add(m); - - m = new Menu("Parameter"); - m.add(new MenuItem("Concept Forgetting Rate")); - m.add(new MenuItem("Task Forgetting Rate")); - m.add(new MenuItem("Belief Forgetting Rate")); - m.addSeparator(); - m.add(new MenuItem("Report Silence Level")); - m.addActionListener(this); - menuBar.add(m); - - m = new Menu("Help"); - m.add(new MenuItem("Related Information")); - m.add(new MenuItem("About NARS")); - m.addActionListener(this); - menuBar.add(m); - - setMenuBar(menuBar); - - GridBagLayout gridbag = new GridBagLayout(); - GridBagConstraints c = new GridBagConstraints(); - setLayout(gridbag); - - c.ipadx = 3; - c.ipady = 3; - c.insets = new Insets(5, 5, 5, 5); - c.fill = GridBagConstraints.BOTH; - c.gridwidth = GridBagConstraints.REMAINDER; - c.weightx = 1.0; - c.weighty = 1.0; - ioText = new TextArea(""); - ioText.setBackground(DISPLAY_BACKGROUND_COLOR); - ioText.setEditable(false); - gridbag.setConstraints(ioText, c); - add(ioText); - - c.weightx = 0.0; - c.weighty = 0.0; - c.gridwidth = 1; - runButton = new Button(" Run "); - gridbag.setConstraints(runButton, c); - runButton.addActionListener(this); - add(runButton); - walkButton = new Button(" Walk "); - gridbag.setConstraints(walkButton, c); - walkButton.addActionListener(this); - add(walkButton); - stopButton = new Button(" Stop "); - gridbag.setConstraints(stopButton, c); - stopButton.addActionListener(this); - add(stopButton); - timerLabel = new Label("Clock:", Label.RIGHT); - timerLabel.setBackground(MAIN_WINDOW_COLOR); - gridbag.setConstraints(timerLabel, c); - add(timerLabel); - - c.weightx = 1.0; - timerText = new TextField(""); - timerText.setBackground(DISPLAY_BACKGROUND_COLOR); - timerText.setEditable(false); - gridbag.setConstraints(timerText, c); - add(timerText); - - c.weightx = 0.0; - exitButton = new Button(" Exit "); - gridbag.setConstraints(exitButton, c); - exitButton.addActionListener(this); - add(exitButton); - - setBounds(0, 250, 400, 350); - setVisible(true); - - inputWindow = new InputWindow(); - conceptWin = new TermWindow(); - forgetTW = new ParameterWindow("Task Forgetting Rate", Parameters.TASK_LINK_FORGETTING_CYCLE); - forgetBW = new ParameterWindow("Belief Forgetting Rate", Parameters.TERM_LINK_FORGETTING_CYCLE); - forgetCW = new ParameterWindow("Concept Forgetting Rate", Parameters.CONCEPT_FORGETTING_CYCLE); - silentW = new ParameterWindow("Report Silence Level", Parameters.SILENT_LEVEL); - - initTimer(); - } - - /** - * Initialize the system for a new run - */ - public void init() { - if (timer != 0) { - Center.experienceIO.saveLine(timer + ""); - initTimer(); - } - ioText.setText(""); - } - - /** - * Reset timer and its display - */ - private void initTimer() { - timer = 0; - timerText.setText(timer + ""); - } - - /** - * Update timer and its display - */ - public void tickTimer() { - timer++; - timerText.setText(timer + ""); - } - - /** - * Add new line to the display, plus the time interval - * @param line The text to be displayed - */ - public void post(String line) { - if (timer > 0) { - String timeLine = new String(timer + "\n"); - ioText.append(timeLine); - Center.experienceIO.saveLine(timeLine); - } - if (line != null) { - ioText.append(line); - Center.experienceIO.saveLine(line); - } - initTimer(); - } - - /** - * Handling button click - * @param e The ActionEvent - */ - public void actionPerformed(ActionEvent e) { - Object obj = e.getSource(); - if (obj instanceof Button) { - if (obj == runButton) { - Center.setStoper(-1); - } else if (obj == stopButton) { - Center.setStoper(0); - } else if (obj == walkButton) { - Center.setStoper(1); - } else if (obj == exitButton) { - setVisible(false); - System.exit(0); - } - } else if (obj instanceof MenuItem) { - String label = e.getActionCommand(); - if (label.equals("Load Experience")) { - Center.experienceIO.openLoadFile(); - } else if (label.equals("Save Experience")) { - savingExp = !savingExp; - if (savingExp) { - ioText.setBackground(SAVING_BACKGROUND_COLOR); - Center.experienceIO.openSaveFile(); - } else { - post(null); - ioText.setBackground(DISPLAY_BACKGROUND_COLOR); - Center.experienceIO.closeSaveFile(); - } - } else if (label.equals("Record Inference")) { - if (Record.isLogging()) { - Record.closeLogFile(); - } else { - Record.openLogFile(); - } - } else if (label.equals("Initialize")) { - Center.reset(); - } else if (label.equals("Concepts")) { - Memory.conceptsStartPlay("Active Concepts"); - } else if (label.equals("Task Buffer")) { - Memory.newTasksStartPlay("Task Buffer"); - } else if (label.equals("Inference Log")) { - Record.show(); - Record.play(); - } else if (label.equals("Concept Content")) { - conceptWin.setVisible(true); - } else if (label.equals("Input Window")) { - inputWindow.setVisible(true); - } else if (label.equals("Task Forgetting Rate")) { - forgetTW.setVisible(true); - } else if (label.equals("Belief Forgetting Rate")) { - forgetBW.setVisible(true); - } else if (label.equals("Concept Forgetting Rate")) { - forgetCW.setVisible(true); - } else if (label.equals("Report Silence Level")) { - silentW.setVisible(true); - } else if (label.equals("Related Information")) { - new MessageDialog(this, NARS.WEBSITE); - } else if (label.equals("About NARS")) { - new MessageDialog(this, NARS.INFO); - } else { - new MessageDialog(this, UNAVAILABLE); - } - } - } -} diff --git a/nars/gui/MessageDialog.java b/nars/gui/MessageDialog.java deleted file mode 100644 index 91fe44d6..00000000 --- a/nars/gui/MessageDialog.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * MessageDialog.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ - -package nars.gui; - -import java.awt.*; -import java.awt.event.*; - -/** - * Pop-up message for the user to accept - */ -public class MessageDialog extends Dialog implements ActionListener { - protected Button button; - protected TextArea text; - - /** - * Constructor - * @param parent The parent Frame - * @param message The text to be displayed - */ - public MessageDialog(Frame parent, String message) { - super(parent, "Message", false); - setLayout(new BorderLayout(5, 5)); - setBackground(NarsFrame.SINGLE_WINDOW_COLOR); - setFont(NarsFrame.NarsFont); - text = new TextArea(message); - text.setBackground(NarsFrame.DISPLAY_BACKGROUND_COLOR); - this.add("Center", text); - button = new Button(" OK "); - button.addActionListener(this); - Panel p = new Panel(); - p.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); - p.add(button); - this.add("South", p); - setModal(true); - setBounds(200, 250, 400, 180); - setVisible(true); - } - - /** - * Handling button click - * @param e The ActionEvent - */ - public void actionPerformed(ActionEvent e) { - if (e.getSource() == button) { - this.setVisible(false); - this.dispose(); - } - } -} \ No newline at end of file diff --git a/nars/gui/NarsFrame.java b/nars/gui/NarsFrame.java deleted file mode 100644 index fcfd69ef..00000000 --- a/nars/gui/NarsFrame.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * NarsFrame.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ - -package nars.gui; - -import java.awt.*; - -/** - * Specify shared properties of NARS windows - */ -public abstract class NarsFrame extends Frame { - /** Color for the background of the main window */ - static final Color MAIN_WINDOW_COLOR = new Color(120, 120, 255); - /** Color for the background of the windows with unique instantiation */ - static final Color SINGLE_WINDOW_COLOR = new Color(180, 100, 230); - /** Color for the background of the windows with multiple instantiations */ - static final Color MULTIPLE_WINDOW_COLOR = new Color(100, 220, 100); - /** Color for the background of the text components that are read-only */ - static final Color DISPLAY_BACKGROUND_COLOR = new Color(200, 230, 220); - /** Color for the background of the text components that are being saved into a file */ - static final Color SAVING_BACKGROUND_COLOR = new Color(216, 216, 128); - /** Font for NARS GUI */ - static final Font NarsFont = new Font("Helvetica", Font.PLAIN, 11); - /** Message for unimplemented functions */ - static final String UNAVAILABLE = "\n Not implemented in this demo applet."; - - /** Default constructor */ - NarsFrame() { - super(); - } - - /** - * Constructor with title and font setting - * @param title The title displayed by the window - */ - NarsFrame(String title) { - super(" " + title); - setFont(NarsFont); - } -} diff --git a/nars/gui/ParameterWindow.java b/nars/gui/ParameterWindow.java deleted file mode 100644 index 403da21e..00000000 --- a/nars/gui/ParameterWindow.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * ParameterWindow.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.gui; - -import java.awt.*; -import java.awt.event.*; - -/** - * Window displaying a system parameter that can be adjusted in run time - */ -public class ParameterWindow extends NarsFrame implements ActionListener, AdjustmentListener { - - /** Display label */ - private Label valueLabel; - /** Control buttons */ - private Button hideButton, undoButton, defaultButton; - /** Adjusting bar */ - private Scrollbar valueBar; - /** parameter values */ - private int defaultValue, previousValue, currentValue; - - /** - * Constructor - * @param title Parameter name - * @param dft The default value of the parameter - */ - ParameterWindow(String title, int dft) { - super(title); - defaultValue = dft; - previousValue = dft; - currentValue = dft; - setLayout(new GridLayout(3, 3, 8, 4)); - setBackground(SINGLE_WINDOW_COLOR); - Label sp1 = new Label(""); - sp1.setBackground(SINGLE_WINDOW_COLOR); - add(sp1); - valueLabel = new Label(String.valueOf(dft), Label.CENTER); - valueLabel.setBackground(SINGLE_WINDOW_COLOR); - add(valueLabel); - Label sp2 = new Label(""); - sp2.setBackground(SINGLE_WINDOW_COLOR); - add(sp2); - add(new Label("0", Label.RIGHT)); - valueBar = new Scrollbar(Scrollbar.HORIZONTAL, dft, 0, 0, 101); - valueBar.addAdjustmentListener(this); - add(valueBar); - add(new Label("100", Label.LEFT)); - undoButton = new Button("Undo"); - undoButton.addActionListener(this); - add(undoButton); - defaultButton = new Button("Default"); - defaultButton.addActionListener(this); - add(defaultButton); - hideButton = new Button("Hide"); - hideButton.addActionListener(this); - add(hideButton); - this.setBounds(300, 300, 250, 120); - } - - /** - * Get the value of the parameter - * @return The current value - */ - public int value() { - return currentValue; - } - - /** - * Handling button click - * @param e The ActionEvent - */ - public void actionPerformed(ActionEvent e) { - Object s = e.getSource(); - if (s == defaultButton) { - currentValue = defaultValue; - valueBar.setValue(currentValue); - valueLabel.setText(String.valueOf(currentValue)); - } else if (s == undoButton) { - currentValue = previousValue; - valueBar.setValue(currentValue); - valueLabel.setText(String.valueOf(currentValue)); - } else if (s == hideButton) { - previousValue = currentValue; - setVisible(false); - } - } - - /** - * Handling scrollbar movement - * @param e The AdjustmentEvent - */ - public void adjustmentValueChanged(AdjustmentEvent e) { - if (e.getSource() == valueBar) { - int v = valueBar.getValue(); - valueLabel.setText(String.valueOf(v)); - valueBar.setValue(v); - currentValue = v; - } - } -} diff --git a/nars/gui/TermWindow.java b/nars/gui/TermWindow.java deleted file mode 100644 index 39fa39a2..00000000 --- a/nars/gui/TermWindow.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * TermWindow.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.gui; - -import java.awt.*; -import java.awt.event.*; - -import nars.entity.Concept; -import nars.main.Memory; - -/** - * Window accept a Term, then display the content of the corresponding Concept - */ -public class TermWindow extends NarsFrame implements ActionListener { - /** Display label */ - private Label termLabel; - /** Input field for term name */ - private TextField termField; - /** Control buttons */ - private Button playButton, hideButton; - - /** - * Constructor - */ - TermWindow() { - super("Term Window"); - setBackground(SINGLE_WINDOW_COLOR); - GridBagLayout gridbag = new GridBagLayout(); - GridBagConstraints c = new GridBagConstraints(); - setLayout(gridbag); - - c.ipadx = 3; - c.ipady = 3; - c.insets = new Insets(5, 5, 5, 5); - c.fill = GridBagConstraints.BOTH; - c.gridwidth = 1; - c.weightx = 0.0; - c.weighty = 0.0; - termLabel = new Label("Term:", Label.RIGHT); - termLabel.setBackground(SINGLE_WINDOW_COLOR); - gridbag.setConstraints(termLabel, c); - add(termLabel); - - c.weightx = 1.0; - termField = new TextField(""); - gridbag.setConstraints(termField, c); - add(termField); - - c.weightx = 0.0; - playButton = new Button("Show"); - playButton.addActionListener(this); - gridbag.setConstraints(playButton, c); - add(playButton); - - hideButton = new Button("Hide"); - hideButton.addActionListener(this); - gridbag.setConstraints(hideButton, c); - add(hideButton); - - setBounds(400, 0, 400, 100); - } - - /** - * Handling button click - * @param e The ActionEvent - */ - public void actionPerformed(ActionEvent e) { - Button b = (Button) e.getSource(); - if (b == playButton) { - String name = termField.getText().trim(); - Concept concept = Memory.nameToConcept(name); - if (concept != null) { - concept.startPlay(); - } - } else if (b == hideButton) { - setVisible(false); - } - } -} diff --git a/nars/inference/CompositionalRules.java b/nars/inference/CompositionalRules.java deleted file mode 100644 index 100f53ba..00000000 --- a/nars/inference/CompositionalRules.java +++ /dev/null @@ -1,398 +0,0 @@ -/* - * CompositionalRules.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.inference; - -import nars.entity.*; -import nars.language.*; -import nars.io.Symbols; -import nars.main.Memory; - -/** - * Compound term composition and decomposition rules, with two premises. - *

- * Forward inference only, except the last group (dependent variable introduction) - * can also be used backward. - */ -public final class CompositionalRules { - - /* -------------------- intersections and differences -------------------- */ - /** - * { M>,

M>} |- {<(S|P) ==> M>, <(S&P) ==> M>, <(S-P) ==> M>, <(P-S) ==> M>} - * - * @param taskSentence The first premise - * @param belief The second premise - * @param index The location of the shared term - */ - static void composeCompound(Sentence taskSentence, Judgment belief, int index) { - if (!taskSentence.isJudgment()) { - return; - } // forward only - Statement content1 = (Statement) taskSentence.getContent(); - Statement content2 = (Statement) belief.getContent(); - if (content1.getClass() != content2.getClass()) { - return; - } - if (content1.getTemporalOrder() != content2.getTemporalOrder()) { - return; - } - if (taskSentence.getTense() == belief.getTense()) { - Memory.currentTense = taskSentence.getTense(); - Term component1, component2; - component1 = content1.componentAt(1 - index); - component2 = content2.componentAt(1 - index); - Term component = content1.componentAt(index); - if ((component1 instanceof CompoundTerm) && ((CompoundTerm) component1).containAllComponents(component2)) { - decomposeCompound((CompoundTerm) component1, component2, component, index, true); - return; - } else if ((component2 instanceof CompoundTerm) && ((CompoundTerm) component2).containAllComponents(component1)) { - decomposeCompound((CompoundTerm) component2, component1, component, index, false); - return; - } - Term t1 = null; - Term t2 = null; - Term t3 = null; - Term t4 = null; - TruthValue v1 = taskSentence.getTruth(); - TruthValue v2 = belief.getTruth(); - if (index == 0) { - if (content1 instanceof Inheritance) { - t1 = IntersectionInt.make(component1, component2); - t2 = IntersectionExt.make(component1, component2); - t3 = DifferenceExt.make(component1, component2); - t4 = DifferenceExt.make(component2, component1); - } else if (content1 instanceof Implication) { - t1 = Disjunction.make(component1, component2); - t2 = Conjunction.make(component1, component2); - t3 = Conjunction.make(component1, Negation.make(component2)); - t4 = Conjunction.make(component2, Negation.make(component1)); - } - processComposed(content1, component, t1, TruthFunctions.union(v1, v2)); - processComposed(content1, component, t2, TruthFunctions.intersection(v1, v2)); - processComposed(content1, component, t3, TruthFunctions.difference(v1, v2)); - processComposed(content1, component, t4, TruthFunctions.difference(v2, v1)); - } else { - if (content1 instanceof Inheritance) { - t1 = IntersectionExt.make(component1, component2); - t2 = IntersectionInt.make(component1, component2); - t3 = DifferenceInt.make(component1, component2); - t4 = DifferenceInt.make(component2, component1); - } else if (content1 instanceof Implication) { - t1 = Conjunction.make(component1, component2); - t2 = Disjunction.make(component1, component2); - t3 = Disjunction.make(component1, Negation.make(component2)); - t4 = Disjunction.make(component2, Negation.make(component1)); - } - processComposed(content1, t1, component, TruthFunctions.union(v1, v2)); - processComposed(content1, t2, component, TruthFunctions.intersection(v1, v2)); - processComposed(content1, t3, component, TruthFunctions.difference(v1, v2)); - processComposed(content1, t4, component, TruthFunctions.difference(v2, v1)); - } - } - if (content1.isConstant()) { - introVarDepOuter(content1, content2, index); - } - } - - /** - * Finish composing compound term - * @param statement Type of the content - * @param subject Subject of content - * @param predicate Predicate of content - * @param truth TruthValue of the content - */ - private static void processComposed(Statement statement, Term subject, Term predicate, TruthValue truth) { - if ((subject == null) || (predicate == null)) { - return; - } - Term content = Statement.make(statement, subject, predicate); - if ((content == null) || content.equals(statement) || content.equals(Memory.currentBelief.getContent())) { - return; - } - BudgetValue budget = BudgetFunctions.compoundForward(truth, content); - Memory.doublePremiseTask(budget, content, truth); - } - - /** - * {<(S|P) ==> M>,

M>} |- M> - * @param compound The compound term to be decomposed - * @param component The part of the compound to be removed - * @param term1 The other term in the content - * @param index The location of the shared term: 0 for subject, 1 for predicate - * @param compoundTask Whether the compound comes from the task - */ - private static void decomposeCompound(CompoundTerm compound, Term component, Term term1, int index, boolean compoundTask) { - Term term2 = CompoundTerm.reduceComponents(compound, component); - if (term2 == null) { - return; - } - Task task = Memory.currentTask; - Sentence sentence = task.getSentence(); - Judgment belief = Memory.currentBelief; - Statement oldContent = (Statement) task.getContent(); - TruthValue v1, v2; - if (compoundTask) { - v1 = sentence.getTruth(); - v2 = belief.getTruth(); - } else { - v1 = belief.getTruth(); - v2 = sentence.getTruth(); - } - TruthValue truth = null; - Term content; - if (index == 0) { - content = Statement.make(oldContent, term1, term2); - if (content == null) { - return; - } - if (oldContent instanceof Inheritance) { - if (compound instanceof IntersectionExt) { - truth = TruthFunctions.reduceConjunction(v1, v2); - } else if (compound instanceof IntersectionInt) { - truth = TruthFunctions.reduceDisjunction(v1, v2); - } else if ((compound instanceof SetInt) && (component instanceof SetInt)) { - truth = TruthFunctions.reduceConjunction(v1, v2); - } else if ((compound instanceof SetExt) && (component instanceof SetExt)) { - truth = TruthFunctions.reduceDisjunction(v1, v2); - } else if (compound instanceof DifferenceExt) { - if (compound.componentAt(0).equals(component)) { - truth = TruthFunctions.reduceDisjunction(v2, v1); - } else { - truth = TruthFunctions.reduceConjunctionNeg(v1, v2); - } - } - } else if (oldContent instanceof Implication) { - if (compound instanceof Conjunction) { - truth = TruthFunctions.reduceConjunction(v1, v2); - } else if (compound instanceof Disjunction) { - truth = TruthFunctions.reduceDisjunction(v1, v2); - } - } - } else { - content = Statement.make(oldContent, term2, term1); - if (content == null) { - return; - } - if (oldContent instanceof Inheritance) { - if (compound instanceof IntersectionInt) { - truth = TruthFunctions.reduceConjunction(v1, v2); - } else if (compound instanceof IntersectionExt) { - truth = TruthFunctions.reduceDisjunction(v1, v2); - } else if ((compound instanceof SetExt) && (component instanceof SetExt)) { - truth = TruthFunctions.reduceConjunction(v1, v2); - } else if ((compound instanceof SetInt) && (component instanceof SetInt)) { - truth = TruthFunctions.reduceDisjunction(v1, v2); - } else if (compound instanceof DifferenceInt) { - if (compound.componentAt(1).equals(component)) { - truth = TruthFunctions.reduceDisjunction(v2, v1); - } else { - truth = TruthFunctions.reduceConjunctionNeg(v1, v2); - } - } - } else if (oldContent instanceof Implication) { - if (compound instanceof Disjunction) { - truth = TruthFunctions.reduceConjunction(v1, v2); - } else if (compound instanceof Conjunction) { - truth = TruthFunctions.reduceDisjunction(v1, v2); - } - } - } - BudgetValue budget = BudgetFunctions.compoundForward(truth, content); - Memory.doublePremiseTask(budget, content, truth); - } - - /** - * {(||, S, P), P} |- S - * {(&&, S, P), P} |- S - * @param compound The compound term to be decomposed - * @param component The part of the compound to be removed - * @param compoundTask Whether the compound comes from the task - */ - static void decomposeStatement(CompoundTerm compound, Term component, boolean compoundTask) { - Task task = Memory.currentTask; - Sentence sentence = task.getSentence(); - if (sentence instanceof Question) { - return; - } - Judgment belief = Memory.currentBelief; - Term content = CompoundTerm.reduceComponents(compound, component); - if (content == null) { - return; - } - TruthValue v1, v2; - if (compoundTask) { - v1 = sentence.getTruth(); - v2 = belief.getTruth(); - } else { - v1 = belief.getTruth(); - v2 = sentence.getTruth(); - } - TruthValue truth = null; - if (compound instanceof Conjunction) { - if (sentence instanceof Goal) { - if (compoundTask) { - truth = TruthFunctions.intersection(v1, v2); - } else { - return; - } - } else if (sentence instanceof Judgment) { - truth = TruthFunctions.reduceConjunction(v1, v2); - } - } else if (compound instanceof Disjunction) { - if (sentence instanceof Goal) { - if (compoundTask) { - truth = TruthFunctions.reduceConjunction(v2, v1); - } else { - return; - } - } else if (sentence instanceof Judgment) { - truth = TruthFunctions.reduceDisjunction(v1, v2); - } - } else { - return; - } - BudgetValue budget = BudgetFunctions.compoundForward(truth, content); - Memory.doublePremiseTask(budget, content, truth); - } - - /* ---------------- dependent variable and conjunction ---------------- */ - /** - * { S>, P>} |- (&&, <#x() --> S>, <#x() --> P>> - * @param premise1 The first premise P> - * @param premise2 The second premise P> - * @param index The location of the shared term: 0 for subject, 1 for predicate - */ - private static Conjunction introVarDep(Statement premise1, Statement premise2, int index) { - Statement state1, state2; - Variable var1 = new Variable(Symbols.VARIABLE_TAG + "0()"); - Variable var2 = new Variable(Symbols.VARIABLE_TAG + "0()"); - if (index == 0) { - state1 = Statement.make(premise1, var1, premise1.getPredicate()); - state2 = Statement.make(premise2, var2, premise2.getPredicate()); - } else { - state1 = Statement.make(premise1, premise1.getSubject(), var1); - state2 = Statement.make(premise2, premise2.getSubject(), var2); - } - TemporalRules.Relation tense1 = Memory.currentTask.getTense(); - TemporalRules.Relation tense2 = Memory.currentBelief.getTense(); - if (tense1 == tense2) { - Memory.currentTense = tense1; - if (tense1 == TemporalRules.Relation.WHEN) { - return (Conjunction) ConjunctionParallel.make(state1, state2); - } else { - return (Conjunction) Conjunction.make(state1, state2); - } - } else { - return null; - } - } - - /** - * Introduce a dependent variable in an outer-layer conjunction - * @param premise1 The first premise S> - * @param premise2 The second premise P> - * @param index The location of the shared term: 0 for subject, 1 for predicate - */ - private static void introVarDepOuter(Statement premise1, Statement premise2, int index) { - Term content = introVarDep(premise1, premise2, index); - if (content != null) { - TruthValue v1 = Memory.currentTask.getSentence().getTruth(); - TruthValue v2 = Memory.currentBelief.getTruth(); - TruthValue truth = TruthFunctions.intersection(v1, v2); - BudgetValue budget = BudgetFunctions.compoundForward(truth, content); - Memory.doublePremiseTask(budget, content, truth); - } - } - - /** - * Introduce a dependent variable in an inner-layer conjunction - * @param compound The compound containing the first premise - * @param component The first premise S> - * @param premise The second premise P> - */ - static void introVarDepInner(CompoundTerm compound, Term component, Term premise) { - if (!(component instanceof Statement) || !(component.getClass() == premise.getClass())) { - return; - } - Statement premise1 = (Statement) premise; - Statement premise2 = (Statement) component; - int index; - if (premise1.getSubject().equals(premise2.getSubject())) { - index = 0; - } else if (premise1.getPredicate().equals(premise2.getPredicate())) { - index = 1; - } else { - return; - } - Term innerContent = introVarDep(premise1, premise2, index); - if (innerContent == null) { - return; - } - Task task = Memory.currentTask; - Sentence sentence = task.getSentence(); - Judgment belief = Memory.currentBelief; - Term content = task.getContent(); - if (compound instanceof Implication) { - content = Statement.make((Statement) content, compound.componentAt(0), innerContent); - } else if (compound instanceof Conjunction) { - content = CompoundTerm.replaceComponent(compound, component, innerContent); - } - TruthValue truth = null; - if (sentence instanceof Goal) { - truth = TruthFunctions.intersection(belief.getTruth(), sentence.getTruth()); // [To be refined] - } - else if (sentence instanceof Judgment) { - truth = TruthFunctions.intersection(belief.getTruth(), sentence.getTruth()); - } else { - assert (sentence instanceof Question); - return; - } - BudgetValue budget = BudgetFunctions.compoundForward(truth, content); - Memory.doublePremiseTask(budget, content, truth); - } - - /** - * {(&&, <#x() --> S>, <#x() --> P>>, P>} |- S> - * @param compound The compound term to be decomposed - * @param component The part of the compound to be removed - * @param compoundTask Whether the compound comes from the task - */ - static void abdVarDepOuter(CompoundTerm compound, Term component, boolean compoundTask) { - Term content = CompoundTerm.reduceComponents(compound, component); - Task task = Memory.currentTask; - Sentence sentence = task.getSentence(); - Judgment belief = Memory.currentBelief; - TruthValue v1 = sentence.getTruth(); - TruthValue v2 = belief.getTruth(); - TruthValue truth = null; - BudgetValue budget; - if (sentence instanceof Question) { - budget = (compoundTask ? BudgetFunctions.backward(v2) : BudgetFunctions.backwardWeak(v2)); - } else { - if (sentence instanceof Goal) { - truth = (compoundTask ? TruthFunctions.desireStrong(v1, v2) : TruthFunctions.desireWeak(v1, v2)); - } else { - truth = (compoundTask ? TruthFunctions.existAnalogy(v1, v2) : TruthFunctions.existAnalogy(v2, v1)); - } - budget = BudgetFunctions.compoundForward(truth, content); - } - Memory.doublePremiseTask(budget, content, truth); - } -} diff --git a/nars/inference/MatchingRules.java b/nars/inference/MatchingRules.java deleted file mode 100644 index 9c4f2b83..00000000 --- a/nars/inference/MatchingRules.java +++ /dev/null @@ -1,243 +0,0 @@ -/* - * MatchingRules.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.inference; - -import nars.entity.*; -import nars.language.*; -import nars.main.Memory; - -/** - * Directly process a task by a oldBelief, with only two Terms in both. - * In matching, the new task is compared with all existing direct Tasks in that Concept, to carry out: - *

- * revision: between judgments on non-overlapping evidence; - * update: between judgments; - * satisfy: between a Judgment and a Question/Goal; - * merge: between items of the same type and stamp; - * conversion: between different inheritance relations. - */ -public final class MatchingRules { - - /* -------------------- same contents -------------------- */ - /** - * The task and belief have the same content - *

- * called in RuleTables.reason - * @param task The task - * @param belief The belief - */ - public static void match(Task task, Judgment belief) { - Sentence sentence = task.getSentence(); - if (sentence.isJudgment()) { - revision(task, belief, true); - } else { - trySolution(sentence, belief, null); - } - } - - /** - * Belief update - *

- * called from oncept.reviseTable - * @param task The task containing new belief - * @param oldBelief The previous belief with the same content - */ - public static void update(Task task, Judgment oldBelief) { - BudgetValue budget = BudgetFunctions.update(task, oldBelief.getTruth()); - Memory.currentTense = TemporalRules.Relation.BEFORE; - Memory.doublePremiseTask(budget, oldBelief.getContent(), oldBelief.getTruth()); - } - // called from Concept (direct) and match (indirect) - /** - * Belief revision - *

- * called from Concept.reviseTable and match - * @param task The task containing new belief - * @param oldBelief The previous belief with the same content - * @param feedbackToLinks Whether to send feedback to the links - * @return Whether revision happened - */ - public static boolean revision(Task task, Judgment oldBelief, boolean feedbackToLinks) { - Judgment newBelief = (Judgment) task.getSentence(); - if (newBelief.getTense() == oldBelief.getTense()) { - TruthValue tTruth = newBelief.getTruth(); - TruthValue bTruth = oldBelief.getTruth(); - TruthValue truth = TruthFunctions.revision(tTruth, bTruth); - BudgetValue budget = BudgetFunctions.revise(tTruth, bTruth, truth, task, feedbackToLinks); - Term content = newBelief.getContent(); - Memory.currentTense = newBelief.getTense(); - Memory.doublePremiseTask(budget, content, truth); - return true; - } else { - return false; - } - } - - /** - * Check if a Judgment provide a better answer to a Question - * @param problem The Goal or Question to be answered - * @param belief The proposed answer - * @param task The task to be processed - */ - public static void trySolution(Sentence problem, Judgment belief, Task task) { - if (problem instanceof Goal) { - if (belief.getTense() == TemporalRules.Relation.AFTER) { - return; - } - } else if ((problem.getTense() != belief.getTense()) && (belief.getTense() != TemporalRules.Relation.NONE)) { - return; - } - Judgment oldBest = problem.getBestSolution(); - if (betterSolution(belief, oldBest, problem)) { - problem.setBestSolution(belief); - BudgetValue budget = BudgetFunctions.solutionEval(problem, belief, task); - if ((budget != null) && budget.aboveThreshold()) { - Memory.activatedTask(budget, belief, problem.isInput()); - } - } - } - - /** - * Compare the quality of two solutions - * @param newSol A new solution - * @param oldSol A old solution - * @param problem The problem - * @return Whether the new one is better - */ - private static boolean betterSolution(Judgment newSol, Judgment oldSol, Sentence problem) { - if (oldSol == null) { - return true; - } else { - return (newSol.solutionQuality(problem) > oldSol.solutionQuality(problem)); - } - } - - /* -------------------- same terms, difference relations -------------------- */ - /** - * The task and belief match reversely - */ - public static void matchReverse() { - Task task = Memory.currentTask; - Judgment belief = Memory.currentBelief; - if (task.getContent().getTemporalOrder() != TemporalRules.reverse(belief.getContent().getTemporalOrder())) { - return; - } - Sentence sentence = task.getSentence(); - if (sentence.isJudgment()) { - inferToSym((Judgment) sentence, belief); - } else { - conversion(); - } - - } - - /** - * Inheritance/Implication matches Similarity/Equivalence - * @param asym A Inheritance/Implication sentence - * @param sym A Similarity/Equivalence sentence - * @param figure location of the shared term - */ - public static void matchAsymSym(Sentence asym, Sentence sym, int figure) { - TemporalRules.Relation order1 = asym.getContent().getTemporalOrder(); - TemporalRules.Relation order2 = sym.getContent().getTemporalOrder(); - TemporalRules.Relation order = TemporalRules.temporalSyllogism(order1, order2, figure); - if (order == null) { - return; - } - if (Memory.currentTask.getSentence().isJudgment()) { - inferToAsym((Judgment) asym, (Judgment) sym, order); - } else { - convertRelation(); - } - } - - /* -------------------- two-premise inference rules -------------------- */ - /** - * { P>,

S} |- p> - * Produce Similarity/Equivalence from a pair of reversed Inheritance/Implication - * @param judgment1 The first premise - * @param judgment2 The second premise - */ - private static void inferToSym(Judgment judgment1, Judgment judgment2) { - Statement s1 = (Statement) judgment1.getContent(); - Statement s2 = (Statement) judgment2.getContent(); - Term t1 = s1.getSubject(); - Term t2 = s1.getPredicate(); - Term content; - if (s1 instanceof Inheritance) { - content = Similarity.make(t1, t2); - } else if (s1 instanceof ImplicationAfter) { - content = EquivalenceAfter.make(t1, t2); - } else if (s1 instanceof ImplicationBefore) { - content = EquivalenceAfter.make(t2, t1); - } else { - content = Equivalence.make(t1, t2); - } - TruthValue value1 = judgment1.getTruth(); - TruthValue value2 = judgment2.getTruth(); - TruthValue truth = TruthFunctions.intersection(value1, value2); - BudgetValue budget = BudgetFunctions.forward(truth); - Memory.doublePremiseTask(budget, content, truth); - } - - /** - * { P>,

S>} |- P> - * Produce an Inheritance/Implication from a Similarity/Equivalence and a reversed Inheritance/Implication - * @param asym The asymmetric premise - * @param sym The symmetric premise - */ - private static void inferToAsym(Judgment asym, Judgment sym, TemporalRules.Relation order) { - Statement statement = (Statement) asym.getContent(); - Term sub = statement.getPredicate(); - Term pre = statement.getSubject(); - Statement content = Statement.make(statement, sub, pre, order); - TruthValue truth = TruthFunctions.reduceConjunction(sym.getTruth(), asym.getTruth()); - BudgetValue budget = BudgetFunctions.forward(truth); - Memory.doublePremiseTask(budget, content, truth); - } - - /* -------------------- one-premise inference rules -------------------- */ - /** - * {

S>} |- P> - * Produce an Inheritance/Implication from a reversed Inheritance/Implication - */ - private static void conversion() { - TruthValue truth = TruthFunctions.conversion(Memory.currentBelief.getTruth()); - BudgetValue budget = BudgetFunctions.forward(truth); - Memory.convertedJudgment(truth, budget); - } - - /** - * { P>} |- P> - * { P>} |- P> - * Switch between Inheritance/Implication and Similarity/Equivalence - */ - private static void convertRelation() { - TruthValue truth = Memory.currentBelief.getTruth(); - if (((Statement) Memory.currentTask.getContent()).isCommutative()) { - truth = TruthFunctions.implied(truth); - } else { - truth = TruthFunctions.implying(truth); - } - BudgetValue budget = BudgetFunctions.forward(truth); - Memory.convertedJudgment(truth, budget); - } -} diff --git a/nars/inference/StructuralRules.java b/nars/inference/StructuralRules.java deleted file mode 100644 index a7069484..00000000 --- a/nars/inference/StructuralRules.java +++ /dev/null @@ -1,475 +0,0 @@ -/* - * StructuralRules.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.inference; - -import java.util.ArrayList; - -import nars.entity.*; -import nars.language.*; -import nars.main.Memory; - -/** - * Single-premise inference rules involving compound terms. - * Input are one sentence (the premise) and one TermLink (indicating a component) - */ -public final class StructuralRules { - - /* -------------------- transform between compounds and components -------------------- */ - /** - * { P>, S@(S&T)} |- <(S&T) --> (P&T)> - * { P>, S@(M-S)} |- <(M-P) --> (M-S)> - * @param compound The compound term - * @param index The location of the indicated term in the compound - * @param statement The premise - * @param side The location of the indicated term in the premise - */ - static void structuralCompose2(CompoundTerm compound, short index, Statement statement, short side) { - if (compound.equals(statement.componentAt(side))) { - return; - } - Term sub = statement.getSubject(); - Term pred = statement.getPredicate(); - ArrayList components = compound.cloneComponents(); - if (((side == 0) && components.contains(pred)) || ((side == 1) && components.contains(sub))) { - return; - } - if (side == 0) { - sub = compound; - components.set(index, pred); - pred = CompoundTerm.make(compound, components); - } else { - components.set(index, sub); - sub = CompoundTerm.make(compound, components); - pred = compound; - } - if ((sub == null) || (pred == null)) { - return; - } - Term content; - if (switchOrder(compound, index)) { - content = Statement.make(statement, pred, sub); - } else { - content = Statement.make(statement, sub, pred); - } - if (content == null) { - return; - } - Task task = Memory.currentTask; - Sentence sentence = task.getSentence(); - TruthValue truth = sentence.getTruth(); - BudgetValue budget; - if (sentence instanceof Question) { - budget = BudgetFunctions.compoundBackwardWeak(content); - } else { - if (compound.size() > 1) { - if (sentence.isJudgment()) { - truth = TruthFunctions.implying(truth); - } else { - assert (sentence instanceof Goal); - truth = TruthFunctions.implied(truth); - } - } - budget = BudgetFunctions.compoundForward(truth, content); - } - Memory.singlePremiseTask(budget, content, truth); - } - - /** - * {<(S&T) --> (P&T)>, S@(S&T)} |- P> - * @param statement The premise - */ - static void structuralDecompose2(Statement statement) { - Term subj = statement.getSubject(); - Term pred = statement.getPredicate(); - if (subj.getClass() != pred.getClass()) { - return; - } - CompoundTerm sub = (CompoundTerm) subj; - CompoundTerm pre = (CompoundTerm) pred; - if (sub.size() != pre.size()) { - return; - } - int index = -1; - Term t1, t2; - for (int i = 0; i < sub.size(); i++) { - t1 = sub.componentAt(i); - t2 = pre.componentAt(i); - if (!t1.equals(t2)) { - if (index < 0) { - index = i; - } else { - return; - } - } - } - t1 = sub.componentAt(index); - t2 = pre.componentAt(index); - Term content; - if (switchOrder(sub, (short) index)) { - content = Statement.make(statement, t2, t1); - } else { - content = Statement.make(statement, t1, t2); - } - Task task = Memory.currentTask; - Sentence sentence = task.getSentence(); - TruthValue truth = sentence.getTruth(); - BudgetValue budget; - if (sentence instanceof Question) { - budget = BudgetFunctions.compoundBackward(content); - } else { - if (sub.size() > 1) { - if (sentence.isJudgment()) { - truth = TruthFunctions.implied(truth); - } else { - assert (sentence instanceof Goal); - truth = TruthFunctions.implying(truth); - } - } - budget = BudgetFunctions.compoundForward(truth, content); - } - Memory.singlePremiseTask(budget, content, truth); - } - - /** - * List the cases where the direction of inheritance is revised in conclusion - * @param compound The compound term - * @param index The location of focus in the compound - * @return Whether the direction of inheritance should be revised - */ - private static boolean switchOrder(CompoundTerm compound, short index) { - return ((((compound instanceof DifferenceExt) || (compound instanceof DifferenceInt)) && (index == 1)) || - ((compound instanceof ImageExt) && (index != ((ImageExt) compound).getRelationIndex())) || - ((compound instanceof ImageInt) && (index != ((ImageInt) compound).getRelationIndex()))); - } - - /** - * { P>, P@(P&Q)} |- (P&Q)> - * @param compound The compound term - * @param index The location of the indicated term in the compound - * @param statement The premise - */ - static void structuralCompose1(CompoundTerm compound, short index, Statement statement) { - if (!Memory.currentTask.getSentence().isJudgment()) { - return; - } - Term component = compound.componentAt(index); - Task task = Memory.currentTask; - Sentence sentence = task.getSentence(); - TruthValue truth = sentence.getTruth(); - Term subj = statement.getSubject(); - Term pred = statement.getPredicate(); - if (component.equals(subj)) { - if (compound instanceof IntersectionExt) { - structuralStatement(compound, pred, TruthFunctions.implying(truth)); - } else if (compound instanceof IntersectionInt) { - structuralStatement(compound, pred, TruthFunctions.implied(truth)); - } else if ((compound instanceof DifferenceExt) && (index == 0)) { - structuralStatement(compound, pred, TruthFunctions.implying(truth)); - } else if (compound instanceof DifferenceInt) { - if (index == 0) { - structuralStatement(compound, pred, TruthFunctions.implied(truth)); - } else { - structuralStatement(compound, pred, TruthFunctions.negImply(truth)); - } - } - } else if (component.equals(pred)) { - if (compound instanceof IntersectionExt) { - structuralStatement(subj, compound, TruthFunctions.implied(truth)); - } else if (compound instanceof IntersectionInt) { - structuralStatement(subj, compound, TruthFunctions.implying(truth)); - } else if (compound instanceof DifferenceExt) { - if (index == 0) { - structuralStatement(subj, compound, TruthFunctions.implied(truth)); - } else { - structuralStatement(subj, compound, TruthFunctions.negImply(truth)); - } - } else if ((compound instanceof DifferenceInt) && (index == 0)) { - structuralStatement(subj, compound, TruthFunctions.implying(truth)); - } - } - } - - /** - * {<(S&T) --> P>, S@(S&T)} |- P> - * @param compound The compound term - * @param index The location of the indicated term in the compound - * @param statement The premise - */ - static void structuralDecompose1(CompoundTerm compound, short index, Statement statement) { - if (!Memory.currentTask.getSentence().isJudgment()) { - return; - } - Term component = compound.componentAt(index); - Task task = Memory.currentTask; - Sentence sentence = task.getSentence(); - TruthValue truth = sentence.getTruth(); - Term subj = statement.getSubject(); - Term pred = statement.getPredicate(); - if (compound.equals(subj)) { - if (compound instanceof IntersectionExt) { - structuralStatement(component, pred, TruthFunctions.implied(truth)); - } else if (compound instanceof IntersectionInt) { - structuralStatement(component, pred, TruthFunctions.implying(truth)); - } else if ((compound instanceof DifferenceExt) && (index == 0)) { - structuralStatement(component, pred, TruthFunctions.implied(truth)); - } else if (compound instanceof DifferenceInt) { - if (index == 0) { - structuralStatement(component, pred, TruthFunctions.implying(truth)); - } else { - structuralStatement(component, pred, TruthFunctions.negImply(truth)); - } - } - } else if (compound.equals(pred)) { - if (compound instanceof IntersectionExt) { - structuralStatement(subj, component, TruthFunctions.implying(truth)); - } else if (compound instanceof IntersectionInt) { - structuralStatement(subj, component, TruthFunctions.implied(truth)); - } else if (compound instanceof DifferenceExt) { - if (index == 0) { - structuralStatement(subj, component, TruthFunctions.implying(truth)); - } else { - structuralStatement(subj, component, TruthFunctions.negImply(truth)); - } - } else if ((compound instanceof DifferenceInt) && (index == 0)) { - structuralStatement(subj, component, TruthFunctions.implied(truth)); - } - } - } - - /** - * Common final operations of the above two methods - * @param subject The subject of the new task - * @param predicate The predicate of the new task - * @param truth The truth value of the new task - */ - private static void structuralStatement(Term subject, Term predicate, TruthValue truth) { - Task task = Memory.currentTask; - Term content = Statement.make((Statement) task.getContent(), subject, predicate); - if (content == null) { - return; - } - BudgetValue budget = BudgetFunctions.compoundForward(truth, content); - Memory.singlePremiseTask(budget, content, truth); - } - - /* -------------------- set transform -------------------- */ - /** - * { {P}>} |- {P}> - * @param compound The set compound - * @param statement The premise - * @param side The location of the indicated term in the premise - */ - static void transformSetRelation(CompoundTerm compound, Statement statement, short side) { - if (compound.size() > 1) { - return; - } - if (statement instanceof Inheritance) { - if (((compound instanceof SetExt) && (side == 0)) || ((compound instanceof SetInt) && (side == 1))) { - return; - } - } - Term sub = statement.getSubject(); - Term pre = statement.getPredicate(); - Term content; - if (statement instanceof Inheritance) { - content = Similarity.make(sub, pre); - } else { - if (((compound instanceof SetExt) && (side == 0)) || ((compound instanceof SetInt) && (side == 1))) { - content = Inheritance.make(pre, sub); - } else { - content = Inheritance.make(sub, pre); - } - } - Task task = Memory.currentTask; - Sentence sentence = task.getSentence(); - TruthValue truth = sentence.getTruth(); - BudgetValue budget; - if (sentence instanceof Question) { - budget = BudgetFunctions.compoundBackward(content); - } else { - budget = BudgetFunctions.compoundForward(truth, content); - } - Memory.singlePremiseTask(budget, content, truth); - } - - /* -------------------- products and images transform -------------------- */ - /** - * Equivalent transformation between products and images - * {<(*, S, M) --> P>, S@(*, S, M)} |- (/, P, _, M)> - * { (/, P, _, M)>, P@(/, P, _, M)} |- <(*, S, M) --> P> - * { (/, P, _, M)>, M@(/, P, _, M)} |- (/, P, S, _)> - * @param inh An Inheritance statement - * @param oldContent The whole content - * @param indices The indices of the TaskLink - * @param task The task - */ - static void transformProductImage(Inheritance inh, CompoundTerm oldContent, short[] indices, Task task) { - Term subject = null; - Term predicate = null; - short index = indices[indices.length - 1]; - short side = indices[indices.length - 2]; - CompoundTerm comp = (CompoundTerm) inh.componentAt(side); - if (comp instanceof Product) { - if (side == 0) { - subject = comp.componentAt(index); - predicate = ImageExt.make((Product) comp, inh.getPredicate(), index); - } else { - subject = ImageInt.make((Product) comp, inh.getSubject(), index); - predicate = comp.componentAt(index); - } - } else if ((comp instanceof ImageExt) && (side == 1)) { - if (index == ((ImageExt) comp).getRelationIndex()) { - subject = Product.make(comp, inh.getSubject(), index); - predicate = comp.componentAt(index); - } else { - subject = comp.componentAt(index); - predicate = ImageExt.make((ImageExt) comp, inh.getSubject(), index); - } - } else if ((comp instanceof ImageInt) && (side == 0)) { - if (index == ((ImageInt) comp).getRelationIndex()) { - subject = comp.componentAt(index); - predicate = Product.make(comp, inh.getPredicate(), index); - } else { - subject = ImageInt.make((ImageInt) comp, inh.getPredicate(), index); - predicate = comp.componentAt(index); - } - } else { - return; - } - Inheritance newInh = Inheritance.make(subject, predicate); - Term content = null; - if (indices.length == 2) { - content = newInh; - } else if ((oldContent instanceof Statement) && (indices[0] == 1)) { - content = Statement.make((Statement) oldContent, oldContent.componentAt(0), newInh); - } else { - ArrayList componentList; - Term condition = oldContent.componentAt(0); - if ((oldContent instanceof Implication) && (condition instanceof Conjunction)) { - componentList = ((CompoundTerm) condition).cloneComponents(); - componentList.set(indices[1], newInh); - Term newCond = CompoundTerm.make((CompoundTerm) condition, componentList); - content = Implication.make(newCond, ((Statement) oldContent).getPredicate()); - } else { - componentList = oldContent.cloneComponents(); - componentList.set(indices[0], newInh); - if (oldContent instanceof Conjunction) { - content = CompoundTerm.make(oldContent, componentList); - } else if ((oldContent instanceof Implication) || (oldContent instanceof Equivalence)) { - content = Statement.make((Statement) oldContent, componentList.get(0), componentList.get(1)); - } - } - } - if (content == null) { - return; - } - Sentence sentence = task.getSentence(); - TruthValue truth = sentence.getTruth(); - BudgetValue budget; - if (sentence instanceof Question) { - budget = BudgetFunctions.compoundBackward(content); - } else { - budget = BudgetFunctions.compoundForward(truth, content); - } - Memory.singlePremiseTask(budget, content, truth); - } - - /* --------------- Disjunction and Conjunction transform --------------- */ - /** - * {(&&, A, B), A@(&&, A, B)} |- A - * {(||, A, B), A@(||, A, B)} |- A - * @param compound The premise - * @param component The recognized component in the premise - * @param compoundTask Whether the compound comes from the task - */ - static void structuralCompound(CompoundTerm compound, Term component, boolean compoundTask) { - if (!component.isConstant()) { - return; - } - Term content = (compoundTask ? component : compound); - Task task = Memory.currentTask; - if (task.isStructual()) { - return; - } - Sentence sentence = task.getSentence(); - TruthValue truth = sentence.getTruth(); - BudgetValue budget; - if (sentence instanceof Question) { - budget = BudgetFunctions.compoundBackward(content); - } else { - if ((sentence.isJudgment()) == (compoundTask == (compound instanceof Conjunction))) { - truth = TruthFunctions.implying(truth); - } else { - truth = TruthFunctions.implied(truth); - } - budget = BudgetFunctions.forward(truth); - } - Memory.singlePremiseTask(budget, content, truth); - } - - /* --------------- Negation related rules --------------- */ - /** - * {A, A@(--, A)} |- (--, A) - * @param content The premise - */ - static void transformNegation(Term content) { - Task task = Memory.currentTask; - Sentence sentence = task.getSentence(); - TruthValue truth = sentence.getTruth(); - if (sentence instanceof Judgment) { - truth = TruthFunctions.negation(truth); - } - BudgetValue budget; - if (sentence instanceof Question) { - budget = BudgetFunctions.compoundBackward(content); - } else { - budget = BudgetFunctions.compoundForward(truth, content); - } - Memory.singlePremiseTask(budget, content, truth); - } - - /** - * { B>, A@(--, A)} |- <(--, B) ==> (--, A)> - * @param statement The premise - */ - static void contraposition(Statement statement) { - Term subj = statement.getSubject(); - Term pred = statement.getPredicate(); - Term content = Statement.make(statement, Negation.make(pred), Negation.make(subj), TemporalRules.reverse(statement.getTemporalOrder())); - Task task = Memory.currentTask; - Sentence sentence = task.getSentence(); - TruthValue truth = sentence.getTruth(); - BudgetValue budget; - if (sentence instanceof Question) { - if (content instanceof Implication) { - budget = BudgetFunctions.compoundBackwardWeak(content); - } else { - budget = BudgetFunctions.compoundBackward(content); - } - } else { - if (content instanceof Implication) { - truth = TruthFunctions.contraposition(truth); - } - budget = BudgetFunctions.compoundForward(truth, content); - } - Memory.singlePremiseTask(budget, content, truth); - } -} diff --git a/nars/inference/SyllogisticRules.java b/nars/inference/SyllogisticRules.java deleted file mode 100644 index e4bafbce..00000000 --- a/nars/inference/SyllogisticRules.java +++ /dev/null @@ -1,654 +0,0 @@ -/* - * SyllogisticRules.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.inference; - -import java.util.*; - -import nars.entity.*; -import nars.language.*; -import nars.io.Symbols; -import nars.main.Memory; - -/** - * Syllogisms: Inference rules based on the transitivity of the relation. - */ -public final class SyllogisticRules { - - /* --------------- rules used in both first-tense inference and higher-tense inference --------------- */ - /** - * { M>, P>} |- { P>,

S>} - * @param term1 Subject of the first new task - * @param term2 Predicate of the first new task - * @param sentence The first premise - * @param belief The second premise - */ - static void dedExe(Term term1, Term term2, Sentence sentence, Judgment belief) { - if (Statement.invalidStatement(term1, term2)) { - return; - } - TruthValue value1 = sentence.getTruth(); - TruthValue value2 = belief.getTruth(); - TruthValue truth1 = null; - TruthValue truth2 = null; - BudgetValue budget1, budget2; - if (sentence instanceof Question) { - budget1 = BudgetFunctions.backwardWeak(value2); - budget2 = BudgetFunctions.backwardWeak(value2); - } else { - if (sentence instanceof Goal) { - truth1 = TruthFunctions.desireWeak(value1, value2); - truth2 = TruthFunctions.desireWeak(value1, value2); - } else { - truth1 = TruthFunctions.deduction(value1, value2); - truth2 = TruthFunctions.exemplification(value1, value2); - } - budget1 = BudgetFunctions.forward(truth1); - budget2 = BudgetFunctions.forward(truth2); - } - TemporalRules.Relation order1 = sentence.getContent().getTemporalOrder(); - TemporalRules.Relation order2 = belief.getContent().getTemporalOrder(); - TemporalRules.Relation order = TemporalRules.temporalInference(order1, order2); - if (order == null) { - order = TemporalRules.Relation.WHEN; - truth1 = TruthFunctions.temporalInduction(truth1); - truth2 = TruthFunctions.temporalInduction(truth2); - } - Statement content1 = Statement.make((Statement) sentence.getContent(), term1, term2, order); - Statement content2 = Statement.make((Statement) sentence.getContent(), term2, term1, TemporalRules.reverse(order)); - Memory.doublePremiseTask(budget1, content1, truth1); - Memory.doublePremiseTask(budget2, content2, truth2); - } - - /** - * { S>, P>} |- { P>,

S>, P>} - * @param term1 Subject of the first new task - * @param term2 Predicate of the first new task - * @param taskSentence The first premise - * @param belief The second premise - * @param figure Locations of the shared term in premises - */ - static void abdIndCom(Term term1, Term term2, Sentence taskSentence, Judgment belief, int figure) { - if (Statement.invalidStatement(term1, term2)) { - return; - } - Statement st1 = (Statement) taskSentence.getContent(); - Statement st2 = (Statement) belief.getContent(); - TruthValue truth1 = null; - TruthValue truth2 = null; - TruthValue truth3 = null; - BudgetValue budget1, budget2, budget3; - TruthValue value1 = taskSentence.getTruth(); - TruthValue value2 = belief.getTruth(); - if (taskSentence instanceof Question) { - budget1 = BudgetFunctions.backward(value2); - budget2 = BudgetFunctions.backwardWeak(value2); - budget3 = BudgetFunctions.backward(value2); - } else { - if (taskSentence instanceof Goal) { - truth1 = TruthFunctions.desireStrong(value1, value2); - truth2 = TruthFunctions.desireWeak(value2, value1); - truth3 = TruthFunctions.desireStrong(value1, value2); - } else { - truth1 = TruthFunctions.abduction(value1, value2); - truth2 = TruthFunctions.abduction(value2, value1); - truth3 = TruthFunctions.comparison(value1, value2); - } - budget1 = BudgetFunctions.forward(truth1); - budget2 = BudgetFunctions.forward(truth2); - budget3 = BudgetFunctions.forward(truth3); - } - TemporalRules.Relation order1 = st1.getTemporalOrder(); - TemporalRules.Relation order2 = st2.getTemporalOrder(); - TemporalRules.Relation order = TemporalRules.temporalSyllogism(order1, order2, figure); - if (order == null) { - order = TemporalRules.Relation.WHEN; - truth1 = TruthFunctions.temporalInduction(truth1); - truth2 = TruthFunctions.temporalInduction(truth2); - truth3 = TruthFunctions.temporalInduction(truth3); - } - Statement statement1 = Statement.make(st1, term1, term2, order); - Statement statement2 = Statement.make(st1, term2, term1, TemporalRules.reverse(order)); - Statement statement3 = Statement.makeSym(st1, term1, term2, order); - Memory.doublePremiseTask(budget1, statement1, truth1); - Memory.doublePremiseTask(budget2, statement2, truth2); - Memory.doublePremiseTask(budget3, statement3, truth3); - if (statement1.isConstant()) { - Memory.doublePremiseTask(budget1, introVarInd(belief, taskSentence, figure, true), truth1); - Memory.doublePremiseTask(budget2, introVarInd(taskSentence, belief, figure, true), truth2); - Memory.doublePremiseTask(budget3, introVarInd(taskSentence, belief, figure, false), truth3); - } - } - - /** - * { P>, P>} |- P> - * @param term1 Subject of the new task - * @param term2 Predicate of the new task - * @param asym The asymmetric premise - * @param sym The symmetric premise - * @param figure Locations of the shared term in premises - */ - static void analogy(Term term1, Term term2, Sentence asym, Sentence sym, int figure) { - if (Statement.invalidStatement(term1, term2)) { - return; - } - Statement asymSt = (Statement) asym.getContent(); - Statement symSt = (Statement) sym.getContent(); - TruthValue truth = null; - BudgetValue budget; - Sentence sentence = Memory.currentTask.getSentence(); - CompoundTerm taskTerm = (CompoundTerm) sentence.getContent(); - if (sentence instanceof Question) { - if (taskTerm.isCommutative()) { - budget = BudgetFunctions.backwardWeak(asym.getTruth()); - } else { - budget = BudgetFunctions.backward(sym.getTruth()); - } - } else { - if (sentence instanceof Goal) { - if (taskTerm.isCommutative()) { - truth = TruthFunctions.desireWeak(asym.getTruth(), sym.getTruth()); - } else { - truth = TruthFunctions.desireStrong(asym.getTruth(), sym.getTruth()); - } - } else { - truth = TruthFunctions.analogy(asym.getTruth(), sym.getTruth()); - } - budget = BudgetFunctions.forward(truth); - } - TemporalRules.Relation order1 = asymSt.getTemporalOrder(); - TemporalRules.Relation order2 = symSt.getTemporalOrder(); - TemporalRules.Relation order; - switch (figure) { - case 11: - case 12: - order = TemporalRules.temporalSyllogism(order2, order1, figure); - break; - case 21: - case 22: - order = TemporalRules.temporalSyllogism(order1, order2, figure); - break; - default: - return; - } - if (order == null) { - order = TemporalRules.Relation.WHEN; - truth = TruthFunctions.temporalInduction(truth); - } - Term content = Statement.make(asymSt, term1, term2, order); - Memory.doublePremiseTask(budget, content, truth); - } - - /** - * { M>, P>} |- P> - * @param term1 Subject of the new task - * @param term2 Predicate of the new task - * @param belief The first premise - * @param sentence The second premise - * @param figure Locations of the shared term in premises - */ - static void resemblance(Term term1, Term term2, Judgment belief, Sentence sentence, int figure) { - if (Statement.invalidStatement(term1, term2)) { - return; - } - Statement st1 = (Statement) belief.getContent(); - Statement st2 = (Statement) sentence.getContent(); - TruthValue truth = null; - BudgetValue budget; - Task task = Memory.currentTask; - if (sentence instanceof Question) { - budget = BudgetFunctions.backward(belief.getTruth()); - } else { - if (sentence instanceof Goal) { - truth = TruthFunctions.desireStrong(sentence.getTruth(), belief.getTruth()); - } else { - truth = TruthFunctions.resemblance(belief.getTruth(), sentence.getTruth()); - } - budget = BudgetFunctions.forward(truth); - } - TemporalRules.Relation order1 = st1.getTemporalOrder(); - TemporalRules.Relation order2 = st2.getTemporalOrder(); - TemporalRules.Relation order = TemporalRules.temporalSyllogism(order1, order2, figure); - if (order == null) { - order = TemporalRules.Relation.WHEN; - truth = TruthFunctions.temporalInduction(truth); - } - Term statement = Statement.make(st1, term1, term2, order); - Memory.doublePremiseTask(budget, statement, truth); - } - - /* --------------- rules used only in conditional inference --------------- */ - /** - * {< S> ==> P>>, S>} |- P> - * {< S> ==> P>>, P>} |- S> - * @param mainSentence The implication/equivalence premise - * @param subSentence The premise on part of s1 - * @param s The location of s2 in s1 - */ - static void detachment(Sentence mainSentence, Sentence subSentence, int s) { - Statement statement = (Statement) mainSentence.getContent(); - Term subject = statement.getSubject(); - Term predicate = statement.getPredicate(); - Term term = subSentence.getContent(); - Term content; - int side; - if (term.equals(subject)) { - side = 0; - content = predicate; - } else if (term.equals(predicate)) { - side = 1; - content = subject; - } else { - return; - } - Sentence taskSentence = Memory.currentTask.getSentence(); - Sentence beliefSentence = Memory.currentBelief; - TruthValue beliefTruth = beliefSentence.getTruth(); - TruthValue truth1 = mainSentence.getTruth(); - TruthValue truth2 = subSentence.getTruth(); - TruthValue truth = null; - BudgetValue budget; - if (taskSentence instanceof Question) { - if (statement instanceof Equivalence) { - budget = BudgetFunctions.backward(beliefTruth); - } else if (side == 0) { - budget = BudgetFunctions.backwardWeak(beliefTruth); - } else { - budget = BudgetFunctions.backward(beliefTruth); - } - } else { - if (taskSentence instanceof Goal) { - if (statement instanceof Equivalence) { - truth = TruthFunctions.desireStrong(truth1, truth2); - } else if (side == 0) { - truth = TruthFunctions.desireInd(truth1, truth2); - } else { - truth = TruthFunctions.desireDed(truth1, truth2); - } - } else { - if (statement instanceof Equivalence) { - truth = TruthFunctions.analogy(truth1, truth2); - } else if (side == 0) { - truth = TruthFunctions.deduction(truth1, truth2); - } else { - truth = TruthFunctions.abduction(truth2, truth1); - } - } - budget = BudgetFunctions.forward(truth); - } - TemporalRules.Relation order1 = subSentence.getTense(); - TemporalRules.Relation order2 = statement.getTemporalOrder(); - TemporalRules.Relation order; - if (side == 0) { - order = TemporalRules.temporalInference(order1, order2); - } else { - order = TemporalRules.temporalInference(order1, TemporalRules.reverse(order2)); - } - if (order == null) { - order = TemporalRules.Relation.WHEN; -// truth = TruthFunctions.temporalInduction(truth); - } - Memory.currentTense = order; - Memory.doublePremiseTask(budget, content, truth); - } - - /** - * {<(&&, S1, S2, S3) ==> P>, S1} |- <(&&, S2, S3) ==> P> - * {<(&&, S2, S3) ==> P>, S2>} |- <(&&, S1, S3) ==> P> - * {<(&&, S1, S3) ==> P>, S2>} |- <(&&, S2, S3) ==> P> - * @param premise1 The conditional premise - * @param index The location of the shared term in the condition of premise1 - * @param premise2 The premise which, or part of which, appears in the condition of premise1 - * @param side The location of the shared term in premise2: 0 for subject, 1 for predicate, -1 for the whole term - */ - static void conditionalDedInd(Implication premise1, short index, Term premise2, int side) { - Task task = Memory.currentTask; - Sentence taskSentence = task.getSentence(); - Judgment belief = Memory.currentBelief; - boolean deduction = (side != 0); - HashMap substitute = Variable.findSubstitute(Variable.VarType.ALL, premise2, belief.getContent()); - boolean conditionalTask = (substitute != null); - TemporalRules.Relation tense1 = (conditionalTask ? taskSentence.getTense() : belief.getTense()); - TemporalRules.Relation tense2 = (conditionalTask ? belief.getTense() : taskSentence.getTense()); - TemporalRules.Relation order1 = premise1.getTemporalOrder(); - TemporalRules.Relation order2 = premise2.getTemporalOrder(); - if ((side == -1) && (tense2 == TemporalRules.Relation.AFTER)) { - return; - } - if ((side == 0) && (order2 == TemporalRules.Relation.AFTER)) { - return; - } - if ((side == 1) && (order2 == TemporalRules.Relation.BEFORE)) { - return; - } - TemporalRules.Relation tense = TemporalRules.temporalInference(tense1, tense2); - if (tense != TemporalRules.Relation.NONE) { - tense = TemporalRules.Relation.WHEN; - } - Term commonComponent; - Term newComponent = null; - if (side == 0) { - commonComponent = ((Statement) premise2).getSubject(); - newComponent = ((Statement) premise2).getPredicate(); - } else if (side == 1) { - commonComponent = ((Statement) premise2).getPredicate(); - newComponent = ((Statement) premise2).getSubject(); - } else { - commonComponent = premise2; - } - Conjunction oldCondition = (Conjunction) premise1.getSubject(); - boolean match = Variable.unify(Variable.VarType.INDEPENDENT, oldCondition.componentAt(index), commonComponent, premise1, premise2); - if (!match && (commonComponent.getClass() == oldCondition.getClass())) { - match = Variable.unify(Variable.VarType.INDEPENDENT, oldCondition.componentAt(index), ((CompoundTerm) commonComponent).componentAt(index), premise1, premise2); - } - if (!match) { - return; - } - Term newCondition; - if (oldCondition.equals(commonComponent)) { - newCondition = null; - } else { - newCondition = CompoundTerm.replaceComponent(oldCondition, index, newComponent); - } - Term content; - if (newCondition != null) { - content = Statement.make(premise1, newCondition, premise1.getPredicate(), order1); - } else { - content = premise1.getPredicate(); - } - if (content == null) { - return; - } - TruthValue truth1 = taskSentence.getTruth(); - TruthValue truth2 = belief.getTruth(); - TruthValue truth = null; - BudgetValue budget; - if (taskSentence instanceof Question) { - budget = BudgetFunctions.backwardWeak(truth2); - } else { - if (taskSentence instanceof Goal) { - if (conditionalTask) { - truth = TruthFunctions.desireWeak(truth1, truth2); - } else if (deduction) { - truth = TruthFunctions.desireInd(truth1, truth2); - } else { - truth = TruthFunctions.desireDed(truth1, truth2); - } - budget = BudgetFunctions.forward(truth); - } else { - if (deduction) { - truth = TruthFunctions.deduction(truth1, truth2); - } else if (conditionalTask) { - truth = TruthFunctions.induction(truth2, truth1); - } else { - truth = TruthFunctions.induction(truth1, truth2); - } - } - budget = BudgetFunctions.forward(truth); - } - Memory.currentTense = tense; - Memory.doublePremiseTask(budget, content, truth); - } - - /** - * {<(&&, S2, S3) ==> P>, <(&&, S1, S3) ==> P>} |- S2> - * @param cond1 The condition of the first premise - * @param cond2 The condition of the second premise - * @param st1 The first premise - * @param st2 The second premise - * @return Whether there are derived tasks - */ - static boolean conditionalAbd(Term cond1, Term cond2, Statement st1, Statement st2) { - if (!(st1 instanceof Implication) || !(st2 instanceof Implication)) { - return false; - } - if (!(cond1 instanceof Conjunction) && !(cond2 instanceof Conjunction)) { - return false; - } - TemporalRules.Relation order1 = st1.getTemporalOrder(); - TemporalRules.Relation order2 = st2.getTemporalOrder(); - if (order1 != order2) { - return false; - } - Term term1 = null; - Term term2 = null; - if (cond1 instanceof Conjunction) { - term1 = CompoundTerm.reduceComponents((Conjunction) cond1, cond2); - } - if (cond2 instanceof Conjunction) { - term2 = CompoundTerm.reduceComponents((Conjunction) cond2, cond1); - } - if ((term1 == null) && (term2 == null)) { - return false; - } - Task task = Memory.currentTask; - Sentence sentence = task.getSentence(); - Judgment belief = Memory.currentBelief; - TruthValue value1 = sentence.getTruth(); - TruthValue value2 = belief.getTruth(); - boolean keepOrder = (Variable.findSubstitute(Variable.VarType.INDEPENDENT, st1, task.getContent()) != null); - Term content; - TruthValue truth = null; - BudgetValue budget; - if (term1 != null) { - if (term2 != null) { - content = Statement.make(st2, term2, term1, order2); - } else { - content = term1; - } - if (sentence instanceof Question) { - budget = BudgetFunctions.backwardWeak(value2); - } else { - if (sentence instanceof Goal) { - if (keepOrder) { - truth = TruthFunctions.desireDed(value1, value2); - } else { - truth = TruthFunctions.desireInd(value1, value2); - } - } else { - truth = TruthFunctions.abduction(value2, value1); - } - budget = BudgetFunctions.forward(truth); - } - Memory.doublePremiseTask(budget, content, truth); - } - if (term2 != null) { - if (term1 != null) { - content = Statement.make(st1, term1, term2, order1); - } else { - content = term2; - } - if (sentence instanceof Question) { - budget = BudgetFunctions.backwardWeak(value2); - } else { - if (sentence instanceof Goal) { - if (keepOrder) { - truth = TruthFunctions.desireDed(value1, value2); - } else { - truth = TruthFunctions.desireInd(value1, value2); - } - } else { - truth = TruthFunctions.abduction(value1, value2); - } - budget = BudgetFunctions.forward(truth); - } - Memory.currentTense = TemporalRules.Relation.NONE; - Memory.doublePremiseTask(budget, content, truth); - } - return true; - } - - /* --------------- rules used for independent variable introduction --------------- */ - /** - * { S>, P>} |- <<#x --> S> ==> <#x --> P>> - * { S>, P>} |- <<#x --> S> <=> <#x --> P>> - * @param sentence1 The first premise S> - * @param sentence2 The second premise P> - * @param figure The figure indicating the location of the shared term - * @param isImplication The conclusion is Implication, not Equivalence - */ - private static Statement introVarInd(Sentence sentence1, Sentence sentence2, int figure, boolean isImplication) { - Statement premise1 = (Statement) sentence1.getContent(); - Statement premise2 = (Statement) sentence2.getContent(); - Statement state1, state2; - Variable v1 = new Variable(Symbols.VARIABLE_TAG + "0"); - Variable v2 = new Variable(Symbols.VARIABLE_TAG + "0"); - if (figure == 11) { - state1 = Statement.make(premise1, v1, premise1.getPredicate()); - state2 = Statement.make(premise2, v2, premise2.getPredicate()); - } else { - state1 = Statement.make(premise1, premise1.getSubject(), v1); - state2 = Statement.make(premise2, premise2.getSubject(), v2); - } - TemporalRules.Relation tense1 = sentence1.getTense(); - TemporalRules.Relation tense2 = sentence2.getTense(); - TemporalRules.Relation tense = TemporalRules.tenseInference(tense1, tense2); - if (tense == null) { - return null; - } - Statement content; - if (isImplication) { - content = Implication.make(state1, state2, tense); - } else { - content = Equivalence.make(state1, state2, tense); - } - return content; - } - - /** - * { S>, P>>} |- <(&&, <#x --> S>, C) ==> <#x --> P>> - * { S>, (&&, C, P>)} |- (&&, C, <<#x --> S> ==> <#x --> P>>) - * @param premise1 The first premise directly used in internal induction, S> - * @param premise2 The component to be used as a premise in internal induction, P> - * @param oldCompound The whole content of the first premise, Implication or Conjunction - */ - static void introVarIndInner(Statement premise1, Statement premise2, CompoundTerm oldCompound) { - Task task = Memory.currentTask; - Sentence taskSentence = task.getSentence(); - if (!taskSentence.isJudgment()) { - return; - } - if (premise1.getClass() != premise2.getClass()) { - return; - } - Variable var1 = new Variable(Symbols.VARIABLE_TAG + "0"); - Variable var2 = new Variable(Symbols.VARIABLE_TAG + "0"); - Statement state1, state2; - if (premise1.getSubject().equals(premise2.getSubject())) { - state1 = Statement.make(premise1, var1, premise1.getPredicate()); - state2 = Statement.make(premise2, var2, premise2.getPredicate()); - } else if (premise1.getPredicate().equals(premise2.getPredicate())) { - state1 = Statement.make(premise1, premise1.getSubject(), var1); - state2 = Statement.make(premise2, premise2.getSubject(), var2); - } else { - return; - } - Sentence belief = Memory.currentBelief; - Term compound, content; - TemporalRules.Relation tense; - TruthValue truth; - if (premise1.equals(taskSentence.getContent())) { - truth = TruthFunctions.abduction(taskSentence.getTruth(), belief.getTruth()); - tense = TemporalRules.tenseInference(taskSentence.getTense(), belief.getTense()); - } else { - truth = TruthFunctions.abduction(belief.getTruth(), taskSentence.getTruth()); - tense = TemporalRules.tenseInference(belief.getTense(), taskSentence.getTense()); - } - if (tense == null) { - return; - } - if ((oldCompound instanceof Implication) && (tense == oldCompound.getTemporalOrder())) { - compound = Statement.make((Statement) oldCompound, oldCompound.componentAt(0), state2); - content = Statement.make((Statement) oldCompound, state1, compound); - } else if (oldCompound instanceof Conjunction) { - compound = Implication.make(state1, state2, tense); - content = CompoundTerm.replaceComponent(oldCompound, premise2, compound); - } else { - return; - } - BudgetValue budget = BudgetFunctions.forward(truth); - Memory.doublePremiseTask(budget, content, truth); - } - - /** - * { S>, P>} |- { P>,

S>, P>} - * @param task1 The first premise - * @param task2 The second premise - * @param order Temporal order of the premises - */ - static void temporalIndCom(Task task1, Task task2, TemporalRules.Relation order) { - Judgment judg1 = (Judgment) task1.getSentence(); - Judgment judg2 = (Judgment) task2.getSentence(); - Stamp stamp = Stamp.make(judg1.getStamp(), judg2.getStamp()); - if (stamp == null) { - return; - } - Memory.currentStamp = stamp; - Term term1 = judg1.getContent(); - Term term2 = judg2.getContent(); - if ((term1 instanceof Inheritance) && (term2 instanceof Inheritance)) { - Statement s1 = (Statement) term1; - Statement s2 = (Statement) term2; - Variable var1 = new Variable(Symbols.VARIABLE_TAG + "0"); - Variable var2 = new Variable(Symbols.VARIABLE_TAG + "0"); - if (s1.getSubject().equals(s2.getSubject())) { - term1 = Statement.make(s1, var1, s1.getPredicate()); - term2 = Statement.make(s2, var2, s2.getPredicate()); - } else if (s1.getPredicate().equals(s2.getPredicate())) { - term1 = Statement.make(s1, s1.getSubject(), var1); - term2 = Statement.make(s2, s2.getSubject(), var2); - } - } else { // to generalize - Term condition; - if ((term1 instanceof Implication) && (term2 instanceof Inheritance)) { - condition = ((Implication) term1).getSubject(); - if (condition.equals(term2)) { - return; - } - if ((condition instanceof Conjunction) && ((Conjunction) condition).containComponent(term2)) { - return; - } - } else if ((term1 instanceof Inheritance) && (term2 instanceof Implication)) { - condition = ((Implication) term2).getSubject(); - if (condition.equals(term1)) { - return; - } - if ((condition instanceof Conjunction) && ((Conjunction) condition).containComponent(term1)) { - return; - } - } - } - Statement statement1 = Implication.make(term1, term2, order); - Statement statement2 = Implication.make(term2, term1, TemporalRules.reverse(order)); - Statement statement3 = Equivalence.make(term1, term2, order); - TruthValue value1 = judg1.getTruth(); - TruthValue value2 = judg2.getTruth(); - TruthValue truth1 = TruthFunctions.induction(value1, value2); - TruthValue truth2 = TruthFunctions.induction(value2, value1); - TruthValue truth3 = TruthFunctions.comparison(value1, value2); - BudgetValue budget1 = BudgetFunctions.temporalIndCom(task1.getBudget(), task2.getBudget(), truth1); - BudgetValue budget2 = BudgetFunctions.temporalIndCom(task1.getBudget(), task2.getBudget(), truth2); - BudgetValue budget3 = BudgetFunctions.temporalIndCom(task1.getBudget(), task2.getBudget(), truth3); - Memory.currentTense = TemporalRules.Relation.WHEN; - Memory.doublePremiseTask(budget1, statement1, truth1); - Memory.doublePremiseTask(budget2, statement2, truth2); - Memory.doublePremiseTask(budget3, statement3, truth3); - } -} diff --git a/nars/inference/TemporalRules.java b/nars/inference/TemporalRules.java deleted file mode 100644 index c80648d7..00000000 --- a/nars/inference/TemporalRules.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * TemporalRules.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.inference; - -import java.util.*; - -import nars.entity.*; -import nars.main.*; - -/** - * Temporal inference rules - *

- * These rules are independent of the semantic and symtactic inference rules. - */ -public class TemporalRules { - - /** Temporal relations: a default and three specific */ - public enum Relation { - - NONE, BEFORE, WHEN, AFTER - } - - /** - * Temporal relationships among three terms - * @param r12 Temporal relationship from term1 to term2 - * @param r23 Temporal relationship from term2 to term3 - * @return Temporal relationship from term1 to term3 - */ - public static Relation temporalInference(Relation r12, Relation r23) { - if (r12 == r23) { - return r12; - } - if (r12 == Relation.NONE) { - return r23; - } - if (r23 == Relation.NONE) { - return r12; - } - if (r12 == Relation.WHEN) { - return r23; - } - if (r23 == Relation.WHEN) { - return r12; - } - assert (r12 == reverse(r23)); - return null; - } - - public static Relation reverse(Relation t1) { - if (t1 == Relation.BEFORE) { - return Relation.AFTER; - } - if (t1 == Relation.AFTER) { - return Relation.BEFORE; - } - return t1; - } - - /** - * Temporal inference in syllogism - * @param r1 The first premise - * @param r2 The second premise - * @param figure The location of the shared term - * @return The temporal order in the conclusion - */ - public static Relation temporalSyllogism(Relation r1, Relation r2, int figure) { - switch (figure) { - case 11: - return temporalInference(reverse(r1), r2); - case 12: - return temporalInference(reverse(r1), reverse(r2)); - case 21: - return temporalInference(r1, r2); - case 22: - return temporalInference(r1, reverse(r2)); - default: - return null; - } - } - - // called in variable introduction - /** - * The temporal inference on tenses - * @param tense1 The tense of the first premise - * @param tense2 The tense of the second premise - * @return The tense of the conclusion - */ - public static Relation tenseInference(Relation tense1, Relation tense2) { - if (tense1 == tense2) { - if (tense1 == Relation.NONE) { - return Relation.NONE; - } - return Relation.WHEN; - } - if (((tense1 == Relation.BEFORE) && (tense2 == Relation.WHEN)) || ((tense1 == Relation.WHEN) && (tense2 == Relation.AFTER))) { - return Relation.AFTER; - } - if (((tense1 == Relation.AFTER) && (tense2 == Relation.WHEN)) || ((tense1 == Relation.WHEN) && (tense2 == Relation.BEFORE))) { - return Relation.BEFORE; - } - return null; - } - - /** - * Simple temporal regularity discovery [To be refined] - *

- * called in Memory.immediateProcess - * @param event1 A new event - */ - public static void eventProcessing(Task event1) { - ArrayList recentEvents = Memory.recentEvents; - Sentence sentence1 = event1.getSentence(); - TemporalRules.Relation tense1 = sentence1.getTense(); - if (!sentence1.isJudgment() || (tense1 == TemporalRules.Relation.AFTER)) { - return; - } - recentEvents.add(0, event1); - if (recentEvents.size() > Parameters.MAXMUM_EVENTS_LENGTH) { - recentEvents.remove(Parameters.MAXMUM_EVENTS_LENGTH); - } - Task event2; - Sentence sentence2; -// TemporalRules.Relation tense2; - TemporalRules.Relation order; - for (int i = 1; i < recentEvents.size(); i++) { - event2 = recentEvents.get(i); - sentence2 = event2.getSentence(); -// tense2 = sentence2.getTense(); -// if (tense1 == tense2) { - order = sentence1.getStamp().orderWith(sentence2.getStamp()); - if (order != null) { - SyllogisticRules.temporalIndCom(event1, event2, order); - } -// } - } - } -} diff --git a/nars/io/ExperienceIO.java b/nars/io/ExperienceIO.java deleted file mode 100644 index 5c5d9332..00000000 --- a/nars/io/ExperienceIO.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * ExperienceIO.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.io; - -import java.awt.FileDialog; -import java.io.*; - -import nars.gui.*; -import nars.main.*; - -/** - * To read and write experience as Task streams - */ -public class ExperienceIO { - - /** Input experience from a window */ - private InputWindow inputWindow; - /** Input experience from a file */ - private BufferedReader inExp; - /** Output experience into a file */ - private PrintWriter outExp; - - /** - * Default constructor - */ - public ExperienceIO() { - inputWindow = MainWindow.inputWindow; - inExp = null; - outExp = null; - } - - /** - * Open an input experience file - */ - public void openLoadFile() { - FileDialog dialog = new FileDialog((FileDialog) null, "Load experience", FileDialog.LOAD); - dialog.setVisible(true); - String directoryName = dialog.getDirectory(); - String fileName = dialog.getFile(); - try { - inExp = new BufferedReader(new FileReader(directoryName + fileName)); - } catch (IOException ex) { - System.out.println("i/o error: " + ex.getMessage()); - } - } - - /** - * Open an output experience file - */ - public void openSaveFile() { - FileDialog dialog = new FileDialog((FileDialog) null, "Save experience", FileDialog.SAVE); - dialog.setVisible(true); - String directoryName = dialog.getDirectory(); - String fileName = dialog.getFile(); - try { - outExp = new PrintWriter(new FileWriter(directoryName + fileName)); - } catch (IOException ex) { - System.out.println("i/o error: " + ex.getMessage()); - } - } - - /** - * Read a line from input, and send running instruction to Memory - * @return Nember of running steps, if any - */ - public long loadLine() { - String line = null; - long cycle = 0; - if (inExp != null) { - try { - line = inExp.readLine(); - if (line == null) { - inExp.close(); - inExp = null; - } - } catch (IOException ex) { - System.out.println("i/o error: " + ex.getMessage()); - } - } else { - line = inputWindow.getLine(); - } - if (line != null) { - line = line.trim(); - if (line.length() > 0) { - try { - cycle = new Long(line); - } catch (NumberFormatException e) { - if (line.charAt(0) == '*') { - Center.reset(); - saveLine(line); - } else { - StringParser.parseExperience(new StringBuffer(line)); - } - } - } - } - return cycle; - } - - /** - * Write a line into the output experience file - * @param line The output line - */ - public void saveLine(String line) { - if (outExp != null) { - outExp.println(line); - } - } - - /** - * Close an input experience file - */ - public void closeLoadFile() { - try { - inExp.close(); - } catch (IOException ex) { - System.out.println("i/o error: " + ex.getMessage()); - } - } - - /** - * Close an output experience file - */ - public void closeSaveFile() { - outExp.close(); - } -} diff --git a/nars/io/Record.java b/nars/io/Record.java deleted file mode 100644 index 6a29aeba..00000000 --- a/nars/io/Record.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Record.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.io; - -import java.awt.FileDialog; -import java.io.*; - -import nars.gui.InferenceWindow; - -/** - * Inference log, which record input/output of each inference step - */ -public class Record { - - /** the display window */ - private static InferenceWindow window = new InferenceWindow(); - /** whether to display */ - private static boolean isReporting = false; - /** the log file */ - private static PrintWriter logFile = null; - - /** - * Initialize the window and the file - */ - public static void init() { - window.clear(); - if (logFile != null) { - closeLogFile(); - } - } - - /** - * Show the window - */ - public static void show() { - window.setVisible(true); - } - - /** - * Begin the display - */ - public static void play() { - isReporting = true; - } - - /** - * Stop the display - */ - public static void stop() { - isReporting = false; - } - - /** - * Add new text to display - * @param s The line to be displayed - */ - public static void append(String s) { - if (isReporting) { - window.append(s); - } - if (logFile != null) { - logFile.println(s); - } - } - - /** - * Open the log file - */ - public static void openLogFile() { - FileDialog dialog = new FileDialog((FileDialog) null, "Inference Log", FileDialog.SAVE); - dialog.setVisible(true); - String directoryName = dialog.getDirectory(); - String fileName = dialog.getFile(); - try { - logFile = new PrintWriter(new FileWriter(directoryName + fileName)); - } catch (IOException ex) { - System.out.println("i/o error: " + ex.getMessage()); - } - window.switchBackground(); - window.setVisible(true); - } - - /** - * Close the log file - */ - public static void closeLogFile() { - logFile.close(); - logFile = null; - window.resetBackground(); - } - - /** - * Check file logging - * @return If the file logging is going on - */ - public static boolean isLogging() { - return (logFile != null); - } -} - diff --git a/nars/language/Conjunction.java b/nars/language/Conjunction.java deleted file mode 100644 index 4c016a64..00000000 --- a/nars/language/Conjunction.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Conjunction.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.language; - -import java.util.*; - -import nars.io.Symbols; -import nars.main.Memory; - -/** - * Conjunction of statements - */ -public class Conjunction extends CompoundTerm { - - /** - * Constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - protected Conjunction(String n, ArrayList arg) { - super(n, arg); - } - - /** - * Constructor with full values, called by clone - * @param n The name of the term - * @param cs Component list - * @param open Open variable list - * @param i Syntactic complexity of the compound - */ - protected Conjunction(String n, ArrayList cs, ArrayList open, short i) { - super(n, cs, open, i); - } - - /** - * Clone an object - * @return A new object - */ - @SuppressWarnings("unchecked") - public Object clone() { - return new Conjunction(name, (ArrayList) cloneList(components), (ArrayList) cloneList(openVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param term1 The first compoment - * @param term2 The second compoment - * @return A compound generated or a term it reduced to - */ - @SuppressWarnings("unchecked") - public static Term make(Term term1, Term term2) { - TreeSet set; - if (term1 instanceof Conjunction) { - set = new TreeSet(((CompoundTerm) term1).cloneComponents()); - if (term2 instanceof Conjunction) { - set.addAll(((CompoundTerm) term2).cloneComponents()); - } // (&,(&,P,Q),(&,R,S)) = (&,P,Q,R,S) - else { - set.add((Term) term2.clone()); - } // (&,(&,P,Q),R) = (&,P,Q,R) - } else if (term2 instanceof Conjunction) { - set = new TreeSet(((CompoundTerm) term2).cloneComponents()); - set.add((Term) term1.clone()); // (&,R,(&,P,Q)) = (&,P,Q,R) - } else { - set = new TreeSet(); - set.add(term1); // clone? - set.add(term2); // clone? - } - return make(set); - } - - /** - * Try to make a new compound from a list of components. Called by StringParser. - * @return the Term generated from the arguments - * @param argList the list of arguments - */ - public static Term make(ArrayList argList) { - TreeSet set = new TreeSet(argList); // sort/merge arguments - return make(set); - } - - /** - * Try to make a new compound from a set of components. Called by the public make methods. - * @param set a set of Term as compoments - * @return the Term generated from the arguments - */ - public static Term make(TreeSet set) { - if (set.isEmpty()) { - return null; - } // special case: no component - if (set.size() == 1) { - return set.first(); - } // special case: single component - ArrayList argument = new ArrayList(set); - String name = makeCompoundName(Symbols.CONJUNCTION_OPERATOR, argument); - Term t = Memory.nameToListedTerm(name); - return (t != null) ? t : new Conjunction(name, argument); - } - - /** - * Get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.CONJUNCTION_OPERATOR; - } - - /** - * Check if the compound is communitative. - * @return true for communitative - */ - public boolean isCommutative() { - return true; - } -} diff --git a/nars/language/ConjunctionParallel.java b/nars/language/ConjunctionParallel.java deleted file mode 100644 index 6d4af771..00000000 --- a/nars/language/ConjunctionParallel.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * ConjunctionParallel.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.language; - -import java.util.*; - -import nars.inference.TemporalRules; -import nars.io.Symbols; -import nars.main.Memory; - -/** - * A parallel conjunction of Statements. - */ -public class ConjunctionParallel extends Conjunction implements Temporal { - - /** - * Constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - protected ConjunctionParallel(String n, ArrayList arg) { - super(n, arg); - } - - /** - * Constructor with full values, called by clone - * @param n The name of the term - * @param cs Component list - * @param open Open variable list - * @param i Syntactic complexity of the compound - */ - private ConjunctionParallel(String n, ArrayList cs, ArrayList open, short i) { - super(n, cs, open, i); - } - - /** - * Clone an object - * @return A new object - */ - @Override - @SuppressWarnings("unchecked") - public Object clone() { - return new ConjunctionParallel(name, (ArrayList) cloneList(components), (ArrayList) cloneList(openVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param term1 The first compoment - * @param term2 The second compoment - * @return A compound generated or a term it reduced to - */ - @SuppressWarnings("unchecked") - public static Term make(Term term1, Term term2) { - TreeSet set; - if (term1 instanceof ConjunctionParallel) { - set = new TreeSet(((CompoundTerm) term1).cloneComponents()); - if (term2 instanceof ConjunctionParallel) { - set.addAll(((CompoundTerm) term2).cloneComponents()); - } // (&,(&,P,Q),(&,R,S)) = (&,P,Q,R,S) - else { - set.add((Term) term2.clone()); - } // (&,(&,P,Q),R) = (&,P,Q,R) - } else if (term2 instanceof ConjunctionParallel) { - set = new TreeSet(((CompoundTerm) term2).cloneComponents()); - set.add((Term) term1.clone()); // (&,R,(&,P,Q)) = (&,P,Q,R) - } else { - set = new TreeSet(); - set.add(term1); // valid solution??? - set.add(term2); - } - return make(set); - } - - /** - * Try to make a new compound from a list of components. Called by StringParser. - * @return the Term generated from the arguments - * @param argList the list of arguments - */ - public static Term make(ArrayList argList) { - TreeSet set = new TreeSet(argList); // sort/merge arguments - return make(set); - } - - /** - * Try to make a new compound from a set of components. Called by the public make methods. - * @param set a set of Term as compoments - * @return the Term generated from the arguments - */ - public static Term make(TreeSet set) { - if (set.isEmpty()) { - return null; - } // special case: no component - if (set.size() == 1) { - return set.first(); - } // special case: single component - ArrayList argument = new ArrayList(set); - String name = makeCompoundName(Symbols.CONJUNCTION_OPERATOR, argument); - Term t = Memory.nameToListedTerm(name); - return (t != null) ? t : new ConjunctionParallel(name, argument); - } - - /** - * Get the operator of the term. - * @return the operator of the term - */ - @Override - public String operator() { - return Symbols.PARALLEL_OPERATOR; - } - - /** - * The components are concurrent - * @return WHEN means the components happen altogether - */ - @Override - public TemporalRules.Relation getTemporalOrder() { - return TemporalRules.Relation.WHEN; - } -} diff --git a/nars/language/ConjunctionSequence.java b/nars/language/ConjunctionSequence.java deleted file mode 100644 index 67d6c3ad..00000000 --- a/nars/language/ConjunctionSequence.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * ConjunctionSequence.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.language; - -import java.util.*; -import nars.inference.*; -import nars.io.*; -import nars.main.Memory; - -/** - * A sequential conjunction of Statements. - */ -public class ConjunctionSequence extends Conjunction implements Temporal { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private ConjunctionSequence(String n, ArrayList arg) { - super(n, arg); - } - - /** - * Constructor with full values, called by clone - * @param n The name of the term - * @param cs Component list - * @param open Open variable list - * @param i Syntactic complexity of the compound - */ - private ConjunctionSequence(String n, ArrayList cs, ArrayList open, short i) { - super(n, cs, open, i); - } - - /** - * Clone an object - * @return A new object - */ - @Override - @SuppressWarnings("unchecked") - public Object clone() { - return new ConjunctionSequence(name, (ArrayList) cloneList(components), (ArrayList) cloneList(openVariables), complexity); - } - - /** - * Try to make a new compound from a list of components. Called by StringParser. - * @param argument the list of arguments - * @return the Term generated from the arguments - */ - public static Term make(ArrayList argument) { - if (argument.size() == 1) { - return argument.get(0); - } - String name = makeCompoundName(Symbols.PRODUCT_OPERATOR, argument); - Term t = Memory.nameToListedTerm(name); - return (t != null) ? t : new ConjunctionSequence(name, argument); - } - - public static Term make(Term term1, Term term2) { - ArrayList argument = new ArrayList(); - argument.add(term1); - argument.add(term2); - return make(argument); - } - - /** - * Get the operator of the term. - * @return the operator of the term - */ - @Override - public String operator() { - return Symbols.SEQUENCE_OPERATOR; - } - - /** - * Check if the compound is communitative. - * @return true for communitative - */ - @Override - public boolean isCommutative() { - return false; - } - - /** - * The components are temporally sorted - * @return AFTER means the components happen in that order - */ - @Override - public TemporalRules.Relation getTemporalOrder() { - return TemporalRules.Relation.AFTER; - } -} diff --git a/nars/language/DifferenceExt.java b/nars/language/DifferenceExt.java deleted file mode 100644 index 0b494bbc..00000000 --- a/nars/language/DifferenceExt.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * DifferenceExt.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.language; - -import java.util.*; - -import nars.io.Symbols; -import nars.main.Memory; - -/** - * A compound term whose extension is the difference of the extensions of its components - */ -public class DifferenceExt extends CompoundTerm { - - /** - * Constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private DifferenceExt(String n, ArrayList arg) { - super(n, arg); - } - - /** - * Constructor with full values, called by clone - * @param n The name of the term - * @param cs Component list - * @param open Open variable list - * @param i Syntactic complexity of the compound - */ - private DifferenceExt(String n, ArrayList cs, ArrayList open, short i) { - super(n, cs, open, i); - } - - /** - * Clone an object - * @return A new object, to be casted into a DifferenceExt - */ - @SuppressWarnings("unchecked") - public Object clone() { - return new DifferenceExt(name, (ArrayList) cloneList(components), (ArrayList) cloneList(openVariables), complexity); - } - - /** - * Try to make a new DifferenceExt. Called by StringParser. - * @return the Term generated from the arguments - * @param argList The list of components - */ - public static Term make(ArrayList argList) { - if (argList.size() == 1) { // special case from CompoundTerm.reduceComponent - return argList.get(0); - } - if (argList.size() != 2) { - return null; - } - String name = makeCompoundName(Symbols.DIFFERENCE_EXT_OPERATOR, argList); - Term t = Memory.nameToListedTerm(name); - return (t != null) ? t : new DifferenceExt(name, argList); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param t1 The first compoment - * @param t2 The second compoment - * @return A compound generated or a term it reduced to - */ - @SuppressWarnings("unchecked") - public static Term make(Term t1, Term t2) { - if (t1.equals(t2)) { - return null; - } - if ((t1 instanceof SetExt) && (t2 instanceof SetExt)) { - TreeSet set = new TreeSet(((CompoundTerm) t1).cloneComponents()); - set.removeAll(((CompoundTerm) t2).cloneComponents()); // set difference - return SetExt.make(set); - } - ArrayList list = argumentsToList(t1, t2); - return make(list); - } - - /** - * Get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.DIFFERENCE_EXT_OPERATOR; - } -} diff --git a/nars/language/DifferenceInt.java b/nars/language/DifferenceInt.java deleted file mode 100644 index 193c3460..00000000 --- a/nars/language/DifferenceInt.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * DifferenceInt.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.language; - -import java.util.*; - -import nars.io.Symbols; -import nars.main.Memory; - -/** - * A compound term whose extension is the difference of the intensions of its components - */ -public class DifferenceInt extends CompoundTerm { - - /** - * Constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private DifferenceInt(String n, ArrayList arg) { - super(n, arg); - } - - /** - * Constructor with full values, called by clone - * @param n The name of the term - * @param cs Component list - * @param open Open variable list - * @param i Syntactic complexity of the compound - */ - private DifferenceInt(String n, ArrayList cs, ArrayList open, short i) { - super(n, cs, open, i); - } - - /** - * Clone an object - * @return A new object, to be casted into a DifferenceInt - */ - @SuppressWarnings("unchecked") - public Object clone() { - return new DifferenceInt(name, (ArrayList) cloneList(components), (ArrayList) cloneList(openVariables), complexity); - } - - /** - * Try to make a new DifferenceExt. Called by StringParser. - * @return the Term generated from the arguments - * @param argList The list of components - */ - public static Term make(ArrayList argList) { - if (argList.size() == 1) { // special case from CompoundTerm.reduceComponent - return argList.get(0); - } - if (argList.size() != 2) { - return null; - } - String name = makeCompoundName(Symbols.DIFFERENCE_INT_OPERATOR, argList); - Term t = Memory.nameToListedTerm(name); - return (t != null) ? t : new DifferenceInt(name, argList); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param t1 The first compoment - * @param t2 The second compoment - * @return A compound generated or a term it reduced to - */ - @SuppressWarnings("unchecked") - public static Term make(Term t1, Term t2) { - if (t1.equals(t2)) { - return null; - } - if ((t1 instanceof SetInt) && (t2 instanceof SetInt)) { - TreeSet set = new TreeSet(((CompoundTerm) t1).cloneComponents()); - set.removeAll(((CompoundTerm) t2).cloneComponents()); // set difference - return SetInt.make(set); - } - ArrayList list = argumentsToList(t1, t2); - return make(list); - } - - /** - * Get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.DIFFERENCE_INT_OPERATOR; - } -} - - diff --git a/nars/language/Disjunction.java b/nars/language/Disjunction.java deleted file mode 100644 index 8aefd96b..00000000 --- a/nars/language/Disjunction.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Disjunction.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.language; - -import java.util.*; - -import nars.io.Symbols; -import nars.main.Memory; - -/** - * A disjunction of Statements. - */ -public class Disjunction extends CompoundTerm { - - /** - * Constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private Disjunction(String n, ArrayList arg) { - super(n, arg); - } - - /** - * Constructor with full values, called by clone - * @param n The name of the term - * @param cs Component list - * @param open Open variable list - * @param i Syntactic complexity of the compound - */ - private Disjunction(String n, ArrayList cs, ArrayList open, short i) { - super(n, cs, open, i); - } - - /** - * Clone an object - * @return A new object - */ - @SuppressWarnings("unchecked") - public Object clone() { - return new Disjunction(name, (ArrayList) cloneList(components), (ArrayList) cloneList(openVariables), complexity); - } - - /** - * Try to make a new Disjunction from two components. Called by the inference rules. - * @param term1 The first compoment - * @param term2 The first compoment - * @return A Disjunction generated or a Term it reduced to - */ - @SuppressWarnings("unchecked") - public static Term make(Term term1, Term term2) { - TreeSet set; - if (term1 instanceof Disjunction) { - set = new TreeSet(((CompoundTerm) term1).cloneComponents()); - if (term2 instanceof Disjunction) { - set.addAll(((CompoundTerm) term2).cloneComponents()); - } // (&,(&,P,Q),(&,R,S)) = (&,P,Q,R,S) - else { - set.add((Term) term2.clone()); - } // (&,(&,P,Q),R) = (&,P,Q,R) - } else if (term2 instanceof Disjunction) { - set = new TreeSet(((CompoundTerm) term2).cloneComponents()); - set.add((Term) term1.clone()); // (&,R,(&,P,Q)) = (&,P,Q,R) - } else { - set = new TreeSet(); - set.add((Term) term1.clone()); - set.add((Term) term2.clone()); - } - return make(set); - } - - /** - * Try to make a new IntersectionExt. Called by StringParser. - * @param argList a list of Term as compoments - * @return the Term generated from the arguments - */ - public static Term make(ArrayList argList) { - TreeSet set = new TreeSet(argList); // sort/merge arguments - return make(set); - } - - /** - * Try to make a new Disjunction from a set of components. Called by the public make methods. - * @param set a set of Term as compoments - * @return the Term generated from the arguments - */ - public static Term make(TreeSet set) { - if (set.size() == 1) { - return set.first(); - } // special case: single component - ArrayList argument = new ArrayList(set); - String name = makeCompoundName(Symbols.DISJUNCTION_OPERATOR, argument); - Term t = Memory.nameToListedTerm(name); - return (t != null) ? t : new Disjunction(name, argument); - } - - /** - * Get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.DISJUNCTION_OPERATOR; - } - - /** - * Disjunction is communitative. - * @return true for communitative - */ - @Override - public boolean isCommutative() { - return true; - } -} diff --git a/nars/language/Equivalence.java b/nars/language/Equivalence.java deleted file mode 100644 index 388226eb..00000000 --- a/nars/language/Equivalence.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Equivalence.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.language; - -import java.util.*; - -import nars.inference.TemporalRules; -import nars.io.Symbols; -import nars.main.Memory; - -/** - * A Statement about an Equivalence relation. - */ -public class Equivalence extends Statement { - - /** - * Constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - protected Equivalence(String n, ArrayList arg) { - super(n, arg); - } - - /** - * Constructor with full values, called by clone - * @param n The name of the term - * @param cs Component list - * @param open Open variable list - * @param i Syntactic complexity of the compound - */ - protected Equivalence(String n, ArrayList cs, ArrayList open, short i) { - super(n, cs, open, i); - } - - /** - * Clone an object - * @return A new object - */ - @SuppressWarnings("unchecked") - public Object clone() { - return new Equivalence(name, (ArrayList) cloneList(components), (ArrayList) cloneList(openVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or null - */ - public static Equivalence make(Term subject, Term predicate) { - if (invalidStatement(subject, predicate)) { - return null; - } - if (subject.compareTo(predicate) > 0) { - return make(predicate, subject); - } - String name = makeStatementName(subject, Symbols.EQUIVALENCE_RELATION, predicate); - Term t = Memory.nameToListedTerm(name); - if (t != null) { - return (Equivalence) t; - } - ArrayList argument = argumentsToList(subject, predicate); - return new Equivalence(name, argument); - } - - public static Equivalence make(Term subject, Term predicate, TemporalRules.Relation temporalOrder) { // to be extended to check if subject is Conjunction - if ((subject instanceof Implication) || (subject instanceof Equivalence) || (predicate instanceof Implication) || (predicate instanceof Equivalence)) { - return null; - } - switch (temporalOrder) { - case BEFORE: - return EquivalenceAfter.make(predicate, subject); - case WHEN: - return EquivalenceWhen.make(subject, predicate); - case AFTER: - return EquivalenceAfter.make(subject, predicate); - default: - return Equivalence.make(subject, predicate); - } - } - - /** - * Get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.EQUIVALENCE_RELATION; - } - - /** - * Check if the compound is communitative. - * @return true for communitative - */ - @Override - public boolean isCommutative() { - return true; - } -} diff --git a/nars/language/EquivalenceAfter.java b/nars/language/EquivalenceAfter.java deleted file mode 100644 index b80b6f65..00000000 --- a/nars/language/EquivalenceAfter.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * EquivalenceAfter.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.language; - -import java.util.*; - -import nars.inference.TemporalRules; -import nars.io.Symbols; -import nars.main.Memory; - -/** - * Temporal Implication relation, predicate after subject. - */ -public class EquivalenceAfter extends Equivalence implements Temporal { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - public EquivalenceAfter(String n, ArrayList arg) { - super(n, arg); - } - - /** - * Constructor with full values, called by clone - * @param n The name of the term - * @param cs Component list - * @param open Open variable list - * @param i Syntactic complexity of the compound - */ - private EquivalenceAfter(String n, ArrayList cs, ArrayList open, short i) { - super(n, cs, open, i); - } - - /** - * Clone an object - * @return A new object - */ - @Override - @SuppressWarnings("unchecked") - public Object clone() { - return new EquivalenceAfter(name, (ArrayList) cloneList(components), (ArrayList) cloneList(openVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or null - */ - public static EquivalenceAfter make(Term subject, Term predicate) { - if (invalidStatement(subject, predicate)) { - return null; - } - String name = makeStatementName(subject, Symbols.EQUIVALENCE_RELATION, predicate); - Term t = Memory.nameToListedTerm(name); - if (t != null) { - return (EquivalenceAfter) t; - } - ArrayList argument = argumentsToList(subject, predicate); - return new EquivalenceAfter(name, argument); - } - - /** - * Get the operator of the term. - * @return the operator of the term - */ - @Override - public String operator() { - return Symbols.EQUIVALENCE_AFTER_RELATION; - } - - /** - * Check if the compound is communitative. - * @return The components are temporally ordered - */ - @Override - public boolean isCommutative() { - return false; - } - - /** - * Get the temporal order of the class - * @return AFTER since the components are temporally ordered - */ - @Override - public TemporalRules.Relation getTemporalOrder() { - return TemporalRules.Relation.AFTER; - } -} diff --git a/nars/language/EquivalenceWhen.java b/nars/language/EquivalenceWhen.java deleted file mode 100644 index c1a3d03f..00000000 --- a/nars/language/EquivalenceWhen.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * EquivalenceWhen.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.language; - -import java.util.*; - -import nars.inference.TemporalRules; -import nars.io.Symbols; -import nars.main.Memory; - -/** - * Temporal Equivalence relation, concurrent. - */ -public class EquivalenceWhen extends Equivalence implements Temporal { - - /** - * Constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - public EquivalenceWhen(String n, ArrayList arg) { - super(n, arg); - } - - /** - * Constructor with full values, called by clone - * @param n The name of the term - * @param cs Component list - * @param open Open variable list - * @param i Syntactic complexity of the compound - */ - private EquivalenceWhen(String n, ArrayList cs, ArrayList open, short i) { - super(n, cs, open, i); - } - - /** - * Clone an object - * @return A new object - */ - @Override - @SuppressWarnings("unchecked") - public Object clone() { - return new EquivalenceWhen(name, (ArrayList) cloneList(components), (ArrayList) cloneList(openVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or null - */ - public static EquivalenceWhen make(Term subject, Term predicate) { - if (invalidStatement(subject, predicate)) { - return null; - } - if (subject.compareTo(predicate) > 0) { - return make(predicate, subject); - } - String name = makeStatementName(subject, Symbols.EQUIVALENCE_RELATION, predicate); - Term t = Memory.nameToListedTerm(name); - if (t != null) { - return (EquivalenceWhen) t; - } - ArrayList argument = argumentsToList(subject, predicate); - return new EquivalenceWhen(name, argument); - } - - /** - * Get the operator of the term. - * @return the operator of the term - */ - @Override - public String operator() { - return Symbols.EQUIVALENCE_WHEN_RELATION; - } - - /** - * Get the temporal order of the class - * @return WHEN since the components are concurrent - */ - @Override - public TemporalRules.Relation getTemporalOrder() { - return TemporalRules.Relation.WHEN; - } -} diff --git a/nars/language/Implication.java b/nars/language/Implication.java deleted file mode 100644 index bdddf315..00000000 --- a/nars/language/Implication.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Implication.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.language; - -import java.util.*; - -import nars.inference.TemporalRules; -import nars.io.Symbols; -import nars.main.Memory; - -/** - * A Statement about an Inheritance relation. - */ -public class Implication extends Statement { - - /** - * Constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - protected Implication(String n, ArrayList arg) { - super(n, arg); - } - - /** - * Constructor with full values, called by clone - * @param n The name of the term - * @param cs Component list - * @param open Open variable list - * @param i Syntactic complexity of the compound - */ - protected Implication(String n, ArrayList cs, ArrayList open, short i) { - super(n, cs, open, i); - } - - /** - * Clone an object - * @return A new object - */ - @SuppressWarnings("unchecked") - public Object clone() { - return new Implication(name, (ArrayList) cloneList(components), (ArrayList) cloneList(openVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or a term it reduced to - */ - public static Implication make(Term subject, Term predicate) { // to be extended to check if subject is Conjunction - if (invalidStatement(subject, predicate)) { - return null; - } - String name = makeStatementName(subject, Symbols.IMPLICATION_RELATION, predicate); - Term t = Memory.nameToListedTerm(name); - if (t != null) { - return (Implication) t; - } - if (predicate instanceof Implication) { - Term oldCondition = ((Implication) predicate).getSubject(); - Term newCondition = Conjunction.make(subject, oldCondition); - return make(newCondition, ((Implication) predicate).getPredicate()); - } else { - ArrayList argument = argumentsToList(subject, predicate); - return new Implication(name, argument); - } - } - - public static Implication make(Term subject, Term predicate, TemporalRules.Relation temporalOrder) { - if ((subject instanceof Implication) || (subject instanceof Equivalence) || (predicate instanceof Equivalence)) { - return null; - } - switch (temporalOrder) { - case BEFORE: - return ImplicationBefore.make(subject, predicate); - case WHEN: - return ImplicationWhen.make(subject, predicate); - case AFTER: - return ImplicationAfter.make(subject, predicate); - default: - return Implication.make(subject, predicate); - } - } - - /** - * Get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.IMPLICATION_RELATION; - } -} diff --git a/nars/language/ImplicationAfter.java b/nars/language/ImplicationAfter.java deleted file mode 100644 index 57f155d0..00000000 --- a/nars/language/ImplicationAfter.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * ImplicationAfter.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.language; - -import java.util.*; - -import nars.inference.TemporalRules; -import nars.io.Symbols; -import nars.main.Memory; - -/** - * Temporal Implication relation, predicate after subject. - */ -public class ImplicationAfter extends Implication implements Temporal { - - /** - * constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private ImplicationAfter(String n, ArrayList arg) { - super(n, arg); - } - - /** - * Constructor with full values, called by clone - * @param n The name of the term - * @param cs Component list - * @param open Open variable list - * @param i Syntactic complexity of the compound - */ - private ImplicationAfter(String n, ArrayList cs, ArrayList open, short i) { - super(n, cs, open, i); - } - - /** - * Clone an object - * @return A new object - */ - @Override - @SuppressWarnings("unchecked") - public Object clone() { - return new ImplicationAfter(name, (ArrayList) cloneList(components), (ArrayList) cloneList(openVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or a term it reduced to - */ - public static ImplicationAfter make(Term subject, Term predicate) { // to be extended to check if subject is Conjunction - if (invalidStatement(subject, predicate)) { - return null; - } - String name = makeStatementName(subject, Symbols.IMPLICATION_AFTER_RELATION, predicate); - Term t = Memory.nameToListedTerm(name); - if (t != null) { - return (ImplicationAfter) t; - } - if (predicate instanceof ImplicationAfter) { - Term oldCondition = ((ImplicationAfter) predicate).getSubject(); - Term newCondition = ConjunctionSequence.make(subject, oldCondition); - return make(newCondition, ((ImplicationAfter) predicate).getPredicate()); - } else if (!(predicate instanceof Implication)) { - ArrayList argument = argumentsToList(subject, predicate); - return new ImplicationAfter(name, argument); - } else { - return null; - } - } - - /** - * Get the operator of the term. - * @return the operator of the term - */ - @Override - public String operator() { - return Symbols.IMPLICATION_AFTER_RELATION; - } - - /** - * The relation is predictive - * @return AFTER means the condition is pre-condition - */ - @Override - public TemporalRules.Relation getTemporalOrder() { - return TemporalRules.Relation.AFTER; - } -} diff --git a/nars/language/ImplicationBefore.java b/nars/language/ImplicationBefore.java deleted file mode 100644 index 8010098c..00000000 --- a/nars/language/ImplicationBefore.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * ImplicationBefore.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.language; - -import java.util.*; - -import nars.inference.TemporalRules; -import nars.io.Symbols; -import nars.main.Memory; - -/** - * Temporal Implication relation, predicate before subject. - */ -public class ImplicationBefore extends Implication implements Temporal { - - /** - * Constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private ImplicationBefore(String n, ArrayList arg) { - super(n, arg); - } - - /** - * Constructor with full values, called by clone - * @param n The name of the term - * @param cs Component list - * @param open Open variable list - * @param i Syntactic complexity of the compound - */ - private ImplicationBefore(String n, ArrayList cs, ArrayList open, short i) { - super(n, cs, open, i); - } - - /** - * Clone an object - * @return A new object - */ - @Override - @SuppressWarnings("unchecked") - public Object clone() { - return new ImplicationBefore(name, (ArrayList) cloneList(components), (ArrayList) cloneList(openVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or a term it reduced to - */ - public static ImplicationBefore make(Term subject, Term predicate) { // to be extended to check if subject is Conjunction - if (invalidStatement(subject, predicate)) { - return null; - } - String name = makeStatementName(subject, Symbols.IMPLICATION_BEFORE_RELATION, predicate); - Term t = Memory.nameToListedTerm(name); - if (t != null) { - return (ImplicationBefore) t; - } - if (predicate instanceof ImplicationBefore) { - Term oldCondition = ((ImplicationBefore) predicate).getSubject(); - Term newCondition = ConjunctionSequence.make(oldCondition, subject); - return make(newCondition, ((ImplicationBefore) predicate).getPredicate()); - } else if (!(predicate instanceof Implication)) { - ArrayList argument = argumentsToList(subject, predicate); - return new ImplicationBefore(name, argument); - } else { - return null; - } - } - - /** - * Get the operator of the term. - * @return the operator of the term - */ - @Override - public String operator() { - return Symbols.IMPLICATION_BEFORE_RELATION; - } - - /** - * The relation is retrospective - * @return BEFORE means the condition is post-condition - */ - @Override - public TemporalRules.Relation getTemporalOrder() { - return TemporalRules.Relation.BEFORE; - } -} diff --git a/nars/language/ImplicationWhen.java b/nars/language/ImplicationWhen.java deleted file mode 100644 index 3d40d440..00000000 --- a/nars/language/ImplicationWhen.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * ImplicationWhen.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.language; - -import java.util.*; - -import nars.inference.TemporalRules; -import nars.io.Symbols; -import nars.main.Memory; - -/** - * Temporal Implication relation, concurrent. - */ -public class ImplicationWhen extends Implication implements Temporal { - - /** - * Constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - protected ImplicationWhen(String n, ArrayList arg) { - super(n, arg); - } - - /** - * Constructor with full values, called by clone - * @param n The name of the term - * @param cs Component list - * @param open Open variable list - * @param i Syntactic complexity of the compound - */ - private ImplicationWhen(String n, ArrayList cs, ArrayList open, short i) { - super(n, cs, open, i); - } - - /** - * Clone an object - * @return A new object - */ - @Override - @SuppressWarnings("unchecked") - public Object clone() { - return new ImplicationWhen(name, (ArrayList) cloneList(components), (ArrayList) cloneList(openVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or a term it reduced to - */ - public static ImplicationWhen make(Term subject, Term predicate) { // to be extended to check if subject is Conjunction - if (invalidStatement(subject, predicate)) { - return null; - } - String name = makeStatementName(subject, Symbols.IMPLICATION_RELATION, predicate); - Term t = Memory.nameToListedTerm(name); - if (t != null) { - return (ImplicationWhen) t; - } - if (predicate instanceof ImplicationWhen) { - Term oldCondition = ((ImplicationWhen) predicate).getSubject(); - Term newCondition = ConjunctionParallel.make(subject, oldCondition); - return make(newCondition, ((ImplicationWhen) predicate).getPredicate()); - } else if (!(predicate instanceof Implication)) { - ArrayList argument = argumentsToList(subject, predicate); - return new ImplicationWhen(name, argument); - } else { - return null; - } - } - - /** - * Get the operator of the term. - * @return the operator of the term - */ - @Override - public String operator() { - return Symbols.IMPLICATION_WHEN_RELATION; - } - - /** - * The relation is concurrent - * @return WHEN means the condition is co-condition - */ - @Override - public TemporalRules.Relation getTemporalOrder() { - return TemporalRules.Relation.WHEN; - } -} diff --git a/nars/language/Inheritance.java b/nars/language/Inheritance.java deleted file mode 100644 index fb1cd91b..00000000 --- a/nars/language/Inheritance.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Inheritance.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.language; - -import java.util.ArrayList; - -import nars.io.Symbols; -import nars.main.Memory; - -/** - * A Statement about an Inheritance relation. - */ -public class Inheritance extends Statement { - - /** - * Constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private Inheritance(String n, ArrayList arg) { - super(n, arg); - } - - /** - * Constructor with full values, called by clone - * @param n The name of the term - * @param cs Component list - * @param open Open variable list - * @param i Syntactic complexity of the compound - */ - private Inheritance(String n, ArrayList cs, ArrayList open, short i) { - super(n, cs, open, i); - } - - /** - * Clone an object - * @return A new object, to be casted into a SetExt - */ - @SuppressWarnings("unchecked") - public Object clone() { - return new Inheritance(name, (ArrayList) cloneList(components), (ArrayList) cloneList(openVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or null - */ - public static Inheritance make(Term subject, Term predicate) { - if (invalidStatement(subject, predicate)) { - return null; - } - String name = makeStatementName(subject, Symbols.INHERITANCE_RELATION, predicate); - Term t = Memory.nameToListedTerm(name); - if (t != null) { - return (Inheritance) t; - } - ArrayList argument = argumentsToList(subject, predicate); - return new Inheritance(name, argument); - } - - /** - * Get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.INHERITANCE_RELATION; - } -} - diff --git a/nars/language/Instance.java b/nars/language/Instance.java deleted file mode 100644 index 93654c93..00000000 --- a/nars/language/Instance.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Instance.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ - -package nars.language; - -/** - * A Statement about an Instance relation, which is used only in Narsese for I/O, - * and translated into Inheritance for internal use. - */ -public abstract class Instance extends Statement { - - /** - * Try to make a new compound from two components. Called by the inference rules. - *

- * A {-- B becomes {A} --> B - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or null - */ - public static Statement make(Term subject, Term predicate) { - return Inheritance.make(SetExt.make(subject), predicate); - } -} diff --git a/nars/language/InstanceProperty.java b/nars/language/InstanceProperty.java deleted file mode 100644 index d57b66c7..00000000 --- a/nars/language/InstanceProperty.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * InstanceProperty.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ - -package nars.language; - -/** - * A Statement about an InstanceProperty relation, which is used only in Narsese for I/O, - * and translated into Inheritance for internal use. - */ -public abstract class InstanceProperty extends Statement { - - /** - * Try to make a new compound from two components. Called by the inference rules. - *

- * A {-] B becomes {A} --> [B] - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or null - */ - public static Statement make(Term subject, Term predicate) { - return Inheritance.make(SetExt.make(subject), SetInt.make(predicate)); - } -} diff --git a/nars/language/Negation.java b/nars/language/Negation.java deleted file mode 100644 index dd6cd400..00000000 --- a/nars/language/Negation.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Negation.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.language; - -import java.util.*; - -import nars.io.Symbols; -import nars.main.Memory; - -/** - * A negation of a Statement. - */ -public class Negation extends CompoundTerm { - - /** - * Constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private Negation(String n, ArrayList arg) { - super(n, arg); - } - - /** - * Constructor with full values, called by clone - * @param n The name of the term - * @param cs Component list - * @param open Open variable list - * @param i Syntactic complexity of the compound - */ - private Negation(String n, ArrayList cs, ArrayList open, short i) { - super(n, cs, open, i); - } - - /** - * Clone an object - * @return A new object - */ - @SuppressWarnings("unchecked") - public Object clone() { - return new Negation(name, (ArrayList) cloneList(components), (ArrayList) cloneList(openVariables), complexity); - } - - /** - * Try to make a Negation of one component. Called by the inference rules. - * @param t The compoment - * @return A compound generated or a term it reduced to - */ - public static Term make(Term t) { - if (t instanceof Negation) { - return ((CompoundTerm) t).cloneComponents().get(0); - } // (--,(--,P)) = P - ArrayList argument = new ArrayList(); - argument.add(t); - return make(argument); - } - - /** - * Try to make a new SetExt. Called by StringParser. - * @return the Term generated from the arguments - * @param argument The list of components - */ - public static Term make(ArrayList argument) { - if (argument.size() != 1) { - return null; - } - String name = makeCompoundName(Symbols.NEGATION_OPERATOR, argument); - Term t = Memory.nameToListedTerm(name); - return (t != null) ? t : new Negation(name, argument); - } - - /** - * Get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.NEGATION_OPERATOR; - } -} diff --git a/nars/language/Property.java b/nars/language/Property.java deleted file mode 100644 index 61b576cb..00000000 --- a/nars/language/Property.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Property.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ - -package nars.language; - -/** - * A Statement about a Property relation, which is used only in Narsese for I/O, - * and translated into Inheritance for internal use. - */ -public abstract class Property extends Statement { - - /** - * Try to make a new compound from two components. Called by the inference rules. - *

- * A --] B becomes A --> [B] - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or null - */ - public static Statement make(Term subject, Term predicate) { - return Inheritance.make(subject, SetInt.make(predicate)); - } -} diff --git a/nars/language/Similarity.java b/nars/language/Similarity.java deleted file mode 100644 index 1367112e..00000000 --- a/nars/language/Similarity.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Similarity.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.language; - -import java.util.ArrayList; - -import nars.io.Symbols; -import nars.main.Memory; - -/** - * A Statement about a Similarity relation. - */ -public class Similarity extends Statement { - - /** - * Constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - private Similarity(String n, ArrayList arg) { - super(n, arg); - } - - /** - * Constructor with full values, called by clone - * @param n The name of the term - * @param cs Component list - * @param open Open variable list - * @param i Syntactic complexity of the compound - */ - private Similarity(String n, ArrayList cs, ArrayList open, short i) { - super(n, cs, open, i); - } - - /** - * Clone an object - * @return A new object, to be casted into a Similarity - */ - @SuppressWarnings("unchecked") - public Object clone() { - return new Similarity(name, (ArrayList) cloneList(components), (ArrayList) cloneList(openVariables), complexity); - } - - /** - * Try to make a new compound from two components. Called by the inference rules. - * @param subject The first compoment - * @param predicate The second compoment - * @return A compound generated or null - */ - public static Similarity make(Term subject, Term predicate) { - if (invalidStatement(subject, predicate)) { - return null; - } - if (subject.compareTo(predicate) > 0) { - return make(predicate, subject); - } - String name = makeStatementName(subject, Symbols.SIMILARITY_RELATION, predicate); - Term t = Memory.nameToListedTerm(name); - if (t != null) { - return (Similarity) t; - } - ArrayList argument = argumentsToList(subject, predicate); - return new Similarity(name, argument); - } - - /** - * Get the operator of the term. - * @return the operator of the term - */ - public String operator() { - return Symbols.SIMILARITY_RELATION; - } - - /** - * Check if the compound is communitative. - * @return true for communitative - */ - @Override - public boolean isCommutative() { - return true; - } -} diff --git a/nars/language/Statement.java b/nars/language/Statement.java deleted file mode 100644 index 9355369f..00000000 --- a/nars/language/Statement.java +++ /dev/null @@ -1,315 +0,0 @@ -/* - * Statement.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.language; - -import java.util.ArrayList; - -import nars.inference.TemporalRules; -import nars.io.Symbols; - -/** - * A statement is a compound term, consisting of a subject, a predicate, - * and a relation symbol in between. It can be of either first-order or higher-order. - */ -public abstract class Statement extends CompoundTerm { - - /** - * Default constructor - */ - protected Statement() { - } - - /** - * Constructor with partial values, called by make - * @param n The name of the term - * @param arg The component list of the term - */ - protected Statement(String n, ArrayList arg) { - super(n, arg); - } - - /** - * Constructor with full values, called by clone - * @param n The name of the term - * @param cs Component list - * @param open Open variable list - * @param i Syntactic complexity of the compound - */ - protected Statement(String n, ArrayList cs, ArrayList open, short i) { - super(n, cs, open, i); - } - - /** - * Make a Statement from String, called by StringParser - * @param relation The relation String - * @param subject The first component - * @param predicate The second component - * @return The Statement built - */ - public static Statement make(String relation, Term subject, Term predicate) { - if (invalidStatement(subject, predicate)) { - return null; - } - if (relation.equals(Symbols.INHERITANCE_RELATION)) { - return Inheritance.make(subject, predicate); - } - if (relation.equals(Symbols.SIMILARITY_RELATION)) { - return Similarity.make(subject, predicate); - } - if (relation.equals(Symbols.INSTANCE_RELATION)) { - return Instance.make(subject, predicate); - } - if (relation.equals(Symbols.PROPERTY_RELATION)) { - return Property.make(subject, predicate); - } - if (relation.equals(Symbols.INSTANCE_PROPERTY_RELATION)) { - return InstanceProperty.make(subject, predicate); - } - if (relation.equals(Symbols.IMPLICATION_RELATION)) { - return Implication.make(subject, predicate); - } - if (relation.equals(Symbols.EQUIVALENCE_RELATION)) { - return Equivalence.make(subject, predicate); - } - if (relation.equals(Symbols.IMPLICATION_AFTER_RELATION)) { - return ImplicationAfter.make(subject, predicate); - } - if (relation.equals(Symbols.IMPLICATION_WHEN_RELATION)) { - return ImplicationWhen.make(subject, predicate); - } - if (relation.equals(Symbols.IMPLICATION_BEFORE_RELATION)) { - return ImplicationBefore.make(subject, predicate); - } - if (relation.equals(Symbols.EQUIVALENCE_AFTER_RELATION)) { - return EquivalenceAfter.make(subject, predicate); - } - if (relation.equals(Symbols.EQUIVALENCE_WHEN_RELATION)) { - return EquivalenceWhen.make(subject, predicate); - } - return null; - } - - /** - * Make a Statement from given components, called by the rules - * @return The Statement built - * @param subj The first component - * @param pred The second component - * @param statement A sample statement providing the class type - */ - public static Statement make(Statement statement, Term subj, Term pred) { - if (statement instanceof Inheritance) { - return Inheritance.make(subj, pred); - } - if (statement instanceof Similarity) { - return Similarity.make(subj, pred); - } - if (statement instanceof ImplicationBefore) { - return ImplicationBefore.make(subj, pred); - } - if (statement instanceof ImplicationWhen) { - return ImplicationWhen.make(subj, pred); - } - if (statement instanceof ImplicationAfter) { - return ImplicationAfter.make(subj, pred); - } - if (statement instanceof Implication) { - return Implication.make(subj, pred); - } - if (statement instanceof EquivalenceWhen) { - return EquivalenceWhen.make(subj, pred); - } - if (statement instanceof EquivalenceAfter) { - return EquivalenceAfter.make(subj, pred); - } - if (statement instanceof Equivalence) { - return Equivalence.make(subj, pred); - } - return null; - } - - /** - * Make a Statement from given components and temporal information, called by the rules - * @param statement A sample statement providing the class type - * @param subj The first component - * @param pred The second component - * @param order The temporal order of the statement - * @return The Statement built - */ - public static Statement make(Statement statement, Term subj, Term pred, TemporalRules.Relation order) { - if (order == TemporalRules.Relation.NONE) { - return make(statement, subj, pred); - } - if (order == TemporalRules.Relation.AFTER) { - if (statement instanceof Implication) { - return ImplicationAfter.make(subj, pred); - } - if (statement instanceof Equivalence) { - return EquivalenceAfter.make(subj, pred); - } - return null; - } - if (order == TemporalRules.Relation.WHEN) { - if (statement instanceof Implication) { - return ImplicationWhen.make(subj, pred); - } - if (statement instanceof Equivalence) { - return EquivalenceWhen.make(subj, pred); - } - return null; - } - if (order == TemporalRules.Relation.BEFORE) { - if (statement instanceof Implication) { - return ImplicationBefore.make(subj, pred); - } - if (statement instanceof Equivalence) { - return EquivalenceAfter.make(pred, subj); - } - return null; - } - return null; - } - - /** - * Make a symmetric Statement from given components and temporal information, called by the rules - * @param statement A sample asymmetric statement providing the class type - * @param subj The first component - * @param pred The second component - * @param order The temporal order of the statement - * @return The Statement built - */ - public static Statement makeSym(Statement statement, Term subj, Term pred, TemporalRules.Relation order) { - if (order == TemporalRules.Relation.NONE) { - if (statement instanceof Inheritance) { - return Similarity.make(subj, pred); - } - if (statement instanceof Implication) { - return Equivalence.make(subj, pred); - } - return null; - } - if (order == TemporalRules.Relation.AFTER) { - if (statement instanceof Implication) { - return EquivalenceAfter.make(subj, pred); - } - return null; - } - if (order == TemporalRules.Relation.WHEN) { - if (statement instanceof Implication) { - return EquivalenceWhen.make(subj, pred); - } - return null; - } - if (order == TemporalRules.Relation.BEFORE) { - if (statement instanceof Implication) { - return EquivalenceAfter.make(pred, subj); - } - return null; - } - return null; - } - - /** - * Check Statement relation symbol, called in StringPaser - * @param s0 The String to be checked - * @return if the given String is a relation symbol - */ - public static boolean isRelation(String s0) { - String s = s0.trim(); - if (s.length() != 3) { - return false; - } - return (s.equals(Symbols.INHERITANCE_RELATION) || - s.equals(Symbols.SIMILARITY_RELATION) || - s.equals(Symbols.INSTANCE_RELATION) || - s.equals(Symbols.PROPERTY_RELATION) || - s.equals(Symbols.INSTANCE_PROPERTY_RELATION) || - s.equals(Symbols.IMPLICATION_RELATION) || - s.equals(Symbols.EQUIVALENCE_RELATION) || - s.equals(Symbols.IMPLICATION_AFTER_RELATION) || - s.equals(Symbols.IMPLICATION_WHEN_RELATION) || - s.equals(Symbols.IMPLICATION_BEFORE_RELATION) || - s.equals(Symbols.EQUIVALENCE_WHEN_RELATION) || - s.equals(Symbols.EQUIVALENCE_AFTER_RELATION)); - } - - /** - * Override the default in making the name of the current term from existing fields - * @return the name of the term - */ - @Override - protected String makeName() { - return makeStatementName(getSubject(), operator(), getPredicate()); - } - - /** - * Default method to make the name of an image term from given fields - * @param subject The first component - * @param predicate The second component - * @param relation The relation operator - * @return The name of the term - */ - protected static String makeStatementName(Term subject, String relation, Term predicate) { - StringBuffer name = new StringBuffer(); - name.append(Symbols.STATEMENT_OPENER); - name.append(subject.getName()); - name.append(' ' + relation + ' '); - name.append(predicate.getName()); - name.append(Symbols.STATEMENT_CLOSER); - return name.toString(); - } - - /** - * Check the validity of a potential Statement. [To be refined] - *

- * Minimum requirement: the two terms cannot be the same, or containing each other as component - * @param subject The first component - * @param predicate The second component - * @return Whether The Statement is invalid - */ - public static boolean invalidStatement(Term subject, Term predicate) { - if (subject.equals(predicate)) { - return true; - } - if ((subject instanceof CompoundTerm) && ((CompoundTerm) subject).containComponent(predicate)) { - return true; - } - if ((predicate instanceof CompoundTerm) && ((CompoundTerm) predicate).containComponent(subject)) { - return true; - } - return false; - } - - /** - * Return the first component of the statement - * @return The first component - */ - public Term getSubject() { - return components.get(0); - } - - /** - * Return the second component of the statement - * @return The second component - */ - public Term getPredicate() { - return components.get(1); - } -} diff --git a/nars/language/Temporal.java b/nars/language/Temporal.java deleted file mode 100644 index 12f5dfe3..00000000 --- a/nars/language/Temporal.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Temporal.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ - -package nars.language; - -/** - * An interface for compound terms with temporal information in it - */ -public interface Temporal { - -} diff --git a/nars/language/Term.java b/nars/language/Term.java deleted file mode 100644 index 817632b1..00000000 --- a/nars/language/Term.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Term.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.language; - -import nars.inference.TemporalRules; - -/** - * Term is the basic component of Narsese, and the object of processing in NARS. - *

- * A Term may have an associated Concept containing relations with other Terms. It - * is not linked in the Term, because a Concept may be forgot, while the Term exists. - */ -public class Term implements Cloneable, Comparable { - - /** A Term is identified uniquely by its name, a sequence of characters in a - * given alphabet (ASCII or Unicode) - */ - protected String name; - - /** - * Default constructor - */ - protected Term() { - } - - /** - * Constructor with a given name - * @param name A String as the name of the Term - */ - public Term(String name) { - this.name = name; - } - - /** - * The same as getName, used in display. - * @return The name of the term as a String - */ - @Override - public final String toString() { - return name; - } - - /** - * Reporting the name of the current Term. - * @return The name of the term as a String - */ - public String getName() { - return name; - } - - /** - * Default, to be overrided in variable Terms. - * @return The name of the term as a String - */ - public String getConstantName() { - return name; - } - - /** - * Make a new Term with the same name. - * @return The new Term - */ - @Override - public Object clone() { - return new Term(name); - } - - /** - * Equal terms have identical name, though not necessarily the same reference. - * @return Whether the two Terms are equal - * @param that The Term to be compared with the current Term - */ - @Override - public boolean equals(Object that) { - return (that instanceof Term) && getName().equals(((Term) that).getName()); - } - - /** - * Produce a hash code for the term - * @return An integer hash code - */ - @Override - public int hashCode() { - int hash = 3; - return hash; - } - - /** - * The syntactic complexity, for constant automic Term, is 1. - * @return The conplexity of the term, an integer - */ - public int getComplexity() { - return 1; - } - - /** - * Check the relative order of two Terms. - *

- * based on the constant part first - * @param that The Term to be compared with the current Term - * @return The same as compareTo as defined on Strings when the constant parts are compared - */ - public final int compareTo(Term that) { - int i = this.getConstantName().compareTo(that.getConstantName()); - return (i != 0) ? i : this.getName().compareTo(that.getName()); - } - - /** - * Check whether the current Term can name a Concept. - * @return A Term is constant by default - */ - public boolean isConstant() { - return true; - } - - /** - * Get the temporal order in a term, which is NONE by default - * @return The default temporal order - */ - public TemporalRules.Relation getTemporalOrder() { - return TemporalRules.Relation.NONE; - } -} diff --git a/nars/language/Variable.java b/nars/language/Variable.java deleted file mode 100644 index 2ad41bab..00000000 --- a/nars/language/Variable.java +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Variable.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.language; - -import java.util.*; - -import nars.io.Symbols; - -/** - * A variable term, which does not correspond to a concept - */ -public class Variable extends Term { - - /** - * Four variable types plus a wild card - */ - public enum VarType { - - INDEPENDENT, DEPENDENT, ANONYMOUS, QUERY, ALL - } - /** Type of the variable */ - private VarType type; - /** The minimum CompoundTerm what contains all occurences of this variable */ - private CompoundTerm scope; - - /** - * Constructor, from a given variable name - * @param s A String read from input - */ - public Variable(String s) { - name = s; - scope = null; - char prefix = s.charAt(0); - if (prefix == Symbols.QUERY_VARIABLE_TAG) { - type = VarType.QUERY; - } else if (s.length() == 1) { - type = VarType.ANONYMOUS; - } else if (s.charAt(s.length() - 1) == Symbols.COMPOUND_TERM_CLOSER) { - type = VarType.DEPENDENT; - int i = s.indexOf(Symbols.COMPOUND_TERM_OPENER); - name = s.substring(0, i); // name does not include the dependency list - } else { - type = VarType.INDEPENDENT; - } - } - - /** - * Constructor, with all fields - * @param n Variable name - * @param s Variable scope - * @param t Variable type - */ - private Variable(String n, VarType t, CompoundTerm s) { - name = n; - type = t; - scope = s; - } - - /** - * Clone a Variable - * @return The cloned Variable - */ - @Override - public Object clone() { - return new Variable(name, type, scope); - } - - /** - * Variable name is omitted in sorting - * @return The Variable prefix - */ - @Override - public String getConstantName() { - return name.substring(0, 1); - } - - /** - * Rename a variable temporally to distinguish it from variables in other Terms - * @param first Whether it is the first term - * @return The new name - */ - public String getVarName(boolean first) { - if (first) { - return Symbols.VARIABLE_TAG + "1" + name; - } else { - return Symbols.VARIABLE_TAG + "2" + name; - } - } - - /** - * Rename the variable - * @param n The new name - */ - public void setName(String n) { - name = n; - } - - /** - * Get the type of the variable - * @return The variable type - */ - public VarType getType() { - return type; - } - - /** - * Set the scope of the variable - * @param t The new scope - */ - public void setScope (CompoundTerm t) { - scope = t; - } - - /** - * Whether this variable equals another one - * @param that The other variable - * @return Whether the two are equal - */ - @Override - public boolean equals(Object that) { - return (that instanceof Variable) && name.equals(((Variable) that).getStoredName()); - } - - /** - * Get a hash code for the variable - * @return The hash code - */ - @Override - public int hashCode() { - int hash = 7; - return hash; - } - - /** - * Get variable name without dependency list (if any) - * @return The stored name - */ - public String getStoredName() { - return name; - } - - /** - * Get variable name with dependency list (if any) - * @return The generated name - */ - @Override - public String getName() { - if (type != VarType.DEPENDENT) { - return name; - } else { - StringBuffer buffer = new StringBuffer(name + "("); - if (scope != null) { - ArrayList dependency = scope.getOpenVariables(); - if (dependency != null) { - for (Variable v : dependency) { - if (v.getType() == VarType.INDEPENDENT) { - buffer.append(v.toString()); - } - } - } - } - buffer.append(")"); - return buffer.toString(); - } - } - - /** - * A variable is constant - * @return false - */ - @Override - public boolean isConstant() { - return false; - } - - /** - * Whether two variable types can match each other in unification - * @param type1 Type of the first variable - * @param type2 Type of the second variable - * @return The matching result - */ - public static boolean match(VarType type1, VarType type2) { - return ((type1 == type2) - || (type1 == VarType.ALL) || (type1 == VarType.QUERY) || (type1 == VarType.ANONYMOUS) - || (type2 == VarType.ALL) || (type2 == VarType.QUERY) || (type2 == VarType.ANONYMOUS)); - } - - /** - * To unify two Terms, then apply the substitution to the two compounds - * @param type The type of Variable to be unified - * @param t1 The first Term to be unified - * @param t2 The second Term to be unified - * @param compound1 The first compound to be substituted - * @param compound2 The second compound to be substituted - * @return Whether a unification has been succeeded - */ - public static boolean unify(VarType type, Term t1, Term t2, Term compound1, Term compound2) { - if (t1.isConstant() && t1.equals(t2)) {// to constant Terms are unified if equals - return true; - } - if (!(compound1 instanceof CompoundTerm) || !(compound2 instanceof CompoundTerm)) { - return false; - } - HashMap substitute = findSubstitute(type, t1, t2, new HashMap()); // find substitution - if (substitute == null) // not unifiable - { - return false; - } - if (!substitute.isEmpty()) { - ((CompoundTerm) compound1).substituteComponent(substitute, true); // apply the substitution to the first compound - ((CompoundTerm) compound2).substituteComponent(substitute, false); // apply the substitution to the second compound - } - return true; - } - - /** - * To find a substitution that can unify two Terms without changing them - * @param type The type of Variable to be substituted - * @param term1 The first Term to be unified - * @param term2 The second Term to be unified - * @return The substitution that unifies the two Terms - */ - public static HashMap findSubstitute(VarType type, Term term1, Term term2) { - return findSubstitute(type, term1, term2, new HashMap()); - } - - /** - * To recursively find a substitution that can unify two Terms without changing them - * @param type The type of Variable to be substituted - * @param term1 The first Term to be unified - * @param term2 The second Term to be unified - * @param subs The substitution formed so far - * @return The substitution that unifies the two Terms - */ - private static HashMap findSubstitute(VarType type, Term term1, Term term2, HashMap subs) { - Term t1, t2; - if (term1.equals(term2)) {// for constant, also shortcut for variable and compound - return subs; - } - if ((term1 instanceof Variable) && match(((Variable) term1).getType(), type)) { // the first Term is a unifiable Variable - return findSubstituteVar(type, (Variable) term1, term2, subs, true); - } - if ((term2 instanceof Variable) && match(((Variable) term2).getType(), type)) { - return findSubstituteVar(type, (Variable) term2, term1, subs, false); - } - if ((term1 instanceof Variable) && (term2 instanceof Variable) && match(((Variable) term1).getType(), ((Variable) term2).getType())) { - return findSubstituteVar(((Variable) term1).getType(), (Variable) term1, term2, subs, true); - } - if (term1 instanceof CompoundTerm) { - if (!term1.getClass().equals(term2.getClass())) { - return null; - } - if (!(((CompoundTerm) term1).size() == ((CompoundTerm) term2).size())) { - return null; - } - for (int i = 0; i < ((CompoundTerm) term1).size(); i++) { - t1 = ((CompoundTerm) term1).componentAt(i); - t2 = ((CompoundTerm) term2).componentAt(i); - HashMap newSubs = findSubstitute(type, t1, t2, subs); - if (newSubs == null) { - return null; - } - subs.putAll(newSubs); - } - return subs; - } - return null; - } - - /** - * To find a substitution that can unify a Vriable and a Term - * @param type The type of Variable to be substituted - * @param var The Variable to be unified - * @param term The Term to be unified - * @param subs The substitution formed so far - * @param first If it is the first Term in unify - * @return The substitution that unifies the two Terms, as "name-term" pairs - */ - private static HashMap findSubstituteVar(VarType type, Variable var, Term term, HashMap subs, boolean first) { - String name1 = var.getVarName(first); - Term oldTerm = subs.get(name1); - if (oldTerm != null) { - if (first) { - return findSubstitute(type, oldTerm, term, subs); - } else { - return findSubstitute(type, term, oldTerm, subs); - } - } else { - if (term instanceof Variable) { - String name2 = ((Variable) term).getVarName(!first); - oldTerm = subs.get(name2); - if (oldTerm != null) { - if (first) { - return findSubstitute(type, var, oldTerm, subs); - } else { - return findSubstitute(type, oldTerm, var, subs); - } - } - } - subs.put(name1, term); - return subs; - } - } -} diff --git a/nars/main/Center.java b/nars/main/Center.java deleted file mode 100644 index 025ff650..00000000 --- a/nars/main/Center.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Center.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.main; - -import nars.io.*; -import nars.gui.MainWindow; -import nars.entity.Stamp; - -/** - * The control center of the system. - *

- * Create static main window and input channel, reset memory, and manage system clock. - */ -public class Center { - /** The unique main window */ - public static MainWindow mainWindow; - /** The unique input channel */ - public static ExperienceIO experienceIO; - /** System clock, relatively defined to guaranttee the repeatability of behaviors */ - private static long clock; - /** Timer for fixed distance walking */ - private static long stoper; - /** Flag for running continously */ - private static boolean running; - - /** - * Start the initial windows and memory. Called from NARS only. - */ - public static void start() { - mainWindow = new MainWindow(); - experienceIO = new ExperienceIO(); - reset(); - } - - /** - * Reset the system with an empty memory and reset clock. Called locally and from MainWindow. - */ - public static void reset() { - stoper = 0; - clock = 0; - running = false; - Stamp.init(); - Record.init(); - Memory.init(); - mainWindow.init(); - } - - /** - * Walk a fixed number of steps or continously. Called from MainWindow only. - * @param i The number of steps of inference, or infinite if negative - */ - public static void setStoper(long i) { - if (i < 0) { - running = true; - stoper = 0; - } else { - running = false; - stoper = i; - } - } - - /** - * A clock tick. Run one working cycle or read input. Called from NARS only. - */ - public static void tick() { - if (stoper == 0) { - stoper = experienceIO.loadLine(); - } - if (running || (stoper > 0)) { - clock++; - Record.append(" --- " + clock + " ---\n"); - mainWindow.tickTimer(); - Memory.cycle(); - if (stoper > 0) { - stoper--; - } - } - } -} diff --git a/nars/main/Memory.java b/nars/main/Memory.java deleted file mode 100644 index 135b1661..00000000 --- a/nars/main/Memory.java +++ /dev/null @@ -1,425 +0,0 @@ -/* - * Memory.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.main; - -import java.util.*; - -import nars.entity.*; -import nars.inference.*; -import nars.io.*; -import nars.language.*; -import nars.operation.Operator; -import nars.storage.*; - -/** - * The memory of the system. - */ -public class Memory { - - /* ---------- all members are static, with limited space ---------- */ - /** Concept bag. Containing all Concepts of the system */ - private static ConceptBag concepts; - /** Operators (built-in terms) table. Accessed by name */ - private static HashMap operators; - /* There is no global Term table, which may ask for unlimited space. */ - /** List of inference newTasks, to be processed in the next working cycle */ - private static ArrayList newTasks; - /** New tasks with novel composed terms, for delayed and selective processing */ - private static TaskBuffer novelTaskBuffer; - /** List of recent events, for temporal learning */ - public static ArrayList recentEvents; - /* ---------- global variables used to reduce method arguments ---------- */ - /** Shortcut to the selected Term */ - public static Term currentTerm; - /** Shortcut to the selected TaskLink */ - public static TaskLink currentTaskLink; - /** Shortcut to the selected Task */ - public static Task currentTask; - /** Shortcut to the selected TermLink */ - public static TermLink currentBeliefLink; - /** Shortcut to the selected belief */ - public static Judgment currentBelief; - /** Shortcut to the derived Stamp */ - public static Stamp currentStamp; - /** Shortcut to the derived tense */ - public static TemporalRules.Relation currentTense; - - /* ---------- initialization ---------- */ - /** - * Initialize a new memory by creating all members. - *

- * Called in Center.reset only - */ - public static void init() { - concepts = new ConceptBag(); // initially empty, with capacity limit - operators = Operator.setOperators(); // with operators created, then remain constant - newTasks = new ArrayList(); // initially empty, without capacity limit - novelTaskBuffer = new TaskBuffer(); // initially empty, with capacity limit - recentEvents = new ArrayList(Parameters.MAXMUM_EVENTS_LENGTH); // initially empty, with capacity limit - } - - /* ---------- access utilities ---------- */ - /** - * Get a Term for a given name of a Concept or Operator - *

- * called in StringParser and the make methods of compound terms. - * @param name the name of a concept or operator - * @return a Term or null (if no Concept/Operator has this name) - */ - public static Term nameToListedTerm(String name) { - Concept concept = concepts.get(name); - if (concept != null) { - return concept.getTerm(); - } - return operators.get(name); - } - - /** - * Check if a string is an operator name - *

- * called in StringParser only. - * @param name the name of a possible operator - * @return the corresponding operator or null - */ - public static Operator nameToOperator(String name) { - return operators.get(name); - } - - /** - * Get an existing Concept for a given name - *

- * called from Term and ConceptWindow. - * @param name the name of a concept - * @return a Concept or null - */ - public static Concept nameToConcept(String name) { - return concepts.get(name); - } - - /** - * Get an existing Concept for a given Term. - * @param term The Term naming a concept - * @return a Concept or null - */ - public static Concept termToConcept(Term term) { - return nameToConcept(term.getName()); - } - - /** - * Get the Concept associated to a Term, or create it. - * @param term indicating the concept - * @return an existing Concept, or a new one - */ - public static Concept getConcept(Term term) { - String n = term.getName(); - Concept concept = concepts.get(n); - if (concept == null) { - concept = new Concept(term); // the only place to make a new Concept - concepts.putIn(concept); - } - return concept; - } - - /** - * Adjust the activation level of a Concept - *

- * called in Concept.insertTaskLink only - * @param c the concept to be adusted - * @param b the new BudgetValue - */ - public static void activateConcept(Concept c, BudgetValue b) { - concepts.pickOut(c.getKey()); - BudgetFunctions.activate(c, b); - concepts.putBack(c); - } - - /** - * Check if there is already any derived Task in the current cycle - *

- * called in Concept.fire only - * @return Whether in the current cycle there is already derived Task - */ - public static boolean noResult() { - return (newTasks.size() == 0); - } - - /* ---------- new task entries ---------- */ - /* There are several types of new tasks, all added into the - newTasks list, to be processed in the next cycle. - Some of them are reported and/or logged. */ - /** - * Input task processing. - * @param task the input task - */ - public static void inputTask(Task task) { - Record.append("!!! Input: " + task + "\n"); - if (task.aboveThreshold()) { - report(task.getSentence(), true); // report input - newTasks.add(task); // wait to be processed in the next cycle - novelTaskBuffer.refresh(); // refresh display - } else { - Record.append("!!! Ignored: " + task + "\n"); - } - } - - /** - * Derived task comes from the inference rules. - * @param task the derived task - */ - private static void derivedTask(Task task) { - Record.append("!!! Derived: " + task + "\n"); - if (task.aboveThreshold()) { - float budget = task.getBudget().summary(); - @SuppressWarnings("static-access") - float minSilent = Center.mainWindow.silentW.value() / 100.0f; - if (budget > minSilent) { // only report significient derived Tasks - report(task.getSentence(), false); - } - newTasks.add(task); - novelTaskBuffer.refresh(); - } else { - Record.append("!!! Ignored: " + task + "\n"); - } - } - - /** - * Reporting executed task, and remember the event - *

- * called from Operator.call only - * @param task the executed task - */ - public static void executedTask(Task task) { - Record.append("!!! Executed: " + task.getSentence() + "\n"); - Goal g = (Goal) task.getSentence(); - Judgment j = new Judgment(g); - Task newTask = new Task(j, task.getBudget()); - report(newTask.getSentence(), false); - newTasks.add(newTask); - novelTaskBuffer.refresh(); - } - - /** - * Activated task coming from MatchingRules.trySolution - * @param budget The budget value of the new Task - * @param sentence The content of the new Task - * @param isInput Whether the question is input - */ - public static void activatedTask(BudgetValue budget, Sentence sentence, boolean isInput) { - Task task = new Task(sentence, budget); - Record.append("!!! Activated: " + task.toString() + "\n"); - newTasks.add(task); - novelTaskBuffer.refresh(); - } - - /* --------------- new task building --------------- */ - /** - * Shared final operations by all double-premise rules, called from the rules except StructuralRules - * @param budget The budget value of the new task - * @param content The content of the new task - * @param truth The truth value of the new task - */ - public static void doublePremiseTask(BudgetValue budget, Term content, TruthValue truth) { - if (content != null) { - Sentence newSentence = Sentence.make(currentTask.getSentence(), content, currentTense, truth, currentStamp); - Task newTask = new Task(newSentence, budget); - derivedTask(newTask); - } - } - - /** - * Shared final operations by all single-premise rules, called in StructuralRules - * @param budget The budget value of the new task - * @param content The content of the new task - * @param truth The truth value of the new task - */ - public static void singlePremiseTask(BudgetValue budget, Term content, TruthValue truth) { - Sentence sentence = currentTask.getSentence(); - Sentence newSentence = Sentence.make(sentence, content, sentence.getTense(), truth, sentence.getStamp()); - Task newTask = new Task(newSentence, budget); - newTask.setStructual(); - derivedTask(newTask); - } - - /** - * Convert jusgment into different relation - *

- * called in MatchingRules - * @param budget The budget value of the new task - * @param truth The truth value of the new task - */ - public static void convertedJudgment(TruthValue truth, BudgetValue budget) { - Term content = Memory.currentTask.getContent(); - TemporalRules.Relation tense = Memory.currentBelief.getTense(); - Stamp stamp = Memory.currentBelief.getStamp(); - Sentence newJudgment = Sentence.make(content, Symbols.JUDGMENT_MARK, tense, truth, stamp); - Task newTask = new Task(newJudgment, budget); - newTask.setStructual(); - derivedTask(newTask); - } - - /* ---------- system working cycle ---------- */ - /** - * An atomic working cycle of the system: process new Tasks, then fire a concept - *

- * Called from Center.tick only - */ - public static void cycle() { - // keep the following order - processTask(); - processConcept(); - } - - /** - * Process the newTasks accumulated in the previous cycle, accept input ones - * and those that corresponding to existing concepts, plus one from the buffer. - */ - private static void processTask() { - Task task; - int counter = newTasks.size(); // don't include new tasks produced in the current cycle - while (counter-- > 0) { - task = newTasks.remove(0); - if (task.getSentence().isInput() || (termToConcept(task.getContent()) != null)) { // new input or existing concept - immediateProcess(task); - } else { - novelTaskBuffer.putIn(task); // delayed processing - } - } - task = novelTaskBuffer.takeOut(); // select a task from novelTaskBuffer - if (task != null) { - immediateProcess(task); - } - } - - /** - * Select a concept to fire. - */ - private static void processConcept() { - Concept currentConcept = concepts.takeOut(); - if (currentConcept != null) { - currentTerm = currentConcept.getTerm(); - Record.append(" * Selected Concept: " + currentTerm + "\n"); - concepts.putBack(currentConcept); // current Concept remains in the bag all the time - currentConcept.fire(); // a working cycle - novelTaskBuffer.refresh(); // show new result - } - } - - /* ---------- task processing ---------- */ - /** - * Imediate processing of a new task, in constant time - * Local processing, in one concept only - * @param task the task to be accepted - */ - private static void immediateProcess(Task task) { - currentTask = task; - Record.append("!!! Insert: " + task + "\n"); - Term content = task.getContent(); - Concept c = getConcept(content); - c.directProcess(task); - if (task.aboveThreshold()) { // still need to be processed - continuedProcess(task, content); - } - } - - /** - * Link to a new task from all relevant concepts for continued processing in - * the near future for unspecified time. - *

- * The only method that calls the TaskLink constructor. - * @param task The task to be linked - * @param content The content of the task - */ - private static void continuedProcess(Task task, Term content) { - TaskLink taskLink; - Concept contentConcept = getConcept(content); - BudgetValue budget = task.getBudget(); - taskLink = new TaskLink(task, null, budget); // link type: SELF - contentConcept.insertTaskLink(taskLink); - if (content instanceof CompoundTerm) { - ArrayList termLinks = (contentConcept != null) ? contentConcept.getTermLinkTemplates() - : ((CompoundTerm) content).prepareComponentLinks(); // use saved if exist - BudgetValue subBudget = BudgetFunctions.distributeAmongLinks(budget, termLinks.size()); - if (subBudget.aboveThreshold()) { - Term componentTerm; - Concept componentConcept; - for (TermLink termLink : termLinks) { - if (!(task.isStructual() && (termLink.getType() == TermLink.TRANSFORM))) { // avoid circular transform - taskLink = new TaskLink(task, termLink, subBudget); - componentTerm = termLink.getTarget(); - componentConcept = getConcept(componentTerm); - componentConcept.insertTaskLink(taskLink); - } - } - contentConcept.buildTermLinks(budget); // recursively insert TermLink - } - } - } - - /* ---------- display ---------- */ - /** - * Display active concepts, called from MainWindow. - * @param s the window title - */ - public static void conceptsStartPlay(String s) { - concepts.startPlay(s); - } - - /** - * Display newd tasks, called from MainWindow. - * @param s the window title - */ - public static void newTasksStartPlay(String s) { - novelTaskBuffer.startPlay(s); - } - - /** - * Prepare buffered tasks for display, called from TaskBuffer. - * @return the tasks as a String - */ - public static String newTasksToString() { - String s = " New Tasks: \n"; - for (int i = 0; i < newTasks.size(); i++) { - s += newTasks.get(i) + "\n"; - } - s += "\n Recent Events:: \n"; - for (int i = 0; i < recentEvents.size(); i++) { - s += recentEvents.get(i) + "\n"; - } - s += "\n Task Buffer: \n"; - return s; - } - - /** - * Display input/output sentence in the MainWindow. - * @param sentence the sentence to be displayed - * @param input whether the task is input - */ - public static void report(Sentence sentence, boolean input) { - String s; - if (input) { - s = " IN: "; - } else { - s = " OUT: "; - } - s += sentence.toString2() + "\n"; - Center.mainWindow.post(s); - } -} diff --git a/nars/main/NARS.java b/nars/main/NARS.java deleted file mode 100644 index 231f596e..00000000 --- a/nars/main/NARS.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * NARS.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.main; - -import java.applet.*; - -/** - * The main class of the project. - *

- * Define an application with full funcationality and an applet with partial functionality. - *

- * Manage the internal working thread. Communicate with Center only. - */ -public class NARS extends Applet implements Runnable { - /** - * The information about the version and date of the project. - */ - public static final String INFO = - " Open-NARS Version 1.1.0 July 2008 \n"; - /** - * The project websites. - */ - public static final String WEBSITE = - " Open-NARS website: http://code.google.com/p/open-nars/ \n" + - " NARS website: http://nars.wang.googlepages.com/ "; - /** - * Flag to distinguish the two running modes of the project. - */ - private static boolean standAlone = false; // application or applet - /** - * The internal working thread of the system. - */ - Thread narsThread = null; - - /** - * The entry point of the standalone application. - *

- * Create an instance of the class, then run the init and start methods. - * @param args no arguments are used - */ - public static void main(String args[]) { - standAlone = true; - NARS nars = new NARS(); - nars.init(); - nars.start(); - } - - /** - * Initialize the system at the control center. - */ - @Override - public void init() { - Center.start(); - } - - /** - * Start the thread if necessary, called when the page containing the applet first appears on the screen. - */ - @Override - public void start() { - if (narsThread == null) { - narsThread = new Thread(this); - narsThread.start(); - } - } - - /** - * Called when the page containing the applet is no longer on the screen. - */ - @Override - public void stop() { - narsThread = null; - } - - /** - * Repeatedly execute NARS working cycle. This method is called when the Runnable's thread is started. - */ - public void run() { - Thread thisThread = Thread.currentThread(); - while (narsThread == thisThread) { - try { - Thread.sleep(10); - } catch (InterruptedException e){ - } - Center.tick(); - } - } - - /** - * Whether the project running as an application. - * @return true for application; false for applet. - */ - public static boolean isStandAlone() { - return standAlone; - } - - /** - * Provide system information for the applet. - * @return The string containing the information about the applet. - */ - @Override - public String getAppletInfo() { - return INFO; - } -} \ No newline at end of file diff --git a/nars/main/Parameters.java b/nars/main/Parameters.java deleted file mode 100644 index 9fe4fd63..00000000 --- a/nars/main/Parameters.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Parameters.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.main; - -/** - * Collected system parameters. To be modified before compiling. - */ -public class Parameters { - - /* ---------- initial values of run-time adjustable parameters ---------- */ - /** Concept decay rate in ConceptBag, in [1, 99]. */ - public static final int CONCEPT_FORGETTING_CYCLE = 3; - /** TaskLink decay rate in TaskLinkBag, in [1, 99]. */ - public static final int TASK_LINK_FORGETTING_CYCLE = 10; - /** TermLink decay rate in TermLinkBag, in [1, 99]. */ - public static final int TERM_LINK_FORGETTING_CYCLE = 50; - /** Silent threshold for task reporting, in [0, 100]. */ - public static final int SILENT_LEVEL = 10; - - /* ---------- time management ---------- */ - /** Task decay rate in TaskBuffer, in [1, 99]. */ - public static final int NEW_TASK_FORGETTING_CYCLE = 1; - /** Maximum TermLinks checked for novelity for each TaskLink in TermLinkBag */ - public static final int MAX_MATCHED_TERM_LINK = 10; - /** Maximum TermLinks used in reasoning for each Task in Concept */ - public static final int MAX_REASONED_TERM_LINK = 3; - - /* ---------- logical parameters ---------- */ - /** Horizon, the amount of evidence coming in the near future. */ - public static final int NEAR_FUTURE = 1; // or 2, can be float - /** The desireability threthold for an operation to be executed. */ - public static final float DECISION_THRESHOLD = (float) 0.66; - /** Range of temporal induction in input events. */ - public static final int MAXMUM_EVENTS_LENGTH = 10; - - /* ---------- budget thresholds ---------- */ - /** The budget threthold for task to be accepted. */ - public static final float BUDGET_THRESHOLD = (float) 0.001; - /** The priority threthold for operation to be executed. */ - public static final float PRIORITY_THRESHOLD = (float) 0.06; - - /* ---------- default input values ---------- */ - /** Default confidence of input judgment. */ - public static final float DEFAULT_JUDGMENT_CONFIDENCE = (float) 0.9; - /** Default priority of input judgment */ - public static final float DEFAULT_JUDGMENT_PRIORITY = (float) 0.8; - /** Default durability of input judgment */ - public static final float DEFAULT_JUDGMENT_DURABILITY = (float) 0.8; - /** Default priority of input goal */ - public static final float DEFAULT_GOAL_PRIORITY = (float) 0.9; - /** Default durability of input goal */ - public static final float DEFAULT_GOAL_DURABILITY = (float) 0.7; - /** Default priority of input question */ - public static final float DEFAULT_QUESTION_PRIORITY = (float) 0.9; - /** Default durability of input question */ - public static final float DEFAULT_QUESTION_DURABILITY = (float) 0.7; - - /* ---------- space management ---------- */ - /** Level granularity in Bag, two digits */ - public static final int BAG_LEVEL = 100; - /** Level separation in Bag, one digit, for display (run-time adjustable) and management (fixed) */ - public static final int BAG_THRESHOLD = 10; - /** Hashtable load factor in Bag */ - public static final float LOAD_FACTOR = (float) 0.5; - /** Size of ConceptBag */ - public static final int CONCEPT_BAG_SIZE = 1000; - /** Size of TaskLinkBag */ - public static final int TASK_LINK_BAG_SIZE = 20; - /** Size of TermLinkBag */ - public static final int TERM_LINK_BAG_SIZE = 100; - /** Size of TaskBuffer */ - public static final int TASK_BUFFER_SIZE = 20; - - /* ---------- avoiding repeated reasoning ---------- */ - /** Maximum length of Stamp, a power of 2 */ - public static final int MAXMUM_STAMP_LENGTH = 16; - /** Remember recently used TermLink on a Task */ - public static final int TERM_LINK_RECORD_LENGTH = 10; - /** Maximum number of beliefs kept in a Concept */ - public static final int MAXMUM_BELIEF_LENGTH = 8; - /** Maximum number of goals kept in a Concept */ - public static final int MAXMUM_GOALS_LENGTH = 5; -} diff --git a/nars/main/package.html b/nars/main/package.html deleted file mode 100644 index c7e64102..00000000 --- a/nars/main/package.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - -Top-level classes of the system - -

Package Specification

- -This package contains the top classes of the system. -

-NARS: defines the application and applet. -

-Parameters: collects all system parameters, which can be edited before compiling. -

-Center: controls the running of the whole system. -

-Memory: maintains the work space of the system, including static objects that -can be directly accessed from anywhere of the system: -

    -
  • a bag of concept,
  • -
  • a look-up table of all built-in operators,
  • -
  • buffers for new tasks.
  • -
- - - diff --git a/nars/operation/Break.java b/nars/operation/Break.java deleted file mode 100644 index 9d748b21..00000000 --- a/nars/operation/Break.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Break.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ - -package nars.operation; - -import java.io.*; -import java.util.ArrayList; -import nars.entity.Task; - -/** - * A class used in testing only. - */ -public class Break extends Operator { - public Break(String name) { - super(name); - } - - public ArrayList execute(Task task) { - return null; - } -} diff --git a/nars/operation/GoTo.java b/nars/operation/GoTo.java deleted file mode 100644 index 2011a0e0..00000000 --- a/nars/operation/GoTo.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * GoTo.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ - -package nars.operation; - -import java.io.*; -import java.util.ArrayList; -import nars.entity.Task; - -/** - * A class used in testing only. - */ -public class GoTo extends Operator { - public GoTo(String name) { - super(name); - } - - public ArrayList execute(Task task) { -// System.out.println("EXECUTE in " + name + " " + task.getSentence()); - return null; - } -} - diff --git a/nars/operation/Open.java b/nars/operation/Open.java deleted file mode 100644 index 5a223e52..00000000 --- a/nars/operation/Open.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Open.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ - -package nars.operation; - -import java.io.*; -import java.util.ArrayList; -import nars.entity.Task; - -/** - * A class used in testing only. - */ -public class Open extends Operator { - public Open(String name) { - super(name); - } - - public ArrayList execute(Task task) { -// System.out.println("EXECUTE in " + name + " " + task); - return null; - } -} - - diff --git a/nars/operation/Operator.java b/nars/operation/Operator.java deleted file mode 100644 index 556295e0..00000000 --- a/nars/operation/Operator.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Operator.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ - -package nars.operation; - -import java.util.*; - -import nars.language.*; -import nars.entity.Task; -import nars.main.Memory; - -/** - * An individual operator that can be execute by the system, though implemented - * outside NARS. - *

- * This is the only file to modify when adding a new operator into NARS. - */ -public abstract class Operator extends Term { - public Operator(String name) { - super(name); - } - - /** - * Required method for every operation, specifying the operation - * @param task The task with the arguments to be passed to the operator - * @return The direct collectable results and feedback of the execution - */ - public abstract ArrayList execute(Task task); - - /** - * Execute an operation, then handle feedback - * @param task The task to be executed - */ - public void call(Task task) { - ArrayList feedback = execute(task); - showExecution((Statement) task.getContent()); - Memory.executedTask(task); - if (feedback != null) { - for (Task t : feedback) { - Memory.inputTask(t); - } - } - } - - /** - * Register all built-in operators in the Memory - *

- * The only method to modify when adding a new operator into NARS. - * An operator name should contain at least two characters after '^'. - * @return A Map between Operator name and object - */ - public static HashMap setOperators() { - HashMap table = new HashMap(); - table.put("^go-to", new GoTo("^go-to")); - table.put("^pick", new Pick("^pick")); - table.put("^open", new Open("^open")); - table.put("^break", new Break("^break")); - return table; - } - - /** - * Display a message in the output stream to indicate the execution of an operation - * @param operation The content of the operation to be executed - */ - private void showExecution(Statement operation) { - Term operator = operation.getPredicate(); - Term arguments = operation.getSubject(); - String argList = arguments.toString().substring(3); // skip the product prefix "(*," - System.out.println("EXECUTE: " + operator + "(" + argList); - } -} - diff --git a/nars/operation/Pick.java b/nars/operation/Pick.java deleted file mode 100644 index d7b7130d..00000000 --- a/nars/operation/Pick.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Pick.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ - -package nars.operation; - -import java.io.*; -import java.util.ArrayList; -import nars.entity.Task; - -/** - * A class used in testing only. - */ -public class Pick extends Operator { - public Pick(String name) { - super(name); - } - - public ArrayList execute(Task task) { -// System.out.println("EXECUTE in " + name + " " + task); - return null; - } -} diff --git a/nars/operation/package.html b/nars/operation/package.html deleted file mode 100644 index 118f23ab..00000000 --- a/nars/operation/package.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - -Built-in operators - -

Package Specification

- -The built-in operator classes are all subclasses of Operator, which -extends Term. -

-All operators are also registered in Operator. -

-Each built-in operator must implement a method execute, which takes a -Task as argument, and returns an ArrayList of Task as direct results and feedback. - - - diff --git a/nars/storage/Bag.java b/nars/storage/Bag.java deleted file mode 100644 index 4afae025..00000000 --- a/nars/storage/Bag.java +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Bag.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.storage; - -import java.util.*; - -import nars.entity.Item; -import nars.gui.BagWindow; -import nars.inference.BudgetFunctions; -import nars.main.Parameters; - -/** - * A Bag is a storage with a constant capacity and maintains an internal priority - * distribution for retrieval. - *

- * Each entity in a bag must extend Item, which has a BudgetValue and a key. - *

- * A name table is used to merge duplicate items that have the same key. - *

- * The bag space is divided by a threshold, above which is mainly time management, - * and below, space mamagement. - * Differences: (1) level selection vs. item selection, (2) decay rate - * @param Type The type of the Item in the Bag - */ -public abstract class Bag { - - /** priority levels */ - protected static final int TOTAL_LEVEL = Parameters.BAG_LEVEL; - /** firing threshold */ - protected static final int THRESHOLD = Parameters.BAG_THRESHOLD; - /** relative threshold, only calculate once */ - protected static final float RELATIVE_THRESHOLD = (float) THRESHOLD / (float) TOTAL_LEVEL; - /** hashtable load factor */ - protected static final float LOAD_FACTOR = Parameters.LOAD_FACTOR; // - /** shared distributor that produce the probability distribution */ - static final Distributor DISTRIBUTOR = new Distributor(TOTAL_LEVEL); // - /** mapping from key to item */ - protected HashMap nameTable; - /** array of lists of items, for items on different level */ - protected ArrayList itemTable[]; - /** defined in different bags */ - protected int capacity; - /** current sum of occupied level */ - protected int mass; - /** index to get next level, kept in individual objects */ - protected int levelIndex; - /** current take out level */ - protected int currentLevel; - /** maximum number of items to be taken out at current level */ - protected int currentCounter; - /** whether this bag has an active window */ - protected boolean showing; - /** display window */ - protected BagWindow window; - - /** - * constructor, called from subclasses - */ - @SuppressWarnings("unchecked") - protected Bag() { - capacity = capacity(); - levelIndex = capacity % TOTAL_LEVEL; // so that different bags start at different point - currentLevel = TOTAL_LEVEL - 1; - itemTable = new ArrayList[TOTAL_LEVEL]; - nameTable = new HashMap((int) (capacity / LOAD_FACTOR), LOAD_FACTOR); - showing = false; - } - - /** - * To get the capacity of the concrete subclass - * @return Bag capacity, in number of Items allowed - */ - protected abstract int capacity(); - - /** - * Get the item decay rate, which differs in difference subclass, and can be - * changed in run time by the user, so not a constant. - * @return The number of times for a decay factor to be fully applied - */ - protected abstract int forgetRate(); - - /** - * Get the average priority of Items - * @return The average priority of Items in the bag - */ - public float averagePriority() { - if (nameTable.size() == 0) { - return 0.01f; - } - float f = (float) mass / (nameTable.size() * TOTAL_LEVEL); - if (f > 1) { - return 1.0f; - } - return f; - } - - /** - * Check if an item is in the bag - * @param it An item - * @return Whether the Item is in the Bag - */ - public boolean contains(Type it) { - return nameTable.containsValue(it); - } - - /** - * Get an Item by key - * @param key The key of the Item - * @return The Item with the given key - */ - public Type get(String key) { - return nameTable.get(key); - } - - /** - * Add a new Item into the Bag - * @param newItem The new Item - */ - public void putIn(Type newItem) { - String newKey = newItem.getKey(); - Type oldItem = nameTable.put(newKey, newItem); - if (oldItem != null) { // merge duplications - outOfBase(oldItem); - newItem.merge(oldItem); - } - Type overflowItem = intoBase(newItem); // put the (new or merged) item into itemTable - if (overflowItem != null) { // remove overflow - String overflowKey = overflowItem.getKey(); - nameTable.remove(overflowKey); - } - } - - /** - * Put an item back into the itemTable - *

- * The only place where the forgetting rate is applied - * @param oldItem The Item to put back - */ - public void putBack(Type oldItem) { - BudgetFunctions.forget(oldItem.getBudget(), forgetRate(), RELATIVE_THRESHOLD); - putIn(oldItem); - } - - /** - * Choose an Item according to priority distribution and take it out of the Bag - * @return The selected Item - */ - public Type takeOut() { - if (mass == 0) { // empty bag - return null; - } - if (emptyLevel(currentLevel) || (currentCounter == 0)) { // done with the current level - currentLevel = DISTRIBUTOR.pick(levelIndex); - levelIndex = DISTRIBUTOR.next(levelIndex); - while (emptyLevel(currentLevel)) { // look for a non-empty level - currentLevel = DISTRIBUTOR.pick(levelIndex); - levelIndex = DISTRIBUTOR.next(levelIndex); - } - if (currentLevel < THRESHOLD) { // for dormant levels, take one item - currentCounter = 1; - } else { // for active levels, take all current items - currentCounter = itemTable[currentLevel].size(); - } - } - Type selected = takeOutFirst(currentLevel); // take out the first item in the level - currentCounter--; - nameTable.remove(selected.getKey()); - refresh(); - return selected; - } - - /** - * Pick an item by key, then remove it from the bag - * @param key The given key - * @return The Item with the key - */ - public Type pickOut(String key) { - Type picked = nameTable.get(key); - if (picked != null) { - outOfBase(picked); - nameTable.remove(key); - } - return picked; - } - - /** - * Check whether a level is empty - * @param n The level index - * @return Whether that level is empty - */ - private boolean emptyLevel(int n) { - return ((itemTable[n] == null) || itemTable[n].isEmpty()); - } - - /** - * Decide the put-in level according to priority - * @param item The Item to put in - * @return The put-in level - */ - private int getLevel(Type item) { - float fl = item.getPriority() * TOTAL_LEVEL; - int level = (int) Math.ceil(fl) - 1; - return (level < 0) ? 0 : level; // cannot be -1 - } - - /** - * Insert an item into the itemTable, and return the overflow - * @param newItem The Item to put in - * @return The overflow Item - */ - @SuppressWarnings("unchecked") - private Type intoBase(Type newItem) { - Type oldItem = null; - int inLevel = getLevel(newItem); - if (nameTable.size() > capacity) { // the bag is full - int outLevel = 0; - while (emptyLevel(outLevel)) { - outLevel++; - } - if (outLevel > inLevel) { // ignore the item and exit - return newItem; - } else { // remove an old item in the lowest non-empty level - oldItem = takeOutFirst(outLevel); - } - } - if (itemTable[inLevel] == null) { // first time insert - itemTable[inLevel] = new ArrayList(); - } - itemTable[inLevel].add(newItem); // FIFO - mass += (inLevel + 1); // increase total mass - refresh(); // refresh the wondow - return oldItem; - } - - /** - * Take out the first or last Type in a level from the itemTable - * @param level The current level - * @return The first Item - */ - private Type takeOutFirst(int level) { - Type selected = itemTable[level].get(0); - itemTable[level].remove(0); - mass -= (level + 1); - refresh(); - return selected; - } - - /** - * Remove an item from itemTable, then adjust mass - * @param oldItem The Item to be removed - */ - protected void outOfBase(Type oldItem) { - int level = getLevel(oldItem); - itemTable[level].remove(oldItem); - mass -= (level + 1); - refresh(); - } - - /** - * To start displaying the Bag in a BagWindow - * @param title The title of the window - */ - public void startPlay(String title) { - window = new BagWindow(this, title); - showing = true; - window.post(toString()); - } - - /** - * Resume display - */ - public void play() { - showing = true; - window.post(toString()); - } - - /** - * Refresh display - */ - public void refresh() { - if (showing) { - window.post(toString()); - } - } - - /** - * Stop display - */ - public void stop() { - showing = false; - } - - /** - * Collect Bag content into a String for display - */ - @Override - public String toString() { - StringBuffer buf = new StringBuffer(" "); - for (int i = TOTAL_LEVEL; i >= window.showLevel(); i--) { - if (!emptyLevel(i - 1)) { - buf = buf.append("\n --- Level " + String.valueOf(i) + ":\n "); - for (int j = 0; j < itemTable[i - 1].size(); j++) { - buf = buf.append(itemTable[i - 1].get(j) + "\n "); - } - } - } - return buf.toString(); - } -} diff --git a/nars/storage/ConceptBag.java b/nars/storage/ConceptBag.java deleted file mode 100644 index 381b03e0..00000000 --- a/nars/storage/ConceptBag.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * ConceptBag.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ - -package nars.storage; - -import nars.entity.Concept; -import nars.main.Parameters; -import nars.gui.MainWindow; - -/** - * Contains Concepts. - */ -public class ConceptBag extends Bag { - - /** - * Get the (constant) capacity of ConceptBag - * @return The capacity of ConceptBag - */ - protected int capacity() { - return Parameters.CONCEPT_BAG_SIZE; - } - - /** - * Get the (adjustable) forget rate of ConceptBag - * @return The forget rate of ConceptBag - */ - protected int forgetRate() { - return MainWindow.forgetCW.value(); - } -} \ No newline at end of file diff --git a/nars/storage/TaskBuffer.java b/nars/storage/TaskBuffer.java deleted file mode 100644 index bf898369..00000000 --- a/nars/storage/TaskBuffer.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * TaskBuffer.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ - -package nars.storage; - -import nars.entity.Task; -import nars.main.*; - -/** - * New tasks that contain new Term. - */ -public class TaskBuffer extends Bag { - - /** - * Get the (constant) capacity of TaskBuffer - * @return The capacity of TaskBuffer - */ - protected int capacity() { - return Parameters.TASK_BUFFER_SIZE; - } - - /** - * Get the (constant) forget rate in TaskBuffer - * @return The forget rate in TaskBuffer - */ - protected int forgetRate() { - return Parameters.NEW_TASK_FORGETTING_CYCLE; - } - - /** - * Sepecial treatment: the display also include Tasks in the NewTask list - * @return New Tasks in the buffer and list for display - */ - @Override - public String toString() { - return Memory.newTasksToString() + super.toString(); - } -} - diff --git a/nars/storage/TaskLinkBag.java b/nars/storage/TaskLinkBag.java deleted file mode 100644 index e69fdf1a..00000000 --- a/nars/storage/TaskLinkBag.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * TaskLinkBag.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ - -package nars.storage; - -import nars.entity.TaskLink; -import nars.gui.MainWindow; -import nars.main.Parameters; - -/** - * TaskLinkBag contains links to tasks. - */ -public class TaskLinkBag extends Bag { - - /** - * Get the (constant) capacity of TaskLinkBag - * @return The capacity of TaskLinkBag - */ - protected int capacity() { - return Parameters.TASK_LINK_BAG_SIZE; - } - - /** - * Get the (adjustable) forget rate of TaskLinkBag - * @return The forget rate of TaskLinkBag - */ - protected int forgetRate() { - return MainWindow.forgetTW.value(); - } -} - diff --git a/nars/storage/TermLinkBag.java b/nars/storage/TermLinkBag.java deleted file mode 100644 index 5202a6af..00000000 --- a/nars/storage/TermLinkBag.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * TermLinkBag.java - * - * Copyright (C) 2008 Pei Wang - * - * This file is part of Open-NARS. - * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . - */ -package nars.storage; - -import nars.entity.*; -import nars.gui.MainWindow; -import nars.main.Parameters; - -/** - * Contains TermLinks to relevant (compound or component) Terms. - */ -public class TermLinkBag extends Bag { - /** - * Get the (constant) capacity of TermLinkBag - * @return The capacity of TermLinkBag - */ - protected int capacity() { - return Parameters.TERM_LINK_BAG_SIZE; - } - - /** - * Get the (adjustable) forget rate of TermLinkBag - * @return The forget rate of TermLinkBag - */ - protected int forgetRate() { - return MainWindow.forgetBW.value(); - } - - /** - * Replace defualt to prevent repeated inference, by checking TaskLink - * @param taskLink The selected TaskLink - * @return The selected TermLink - */ - public TermLink takeOut(TaskLink taskLink) { - for (int i = 0; i < Parameters.MAX_MATCHED_TERM_LINK; i++) { - TermLink termLink = takeOut(); - if (termLink == null) { - return null; - } - if (taskLink.novel(termLink)) { - return termLink; - } - putBack(termLink); - } - return null; - } -} - diff --git a/nars/entity/BudgetValue.java b/nars_core_java/nars/entity/BudgetValue.java old mode 100644 new mode 100755 similarity index 74% rename from nars/entity/BudgetValue.java rename to nars_core_java/nars/entity/BudgetValue.java index b6bbc89c..2873c3b9 --- a/nars/entity/BudgetValue.java +++ b/nars_core_java/nars/entity/BudgetValue.java @@ -1,41 +1,49 @@ -/* - * BudgetValue.java +/* + * The MIT License * - * Copyright (C) 2008 Pei Wang + * Copyright 2019 The OpenNARS authors. * - * This file is part of Open-NARS. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ package nars.entity; import nars.inference.*; import nars.io.Symbols; -import nars.main.Parameters; +import nars.main_nogui.Parameters; /** * A triple of priority (current), durability (decay), and quality (long-term average). */ public class BudgetValue implements Cloneable { - /** The charactor that marks the two ends of a budget value */ + /** The character that marks the two ends of a budget value */ private static final char MARK = Symbols.BUDGET_VALUE_MARK; - /** The charactor that separates the factors in a budget value */ + /** The character that separates the factors in a budget value */ private static final char SEPARATOR = Symbols.VALUE_SEPARATOR; /** The relative share of time resource to be allocated */ protected ShortFloat priority; - /** The percent of priority to be kept in a constant period */ + /** + * The percent of priority to be kept in a constant period; All priority + * values “decay” over time, though at different rates. Each item is given a + * “durability” factor in (0, 1) to specify the percentage of priority level + * left after each reevaluation + */ protected ShortFloat durability; /** The overall (context-independent) evaluation */ protected ShortFloat quality; @@ -214,7 +222,7 @@ public String toString() { * Briefly display the BudgetValue * @return String representation of the value with 2-digit accuracy */ - public String toString2() { - return MARK + priority.toString2() + SEPARATOR + durability.toString2() + SEPARATOR + quality.toString2() + MARK; + public String toStringBrief() { + return MARK + priority.toStringBrief() + SEPARATOR + durability.toStringBrief() + SEPARATOR + quality.toStringBrief() + MARK; } } diff --git a/nars_core_java/nars/entity/Concept.java b/nars_core_java/nars/entity/Concept.java new file mode 100755 index 00000000..e4ff82c9 --- /dev/null +++ b/nars_core_java/nars/entity/Concept.java @@ -0,0 +1,562 @@ +/* + * The MIT License + * + * Copyright 2019 The OpenNARS authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package nars.entity; + +import java.util.ArrayList; + +import nars.inference.BudgetFunctions; +import nars.inference.LocalRules; +import nars.inference.RuleTables; +import nars.inference.UtilityFunctions; +import nars.language.CompoundTerm; +import nars.language.Term; +import nars.main_nogui.NARSBatch; +import nars.main_nogui.Parameters; +import nars.storage.BagObserver; +import nars.storage.Memory; +import nars.storage.NullBagObserver; +import nars.storage.TaskLinkBag; +import nars.storage.TermLinkBag; + +/** + * A concept contains information associated with a term, including directly and + * indirectly related tasks and beliefs. + *

+ * To make sure the space will be released, the only allowed reference to a + * concept are those in a ConceptBag. All other access go through the Term that + * names the concept. + */ +public final class Concept extends Item { + + /** + * The term is the unique ID of the concept + */ + private final Term term; + /** + * Task links for indirect processing + */ + private final TaskLinkBag taskLinks; + /** + * Term links between the term and its components and compounds + */ + private final TermLinkBag termLinks; + /** + * Link templates of TermLink, only in concepts with CompoundTerm jmv TODO + * explain more + */ + private ArrayList termLinkTemplates; + /** + * Question directly asked about the term + */ + private final ArrayList questions; + /** + * Sentences directly made about the term, with non-future tense + */ + private final ArrayList beliefs; + /** + * Reference to the memory + */ + Memory memory; + /** + * The display window + */ + private EntityObserver entityObserver = new NullEntityObserver(); + + + /* ---------- constructor and initialization ---------- */ + /** + * Constructor, called in Memory.getConcept only + * + * @param tm A term corresponding to the concept + * @param memory A reference to the memory + */ + public Concept(Term tm, Memory memory) { + super(tm.getName()); + term = tm; + this.memory = memory; + questions = new ArrayList<>(); + beliefs = new ArrayList<>(); + taskLinks = new TaskLinkBag(memory); + termLinks = new TermLinkBag(memory); + if (tm instanceof CompoundTerm) { + termLinkTemplates = ((CompoundTerm) tm).prepareComponentLinks(); + } + } + + /* ---------- direct processing of tasks ---------- */ + /** + * Directly process a new task. Called exactly once on each task. Using + * local information and finishing in a constant time. Provide feedback in + * the taskBudget value of the task. + *

+ * called in Memory.immediateProcess only + * + * @param task The task to be processed + */ + public void directProcess(Task task) { + if (task.getSentence().isJudgment()) { + processJudgment(task); + } else { + processQuestion(task); + } + if (task.getBudget().aboveThreshold()) { // still need to be processed + linkToTask(task); + } + entityObserver.refresh(displayContent()); + } + + /** + * To accept a new judgment as isBelief, and check for revisions and + * solutions + * + * @param judg The judgment to be accepted + * @param task The task to be processed + * @return Whether to continue the processing of the task + */ + private void processJudgment(Task task) { + Sentence judg = task.getSentence(); + Sentence oldBelief = evaluation(judg, beliefs); + if (oldBelief != null) { + Stamp newStamp = judg.getStamp(); + Stamp oldStamp = oldBelief.getStamp(); + if (newStamp.equals(oldStamp)) { + if (task.getParentTask().getSentence().isJudgment()) { + task.getBudget().decPriority(0); // duplicated task + } // else: activated belief + return; + } else if (LocalRules.revisible(judg, oldBelief)) { + memory.newStamp = Stamp.make(newStamp, oldStamp, memory.getTime()); + if (memory.newStamp != null) { + memory.currentBelief = oldBelief; + LocalRules.revision(judg, oldBelief, false, memory); + } + } + } + if (task.getBudget().aboveThreshold()) { + for (Task ques : questions) { +// LocalRules.trySolution(ques.getSentence(), judg, ques, memory); + LocalRules.trySolution(judg, ques, memory); + } + addToTable(judg, beliefs, Parameters.MAXIMUM_BELIEF_LENGTH); + } + } + + /** + * To answer a question by existing beliefs + * + * @param task The task to be processed + * @return Whether to continue the processing of the task + */ + public float processQuestion(Task task) { + Sentence ques = task.getSentence(); + boolean newQuestion = true; + if (questions != null) { + for (Task t : questions) { + Sentence q = t.getSentence(); + if (q.getContent().equals(ques.getContent())) { + ques = q; + newQuestion = false; + break; + } + } + } + if (newQuestion) { + questions.add(task); + } + if (questions.size() > Parameters.MAXIMUM_QUESTIONS_LENGTH) { + questions.remove(0); // FIFO + } + Sentence newAnswer = evaluation(ques, beliefs); + if (newAnswer != null) { +// LocalRules.trySolution(ques, newAnswer, task, memory); + LocalRules.trySolution(newAnswer, task, memory); + return newAnswer.getTruth().getExpectation(); + } else { + return 0.5f; + } + } + + /** + * Link to a new task from all relevant concepts for continued processing in + * the near future for unspecified time. + *

+ * The only method that calls the TaskLink constructor. + * + * @param task The task to be linked + * @param content The content of the task + */ + private void linkToTask(Task task) { + BudgetValue taskBudget = task.getBudget(); + TaskLink taskLink = new TaskLink(task, null, taskBudget); // link type: SELF + insertTaskLink(taskLink); + if (term instanceof CompoundTerm) { + if (termLinkTemplates.size() > 0) { + BudgetValue subBudget = BudgetFunctions.distributeAmongLinks(taskBudget, termLinkTemplates.size()); + if (subBudget.aboveThreshold()) { + Term componentTerm; + Concept componentConcept; + for (TermLink termLink : termLinkTemplates) { +// if (!(task.isStructural() && (termLink.getType() == TermLink.TRANSFORM))) { // avoid circular transform + taskLink = new TaskLink(task, termLink, subBudget); + componentTerm = termLink.getTarget(); + componentConcept = memory.getConcept(componentTerm); + if (componentConcept != null) { + componentConcept.insertTaskLink(taskLink); + } +// } + } + buildTermLinks(taskBudget); // recursively insert TermLink + } + } + } + } + + /** + * Add a new belief (or goal) into the table Sort the beliefs/goals by rank, + * and remove redundant or low rank one + * + * @param newSentence The judgment to be processed + * @param table The table to be revised + * @param capacity The capacity of the table + */ + private void addToTable(Sentence newSentence, ArrayList table, int capacity) { + float rank1 = BudgetFunctions.rankBelief(newSentence); // for the new isBelief + Sentence judgment2; + float rank2; + int i; + for (i = 0; i < table.size(); i++) { + judgment2 = table.get(i); + rank2 = BudgetFunctions.rankBelief(judgment2); + if (rank1 >= rank2) { + if (newSentence.equivalentTo(judgment2)) { + return; + } + table.add(i, newSentence); + break; + } + } + if (table.size() >= capacity) { + while (table.size() > capacity) { + table.remove(table.size() - 1); + } + } else if (i == table.size()) { + table.add(newSentence); + } + } + + /** + * Evaluate a query against beliefs (and desires in the future) + * + * @param query The question to be processed + * @param list The list of beliefs to be used + * @return The best candidate belief selected + */ + private Sentence evaluation(Sentence query, ArrayList list) { + if (list == null) { + return null; + } + float currentBest = 0; + float beliefQuality; + Sentence candidate = null; + for (Sentence judg : list) { + beliefQuality = LocalRules.solutionQuality(query, judg); + if (beliefQuality > currentBest) { + currentBest = beliefQuality; + candidate = judg; + } + } + return candidate; + } + + /* ---------- insert Links for indirect processing ---------- */ + /** + * Insert a TaskLink into the TaskLink bag + *

+ * called only from Memory.continuedProcess + * + * @param taskLink The termLink to be inserted + */ + public void insertTaskLink(TaskLink taskLink) { + BudgetValue taskBudget = taskLink.getBudget(); + taskLinks.putIn(taskLink); + memory.activateConcept(this, taskBudget); + } + + /** + * Recursively build TermLinks between a compound and its components + *

+ * called only from Memory.continuedProcess + * + * @param taskBudget The BudgetValue of the task + */ + public void buildTermLinks(BudgetValue taskBudget) { + Term t; + Concept concept; + TermLink termLink1, termLink2; + if (termLinkTemplates.size() > 0) { + BudgetValue subBudget = BudgetFunctions.distributeAmongLinks(taskBudget, termLinkTemplates.size()); + if (subBudget.aboveThreshold()) { + for (TermLink template : termLinkTemplates) { + if (template.getType() != TermLink.TRANSFORM) { + t = template.getTarget(); + concept = memory.getConcept(t); + if (concept != null) { + termLink1 = new TermLink(t, template, subBudget); + insertTermLink(termLink1); // this termLink to that + termLink2 = new TermLink(term, template, subBudget); + concept.insertTermLink(termLink2); // that termLink to this + if (t instanceof CompoundTerm) { + concept.buildTermLinks(subBudget); + } + } + } + } + } + } + } + + /** + * Insert a TermLink into the TermLink bag + *

+ * called from buildTermLinks only + * + * @param termLink The termLink to be inserted + */ + public void insertTermLink(TermLink termLink) { + termLinks.putIn(termLink); + } + + /* ---------- access local information ---------- */ + /** + * Return the associated term, called from Memory only + * + * @return The associated term + */ + public Term getTerm() { + return term; + } + + /** + * Return a string representation of the concept, called in ConceptBag only + * + * @return The concept name, with taskBudget in the full version + */ + @Override + public String toString() { // called from concept bag + if (NARSBatch.isStandAlone()) { + return (super.toStringBrief() + " " + key); + } else { + return key; + } + } + + /** + * called from {@link NARSBatch} + * + * @return A string representation of the concept + */ + @Override + public String toStringLong() { + String res = toStringBrief() + " " + key + + toStringIfNotNull(termLinks, "termLinks") + + toStringIfNotNull(taskLinks, "taskLinks"); + res += toStringIfNotNull(null, "questions"); + for (Task t : questions) { + res += t.toString(); + } + // TODO other details? + return res; + } + + private String toStringIfNotNull(Object item, String title) { + return item == null ? "" : "\n " + title + ":" + item.toString(); + } + + /** + * Recalculate the quality of the concept [to be refined to show + * extension/intension balance] + * + * @return The quality value + */ + @Override + public float getQuality() { + float linkPriority = termLinks.averagePriority(); + float termComplexityFactor = 1.0f / term.getComplexity(); + return UtilityFunctions.or(linkPriority, termComplexityFactor); + } + + /** + * Return the templates for TermLinks, only called in + * Memory.continuedProcess + * + * @return The template get + */ + public ArrayList getTermLinkTemplates() { + return termLinkTemplates; + } + + /** + * Select a isBelief to interact with the given task in inference + *

+ * get the first qualified one + *

+ * only called in RuleTables.reason + * + * @param task The selected task + * @return The selected isBelief + */ + public Sentence getBelief(Task task) { + Sentence taskSentence = task.getSentence(); + for (Sentence belief : beliefs) { + memory.getRecorder().append(" * Selected Belief: " + belief + "\n"); + memory.newStamp = Stamp.make(taskSentence.getStamp(), belief.getStamp(), memory.getTime()); + if (memory.newStamp != null) { + Sentence belief2 = (Sentence) belief.clone(); // will this mess up priority adjustment? + return belief2; + } + } + return null; + } + + /* ---------- main loop ---------- */ + /** + * An atomic step in a concept, only called in {@link Memory#processConcept} + */ + public void fire() { + TaskLink currentTaskLink = taskLinks.takeOut(); + if (currentTaskLink == null) { + return; + } + memory.currentTaskLink = currentTaskLink; + memory.currentBeliefLink = null; + memory.getRecorder().append(" * Selected TaskLink: " + currentTaskLink + "\n"); + Task task = currentTaskLink.getTargetTask(); + memory.currentTask = task; // one of the two places where this variable is set +// memory.getRecorder().append(" * Selected Task: " + task + "\n"); // for debugging + if (currentTaskLink.getType() == TermLink.TRANSFORM) { + memory.currentBelief = null; + RuleTables.transformTask(currentTaskLink, memory); // to turn this into structural inference as below? + } else { + int termLinkCount = Parameters.MAX_REASONED_TERM_LINK; +// while (memory.noResult() && (termLinkCount > 0)) { + while (termLinkCount > 0) { + TermLink termLink = termLinks.takeOut(currentTaskLink, memory.getTime()); + if (termLink != null) { + memory.getRecorder().append(" * Selected TermLink: " + termLink + "\n"); + memory.currentBeliefLink = termLink; + RuleTables.reason(currentTaskLink, termLink, memory); + termLinks.putBack(termLink); + termLinkCount--; + } else { + termLinkCount = 0; + } + } + } + taskLinks.putBack(currentTaskLink); + } + + /* ---------- display ---------- */ + /** + * Start displaying contents and links, called from ConceptWindow, + * TermWindow or Memory.processTask only + * + * same design as for {@link nars.storage.Bag} and + * {@link nars.gui.BagWindow}; see + * {@link nars.storage.Bag#addBagObserver(BagObserver, String)} + * + * @param entityObserver {@link EntityObserver} to set; TODO make it a real + * observer pattern (i.e. with a plurality of observers) + * @param showLinks Whether to display the task links + */ + @SuppressWarnings("unchecked") + public void startPlay(EntityObserver entityObserver, boolean showLinks) { + this.entityObserver = entityObserver; + entityObserver.startPlay(this, showLinks); + entityObserver.post(displayContent()); + if (showLinks) { + taskLinks.addBagObserver(entityObserver.createBagObserver(), "Task Links in " + term); + termLinks.addBagObserver(entityObserver.createBagObserver(), "Term Links in " + term); + } + } + + /** + * Resume display, called from ConceptWindow only + */ + public void play() { + entityObserver.post(displayContent()); + } + + /** + * Stop display, called from ConceptWindow only + */ + public void stop() { + entityObserver.stop(); + } + + /** + * Collect direct isBelief, questions, and goals for display + * + * @return String representation of direct content + */ + public String displayContent() { + StringBuilder buffer = new StringBuilder(); + buffer.append("\n Beliefs:\n"); + if (beliefs.size() > 0) { + for (Sentence s : beliefs) { + buffer.append(s).append("\n"); + } + } + buffer.append("\n Question:\n"); + if (questions.size() > 0) { + for (Task t : questions) { + buffer.append(t).append("\n"); + } + } + return buffer.toString(); + } + + class NullEntityObserver implements EntityObserver { + + @Override + public void post(String str) { + } + + @Override + public BagObserver createBagObserver() { + return new NullBagObserver<>(); + } + + @Override + public void startPlay(Concept concept, boolean showLinks) { + } + + @Override + public void stop() { + } + + @Override + public void refresh(String message) { + } + } +} diff --git a/nars_core_java/nars/entity/EntityObserver.java b/nars_core_java/nars/entity/EntityObserver.java new file mode 100755 index 00000000..cf8df331 --- /dev/null +++ b/nars_core_java/nars/entity/EntityObserver.java @@ -0,0 +1,60 @@ +/* + * The MIT License + * + * Copyright 2019 The OpenNARS authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package nars.entity; + +import nars.storage.BagObserver; + +/** + * Observer for a {@link Concept} object; similar to Observer design pattern, except that here we have a single observer; + * NOTE: very similar to interface {@link nars.storage.BagObserver} + */ +public interface EntityObserver { + + /** + * Display the content of the concept + * @param str The text to be displayed + */ + public abstract void post(String str); + + /** create a {@link BagObserver} of the right type (Factory design pattern) */ + @SuppressWarnings("rawtypes") + public abstract BagObserver createBagObserver(); + + /** + * Set the observed Concept + * @param showLinks unused : TODO : is this forgotten ? + */ + public abstract void startPlay(Concept concept, boolean showLinks); + + /** + * put in non-showing state + */ + public abstract void stop(); + + /** + * Refresh display if in showing state + */ + void refresh(String message); + +} \ No newline at end of file diff --git a/nars_core_java/nars/entity/Item.java b/nars_core_java/nars/entity/Item.java new file mode 100755 index 00000000..d4904339 --- /dev/null +++ b/nars_core_java/nars/entity/Item.java @@ -0,0 +1,196 @@ +/* + * The MIT License + * + * Copyright 2019 The OpenNARS authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package nars.entity; + +/** + * An item is an object that can be put into a Bag, + * to participate in the resource competition of the system. + *

+ * It has a key and a budget. Cannot be cloned + */ +public abstract class Item { + + /** The key of the Item, unique in a Bag */ + protected String key; + /** The budget of the Item, consisting of 3 numbers */ + protected BudgetValue budget; + + /** + * The default constructor + */ + protected Item() {} + + /** + * Constructor with default budget + * @param key The key value + */ + protected Item(String key) { + this.key = key; + this.budget = new BudgetValue(); + } + + /** + * Constructor with initial budget + * @param key The key value + * @param budget The initial budget + */ + protected Item(String key, BudgetValue budget) { + this.key = key; + this.budget = new BudgetValue(budget); // clone, not assignment + } + + /** + * Constructor with initial budget + * @param budget The initial budget + */ + protected void setBudget(BudgetValue budget) { + this.budget = budget; + } + + /** + * Get the current key + * @return Current key value + */ + public String getKey() { + return key; + } + + /** + * Get BudgetValue + * @return Current BudgetValue + */ + public BudgetValue getBudget() { + return budget; + } + + /** + * Get priority value + * @return Current priority value + */ + public float getPriority() { + return budget.getPriority(); + } + + /** + * Set priority value + * @param v Set a new priority value + */ + public void setPriority(float v) { + budget.setPriority(v); + } + + /** + * Increase priority value + * @param v The amount of increase + */ + public void incPriority(float v) { + budget.incPriority(v); + } + + /** + * Decrease priority value + * @param v The amount of decrease + */ + public void decPriority(float v) { + budget.decPriority(v); + } + + /** + * Get durability value + * @return Current durability value + */ + public float getDurability() { + return budget.getDurability(); + } + + /** + * Set durability value + * @param v The new durability value + */ + public void setDurability(float v) { + budget.setDurability(v); + } + + /** + * Increase durability value + * @param v The amount of increase + */ + public void incDurability(float v) { + budget.incDurability(v); + } + + /** + * Decrease durability value + * @param v The amount of decrease + */ + public void decDurability(float v) { + budget.decDurability(v); + } + + /** + * Get quality value + * @return The quality value + */ + public float getQuality() { + return budget.getQuality(); + } + + /** + * Set quality value + * @param v The new quality value + */ + public void setQuality(float v) { + budget.setQuality(v); + } + + /** + * Merge with another Item with identical key + * @param that The Item to be merged + */ + public void merge(Item that) { + budget.merge(that.getBudget()); + } + + /** + * Return a String representation of the Item + * @return The String representation of the full content + */ + @Override + public String toString() { + return budget + " " + key ; + } + + /** + * Return a String representation of the Item after simplification + * @return A simplified String representation of the content + */ + public String toStringBrief() { + return budget.toStringBrief() + " " + key ; + } + + public String toStringLong() { + return toString(); + } + +} diff --git a/nars_core_java/nars/entity/Sentence.java b/nars_core_java/nars/entity/Sentence.java new file mode 100755 index 00000000..a80e0b72 --- /dev/null +++ b/nars_core_java/nars/entity/Sentence.java @@ -0,0 +1,288 @@ +/* + * The MIT License + * + * Copyright 2019 The OpenNARS authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package nars.entity; + +import nars.io.Symbols; +import nars.language.Term; + +/** + * A Sentence is an abstract class, mainly containing a Term, a TruthValue, and + * a Stamp. + *

+ * It is used as the premises and conclusions of all inference rules. + */ +public class Sentence implements Cloneable { + + /** + * The content of a Sentence is a Term + */ + private Term content; + /** + * The punctuation also indicates the type of the Sentence: Judgment, + * Question, or Goal + */ + private char punctuation; + /** + * The truth value of Judgment + */ + private TruthValue truth; + /** + * Partial record of the derivation path + */ + private Stamp stamp; + /** + * Whether the sentence can be revised + */ + private boolean revisible; + + /** + * Create a Sentence with the given fields + * + * @param content The Term that forms the content of the sentence + * @param punctuation The punctuation indicating the type of the sentence + * @param truth The truth value of the sentence, null for question + * @param stamp The stamp of the sentence indicating its derivation time and + * base + */ + public Sentence(Term content, char punctuation, TruthValue truth, Stamp stamp) { + this.content = content; + this.content.renameVariables(); + this.punctuation = punctuation; + this.truth = truth; + this.stamp = stamp; + this.revisible = true; + } + + /** + * Create a Sentence with the given fields + * + * @param content The Term that forms the content of the sentence + * @param punctuation The punctuation indicating the type of the sentence + * @param truth The truth value of the sentence, null for question + * @param stamp The stamp of the sentence indicating its derivation time and + * base + * @param revisible Whether the sentence can be revised + */ + public Sentence(Term content, char punctuation, TruthValue truth, Stamp stamp, boolean revisible) { + this.content = content; + this.content.renameVariables(); + this.punctuation = punctuation; + this.truth = truth; + this.stamp = stamp; + this.revisible = revisible; + } + + /** + * To check whether two sentences are equal + * + * @param that The other sentence + * @return Whether the two sentences have the same content + */ + @Override + public boolean equals(Object that) { + if (that instanceof Sentence) { + Sentence t = (Sentence) that; + return content.equals(t.getContent()) && punctuation == t.getPunctuation() && truth.equals(t.getTruth()) && stamp.equals(t.getStamp()); + } + return false; + } + + public int getTemporalOrder(){ + return content.getTemporalOrder(); + } + + public long getOccurrenceTime(){ + return stamp.getOccurrenceTime(); + } + + /** + * To produce the hashcode of a sentence + * + * @return A hashcode + */ + @Override + public int hashCode() { + int hash = 5; + hash = 67 * hash + (this.content != null ? this.content.hashCode() : 0); + hash = 67 * hash + this.punctuation; + hash = 67 * hash + (this.truth != null ? this.truth.hashCode() : 0); + hash = 67 * hash + (this.stamp != null ? this.stamp.hashCode() : 0); + return hash; + } + + /** + * Check whether the judgment is equivalent to another one + *

+ * The two may have different keys + * + * @param that The other judgment + * @return Whether the two are equivalent + */ + public boolean equivalentTo(Sentence that) { + assert content.equals(that.getContent()) && punctuation == that.getPunctuation(); + return (truth.equals(that.getTruth()) && stamp.equals(that.getStamp())); + } + + /** + * Clone the Sentence + * + * @return The clone + */ + @Override + public Object clone() { + if (truth == null) { + return new Sentence((Term) content.clone(), punctuation, null, (Stamp) stamp.clone()); + } + return new Sentence((Term) content.clone(), punctuation, new TruthValue(truth), (Stamp) stamp.clone(), revisible); + } + + /** + * Get the content of the sentence + * + * @return The content Term + */ + public Term getContent() { + return content; + } + + /** + * Get the punctuation of the sentence + * + * @return The character '.' or '?' + */ + public char getPunctuation() { + return punctuation; + } + + /** + * Clone the content of the sentence + * + * @return A clone of the content Term + */ + public Term cloneContent() { + return (Term) content.clone(); + } + + /** + * Set the content Term of the Sentence + * + * @param t The new content + */ + public void setContent(Term t) { + content = t; + } + + /** + * Get the truth value of the sentence + * + * @return Truth value, null for question + */ + public TruthValue getTruth() { + return truth; + } + + /** + * Get the stamp of the sentence + * + * @return The stamp + */ + public Stamp getStamp() { + return stamp; + } + + public void setStamp(Stamp s) { + stamp = s; + } + + /** + * Distinguish Judgment from Goal ("instanceof Judgment" doesn't work) + * + * @return Whether the object is a Judgment + */ + public boolean isJudgment() { + return (punctuation == Symbols.JUDGMENT_MARK); + } + + /** + * Distinguish Question from Quest ("instanceof Question" doesn't work) + * + * @return Whether the object is a Question + */ + public boolean isQuestion() { + return (punctuation == Symbols.QUESTION_MARK); + } + + public boolean containQueryVar() { + return (content.getName().indexOf(Symbols.VAR_QUERY) >= 0); + } + + public boolean getRevisible() { + return revisible; + } + + public void setRevisible(boolean b) { + revisible = b; + } + + /** + * Get a String representation of the sentence + * + * @return The String + */ + @Override + public String toString() { + StringBuilder s = new StringBuilder(); + s.append(content.toString()); + s.append(punctuation).append(" "); + if (truth != null) { + s.append(truth.toString()); + } + s.append(stamp.toString()); + return s.toString(); + } + + /** + * Get a String representation of the sentence, with 2-digit accuracy + * + * @return The String + */ + public String toStringBrief() { + return toKey() + stamp.toString(); + } + + /** + * Get a String representation of the sentence for key of Task and TaskLink + * + * @return The String + */ + public String toKey() { + StringBuilder s = new StringBuilder(); + s.append(content.toString()); + s.append(punctuation).append(" "); + if (truth != null) { + s.append(truth.toStringBrief()); + } + return s.toString(); + } +} diff --git a/nars/entity/ShortFloat.java b/nars_core_java/nars/entity/ShortFloat.java old mode 100644 new mode 100755 similarity index 52% rename from nars/entity/ShortFloat.java rename to nars_core_java/nars/entity/ShortFloat.java index b24764c9..0c2ee733 --- a/nars/entity/ShortFloat.java +++ b/nars_core_java/nars/entity/ShortFloat.java @@ -1,22 +1,25 @@ -/* - * ShortFloat.java +/* + * The MIT License * - * Copyright (C) 2008 Pei Wang + * Copyright 2019 The OpenNARS authors. * - * This file is part of Open-NARS. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ package nars.entity; @@ -29,10 +32,18 @@ public class ShortFloat implements Cloneable { but used as float */ private short value; - /** + /** * Constructor * @param v The initial value */ + public ShortFloat(short v) { + value = v; + } + + /** + * Constructor + * @param v The initial value in float + */ public ShortFloat(float v) { setValue(v); } @@ -42,14 +53,14 @@ public ShortFloat(float v) { * @return The current value in float */ public float getValue() { - return (float) (value * 0.0001); + return value * 0.0001f; } /** * To access the value as short * @return The current value in short */ - short getShortValue() { + private short getShortValue() { return value; } @@ -57,9 +68,9 @@ short getShortValue() { * Set new value, rounded, with validity checking * @param v The new value */ - public void setValue(float v) { + public final void setValue(float v) { if ((v < 0) || (v > 1)) { - System.out.println("!!! Wrong value: " + v); + throw new ArithmeticException("Invalid value: " + v); } else { value = (short) (v * 10000.0 + 0.5); } @@ -81,9 +92,16 @@ public boolean equals(Object that) { */ @Override public int hashCode() { - int hash = 3; - hash = 17 * hash + this.value; - return hash; + return this.value + 17; + } + + /** + * To create an identical copy of the ShortFloat + * @return A cloned ShortFloat + */ + @Override + public Object clone() { + return new ShortFloat(value); } /** @@ -92,7 +110,7 @@ public int hashCode() { */ @Override public String toString() { - if (value == 10000) { + if (value >= 10000) { return "1.0000"; } else { String s = String.valueOf(value); @@ -104,11 +122,13 @@ public String toString() { } /** - * Convert the value into a String + * Round the value into a short String * @return The String representation, with 2 digits accuracy */ - public String toString2() { + public String toStringBrief() { + value += 50; String s = toString(); + value -= 50; if (s.length() > 4) { return s.substring(0, 4); } else { diff --git a/nars_core_java/nars/entity/Stamp.java b/nars_core_java/nars/entity/Stamp.java new file mode 100755 index 00000000..6407d763 --- /dev/null +++ b/nars_core_java/nars/entity/Stamp.java @@ -0,0 +1,320 @@ +/* + * The MIT License + * + * Copyright 2019 The OpenNARS authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package nars.entity; + +import java.util.*; +import nars.inference.TemporalRules; +import static nars.inference.TemporalRules.ORDER_BACKWARD; +import static nars.inference.TemporalRules.ORDER_CONCURRENT; +import static nars.inference.TemporalRules.ORDER_FORWARD; + +import nars.io.Symbols; +import nars.language.Tense; +import nars.main_nogui.Debug; +import nars.main_nogui.Parameters; +import nars.main_nogui.ReasonerBatch; + +/** + * Each Sentence has a time stamp, consisting the following components: + * (1) The creation time of the sentence, + * (2) A evidentialBase of serial numbers of sentence, from which the sentence is derived. + * Each input sentence gets a unique serial number, though the creation time may be not unique. + * The derived sentences inherits serial numbers from its parents, cut at the baseLength limit. + */ +public class Stamp implements Cloneable { + + /** serial number, for the whole system + * TODO : should it really be static? + * or a Stamp be a field in {@link ReasonerBatch} ? */ + private static long currentSerial = 0; + /** serial numbers */ + private long[] evidentialBase; + /** evidentialBase baseLength */ + private int baseLength; + /** creation time of the stamp */ + private long creationTime; + + private long putInTime; + + private Tense tense; + + private long occurrenceTime; + + // default for a temporal events means "always" in Judgment/Question, but + // "current" in Goal/Quest + public static final long ETERNAL = Integer.MIN_VALUE; + + public boolean before(final Stamp s, final int duration){ + if(isEternal() || s.isEternal()) + return false; + + return order(s.occurrenceTime, occurrenceTime, duration) == TemporalRules.ORDER_BACKWARD; + } + + public boolean after(final Stamp s, final int duration){ + if(isEternal() || s.isEternal()) + return false; + return order(s.occurrenceTime, occurrenceTime, duration) == TemporalRules.ORDER_FORWARD; + } + + public boolean isEternal(){ + final boolean eternalOccurrence = occurrenceTime == ETERNAL; + + if(Debug.DETAILED){ + if (eternalOccurrence && tense != Tense.Eternal) + throw new IllegalStateException("Stamp has inconsistent tense and eternal ocurrenceTime: tense=" + tense); + } + + return eternalOccurrence; + } + + public long getOccurrenceTime(){ + return occurrenceTime; + } + + public static int order(final long timeDiff, final int durationCycles){ + final int halfDuration = durationCycles/2; + if(timeDiff > halfDuration) + return ORDER_FORWARD; + else if(timeDiff < -halfDuration) + return ORDER_BACKWARD; + else + return ORDER_CONCURRENT; + } + + public static int order(final long a, final long b, final int durationCycles){ + if((a == Stamp.ETERNAL) || (b == Stamp.ETERNAL)) + throw new IllegalStateException("order() does not compare ETERNAL times"); + + return order(b - a, durationCycles); + } + + /** + * Generate a new stamp, with a new serial number, for a new Task + * @param time Creation time of the stamp + */ + public Stamp(long time) { + currentSerial++; + baseLength = 1; + evidentialBase = new long[baseLength]; + evidentialBase[0] = currentSerial; + creationTime = time; + } + + /** + * Generate a new stamp identical with a given one + * @param old The stamp to be cloned + */ + private Stamp(Stamp old) { + baseLength = old.length(); + evidentialBase = old.getBase(); + creationTime = old.getCreationTime(); + } + + /** + * Generate a new stamp from an existing one, with the same evidentialBase but different creation time + *

+ * For single-premise rules + * @param old The stamp of the single premise + * @param time The current time + */ + public Stamp(Stamp old, long time) { + baseLength = old.length(); + evidentialBase = old.getBase(); + creationTime = time; + } + + public Stamp(long time, Tense tense){ + currentSerial++; + baseLength = 1; + evidentialBase = new long[baseLength]; + evidentialBase[0] = currentSerial; + this.tense = tense; + //setCreationTime(time, Parameters.DURATION_FOR_INTERNAL_BUFFER) + } + + /** + * Generate a new stamp for derived sentence by merging the two from parents + * the first one is no shorter than the second + * @param first The first Stamp + * @param second The second Stamp + */ + private Stamp(Stamp first, Stamp second, long time) { + int i1, i2, j; + i1 = i2 = j = 0; + baseLength = Math.min(first.length() + second.length(), Parameters.MAXIMUM_STAMP_LENGTH); + evidentialBase = new long[baseLength]; + while (i2 < second.length() && j < baseLength) { + evidentialBase[j] = first.get(i1); + i1++; + j++; + evidentialBase[j] = second.get(i2); + i2++; + j++; + } + while (i1 < first.length() && j < baseLength) { + evidentialBase[j] = first.get(i1); + i1++; + j++; + } + creationTime = time; + } + + /** + * Try to merge two Stamps, return null if have overlap + *

+ * By default, the event time of the first stamp is used in the result + * @param first The first Stamp + * @param second The second Stamp + * @param time The new creation time + * @return The merged Stamp, or null + */ + public static Stamp make(Stamp first, Stamp second, long time) { + for (int i = 0; i < first.length(); i++) { + for (int j = 0; j < second.length(); j++) { + if (first.get(i) == second.get(j)) { + return null; + } + } + } + if (first.length() > second.length()) { + return new Stamp(first, second, time); + } else { + return new Stamp(second, first, time); + } + } + + /** + * Clone a stamp + * @return The cloned stamp + */ + @Override + public Object clone() { + return new Stamp(this); + } + + /** + * Initialize the stamp mechanism of the system, called in Reasoner + */ + public static void init() { + currentSerial = 0; + } + + /** + * Return the baseLength of the evidentialBase + * @return Length of the Stamp + */ + public int length() { + return baseLength; + } + + /** + * Get a number from the evidentialBase by index, called in this class only + * @param i The index + * @return The number at the index + */ + long get(int i) { + return evidentialBase[i]; + } + + /** + * Get the evidentialBase, called in this class only + * @return The evidentialBase of numbers + */ + private long[] getBase() { + return evidentialBase; + } + + /** + * Convert the evidentialBase into a set + * @return The TreeSet representation of the evidential base + */ + private TreeSet toSet() { + TreeSet set = new TreeSet<>(); + for (int i = 0; i < baseLength; i++) { + set.add(evidentialBase[i]); + } + return set; + } + + /** + * Check if two stamps contains the same content + * @param that The Stamp to be compared + * @return Whether the two have contain the same elements + */ + @Override + public boolean equals(Object that) { + if (!(that instanceof Stamp)) { + return false; + } + TreeSet set1 = toSet(); + TreeSet set2 = ((Stamp) that).toSet(); + return (set1.containsAll(set2) && set2.containsAll(set1)); + } + + /** + * The hash code of Stamp + * @return The hash code + */ + @Override + public int hashCode() { + return toString().hashCode(); + } + + /** + * Get the creationTime of the truth-value + * @return The creation time + */ + public long getCreationTime() { + return creationTime; + } + + /** + * Get a String form of the Stamp for display + * Format: {creationTime [: eventTime] : evidentialBase} + * @return The Stamp as a String + */ + @Override + public String toString() { + StringBuilder buffer = new StringBuilder(" " + Symbols.STAMP_OPENER + creationTime); + buffer.append(" ").append(Symbols.STAMP_STARTER).append(" "); + for (int i = 0; i < baseLength; i++) { + buffer.append(Long.toString(evidentialBase[i])); + if (i < (baseLength - 1)) { + buffer.append(Symbols.STAMP_SEPARATOR); + } else { + buffer.append(Symbols.STAMP_CLOSER).append(" "); + } + } + return buffer.toString(); + } + + public long getPutInTime(){ + return putInTime; + } + + public void setPutInTime(long time){ + putInTime = time; + } +} diff --git a/nars_core_java/nars/entity/Task.java b/nars_core_java/nars/entity/Task.java new file mode 100755 index 00000000..566a442d --- /dev/null +++ b/nars_core_java/nars/entity/Task.java @@ -0,0 +1,206 @@ +/* + * The MIT License + * + * Copyright 2019 The OpenNARS authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package nars.entity; + +import nars.language.Term; + +/** + * A task to be processed, consists of a Sentence and a BudgetValue + */ +public class Task extends Item { + + /** + * The sentence of the Task + */ + private Sentence sentence; + /** + * Task from which the Task is derived, or null if input + */ + private Task parentTask; + /** + * Belief from which the Task is derived, or null if derived from a theorem + */ + private Sentence parentBelief; + /** + * For Question and Goal: best solution found so far + */ + private Sentence bestSolution; + + /** + * Constructor for input task + * + * @param s The sentence + * @param b The budget + */ + public Task(Sentence s, BudgetValue b) { + super(s.toKey(), b); // change to toKey() + sentence = s; + key = sentence.toKey(); + } + + /** + * Constructor for a derived task + * + * @param s The sentence + * @param b The budget + * @param parentTask The task from which this new task is derived + * @param parentBelief The belief from which this new task is derived + */ + public Task(Sentence s, BudgetValue b, Task parentTask, Sentence parentBelief) { + this(s, b); + this.parentTask = parentTask; + this.parentBelief = parentBelief; + } + + /** + * Constructor for an activated task + * + * @param s The sentence + * @param b The budget + * @param parentTask The task from which this new task is derived + * @param parentBelief The belief from which this new task is derived + * @param solution The belief to be used in future inference + */ + public Task(Sentence s, BudgetValue b, Task parentTask, Sentence parentBelief, Sentence solution) { + this(s, b, parentTask, parentBelief); + this.bestSolution = solution; + } + + /** + * Get the sentence + * + * @return The sentence + */ + public Sentence getSentence() { + return sentence; + } + + /** + * Directly get the content of the sentence + * + * @return The content of the sentence + */ + public Term getContent() { + return sentence.getContent(); + } + + /** + * Directly get the creation time of the sentence + * + * @return The creation time of the sentence + */ + public long getCreationTime() { + return sentence.getStamp().getCreationTime(); + } + + /** + * Check if a Task is a direct input + * + * @return Whether the Task is derived from another task + */ + public boolean isInput() { + return parentTask == null; + } + + /** + * Check if a Task is derived by a StructuralRule + * + * @return Whether the Task is derived by a StructuralRule + */ +// public boolean isStructural() { +// return (parentBelief == null) && (parentTask != null); +// } + /** + * Merge one Task into another + * + * @param that The other Task + */ + @Override + public void merge(Item that) { + if (getCreationTime() >= ((Task) that).getCreationTime()) { + super.merge(that); + } else { + that.merge(this); + } + } + + /** + * Get the best-so-far solution for a Question or Goal + * + * @return The stored Sentence or null + */ + public Sentence getBestSolution() { + return bestSolution; + } + + /** + * Set the best-so-far solution for a Question or Goal, and report answer + * for input question + * + * @param judg The solution to be remembered + */ + public void setBestSolution(Sentence judg) { + bestSolution = judg; + } + + /** + * Get the parent belief of a task + * + * @return The belief from which the task is derived + */ + public Sentence getParentBelief() { + return parentBelief; + } + + /** + * Get the parent task of a task + * + * @return The task from which the task is derived + */ + public Task getParentTask() { + return parentTask; + } + + /** + * Get a String representation of the Task + * + * @return The Task as a String + */ + @Override + public String toString() { + StringBuilder s = new StringBuilder(); + s.append(super.toString()).append(" "); + s.append(getSentence().getStamp()); + if (parentTask != null) { + s.append(" \n from task: ").append(parentTask.toStringBrief()); + if (parentBelief != null) { + s.append(" \n from belief: ").append(parentBelief.toStringBrief()); + } + } + if (bestSolution != null) { + s.append(" \n solution: ").append(bestSolution.toStringBrief()); + } + return s.toString(); + } +} diff --git a/nars_core_java/nars/entity/TaskLink.java b/nars_core_java/nars/entity/TaskLink.java new file mode 100755 index 00000000..7d2d5d3b --- /dev/null +++ b/nars_core_java/nars/entity/TaskLink.java @@ -0,0 +1,130 @@ +/* + * The MIT License + * + * Copyright 2019 The OpenNARS authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package nars.entity; + +import nars.language.Term; +import nars.main_nogui.Parameters; + +/** + * Reference to a Task. + *

+ * The reason to separate a Task and a TaskLink is that the same Task can be + * linked from multiple Concepts, with different BudgetValue. + */ +public class TaskLink extends TermLink { + + /** + * The Task linked. The "target" field in TermLink is not used here. + */ + private Task targetTask; + /** + * Remember the TermLinks that has been used recently with this TaskLink + */ + private String recordedLinks[]; + /** + * Remember the time when each TermLink is used with this TaskLink + */ + private long recordingTime[]; + /** + * The number of TermLinks remembered + */ + int counter; + + /** + * Constructor + *

+ * only called in Memory.continuedProcess + * + * @param t The target Task + * @param template The TermLink template + * @param v The budget + */ + public TaskLink(Task t, TermLink template, BudgetValue v) { + super("", v); + targetTask = t; + if (template == null) { + type = TermLink.SELF; + index = null; + } else { + type = template.getType(); + index = template.getIndices(); + } + recordedLinks = new String[Parameters.TERM_LINK_RECORD_LENGTH]; + recordingTime = new long[Parameters.TERM_LINK_RECORD_LENGTH]; + counter = 0; + setKey(); // as defined in TermLink + key += t.getKey(); + } + + /** + * Get the target Task + * + * @return The linked Task + */ + public Task getTargetTask() { + return targetTask; + } + + /** + * To check whether a TaskLink should use a TermLink, return false if they + * interacted recently + *

+ * called in TermLinkBag only + * + * @param termLink The TermLink to be checked + * @param currentTime The current time + * @return Whether they are novel to each other + */ + public boolean novel(TermLink termLink, long currentTime) { + Term bTerm = termLink.getTarget(); + if (bTerm.equals(targetTask.getSentence().getContent())) { + return false; + } + String linkKey = termLink.getKey(); + int next, i; + for (i = 0; i < counter; i++) { + next = i % Parameters.TERM_LINK_RECORD_LENGTH; + if (linkKey.equals(recordedLinks[next])) { + if (currentTime < recordingTime[next] + Parameters.TERM_LINK_RECORD_LENGTH) { + return false; + } else { + recordingTime[next] = currentTime; + return true; + } + } + } + next = i % Parameters.TERM_LINK_RECORD_LENGTH; + recordedLinks[next] = linkKey; // add knowledge reference to recordedLinks + recordingTime[next] = currentTime; + if (counter < Parameters.TERM_LINK_RECORD_LENGTH) { // keep a constant length + counter++; + } + return true; + } + + @Override + public String toString() { + return super.toString() + " " + getTargetTask().getSentence().getStamp(); + } +} diff --git a/nars/entity/TermLink.java b/nars_core_java/nars/entity/TermLink.java old mode 100644 new mode 100755 similarity index 75% rename from nars/entity/TermLink.java rename to nars_core_java/nars/entity/TermLink.java index 50aec366..136db2c7 --- a/nars/entity/TermLink.java +++ b/nars_core_java/nars/entity/TermLink.java @@ -1,22 +1,25 @@ -/* - * TermLink.java +/* + * The MIT License * - * Copyright (C) 2008 Pei Wang + * Copyright 2019 The OpenNARS authors. * - * This file is part of Open-NARS. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * Open-NARS is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * - * Open-NARS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Open-NARS. If not, see . + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ package nars.entity; @@ -59,12 +62,6 @@ public class TermLink extends Item { /** The index of the component in the component list of the compound, may have up to 4 levels */ protected short[] index; - /** - * Default constructor - */ - public TermLink() { - } - /** * Constructor for TermLink template *

@@ -91,12 +88,12 @@ public TermLink(Term t, short p, int... indices) { } } - /** - * Default Constructor need in TaskLink - * @param v Budget value of the link + /** called from TaskLink + * @param s The key of the TaskLink + * @param v The budget value of the TaskLink */ - protected TermLink(BudgetValue v) { - super(v); + protected TermLink(String s, BudgetValue v) { + super(s, v); } /** @@ -108,7 +105,7 @@ protected TermLink(BudgetValue v) { * @param v Budget value of the link */ public TermLink(Term t, TermLink template, BudgetValue v) { - super(v); + super(t.getName(), v); target = t; type = template.getType(); if (template.getTarget().equals(t)) { @@ -121,7 +118,7 @@ public TermLink(Term t, TermLink template, BudgetValue v) { /** * Set the key of the link */ - protected void setKey() { + protected final void setKey() { String at1, at2; if ((type % 2) == 1) { // to component at1 = Symbols.TO_COMPONENT_1; @@ -178,22 +175,4 @@ public short getIndex(int i) { return -1; } } - - /** - * Get a String representation of the link, with full accuracy - * @return The String - */ - @Override - public String toString() { - return (super.toString() + " " + key); - } - - /** - * Get a String representation of the link, with 2-digit accuracy - * @return The String - */ - @Override - public String toString2() { - return (super.toString2() + " " + key); - } } diff --git a/nars_core_java/nars/entity/TruthValue.java b/nars_core_java/nars/entity/TruthValue.java new file mode 100755 index 00000000..5dc715fc --- /dev/null +++ b/nars_core_java/nars/entity/TruthValue.java @@ -0,0 +1,209 @@ +/* + * The MIT License + * + * Copyright 2019 The OpenNARS authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package nars.entity; + +import nars.io.Symbols; + +/** + * Frequency and confidence. + */ +public class TruthValue implements Cloneable { // implements Cloneable { + + /** + * The character that marks the two ends of a truth value + */ + private static final char DELIMITER = Symbols.TRUTH_VALUE_MARK; + /** + * The character that separates the factors in a truth value + */ + private static final char SEPARATOR = Symbols.VALUE_SEPARATOR; + /** + * The frequency factor of the truth value + */ + private ShortFloat frequency; + /** + * The confidence factor of the truth value + */ + private ShortFloat confidence; + /** + * Whether the truth value is derived from a definition + */ + private boolean isAnalytic = false; + + /** + * Constructor with two ShortFloats + * + * @param f The frequency value + * @param c The confidence value + */ + public TruthValue(float f, float c) { + frequency = new ShortFloat(f); + confidence = (c < 1) ? new ShortFloat(c) : new ShortFloat(0.9999f); + } + + /** + * Constructor with two ShortFloats + * + * @param f The frequency value + * @param c The confidence value + * + */ + public TruthValue(float f, float c, boolean b) { + frequency = new ShortFloat(f); + confidence = (c < 1) ? new ShortFloat(c) : new ShortFloat(0.9999f); + isAnalytic = b; + } + + /** + * Constructor with a TruthValue to clone + * + * @param v The truth value to be cloned + */ + public TruthValue(TruthValue v) { + frequency = new ShortFloat(v.getFrequency()); + confidence = new ShortFloat(v.getConfidence()); + isAnalytic = v.getAnalytic(); + } + + /** + * Get the frequency value + * + * @return The frequency value + */ + public float getFrequency() { + return frequency.getValue(); + } + + /** + * Get the confidence value + * + * @return The confidence value + */ + public float getConfidence() { + return confidence.getValue(); + } + + /** + * Get the isAnalytic flag + * + * @return The isAnalytic value + */ + public boolean getAnalytic() { + return isAnalytic; + } + + /** + * Set the isAnalytic flag + */ + public void setAnalytic() { + isAnalytic = true; + } + + /** + * Calculate the expectation value of the truth value + * + * @return The expectation value + */ + public float getExpectation() { + return (float) (confidence.getValue() * (frequency.getValue() - 0.5) + 0.5); + } + + /** + * Calculate the absolute difference of the expectation value and that of a + * given truth value + * + * @param t The given value + * @return The absolute difference + */ + public float getExpDifAbs(TruthValue t) { + return Math.abs(getExpectation() - t.getExpectation()); + } + + /** + * Check if the truth value is negative + * + * @return True if the frequence is less than 1/2 + */ + public boolean isNegative() { + return getFrequency() < 0.5; + } + + public float getIgnornce(){ + return (float) (1.0 - confidence.getValue()); + } + + /** + * Compare two truth values + * + * @param that The other TruthValue + * @return Whether the two are equivalent + */ + @Override + public boolean equals(Object that) { + return ((that instanceof TruthValue) + && (getFrequency() == ((TruthValue) that).getFrequency()) + && (getConfidence() == ((TruthValue) that).getConfidence())); + } + + /** + * The hash code of a TruthValue + * + * @return The hash code + */ + @Override + public int hashCode() { + return (int) (getExpectation() * 37); + } + + @Override + public Object clone() { + return new TruthValue(getFrequency(), getConfidence(), getAnalytic()); + } + + /** + * The String representation of a TruthValue + * + * @return The String + */ + @Override + public String toString() { + return DELIMITER + frequency.toString() + SEPARATOR + confidence.toString() + DELIMITER; + } + + /** + * A simplified String representation of a TruthValue, where each factor is + * accruate to 1% + * + * @return The String + */ + public String toStringBrief() { + String s1 = DELIMITER + frequency.toStringBrief() + SEPARATOR; + String s2 = confidence.toStringBrief(); + if (s2.equals("1.00")) { + return s1 + "0.99" + DELIMITER; + } else { + return s1 + s2 + DELIMITER; + } + } +} diff --git a/nars/entity/package.html b/nars_core_java/nars/entity/package.html old mode 100644 new mode 100755 similarity index 82% rename from nars/entity/package.html rename to nars_core_java/nars/entity/package.html index 1eb73d9a..dec3a9dd --- a/nars/entity/package.html +++ b/nars_core_java/nars/entity/package.html @@ -8,7 +8,7 @@

Package Specification