├── .circleci └── config.yml ├── .gitignore ├── AUTHORS ├── CMakeLists.txt ├── LICENSE ├── README.md ├── TODO ├── cmake ├── CMakeLists.txt ├── OpenCogAtomTypes.cmake ├── OpenCogCython.cmake ├── OpenCogFunctions.cmake ├── OpenCogGuile.cmake └── OpenCogMacros.cmake ├── doc ├── CMakeLists.txt ├── Doxyfile ├── HaskellDoc.cmake ├── README.archlinux ├── README.fedora ├── README.gentoo ├── README.opensuse ├── README.osx ├── README.ubuntu ├── README.win32 ├── README_to_doxygen.sh └── doxydoc │ ├── bldtargets.dox │ ├── fsstructure.dox │ ├── layout.ini │ ├── libatomspace.dox │ ├── libattention.dox │ ├── libhaskell.dox │ ├── libpersist.dox │ ├── libraries.dox │ ├── libsmob.dox │ ├── license.dox │ ├── main.dox │ ├── otherwikis.dox │ └── update-links.py ├── examples ├── CMakeLists.txt ├── README.md ├── atomspace │ ├── README.md │ ├── assert-retract.scm │ ├── basic.scm │ ├── bindlink.scm │ ├── copy-on-write.scm │ ├── distributed.scm │ ├── except.scm │ ├── execute.scm │ ├── factorial.scm │ ├── flow-formulas.scm │ ├── flows.scm │ ├── formulas.scm │ ├── frame.scm │ ├── get-put.scm │ ├── gperf.scm │ ├── knowledge.scm │ ├── logging.scm │ ├── my_py_func.py │ ├── parallel.scm │ ├── persist-file.scm │ ├── persist-multi.scm │ ├── persist-query.scm │ ├── persist-store.scm │ ├── persistence.scm │ ├── property.scm │ ├── python.scm │ ├── queue.scm │ ├── random-choice.scm │ ├── recursive-loop.scm │ ├── state.scm │ ├── stream.scm │ ├── threaded.scm │ ├── truthvalues.scm │ └── values.scm ├── c++-guile │ ├── CMakeLists.txt │ ├── ExampleSCM.cc │ ├── ExampleSCM.h │ ├── PrimitiveExample.cc │ ├── README.md │ └── opencog │ │ └── example.scm ├── c++ │ ├── CMakeLists.txt │ └── basic.cc ├── gearman │ ├── README.md │ ├── client.scm │ ├── task.scm │ ├── worker-1.scm │ ├── worker-2.scm │ └── worker-3.scm ├── haskell │ ├── README.md │ ├── example.hs │ ├── example_multiple_atoms.hs │ ├── example_multiple_atomspaces.hs │ ├── example_multithreading.hs │ └── example_pattern_matcher.hs ├── pattern-matcher │ ├── README.md │ ├── absent.scm │ ├── always.scm │ ├── anchor.scm │ ├── choice.scm │ ├── condition.scm │ ├── deduction-engine.scm │ ├── define.scm │ ├── filter.scm │ ├── fsm-basic.scm │ ├── fsm-full.scm │ ├── fsm-mealy.scm │ ├── glob.scm │ ├── gpn.scm │ ├── gsn-truth.scm │ ├── gsn.scm │ ├── map.scm │ ├── markov-chain.scm │ ├── presence.scm │ ├── query.scm │ ├── recognizer.scm │ ├── satisfaction.scm │ ├── sequence.scm │ ├── type-signature.scm │ ├── value-of.scm │ └── virtual.scm └── python │ ├── README.md │ ├── TUTORIAL.md │ ├── __init__.py │ ├── create_atoms_by_type.py │ ├── create_atoms_simple.py │ ├── get_outgoings.py │ ├── ground │ ├── ground.py │ └── mymodule.py │ ├── is_a.py │ ├── scheme │ ├── atom_type_names.py │ ├── bindlink.py │ └── scheme_timer.py │ ├── stop_go.py │ └── values.py ├── lib ├── AtomSpaceConfig.cmake.in ├── CMakeLists.txt ├── README.md ├── Vagrantfile ├── atomspace-test.conf ├── buildbot-master.cfg ├── helgrind.guile.suppressions ├── valgrind.boost.suppressions ├── valgrind.guile.suppressions ├── valgrind.link-grammar.suppressions ├── valgrind.logger.suppressions └── valgrind.python.suppressions ├── opencog ├── CMakeLists.txt ├── README.md ├── atoms │ ├── CMakeLists.txt │ ├── README.md │ ├── atom_types │ │ ├── CMakeLists.txt │ │ ├── NameServer.cc │ │ ├── NameServer.h │ │ ├── README.md │ │ ├── atom_types.cc │ │ ├── atom_types.script │ │ ├── atom_types_init.cc │ │ └── types.h │ ├── base │ │ ├── Atom.cc │ │ ├── Atom.h │ │ ├── CMakeLists.txt │ │ ├── ClassServer.cc │ │ ├── ClassServer.h │ │ ├── Handle.cc │ │ ├── Handle.h │ │ ├── Link.cc │ │ ├── Link.h │ │ ├── Node.cc │ │ ├── Node.h │ │ ├── README.md │ │ ├── Valuation.cc │ │ ├── Valuation.h │ │ └── hash.h │ ├── container │ │ ├── CMakeLists.txt │ │ ├── JoinLink.cc │ │ └── JoinLink.h │ ├── core │ │ ├── ArityLink.cc │ │ ├── ArityLink.h │ │ ├── CMakeLists.txt │ │ ├── Checkers.cc │ │ ├── CondLink.cc │ │ ├── CondLink.h │ │ ├── Context.cc │ │ ├── Context.h │ │ ├── DefineLink.cc │ │ ├── DefineLink.h │ │ ├── DeleteLink.cc │ │ ├── DeleteLink.h │ │ ├── FindUtils.cc │ │ ├── FindUtils.h │ │ ├── FreeLink.cc │ │ ├── FreeLink.h │ │ ├── FreeVariables.cc │ │ ├── FreeVariables.h │ │ ├── FunctionLink.cc │ │ ├── FunctionLink.h │ │ ├── ImplicationScopeLink.cc │ │ ├── ImplicationScopeLink.h │ │ ├── LambdaLink.cc │ │ ├── LambdaLink.h │ │ ├── MapLink.cc │ │ ├── MapLink.h │ │ ├── NumberNode.cc │ │ ├── NumberNode.h │ │ ├── PrenexLink.cc │ │ ├── PrenexLink.h │ │ ├── PresentLink.cc │ │ ├── PresentLink.h │ │ ├── PutLink.cc │ │ ├── PutLink.h │ │ ├── Quotation.cc │ │ ├── Quotation.h │ │ ├── RandomChoice.cc │ │ ├── RandomChoice.h │ │ ├── RandomNumber.cc │ │ ├── RandomNumber.h │ │ ├── Replacement.cc │ │ ├── Replacement.h │ │ ├── RewriteLink.cc │ │ ├── RewriteLink.h │ │ ├── ScopeLink.cc │ │ ├── ScopeLink.h │ │ ├── SleepLink.cc │ │ ├── SleepLink.h │ │ ├── StateLink.cc │ │ ├── StateLink.h │ │ ├── TimeLink.cc │ │ ├── TimeLink.h │ │ ├── TypeChoice.cc │ │ ├── TypeChoice.h │ │ ├── TypeIntersectionLink.cc │ │ ├── TypeIntersectionLink.h │ │ ├── TypeNode.cc │ │ ├── TypeNode.h │ │ ├── TypeUtils.cc │ │ ├── TypeUtils.h │ │ ├── TypedAtomLink.cc │ │ ├── TypedAtomLink.h │ │ ├── TypedVariableLink.cc │ │ ├── TypedVariableLink.h │ │ ├── UniqueLink.cc │ │ ├── UniqueLink.h │ │ ├── UnorderedLink.cc │ │ ├── UnorderedLink.h │ │ ├── VariableList.cc │ │ ├── VariableList.h │ │ ├── VariableSet.cc │ │ ├── VariableSet.h │ │ ├── Variables.cc │ │ └── Variables.h │ ├── execution │ │ ├── ApplyLink.cc │ │ ├── ApplyLink.h │ │ ├── CMakeLists.txt │ │ ├── EvaluationLink.cc │ │ ├── EvaluationLink.h │ │ ├── ExecutionOutputLink.cc │ │ ├── ExecutionOutputLink.h │ │ ├── Force.cc │ │ ├── Force.h │ │ ├── GroundedFunctionLink.h │ │ ├── GroundedObject.h │ │ ├── GroundedObjectNode.cc │ │ ├── GroundedObjectNode.h │ │ ├── GroundedProcedureNode.h │ │ ├── Instantiator.cc │ │ ├── Instantiator.h │ │ ├── MethodOfLink.cc │ │ ├── MethodOfLink.h │ │ └── README.md │ ├── flow │ │ ├── CMakeLists.txt │ │ ├── PredicateFormulaLink.cc │ │ ├── PredicateFormulaLink.h │ │ ├── SetTVLink.cc │ │ ├── SetTVLink.h │ │ ├── SetValueLink.cc │ │ ├── SetValueLink.h │ │ ├── StreamValueOfLink.cc │ │ ├── StreamValueOfLink.h │ │ ├── TruthValueOfLink.cc │ │ ├── TruthValueOfLink.h │ │ ├── ValueOfLink.cc │ │ └── ValueOfLink.h │ ├── grounded │ │ ├── CMakeLists.txt │ │ ├── DLPython.cc │ │ ├── DLPython.h │ │ ├── DLScheme.cc │ │ ├── DLScheme.h │ │ ├── GroundedPredicateNode.cc │ │ ├── GroundedPredicateNode.h │ │ ├── GroundedSchemaNode.cc │ │ ├── GroundedSchemaNode.h │ │ ├── LibraryManager.cc │ │ ├── LibraryManager.h │ │ ├── LibraryRunner.cc │ │ ├── LibraryRunner.h │ │ ├── PythonRunner.cc │ │ ├── PythonRunner.h │ │ ├── README.md │ │ ├── Runner.h │ │ ├── SCMRunner.cc │ │ └── SCMRunner.h │ ├── parallel │ │ ├── CMakeLists.txt │ │ ├── ExecuteThreadedLink.cc │ │ ├── ExecuteThreadedLink.h │ │ ├── ParallelLink.cc │ │ ├── ParallelLink.h │ │ ├── ThreadJoinLink.cc │ │ └── ThreadJoinLink.h │ ├── pattern │ │ ├── BindLink.cc │ │ ├── BindLink.h │ │ ├── CMakeLists.txt │ │ ├── DualLink.cc │ │ ├── DualLink.h │ │ ├── GetLink.cc │ │ ├── GetLink.h │ │ ├── MeetLink.cc │ │ ├── MeetLink.h │ │ ├── Pattern.cc │ │ ├── Pattern.h │ │ ├── PatternJit.cc │ │ ├── PatternLink.cc │ │ ├── PatternLink.h │ │ ├── PatternTerm.cc │ │ ├── PatternTerm.h │ │ ├── PatternUtils.cc │ │ ├── PatternUtils.h │ │ ├── QueryLink.cc │ │ ├── QueryLink.h │ │ ├── README.md │ │ ├── SatisfactionLink.cc │ │ └── SatisfactionLink.h │ ├── reduct │ │ ├── AccumulateLink.cc │ │ ├── AccumulateLink.h │ │ ├── ArithmeticLink.cc │ │ ├── ArithmeticLink.h │ │ ├── CMakeLists.txt │ │ ├── DivideLink.cc │ │ ├── DivideLink.h │ │ ├── FoldLink.cc │ │ ├── FoldLink.h │ │ ├── HeavisideLink.cc │ │ ├── HeavisideLink.h │ │ ├── MaxLink.cc │ │ ├── MaxLink.h │ │ ├── MinLink.cc │ │ ├── MinLink.h │ │ ├── MinusLink.cc │ │ ├── MinusLink.h │ │ ├── PlusLink.cc │ │ ├── PlusLink.h │ │ ├── README.md │ │ ├── TimesLink.cc │ │ └── TimesLink.h │ ├── truthvalue │ │ ├── CMakeLists.txt │ │ ├── CountTruthValue.cc │ │ ├── CountTruthValue.h │ │ ├── EvidenceCountTruthValue.cc │ │ ├── EvidenceCountTruthValue.h │ │ ├── FormulaTruthValue.cc │ │ ├── FormulaTruthValue.h │ │ ├── FuzzyTruthValue.cc │ │ ├── FuzzyTruthValue.h │ │ ├── IndefiniteTruthValue.cc │ │ ├── IndefiniteTruthValue.h │ │ ├── ProbabilisticTruthValue.cc │ │ ├── ProbabilisticTruthValue.h │ │ ├── SimpleTruthValue.cc │ │ ├── SimpleTruthValue.h │ │ ├── TensorTruthValue.cc │ │ ├── TensorTruthValue.h │ │ ├── TruthValue.cc │ │ └── TruthValue.h │ └── value │ │ ├── CMakeLists.txt │ │ ├── FloatValue.cc │ │ ├── FloatValue.h │ │ ├── FormulaStream.cc │ │ ├── FormulaStream.h │ │ ├── LinkStreamValue.cc │ │ ├── LinkStreamValue.h │ │ ├── LinkValue.cc │ │ ├── LinkValue.h │ │ ├── PtrValue.cc │ │ ├── PtrValue.h │ │ ├── QueueValue.cc │ │ ├── QueueValue.h │ │ ├── README.md │ │ ├── RandomStream.cc │ │ ├── RandomStream.h │ │ ├── StreamValue.cc │ │ ├── StreamValue.h │ │ ├── StringValue.cc │ │ ├── StringValue.h │ │ ├── Value.cc │ │ ├── Value.h │ │ ├── ValueFactory.cc │ │ ├── ValueFactory.h │ │ ├── VoidValue.cc │ │ └── VoidValue.h ├── atomspace │ ├── AtomSpace.cc │ ├── AtomSpace.h │ ├── AtomTable.cc │ ├── AtomTable.h │ ├── CMakeLists.txt │ ├── README.md │ ├── Transient.cc │ ├── Transient.h │ ├── TypeIndex.cc │ ├── TypeIndex.h │ └── version.h ├── bench-mst │ ├── README.md │ ├── boruvka-101.dat │ ├── boruvka-101.png │ ├── boruvka-701K-limit.dat │ ├── boruvka-701K.dat │ ├── boruvka-701K.png │ ├── boruvka.gplot │ └── mst-bench.scm ├── cython │ ├── CMakeLists.txt │ ├── PyIncludeWrapper.h │ ├── PythonEval.cc │ ├── PythonEval.h │ ├── PythonSCM.cc │ ├── README.md │ ├── executioncontext │ │ ├── CMakeLists.txt │ │ ├── Context.cc │ │ └── Context.h │ └── opencog │ │ ├── BindlinkStub.cc │ │ ├── BindlinkStub.h │ │ ├── CMakeLists.txt │ │ ├── PyScheme.cc │ │ ├── PyScheme.h │ │ ├── PythonGroundedObject.cc │ │ ├── PythonGroundedObject.h │ │ ├── Utilities.cc │ │ ├── Utilities.h │ │ ├── __init__.py │ │ ├── atom.pyx │ │ ├── atomspace.pxd │ │ ├── atomspace.pyx │ │ ├── atomspace_details.pyx │ │ ├── bindlink.py │ │ ├── exec.py │ │ ├── execute.pxd │ │ ├── execute.pyx │ │ ├── float_value.pyx │ │ ├── grounded_object_node.pxd │ │ ├── grounded_object_node.pyx │ │ ├── link_value.pyx │ │ ├── load-file.cc │ │ ├── load-file.h │ │ ├── logger.pxd │ │ ├── logger.pyx │ │ ├── nameserver.pyx │ │ ├── ptrvalue.pxd │ │ ├── ptrvalue.pyx │ │ ├── scheme.pyx │ │ ├── scheme_wrapper.py │ │ ├── string_value.pyx │ │ ├── truth_value.pyx │ │ ├── type_constructors.pyx │ │ ├── utilities.pxd │ │ ├── utilities.pyx │ │ ├── value.pyx │ │ └── value_types.pxd ├── eval │ ├── CMakeLists.txt │ └── GenericEval.h ├── guile │ ├── CMakeLists.txt │ ├── README │ ├── SchemeEval.cc │ ├── SchemeEval.h │ ├── SchemeModule.cc │ ├── SchemeModule.h │ ├── SchemePrimitive.cc │ ├── SchemePrimitive.h │ ├── SchemeSmob.cc │ ├── SchemeSmob.h │ ├── SchemeSmobAS.cc │ ├── SchemeSmobAtom.cc │ ├── SchemeSmobGC.cc │ ├── SchemeSmobLogger.cc │ ├── SchemeSmobNew.cc │ ├── SchemeSmobPrint.cc │ ├── SchemeSmobTV.cc │ ├── SchemeSmobValue.cc │ └── modules │ │ ├── CMakeLists.txt │ │ ├── ExecSCM.cc │ │ ├── LoggerSCM.cc │ │ ├── RandGenSCM.cc │ │ ├── TypeUtilsSCM.cc │ │ └── UuidSCM.cc ├── haskell │ ├── .gitignore │ ├── AtomSpace_CWrapper.cpp │ ├── AtomSpace_CWrapper.h │ ├── CMakeLists.txt │ ├── Exec_CWrapper.cpp │ ├── Exec_CWrapper.h │ ├── OpenCog │ │ ├── AtomSpace.hs │ │ └── AtomSpace │ │ │ ├── Api.hs │ │ │ ├── CUtils.hs │ │ │ ├── Env.hs │ │ │ ├── Internal.hs │ │ │ ├── Query.hs │ │ │ ├── Sugar.hs │ │ │ ├── Types.hs │ │ │ └── Utils.hs │ ├── PatternMatcher_CWrapper.cpp │ ├── PatternMatcher_CWrapper.h │ ├── README.md │ ├── Setup.hs │ ├── TruthValue_CWrapper.cpp │ ├── TruthValue_CWrapper.h │ ├── Value_CWrapper.cpp │ ├── Value_CWrapper.h │ ├── build.sh │ ├── deeptypes │ │ ├── README.md │ │ ├── experiment_with_GADT.hs │ │ └── experiment_with_data.hs │ ├── opencog-atomspace.cabal │ └── stack.yaml ├── matrix │ ├── CMakeLists.txt │ ├── README.md │ ├── bin-count.scm │ ├── compute-mi.scm │ ├── cosine.scm │ ├── direct-sum.scm │ ├── docs │ │ ├── AtomSpace.lyx │ │ ├── AtomSpace.pdf │ │ ├── cloud-matrix.dia │ │ ├── cloud-matrix.eps │ │ ├── matrix.dia │ │ ├── matrix.eps │ │ ├── phosphorylation.svg │ │ ├── puzzle.png │ │ ├── seed.png │ │ └── seeds-two.png │ ├── dynamic.scm │ ├── entropy.scm │ ├── eval-pairs.scm │ ├── filter.scm │ ├── fold-api.scm │ ├── loop-api.scm │ ├── matrix.scm │ ├── object-api.scm │ ├── progress.scm │ ├── report-api.scm │ ├── similarity-api.scm │ ├── store.scm │ ├── support.scm │ ├── symmetric-mi.scm │ ├── thresh-pca.scm │ ├── trans-batch.scm │ ├── transpose.scm │ └── trim.scm ├── persist │ ├── CMakeLists.txt │ ├── README.md │ ├── api │ │ ├── BackingQuery.cc │ │ ├── BackingStore.cc │ │ ├── BackingStore.h │ │ ├── CMakeLists.txt │ │ ├── PersistSCM.cc │ │ ├── PersistSCM.h │ │ ├── README.md │ │ ├── StorageNode.cc │ │ └── StorageNode.h │ ├── gearman │ │ ├── CMakeLists.txt │ │ ├── DistSCM.cc │ │ └── README.md │ ├── json │ │ ├── CMakeLists.txt │ │ ├── DecodeJson.cc │ │ ├── EncodeJson.cc │ │ ├── JSCommands.cc │ │ ├── JSCommands.h │ │ ├── Json.h │ │ ├── JsonEval.h │ │ └── README.md │ ├── sexpr │ │ ├── AtomSexpr.cc │ │ ├── CMakeLists.txt │ │ ├── Commands.cc │ │ ├── Commands.h │ │ ├── FileStorage.cc │ │ ├── FileStorage.h │ │ ├── PersistFileSCM.cc │ │ ├── README.md │ │ ├── Sexpr.h │ │ ├── SexprEval.cc │ │ ├── SexprEval.h │ │ ├── ValueSexpr.cc │ │ ├── fast_load.cc │ │ └── fast_load.h │ ├── sql │ │ ├── CMakeLists.txt │ │ ├── README-design.md │ │ ├── README-odbc.md │ │ ├── README-perf.md │ │ ├── README.md │ │ └── multi-driver │ │ │ ├── CMakeLists.txt │ │ │ ├── README.md │ │ │ ├── SQLAtomDelete.cc │ │ │ ├── SQLAtomLoad.cc │ │ │ ├── SQLAtomStorage.cc │ │ │ ├── SQLAtomStorage.h │ │ │ ├── SQLAtomStore.cc │ │ │ ├── SQLBulk.cc │ │ │ ├── SQLPersistSCM.cc │ │ │ ├── SQLPersistSCM.h │ │ │ ├── SQLResponse.h │ │ │ ├── SQLSpaces.cc │ │ │ ├── SQLTypeMap.cc │ │ │ ├── SQLUUID.cc │ │ │ ├── SQLValues.cc │ │ │ ├── atom.sql │ │ │ ├── convert.sql │ │ │ ├── ll-pg-cxx.cc │ │ │ ├── ll-pg-cxx.h │ │ │ ├── llapi.cc │ │ │ ├── llapi.h │ │ │ ├── notes │ │ │ ├── odbcxx.cc │ │ │ ├── odbcxx.h │ │ │ └── sniff.cc │ ├── storage │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── storage_types.script │ │ └── storage_types_init.cc │ └── tlb │ │ ├── CMakeLists.txt │ │ ├── TLB.cc │ │ └── TLB.h ├── query │ ├── CMakeLists.txt │ ├── Implicator.h │ ├── InitiateSearchMixin.cc │ ├── InitiateSearchMixin.h │ ├── NextSearchMixin.cc │ ├── PatternMatchCallback.h │ ├── PatternMatchEngine.cc │ ├── PatternMatchEngine.h │ ├── README-Algorithm.md │ ├── README-recursive.scm │ ├── README.md │ ├── Recognizer.cc │ ├── Recognizer.h │ ├── RewriteMixin.cc │ ├── RewriteMixin.h │ ├── Satisfier.cc │ ├── Satisfier.h │ ├── SatisfyMixin.cc │ ├── SatisfyMixin.h │ ├── TermMatchMixin.cc │ └── TermMatchMixin.h ├── scm │ ├── CMakeLists.txt │ ├── README.md │ ├── opencog.scm │ ├── opencog │ │ ├── base │ │ │ ├── README │ │ │ ├── apply.scm │ │ │ ├── atom-cache.scm │ │ │ ├── core-docs.scm │ │ │ ├── debug-trace.scm │ │ │ ├── file-utils.scm │ │ │ ├── repl-shell.scm │ │ │ ├── tv.scm │ │ │ ├── types.scm │ │ │ └── utilities.scm │ │ ├── dist-gearman.scm │ │ ├── exec.scm │ │ ├── extension.scm │ │ ├── logger.scm │ │ ├── persist-file.scm │ │ ├── persist-sql.scm │ │ ├── persist.scm │ │ ├── python.scm │ │ ├── query.scm │ │ ├── randgen.scm │ │ ├── test-runner.scm │ │ ├── type-utils.scm │ │ └── uuid.scm │ └── wires │ │ ├── README │ │ ├── cgw-bidi.scm │ │ ├── cgw-fan.scm │ │ ├── cgw-filter.scm │ │ ├── cgw-predicate.scm │ │ ├── cgw-simple.scm │ │ ├── cgw-wire.scm │ │ └── test-wire-order.scm └── sheaf │ ├── CMakeLists.txt │ ├── README.md │ ├── docs │ ├── README.md │ ├── connectors-and-variables.lyx │ ├── connectors-and-variables.pdf │ ├── feature.lyx │ ├── feature.pdf │ ├── graphics │ │ ├── bad-graph.dia │ │ ├── bad-graph.eps │ │ ├── chain.dia │ │ ├── chain.eps │ │ ├── corn-field.jpg │ │ ├── cornstalk.jpg │ │ ├── corpus-dep.dia │ │ ├── corpus-dep.eps │ │ ├── corpus-ngram.dia │ │ ├── corpus-ngram.eps │ │ ├── directed-graph.png │ │ ├── example.dia │ │ ├── example.eps │ │ ├── grammar.dia │ │ ├── grammar.eps │ │ ├── hedgehog.dia │ │ ├── hedgehog.eps │ │ ├── history.dia │ │ ├── history.eps │ │ ├── hypergraph.dia │ │ ├── hypergraph.eps │ │ ├── krebs.svg │ │ ├── metagraph.dia │ │ ├── metagraph.eps │ │ ├── org-chart.dia │ │ ├── org-chart.eps │ │ ├── parsing.dia │ │ ├── parsing.eps │ │ ├── partial-index.dia │ │ ├── partial-index.eps │ │ ├── phosphorylation.svg │ │ ├── polymorph.dia │ │ ├── polymorph.eps │ │ ├── project.dia │ │ ├── project.eps │ │ ├── puzzle-vector.dia │ │ ├── puzzle-vector.eps │ │ ├── puzzle.dia │ │ ├── puzzle.eps │ │ ├── section-field.dia │ │ ├── section-field.eps │ │ ├── seed-puzzle.dia │ │ ├── seed-puzzle.eps │ │ ├── seed-unlabelled.dia │ │ ├── seed-unlabelled.eps │ │ ├── seed.dia │ │ ├── seed.eps │ │ ├── seeds-two.dia │ │ ├── seeds-two.eps │ │ ├── sheaf-of-papers.jpg │ │ ├── sheaf-of-stalks.jpg │ │ ├── sheaf.dia │ │ ├── sheaf.eps │ │ ├── similar.dia │ │ ├── similar.eps │ │ ├── stack-jigsaw-puzzle-pieces.jpg │ │ ├── stalk-field.dia │ │ ├── stalk-field.eps │ │ ├── stalk.dia │ │ ├── stalk.eps │ │ ├── tensor.dia │ │ ├── tensor.eps │ │ ├── viterbi.dia │ │ └── viterbi.eps │ ├── lang.bib │ ├── learning.lyx │ ├── learning.pdf │ ├── mereology.lyx │ ├── mereology.pdf │ ├── morse.lyx │ ├── pattern-traversal.lyx │ ├── ram-cpu.lyx │ ├── ram-cpu.pdf │ ├── sheaf-axioms.lyx │ ├── sheaf-axioms.pdf │ ├── sheaves.lyx │ ├── sheaves.pdf │ ├── tensors.lyx │ └── tensors.pdf │ ├── linear-parser.scm │ ├── make-section.scm │ ├── mpg-parser.scm │ ├── mst-parser.scm │ ├── sections.scm │ ├── sheaf.scm │ └── vo-graph.scm ├── scripts ├── .gdbinit ├── .gdbinit-print-opencog ├── benchmark_utests.sh ├── combine_lcov.sh ├── query │ └── benchmark_query.sh └── run_lcov.sh └── tests ├── CMakeLists.txt ├── atoms ├── AlphaConvertUTest.cxxtest ├── BetaReduceUTest.cxxtest ├── CMakeLists.txt ├── DefineLinkUTest.cxxtest ├── DeleteLinkUTest.cxxtest ├── FreeLinkUTest.cxxtest ├── HashUTest.cxxtest ├── RandomUTest.cxxtest ├── StateLinkUTest.cxxtest ├── atom_types │ ├── AtomNamesUTest.cxxtest │ ├── CMakeLists.txt │ └── NameServerUTest.cxxtest ├── base │ ├── AtomUTest.cxxtest │ ├── CMakeLists.txt │ ├── ClassServerUTest.cxxtest │ ├── FactoryUTest.cxxtest │ ├── HandleUTest.cxxtest │ ├── LinkUTest.cxxtest │ ├── NodeUTest.cxxtest │ ├── TestTypes.cc │ └── test_types.script ├── container │ ├── BlueJoinUTest.cxxtest │ ├── CMakeLists.txt │ ├── CompoundJoinUTest.cxxtest │ ├── GPNJoinUTest.cxxtest │ ├── JoinLinkUTest.cxxtest │ ├── TrueJoinUTest.cxxtest │ ├── blue-sky.scm │ ├── compound-join.scm │ ├── gpn-container.scm │ ├── gpn-join.scm │ ├── join-content.scm │ ├── join.scm │ ├── true-container.scm │ ├── true-join.scm │ └── true-upper.scm ├── core │ ├── CMakeLists.txt │ ├── CheckersUTest.cxxtest │ ├── CondLinkUTest.cxxtest │ ├── FindUtilsUTest.cxxtest │ ├── NumberNodeUTest.cxxtest │ ├── PutLinkUTest.cxxtest │ ├── QuotationUTest.cxxtest │ ├── RewriteLinkUTest.cxxtest │ ├── ScopeLinkUTest.cxxtest │ ├── TypeIntersectionUTest.cxxtest │ ├── TypeUtilsUTest.cxxtest │ ├── VariablesUTest.cxxtest │ ├── condlink.scm │ ├── put-and.scm │ ├── put-get-lambda.scm │ ├── put-get-multi.scm │ ├── put-get.scm │ ├── put-multi-set.scm │ ├── put-nested.scm │ ├── put-quoted-lambda.scm │ ├── put-quoted.scm │ ├── put-tricky.scm │ └── quotations.scm ├── evaluation │ ├── CMakeLists.txt │ ├── EqualLinkUTest.cxxtest │ ├── ExclusiveLinkUTest.cxxtest │ ├── IdenticalLinkUTest.cxxtest │ ├── MemberLinkUTest.cxxtest │ └── SubsetLinkUTest.cxxtest ├── execution │ ├── ApplyLinkUTest.cxxtest │ ├── CMakeLists.txt │ ├── DefinedSchemaUTest.cxxtest │ ├── MapLinkUTest.cxxtest │ ├── defined-schema.scm │ └── maplink.scm ├── flow │ ├── CMakeLists.txt │ ├── DynamicUTest.cxxtest │ ├── FormulaUTest.cxxtest │ ├── SetTVUTest.cxxtest │ ├── SetValueUTest.cxxtest │ ├── StreamValueOfUTest.cxxtest │ ├── ValueOfUTest.cxxtest │ ├── dynamic.scm │ ├── formulas.scm │ ├── set-tv-flow.scm │ └── set-value-flow.scm ├── grounded │ ├── CMakeLists.txt │ └── GroundedSchemaLocalUTest.cxxtest ├── hash.scm ├── parallel │ ├── CMakeLists.txt │ ├── ParallelUTest.cxxtest │ ├── ThreadedUTest.cxxtest │ ├── parallel.scm │ └── threaded.scm ├── pattern │ ├── BindLinkUTest.cxxtest │ ├── CMakeLists.txt │ ├── PatternUtilsUTest.cxxtest │ └── SatisfactionLinkUTest.cxxtest ├── random-choice.scm ├── reduct │ ├── AccumulateUTest.cxxtest │ ├── CMakeLists.txt │ ├── HeavisideUTest.cxxtest │ ├── MinMaxUTest.cxxtest │ └── ReductUTest.cxxtest ├── truthvalue │ ├── CMakeLists.txt │ ├── EvidenceCountTruthValueUTest.cxxtest │ ├── IndefiniteTruthValueUTest.cxxtest │ ├── SimpleTruthValueUTest.cxxtest │ ├── TVMergeUTest.cxxtest │ ├── TVUTest.cxxtest │ └── tv-test.scm └── value │ ├── CMakeLists.txt │ ├── PtrValueUTest.cxxtest │ ├── StreamUTest.cxxtest │ ├── ValueUTest.cxxtest │ ├── VoidValueUTest.cxxtest │ └── stream.scm ├── atomspace ├── AtomSpaceAsyncUTest.cxxtest ├── AtomSpaceUTest.cxxtest ├── AtomTableUTest.cxxtest ├── CMakeLists.txt ├── COWSpaceUTest.cxxtest ├── HashMixUTest.cxxtest ├── MultiSpaceUTest.cxxtest ├── RemoveUTest.cxxtest ├── UseCountUTest.cxxtest ├── ValuationTableUTest.cxxtest ├── atom_table_utest.scm └── makeVirtualAtom.h ├── cython ├── CMakeLists.txt ├── PythonEvalUTest.cxxtest ├── PythonUtilitiesUTest.cxxtest ├── README.md ├── atomspace │ ├── test_atom.py │ ├── test_atomspace.py │ ├── test_callback_arity.py │ ├── test_do_execute.py │ ├── test_exception.py │ ├── test_floatvalue.py │ ├── test_groundedobjectnode.py │ ├── test_groundedobjectnode_gil.py │ ├── test_linkvalue.py │ ├── test_linkvalue_containing_atoms.py │ ├── test_nameserver.py │ ├── test_ptrvalue.py │ ├── test_stringvalue.py │ └── test_tensortv.py ├── bindlink │ ├── test_bindlink.py │ └── test_functions.py ├── guile │ ├── basic_unify.scm │ ├── test_exception.py │ └── test_pattern.py ├── test_logger.py └── utilities │ ├── test_utilities.py │ └── utilities.py ├── haskell ├── CMakeLists.txt ├── executionTestLib │ ├── .gitignore │ ├── CMakeLists.txt │ ├── buildTest.sh │ ├── hsbracket.c │ ├── opencoglib.cabal │ ├── src │ │ └── OpenCog │ │ │ └── Lib.hs │ └── stack.yaml └── haskellTest │ ├── CMakeLists.txt │ ├── Main.hs │ ├── Setup.hs │ ├── buildTest.sh │ ├── haskell-test.cabal │ ├── log.txt │ ├── runTest.sh │ ├── src │ └── Dummy.hs │ └── stack.yaml ├── matrix ├── CMakeLists.txt ├── VectorAPIUTest.cxxtest ├── basic-api.scm └── basic-data.scm ├── persist ├── CMakeLists.txt ├── gearman │ ├── CMakeLists.txt │ ├── GearmanUTest.cxxtest │ ├── README │ └── run_gearman_test.sh ├── sexpr │ ├── CMakeLists.txt │ ├── CommandsUTest.cxxtest │ ├── FastLoadUTest.cxxtest │ └── file-storage.scm ├── sql │ ├── CMakeLists.txt │ ├── README.md │ └── multi-driver │ │ ├── AlphaEquivUTest.cxxtest │ │ ├── BasicDeleteUTest.cxxtest │ │ ├── BasicSaveUTest.cxxtest │ │ ├── CMakeLists.txt │ │ ├── DeleteUTest.cxxtest │ │ ├── FetchUTest.cxxtest │ │ ├── LargeFlatUTest.cxxtest │ │ ├── LargeZipfUTest.cxxtest │ │ ├── MultiDeleteUTest.cxxtest │ │ ├── MultiPersistUTest.cxxtest │ │ ├── MultiUserUTest.cxxtest │ │ ├── PersistUTest.cxxtest │ │ ├── QueryPersistUTest.cxxtest │ │ ├── README.md │ │ ├── ValueSaveUTest.cxxtest │ │ └── mkuri.h └── tlb │ ├── CMakeLists.txt │ └── TLBUTest.cxxtest ├── query ├── AbsentUTest.cxxtest ├── AlwaysUTest.cxxtest ├── AnchorUTest.cxxtest ├── ArcanaUTest.cxxtest ├── BigPatternUTest.cxxtest ├── BiggerPatternUTest.cxxtest ├── BindTVUTest.cxxtest ├── BindVariableSetUTest.cxxtest ├── Boolean2NotUTest.cxxtest ├── BooleanUTest.cxxtest ├── BuggyBindLinkUTest.cxxtest ├── BuggyEqualUTest.cxxtest ├── BuggyLinkUTest.cxxtest ├── BuggyNotUTest.cxxtest ├── BuggyQuoteUTest.cxxtest ├── BuggySelfGroundUTest.cxxtest ├── BuggyStackUTest.cxxtest ├── CMakeLists.txt ├── CacheHitUTest.cxxtest ├── ChoiceLinkUTest.cxxtest ├── ClassicalBooleanUTest.cxxtest ├── ConstantClausesUTest.cxxtest ├── DeepTypeUTest.cxxtest ├── DefineUTest.cxxtest ├── DisconnectedUTest.cxxtest ├── DontExecUTest.cxxtest ├── EinsteinUTest.cxxtest ├── EvalLinkDefaultTVUTest.cxxtest ├── EvaluationUTest.cxxtest ├── ExecutionOutputUTest.cxxtest ├── FiniteStateMachineUTest.cxxtest ├── GetLinkUTest.cxxtest ├── GetStateUTest.cxxtest ├── GlobUTest.cxxtest ├── GreaterComputeUTest.cxxtest ├── GreaterThanUTest.cxxtest ├── IllPutUTest.cxxtest ├── ImplicationUTest.cxxtest ├── IsClosedUTest.cxxtest ├── IsFalseUTest.cxxtest ├── IsTrueUTest.cxxtest ├── LocalQuoteUTest.cxxtest ├── LoopPatternUTest.cxxtest ├── MatchLinkUTest.cxxtest ├── NestedClauseUTest.cxxtest ├── NoExceptionUTest.cxxtest ├── NotLinkUTest.cxxtest ├── PatternCrashUTest.cxxtest ├── PatternUTest.cxxtest ├── PermutationsUTest.cxxtest ├── PredicateFormulaUTest.cxxtest ├── PresentUTest.cxxtest ├── QueryUTest.cxxtest ├── QuoteUTest.cxxtest ├── RecognizerUTest.cxxtest ├── ScopeUTest.cxxtest ├── SequenceUTest.cxxtest ├── StackMoreUTest.cxxtest ├── StackUTest.cxxtest ├── SubstitutionUTest.cxxtest ├── SudokuUTest.cxxtest ├── TypeChoiceUTest.cxxtest ├── UnorderedUTest.cxxtest ├── UnquoteUTest.cxxtest ├── VarTypeNotUTest.cxxtest ├── VirtualUTest.cxxtest ├── absent-conn1.scm ├── absent-conn2.scm ├── absent-disconn1.scm ├── absent-disconn2.scm ├── absent-multi.scm ├── absent-pets.scm ├── absent.scm ├── always-more.scm ├── always.scm ├── anchor.scm ├── arcana-bigger-dummy.scm ├── arcana-const.scm ├── arcana-dummy.scm ├── arcana-numeric.scm ├── arcana-repeat.scm ├── bind-tv.scm ├── blair-witch.scm ├── buggy-crime.scm ├── buggy-equal-arithmetic.scm ├── buggy-equal-unify.scm ├── buggy-equal.scm ├── buggy-link.scm ├── buggy-not.scm ├── buggy-selfgnd.scm ├── buggy-stack.scm ├── choice-compound.scm ├── choice-constant.scm ├── choice-disconnected.scm ├── choice-double.scm ├── choice-embed-disco.scm ├── choice-embed.scm ├── choice-link.scm ├── choice-nest.scm ├── choice-present.scm ├── choice-top-nest.scm ├── choice-typed.scm ├── choice-unary.scm ├── classical-boolean.scm ├── constant-clauses.scm ├── constant-present.scm ├── constant-scope.scm ├── deduct-einstein.scm ├── deduct-keep.scm ├── deduct-rules.scm ├── deduct-trivial.scm ├── deep-types.scm ├── define-schema.scm ├── define.scm ├── disco-dancers.scm ├── disco-vars.scm ├── disconnected.scm ├── dont-exec-simple.scm ├── dont-exec.scm ├── eval-default-tv.scm ├── eval-lambda.scm ├── eval-var.scm ├── evaluation.scm ├── exec-factorial.scm ├── exec-gsn.scm ├── exec-implication-scope.scm ├── exec-lambda-get.scm ├── exec-lambda.scm ├── exec.scm ├── executable-pattern.scm ├── finite-state-machine.scm ├── get-link-embed.scm ├── get-link-equal.scm ├── get-link-eval.scm ├── get-link-glob.scm ├── get-link.scm ├── glob-basic.scm ├── glob-multi-pivot.scm ├── glob-nest.scm ├── glob-number.scm ├── glob-partition.scm ├── glob-pivot.scm ├── greater-compute.scm ├── greater_than.scm ├── ill-put.scm ├── implication-introduction.scm ├── imply.h ├── is_closed.scm ├── is_false.scm ├── is_true.scm ├── match-link.scm ├── nested-and.scm ├── no-exception-analysis.scm ├── no-exception.scm ├── predicate-formula.scm ├── present-virtual.scm ├── present.scm ├── query-exclusive.scm ├── query-meet.scm ├── query.scm ├── quote-crash.scm ├── quote-exec-getlink.scm ├── quote-glob.scm ├── quote-gpn.scm ├── quote-greater.scm ├── quote-impossible.scm ├── quote-nest.scm ├── quote-quote.scm ├── quote-scope.scm ├── quote-self.scm ├── quote-throw.scm ├── quote-var.scm ├── recognizer.scm ├── sat-anonymous.scm ├── sat-named.scm ├── scope-confound.scm ├── scope-hide.scm ├── scope-quote.scm ├── scope-search.scm ├── seq-absence.scm ├── seq-presence.scm ├── seq-trivial.scm ├── sequence.scm ├── stackmany-o-u.scm ├── stackmore-o-o.scm ├── stackmore-o-u.scm ├── stackmore-o-uu.scm ├── stackmore-u-o.scm ├── stackmore-u-u.scm ├── stackmore-u-uu.scm ├── substitution.scm ├── sudoku-puzzle.scm ├── sudoku-rules.scm ├── sudoku-simple.scm ├── test-types.cc ├── test-types.h ├── test_types.scm ├── unordered-embed.scm ├── unordered-exhaust.scm ├── unordered-jswiergo.scm ├── unordered-more.scm ├── unordered-odo-below.scm ├── unordered-odo-couplayer.scm ├── unordered-odo-couple.scm ├── unordered-odo-distinct.scm ├── unordered-odo-equal.scm ├── unordered-odo-equpr.scm ├── unordered-odo-indistinct.scm ├── unordered-odo-layer.scm ├── unordered-odometer.scm ├── unordered-quote.scm ├── unordered.scm ├── var-type-not.scm └── virtual.scm ├── scm ├── BasicSCMUTest.cxxtest ├── CMakeLists.txt ├── MultiAtomSpaceUTest.cxxtest ├── MultiThreadUTest.cxxtest ├── SCMExecutionOutputUTest.cxxtest ├── SCMPrimitiveUTest.cxxtest ├── SCMUtilsUTest.cxxtest ├── as-of-atom.scm ├── copy-atom.scm ├── inline-values.scm ├── pm.scm ├── scm-load-file-test-data.scm ├── scm-load-file.scm ├── scm-opencog-test-runner-fail.scm ├── scm-opencog-test-runner-pass.scm ├── scm-python-arity.scm ├── scm-python-shared-atomspace.scm ├── scm-python.scm ├── typedefs.scm └── utils-test.scm └── sheaf ├── CMakeLists.txt ├── extents.scm └── linear-parser.scm /AUTHORS: -------------------------------------------------------------------------------- 1 | @author Ben Goertzel 2 | @author Cassio Pennachin 3 | @author Murilo Saraiva de Queiroz 4 | @author Linas Vepstas 5 | @author Nil Geisweiller 6 | @author Joel Pitt 7 | @author Andre Senna 8 | @author Jared Wigmore 9 | @author Zhenhua Cai 10 | @author Troy Huang 11 | @author Shujing Ke 12 | @author Ruiting Lian 13 | @author Lake Watkins 14 | @author Alex van der Peet 15 | @author max willis 16 | @author Scott Jones 17 | @author Carlos Lopes 18 | @author Fabricio Silva 19 | @author Gustavo Gama 20 | @author Moshe Looks 21 | @author Ari Heljakka 22 | @author Rodrigo Barra 23 | @author Thiago Maia 24 | @author Tony Lofthouse 25 | @author Trent Waddington 26 | @author Welter Silva 27 | @author Samir Araujo 28 | @author Keyvan Mir Mohammad Sadeghi 29 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | 2 | Reading-list TODO: 3 | ------------------ 4 | 5 | * Russ Harmer and Eugenia Oshurko "Reversibility and composition of 6 | rewriting in hierarchies", (2020) 7 | https://hal.archives-ouvertes.fr/hal-02869865 8 | 9 | The idea here is that sequences of rules can be applied, and then they 10 | can be reversed. This enableds back-tracking on a rule system. 11 | 12 | * Scott Garrabrant, Tsvi Benson-Tilsen, Andrew Critch, Nate Soares, 13 | Jessica Taylor "Logical Induction" (2016) 14 | https://arxiv.org/abs/1609.03543 15 | 16 | "We present a computable algorithm that assigns probabilities to 17 | every logical statement in a given formal language, and refines 18 | those probabilities over time." 19 | -------------------------------------------------------------------------------- /cmake/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | INSTALL(FILES 2 | OpenCogAtomTypes.cmake 3 | OpenCogCython.cmake 4 | OpenCogGuile.cmake 5 | OpenCogMacros.cmake 6 | OpenCogFunctions.cmake 7 | DESTINATION 8 | ${DATADIR}/cmake/) 9 | -------------------------------------------------------------------------------- /cmake/OpenCogCython.cmake: -------------------------------------------------------------------------------- 1 | # Cythonizes one .pyx file into a .cpp file 2 | # Additional arguments are dependencies 3 | 4 | MACRO(CYTHON_ADD_MODULE_PYX name) 5 | SET(DEPENDS ${name}.pyx) 6 | 7 | IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.pxd) 8 | SET(DEPENDS ${DEPENDS} ${name}.pxd) 9 | ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.pxd) 10 | 11 | # Allow the user to specify dependencies as optional arguments 12 | SET(DEPENDS ${DEPENDS} ${ARGN}) 13 | 14 | ADD_CUSTOM_COMMAND( 15 | OUTPUT ${name}.cpp 16 | COMMAND ${CYTHON_EXECUTABLE} 17 | ARGS ${CYTHON_FLAGS} -I ${PROJECT_BINARY_DIR} 18 | -I ${CMAKE_CURRENT_SOURCE_DIR} -o ${name}.cpp 19 | --cplus ${CMAKE_CURRENT_SOURCE_DIR}/${name}.pyx 20 | DEPENDS ${DEPENDS} 21 | COMMENT "Cythonizing ${name}.pyx") 22 | 23 | list(APPEND ADDITIONAL_MAKE_CLEAN_FILES "${name}.cpp") 24 | ENDMACRO(CYTHON_ADD_MODULE_PYX) 25 | -------------------------------------------------------------------------------- /cmake/OpenCogFunctions.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Backwards-compatibility wrapper 3 | INCLUDE(OpenCogMacros) 4 | INCLUDE(OpenCogGuile) 5 | INCLUDE(OpenCogCython) 6 | -------------------------------------------------------------------------------- /doc/HaskellDoc.cmake: -------------------------------------------------------------------------------- 1 | 2 | EXECUTE_PROCESS( 3 | COMMAND stack haddock --extra-lib-dirs=${BINDIR}/opencog/haskell 4 | WORKING_DIRECTORY "${SRCDIR}/opencog/haskell" 5 | ) 6 | 7 | EXECUTE_PROCESS( 8 | COMMAND mkdir ${BINDIR}/doc/html 9 | ) 10 | 11 | EXECUTE_PROCESS( 12 | COMMAND mkdir ${BINDIR}/doc/html/haskell 13 | ) 14 | 15 | EXECUTE_PROCESS( 16 | COMMAND find .stack-work/install -name "doc" 17 | COMMAND xargs cp -r -t ${BINDIR}/doc/html/haskell 18 | WORKING_DIRECTORY "${SRCDIR}/opencog/haskell" 19 | ) 20 | 21 | -------------------------------------------------------------------------------- /doc/README.archlinux: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | Installation and dependency resolution for ArchLinux users 3 | ############################################################################### 4 | 5 | There exists a package in the AUR named opencog-bzr found at 6 | http://aur.archlinux.org/packages.php?ID=35449 7 | 8 | To get started with the AUR, please read: 9 | http://wiki.archlinux.org/index.php/AUR 10 | 11 | An AUR helper automates the use of the AUR. 12 | To use an AUR helper (yaourt) please read: 13 | http://wiki.archlinux.org/index.php/Yaourt 14 | 15 | Note that it's possible you will encounter a linkage error at the end 16 | OpenCog compiling, this is because the install script uses fakeroot, 17 | if so just compile it manually and it should work. 18 | 19 | ---------------------------------------------------------- 20 | 21 | Opencog depends on the many packages. Some of the more important ones are: 22 | 23 | g++ cmake boost guile cxxtest unixodbc 24 | 25 | unixodbc is optional. See the main README for details. 26 | 27 | ---------------------------------------------------------- 28 | -------------------------------------------------------------------------------- /doc/README.fedora: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | Instalation and dependency resolution for Fedora 9 users 3 | ############################################################################### 4 | 5 | Opencog depends on the following packages: 6 | 7 | gcc-c++ cmake boost boost-devel 8 | 9 | ---------------------------------------------------------- 10 | 11 | They may be downloaded and installed using the following commands: 12 | 13 | wget http://downloads.sourceforge.net/cxxtest/cxxtest-3.10.1-1.noarch.rpm 14 | 15 | sudo yum --nogpgcheck localinstall cxxtest-3.10.1-1.noarch.rpm 16 | 17 | ---------------------------------------------------------- 18 | 19 | Opencog also optionally depends on the following packages: 20 | 21 | unixODBC-devel -- needed for SQL persistence 22 | 23 | guile-devel -- needed for scheme bindings 24 | 25 | ---------------------------------------------------------- 26 | -------------------------------------------------------------------------------- /doc/README.gentoo: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | Instalation and dependency resolution for Gentoo (circa Sep. 2008) 3 | ####################################################################### 4 | 5 | Opencog depends on the following packages: 6 | 7 | dev-util/cmake dev-libs/boost 8 | 9 | You might need to eselect the right boost version as well. 10 | 11 | ---------------------------------------------------------- 12 | 13 | Additionally, it depends on the following non-official packages: 14 | 15 | cxxtest 16 | 17 | which are available in the 'vendor' directory. To install them, issue 18 | the following commands: 19 | 20 | prompt# cd 21 | prompt# ebuild vendor/cxxtest/gentoo/dev-cpp/cxxtest/cxxtest*.ebuild install qmerge 22 | 23 | ---------------------------------------------------------- 24 | 25 | Opencog also depends on the following packages: 26 | 27 | dev-db/unixODBC -- needed for SQL persistence 28 | 29 | dev-scheme/guile -- needed for scheme bindings 30 | -------------------------------------------------------------------------------- /doc/README.opensuse: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | Instalation and dependency resolution for OpenSUSE 11.2 users 3 | ############################################################################### 4 | 5 | Opencog depends on the following packages: 6 | 7 | gcc-c++ make cmake boost-devel 8 | 9 | ------------------------------------------------------------------------------- 10 | 11 | Additionally, it depends on the following non-official packages: 12 | 13 | cxxtest 14 | 15 | They may be downloaded and installed using the following commands: 16 | 17 | wget http://downloads.sourceforge.net/cxxtest/cxxtest-3.10.1-1.noarch.rpm 18 | 19 | sudo rpm -Uhv cxxtest-3.10.1-1.noarch.rpm csockets-2.2.5-1.1.i586.rpm 20 | 21 | ------------------------------------------------------------------------------- 22 | 23 | Opencog also depends on the following packages: 24 | 25 | unixODBC-devel -- needed for SQL persistence 26 | 27 | guile-devel -- needed for scheme bindings 28 | 29 | ------------------------------------------------------------------------------- 30 | -------------------------------------------------------------------------------- /doc/README.osx: -------------------------------------------------------------------------------- 1 | 2 | Instructions for Apple Mac OSX users 3 | ------------------------------------ 4 | 5 | The MacPorts installer does not include /opt/local/lib into the shared 6 | library search path. Thus, any libraries installed there will fail to 7 | be found. The search path needs to be fixed manually. This can be done 8 | by editing ~/.profile and specifying 9 | 10 | export DYLD_LIBRARY_PATH=/opt/local/lib:$DYLD_LIBRARY_PATH 11 | 12 | A dynamic library search path failure will manifest itself with this 13 | error message: 14 | 15 | ./opencog/server/cogserver 16 | Searching for config in default locations... 17 | Found ../lib/opencog.conf 18 | loaded configuration from file "../lib/opencog.conf" 19 | File: ../opencog/scm/utilities.scm line: 9 20 | ERROR: In procedure dynamic-link: 21 | ERROR: file: "libguile-srfi-srfi-1-v-3", message: "file not found" 22 | ABORT: misc-error 23 | 24 | Proper operation can be confirmed with opencog, or by invoking guile on 25 | the command line: 26 | 27 | $ guile 28 | guile> (use-modules (srfi srfi-1)) 29 | guile> 30 | 31 | The above should not generate any errors when the shared libary load 32 | path is correctly configured. 33 | -------------------------------------------------------------------------------- /doc/doxydoc/layout.ini: -------------------------------------------------------------------------------- 1 | # This file describes the structure of the documentation. 2 | # Use tabs at the beginning of the line to indicate the depth of a page. 3 | # The name used must match the name of the .dox file without extension 4 | # and the name used with the \page command. 5 | # Main page should not be part of this list. 6 | 7 | libraries 8 | libatomspace 9 | libattention 10 | libsmob 11 | libpersist 12 | fsstructure 13 | bldtargets 14 | otherwikis 15 | license 16 | -------------------------------------------------------------------------------- /doc/doxydoc/libhaskell.dox: -------------------------------------------------------------------------------- 1 | namespace opencog { 2 | /** 3 | 4 | \page libhaskell Haskell bindings library 5 | 6 | The library (opencog/haskell) implements Haskell bindings. 7 | Right now, it is automatically installed, but if you want to reinstall, 8 | go to opencog/haskell and run: 9 | @code 10 | stack build --extra-lib-dirs=/usr/local/lib/opencog 11 | @endcode 12 | 13 | For appropiate Haddock documentation on the haskell library look 14 | at: 15 | opencog-atomspace 16 | 17 | 18 | Dependencies: 19 | - haskell-atomspace library 20 | 21 | The wiki page describes both 22 | how to run it and the core functions that are provided. 23 | 24 | \if MARKER_TREE_START 25 | ignored by doxygen; used as markers for update-links.py; 26 | \endif 27 | 28 | 29 | 30 | 31 | 32 |
\ref libattention "Previous"\ref libpersist "Next"
33 | \if MARKER_TREE_END 34 | ignored by doxygen; used as markers for update-links.py; 35 | \endif 36 | */ 37 | } //~namespace opencog 38 | -------------------------------------------------------------------------------- /doc/doxydoc/libraries.dox: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | \page libraries Libraries 4 | 5 | This page groups the libraries that are being build by the project. 6 | 7 | \if MARKER_TREE_START 8 | ignored by doxygen; used as markers for update-links.py; 9 | \endif 10 | - \subpage libcogutil 11 | - \subpage libatomspace 12 | - \subpage libserver 13 | - \subpage libspatial 14 | - \subpage libspacetime 15 | - \subpage libattention 16 | - \subpage libsmob 17 | - \subpage libhaskell 18 | - \subpage libpersist 19 | - \subpage libcomboreduct 20 | 21 | 22 | 23 | 24 | 25 |
\ref index "Previous"\ref libcogutil "Next"
26 | \if MARKER_TREE_END 27 | ignored by doxygen; used as markers for update-links.py; 28 | \endif 29 | */ 30 | 31 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY (c++) 2 | ADD_SUBDIRECTORY (c++-guile) 3 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | AtomSpace Examples 2 | ------------------ 3 | 4 | This directory contains various examples and demos that illustrate 5 | what the AtomSpace is, and what it's capable of doing. You will 6 | want to go through the contents here, as written in the order below. 7 | By the end, you will have a very clear idea of what the AtomSpace is! 8 | 9 | * atomspace - Demos of all of the basic AtomSpace features and 10 | functions. VISIT THIS FIRST!! 11 | 12 | * pattern-matcher - Example code demonstrating the graph query system. 13 | It shows how to search for data that fits a pattern, 14 | how to search for patterns that fit the data, and 15 | how to trigger actions when these are found. 16 | 17 | * gearman - Using `gearman` for simple distributed processing. 18 | 19 | * python - Python usage examples. 20 | * haskell - Haskell usage examples. 21 | 22 | * c++ - Example CMakefile and demos for C++ code. 23 | * c++-guile - Creating guile wrappers for C++ code. 24 | -------------------------------------------------------------------------------- /examples/atomspace/basic.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; basic.scm -- Basic guile usage example! 3 | ; 4 | ; See `opencog/guile/README` or http://wiki.opencog.org/w/Scheme 5 | ; for additional documentation. 6 | ; 7 | ; If you have installed opencog, then start guile simply by saying 8 | ; "guile" at the bash prompt $. Otherwise, you will need to do this: 9 | ; 10 | ; $ guile -L opencog/scm -L build 11 | ; 12 | ; where "build" is where-ever you built opencog. 13 | ; 14 | ; Another possibility: add stuff to your ~/.guile file, for example: 15 | ; (add-to-load-path "/home/yourname/opencog/build") 16 | ; (add-to-load-path "/home/yourname/opencog/opencog/scm") 17 | ; 18 | 19 | (use-modules (opencog)) 20 | 21 | ; Create an atom and place it in the default AtomSpace. 22 | (ConceptNode "asdf") 23 | 24 | ; Access this newly created atom. 25 | (cog-node 'ConceptNode "asdf") 26 | 27 | ; Access an atom that does not exist. 28 | (cog-node 'ConceptNode "qwerty") 29 | 30 | ; Run the following REPL commands 31 | ; * Print a list of all (currently loaded) opencog functions. 32 | ; ,apropos cog 33 | 34 | ; * Get the documentation of a a given function 35 | ; ,describe cog-new-node 36 | ; ,describe cog-node 37 | -------------------------------------------------------------------------------- /examples/atomspace/my_py_func.py: -------------------------------------------------------------------------------- 1 | # 2 | # my_py_func.py -- Python callback example. 3 | # 4 | # This is a short python snippet that is needed by the `execute.scm` 5 | # example. The code below is called, when a GroundedSchemaNode and 6 | # a GroundedPredicateNode is triggered. 7 | # 8 | from opencog.atomspace import AtomSpace, TruthValue 9 | from opencog.atomspace import types 10 | 11 | asp = AtomSpace() 12 | 13 | # Python function taking two atoms, converting thier string-names to 14 | # floats, adding the floats, and returning a new atom holding the sum. 15 | def my_py_func(atoma, atomb): 16 | print('Python received two arguments:\n' + str(atoma) + str(atomb)) 17 | av = float(atoma.name) 18 | bv = float(atomb.name) 19 | cv = av + bv # Add numeric values! 20 | print('The sum is ' + str(cv)) 21 | return asp.add_node(types.ConceptNode, str(cv)) 22 | 23 | # Similar to the above, but returning a truth value. 24 | def my_py_predicate(atoma, atomb): 25 | print('Python predicate received two arguments:\n' + str(atoma) + str(atomb)) 26 | av = float(atoma.name) 27 | bv = float(atomb.name) 28 | TV = TruthValue(1.0/av, 1.0/bv) 29 | return TV 30 | -------------------------------------------------------------------------------- /examples/c++-guile/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}) 2 | 3 | ADD_EXECUTABLE(PrimitiveExample 4 | PrimitiveExample.cc 5 | ) 6 | 7 | TARGET_LINK_LIBRARIES(PrimitiveExample 8 | smob 9 | atomspace 10 | clearbox 11 | ) 12 | 13 | ADD_LIBRARY (example 14 | ExampleSCM.cc 15 | ) 16 | 17 | TARGET_LINK_LIBRARIES(example 18 | smob 19 | atomspace 20 | ) 21 | 22 | # This is what the install should look like. 23 | # INSTALL (TARGETS example DESTINATION "lib${LIB_DIR_SUFFIX}/opencog") 24 | # INSTALL (FILES opencog/example.scm DESTINATION "${GUILE_SITE_DIR}/opencog") 25 | -------------------------------------------------------------------------------- /examples/c++-guile/ExampleSCM.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ExampleSCM.h 3 | * 4 | * Simplified wrapper for creating guile modules. 5 | * Copyright (c) 2008, 2014, 2015 Linas Vepstas 6 | */ 7 | 8 | #ifndef _OPENCOG_EXAMPLE_SCM_H 9 | #define _OPENCOG_EXAMPLE_SCM_H 10 | 11 | #include 12 | 13 | namespace opencog { 14 | 15 | class ExampleSCM : public ModuleWrap 16 | { 17 | protected: 18 | virtual void init(void); 19 | static std::vector _binders; 20 | public: 21 | ExampleSCM(void); 22 | ~ExampleSCM(); 23 | }; 24 | 25 | } 26 | 27 | extern "C" { 28 | // This function will be called to initialize the module. 29 | void opencog_example_init(void); 30 | }; 31 | 32 | #endif // _OPENCOG_EXAMPLE_SCM_H 33 | -------------------------------------------------------------------------------- /examples/c++-guile/README.md: -------------------------------------------------------------------------------- 1 | 2 | C++ to Guile wrapper examples 3 | ----------------------------- 4 | 5 | The PrimitiveExample.cc file demonstrates how a C++ class can be 6 | wrapped by guile, so that the C++ methods become callable in guile. 7 | 8 | It is best if such wrappers are encapsulated in a guile module. 9 | The ExampleSCM.cc file demonstrates how to create a new guile 10 | module; the opencog/example.scm file shows how to set up that module. 11 | -------------------------------------------------------------------------------- /examples/c++-guile/opencog/example.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; OpenCog Example module 3 | ; 4 | 5 | ; This must be the same name as in the C++ code 6 | (define-module (opencog example)) 7 | 8 | ; This must be the C++ library, and the initialization routien to call. 9 | (load-extension "libexample" "opencog_example_init") 10 | -------------------------------------------------------------------------------- /examples/c++/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}) 2 | 3 | ADD_EXECUTABLE(basic 4 | basic.cc 5 | ) 6 | 7 | TARGET_LINK_LIBRARIES(basic 8 | atomspace 9 | ) 10 | 11 | # This is what the install should look like. 12 | # INSTALL (TARGETS example DESTINATION "lib${LIB_DIR_SUFFIX}/opencog") 13 | # INSTALL (FILES opencog/example.scm DESTINATION "${GUILE_SITE_DIR}/opencog") 14 | -------------------------------------------------------------------------------- /examples/c++/basic.cc: -------------------------------------------------------------------------------- 1 | // 2 | // examples/c++/basic.cc 3 | // 4 | // A basic example of creating Atoms in an AtomSpace. 5 | 6 | #include 7 | #include 8 | 9 | using namespace opencog; 10 | 11 | int main() 12 | { 13 | // Create a new AtomSpace. 14 | AtomSpace* as = new AtomSpace(); 15 | 16 | // Create a ConceptNode Atom, place it in the AtomSpace. 17 | as->add_atom(Concept("foobar")); 18 | 19 | // Print the atomspace contents. 20 | // Note that the unique Atom ID's (64-bit hashes) are printed. 21 | printf("So far its this: %s\n", as->to_string().c_str()); 22 | 23 | // Create an EvaluationLink Atom, place it in the AtomSpace. 24 | as->add_atom( 25 | Evaluation( 26 | Predicate("bling"), 27 | List( 28 | Concept("foo"), 29 | Concept("bar")))); 30 | 31 | printf("Now it is this: %s\n", as->to_string().c_str()); 32 | } 33 | -------------------------------------------------------------------------------- /examples/gearman/README.md: -------------------------------------------------------------------------------- 1 | # Minimal Gearman Example 2 | 3 | ## Description 4 | 5 | Gearman example to run a simple task in parallel. The task in question 6 | is `do-work` in file `task.scm`, some simple crushing number that 7 | takes about a second to complete. 8 | 9 | The goal is to use gearman to run 10 instances of this task in 10 | parallel across 3 workers. 11 | 12 | ## Usage 13 | 14 | Launch `worker-1.scm` to `worker-3.scm` in three terminals (using 15 | option -l of `guile`). 16 | 17 | Then launch `client.scm` in a fourth terminal. In should crash with 18 | message 19 | 20 | ``` 21 | _client_do(GEARMAN_ERRNO) occurred during gearman_client_run_ta_client_do(GEARMAN_ERRNO) occurred during gearman_client_run_tasks() -> libgearman/client.cc:212.cc:171_client_do(GEARMAN_ERRNO) occurred during gearman_client_run_tasks() -> libgearman/client.cc:212_client_do(GEARMAN_ERRNO) occurred during gearman_client_run_tasks() -> libgearman/client.cc:212Segmentation fault (core dumped) 22 | ``` 23 | 24 | If you replace `par-map` by `map` in `client.scm` then it doesn't 25 | crash, but doesn't execute the tasks in parallel either. 26 | 27 | The reason `par-map` is used is because `dist-eval` is blocking. I 28 | don't see another way to use more than one worker at a time. 29 | -------------------------------------------------------------------------------- /examples/gearman/client.scm: -------------------------------------------------------------------------------- 1 | (use-modules (opencog dist-gearman)) 2 | (use-modules (ice-9 threads)) 3 | 4 | (define (send-work x) (dist-eval "(do-work 120 120)" "client")) 5 | (define result (par-map send-work (iota 10))) 6 | 7 | ;; (exit-all-workers) 8 | -------------------------------------------------------------------------------- /examples/gearman/task.scm: -------------------------------------------------------------------------------- 1 | (define (do-work-rec x y) (+ x y (if (< 0 x) 2 | (if (< 0 y) 3 | (do-work-rec x (- y 1)) 4 | (do-work-rec (- x 1) x)) 5 | 0))) 6 | (define (do-work x y) (Concept (string-concatenate 7 | (map number->string (iota (do-work-rec x y)))))) 8 | -------------------------------------------------------------------------------- /examples/gearman/worker-1.scm: -------------------------------------------------------------------------------- 1 | (use-modules (opencog dist-gearman)) 2 | (use-modules (srfi srfi-1)) 3 | 4 | (load "task.scm") 5 | 6 | (start-work-handler "localhost" "worker-1") 7 | -------------------------------------------------------------------------------- /examples/gearman/worker-2.scm: -------------------------------------------------------------------------------- 1 | (use-modules (opencog dist-gearman)) 2 | (use-modules (srfi srfi-1)) 3 | 4 | (load "task.scm") 5 | 6 | (start-work-handler "localhost" "worker-2") 7 | -------------------------------------------------------------------------------- /examples/gearman/worker-3.scm: -------------------------------------------------------------------------------- 1 | (use-modules (opencog dist-gearman)) 2 | (use-modules (srfi srfi-1)) 3 | 4 | (load "task.scm") 5 | 6 | (start-work-handler "localhost" "worker-3") 7 | -------------------------------------------------------------------------------- /examples/haskell/README.md: -------------------------------------------------------------------------------- 1 | Haskell Examples: 2 | ================ 3 | 4 | To run these examples you have to previously 5 | [build](https://github.com/opencog/atomspace#building-atomspace) and 6 | [install](https://github.com/opencog/atomspace#install) the AtomSpace. 7 | 8 | Set the stack environment with: 9 | ``` 10 | export STACK_YAML=/opencog/haskell/stack.yaml 11 | ``` 12 | Then you can just compile them with: 13 | ``` 14 | stack ghc example.hs 15 | ``` 16 | 17 | To use GHCi: 18 | 19 | ``` 20 | export STACK_YAML=/opencog/haskell/stack.yaml 21 | stack ghci --ghc-options -lhaskell-atomspace 22 | ``` 23 | 24 | If when running an example you get an error: "...cannont open shared object 25 | file: No such file or directory ...": 26 | - Remember to add: "/usr/local/lib/opencog" to your */etc/ld.so.conf* file. 27 | - Check if the file: */usr/local/lib/opencog/libhaskell-atomspace.so* exists. 28 | - To update loader's cache, run: 29 | ``` 30 | sudo ldconfig /usr/local/lib/opencog/ 31 | ``` 32 | 33 | -------------------------------------------------------------------------------- /examples/haskell/example_multiple_atoms.hs: -------------------------------------------------------------------------------- 1 | -- GSoC 2015 - Haskell bindings for OpenCog. 2 | {-# LANGUAGE GADTs #-} 3 | {-# LANGUAGE DataKinds #-} 4 | 5 | -- | Simple example on inserting and removing many atoms in a new AtomSpace. 6 | import OpenCog.AtomSpace (TruthVal(..),Atom(..),AtomSpace, 7 | runOnNewAtomSpace,get,insert,remove, 8 | debug,printAtom,noTv,stv) 9 | import Control.Monad.IO.Class (liftIO) 10 | 11 | conceptN :: Int -> Atom 12 | conceptN i = Node "ConceptNode" ("Animal"++ show i) (stv 1 1) 13 | 14 | main :: IO () 15 | main = runOnNewAtomSpace $ do 16 | let listConcepts :: Int -> [Atom] 17 | listConcepts n = [conceptN i | i <- [1..n]] 18 | mapM insert $ listConcepts 50000 19 | res <- get $ conceptN 49877 20 | liftIO $ putStrLn $ "We found: " ++ show res 21 | mapM remove $ listConcepts 50000 22 | debug 23 | insert $ Link "ListLink" 24 | [Link "ListLink" (listConcepts 200) noTv 25 | ,Link "ListLink" (listConcepts 200) noTv 26 | ] noTv 27 | debug 28 | return () 29 | 30 | -------------------------------------------------------------------------------- /examples/python/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Cosmo Harrigan' 2 | -------------------------------------------------------------------------------- /examples/python/create_atoms_by_type.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | # 3 | # create_atoms_by_type.py 4 | # 5 | """ 6 | Simple example of how to create atoms in the AtomSpace. 7 | See also create_atomspace_simple.py for an alternate interface. 8 | """ 9 | 10 | from opencog.atomspace import AtomSpace, Atom 11 | from opencog.type_constructors import TruthValue 12 | from opencog.atomspace import types 13 | 14 | a = AtomSpace() 15 | 16 | # Create a truth value asserting true and mostly confident. 17 | TV = TruthValue(1, 0.8) 18 | 19 | # Add three nodes 20 | concept_type = types.ConceptNode 21 | A = a.add_node(concept_type, 'Apple', TV) 22 | B = a.add_node(concept_type, 'Berry', TruthValue(0.5, 0.75)) 23 | C = a.add_node(concept_type, 'Comestible', TV) 24 | 25 | # Add three inhertance links, asserting that apples are berries 26 | # and that berries are edible. 27 | inh_type = types.InheritanceLink 28 | AB = a.add_link(inh_type, [A, B], TV) 29 | BC = a.add_link(inh_type, [B, C], TV) 30 | AC = a.add_link(inh_type, [A, C]) 31 | 32 | 33 | print("The atomspace contains:\n\n", a.get_atoms_by_type(types.Atom)) 34 | -------------------------------------------------------------------------------- /examples/python/create_atoms_simple.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | # 3 | # create_atoms_simple.py 4 | # 5 | """ 6 | A simple way of creating atoms in the AtomSpace. 7 | See also create_stoms_by_type.py for an alternate API for atoms. 8 | """ 9 | 10 | from opencog.atomspace import AtomSpace, TruthValue 11 | from opencog.atomspace import types 12 | from opencog.type_constructors import * 13 | 14 | a = AtomSpace() 15 | 16 | # Tell the type constructors which atomspace to use. 17 | set_default_atomspace(a) 18 | 19 | # Create a truth value asserting true and mostly confident. 20 | TV = TruthValue(1, 0.8) 21 | 22 | # Add three nodes 23 | A = ConceptNode('Apple', TV) 24 | B = ConceptNode('Berry', TruthValue(0.5, 0.75)) 25 | C = ConceptNode('Comestible', TV) 26 | 27 | # Add three inhertance links, asserting that apples are berries 28 | # and that berries are edible. 29 | AB = InheritanceLink(A, B, tv=TV) 30 | BC = InheritanceLink(B, C, tv=TV) 31 | AC = InheritanceLink(A, C) 32 | 33 | 34 | print("The atomspace contains:\n\n", a.get_atoms_by_type(types.Atom)) 35 | -------------------------------------------------------------------------------- /examples/python/get_outgoings.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | # 3 | # get_outgoings.py 4 | # 5 | """ 6 | A simple example of how to access the outgoing set of a link. 7 | """ 8 | 9 | from opencog.atomspace import AtomSpace, TruthValue 10 | from opencog.atomspace import types 11 | from opencog.type_constructors import * 12 | 13 | a = AtomSpace() 14 | 15 | # Tell the type constructors which atomspace to use. 16 | set_default_atomspace(a) 17 | 18 | # Add three nodes 19 | A = ConceptNode('Apple') 20 | B = ConceptNode('Berry') 21 | C = ConceptNode('Cherry') 22 | 23 | # Add list link 24 | ABC = ListLink(A, B, C) 25 | 26 | # Get the outgoing set of ABC 27 | print("The outgoing set of ABC:\n\n", ABC.out) 28 | -------------------------------------------------------------------------------- /examples/python/ground/mymodule.py: -------------------------------------------------------------------------------- 1 | def mod_func(x1, x2, x3): 2 | print("Entering mymodule function with\n", x1, x2, x3); 3 | return x1 4 | 5 | class SubModule: 6 | def forward(self, x1, x2): 7 | print("Entering mymodule SubModule with\n", x1, x2) 8 | return x2 9 | 10 | class NNModule: 11 | def __init__(self): 12 | self.submodule = SubModule(); 13 | 14 | nn = NNModule() 15 | -------------------------------------------------------------------------------- /examples/python/is_a.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | # 3 | # is_a.py 4 | # 5 | """ 6 | A simple example of how to use the nameserver. 7 | """ 8 | 9 | from opencog.atomspace import AtomSpace 10 | from opencog.atomspace import get_type, is_a 11 | from opencog.atomspace import types 12 | from opencog.type_constructors import * 13 | 14 | a = AtomSpace() 15 | 16 | # Tell the type constructors which atomspace to use. 17 | set_default_atomspace(a) 18 | 19 | # Is a set unordered 20 | set_is_unordered = is_a(get_type("SetLink"), get_type("UnorderedLink")) 21 | print("Is a set unordered?", set_is_unordered) 22 | 23 | # Is A a concept or a predicate? 24 | A = ConceptNode("A") 25 | print("Is A a concept?", is_a(A.type, get_type("ConceptNode"))) 26 | print("Is A a predicate?", is_a(A.type, get_type("PredicateNode"))) 27 | -------------------------------------------------------------------------------- /examples/python/scheme/atom_type_names.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | # 3 | # atom_type_names.py 4 | # 5 | """ 6 | Example of how to obtain atom type names and atom type IDs in Python 7 | """ 8 | 9 | __author__ = 'Cosmo Harrigan' 10 | 11 | from opencog.atomspace import AtomSpace, types, get_type_name 12 | 13 | atomspace = AtomSpace() 14 | 15 | atom = atomspace.add(types.ConceptNode, "Frog #1") 16 | 17 | # To get one type name 18 | print(get_type_name(3) + '\n') 19 | 20 | # To get one atom's type name 21 | print(get_type_name(atom.type) + '\n') 22 | 23 | # Get a list of all possible type names and numbers 24 | for key, value in sorted(types.__dict__.items()): 25 | if '__' not in key: 26 | print(key, value) 27 | -------------------------------------------------------------------------------- /examples/python/scheme/scheme_timer.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | """ 4 | Checks the execution time of repeated calls to the Scheme API from Python 5 | 6 | Runs an empty Scheme command NUMBER_OF_ITERATIONS times and displays the 7 | total execution time 8 | """ 9 | 10 | __author__ = 'Cosmo Harrigan' 11 | 12 | from opencog.atomspace import AtomSpace, TruthValue 13 | from opencog.scheme_wrapper import scheme_eval, scheme_eval_h 14 | atomspace = AtomSpace() 15 | 16 | NUMBER_OF_ITERATIONS = 50000 17 | 18 | def test_operation(): 19 | for i in range(NUMBER_OF_ITERATIONS): 20 | # scheme_eval(atomspace, '(+ 2 2)') 21 | scheme_eval_h(atomspace, '(Concept "foo")') 22 | # scheme_eval_h(atomspace, '(Number ' + str(i) + ')') 23 | 24 | import timeit 25 | elapsed = timeit.timeit("test_operation()", 26 | setup="from __main__ import test_operation", 27 | number=1) 28 | 29 | def report(): 30 | print ("{0} seconds elapsed performing {1} repeated calls = {2} calls / sec".\ 31 | format(elapsed, NUMBER_OF_ITERATIONS, NUMBER_OF_ITERATIONS / elapsed)) 32 | 33 | report() 34 | -------------------------------------------------------------------------------- /examples/python/values.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | # 3 | # values.py 4 | # 5 | """ 6 | An example of using values via Python API 7 | """ 8 | 9 | from opencog.atomspace import AtomSpace, TruthValue 10 | from opencog.type_constructors import * 11 | from opencog.scheme_wrapper import scheme_eval_v 12 | 13 | atomspace = AtomSpace() 14 | set_default_atomspace(atomspace) 15 | 16 | a = FloatValue([1.0, 2.0, 3.0]) 17 | b = FloatValue([1.0, 2.0, 3.0]) 18 | c = FloatValue(1.0) 19 | print('{} == {}: {}'.format(a, b, a == b)) 20 | print('{} == {}: {}'.format(a, c, a == c)) 21 | 22 | featureValue = FloatValue([1.0, 2]) 23 | print('new value created: {}'.format(featureValue)) 24 | 25 | boundingBox = ConceptNode('boundingBox') 26 | featureKey = PredicateNode('features') 27 | 28 | boundingBox.set_value(featureKey, featureValue) 29 | print('set value to atom: {}'.format(boundingBox)) 30 | 31 | value = boundingBox.get_value(featureKey) 32 | print('get value from atom: {}'.format(value)) 33 | 34 | list = value.to_list() 35 | print('get python list from value: {}'.format(list)) 36 | 37 | value = scheme_eval_v(atomspace, '(ValueOf (ConceptNode "boundingBox") ' 38 | '(PredicateNode "features"))') 39 | value = boundingBox.get_value(featureKey) 40 | print('get value from atom using Scheme program: {}'.format(value)) 41 | -------------------------------------------------------------------------------- /lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Create a test configuration file by copying the default config file 3 | # 4 | CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/lib/atomspace-test.conf 5 | ${PROJECT_BINARY_DIR}/lib/atomspace-test.conf) 6 | 7 | # build_type is used in AtomSpaceConfig.cmake.in 8 | string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type ) 9 | 10 | export(EXPORT AtomSpaceTargets 11 | FILE "${CMAKE_CURRENT_BINARY_DIR}/AtomSpace/AtomSpaceTargets.cmake" 12 | ) 13 | 14 | set(ConfigPackageLocation lib/cmake/AtomSpace) 15 | 16 | install(EXPORT AtomSpaceTargets 17 | FILE AtomSpaceTargets.cmake 18 | DESTINATION ${ConfigPackageLocation} 19 | ) 20 | 21 | include(CMakePackageConfigHelpers) 22 | 23 | configure_package_config_file(AtomSpaceConfig.cmake.in 24 | ${CMAKE_CURRENT_BINARY_DIR}/AtomSpaceConfig.cmake 25 | INSTALL_DESTINATION lib/AtomSpace/cmake 26 | PATH_VARS CMAKE_INSTALL_PREFIX 27 | ) 28 | 29 | write_basic_package_version_file( 30 | "${CMAKE_CURRENT_BINARY_DIR}/AtomSpaceConfigVersion.cmake" 31 | VERSION ${SEMANTIC_VERSION} 32 | COMPATIBILITY SameMajorVersion 33 | ) 34 | 35 | INSTALL(FILES 36 | ${CMAKE_CURRENT_BINARY_DIR}/AtomSpaceConfigVersion.cmake 37 | ${CMAKE_CURRENT_BINARY_DIR}/AtomSpaceConfig.cmake 38 | DESTINATION ${ConfigPackageLocation} 39 | ) 40 | -------------------------------------------------------------------------------- /lib/README.md: -------------------------------------------------------------------------------- 1 | 2 | How to use Valgrind suppressions 3 | -------------------------------- 4 | Using valgrind with opencog can be tricky, because many spurious messages 5 | are created. These can be suppressed with suppression files, like so: 6 | ``` 7 | valgrind --suppressions=../lib/valgrind.guile.suppressions \ 8 | --suppressions=../lib/valgrind.python.suppressions \ 9 | --suppressions=../lib/valgrind.boost.suppressions \ 10 | --suppressions=../lib/valgrind.logger.suppressions \ 11 | --suppressions=../lib/valgrind.link-grammar.suppressions \ 12 | 13 | ``` 14 | where `` is probably `opencog/server/cogserver` 15 | 16 | Memory leaks: `valgrind --leak-check=full` 17 | 18 | Memory non-leaks: `valgrind --leak-check=full --show-leak-kinds=all` 19 | 20 | Memory profile: `valgrind --tool=massif` 21 | 22 | CPU profile: `valgrind --tool=callgrind` 23 | 24 | then: `callgrind_annotate callgrind.out.nnnn` 25 | -------------------------------------------------------------------------------- /lib/atomspace-test.conf: -------------------------------------------------------------------------------- 1 | # This is an example config file for various opencog unit tests. 2 | # You should fill in the appropriate details. 3 | # 4 | # This config file is used by various opencog unit tests. 5 | # Of particular importance is the test database name and login credentials. 6 | 7 | # IMPORTANT! 8 | # Database login credentials. Uncomment and change these to reflect your actual 9 | # setup! 10 | # 11 | TEST_DB_NAME = "opencog_test" 12 | TEST_DB_USERNAME = "opencog_tester" 13 | TEST_DB_PASSWD = "cheese" 14 | -------------------------------------------------------------------------------- /lib/valgrind.boost.suppressions: -------------------------------------------------------------------------------- 1 | 2 | { 3 | 4 | Memcheck:Cond 5 | ... 6 | fun:_ZN5boost6detail12lexical_castISsdLb0EcEET_NS_11call_traitsIT0_E10param_typeEPT2_m 7 | ... 8 | } 9 | { 10 | 11 | Memcheck:Value8 12 | ... 13 | fun:_ZN5boost6detail12lexical_castISsdLb0EcEET_NS_11call_traitsIT0_E10param_typeEPT2_m 14 | ... 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /lib/valgrind.link-grammar.suppressions: -------------------------------------------------------------------------------- 1 | { 2 | 3 | Memcheck:Cond 4 | ... 5 | fun:pp_knowledge_open 6 | ... 7 | } 8 | -------------------------------------------------------------------------------- /lib/valgrind.logger.suppressions: -------------------------------------------------------------------------------- 1 | { 2 | 3 | Memcheck:Cond 4 | ... 5 | fun:_ZN7opencog6Logger5logvaENS0_5LevelEPKcP13__va_list_tag 6 | ... 7 | } 8 | { 9 | 10 | Memcheck:Addr1 11 | ... 12 | fun:_ZN7opencog6Logger5logvaENS0_5LevelEPKcP13__va_list_tag 13 | ... 14 | } 15 | { 16 | 17 | Memcheck:Addr2 18 | ... 19 | fun:_ZN7opencog6Logger5logvaENS0_5LevelEPKcP13__va_list_tag 20 | ... 21 | } 22 | { 23 | 24 | Memcheck:Addr4 25 | ... 26 | fun:_ZN7opencog6Logger5logvaENS0_5LevelEPKcP13__va_list_tag 27 | ... 28 | } 29 | { 30 | 31 | Memcheck:Addr8 32 | ... 33 | fun:_ZN7opencog6Logger5logvaENS0_5LevelEPKcP13__va_list_tag 34 | ... 35 | } 36 | { 37 | 38 | Memcheck:Cond 39 | ... 40 | fun:_ZN7opencog6Logger11writingLoopEv 41 | fun:thread_proxy 42 | fun:start_thread 43 | fun:clone 44 | } 45 | { 46 | 47 | Helgrind:Misc 48 | ... 49 | fun:_ZNSt18condition_variable10notify_oneEv 50 | fun:push 51 | fun:qmsg 52 | ... 53 | fun:_ZN7opencog6Logger5logvaENS0_5LevelEPKcP13__va_list_tag 54 | ... 55 | } 56 | -------------------------------------------------------------------------------- /opencog/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # The atom_types.h file is written to the build directory 3 | INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}) 4 | 5 | DECLARE_GUILE_CONFIG_TARGET(SCM_CONFIG "opencog as-config" "ATOMSPACE_TEST") 6 | 7 | # The build order used here is loosely in terms of 8 | # dependencies: the later parts depend on, or may 9 | # someday depend on the earlier parts. 10 | # 11 | ADD_SUBDIRECTORY (atoms) 12 | ADD_SUBDIRECTORY (atomspace) 13 | ADD_SUBDIRECTORY (eval) 14 | ADD_SUBDIRECTORY (query) 15 | ADD_SUBDIRECTORY (persist) 16 | 17 | # Extension language support 18 | IF (HAVE_GUILE) 19 | ADD_SUBDIRECTORY (guile) 20 | ADD_SUBDIRECTORY (scm) 21 | ADD_SUBDIRECTORY (matrix) 22 | ADD_SUBDIRECTORY (sheaf) 23 | ENDIF (HAVE_GUILE) 24 | 25 | IF (HAVE_CYTHON) 26 | ADD_SUBDIRECTORY (cython) 27 | ENDIF (HAVE_CYTHON) 28 | 29 | # Haskell bindings. 30 | IF (HAVE_STACK) 31 | ADD_SUBDIRECTORY (haskell) 32 | ENDIF (HAVE_STACK) 33 | 34 | WRITE_GUILE_CONFIG(${GUILE_BIN_DIR}/opencog/as-config.scm SCM_CONFIG TRUE) 35 | 36 | WRITE_GUILE_CONFIG(${GUILE_BIN_DIR}/opencog/as-config-installable.scm SCM_CONFIG FALSE) 37 | INSTALL(FILES ${GUILE_BIN_DIR}/opencog/as-config-installable.scm DESTINATION ${GUILE_SITE_DIR}/opencog RENAME as-config.scm) 38 | -------------------------------------------------------------------------------- /opencog/atoms/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY (atom_types) 2 | ADD_SUBDIRECTORY (value) 3 | ADD_SUBDIRECTORY (base) 4 | ADD_SUBDIRECTORY (core) 5 | ADD_SUBDIRECTORY (container) 6 | ADD_SUBDIRECTORY (flow) 7 | ADD_SUBDIRECTORY (execution) 8 | ADD_SUBDIRECTORY (grounded) 9 | ADD_SUBDIRECTORY (parallel) 10 | ADD_SUBDIRECTORY (pattern) 11 | ADD_SUBDIRECTORY (reduct) 12 | ADD_SUBDIRECTORY (truthvalue) 13 | -------------------------------------------------------------------------------- /opencog/atoms/atom_types/atom_types.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * atom_types.cc 3 | * 4 | * Generic Atom Types declaration 5 | * 6 | * Copyright (c) 2009, 2014 Linas Vepstas 7 | */ 8 | 9 | // library initialization 10 | 11 | static __attribute__ ((constructor)) void init(void) 12 | { 13 | #define str(x) #x 14 | #define xstr(x) str(x) 15 | 16 | bool is_init = opencog::nameserver().beginTypeDecls(xstr(INITNAME)); 17 | if (is_init) return; 18 | 19 | #include INHERITANCE_FILE 20 | #ifdef INHERITANCE_FILE2 21 | #include INHERITANCE_FILE2 22 | #endif 23 | opencog::nameserver().endTypeDecls(); 24 | 25 | // Backwards compat. Argh... 26 | opencog::TYPE_SET_LINK = opencog::TYPE_INTERSECTION_LINK; 27 | } 28 | 29 | static __attribute__ ((destructor)) void fini(void) 30 | { 31 | } 32 | 33 | extern "C" { 34 | // Calling this forces this shared-lib to load, thus calling the 35 | // constructor above, thus causing the atom types to be loaded into 36 | // the atomspace. 37 | void INITNAME(void) 38 | { 39 | /* No-op */ 40 | } 41 | }; 42 | -------------------------------------------------------------------------------- /opencog/atoms/atom_types/atom_types_init.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * atom_types_init.cc 3 | * 4 | * Copyright (C) 2014 Linas Vepstas 5 | * All Rights Reserved 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License v3 as 9 | * published by the Free Software Foundation and including the exceptions 10 | * at http://opencog.org/wiki/Licenses 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program; if not, write to: 19 | * Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | #include "opencog/atoms/atom_types/atom_types.definitions" 24 | 25 | // Backwards-compat. Argh... 26 | opencog::Type opencog::TYPE_SET_LINK; 27 | 28 | #define INHERITANCE_FILE "opencog/atoms/atom_types/atom_types.inheritance" 29 | #define INITNAME base_types_init 30 | 31 | #include 32 | -------------------------------------------------------------------------------- /opencog/atoms/base/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # The atom_types.h file is written to the build directory 3 | INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}) 4 | 5 | ADD_LIBRARY (atombase 6 | Atom.cc 7 | ClassServer.cc 8 | Handle.cc 9 | Link.cc 10 | Node.cc 11 | Valuation.cc 12 | ) 13 | 14 | # Without this, parallel make will race and crap up the generated files. 15 | ADD_DEPENDENCIES(atombase opencog_atom_types value) 16 | 17 | TARGET_LINK_LIBRARIES(atombase 18 | atom_types 19 | value 20 | truthvalue 21 | ${COGUTIL_LIBRARY} 22 | ) 23 | 24 | INSTALL (TARGETS atombase EXPORT AtomSpaceTargets 25 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog" 26 | ) 27 | 28 | INSTALL (FILES 29 | Atom.h 30 | ClassServer.h 31 | Handle.h 32 | Link.h 33 | Node.h 34 | Valuation.h 35 | DESTINATION "include/opencog/atoms/base" 36 | ) 37 | -------------------------------------------------------------------------------- /opencog/atoms/container/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # The atom_types.h file is written to the build directory 3 | INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}) 4 | 5 | ADD_LIBRARY (container 6 | JoinLink.cc 7 | ) 8 | 9 | # Without this, parallel make will race and crap up the generated files. 10 | ADD_DEPENDENCIES(container opencog_atom_types) 11 | 12 | TARGET_LINK_LIBRARIES(container 13 | atomcore 14 | atombase 15 | ${COGUTIL_LIBRARY} 16 | ) 17 | 18 | INSTALL (TARGETS container EXPORT AtomSpaceTargets 19 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog" 20 | ) 21 | 22 | INSTALL (FILES 23 | JoinLink.h 24 | DESTINATION "include/opencog/atoms/container" 25 | ) 26 | -------------------------------------------------------------------------------- /opencog/atoms/core/TypeNode.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * opencog/atoms/core/TypeNode.cc 3 | * 4 | * Copyright (C) 2015 Linas Vepstas 5 | * All Rights Reserved 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License v3 as 9 | * published by the Free Software Foundation and including the exceptions 10 | * at http://opencog.org/wiki/Licenses 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program; if not, write to: 19 | * Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | #include "TypeNode.h" 24 | 25 | using namespace opencog; 26 | 27 | DEFINE_NODE_FACTORY(TypeNode, TYPE_NODE) 28 | -------------------------------------------------------------------------------- /opencog/atoms/execution/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # The atom_types.h file is written to the build directory 3 | INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}) 4 | 5 | ADD_LIBRARY (execution 6 | Force.cc 7 | EvaluationLink.cc 8 | ExecutionOutputLink.cc 9 | Instantiator.cc 10 | ApplyLink.cc 11 | GroundedObjectNode.cc 12 | MethodOfLink.cc 13 | ) 14 | 15 | # Without this, parallel make will race and crap up the generated files. 16 | ADD_DEPENDENCIES(execution opencog_atom_types) 17 | 18 | TARGET_LINK_LIBRARIES(execution 19 | parallel 20 | clearbox 21 | atomflow 22 | atomcore 23 | atombase 24 | ) 25 | 26 | INSTALL (TARGETS execution 27 | EXPORT AtomSpaceTargets 28 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog") 29 | 30 | INSTALL (FILES 31 | EvaluationLink.h 32 | ExecutionOutputLink.h 33 | Force.h 34 | GroundedProcedureNode.h 35 | Instantiator.h 36 | ApplyLink.h 37 | GroundedObject.h 38 | GroundedObjectNode.h 39 | GroundedFunctionLink.h 40 | MethodOfLink.h 41 | DESTINATION "include/opencog/atoms/execution" 42 | ) 43 | -------------------------------------------------------------------------------- /opencog/atoms/flow/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # The atom_types.h file is written to the build directory 3 | INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}) 4 | 5 | ADD_LIBRARY (atomflow 6 | PredicateFormulaLink.cc 7 | SetTVLink.cc 8 | SetValueLink.cc 9 | StreamValueOfLink.cc 10 | TruthValueOfLink.cc 11 | ValueOfLink.cc 12 | ) 13 | 14 | # Without this, parallel make will race and crap up the generated files. 15 | ADD_DEPENDENCIES(atomflow opencog_atom_types) 16 | 17 | TARGET_LINK_LIBRARIES(atomflow 18 | atomcore 19 | atombase 20 | ${COGUTIL_LIBRARY} 21 | ) 22 | 23 | INSTALL (TARGETS atomflow EXPORT AtomSpaceTargets 24 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog" 25 | ) 26 | 27 | INSTALL (FILES 28 | PredicateFormulaLink.h 29 | SetTVLink.h 30 | SetValueLink.h 31 | StreamValueOfLink.h 32 | TruthValueOfLink.h 33 | ValueOfLink.h 34 | DESTINATION "include/opencog/atoms/flow" 35 | ) 36 | -------------------------------------------------------------------------------- /opencog/atoms/grounded/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # The atom_types.h file is written to the build directory 3 | INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}) 4 | 5 | ADD_LIBRARY (grounded 6 | DLScheme.cc 7 | GroundedPredicateNode.cc 8 | GroundedSchemaNode.cc 9 | LibraryManager.cc 10 | LibraryRunner.cc 11 | SCMRunner.cc 12 | ) 13 | 14 | IF (HAVE_CYTHON) 15 | INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) 16 | TARGET_SOURCES(grounded PRIVATE DLPython.cc) 17 | TARGET_SOURCES(grounded PRIVATE PythonRunner.cc) 18 | ENDIF (HAVE_CYTHON) 19 | 20 | # Without this, parallel make will race and crap up the generated files. 21 | ADD_DEPENDENCIES(grounded opencog_atom_types) 22 | 23 | TARGET_LINK_LIBRARIES(grounded 24 | atombase 25 | ) 26 | 27 | INSTALL (TARGETS grounded 28 | EXPORT AtomSpaceTargets 29 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog") 30 | 31 | INSTALL (FILES 32 | GroundedPredicateNode.h 33 | GroundedSchemaNode.h 34 | LibraryManager.h 35 | DESTINATION "include/opencog/atoms/grounded" 36 | ) 37 | -------------------------------------------------------------------------------- /opencog/atoms/grounded/DLPython.h: -------------------------------------------------------------------------------- 1 | /* 2 | * opencog/atoms/execution/DLPython.h 3 | * 4 | * Copyright (C) 2019 Linas Vepstas 5 | * All Rights Reserved 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License v3 as 9 | * published by the Free Software Foundation and including the exceptions 10 | * at http://opencog.org/wiki/Licenses 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program; if not, write to: 19 | * Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | #ifndef _OPENCOG_DL_PYTHON_H 24 | #define _OPENCOG_DL_PYTHON_H 25 | 26 | namespace opencog 27 | { 28 | class AtomSpace; 29 | class PythonEval; 30 | PythonEval* get_evaluator_for_python(AtomSpace*); 31 | } 32 | 33 | #endif // _OPENCOG_DL_PYTHON_H 34 | -------------------------------------------------------------------------------- /opencog/atoms/grounded/DLScheme.h: -------------------------------------------------------------------------------- 1 | /* 2 | * opencog/atoms/execution/DLScheme.h 3 | * 4 | * Copyright (C) 2019 Linas Vepstas 5 | * All Rights Reserved 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License v3 as 9 | * published by the Free Software Foundation and including the exceptions 10 | * at http://opencog.org/wiki/Licenses 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program; if not, write to: 19 | * Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | #ifndef _OPENCOG_DL_SCHEME_H 24 | #define _OPENCOG_DL_SCHEME_H 25 | 26 | #include 27 | 28 | namespace opencog 29 | { 30 | SchemeEval* get_evaluator_for_scheme(AtomSpace*); 31 | } 32 | 33 | #endif // _OPENCOG_DL_SCHEME_H 34 | -------------------------------------------------------------------------------- /opencog/atoms/parallel/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # The atom_types.h file is written to the build directory 3 | INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}) 4 | 5 | ADD_LIBRARY (parallel 6 | ExecuteThreadedLink.cc 7 | ParallelLink.cc 8 | ThreadJoinLink.cc 9 | ) 10 | 11 | # Without this, parallel make will race and crap up the generated files. 12 | ADD_DEPENDENCIES(parallel opencog_atom_types) 13 | 14 | TARGET_LINK_LIBRARIES(parallel 15 | atomcore 16 | atombase 17 | ) 18 | 19 | INSTALL (TARGETS parallel 20 | EXPORT AtomSpaceTargets 21 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog") 22 | 23 | INSTALL (FILES 24 | ExecuteThreadedLink.h 25 | ParallelLink.h 26 | ThreadJoinLink.h 27 | DESTINATION "include/opencog/atoms/parallel" 28 | ) 29 | -------------------------------------------------------------------------------- /opencog/atoms/pattern/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # The atom_types.h file is written to the build directory 3 | INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}) 4 | 5 | ADD_LIBRARY (pattern 6 | BindLink.cc 7 | DualLink.cc 8 | GetLink.cc 9 | MeetLink.cc 10 | PatternJit.cc 11 | PatternLink.cc 12 | PatternTerm.cc 13 | PatternUtils.cc 14 | Pattern.cc 15 | QueryLink.cc 16 | SatisfactionLink.cc 17 | ) 18 | 19 | # Without this, parallel make will race and crap up the generated files. 20 | ADD_DEPENDENCIES(pattern opencog_atom_types) 21 | 22 | # TARGET_COMPILE_OPTIONS(pattern PRIVATE -DQDEBUG=1) 23 | 24 | TARGET_LINK_LIBRARIES(pattern 25 | query-engine 26 | atomcore 27 | atombase 28 | ${COGUTIL_LIBRARY} 29 | ) 30 | 31 | INSTALL (TARGETS pattern EXPORT AtomSpaceTargets 32 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog" 33 | ) 34 | 35 | INSTALL (FILES 36 | BindLink.h 37 | DualLink.h 38 | GetLink.h 39 | MeetLink.h 40 | PatternLink.h 41 | Pattern.h 42 | PatternTerm.h 43 | PatternUtils.h 44 | QueryLink.h 45 | SatisfactionLink.h 46 | DESTINATION "include/opencog/atoms/pattern" 47 | ) 48 | -------------------------------------------------------------------------------- /opencog/atoms/reduct/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # The atom_types.h file is written to the build directory 3 | INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}) 4 | 5 | ADD_LIBRARY (clearbox 6 | AccumulateLink.cc 7 | ArithmeticLink.cc 8 | DivideLink.cc 9 | FoldLink.cc 10 | HeavisideLink.cc 11 | MaxLink.cc 12 | MinLink.cc 13 | MinusLink.cc 14 | PlusLink.cc 15 | TimesLink.cc 16 | ) 17 | 18 | # Without this, parallel make will race and crap up the generated files. 19 | ADD_DEPENDENCIES(clearbox opencog_atom_types) 20 | 21 | TARGET_LINK_LIBRARIES(clearbox 22 | atom_types 23 | atomcore 24 | atombase 25 | value 26 | ${COGUTIL_LIBRARY} 27 | ) 28 | 29 | INSTALL (TARGETS clearbox EXPORT AtomSpaceTargets 30 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog" 31 | ) 32 | 33 | INSTALL (FILES 34 | AccumulateLink.h 35 | ArithmeticLink.h 36 | DivideLink.h 37 | FoldLink.h 38 | HeavisideLink.h 39 | MaxLink.h 40 | MinLink.h 41 | MinusLink.h 42 | PlusLink.h 43 | TimesLink.h 44 | DESTINATION "include/opencog/atoms/reduct" 45 | ) 46 | -------------------------------------------------------------------------------- /opencog/atoms/reduct/MaxLink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * opencog/atoms/reduct/MaxLink.h 3 | * 4 | * Copyright (C) 2020 Linas Vepstas 5 | * All Rights Reserved 6 | * SPDX-License-Identifier: AGPL-3.0-or-later 7 | */ 8 | 9 | #ifndef _OPENCOG_MAX_LINK_H 10 | #define _OPENCOG_MAX_LINK_H 11 | 12 | #include 13 | 14 | namespace opencog 15 | { 16 | /** \addtogroup grp_atomspace 17 | * @{ 18 | */ 19 | 20 | /** 21 | * The MaxLink implements the arithmetic operation of "greatest of" 22 | * on a component-by-component level. 23 | */ 24 | class MaxLink : public FunctionLink 25 | { 26 | protected: 27 | void init(void); 28 | 29 | public: 30 | MaxLink(const HandleSeq&&, Type=MAX_LINK); 31 | 32 | MaxLink(const MaxLink&) = delete; 33 | MaxLink& operator=(const MaxLink&) = delete; 34 | 35 | virtual ValuePtr execute(AtomSpace*, bool); 36 | 37 | static Handle factory(const Handle&); 38 | }; 39 | 40 | typedef std::shared_ptr MaxLinkPtr; 41 | static inline MaxLinkPtr MaxLinkCast(const Handle& h) 42 | { AtomPtr a(h); return std::dynamic_pointer_cast(a); } 43 | static inline MaxLinkPtr MaxLinkCast(AtomPtr a) 44 | { return std::dynamic_pointer_cast(a); } 45 | 46 | #define createMaxLink std::make_shared 47 | 48 | /** @}*/ 49 | } 50 | 51 | #endif // _OPENCOG_MAX_LINK_H 52 | -------------------------------------------------------------------------------- /opencog/atoms/reduct/MinLink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * opencog/atoms/reduct/MinLink.h 3 | * 4 | * Copyright (C) 2020 Linas Vepstas 5 | * All Rights Reserved 6 | * SPDX-License-Identifier: AGPL-3.0-or-later 7 | */ 8 | 9 | #ifndef _OPENCOG_MIN_LINK_H 10 | #define _OPENCOG_MIN_LINK_H 11 | 12 | #include 13 | 14 | namespace opencog 15 | { 16 | /** \addtogroup grp_atomspace 17 | * @{ 18 | */ 19 | 20 | /** 21 | * The MinLink implements the arithmetic operation of "least of" 22 | * on a component-by-component level. 23 | */ 24 | class MinLink : public FunctionLink 25 | { 26 | protected: 27 | void init(void); 28 | 29 | public: 30 | MinLink(const HandleSeq&&, Type=MIN_LINK); 31 | 32 | MinLink(const MinLink&) = delete; 33 | MinLink& operator=(const MinLink&) = delete; 34 | 35 | virtual ValuePtr execute(AtomSpace*, bool); 36 | 37 | static Handle factory(const Handle&); 38 | }; 39 | 40 | typedef std::shared_ptr MinLinkPtr; 41 | static inline MinLinkPtr MinLinkCast(const Handle& h) 42 | { AtomPtr a(h); return std::dynamic_pointer_cast(a); } 43 | static inline MinLinkPtr MinLinkCast(AtomPtr a) 44 | { return std::dynamic_pointer_cast(a); } 45 | 46 | #define createMinLink std::make_shared 47 | 48 | /** @}*/ 49 | } 50 | 51 | #endif // _OPENCOG_MIN_LINK_H 52 | -------------------------------------------------------------------------------- /opencog/atoms/value/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) 2 | 3 | ADD_LIBRARY (value 4 | Value.cc 5 | FloatValue.cc 6 | FormulaStream.cc 7 | LinkStreamValue.cc 8 | LinkValue.cc 9 | QueueValue.cc 10 | RandomStream.cc 11 | StreamValue.cc 12 | StringValue.cc 13 | ValueFactory.cc 14 | PtrValue.cc 15 | VoidValue.cc 16 | ) 17 | 18 | # Without this, parallel make will race and crap up the generated files. 19 | ADD_DEPENDENCIES(value opencog_atom_types) 20 | 21 | TARGET_LINK_LIBRARIES(value 22 | atom_types 23 | ${COGUTIL_LIBRARY} 24 | ) 25 | 26 | INSTALL (TARGETS value EXPORT AtomSpaceTargets 27 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog" 28 | ) 29 | 30 | INSTALL (FILES 31 | FloatValue.h 32 | FormulaStream.h 33 | LinkStreamValue.h 34 | LinkValue.h 35 | QueueValue.h 36 | RandomStream.h 37 | StreamValue.h 38 | StringValue.h 39 | Value.h 40 | ValueFactory.h 41 | PtrValue.h 42 | VoidValue.h 43 | DESTINATION "include/opencog/atoms/value" 44 | ) 45 | -------------------------------------------------------------------------------- /opencog/atoms/value/LinkStreamValue.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * opencog/atoms/value/LinkStreamValue.cc 3 | * 4 | * Copyright (C) 2020 Linas Vepstas 5 | * All Rights Reserved 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License v3 as 9 | * published by the Free Software Foundation and including the exceptions 10 | * at http://opencog.org/wiki/Licenses 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program; if not, write to: 19 | * Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | using namespace opencog; 27 | 28 | // ============================================================== 29 | 30 | bool LinkStreamValue::operator==(const Value& other) const 31 | { 32 | return &other == this; 33 | } 34 | 35 | // ============================================================== 36 | -------------------------------------------------------------------------------- /opencog/atoms/value/StreamValue.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * opencog/atoms/value/StreamValue.cc 3 | * 4 | * Copyright (C) 2015, 2018 Linas Vepstas 5 | * All Rights Reserved 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License v3 as 9 | * published by the Free Software Foundation and including the exceptions 10 | * at http://opencog.org/wiki/Licenses 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program; if not, write to: 19 | * Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | using namespace opencog; 27 | 28 | // ============================================================== 29 | 30 | bool StreamValue::operator==(const Value& other) const 31 | { 32 | return &other == this; 33 | } 34 | 35 | // ============================================================== 36 | -------------------------------------------------------------------------------- /opencog/atoms/value/ValueFactory.cc: -------------------------------------------------------------------------------- 1 | #include "ValueFactory.h" 2 | 3 | using namespace opencog; 4 | 5 | void ValueServer::addFactory(Type vtype, ValueFactory func, 6 | std::vector args) 7 | { 8 | ProtoFactory fr = {func, args}; 9 | 10 | if (_factories.find(vtype) != _factories.end()) 11 | _factories[vtype].push_back(fr); 12 | else 13 | _factories[vtype] = {fr}; 14 | 15 | // Annoyingly-annoying special case for VoidValue. 16 | if (args[0] == std::type_index(typeid(void))) 17 | { 18 | ProtoFactory fr = {func, std::vector()}; 19 | _factories[vtype] = {fr}; 20 | } 21 | } 22 | 23 | void ValueServer::addCaster(Type vtype, ValueCaster func) 24 | { 25 | _vcasters[vtype] = func; 26 | } 27 | 28 | ValuePtr ValueServer::recast(const ValuePtr& ptr) const 29 | { 30 | Type vtype = ptr->get_type(); 31 | try 32 | { 33 | ValueCaster caster = _vcasters.at(vtype); 34 | return (*caster)(ptr); 35 | } 36 | catch (...) 37 | { 38 | return ptr; 39 | } 40 | } 41 | 42 | ValueServer& opencog::valueserver() 43 | { 44 | static std::unique_ptr instance(new ValueServer()); 45 | return *instance; 46 | } 47 | -------------------------------------------------------------------------------- /opencog/atoms/value/VoidValue.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * opencog/atoms/value/VoidValue.cc 3 | * 4 | * Copyright (C) 2020 OpenCog Foundation 5 | * All Rights Reserved 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License v3 as 9 | * published by the Free Software Foundation and including the exceptions 10 | * at http://opencog.org/wiki/Licenses 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program; if not, write to: 19 | * Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | using namespace opencog; 27 | 28 | const ValuePtr VoidValue::INSTANCE { new VoidValue() }; 29 | 30 | DEFINE_VALUE_FACTORY(VOID_VALUE, createVoidValue, void) 31 | -------------------------------------------------------------------------------- /opencog/atomspace/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # The atom_types.h file is written to the build directory 3 | INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}) 4 | 5 | ADD_LIBRARY (atomspace 6 | AtomSpace.cc 7 | AtomTable.cc 8 | Transient.cc 9 | TypeIndex.cc 10 | ) 11 | 12 | # Without this, parallel make will race and crap up the generated files. 13 | ADD_DEPENDENCIES(atomspace opencog_atom_types) 14 | 15 | TARGET_LINK_LIBRARIES(atomspace 16 | # We want to list every possible library that defines some 17 | # atom type, so that the library ctors will run, and add those 18 | # atom types to the classserver. If this is not done, then the 19 | # classserver will fail to run atom factories, viz, will fail 20 | # to run the ctors for C++-backed atom types, resulting in 21 | # screwball failures. 22 | ${NO_AS_NEEDED} 23 | clearbox 24 | container 25 | pattern 26 | grounded 27 | execution 28 | atomflow 29 | atomcore 30 | atombase 31 | truthvalue 32 | ${COGUTIL_LIBRARY} 33 | ) 34 | 35 | INSTALL (TARGETS atomspace EXPORT AtomSpaceTargets 36 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog" 37 | ) 38 | 39 | INSTALL (FILES 40 | AtomSpace.h 41 | AtomTable.h 42 | Transient.h 43 | TypeIndex.h 44 | version.h 45 | DESTINATION "include/opencog/atomspace" 46 | ) 47 | -------------------------------------------------------------------------------- /opencog/atomspace/Transient.h: -------------------------------------------------------------------------------- 1 | /* 2 | * opencog/atomspace/Transient.h 3 | * 4 | * Copyright (C) 2008,2009,2014,2015 Linas Vepstas 5 | * 6 | * Author: Linas Vepstas February 2008 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU Affero General Public License v3 as 10 | * published by the Free Software Foundation and including the exceptions 11 | * at http://opencog.org/wiki/Licenses 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Affero General Public License 19 | * along with this program; if not, write to: 20 | * Free Software Foundation, Inc., 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 | */ 23 | 24 | #ifndef _OPENCOG_TRANSIENT_H 25 | #define _OPENCOG_TRANSIENT_H 26 | 27 | namespace opencog 28 | { 29 | 30 | class AtomSpace; 31 | AtomSpace* grab_transient_atomspace(AtomSpace*); 32 | void release_transient_atomspace(AtomSpace*); 33 | 34 | } //namespace opencog 35 | 36 | #endif // _OPENCOG_TRANSIENT_H 37 | -------------------------------------------------------------------------------- /opencog/atomspace/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * opencog/atomspace/version.h 3 | * 4 | * Copyright (C) 2015 by OpenCog Foundation 5 | * All Rights Reserved 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License v3 as 9 | * published by the Free Software Foundation and including the exceptions 10 | * at http://opencog.org/wiki/Licenses 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program; if not, write to: 19 | * Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | #ifndef _OPENCOG_ATOMSPACE_VER_H 24 | #define _OPENCOG_ATOMSPACE_VER_H 25 | 26 | #define ATOMSPACE_MAJOR_VERSION 5 27 | #define ATOMSPACE_MINOR_VERSION 0 28 | #define ATOMSPACE_MICRO_VERSION 4 29 | 30 | #define ATOMSPACE_VERSION_STRING "5.0.4" 31 | 32 | 33 | #endif // _OPENCOG_ATOMSPACE_VER_H 34 | -------------------------------------------------------------------------------- /opencog/bench-mst/boruvka-101.dat: -------------------------------------------------------------------------------- 1 | # 2 | # Measurements of the current planar-Boruvka algo. 3 | # Performed by Linas 12 August 2017 4 | # Used these settings: 5 | # (define nvocab 5000) 6 | # (define npairs 101000) 7 | # This is fairly sparse I think. 8 | # 9 | # columns: sent-length millisecs-per-parse rate 10 | 2 0.011848 84403.58 11 | 3 0.036195 27628.31 12 | 4 0.107975 9261.425 13 | 5 0.191020 5235.062 14 | 6 0.345188 2896.969 15 | 7 0.452739 2208.776 16 | 8 0.701349 1425.824 17 | 9 1.000891 999.1097 18 | 10 1.279723 781.4191 19 | 11 1.648775 606.5108 20 | 12 2.195890 455.3962 21 | 13 2.713962 368.4650 22 | 14 3.332298 300.0932 23 | 15 4.042115 247.3952 24 | 16 4.906136 203.8264 25 | 17 5.870538 170.3422 26 | 18 6.716226 148.8931 27 | 19 8.340688 119.8942 28 | 20 9.637084 103.7658 29 | 21 10.87669 91.93971 30 | 22 13.19758 75.77148 31 | 23 15.10867 66.18717 32 | 24 17.56092 56.94463 33 | 25 19.93886 50.15332 34 | -------------------------------------------------------------------------------- /opencog/bench-mst/boruvka-101.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/bench-mst/boruvka-101.png -------------------------------------------------------------------------------- /opencog/bench-mst/boruvka-701K.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/bench-mst/boruvka-701K.png -------------------------------------------------------------------------------- /opencog/cython/PyIncludeWrapper.h: -------------------------------------------------------------------------------- 1 | 2 | #ifdef HAVE_CYTHON 3 | 4 | // XXX Cython currently conflicts with standard C library defintions. 5 | // The push/pop below should hush it, for now. (needed for cython 6 | // 0.15.1 and maybe other versions) FIXME someday... 7 | #ifdef _GNU_SOURCE 8 | #pragma push_macro("_POSIX_C_SOURCE") 9 | #pragma push_macro("_XOPEN_SOURCE") 10 | #undef _POSIX_C_SOURCE 11 | #undef _XOPEN_SOURCE 12 | #endif 13 | #include 14 | // Include header for Python traceback forward declaration 15 | #include 16 | #ifdef _GNU_SOURCE 17 | #pragma pop_macro("_POSIX_C_SOURCE") 18 | #pragma pop_macro("_XOPEN_SOURCE") 19 | #endif 20 | 21 | #endif /* HAVE_CYTHON */ 22 | -------------------------------------------------------------------------------- /opencog/cython/README.md: -------------------------------------------------------------------------------- 1 | Python bindings for OpenCog 2 | --------------------------- 3 | 4 | ## Requirements ## 5 | 6 | * Python 2.7 - although Python3 is recommended. 7 | * Cython 0.14 or later. http://www.cython.org/ 8 | * Nosetests - for running unit tests. 9 | 10 | Both Cython and Nosetests can be installed with `apt-get`: 11 | ``` 12 | sudo apt-get install cython python-nose 13 | ``` 14 | or with `easy_install`: 15 | ``` 16 | sudo easy_install cython nose 17 | ``` 18 | The bindings are written mostly using Cython, which allows writing 19 | code that looks pythonic but gets compiled to C. 20 | 21 | Currently the package structure looks like this: 22 | ``` 23 | opencog.atomspace 24 | opencog.atomspace.types 25 | opencog.scheme 26 | ``` 27 | ## Tutorial ## 28 | 29 | The OpenCog wiki contains the Python tutorial: 30 | 31 | http://wiki.opencog.org/w/Python 32 | -------------------------------------------------------------------------------- /opencog/cython/executioncontext/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # The atom_types.h file is written to the build directory 3 | INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}) 4 | 5 | ADD_LIBRARY (executioncontext 6 | Context.cc 7 | ) 8 | 9 | # Avoid building this lib until AFTER the types have been built. 10 | ADD_DEPENDENCIES(executioncontext opencog_atom_types) 11 | 12 | INSTALL (TARGETS executioncontext 13 | EXPORT AtomSpaceTargets 14 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog") 15 | 16 | INSTALL (FILES 17 | Context.h 18 | DESTINATION "include/opencog/executioncontext" 19 | ) 20 | -------------------------------------------------------------------------------- /opencog/cython/executioncontext/Context.cc: -------------------------------------------------------------------------------- 1 | #include "Context.h" 2 | 3 | namespace opencog { 4 | 5 | thread_local std::deque current = std::deque(); 6 | 7 | AtomSpace* get_context_atomspace(){ 8 | if (current.empty()) 9 | return nullptr; 10 | return current.back(); 11 | } 12 | void push_context_atomspace(AtomSpace * atomspace){ 13 | current.push_back(atomspace); 14 | } 15 | 16 | AtomSpace * pop_context_atomspace(){ 17 | AtomSpace * result = get_context_atomspace(); 18 | current.pop_back(); 19 | return result; 20 | } 21 | 22 | void clear_context(){ 23 | current.clear(); 24 | } 25 | 26 | } // namespace 27 | -------------------------------------------------------------------------------- /opencog/cython/executioncontext/Context.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #ifndef _OPENCOG_CONTEXT_H 5 | #define _OPENCOG_CONTEXT_H 6 | 7 | namespace opencog { 8 | extern thread_local std::deque current; 9 | 10 | AtomSpace * get_context_atomspace(); 11 | void push_context_atomspace(AtomSpace *atomspace); 12 | AtomSpace * pop_context_atomspace(); 13 | void clear_context(); 14 | } 15 | 16 | #endif // _OPENCOG_CONTEXT_H 17 | -------------------------------------------------------------------------------- /opencog/cython/opencog/BindlinkStub.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "BindlinkStub.h" 8 | 9 | using namespace opencog; 10 | 11 | ValuePtr opencog::do_execute(AtomSpace* atomspace, Handle h) 12 | { 13 | Instantiator inst(atomspace); 14 | ValuePtr pap(inst.execute(h)); 15 | if (pap and pap->is_atom()) 16 | return atomspace->add_atom(HandleCast(pap)); 17 | return pap; 18 | } 19 | -------------------------------------------------------------------------------- /opencog/cython/opencog/BindlinkStub.h: -------------------------------------------------------------------------------- 1 | /* 2 | * opencog/cython/BindlinkStub.h 3 | * 4 | * Copyright (C) 2011 by The OpenCog Foundation 5 | * All Rights Reserved 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License v3 as 9 | * published by the Free Software Foundation and including the exceptions 10 | * at http://opencog.org/wiki/Licenses 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program; if not, write to: 19 | * Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | #ifndef _OPENCOG_BINDLINKSTUB_H 24 | #define _OPENCOG_BINDLINKSTUB_H 25 | 26 | 27 | namespace opencog { 28 | 29 | ValuePtr do_execute(AtomSpace*, Handle); 30 | 31 | } // namespace opencog 32 | 33 | 34 | #endif // _OPENCOG_BINDLINKSTUB_H 35 | -------------------------------------------------------------------------------- /opencog/cython/opencog/PyScheme.h: -------------------------------------------------------------------------------- 1 | // 2 | #ifndef _OPENCOG_PYTHON_SCHEME_H 3 | #define _OPENCOG_PYTHON_SCHEME_H 4 | 5 | #include 6 | #include 7 | 8 | namespace opencog 9 | { 10 | 11 | /** For easier wrapping by Cython */ 12 | std::string eval_scheme(AtomSpace*, const std::string &); 13 | ValuePtr eval_scheme_v(AtomSpace*, const std::string &); 14 | Handle eval_scheme_h(AtomSpace*, const std::string &); 15 | AtomSpace* eval_scheme_as(const std::string &); 16 | 17 | } // namespace opencog 18 | 19 | #endif // _OPENCOG_PYTHON_SCHEME_H 20 | 21 | -------------------------------------------------------------------------------- /opencog/cython/opencog/Utilities.h: -------------------------------------------------------------------------------- 1 | /* 2 | * opencog/cython/Utilities.h 3 | * 4 | * Copyright (C) 2011 by The OpenCog Foundation 5 | * All Rights Reserved 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License v3 as 9 | * published by the Free Software Foundation and including the exceptions 10 | * at http://opencog.org/wiki/Licenses 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program; if not, write to: 19 | * Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | #ifndef _OPENCOG_UTILITIES_H 24 | #define _OPENCOG_UTILITIES_H 25 | #include "opencog/atoms/base/Handle.h" 26 | 27 | 28 | namespace opencog { 29 | 30 | void initialize_python(); 31 | void finalize_python(); 32 | Handle add_node(Type, std::string); 33 | Handle add_link(Type, HandleSeq); 34 | 35 | } // namespace opencog 36 | 37 | 38 | #endif // _OPENCOG_UTILITIES_H 39 | -------------------------------------------------------------------------------- /opencog/cython/opencog/__init__.py: -------------------------------------------------------------------------------- 1 | from pkgutil import extend_path 2 | __path__ = extend_path(__path__, __name__) 3 | 4 | # The above addresses the issues that came up in 5 | # https://github.com/opencog/atomspace/issues/20 6 | # Basically, the various python modules are split over multiple 7 | # directories, including the build directories. See this: 8 | # http://stackoverflow.com/questions/2699287/what-is-path-useful-for 9 | # for an explanation. 10 | -------------------------------------------------------------------------------- /opencog/cython/opencog/atomspace.pyx: -------------------------------------------------------------------------------- 1 | # Cython/distutils can only handle a single file as the source for 2 | # a python module. Since it is helpful to be able to split the binding 3 | # code into separate files, we just include them here. 4 | # 5 | # Note that the ordering of include statements may influence whether 6 | # things work or not 7 | 8 | include "value.pyx" 9 | include "atomspace_details.pyx" 10 | include "truth_value.pyx" 11 | include "float_value.pyx" 12 | include "string_value.pyx" 13 | include "atom.pyx" 14 | include "nameserver.pyx" 15 | include "link_value.pyx" 16 | include "ptrvalue.pyx" 17 | include "grounded_object_node.pyx" 18 | -------------------------------------------------------------------------------- /opencog/cython/opencog/bindlink.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | 3 | from opencog.execute import * 4 | 5 | warnings.warn('opencog.bindlink has been renamed to opencog.execute, update your imports.', DeprecationWarning) 6 | -------------------------------------------------------------------------------- /opencog/cython/opencog/exec.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | 3 | from opencog.execute import * 4 | 5 | warnings.warn('opencog.exec has been renamed to opencog.execute, update your imports.', DeprecationWarning) 6 | -------------------------------------------------------------------------------- /opencog/cython/opencog/execute.pxd: -------------------------------------------------------------------------------- 1 | from opencog.atomspace cimport cValuePtr, cHandle, tv_ptr, cAtomSpace 2 | 3 | ctypedef size_t cSize 4 | 5 | cdef extern from "opencog/atoms/execution/EvaluationLink.h" namespace "opencog": 6 | tv_ptr c_evaluate_atom "opencog::EvaluationLink::do_evaluate"(cAtomSpace*, cHandle) except + 7 | 8 | cdef extern from "opencog/cython/opencog/BindlinkStub.h" namespace "opencog": 9 | cdef cValuePtr c_execute_atom "do_execute"(cAtomSpace*, cHandle) except + 10 | -------------------------------------------------------------------------------- /opencog/cython/opencog/execute.pyx: -------------------------------------------------------------------------------- 1 | from opencog.atomspace cimport Atom, AtomSpace 2 | from opencog.atomspace cimport cAtomSpace, cTruthValue 3 | from opencog.atomspace cimport tv_ptr, strength_t, confidence_t, count_t 4 | from opencog.atomspace cimport create_python_value_from_c_value 5 | 6 | from cython.operator cimport dereference as deref 7 | 8 | from opencog.type_constructors import TruthValue 9 | 10 | 11 | def execute_atom(AtomSpace atomspace, Atom atom): 12 | if atom is None: 13 | raise ValueError("execute_atom atom is: None") 14 | cdef cValuePtr c_value_ptr = c_execute_atom( 15 | atomspace.atomspace, deref(atom.handle) 16 | ) 17 | return create_python_value_from_c_value(c_value_ptr) 18 | 19 | 20 | def evaluate_atom(AtomSpace atomspace, Atom atom): 21 | if atom is None: 22 | raise ValueError("evaluate_atom atom is: None") 23 | cdef tv_ptr result_tv_ptr = c_evaluate_atom( 24 | atomspace.atomspace, deref(atom.handle) 25 | ) 26 | cdef cTruthValue* result_tv = result_tv_ptr.get() 27 | cdef strength_t strength = deref(result_tv).get_mean() 28 | cdef confidence_t confidence = deref(result_tv).get_confidence() 29 | return TruthValue(strength, confidence) 30 | -------------------------------------------------------------------------------- /opencog/cython/opencog/float_value.pyx: -------------------------------------------------------------------------------- 1 | 2 | def createFloatValue(arg): 3 | cdef shared_ptr[cFloatValue] c_ptr 4 | if (isinstance(arg, list)): 5 | c_ptr.reset(new cFloatValue(FloatValue.list_of_doubles_to_vector(arg))) 6 | else: 7 | c_ptr.reset(new cFloatValue(arg)) 8 | return FloatValue(PtrHolder.create(c_ptr)) 9 | 10 | cdef class FloatValue(Value): 11 | 12 | def to_list(self): 13 | return FloatValue.vector_of_doubles_to_list( 14 | &((self.get_c_value_ptr().get()).value())) 15 | 16 | @staticmethod 17 | cdef vector[double] list_of_doubles_to_vector(list python_list): 18 | cdef vector[double] cpp_vector 19 | cdef double value 20 | for value in python_list: 21 | cpp_vector.push_back(value) 22 | return cpp_vector 23 | 24 | @staticmethod 25 | cdef list vector_of_doubles_to_list(const vector[double]* cpp_vector): 26 | list = [] 27 | it = cpp_vector.const_begin() 28 | while it != cpp_vector.const_end(): 29 | list.append(deref(it)) 30 | inc(it) 31 | return list 32 | 33 | -------------------------------------------------------------------------------- /opencog/cython/opencog/grounded_object_node.pxd: -------------------------------------------------------------------------------- 1 | from libcpp.memory cimport shared_ptr 2 | from cpython.object cimport PyObject 3 | from libcpp cimport bool 4 | 5 | cdef extern from "opencog/atoms/execution/GroundedObject.h" namespace "opencog": 6 | cdef cppclass cGroundedObject "opencog::GroundedObject": 7 | pass 8 | 9 | cdef extern from "opencog/cython/opencog/PythonGroundedObject.h": 10 | cdef cppclass cPythonGroundedObject "opencog::PythonGroundedObject" (cGroundedObject): 11 | cPythonGroundedObject(void* object, bool unwrap_args) 12 | void* get_object() const 13 | 14 | cdef extern from "opencog/atoms/execution/GroundedObjectNode.h" namespace "opencog": 15 | cdef cppclass cGroundedObjectNode "opencog::GroundedObjectNode": 16 | cGroundedObjectNode(const string&) 17 | cGroundedObjectNode(const string&, const shared_ptr[cGroundedObject]&) 18 | bool has_object() const 19 | void set_object(const shared_ptr[cGroundedObject]& object) 20 | cGroundedObject* get_object() except + 21 | 22 | ctypedef shared_ptr[cGroundedObjectNode] cGroundedObjectNodePtr "opencog::GroundedObjectNodePtr" 23 | 24 | cdef cGroundedObjectNodePtr cCreateGroundedObjectNode "createGroundedObjectNode" (...) 25 | 26 | -------------------------------------------------------------------------------- /opencog/cython/opencog/link_value.pyx: -------------------------------------------------------------------------------- 1 | 2 | def createLinkValue(arg): 3 | cdef shared_ptr[cLinkValue] c_ptr 4 | if (isinstance(arg, list)): 5 | c_ptr.reset(new cLinkValue(LinkValue.list_of_values_to_vector(arg))) 6 | else: 7 | c_ptr.reset(new cLinkValue(LinkValue.list_of_values_to_vector([arg]))) 8 | return LinkValue(PtrHolder.create(c_ptr)) 9 | 10 | cdef class LinkValue(Value): 11 | 12 | def to_list(self): 13 | return LinkValue.vector_of_values_to_list( 14 | &((self.get_c_value_ptr().get()).value())) 15 | 16 | @staticmethod 17 | cdef vector[cValuePtr] list_of_values_to_vector(list python_list): 18 | cdef vector[cValuePtr] cpp_vector 19 | cdef Value value 20 | for value in python_list: 21 | cpp_vector.push_back(value.get_c_value_ptr()) 22 | return cpp_vector 23 | 24 | @staticmethod 25 | cdef list vector_of_values_to_list(const vector[cValuePtr]* cpp_vector): 26 | list = [] 27 | it = cpp_vector.const_begin() 28 | cdef cValuePtr value 29 | while it != cpp_vector.const_end(): 30 | value = deref(it) 31 | list.append(create_python_value_from_c_value(value)) 32 | inc(it) 33 | return list 34 | -------------------------------------------------------------------------------- /opencog/cython/opencog/ptrvalue.pxd: -------------------------------------------------------------------------------- 1 | from libcpp.memory cimport shared_ptr 2 | from opencog.atomspace cimport Type, Value, cValue, cValuePtr 3 | 4 | cdef extern from "opencog/atoms/value/PtrValue.h" namespace "opencog": 5 | cdef cppclass cPtrValue "opencog::PtrValue": 6 | void* value() const; 7 | 8 | cdef cValuePtr createPtrValue(...) 9 | -------------------------------------------------------------------------------- /opencog/cython/opencog/ptrvalue.pyx: -------------------------------------------------------------------------------- 1 | from cpython.ref cimport Py_INCREF, Py_DECREF 2 | 3 | cdef class PtrValue(Value): 4 | 5 | def __init__(self, obj = None, ptr_holder = None): 6 | if obj is not None: 7 | cvalue = create_ptr_value_from_python_object(obj) 8 | super(PtrValue, self).__init__(PtrHolder.create(cvalue)) 9 | else: 10 | super(PtrValue, self).__init__(ptr_holder) 11 | 12 | def value(self): 13 | return ((self.get_c_value_ptr().get()).value()) 14 | 15 | cdef void decref(void* obj): 16 | Py_DECREF(obj) 17 | 18 | cdef cValuePtr create_ptr_value_from_python_object(object obj): 19 | Py_INCREF(obj) 20 | return createPtrValue(obj, decref) 21 | -------------------------------------------------------------------------------- /opencog/cython/opencog/scheme_wrapper.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | 3 | from opencog.scheme import * 4 | 5 | warnings.warn('opencog.scheme_wrapper has been renamed to opencog.scheme, update your imports.', DeprecationWarning) 6 | -------------------------------------------------------------------------------- /opencog/cython/opencog/string_value.pyx: -------------------------------------------------------------------------------- 1 | 2 | def createStringValue(arg): 3 | cdef shared_ptr[cStringValue] c_ptr 4 | if (isinstance(arg, list)): 5 | c_ptr.reset(new cStringValue(StringValue.list_of_strings_to_vector(arg))) 6 | else: 7 | c_ptr.reset(new cStringValue((arg.encode('UTF-8')))) 8 | return StringValue(PtrHolder.create(c_ptr)) 9 | 10 | cdef class StringValue(Value): 11 | 12 | def to_list(self): 13 | return StringValue.vector_of_strings_to_list( 14 | &((self.get_c_value_ptr().get()).value())) 15 | 16 | @staticmethod 17 | cdef vector[string] list_of_strings_to_vector(list python_list): 18 | cdef vector[string] cpp_vector 19 | for value in python_list: 20 | cpp_vector.push_back(value.encode('UTF-8')) 21 | return cpp_vector 22 | 23 | @staticmethod 24 | cdef list vector_of_strings_to_list(const vector[string]* cpp_vector): 25 | list = [] 26 | it = cpp_vector.const_begin() 27 | while it != cpp_vector.const_end(): 28 | list.append((deref(it).c_str()).decode('UTF-8')) 29 | inc(it) 30 | return list 31 | -------------------------------------------------------------------------------- /opencog/cython/opencog/value_types.pxd: -------------------------------------------------------------------------------- 1 | cdef class FloatValue(Value): 2 | @staticmethod 3 | cdef vector[double] list_of_doubles_to_vector(list python_list) 4 | 5 | @staticmethod 6 | cdef list vector_of_doubles_to_list(const vector[double]* cpp_vector) 7 | 8 | 9 | cdef class StringValue(Value): 10 | @staticmethod 11 | cdef vector[string] list_of_strings_to_vector(list python_list) 12 | 13 | @staticmethod 14 | cdef list vector_of_strings_to_list(const vector[string]* cpp_vector) 15 | 16 | 17 | cdef class LinkValue(Value): 18 | @staticmethod 19 | cdef vector[cValuePtr] list_of_values_to_vector(list python_list) 20 | 21 | @staticmethod 22 | cdef list vector_of_values_to_list(const vector[cValuePtr]* cpp_vector) 23 | -------------------------------------------------------------------------------- /opencog/eval/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | INSTALL (FILES 3 | GenericEval.h 4 | DESTINATION "include/opencog/eval" 5 | ) 6 | -------------------------------------------------------------------------------- /opencog/haskell/.gitignore: -------------------------------------------------------------------------------- 1 | .stack-work* 2 | -------------------------------------------------------------------------------- /opencog/haskell/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_LIBRARY (atomspace-cwrapper 2 | AtomSpace_CWrapper.cpp 3 | PatternMatcher_CWrapper.cpp 4 | Exec_CWrapper.cpp 5 | TruthValue_CWrapper.cpp 6 | Value_CWrapper.cpp 7 | ) 8 | 9 | ADD_DEPENDENCIES(atomspace-cwrapper atomspace query-engine) 10 | 11 | TARGET_LINK_LIBRARIES(atomspace-cwrapper 12 | query-engine 13 | execution 14 | atomspace 15 | ) 16 | 17 | INSTALL (TARGETS atomspace-cwrapper 18 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog" 19 | ) 20 | 21 | IF (HAVE_STACK) 22 | ADD_CUSTOM_TARGET(haskell-atomspace-lib ALL 23 | DEPENDS atomspace-cwrapper 24 | COMMAND sh build.sh ${CMAKE_CURRENT_BINARY_DIR} 25 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 26 | COMMENT "Building Haskell bindings." 27 | ) 28 | ENDIF (HAVE_STACK) 29 | -------------------------------------------------------------------------------- /opencog/haskell/Exec_CWrapper.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Exec_CWrapper.h" 3 | #include "Value_CWrapper.h" 4 | #include 5 | #include 6 | 7 | /** 8 | * See ExecSCM 9 | */ 10 | int Exec_execute(AtomSpace* atomspace, Handle* handle,Handle* out) 11 | { 12 | Handle h = *handle; 13 | Instantiator inst(atomspace); 14 | Handle rh(HandleCast(inst.execute(h))); 15 | if (nullptr != rh) { 16 | rh = atomspace->add_atom(rh); 17 | *out = rh; 18 | return 0; 19 | } else { 20 | return 1; 21 | } 22 | } 23 | 24 | /** 25 | * See ExecSCM 26 | */ 27 | int Exec_evaluate(AtomSpace* atomspace 28 | , Handle* handle 29 | , char** tv_type 30 | , double* parameters) 31 | { 32 | Handle h = *handle; 33 | TruthValuePtr tv = EvaluationLink::do_evaluate(atomspace, h); 34 | return FloatValue_toRaw(tv,tv_type,parameters); 35 | } 36 | 37 | 38 | -------------------------------------------------------------------------------- /opencog/haskell/Exec_CWrapper.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | extern "C" 5 | { 6 | using namespace opencog; 7 | 8 | int Exec_execute(AtomSpace* atomspace, Handle* handle,Handle* out); 9 | 10 | int Exec_evaluate(AtomSpace* atomspace 11 | , Handle* handle 12 | , char** tv_type 13 | , double* parameters); 14 | } 15 | -------------------------------------------------------------------------------- /opencog/haskell/OpenCog/AtomSpace/CUtils.hs: -------------------------------------------------------------------------------- 1 | module OpenCog.AtomSpace.CUtils where 2 | 3 | import Foreign (Ptr) 4 | import Foreign.C.Types (CULong(..),CInt(..),CDouble(..)) 5 | import Foreign.C.String (CString,withCString,peekCString) 6 | import Foreign.Marshal.Array (withArray,allocaArray,peekArray) 7 | import Foreign.Marshal.Alloc (alloca,free) 8 | import Foreign.Storable (peek) 9 | import OpenCog.AtomSpace.Internal (TVRaw(..),fromTVRaw,tvMAX_PARAMS) 10 | import OpenCog.AtomSpace.Types (TruthVal(..),Atom(..)) 11 | import Debug.Trace 12 | 13 | getTVfromC :: (Ptr CString -> Ptr CDouble -> IO CInt) -> (IO (Maybe TruthVal)) 14 | getTVfromC f = do 15 | alloca $ \tptr -> allocaArray tvMAX_PARAMS $ \lptr -> do 16 | res <- f tptr lptr 17 | case res of 18 | 0 -> do 19 | ctptr <- peek tptr 20 | tvType <- peekCString ctptr 21 | l <- peekArray tvMAX_PARAMS lptr 22 | return $ Just $ fromTVRaw $ TVRaw tvType (map realToFrac l) 23 | _ -> return Nothing 24 | -------------------------------------------------------------------------------- /opencog/haskell/OpenCog/AtomSpace/Sugar.hs: -------------------------------------------------------------------------------- 1 | -- GSoC 2015 - Haskell bindings for OpenCog. 2 | {-# LANGUAGE TypeOperators #-} 3 | {-# LANGUAGE ConstraintKinds #-} 4 | {-# LANGUAGE MultiParamTypeClasses #-} 5 | {-# LANGUAGE FlexibleInstances #-} 6 | {-# LANGUAGE UndecidableInstances #-} 7 | {-# LANGUAGE DataKinds #-} 8 | 9 | -- | This Module defines some util syntactic sugar for embedded atom notation. 10 | module OpenCog.AtomSpace.Sugar ( 11 | stv 12 | , ctv 13 | , itv 14 | , ftv 15 | , ptv 16 | , noTv 17 | ) where 18 | 19 | import OpenCog.AtomSpace.Types (TruthVal(..)) 20 | 21 | -- | TruthVal syntactic sugar. 22 | noTv :: TruthVal 23 | noTv = stv 1 0 24 | 25 | stv :: Double -> Double -> TruthVal 26 | stv a b = SimpleTV a b 27 | 28 | ctv :: Double -> Double -> Double -> TruthVal 29 | ctv a b c = CountTV a b c 30 | 31 | itv :: Double -> Double -> Double -> Double -> Double -> TruthVal 32 | itv a b c d e = IndefTV a b c d e 33 | 34 | ftv :: Double -> Double -> TruthVal 35 | ftv a b = FuzzyTV a b 36 | 37 | ptv :: Double -> Double -> Double -> TruthVal 38 | ptv a b c = ProbTV a b c 39 | -------------------------------------------------------------------------------- /opencog/haskell/PatternMatcher_CWrapper.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "PatternMatcher_CWrapper.h" 3 | #include "Value_CWrapper.h" 4 | #include 5 | #include 6 | 7 | Handle* PatternMatcher_BindLink(AtomSpace* this_ptr, Handle* handle) 8 | { 9 | Handle* res = (Handle*)malloc(sizeof(Handle)); 10 | (*res) = HandleCast((*handle)->execute(this_ptr)); 11 | return res; 12 | } 13 | 14 | int PatternMatcher_SatisfactionLink(AtomSpace* this_ptr 15 | , Handle* handle 16 | , char** tv_type 17 | , double* parameters) 18 | { 19 | TruthValuePtr tv = (*handle)->evaluate(this_ptr); 20 | return FloatValue_toRaw(tv,tv_type,parameters); 21 | } 22 | -------------------------------------------------------------------------------- /opencog/haskell/PatternMatcher_CWrapper.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | /** 5 | * C wrapper of the Pattern Matcher api: 6 | * An interface necessary for haskell bindings. 7 | * (ghc supports FFI for c libraries) 8 | * XXX FIXME: atoms must never be accessed by UUID except by the 9 | * communication and database layers. The UUID is not meant to be 10 | * a public interface. 11 | */ 12 | 13 | extern "C" 14 | { 15 | using namespace opencog; 16 | 17 | /** 18 | * PatternMatcher_bindlink Redirect the call to bindlink. 19 | * 20 | * @param this_ptr Pointer to AtomSpace instance. 21 | * @param handle Handle id of the bind link pattern. 22 | * 23 | * @return Handle id of the atom. 24 | */ 25 | Handle* PatternMatcher_BindLink(AtomSpace* this_ptr, Handle* handle); 26 | int PatternMatcher_SatisfactionLink(AtomSpace* this_ptr 27 | , Handle* handle 28 | , char** tv_type 29 | , double* parameters); 30 | 31 | } 32 | 33 | -------------------------------------------------------------------------------- /opencog/haskell/Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | main = defaultMain 3 | -------------------------------------------------------------------------------- /opencog/haskell/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | BIN_DIR=$1 3 | 4 | ghcver="$(stack --allow-different-user ghc -- --version)" 5 | 6 | case "$ghcver" in 7 | *"8.0.2"*) 8 | echo "Correct GHC version installed." 9 | ;; 10 | *) 11 | echo "Wrong GHC version installed. Running stack setup." 12 | stack setup --allow-different-user 13 | ;; 14 | esac 15 | 16 | if [ "$(id -u)" -ne 0 ]; 17 | then 18 | # Build haskell bindings package. 19 | stack build --allow-different-user --extra-lib-dirs=${BIN_DIR} 20 | fi 21 | -------------------------------------------------------------------------------- /opencog/haskell/stack.yaml: -------------------------------------------------------------------------------- 1 | flags: {} 2 | packages: 3 | - '.' 4 | extra-deps: [] 5 | resolver: lts-8.5 6 | #extra-lib-dirs: [/usr/local/lib/opencog 7 | # ,/home/roman/OpenCog/atomspace/build/opencog/haskell 8 | # ] 9 | # 10 | 11 | ghc-options: 12 | opencog-atomspace: -latomspace-cwrapper 13 | -------------------------------------------------------------------------------- /opencog/matrix/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_GUILE_MODULE (FILES 2 | matrix.scm 3 | bin-count.scm 4 | compute-mi.scm 5 | cosine.scm 6 | direct-sum.scm 7 | dynamic.scm 8 | entropy.scm 9 | eval-pairs.scm 10 | filter.scm 11 | fold-api.scm 12 | loop-api.scm 13 | object-api.scm 14 | progress.scm 15 | report-api.scm 16 | similarity-api.scm 17 | store.scm 18 | support.scm 19 | symmetric-mi.scm 20 | thresh-pca.scm 21 | transpose.scm 22 | trans-batch.scm 23 | trim.scm 24 | MODULE_DESTINATION "${GUILE_SITE_DIR}/opencog/matrix" 25 | ) 26 | -------------------------------------------------------------------------------- /opencog/matrix/docs/AtomSpace.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/matrix/docs/AtomSpace.pdf -------------------------------------------------------------------------------- /opencog/matrix/docs/cloud-matrix.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/matrix/docs/cloud-matrix.dia -------------------------------------------------------------------------------- /opencog/matrix/docs/matrix.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/matrix/docs/matrix.dia -------------------------------------------------------------------------------- /opencog/matrix/docs/puzzle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/matrix/docs/puzzle.png -------------------------------------------------------------------------------- /opencog/matrix/docs/seed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/matrix/docs/seed.png -------------------------------------------------------------------------------- /opencog/matrix/docs/seeds-two.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/matrix/docs/seeds-two.png -------------------------------------------------------------------------------- /opencog/persist/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY (storage) 2 | ADD_SUBDIRECTORY (api) 3 | 4 | IF (HAVE_GEARMAN AND HAVE_GUILE) 5 | ADD_SUBDIRECTORY (gearman) 6 | ENDIF(HAVE_GEARMAN AND HAVE_GUILE) 7 | 8 | ADD_SUBDIRECTORY (json) 9 | ADD_SUBDIRECTORY (sexpr) 10 | ADD_SUBDIRECTORY (sql) 11 | ADD_SUBDIRECTORY (tlb) 12 | -------------------------------------------------------------------------------- /opencog/persist/api/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ADD_LIBRARY (persist 3 | BackingQuery.cc 4 | BackingStore.cc 5 | PersistSCM.cc 6 | StorageNode.cc 7 | ) 8 | 9 | TARGET_LINK_LIBRARIES(persist 10 | storage-types 11 | atomspace 12 | smob 13 | ) 14 | 15 | ADD_GUILE_EXTENSION(SCM_CONFIG persist "opencog-ext-path-persist") 16 | 17 | INSTALL (TARGETS persist EXPORT AtomSpaceTargets 18 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog" 19 | ) 20 | 21 | INSTALL (FILES 22 | BackingStore.h 23 | StorageNode.h 24 | PersistSCM.h 25 | DESTINATION "include/opencog/persist/api" 26 | ) 27 | -------------------------------------------------------------------------------- /opencog/persist/gearman/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # Build the GearMan based distributed system. 3 | # 4 | ADD_LIBRARY(dist-gearman 5 | DistSCM.cc 6 | ) 7 | 8 | TARGET_LINK_LIBRARIES(dist-gearman 9 | smob 10 | atomspace 11 | ${GEARMAN_LIBRARY} 12 | ) 13 | 14 | ADD_GUILE_EXTENSION(SCM_CONFIG dist-gearman "opencog-ext-path-dist-gearman") 15 | 16 | INSTALL (TARGETS dist-gearman 17 | EXPORT AtomSpaceTargets 18 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog") 19 | 20 | -------------------------------------------------------------------------------- /opencog/persist/json/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # Generic JSON decoding. 3 | ADD_LIBRARY (json 4 | DecodeJson 5 | EncodeJson 6 | JSCommands 7 | JsonEval 8 | ) 9 | 10 | ADD_DEPENDENCIES(json opencog_atom_types) 11 | 12 | TARGET_LINK_LIBRARIES(json 13 | atomspace 14 | execution 15 | atombase 16 | ${COGUTIL_LIBRARY} 17 | ) 18 | 19 | INSTALL (TARGETS json EXPORT AtomSpaceTargets 20 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog" 21 | ) 22 | 23 | INSTALL (FILES 24 | JSCommands.h 25 | JsonEval.h 26 | Json.h 27 | DESTINATION "include/opencog/persist/json" 28 | ) 29 | 30 | # ------------------------------- 31 | -------------------------------------------------------------------------------- /opencog/persist/sql/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | IF (HAVE_SQL_STORAGE) 3 | ADD_SUBDIRECTORY(multi-driver) 4 | ENDIF (HAVE_SQL_STORAGE) 5 | -------------------------------------------------------------------------------- /opencog/persist/storage/README.md: -------------------------------------------------------------------------------- 1 | 2 | Storage Atom Types 3 | ------------------ 4 | This defines some atom types, currently, just nodes, that indicate 5 | how to connect up to storage. There are currently three types: 6 | 7 | * `PostgresStorageNode` -- connect to a Postgres backend 8 | * `RocksDBStorageNode` -- connect to a RocksDB backend 9 | * `CogStorageNode` -- connect to a CogServer backend 10 | 11 | `RocksDBStorageNode` is implemented in the 12 | [opencog/atomspace-rocks](https://github.com/opncog/atomspace-rocks) 13 | git repo. 14 | 15 | `CogStorageNode` is implemented in the 16 | [opencog/atomspace-cog](https://github.com/opncog/atomspace-cog) 17 | git repo. 18 | 19 | General information about the `storage_types.script` file can be found 20 | in the `opencog/atoms/atom_types` directory. 21 | -------------------------------------------------------------------------------- /opencog/persist/storage/storage_types.script: -------------------------------------------------------------------------------- 1 | // 2 | // Script for automatic "storage atom type" generation. This defines 3 | // a collection of types suitable for defining distributed storage 4 | // interconnects. 5 | // 6 | // The base type for all storage nodes. Seems like BondNode is a 7 | // suitable base, I guess .. !? 8 | STORAGE_NODE <- BOND_NODE 9 | // 10 | // Specific storage nodes. Most of these are implemented in other git 11 | // repos, and not here. Look for git repos called "atomspace-xxx" for 12 | // approrpiate values of "xxx". 13 | POSTGRES_STORAGE_NODE <- STORAGE_NODE 14 | ROCKS_STORAGE_NODE <- STORAGE_NODE 15 | COG_SIMPLE_STORAGE_NODE <- STORAGE_NODE 16 | COG_STORAGE_NODE <- STORAGE_NODE 17 | FILE_STORAGE_NODE <- STORAGE_NODE 18 | // 19 | // There is no IPFS_STORAGE_NODE nore DHT_STORAGE_NODE because these 20 | // are currently deeply, fundamentally broken. Whoops! 21 | -------------------------------------------------------------------------------- /opencog/persist/storage/storage_types_init.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * atomspace/persist/storage/storage_types_init.cc 3 | * 4 | * Copyright (C) 2014,2020 Linas Vepstas 5 | * All Rights Reserved 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU Affero General Public License v3 as 9 | * published by the Free Software Foundation and including the exceptions 10 | * at http://opencog.org/wiki/Licenses 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Affero General Public License 18 | * along with this program; if not, write to: 19 | * Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | #include "opencog/persist/storage/storage_types.definitions" 24 | 25 | #define INHERITANCE_FILE "opencog/persist/storage/storage_types.inheritance" 26 | #define INITNAME storage_types_init 27 | 28 | #include 29 | -------------------------------------------------------------------------------- /opencog/persist/tlb/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ADD_LIBRARY (tlb 3 | TLB 4 | ) 5 | 6 | TARGET_LINK_LIBRARIES(tlb 7 | atombase 8 | atomspace 9 | ${COGUTIL_LIBRARY} 10 | ) 11 | 12 | INSTALL (TARGETS tlb EXPORT AtomSpaceTargets 13 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog" 14 | ) 15 | 16 | INSTALL (FILES 17 | TLB.h 18 | DESTINATION "include/opencog/persist/tlb" 19 | ) 20 | -------------------------------------------------------------------------------- /opencog/query/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # Build the query-engine library 3 | ADD_LIBRARY(query-engine 4 | InitiateSearchMixin.cc 5 | NextSearchMixin.cc 6 | PatternMatchEngine.cc 7 | Recognizer.cc 8 | RewriteMixin.cc 9 | Satisfier.cc 10 | SatisfyMixin.cc 11 | TermMatchMixin.cc 12 | ) 13 | 14 | # Optionally enable debug logging for the pattern matcher. 15 | # TARGET_COMPILE_OPTIONS(query-engine PRIVATE -DQDEBUG=1) 16 | 17 | # Optionally enable multi-threaded pattern matcher. Experimental. 18 | # TARGET_COMPILE_OPTIONS(query-engine PRIVATE -DUSE_THREADED_PATTERN_ENGINE=1) 19 | 20 | ADD_DEPENDENCIES(query-engine 21 | opencog_atom_types 22 | ) 23 | 24 | TARGET_LINK_LIBRARIES(query-engine 25 | execution 26 | ) 27 | 28 | INSTALL (TARGETS query-engine 29 | EXPORT AtomSpaceTargets 30 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog") 31 | 32 | INSTALL (FILES 33 | Implicator.h 34 | InitiateSearchMixin.h 35 | PatternMatchCallback.h 36 | PatternMatchEngine.h 37 | RewriteMixin.h 38 | Satisfier.h 39 | SatisfyMixin.h 40 | TermMatchMixin.h 41 | DESTINATION "include/opencog/query" 42 | ) 43 | -------------------------------------------------------------------------------- /opencog/scm/README.md: -------------------------------------------------------------------------------- 1 | 2 | Scheme (guile) modules 3 | ---------------------- 4 | 5 | This directory contains various scheme (guile) modules for working 6 | with opencog. This includes the base system, as well as extensions 7 | of various sorts. Soome of the major ones include the pattern matcher 8 | (in the `opencog query` module), the rule engine, the SQL interfaces, 9 | etc. 10 | 11 | ==WIRES 12 | The "wires" directory contains a currently abandoned, but interesting 13 | implementation of a "constraint propagation system", wherein OpenCog 14 | hypergraphs are treated like electrical circuits, with interactions 15 | flowing between them. The idea may be worth resurrecting, although 16 | currently there's no strong motivation. 17 | -------------------------------------------------------------------------------- /opencog/scm/opencog/base/README: -------------------------------------------------------------------------------- 1 | 2 | opencog base 3 | ------------ 4 | 5 | This repository contains assorted routines, written in scheme, for 6 | manipulating OpenCog atoms, in various general ways. These utilities 7 | include: 8 | 9 | -- debug.scm 10 | + debugger/backtrace support. 11 | 12 | -- file-utils.scm 13 | + list files in directory 14 | + load scheme code from file 15 | + execute scheme code from a string or a port. 16 | 17 | -- utilities.scm 18 | + increment a CountTruthValue 19 | + delete an OpenCog hypergraph, from the top-node downwards 20 | + get all atoms of a certain given type 21 | + get all incoming/outgoing atoms of a given type 22 | + apply filter to a list of atoms 23 | + get "partner" atoms connected by links in various ways 24 | -------------------------------------------------------------------------------- /opencog/scm/opencog/base/repl-shell.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; repl-shell.scm 3 | ; 4 | ; Start the "high-level" scheme shell. 5 | ; 6 | ; Copyright (C) 2013 Linas Vepstas 7 | ; 8 | ; -------------------------------------------------------------------- 9 | 10 | (use-modules (system repl server)) 11 | (use-modules (system repl common)) 12 | 13 | ; localhost, port number 18001 14 | (spawn-server (make-tcp-server-socket #:port 18001)) 15 | 16 | ; A plain simple prompt 17 | ; (define shell-prompt "opencog-scheme> ") 18 | 19 | ; An ANSI-terminal colorized prompt! This one is blue. 20 | (define shell-prompt "opencog-scheme> ") 21 | 22 | (repl-default-prompt-set! shell-prompt) 23 | ; -------------------------------------------------------------------- 24 | -------------------------------------------------------------------------------- /opencog/scm/opencog/dist-gearman.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; OpenCog Gearman module 3 | ; 4 | (define-module (opencog dist-gearman)) 5 | 6 | (use-modules (opencog)) 7 | (use-modules (opencog as-config)) 8 | (load-extension (string-append opencog-ext-path-dist-gearman "libdist-gearman") "opencog_dist_init") 9 | 10 | (export start-work-handler dist-eval exit-all-workers) 11 | -------------------------------------------------------------------------------- /opencog/scm/opencog/extension.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; OpenCog General-purpose extension module 3 | ; 4 | ; This simply gives scope to the wrapper code in guile/SchemePrimitive.cc 5 | ; 6 | (define-module (opencog extension)) 7 | 8 | (use-modules (opencog)) 9 | -------------------------------------------------------------------------------- /opencog/scm/opencog/persist-file.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; OpenCog File Persistence module 3 | ; 4 | 5 | (define-module (opencog persist-file)) 6 | 7 | (use-modules (opencog)) 8 | (use-modules (opencog persist)) 9 | (use-modules (opencog as-config)) 10 | (load-extension 11 | (string-append opencog-ext-path-persist-file "libpersist-file") 12 | "opencog_persist_file_init") 13 | 14 | (export load-file) 15 | 16 | (set-procedure-property! load-file 'documentation 17 | " 18 | load-file FILE -- Load atomese from FILE. 19 | 20 | Throws error if FILE does not exist. 21 | ") 22 | 23 | ; -------------------------------------------------------------------- 24 | -------------------------------------------------------------------------------- /opencog/sheaf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_GUILE_MODULE (FILES 2 | sheaf.scm 3 | linear-parser.scm 4 | make-section.scm 5 | mpg-parser.scm 6 | mst-parser.scm 7 | sections.scm 8 | vo-graph.scm 9 | MODULE_DESTINATION "${GUILE_SITE_DIR}/opencog/sheaf" 10 | ) 11 | -------------------------------------------------------------------------------- /opencog/sheaf/docs/connectors-and-variables.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/sheaf/docs/connectors-and-variables.pdf -------------------------------------------------------------------------------- /opencog/sheaf/docs/feature.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/sheaf/docs/feature.pdf -------------------------------------------------------------------------------- /opencog/sheaf/docs/graphics/corn-field.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/sheaf/docs/graphics/corn-field.jpg -------------------------------------------------------------------------------- /opencog/sheaf/docs/graphics/cornstalk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/sheaf/docs/graphics/cornstalk.jpg -------------------------------------------------------------------------------- /opencog/sheaf/docs/graphics/directed-graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/sheaf/docs/graphics/directed-graph.png -------------------------------------------------------------------------------- /opencog/sheaf/docs/graphics/hypergraph.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/sheaf/docs/graphics/hypergraph.dia -------------------------------------------------------------------------------- /opencog/sheaf/docs/graphics/metagraph.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/sheaf/docs/graphics/metagraph.dia -------------------------------------------------------------------------------- /opencog/sheaf/docs/graphics/org-chart.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/sheaf/docs/graphics/org-chart.dia -------------------------------------------------------------------------------- /opencog/sheaf/docs/graphics/partial-index.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/sheaf/docs/graphics/partial-index.dia -------------------------------------------------------------------------------- /opencog/sheaf/docs/graphics/sheaf-of-papers.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/sheaf/docs/graphics/sheaf-of-papers.jpg -------------------------------------------------------------------------------- /opencog/sheaf/docs/graphics/sheaf-of-stalks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/sheaf/docs/graphics/sheaf-of-stalks.jpg -------------------------------------------------------------------------------- /opencog/sheaf/docs/graphics/stack-jigsaw-puzzle-pieces.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/sheaf/docs/graphics/stack-jigsaw-puzzle-pieces.jpg -------------------------------------------------------------------------------- /opencog/sheaf/docs/learning.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/sheaf/docs/learning.pdf -------------------------------------------------------------------------------- /opencog/sheaf/docs/mereology.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/sheaf/docs/mereology.pdf -------------------------------------------------------------------------------- /opencog/sheaf/docs/ram-cpu.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/sheaf/docs/ram-cpu.pdf -------------------------------------------------------------------------------- /opencog/sheaf/docs/sheaf-axioms.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/sheaf/docs/sheaf-axioms.pdf -------------------------------------------------------------------------------- /opencog/sheaf/docs/sheaves.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/sheaf/docs/sheaves.pdf -------------------------------------------------------------------------------- /opencog/sheaf/docs/tensors.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/opencog/sheaf/docs/tensors.pdf -------------------------------------------------------------------------------- /opencog/sheaf/sheaf.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Network inference module. 3 | ; Wraps up the assorted tools and scripts into one module. 4 | ; 5 | (define-module (opencog sheaf)) 6 | 7 | (use-modules (opencog)) 8 | 9 | ; The files are loaded in pipeline order. 10 | ; In general, the later files depend on definitions contained 11 | ; in the earlier files. 12 | (include-from-path "opencog/sheaf/sections.scm") 13 | (include-from-path "opencog/sheaf/vo-graph.scm") 14 | (include-from-path "opencog/sheaf/linear-parser.scm") 15 | (include-from-path "opencog/sheaf/mst-parser.scm") 16 | (include-from-path "opencog/sheaf/mpg-parser.scm") 17 | (include-from-path "opencog/sheaf/make-section.scm") 18 | -------------------------------------------------------------------------------- /scripts/.gdbinit: -------------------------------------------------------------------------------- 1 | # 2 | # guile garbage collection uses these. Ignore them. 3 | # 4 | handle SIGPWR noprint nostop 5 | handle SIGXCPU noprint nostop 6 | -------------------------------------------------------------------------------- /scripts/benchmark_utests.sh: -------------------------------------------------------------------------------- 1 | # Small script to test the performance of the AtomSpace and its tools 2 | # (pattern matcher, URE, etc). It merely runs all the unit tests a 3 | # certain number of times and output statistics about it. 4 | 5 | # This script relies on https://github.com/nferraz/st 6 | 7 | # Check unbound variables 8 | set -u 9 | 10 | # # Debug trace 11 | # set -x 12 | 13 | # Number of times to run the unit tests 14 | N=10 15 | 16 | # Name of the build directory 17 | BUILD_DIR_NAME=build 18 | 19 | # Get the script directory 20 | PRG_PATH="$(readlink -f "$0")" 21 | PRG_DIR="$(dirname "$PRG_PATH")" 22 | UTEST_DIR="$PRG_DIR/../$BUILD_DIR_NAME" 23 | 24 | ############# 25 | # Functions # 26 | ############# 27 | 28 | # Get the real time in second (given the output of time command) 29 | get_real_time() { 30 | grep "real" | cut -d' ' -f2 31 | } 32 | 33 | # Run all query unit tests 34 | run_utests() { 35 | cd "$UTEST_DIR"; 36 | make -j4 test ARGS=-j4 37 | cd - 38 | } 39 | 40 | ######## 41 | # Main # 42 | ######## 43 | 44 | for i in $(seq 1 $N); do 45 | echo "Run unit test suite ($i/$N)" 1>&2 46 | (time -p run_utests 1>/dev/null) 2>&1 47 | done | get_real_time | st | column -t 48 | -------------------------------------------------------------------------------- /scripts/query/benchmark_query.sh: -------------------------------------------------------------------------------- 1 | # Small script to test the performance of the pattern matcher. It 2 | # merely runs all the unit tests in query a certain number of times 3 | # and output statistics about it. 4 | 5 | # This script relies on https://github.com/nferraz/st 6 | 7 | # Check unbound variables 8 | set -u 9 | 10 | # Debug trace 11 | # set -x 12 | 13 | # Number of times to run the unit tests 14 | N=20 15 | 16 | # Name of the build directory 17 | BUILD_DIR_NAME=build 18 | 19 | # Get the script directory 20 | PRG_PATH="$(readlink -f "$0")" 21 | PRG_DIR="$(dirname "$PRG_PATH")" 22 | UTEST_DIR="$PRG_DIR/../../$BUILD_DIR_NAME/tests/query" 23 | 24 | ############# 25 | # Functions # 26 | ############# 27 | 28 | # Get the real time in second (given the output of time command) 29 | get_real_time() { 30 | grep "real" | cut -d' ' -f2 31 | } 32 | 33 | # Run all query unit tests 34 | run_all_utests() { 35 | for ut in "$UTEST_DIR"/*UTest; do 36 | "$ut" > /dev/null 37 | done 38 | } 39 | 40 | ######## 41 | # Main # 42 | ######## 43 | 44 | for i in $(seq 1 $N); do 45 | time -p run_all_utests 46 | done |& get_real_time | st | column -t 47 | -------------------------------------------------------------------------------- /scripts/run_lcov.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This file is a wrapper for running cxxtests and creating per test coverage 3 | # results. It takes a long time, and tests added outside of the patched 4 | # ADD_CXXTEST won't be included. 5 | builddir=$1 # the root build dir 6 | name=$3 # name of the test (and executable) 7 | dir=$2 # dir the the test is built in 8 | echo "test $name" 1>&2 9 | cd $builddir 10 | mkdir -p coverage 11 | rm coverage/$name.info 12 | 13 | # This is run in the BUILDDIR/tests directory so .. is the root 14 | lcov --directory . --zerocounter 15 | # run test 16 | $dir/$name 17 | ret_val=$? 18 | # capture coverage data to info file 19 | lcov --directory . --capture --output-file coverage/$name.info --test-name $name 20 | 21 | # strip out unwanted stuff 22 | # XXX FIXME the "*/build/*" should be some hacked $builddir 23 | lcov --remove coverage/$name.info "/usr*" -o coverage/$name.info 24 | lcov --remove coverage/$name.info "*/tests/*" -o coverage/$name.info 25 | lcov --remove coverage/$name.info "*/build/*" -o coverage/$name.info 26 | 27 | exit $ret_val 28 | -------------------------------------------------------------------------------- /tests/atoms/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ADD_SUBDIRECTORY (atom_types) 3 | 4 | ADD_SUBDIRECTORY (base) 5 | 6 | ADD_SUBDIRECTORY (core) 7 | 8 | ADD_SUBDIRECTORY (container) 9 | 10 | ADD_SUBDIRECTORY (evaluation) 11 | 12 | ADD_SUBDIRECTORY (execution) 13 | 14 | ADD_SUBDIRECTORY (parallel) 15 | 16 | ADD_SUBDIRECTORY (truthvalue) 17 | 18 | ADD_SUBDIRECTORY (value) 19 | 20 | ADD_SUBDIRECTORY (reduct) 21 | 22 | ADD_SUBDIRECTORY (flow) 23 | 24 | ADD_SUBDIRECTORY (pattern) 25 | 26 | IF(HAVE_GUILE) 27 | ADD_CXXTEST(HashUTest) 28 | TARGET_LINK_LIBRARIES(HashUTest smob atomspace) 29 | ADD_CXXTEST(FreeLinkUTest) 30 | TARGET_LINK_LIBRARIES(FreeLinkUTest smob atomspace) 31 | ADD_CXXTEST(RandomUTest) 32 | TARGET_LINK_LIBRARIES(RandomUTest clearbox execution smob atomspace) 33 | ENDIF(HAVE_GUILE) 34 | 35 | ADD_CXXTEST(AlphaConvertUTest) 36 | TARGET_LINK_LIBRARIES(AlphaConvertUTest execution pattern atomspace) 37 | 38 | ADD_CXXTEST(BetaReduceUTest) 39 | TARGET_LINK_LIBRARIES(BetaReduceUTest atomspace) 40 | 41 | ADD_CXXTEST(DefineLinkUTest) 42 | TARGET_LINK_LIBRARIES(DefineLinkUTest atomspace) 43 | 44 | ADD_CXXTEST(DeleteLinkUTest) 45 | TARGET_LINK_LIBRARIES(DeleteLinkUTest execution atomspace) 46 | 47 | ADD_CXXTEST(StateLinkUTest) 48 | TARGET_LINK_LIBRARIES(StateLinkUTest execution atomspace) 49 | -------------------------------------------------------------------------------- /tests/atoms/atom_types/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | LINK_LIBRARIES( 3 | execution 4 | atomspace 5 | atombase 6 | ) 7 | 8 | ADD_CXXTEST(NameServerUTest) 9 | ADD_CXXTEST(AtomNamesUTest) 10 | -------------------------------------------------------------------------------- /tests/atoms/base/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | LINK_LIBRARIES( 3 | atombase 4 | atomspace 5 | ) 6 | 7 | ADD_CXXTEST(AtomUTest) 8 | ADD_CXXTEST(NodeUTest) 9 | ADD_CXXTEST(LinkUTest) 10 | ADD_CXXTEST(ClassServerUTest) 11 | ADD_CXXTEST(HandleUTest) 12 | 13 | # Special unit test atom types, tested by the FactoryUTest 14 | OPENCOG_ADD_ATOM_TYPES( 15 | test_types.script 16 | test_types.h 17 | test_types.definitions 18 | test_types.inheritance 19 | test_types.scm 20 | test_types.pyx 21 | ) 22 | ADD_CUSTOM_TARGET(test_atom_types DEPENDS test_types.h) 23 | 24 | # The atom_types.h file is written to the build directory 25 | INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}) 26 | 27 | ADD_LIBRARY (test-types SHARED 28 | test_types 29 | TestTypes 30 | ) 31 | 32 | # Without this, parallel make will race and crap up the generated files. 33 | ADD_DEPENDENCIES(test-types test_atom_types) 34 | 35 | TARGET_LINK_LIBRARIES(test-types 36 | ${ATOMSPACE_atomtypes_LIBRARY} 37 | ) 38 | 39 | ADD_CXXTEST(FactoryUTest) 40 | TARGET_LINK_LIBRARIES(FactoryUTest test-types) 41 | -------------------------------------------------------------------------------- /tests/atoms/base/TestTypes.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * TestTypes.cc 3 | * 4 | * Atom Types needed unit testing. 5 | * 6 | * Copyright (c) 2009, 2014 Linas Vepstas 7 | */ 8 | 9 | #include "tests/atoms/base/test_types.definitions" 10 | 11 | #define INHERITANCE_FILE "tests/atoms/base/test_types.inheritance" 12 | #define INITNAME test_types_init 13 | 14 | #include 15 | -------------------------------------------------------------------------------- /tests/atoms/base/test_types.script: -------------------------------------------------------------------------------- 1 | 2 | // Mimic basic types provided by spacetime and PLN. 3 | TIME_NODE <- NUMBER_NODE 4 | TIME_INTERVAL_LINK <- ORDERED_LINK 5 | PREDICTIVE_IMPLICATION_SCOPE_LINK <- SCOPE_LINK 6 | -------------------------------------------------------------------------------- /tests/atoms/container/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | LINK_LIBRARIES(container smob execution atomspace) 3 | ADD_CXXTEST(JoinLinkUTest) 4 | ADD_CXXTEST(BlueJoinUTest) 5 | ADD_CXXTEST(TrueJoinUTest) 6 | ADD_CXXTEST(CompoundJoinUTest) 7 | ADD_CXXTEST(GPNJoinUTest) 8 | -------------------------------------------------------------------------------- /tests/atoms/container/compound-join.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; compound-join.scm 3 | ; CompoundJoinUTest 4 | ; 5 | 6 | (use-modules (opencog) (opencog exec)) 7 | 8 | ; Data 9 | (Evaluation (Predicate "above") (List (Concept "sky"))) 10 | (Evaluation (Predicate "part of") (List (Concept "beach") (Concept "sand"))) 11 | (Evaluation (Predicate "part of") (List (Concept "beach") (Concept "sea"))) 12 | (Evaluation (Predicate "planetary") 13 | (List (Concept "sky") (Concept "ground") (Concept "ocean"))) 14 | 15 | (define min-compound 16 | (MinimalJoin 17 | (VariableList 18 | (TypedVariable (Variable "X") (Type 'ConceptNode)) 19 | (TypedVariable (Variable "Y") (Type 'ConceptNode))) 20 | (Present (List (Variable "X") (Variable "Y"))))) 21 | 22 | (define max-compound 23 | (MaximalJoin 24 | (VariableList 25 | (TypedVariable (Variable "X") (Type 'ConceptNode)) 26 | (TypedVariable (Variable "Y") (Type 'ConceptNode))) 27 | (Present (List (Variable "X") (Variable "Y"))))) 28 | -------------------------------------------------------------------------------- /tests/atoms/container/join-content.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; join-content.scm 3 | ; Data for the JoinLink unit test. 4 | 5 | (use-modules (opencog)) 6 | 7 | (Member (Concept "A") (Concept "S")) 8 | (Evaluation (Predicate "P") (List (Concept "A"))) 9 | -------------------------------------------------------------------------------- /tests/atoms/container/true-container.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; true-container.scm 3 | ; TrueJoinUTest 4 | ; make sure constraints on the top type works. 5 | 6 | (use-modules (opencog) (opencog exec)) 7 | 8 | ; Data 9 | (Member (Concept "A") (Concept "S")) 10 | (Evaluation (Predicate "P") (List (Concept "A"))) 11 | (Similarity (Concept "foo") (Concept "bar")) 12 | 13 | (define min-top 14 | (MinimalJoin 15 | (TypedVariable (Variable "X") (Signature (Concept "A"))) 16 | (TypeChoice 17 | (Type 'EvaluationLink) 18 | (Type 'SimilarityLink)))) 19 | 20 | (define max-top 21 | (MaximalJoin 22 | (TypedVariable (Variable "X") (Signature (Concept "A"))) 23 | (TypeChoice 24 | (Type 'EvaluationLink) 25 | (Type 'SimilarityLink)))) 26 | -------------------------------------------------------------------------------- /tests/atoms/container/true-upper.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; true-upper.scm 3 | ; TrueJoinUTest 4 | ; Validate that UpperSet works correctly. 5 | 6 | (use-modules (opencog) (opencog exec)) 7 | 8 | (Evaluation (Predicate "ontology") 9 | (List 10 | (Concept "class") 11 | (Member (Concept "crow") (Concept "bird")))) 12 | 13 | (define min-join 14 | (MinimalJoin 15 | (Present (Concept "crow")) 16 | (Present (Concept "bird")))) 17 | 18 | (define max-join 19 | (MaximalJoin 20 | (Present (Concept "crow")) 21 | (Present (Concept "bird")))) 22 | 23 | (define upper-set 24 | (UpperSet 25 | (Present (Concept "crow")) 26 | (Present (Concept "bird")))) 27 | -------------------------------------------------------------------------------- /tests/atoms/core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | LINK_LIBRARIES( 3 | atomcore 4 | atomspace 5 | ) 6 | 7 | IF(HAVE_GUILE) 8 | ADD_CXXTEST(CondLinkUTest) 9 | TARGET_LINK_LIBRARIES(CondLinkUTest execution smob) 10 | 11 | ADD_CXXTEST(ScopeLinkUTest) 12 | TARGET_LINK_LIBRARIES(ScopeLinkUTest smob) 13 | 14 | ADD_CXXTEST(RewriteLinkUTest) 15 | TARGET_LINK_LIBRARIES(RewriteLinkUTest smob) 16 | 17 | ADD_CXXTEST(PutLinkUTest) 18 | TARGET_LINK_LIBRARIES(PutLinkUTest execution smob) 19 | 20 | ADD_CXXTEST(QuotationUTest) 21 | TARGET_LINK_LIBRARIES(QuotationUTest execution smob) 22 | ENDIF(HAVE_GUILE) 23 | 24 | ADD_CXXTEST(CheckersUTest) 25 | ADD_CXXTEST(FindUtilsUTest) 26 | ADD_CXXTEST(NumberNodeUTest) 27 | ADD_CXXTEST(TypeIntersectionUTest) 28 | ADD_CXXTEST(TypeUtilsUTest) 29 | ADD_CXXTEST(VariablesUTest) 30 | -------------------------------------------------------------------------------- /tests/atoms/core/put-and.scm: -------------------------------------------------------------------------------- 1 | (define top 2 | (LambdaLink 3 | (VariableNode "$top-arg") 4 | (VariableNode "$top-arg"))) 5 | 6 | (define inheritance-shallow-abstraction 7 | (LambdaLink 8 | (VariableList 9 | (VariableNode "$sha-arg-0") 10 | (VariableNode "$sha-arg-1")) 11 | (InheritanceLink 12 | (VariableNode "$sha-arg-0") 13 | (VariableNode "$sha-arg-1")))) 14 | 15 | (define and-shallow-abstraction 16 | (LambdaLink 17 | (VariableList 18 | (VariableNode "$sha-arg-0") 19 | (VariableNode "$sha-arg-1")) 20 | (LocalQuoteLink 21 | (AndLink 22 | (VariableNode "$sha-arg-0") 23 | (VariableNode "$sha-arg-1"))))) 24 | -------------------------------------------------------------------------------- /tests/atoms/core/put-get-lambda.scm: -------------------------------------------------------------------------------- 1 | (Inheritance (Concept "B") (Concept "Parent")) 2 | (Inheritance (Concept "C") (Concept "Parent")) 3 | 4 | (define put-get-lambda 5 | (PutLink 6 | (LambdaLink 7 | (VariableNode "x") 8 | (EvaluationLink 9 | (PredicateNode "relation") 10 | (ListLink 11 | (VariableNode "x") 12 | (ConceptNode "A")))) 13 | (GetLink 14 | (Inheritance (Variable "$X") (Concept "Parent"))))) 15 | 16 | (define expected-put-get-lambda 17 | (SetLink 18 | (EvaluationLink 19 | (PredicateNode "relation") 20 | (ListLink 21 | (ConceptNode "B") 22 | (ConceptNode "A"))) 23 | (EvaluationLink 24 | (PredicateNode "relation") 25 | (ListLink 26 | (ConceptNode "C") 27 | (ConceptNode "A"))))) 28 | -------------------------------------------------------------------------------- /tests/atoms/core/put-get-multi.scm: -------------------------------------------------------------------------------- 1 | (use-modules (opencog) (opencog exec)) 2 | 3 | (Inheritance (Concept "Jim") (Concept "Father")) 4 | (Inheritance (Concept "Jane") (Concept "Mother")) 5 | 6 | (define put-get-multi 7 | (PutLink 8 | (LambdaLink 9 | (VariableList (Variable "x") (Variable "y")) 10 | (EvaluationLink 11 | (PredicateNode "relatives") 12 | (ListLink 13 | (Variable "x") 14 | (Variable "y") 15 | (Concept "mom and pop")))) 16 | (ListLink 17 | (GetLink (TypedVariable (Variable "$X") (Type 'ConceptNode)) 18 | (Inheritance (Variable "$X") (Concept "Father"))) 19 | (GetLink (TypedVariable (Variable "$X") (Type 'ConceptNode)) 20 | (Inheritance (Variable "$X") (Concept "Mother")))))) 21 | 22 | (define put-get-multi-empty 23 | (PutLink 24 | (LambdaLink 25 | (VariableList (Variable "x") (Variable "y")) 26 | (EvaluationLink 27 | (PredicateNode "relatives") 28 | (ListLink 29 | (Variable "x") 30 | (Variable "y") 31 | (Concept "mom and pop")))) 32 | (ListLink 33 | (GetLink (TypedVariable (Variable "$X") (Type 'ConceptNode)) 34 | (Inheritance (Variable "$X") (Concept "Father"))) 35 | (GetLink (TypedVariable (Variable "$X") (Type 'ConceptNode)) 36 | (Inheritance (Variable "$X") (Concept "XeZir")))))) 37 | -------------------------------------------------------------------------------- /tests/atoms/core/put-get.scm: -------------------------------------------------------------------------------- 1 | (Inheritance (Concept "B") (Concept "Parent")) 2 | (Inheritance (Concept "C") (Concept "Parent")) 3 | 4 | (define put-get 5 | (PutLink 6 | (EvaluationLink 7 | (PredicateNode "relation") 8 | (ListLink 9 | (VariableNode "x") 10 | (ConceptNode "A"))) 11 | (GetLink 12 | (Inheritance (Variable "$X") (Concept "Parent"))))) 13 | 14 | (define expected-put-get 15 | (SetLink 16 | (EvaluationLink 17 | (PredicateNode "relation") 18 | (ListLink 19 | (ConceptNode "B") 20 | (ConceptNode "A"))) 21 | (EvaluationLink 22 | (PredicateNode "relation") 23 | (ListLink 24 | (ConceptNode "C") 25 | (ConceptNode "A"))))) 26 | -------------------------------------------------------------------------------- /tests/atoms/core/put-multi-set.scm: -------------------------------------------------------------------------------- 1 | (use-modules (opencog) (opencog exec)) 2 | 3 | ; A lot like put-get-multi.scm, but the Gets have been previously run. 4 | 5 | (define put-multi-set 6 | (PutLink 7 | (LambdaLink 8 | (VariableList (Variable "x") (Variable "y")) 9 | (EvaluationLink 10 | (PredicateNode "relatives") 11 | (ListLink 12 | (Variable "x") 13 | (Variable "y") 14 | (Concept "mom and pop")))) 15 | (ListLink 16 | (SetLink (Concept "Jim")) 17 | (SetLink (Concept "Jane"))))) 18 | -------------------------------------------------------------------------------- /tests/atoms/core/put-quoted-lambda.scm: -------------------------------------------------------------------------------- 1 | (define put-quoted-conjuction-lambda 2 | (Put 3 | (VariableList 4 | (Variable "$vardecl") 5 | (Variable "$clause-1") 6 | (Variable "$clause-2")) 7 | (Quote 8 | (Lambda 9 | (Unquote (Variable "$vardecl")) 10 | (And 11 | (Unquote (Variable "$clause-1")) 12 | (Unquote (Variable "$clause-2"))))) 13 | (List 14 | (VariableList (Variable "$X") (Variable "$Y")) 15 | (Inheritance (Concept "A") (Variable "$X")) 16 | (Inheritance (Concept "$X") (Variable "$Y")))) 17 | ) 18 | 19 | (define put-quoted-conjuction-lambda-result 20 | (LambdaLink 21 | (VariableList 22 | (VariableNode "$X") 23 | (VariableNode "$Y") 24 | ) 25 | (AndLink 26 | (InheritanceLink 27 | (ConceptNode "$X") 28 | (VariableNode "$Y") 29 | ) 30 | (InheritanceLink 31 | (ConceptNode "A") 32 | (VariableNode "$X") 33 | ) 34 | ) 35 | ) 36 | ) 37 | -------------------------------------------------------------------------------- /tests/atoms/core/put-quoted.scm: -------------------------------------------------------------------------------- 1 | (define quoted-exec 2 | (LambdaLink 3 | (VariableList 4 | (VariableNode "$gsn") 5 | (VariableNode "$arg") 6 | ) 7 | (QuoteLink 8 | (ExecutionOutputLink 9 | (UnquoteLink 10 | (VariableNode "$gsn") 11 | ) 12 | (UnquoteLink 13 | (VariableNode "$arg") 14 | ) 15 | ) 16 | ) 17 | ) 18 | ) 19 | 20 | (define put-quoted-exec 21 | (PutLink 22 | (LambdaLink 23 | (VariableNode "$X") 24 | ) 25 | quoted-exec) 26 | ) 27 | 28 | (define quoted-eval 29 | (LambdaLink 30 | (VariableList 31 | (VariableNode "$gpn") 32 | (VariableNode "$arg") 33 | ) 34 | (QuoteLink 35 | (EvaluationLink 36 | (UnquoteLink 37 | (VariableNode "$gpn") 38 | ) 39 | (UnquoteLink 40 | (VariableNode "$arg") 41 | ) 42 | ) 43 | ) 44 | ) 45 | ) 46 | 47 | (define put-quoted-eval 48 | (PutLink 49 | (LambdaLink 50 | (VariableNode "$X") 51 | ) 52 | quoted-eval) 53 | ) 54 | -------------------------------------------------------------------------------- /tests/atoms/evaluation/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | LINK_LIBRARIES(execution atomspace) 3 | 4 | ADD_CXXTEST(EqualLinkUTest) 5 | ADD_CXXTEST(IdenticalLinkUTest) 6 | ADD_CXXTEST(MemberLinkUTest) 7 | ADD_CXXTEST(SubsetLinkUTest) 8 | ADD_CXXTEST(ExclusiveLinkUTest) 9 | -------------------------------------------------------------------------------- /tests/atoms/execution/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_CXXTEST(ApplyLinkUTest) 2 | TARGET_LINK_LIBRARIES(ApplyLinkUTest execution atomspace) 3 | 4 | LINK_LIBRARIES(execution smob atomspace) 5 | 6 | ADD_CXXTEST(DefinedSchemaUTest) 7 | ADD_CXXTEST(MapLinkUTest) 8 | -------------------------------------------------------------------------------- /tests/atoms/flow/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | LINK_LIBRARIES( 2 | atomflow 3 | atomcore 4 | atomspace 5 | ) 6 | 7 | ADD_CXXTEST(ValueOfUTest) 8 | ADD_CXXTEST(StreamValueOfUTest) 9 | 10 | ADD_CXXTEST(FormulaUTest) 11 | TARGET_LINK_LIBRARIES(FormulaUTest execution smob) 12 | 13 | ADD_CXXTEST(SetTVUTest) 14 | TARGET_LINK_LIBRARIES(SetTVUTest execution smob) 15 | 16 | ADD_CXXTEST(SetValueUTest) 17 | TARGET_LINK_LIBRARIES(SetValueUTest execution smob) 18 | 19 | ADD_CXXTEST(DynamicUTest) 20 | TARGET_LINK_LIBRARIES(DynamicUTest execution smob) 21 | -------------------------------------------------------------------------------- /tests/atoms/flow/set-value-flow.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; value-flows.scm -- Flowing Values unit test. 3 | ; Copy of /examples/atomspace/flows.scm 4 | 5 | (use-modules (opencog) (opencog exec)) 6 | 7 | (define foo (Concept "foo")) 8 | (define bar (Concept "bar")) 9 | (define key (Predicate "some key")) 10 | (define kee (Predicate "other key")) 11 | 12 | ; Expected results 13 | (define seq (FloatValue 1 2 3 4 5)) 14 | (define squ (FloatValue 1 4 9 16 25)) 15 | (define tri (FloatValue 1 3 6 10 15)) 16 | 17 | (cog-set-value! foo key seq) 18 | 19 | ; Copy from foo to bar 20 | (define set-value (SetValue bar kee (ValueOf foo key))) 21 | 22 | ; Try out some math 23 | (define square (SetValue bar kee 24 | (Times (ValueOf foo key) (ValueOf foo key)))) 25 | 26 | (DefineLink 27 | (DefinedSchema "triangle numbers") 28 | (Lambda 29 | (Variable "$X") 30 | (Divide 31 | (Times (Variable "$X") (Plus (Variable "$X") (Number 1))) 32 | (Number 2)))) 33 | 34 | (define triangle 35 | (SetValue bar kee 36 | (DefinedSchema "triangle numbers") 37 | (ValueOf foo key))) 38 | ; 39 | ; -------- THE END ----------- 40 | -------------------------------------------------------------------------------- /tests/atoms/grounded/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | LINK_LIBRARIES(grounded execution smob atomspace) 2 | 3 | ADD_CXXTEST(GroundedSchemaLocalUTest) 4 | -------------------------------------------------------------------------------- /tests/atoms/parallel/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | IF(HAVE_GUILE) 3 | ADD_CXXTEST(ParallelUTest) 4 | TARGET_LINK_LIBRARIES(ParallelUTest parallel clearbox execution smob atomspace) 5 | ADD_CXXTEST(ThreadedUTest) 6 | TARGET_LINK_LIBRARIES(ThreadedUTest parallel clearbox execution smob atomspace) 7 | ENDIF(HAVE_GUILE) 8 | -------------------------------------------------------------------------------- /tests/atoms/parallel/threaded.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; threaded.scm 3 | ; 4 | ; Part of the unit test for ExecuteThreadedLink. 5 | ; 6 | (use-modules (opencog) (opencog exec)) 7 | 8 | (Inheritance (Concept "rock") (Concept "mineral")) 9 | (Inheritance (Concept "flower") (Concept "plant")) 10 | (Inheritance (Concept "cat") (Concept "animal")) 11 | 12 | ; Just two threads. 13 | (define pexec 14 | (ExecuteThreaded 15 | (Set 16 | (Meet 17 | (TypedVariable (Variable "X") (Type 'Concept)) 18 | (Inheritance (Variable "X") (Concept "mineral"))) 19 | (Meet 20 | (TypedVariable (Variable "X") (Type 'Concept)) 21 | (Inheritance (Variable "X") (Concept "plant")))) 22 | )) 23 | 24 | ; (cog-execute! pexec) 25 | 26 | ; one-hundred things to do in two threads. 27 | (define pmany 28 | (ExecuteThreaded 29 | (Number 2) 30 | (Set 31 | (map 32 | (lambda (n) 33 | (Meet 34 | (TypedVariable (Variable "X") (Type 'Concept)) 35 | (Inheritance (Variable "X") (Concept "mineral")))) 36 | (iota 50)) 37 | (map 38 | (lambda (n) 39 | (Meet 40 | (TypedVariable (Variable "X") (Type 'Concept)) 41 | (Inheritance (Variable "X") (Concept "plant")))) 42 | (iota 50)) 43 | ))) 44 | 45 | ; (cog-execute! pmany) 46 | -------------------------------------------------------------------------------- /tests/atoms/pattern/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | LINK_LIBRARIES( 2 | execution 3 | atomcore 4 | atomspace 5 | ) 6 | 7 | ADD_CXXTEST(BindLinkUTest) 8 | ADD_CXXTEST(SatisfactionLinkUTest) 9 | ADD_CXXTEST(PatternUtilsUTest) 10 | -------------------------------------------------------------------------------- /tests/atoms/reduct/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | IF(HAVE_GUILE) 2 | LINK_LIBRARIES(clearbox execution smob atomspace) 3 | 4 | ADD_CXXTEST(ReductUTest) 5 | ADD_CXXTEST(HeavisideUTest) 6 | ADD_CXXTEST(MinMaxUTest) 7 | ADD_CXXTEST(AccumulateUTest) 8 | ENDIF(HAVE_GUILE) 9 | -------------------------------------------------------------------------------- /tests/atoms/truthvalue/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | LINK_LIBRARIES( 3 | smob 4 | atomspace 5 | value 6 | ) 7 | 8 | ADD_CXXTEST(SimpleTruthValueUTest) 9 | ADD_CXXTEST(TVUTest) 10 | ADD_CXXTEST(TVMergeUTest) 11 | ADD_CXXTEST(EvidenceCountTruthValueUTest) 12 | # ADD_CXXTEST(IndefiniteTruthValueUTest) 13 | -------------------------------------------------------------------------------- /tests/atoms/truthvalue/tv-test.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; tv-test.scm -- copy of demo example truthvalues.scm 3 | ; 4 | (use-modules (opencog)) 5 | 6 | ; TruthValues normally consist of two floats: 7 | ; by convention, a "strength" and a "confidence". 8 | (define tv (SimpleTruthValue 0.1 0.2)) 9 | 10 | ; A truth value can be converted to a scheme list 11 | (cog-value->list tv) 12 | 13 | ; Alternately, individual elements in the list can be accessed directly. 14 | ; This behaves just like (list-ref (cog-value->list VAL) NUM) 15 | ; but is computationally faster. 16 | (cog-value-ref tv 0) 17 | (cog-value-ref tv 1) 18 | 19 | ; TruthValues can be attached to atoms: 20 | (define a (Concept "aaa")) 21 | (cog-set-tv! a tv) 22 | 23 | ; The attached truth value can be fetched. 24 | (cog-tv a) 25 | 26 | (cog-set-tv! (Concept "bbb") (CountTruthValue 1.0e-6 -19.9316 55)) 27 | -------------------------------------------------------------------------------- /tests/atoms/value/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | LINK_LIBRARIES( 2 | value 3 | atombase 4 | exec 5 | ) 6 | 7 | # Tests in order of increasing functional complexity/dependency 8 | ADD_CXXTEST(ValueUTest) 9 | ADD_CXXTEST(PtrValueUTest) 10 | 11 | ADD_CXXTEST(StreamUTest) 12 | TARGET_LINK_LIBRARIES(StreamUTest smob atomspace) 13 | 14 | ADD_CXXTEST(VoidValueUTest) 15 | -------------------------------------------------------------------------------- /tests/atomspace/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | LINK_LIBRARIES( 3 | atombase 4 | atomspace 5 | ) 6 | 7 | IF(HAVE_GUILE) 8 | ADD_CXXTEST(AtomTableUTest) 9 | TARGET_LINK_LIBRARIES(AtomTableUTest smob clearbox) 10 | ENDIF(HAVE_GUILE) 11 | 12 | ADD_CXXTEST(HashMixUTest) 13 | ADD_CXXTEST(AtomSpaceUTest) 14 | ADD_CXXTEST(AtomSpaceAsyncUTest) 15 | ADD_CXXTEST(UseCountUTest) 16 | ADD_CXXTEST(MultiSpaceUTest) 17 | ADD_CXXTEST(COWSpaceUTest) 18 | ADD_CXXTEST(RemoveUTest) 19 | 20 | # The ValuationTable is no longer used or even built, so don't test it. 21 | # ADD_CXXTEST(ValuationTableUTest) 22 | -------------------------------------------------------------------------------- /tests/cython/PythonUtilitiesUTest.cxxtest: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | 8 | using std::string; 9 | 10 | using namespace opencog; 11 | 12 | 13 | class PythonUtilitiesUTest : public CxxTest::TestSuite 14 | { 15 | 16 | private: 17 | 18 | 19 | public: 20 | 21 | PythonUtilitiesUTest() { 22 | 23 | } 24 | 25 | ~PythonUtilitiesUTest() { 26 | } 27 | 28 | void setUp() { 29 | } 30 | 31 | void tearDown() { 32 | } 33 | 34 | void testOpencogInitializationFinalization() { 35 | 36 | // Initialize Python. 37 | initialize_python(); 38 | 39 | // Stop Python. 40 | finalize_python(); 41 | 42 | // Do it again. 43 | 44 | // Stop Python. 45 | finalize_python(); 46 | 47 | } 48 | 49 | 50 | }; 51 | -------------------------------------------------------------------------------- /tests/cython/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Preconditions 3 | 4 | ```nose``` Python testing framework is required. 5 | 6 | Installation using ```apt-get``` package manager : 7 | ``` 8 | apt-get install python3-nose 9 | ``` 10 | 11 | ## Running tests 12 | 13 | You may need to set up the PYTHON path: 14 | export PYTHONPATH=${PROJECT_BINARY_DIR}/opencog/cython 15 | or, if installed: 16 | export PYTHONPATH=/usr/local/lib/python3.7/dist-packages/opencog:${PYTHON} 17 | 18 | For example: 19 | export PYTHONPATH=build/opencog/cython PROJECT_SOURCE_DIR=. 20 | 21 | Then from atomspace root source dir execute: 22 | 23 | ``` 24 | nosetests3 -vs ./tests/cython/ 25 | nosetests3 -vs ./tests/cython/atomspace/ 26 | nosetests3 -vs ./tests/cython/bindlink/ 27 | nosetests3 -vs ./tests/cython/guile/ 28 | nosetests3 -vs ./tests/cython/utilities/ 29 | ``` 30 | -------------------------------------------------------------------------------- /tests/cython/atomspace/test_ptrvalue.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from opencog.atomspace import AtomSpace 4 | from opencog.utilities import initialize_opencog, finalize_opencog 5 | from opencog.atomspace import PtrValue 6 | from opencog.type_constructors import ConceptNode 7 | 8 | class PtrValueTest(unittest.TestCase): 9 | 10 | def setUp(self): 11 | self.space = AtomSpace() 12 | initialize_opencog(self.space) 13 | 14 | def tearDown(self): 15 | finalize_opencog() 16 | del self.space 17 | 18 | def test_call_grounded_object_predicate(self): 19 | obj = TestObject("some object") 20 | 21 | value = PtrValue(obj) 22 | 23 | ref = value.value() 24 | self.assertEqual(ref.name, "some object") 25 | 26 | def test_pass_value_via_atom(self): 27 | obj = TestObject("some object") 28 | container = ConceptNode("container") 29 | key = ConceptNode("key") 30 | container.set_value(key, PtrValue(obj)) 31 | 32 | value = container.get_value(key) 33 | 34 | ref = value.value() 35 | self.assertEqual(ref.name, "some object") 36 | 37 | class TestObject: 38 | def __init__(self, name): 39 | self.name = name 40 | -------------------------------------------------------------------------------- /tests/cython/guile/basic_unify.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Basic test of unification 3 | ; 4 | ; Create some misc atoms. 5 | 6 | (use-modules (opencog)) 7 | (use-modules (opencog exec)) 8 | 9 | (define (stv mean conf) (cog-new-stv mean conf)) 10 | 11 | (ListLink 12 | (ConceptNode "hello" (stv 0.5 0.5)) 13 | (ConceptNode "world") 14 | ) 15 | 16 | (define wobbly 17 | (ConceptNode "wobbly" (stv 0.5 0.5)) 18 | ) 19 | 20 | (InheritanceLink (ConceptNode "Frog") (ConceptNode "animal")) 21 | (InheritanceLink (ConceptNode "Zebra") (ConceptNode "animal")) 22 | (InheritanceLink (ConceptNode "Deer") (ConceptNode "animal")) 23 | (InheritanceLink (ConceptNode "Spaceship") (ConceptNode "machine")) 24 | 25 | (define find-animals 26 | (BindLink 27 | (VariableNode "$var") 28 | (InheritanceLink 29 | (VariableNode "$var") 30 | (ConceptNode "animal") 31 | ) 32 | (VariableNode "$var") 33 | ) 34 | ) 35 | -------------------------------------------------------------------------------- /tests/haskell/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY(executionTestLib) 2 | ADD_SUBDIRECTORY(haskellTest) -------------------------------------------------------------------------------- /tests/haskell/executionTestLib/.gitignore: -------------------------------------------------------------------------------- 1 | .stack-work/ 2 | a.out 3 | libopencoglib-0.1.0.0.so 4 | -------------------------------------------------------------------------------- /tests/haskell/executionTestLib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_CUSTOM_TARGET(haskell-atomspace-executionlib 2 | DEPENDS atomspace-cwrapper 3 | COMMAND sh buildTest.sh "${PROJECT_BINARY_DIR}/opencog/haskell" "${CMAKE_CURRENT_SOURCE_DIR}" 4 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 5 | COMMENT "Building Haskell Execution-Test." 6 | ) 7 | -------------------------------------------------------------------------------- /tests/haskell/executionTestLib/buildTest.sh: -------------------------------------------------------------------------------- 1 | BIN_DIR=$1 2 | SOURCE_DIR=$2 3 | 4 | libname=opencoglib 5 | libver=$(stack query locals opencoglib | awk 'NR==2' | sed 's/version: //g' | sed "s/'//g" | sed "s/ //g") 6 | 7 | if [ "$(id -u)" -ne 0 ] 8 | then 9 | #Cleanup of last build if it exists 10 | artifact_1="$SOURCE_DIR/../haskellTest/lib$libname-$libver.so" 11 | artifact_2="$SOURCE_DIR/a.out" 12 | if [ -e "$artifact_1" ]; then rm "$artifact_1"; fi 13 | if [ -e "$artifact_2" ]; then rm "$artifact_2"; fi 14 | 15 | # Build haskell bindings package. 16 | stack build --no-run-tests --extra-lib-dirs=${BIN_DIR} 17 | 18 | LIB=$(find . -name "*$libname*.so" | awk 'NR==1') 19 | 20 | cp $LIB "$SOURCE_DIR/../haskellTest/lib$libname-$libver.so" 21 | else 22 | echo "Can't run Haskell-Tests as root" 23 | fi 24 | -------------------------------------------------------------------------------- /tests/haskell/executionTestLib/hsbracket.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | static void my_enter(void) __attribute__((constructor)); 5 | static void my_enter(void) 6 | { 7 | static char *argv[] = { "libEval.so", 0 }, **argv_ = argv; 8 | static int argc = 1; 9 | hs_init(&argc, &argv_); 10 | } 11 | 12 | static void my_exit(void) __attribute__((destructor)); 13 | static void my_exit(void) 14 | { 15 | hs_exit(); 16 | } 17 | -------------------------------------------------------------------------------- /tests/haskell/executionTestLib/opencoglib.cabal: -------------------------------------------------------------------------------- 1 | name: opencoglib 2 | version: 0.1.0.0 3 | synopsis: Initial project template from stack 4 | description: Please see README.md 5 | homepage: http://github.com/rTreutlein/opencoglib#readme 6 | license: BSD3 7 | author: Roman Treutlein 8 | maintainer: roman.treutlein@gmail.com 9 | copyright: GPL-3 10 | category: Artificial Intelligence 11 | build-type: Simple 12 | -- extra-source-files: 13 | cabal-version: >=1.10 14 | 15 | library 16 | hs-source-dirs: src 17 | exposed-modules: OpenCog.Lib 18 | build-depends: base >= 4.7 && < 5 19 | , opencog-atomspace 20 | c-sources: hsbracket.c 21 | ghc-options: -dynamic -shared -fPIC 22 | --extra-libraries: HSrts-ghc8.0.1 23 | default-language: Haskell2010 24 | -------------------------------------------------------------------------------- /tests/haskell/executionTestLib/src/OpenCog/Lib.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE GADTs #-} 2 | module OpenCog.Lib where 3 | 4 | import OpenCog.AtomSpace 5 | import Foreign.C 6 | import Foreign.Ptr 7 | 8 | foreign export ccall "someFunc" 9 | c_func :: Ptr AtomSpaceRef -> Handle -> IO (Handle) 10 | 11 | c_func = exportFunction someFunc 12 | 13 | someFunc :: Atom -> AtomSpace Atom 14 | someFunc a = pure a 15 | 16 | 17 | foreign export ccall "somePredicate" 18 | c_pred :: Ptr AtomSpaceRef -> Handle -> IO (TruthValueP) 19 | 20 | c_pred = exportPredicate somePredicate 21 | 22 | somePredicate :: Atom -> TruthVal 23 | somePredicate (Link "ListLink" [(Node _ _ tv)] _) = tv 24 | somePredicate (Link "ListLink" [(Link _ _ tv)] _) = tv 25 | -------------------------------------------------------------------------------- /tests/haskell/executionTestLib/stack.yaml: -------------------------------------------------------------------------------- 1 | # For more information, see: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md 2 | 3 | # Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2) 4 | resolver: lts-8.5 5 | 6 | # Local packages, usually specified by relative directory name 7 | packages: 8 | - '.' 9 | - '../../../opencog/haskell' 10 | 11 | # Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3) 12 | #extra-deps: [opencog-atomspace-0.1.0.1] 13 | 14 | # Override default flag values for local packages and extra-deps 15 | flags: {} 16 | 17 | # Extra package databases containing global packages 18 | extra-package-dbs: [] 19 | 20 | # Control whether we use the GHC we find on the path 21 | # system-ghc: true 22 | 23 | # Require a specific version of stack, using version ranges 24 | # require-stack-version: -any # Default 25 | # require-stack-version: >= 0.1.4.0 26 | 27 | # Override the architecture used by stack, especially useful on Windows 28 | # arch: i386 29 | # arch: x86_64 30 | 31 | # Extra directories used by stack for building 32 | # extra-include-dirs: [/path/to/dir] 33 | # extra-lib-dirs: [/usr/local/lib/opencog] 34 | # 35 | 36 | ghc-options: 37 | opencoglib: -lHSrts-ghc8.0.2 38 | -------------------------------------------------------------------------------- /tests/haskell/haskellTest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_CUSTOM_TARGET(haskell-atomspace-test 2 | DEPENDS atomspace-cwrapper 3 | COMMAND sh buildTest.sh "${PROJECT_BINARY_DIR}/opencog/haskell" 4 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 5 | COMMENT "Building Haskell Test-Suite." 6 | ) 7 | 8 | ADD_DEPENDENCIES(tests haskell-atomspace-test) 9 | 10 | #The Code does not actually depend on haskell-atomspace-test 11 | #but we can't build both at the same time 12 | ADD_DEPENDENCIES(haskell-atomspace-test haskell-atomspace-executionlib) 13 | 14 | ADD_TEST(NAME HaskellAtomSpace 15 | COMMAND sh runTest.sh "${PROJECT_BINARY_DIR}/opencog/haskell" "${CMAKE_CURRENT_SOURCE_DIR}" 16 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 17 | ) 18 | -------------------------------------------------------------------------------- /tests/haskell/haskellTest/Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | main = defaultMain 3 | -------------------------------------------------------------------------------- /tests/haskell/haskellTest/buildTest.sh: -------------------------------------------------------------------------------- 1 | BIN_DIR=$1 2 | 3 | if [ "$(id -u)" -ne 0 ] 4 | then 5 | # Build haskell bindings package. 6 | stack test --no-run-tests --extra-lib-dirs=${BIN_DIR} 7 | patchelf --set-rpath ${BIN_DIR} `stack path --dist-dir`"/build/haskell-test-suite/haskell-test-suite" 8 | else 9 | echo "Can't run Haskell-Tests as root" 10 | fi 11 | -------------------------------------------------------------------------------- /tests/haskell/haskellTest/haskell-test.cabal: -------------------------------------------------------------------------------- 1 | name: haskell-test 2 | version: 0.1.0.0 3 | synopsis: Tests for the Haskell AtomSpace Bindings 4 | description: 5 | homepage: github.com/opencog/atomspace/tree/master/tests/haskell 6 | license: OtherLicense 7 | author: Roman Treutlein 8 | maintainer: - 9 | category: Artificial Intelligence 10 | build-type: Simple 11 | cabal-version: >=1.10 12 | 13 | library 14 | hs-source-dirs: src 15 | exposed-modules: Dummy 16 | build-depends: base >= 4.7 && < 5 17 | , directory 18 | default-language: Haskell2010 19 | 20 | Test-Suite haskell-test-suite 21 | type: exitcode-stdio-1.0 22 | main-is: Main.hs 23 | ghc-options: -threaded -rtsopts -with-rtsopts=-N 24 | build-depends: base 25 | , opencog-atomspace 26 | , haskell-test 27 | , directory 28 | default-language: Haskell2010 29 | -------------------------------------------------------------------------------- /tests/haskell/haskellTest/log.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/singnet/atomspace/5bc43d339687af07b589beb73615ca318d346314/tests/haskell/haskellTest/log.txt -------------------------------------------------------------------------------- /tests/haskell/haskellTest/runTest.sh: -------------------------------------------------------------------------------- 1 | BIN_DIR=$1 2 | 3 | if [ "$(id -u)" -ne 0 ] 4 | then 5 | # Build haskell bindings package. 6 | stack test --extra-lib-dirs=${BIN_DIR} 7 | else 8 | echo "Can't run Haskell-Tests as root" 9 | fi 10 | -------------------------------------------------------------------------------- /tests/haskell/haskellTest/src/Dummy.hs: -------------------------------------------------------------------------------- 1 | module Dummy where 2 | -------------------------------------------------------------------------------- /tests/haskell/haskellTest/stack.yaml: -------------------------------------------------------------------------------- 1 | # For more information, see: https://github.com/commercialhaskell/stack/blob/master/doc/yaml_configuration.md 2 | 3 | # Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2) 4 | resolver: lts-8.5 5 | 6 | # Local packages, usually specified by relative directory name 7 | packages: 8 | - '.' 9 | - '../../../opencog/haskell' 10 | 11 | # Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3) 12 | extra-deps: [] 13 | 14 | # Override default flag values for local packages and extra-deps 15 | flags: {} 16 | 17 | # Control whether we use the GHC we find on the path 18 | # system-ghc: true 19 | 20 | # Require a specific version of stack, using version ranges 21 | # require-stack-version: -any # Default 22 | # require-stack-version: >= 0.1.4.0 23 | 24 | # Override the architecture used by stack, especially useful on Windows 25 | # arch: i386 26 | # arch: x86_64 27 | 28 | # Extra directories used by stack for building 29 | # extra-include-dirs: [/usr/local/lib/opencog/] 30 | extra-lib-dirs: [../../../build/opencog/haskell] 31 | 32 | ghc-options: 33 | haskell-test: -latomspace-cwrapper 34 | -------------------------------------------------------------------------------- /tests/matrix/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | INCLUDE_DIRECTORIES ( 2 | ${PROJECT_SOURCE_DIR}/opencog/atomspace 3 | ${PROJECT_SOURCE_DIR}/opencog/guile 4 | ${PROJECT_SOURCE_DIR}/opencog/util 5 | ) 6 | 7 | LINK_DIRECTORIES( 8 | ${PROJECT_BINARY_DIR}/opencog/atomspace 9 | ${PROJECT_BINARY_DIR}/opencog/guile 10 | ${PROJECT_BINARY_DIR}/opencog/util 11 | ) 12 | 13 | LINK_LIBRARIES( 14 | atomspace 15 | persist 16 | persist-sql 17 | smob 18 | ) 19 | 20 | ADD_CXXTEST(VectorAPIUTest) 21 | -------------------------------------------------------------------------------- /tests/persist/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY (sexpr) 2 | ADD_SUBDIRECTORY (sql) 3 | ADD_SUBDIRECTORY (tlb) 4 | 5 | IF (HAVE_GUILE AND HAVE_GEARMAN) 6 | ADD_SUBDIRECTORY (gearman) 7 | ENDIF (HAVE_GUILE AND HAVE_GEARMAN) 8 | -------------------------------------------------------------------------------- /tests/persist/gearman/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | INCLUDE_DIRECTORIES ( 2 | ${PROJECT_SOURCE_DIR}/opencog/atomspace 3 | ${PROJECT_SOURCE_DIR}/opencog/persist/gearman 4 | ) 5 | 6 | LINK_DIRECTORIES ( 7 | ${PROJECT_BINARY_DIR}/opencog/atomspace 8 | ) 9 | 10 | LINK_LIBRARIES ( 11 | smob 12 | atomspace 13 | dist-gearman 14 | ) 15 | 16 | # Make sure that the Gearman job server is running. 17 | # See the README file for details. 18 | FIND_PROGRAM(GEARMAN_JOB_SERVER gearmand) 19 | IF (GEARMAN_JOB_SERVER) 20 | ADD_CONFIGURABLE_CXXTEST(GearmanUTest) 21 | 22 | ADD_DEPENDENCIES(tests GearmanUTest) 23 | 24 | ADD_TEST(NAME GearmanUTest 25 | COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/run_gearman_test.sh 26 | ${CMAKE_CURRENT_BINARY_DIR} 27 | ) 28 | SET_TESTS_PROPERTIES(GearmanUTest 29 | PROPERTIES 30 | ENVIRONMENT "GUILE_LOAD_PATH=${GUILE_LOAD_PATH}" 31 | ) 32 | 33 | ENDIF (GEARMAN_JOB_SERVER) 34 | -------------------------------------------------------------------------------- /tests/persist/gearman/README: -------------------------------------------------------------------------------- 1 | 2 | 3 | In order for this test to pass, you must install the package 4 | `gearman-job-server` (in Debian, Ubuntu) and also make sure that the 5 | job server is actually running: viz, 6 | 7 | ``` 8 | sudo service gearman-job-server status 9 | ``` 10 | and, if necessary, 11 | ``` 12 | sudo service gearman-job-server start 13 | ``` 14 | -------------------------------------------------------------------------------- /tests/persist/gearman/run_gearman_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TEST_DIR=$1 4 | 5 | ps -C gearmand 6 | if [ 1 -eq "$?" ]; then 7 | gearmand -d -l stderr 8 | shutdown_server=0 9 | fi 10 | 11 | ${TEST_DIR}/GearmanUTest 12 | exit_status="$?" 13 | 14 | if [ 0 -eq "$shutdown_server" ]; then 15 | gearadmin --shutdown 16 | fi 17 | 18 | exit "$exit_status" 19 | -------------------------------------------------------------------------------- /tests/persist/sexpr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | LINK_LIBRARIES(atomspace load_scm) 2 | 3 | ADD_CXXTEST(FastLoadUTest) 4 | ADD_CXXTEST(CommandsUTest) 5 | 6 | ADD_GUILE_TEST(FileStorageUTest file-storage.scm) 7 | -------------------------------------------------------------------------------- /tests/persist/sql/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # If SQL is not installed, then don't build the tests. 3 | 4 | IF(HAVE_SQL_STORAGE) 5 | ADD_SUBDIRECTORY (multi-driver) 6 | ENDIF(HAVE_SQL_STORAGE) 7 | -------------------------------------------------------------------------------- /tests/persist/sql/multi-driver/README.md: -------------------------------------------------------------------------------- 1 | 2 | Forgot how to debug? 3 | Try this: 4 | ``` 5 | psql -d opencog_test -U opencog_tester 6 | \d 7 | select * from atoms; 8 | select * from valuations; 9 | ``` 10 | -------------------------------------------------------------------------------- /tests/persist/sql/multi-driver/mkuri.h: -------------------------------------------------------------------------------- 1 | std::string mkuri(std::string driver, std::string dbname, 2 | std::string username, std::string passwd) 3 | { 4 | std::string uri; 5 | 6 | // Sigh. The buildbot postgres config balks at the 7 | // "localhost" URI scheme. 8 | if (driver == "postgres") 9 | { 10 | uri = driver; 11 | uri += ":///"; 12 | uri += dbname; 13 | uri += "?user="; 14 | uri += username; 15 | uri += "&password="; 16 | uri += passwd; 17 | } 18 | else 19 | { 20 | uri = driver; 21 | uri += "://"; 22 | uri += username; 23 | uri += ":"; 24 | uri += passwd; 25 | uri += "/"; 26 | uri += dbname; 27 | } 28 | return uri; 29 | } 30 | -------------------------------------------------------------------------------- /tests/persist/tlb/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | LINK_LIBRARIES( 3 | tlb 4 | atombase 5 | atomspace 6 | ) 7 | 8 | ADD_CXXTEST(TLBUTest) 9 | -------------------------------------------------------------------------------- /tests/query/absent-disconn1.scm: -------------------------------------------------------------------------------- 1 | 2 | (use-modules (opencog) (opencog exec)) 3 | 4 | (define soln (SetLink)) 5 | 6 | (ListLink (ConceptNode "A") (ConceptNode "B")) 7 | (ListLink (ConceptNode "Y") (ConceptNode "X")) 8 | 9 | (define test 10 | (BindLink 11 | (VariableList 12 | (TypedVariableLink (VariableNode "$var1") (TypeNode "ConceptNode")) 13 | (TypedVariableLink (VariableNode "$var2") (TypeNode "ConceptNode")) 14 | (TypedVariableLink (VariableNode "$var3") (TypeNode "ConceptNode")) 15 | ) 16 | (AndLink 17 | (ListLink 18 | (VariableNode "$var1") 19 | (VariableNode "$var2") 20 | ) 21 | (AbsentLink 22 | (ListLink 23 | (VariableNode "$var3") 24 | (ConceptNode "X") 25 | ) 26 | ) 27 | ) 28 | (ListLink 29 | (VariableNode "$var1") 30 | (VariableNode "$var2") 31 | ) 32 | ) 33 | ) 34 | -------------------------------------------------------------------------------- /tests/query/absent-disconn2.scm: -------------------------------------------------------------------------------- 1 | (define soln (SetLink (ListLink (ConceptNode "A") (ConceptNode "B")))) 2 | 3 | (define test 4 | (BindLink 5 | (VariableList 6 | (TypedVariableLink (VariableNode "$var1") (TypeNode "ConceptNode")) 7 | (TypedVariableLink (VariableNode "$var2") (TypeNode "ConceptNode")) 8 | (TypedVariableLink (VariableNode "$var3") (TypeNode "ConceptNode")) 9 | ) 10 | (AndLink 11 | (ListLink 12 | (VariableNode "$var1") 13 | (VariableNode "$var2") 14 | ) 15 | (AbsentLink 16 | (ListLink 17 | (VariableNode "$var3") 18 | (ConceptNode "X") 19 | ) 20 | ) 21 | ) 22 | (ListLink 23 | (VariableNode "$var1") 24 | (VariableNode "$var2") 25 | ) 26 | ) 27 | ) 28 | -------------------------------------------------------------------------------- /tests/query/anchor.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; AnchorLink unit test 3 | ; 4 | (use-modules (opencog) (opencog exec)) 5 | 6 | (Evaluation (Predicate "foo") (List (Concept "A") (Concept "alpha"))) 7 | (Evaluation (Predicate "foo") (List (Concept "B") (Concept "alpha"))) 8 | (Evaluation (Predicate "foo") (List (Concept "C") (Concept "alpha"))) 9 | 10 | (define getli 11 | (Get (VariableList 12 | (TypedVariable (Variable "$x") (Type 'ConceptNode)) 13 | (Anchor "get-results")) 14 | (Present 15 | (Evaluation (Predicate "foo") 16 | (List (Variable "$x") (Concept "alpha")))))) 17 | 18 | ; (cog-execute! getli) 19 | ; (cog-incoming-by-type (AnchorNode "get-results") 'MemberLink) 20 | ; ---------------------------------- 21 | 22 | (define bindli 23 | (Bind (VariableList 24 | (TypedVariable (Variable "$z") (Type 'ConceptNode)) 25 | (Anchor "bind-results")) 26 | (Present 27 | (Evaluation (Predicate "foo") 28 | (List (Variable "$z") (Concept "alpha")))) 29 | (Inheritance (Variable "$z") (Concept "letters")))) 30 | 31 | ; (cog-execute! bindli) 32 | ; (cog-incoming-by-type (AnchorNode "bind-results") 'MemberLink) 33 | ; ---------------------------------- 34 | 35 | ; Stimulous-Response-style AI 36 | (define srai 37 | (Evaluation (Predicate "foo") (List (Concept "C") (Concept "alpha")))) 38 | 39 | ; (cog-execute! (Dual srai)) 40 | -------------------------------------------------------------------------------- /tests/query/arcana-bigger-dummy.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Unit testing for addition of more complex dummy clauses 3 | ; 4 | (use-modules (opencog)) 5 | (use-modules (opencog exec)) 6 | 7 | ; Data -- This is the answer we expect to get. 8 | (define stfu 9 | (SetLink 10 | (ListLink 11 | (ImplicationLink 12 | (ListLink 13 | (ConceptNode "I") 14 | (ConceptNode "love") 15 | (ConceptNode "you")) 16 | (ConceptNode "blrable")) 17 | (ConceptNode "blrable")))) 18 | 19 | ; Query. Should return the above. 20 | ; Note that the query has only a single evaluatable within it. 21 | (define bigger-dummy 22 | (GetLink 23 | (VariableList 24 | (TypedVariable (VariableNode "$whole") (Type "ImplicationLink")) 25 | (VariableNode "$impl")) 26 | (Identical 27 | (VariableNode "$whole") 28 | (ImplicationLink 29 | (ListLink 30 | (ConceptNode "I") 31 | (ConceptNode "love") 32 | (ConceptNode "you")) 33 | (VariableNode "$impl")) 34 | ) 35 | )) 36 | -------------------------------------------------------------------------------- /tests/query/arcana-const.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Unit testing for a constant pattern 3 | ; 4 | (use-modules (opencog)) 5 | (use-modules (opencog exec)) 6 | 7 | (define marconi 8 | (ListLink 9 | (ConceptNode "Marconi") 10 | (ConceptNode "developed") 11 | (ConceptNode "the") 12 | (ConceptNode "first") 13 | (ConceptNode "practical") 14 | (ConceptNode "wireless."))) 15 | 16 | ; A query with no variables in it. 17 | (define who 18 | (BindLink 19 | (ListLink 20 | (ConceptNode "WHO") 21 | (ConceptNode "INVENTED") 22 | (ConceptNode "RADIO")) 23 | marconi)) 24 | 25 | (DefineLink (DefinedSchemaNode "Marco did") marconi) 26 | 27 | ; Same query as above, but with the answer wrapped up in a define. 28 | (define whodfn 29 | (BindLink 30 | (ListLink 31 | (ConceptNode "WHO") 32 | (ConceptNode "INVENTED") 33 | (ConceptNode "RADIO")) 34 | (DefinedSchemaNode "Marco did"))) 35 | -------------------------------------------------------------------------------- /tests/query/arcana-dummy.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Unit testing for addition of "dummy" clauses into pattern. 3 | ; 4 | (use-modules (opencog)) 5 | (use-modules (opencog exec)) 6 | 7 | ; Data 8 | (Number 42) 9 | (Number 3003) 10 | 11 | ; Query. Should return only "42" 12 | (define dummy 13 | (GetLink 14 | (TypedVariable (Variable "$x") (Type "NumberNode")) 15 | (GreaterThan (Number 88) (Variable "$x")))) 16 | -------------------------------------------------------------------------------- /tests/query/arcana-numeric.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; aracana-numeric.scm 3 | ; 4 | ; Some squonky numeric hacking about. 5 | ; Get the current time, see how much time has elapsed, and 6 | ; return true or false, depending on the elapsed time. 7 | 8 | (use-modules (opencog) (opencog exec)) 9 | 10 | (StateLink (SchemaNode "start-interaction-timestamp") (NumberNode 0)) 11 | (StateLink (SchemaNode "current expression duration") (NumberNode 2.0)) ; in seconds 12 | 13 | ;; line 757, timestamp 14 | (DefineLink 15 | (DefinedSchemaNode "set timestamp") 16 | (PutLink 17 | (StateLink (SchemaNode "start-interaction-timestamp") 18 | (VariableNode "$x")) 19 | (TimeLink))) 20 | 21 | (DefineLink 22 | (DefinedSchemaNode "get timestamp") 23 | (GetLink 24 | (StateLink (SchemaNode "start-interaction-timestamp") 25 | (VariableNode "$x")))) 26 | 27 | ;; Evaluate to true, if an expression should be shown. 28 | ;; line 933, should_show_expression() 29 | (DefineLink 30 | (DefinedPredicateNode "Time to change expression") 31 | (GreaterThanLink 32 | (MinusLink 33 | (TimeLink) 34 | (DefinedSchemaNode "get timestamp")) 35 | (GetLink (StateLink (SchemaNode "current expression duration") 36 | (VariableNode "$x"))) ; in seconds 37 | )) 38 | -------------------------------------------------------------------------------- /tests/query/bind-tv.scm: -------------------------------------------------------------------------------- 1 | (use-modules (opencog) (opencog exec)) 2 | 3 | ;; Definitions 4 | (define (sp x) 5 | " 6 | Return (stv 0.55 0.55) and store it into its own call, that is 7 | 8 | Evaluation (stv 0.55 0.55) 9 | GroundedPredicate \"scm:sp\" 10 | x 11 | " 12 | (let* ((tv (stv 0.55 0.55)) 13 | (gp (GroundedPredicate "scm:sp")) 14 | (ev (Evaluation gp x))) 15 | (cog-set-tv! ev tv) 16 | tv)) 17 | 18 | (define GP (GroundedPredicate "scm:sp")) 19 | (define A (Concept "A")) 20 | (define B (Concept "B")) 21 | (define E (Evaluation GP A)) 22 | 23 | (define X (Variable "$X")) 24 | ;; Facts 25 | 26 | (Inheritance A B) 27 | 28 | ;; Query 29 | ;; Note that this is a strange query -- the variable X never appears 30 | ;; in the EvaluationLink, and so this splits up as two disjoint queries 31 | ;; having nothing to do with each-other. 32 | 33 | (define query 34 | (BindLink 35 | (AndLink 36 | E 37 | (InheritanceLink X B)) 38 | E)) 39 | -------------------------------------------------------------------------------- /tests/query/blair-witch.scm: -------------------------------------------------------------------------------- 1 | ;; Data set for testing issue 2 | ;; 3 | ;; https://github.com/opencog/atomspace/issues/1528 4 | ;; 5 | ;; blair-witch is here to emphasize the weirdness of the bug. 6 | 7 | ;; Grounded Predicate 8 | (define (truth X) (stv 1 1)) 9 | (define (alternative-fact X) (stv 0 1)) 10 | 11 | ;; Query 12 | (define find-something 13 | (BindLink 14 | (AndLink 15 | (VariableNode "$f-lamb-e84bdd8") 16 | (NumberNode "2.000000") 17 | (EvaluationLink 18 | (GroundedPredicateNode "scm: truth") 19 | (NumberNode "2.000000") 20 | ) 21 | ) 22 | (Concept "A")) 23 | ) 24 | 25 | (define find-nothing 26 | (BindLink 27 | (AndLink 28 | (VariableNode "$f-lamb-e84bdd8") 29 | (NumberNode "2.000000") 30 | (EvaluationLink 31 | (GroundedPredicateNode "scm: alternative-fact") 32 | (NumberNode "2.000000") 33 | ) 34 | ) 35 | (Concept "A")) 36 | ) 37 | -------------------------------------------------------------------------------- /tests/query/buggy-equal-arithmetic.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; buggy-equal-arithmetic.scm 3 | ; 4 | ; Unit test for github bug report opencog/atomspace#2284 5 | ; 6 | (use-modules (opencog) (opencog exec)) 7 | 8 | (Number 1) 9 | (Number 2) 10 | (Number 3) 11 | (Number 4) 12 | (Number 5) 13 | (Number 6) 14 | 15 | ;; Exepcted result of running below is (Number 6) 16 | (define arithmetic-search 17 | (GetLink 18 | (TypedVariable (Variable "$X1") (Type 'NumberNode)) 19 | (Equal (Plus (Variable "$X1") (Number 5)) (Number 11)))) 20 | 21 | ; (cog-execute! arithmetic-search) 22 | -------------------------------------------------------------------------------- /tests/query/buggy-equal-unify.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; buggy-equal-unify.scm 3 | ; Unit test for https://github.com/opencog/atomspace/issues/2650 4 | ; Unification of variables was mis-handled. 5 | ; 6 | 7 | (use-modules (opencog) (opencog exec)) 8 | 9 | (Member 10 | (Evaluation 11 | (Predicate "has_name") 12 | (List (Concept "node1") (Concept "name1"))) 13 | (Concept "node2")) 14 | 15 | (define qunify 16 | (Query 17 | (And 18 | (Member 19 | (Evaluation (Predicate "has_name") (Variable "Y")) 20 | (Concept "node2")) 21 | (Equal 22 | (Variable "Y") 23 | (List (Variable "N") (Concept "name1")))) 24 | (Variable "Y"))) 25 | 26 | ; (cog-evaluate! qunify) 27 | 28 | ; Exptected result of above 29 | (define expected 30 | (List (Concept "node1") (Concept "name1"))) 31 | -------------------------------------------------------------------------------- /tests/query/choice-constant.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; choice-constant.scm 3 | ; ChoiceLink with no variables!! 4 | ; 5 | (use-modules (opencog)) 6 | (use-modules (opencog exec)) 7 | 8 | ;;; Populate the atomspace with four small trees. 9 | (ListLink 10 | (ConceptNode "A") 11 | (ConceptNode "B") 12 | ) 13 | 14 | ;;; Two clauses; they both connected with a common variable. 15 | (define query 16 | (GetLink 17 | (TypedVariableLink (VariableNode "$x") (TypeNode "ConceptNode")) 18 | (ListLink 19 | (ChoiceLink 20 | (ConceptNode "A") 21 | (ConceptNode "C") 22 | ) 23 | (VariableNode "$x") 24 | ) 25 | ) 26 | ) 27 | -------------------------------------------------------------------------------- /tests/query/choice-double.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; choice-double.scm 3 | ; 4 | ; Unit testing for Choices in the pattern matcher. 5 | ; Much link choice-embed, except it ahs two choice links 6 | ; 7 | (use-modules (opencog)) 8 | (use-modules (opencog exec)) 9 | 10 | ;;; Populate the atomspace with four small trees. 11 | (Member (Concept "Tom") (Concept "ways and means")) 12 | (Member (Concept "Joe") (Concept "ways and means")) 13 | (Member (Concept "Hank") (Concept "ways and means")) 14 | (Member (Concept "Dick") (Concept "agriculture")) 15 | 16 | ;;; the list link serves no purpose other than to "embed" 17 | (List (Member (Concept "Tom") (Concept "Senator"))) 18 | (List (Member (Concept "Dick") (Concept "Senator"))) 19 | (List (Member (Concept "Joe") (Concept "Representative"))) 20 | 21 | ;; We should NOT find Hank! 22 | (List (Member (Concept "Hank") (Concept "CEO"))) 23 | 24 | ;;; Two clauses; they are both connected with a common variable. 25 | (define double 26 | (Bind 27 | (And 28 | (Choice 29 | (Member (Variable "$x") (Concept "ways and means")) 30 | (Member (Variable "$x") (Concept "agriculture"))) 31 | (List 32 | (Choice 33 | (Member (Variable "$x") (Concept "Senator")) 34 | (Member (Variable "$x") (Concept "Representative"))))) 35 | (Variable "$x"))) 36 | -------------------------------------------------------------------------------- /tests/query/choice-link.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Basic unit testing for ChoiceLinks in the pattern matcher. 3 | ; 4 | (use-modules (opencog)) 5 | (use-modules (opencog exec)) 6 | 7 | ;;; Populate the atomspace with four small trees. 8 | (MemberLink 9 | (ConceptNode "Tom") 10 | (ConceptNode "ways and means") 11 | ) 12 | 13 | (MemberLink 14 | (ConceptNode "Joe") 15 | (ConceptNode "ways and means") 16 | ) 17 | 18 | (MemberLink 19 | (ConceptNode "Hank") 20 | (ConceptNode "ways and means") 21 | ) 22 | 23 | (MemberLink 24 | (ConceptNode "Tom") 25 | (ConceptNode "Senator") 26 | ) 27 | 28 | (MemberLink 29 | (ConceptNode "Joe") 30 | (ConceptNode "Representative") 31 | ) 32 | 33 | ;; We should NOT find Hank among the solutions 34 | (MemberLink 35 | (ConceptNode "Hank") 36 | (ConceptNode "CEO") 37 | ) 38 | 39 | ;;; Two clauses; they both connected with a common variable. 40 | (define (basic) 41 | (BindLink 42 | (AndLink 43 | (MemberLink 44 | (VariableNode "$x") 45 | (ConceptNode "ways and means") 46 | ) 47 | (ChoiceLink 48 | (MemberLink 49 | (VariableNode "$x") 50 | (ConceptNode "Senator") 51 | ) 52 | (MemberLink 53 | (VariableNode "$x") 54 | (ConceptNode "Representative") 55 | ) 56 | ) 57 | ) 58 | (VariableNode "$x") 59 | ) 60 | ) 61 | -------------------------------------------------------------------------------- /tests/query/choice-present.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; choice-present.scm 3 | ; 4 | ; Validate PresentLinks appearing in ChoiceLinks 5 | ; Per issue #2644 6 | 7 | (use-modules (opencog) (opencog exec)) 8 | 9 | (State (List (Concept "alice") (Predicate "hungry")) (Concept "TRUE")) 10 | (State (Concept "alice") (Concept "at home")) 11 | 12 | (define who-is-hungry? 13 | (Get 14 | (VariableList 15 | (TypedVariable (Variable "x") (Type "ConceptNode")) 16 | (TypedVariable (Variable "y") (Type "ConceptNode"))) 17 | (Choice 18 | (Present 19 | (State (Variable "x") (Variable "y")) 20 | (State (List (Variable "x") (Predicate "hungry")) (Concept "TRUE")) 21 | )))) 22 | 23 | ; (cog-execute! who-is-hungry?) 24 | 25 | ; Above should result in this: 26 | (define expected (Set (List (Concept "alice") (Concept "at home")))) 27 | -------------------------------------------------------------------------------- /tests/query/choice-typed.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; ChoiceLink unit test. 3 | ; This test originally failed, because the initiate-search method 4 | ; failed to look at the two choices, which caused a fall-through 5 | ; to the variable-initiate-search, which failed because the variables 6 | ; were typed. (and was also wildly inefficient). 7 | 8 | (use-modules (opencog) (opencog exec)) 9 | 10 | (EvaluationLink 11 | (PredicateNode "OpenPsi:Decrease") 12 | (ListLink 13 | (Node "OpenPsi: Energy-rule-xej90") 14 | (ConceptNode "OpenPsi:Energy"))) 15 | 16 | (EvaluationLink 17 | (PredicateNode "OpenPsi:Increase") 18 | (ListLink 19 | (Node "OpenPsi: Energy-rule-pG1ez") 20 | (ConceptNode "OpenPsi:Energy"))) 21 | 22 | (define get-nodes1 23 | (GetLink 24 | (TypedVariableLink 25 | (VariableNode "x") 26 | (TypeNode "Node")) 27 | (ChoiceLink 28 | (EvaluationLink 29 | (PredicateNode "OpenPsi:Increase") 30 | (ListLink 31 | (VariableNode "x") 32 | (ConceptNode "OpenPsi:Energy"))) 33 | (EvaluationLink 34 | (PredicateNode "OpenPsi:Decrease") 35 | (ListLink 36 | (VariableNode "x") 37 | (ConceptNode "OpenPsi:Energy")))))) 38 | -------------------------------------------------------------------------------- /tests/query/choice-unary.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Testing of ChoiceLink, where the ChoiceLink has just a single 3 | ; member in it. Thus, if behaves just like a single-member PresentLink. 4 | ; 5 | (use-modules (opencog) (opencog exec)) 6 | 7 | (EvaluationLink (PredicateNode "door A") (ConceptNode "locked")) 8 | (EvaluationLink (PredicateNode "door A") (ConceptNode "closed")) 9 | 10 | (EvaluationLink (PredicateNode "door B") (ConceptNode "unlocked")) 11 | (EvaluationLink (PredicateNode "door B") (ConceptNode "closed")) 12 | 13 | (EvaluationLink (PredicateNode "door C") (ConceptNode "unlocked")) 14 | (EvaluationLink (PredicateNode "door C") (ConceptNode "open")) 15 | 16 | ; Should find only door A 17 | (define (get-a) (GetLink 18 | (AndLink 19 | (ChoiceLink 20 | (EvaluationLink (VariableNode "$door") (ConceptNode "locked"))) 21 | (ChoiceLink 22 | (EvaluationLink (VariableNode "$door") (ConceptNode "closed"))) 23 | ))) 24 | 25 | ; Should find doors B and C 26 | (define (get-bc) (GetLink 27 | (AndLink 28 | (ChoiceLink 29 | (EvaluationLink (VariableNode "$door") (ConceptNode "unlocked"))) 30 | (ChoiceLink 31 | (EvaluationLink (VariableNode "$door") (VariableNode "$ajar"))) 32 | ))) 33 | -------------------------------------------------------------------------------- /tests/query/constant-present.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; constant-present.scm 3 | ; 4 | ; Contains a constant clause insidde of a PresentLink. 5 | ; This occurs naturally in the URE ForwardChainerUTest 6 | ; 7 | 8 | (use-modules (opencog) (opencog exec)) 9 | 10 | (Inheritance (Concept "B") (Concept "foo")) 11 | 12 | (define query 13 | (Bind 14 | (TypedVariable (Variable "$C-7a4842c1") (Type "Concept")) 15 | (And 16 | (Present 17 | (Inheritance (Concept "A") (Concept "B")) 18 | (Inheritance (Concept "B") (Variable "$C-7a4842c1"))) 19 | (Not (Identical (Variable "$C-7a4842c1") (Concept "A")))) 20 | (Execution 21 | (Schema "scm: fc-deduction-formula") 22 | (List 23 | (Inheritance (Concept "A") (Variable "$C-7a4842c1")) 24 | (Inheritance (Concept "A") (Concept "B")) 25 | (Inheritance (Concept "B") (Variable "$C-7a4842c1")))))) 26 | 27 | ; (cog-execute! query) 28 | 29 | (define expected 30 | (Set 31 | (Execution 32 | (Schema "scm: fc-deduction-formula") 33 | (List 34 | (Inheritance (Concept "A") (Concept "foo")) 35 | (Inheritance (Concept "A") (Concept "B")) 36 | (Inheritance (Concept "B") (Concept "foo")))))) 37 | -------------------------------------------------------------------------------- /tests/query/deduct-trivial.scm: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; deduct-trivial.scm 3 | ;; 4 | ;; Trivial example of deduction. 5 | ;; 6 | ;; Part of the "Einstein puzzle" demo. 7 | ;; 8 | 9 | (define (stv mean conf) (cog-new-stv mean conf)) 10 | 11 | ;; The Englishman lives in the red house. 12 | (EvaluationLink (stv 1 1) 13 | (PredicateNode "Nationality") 14 | (ListLink 15 | (FeatureNode "person1") ; AvatarNode 16 | (ConceptNode "British") 17 | ) 18 | ) 19 | 20 | (EvaluationLink (stv 1 1) 21 | (PredicateNode "LivesIn") 22 | (ListLink 23 | (FeatureNode "person1") ; AvatarNode 24 | (ConceptNode "red_house") 25 | ) 26 | ) 27 | 28 | ;; The person who lives in the red house keeps fish. 29 | (EvaluationLink (stv 1 1) 30 | (PredicateNode "LivesIn") 31 | (ListLink 32 | (FeatureNode "person2") 33 | (ConceptNode "red_house") 34 | ) 35 | ) 36 | 37 | (EvaluationLink (stv 1 1) 38 | (PredicateNode "KeepsPet") 39 | (ListLink 40 | (FeatureNode "person2") 41 | (ConceptNode "fish") 42 | ) 43 | ) 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /tests/query/define-schema.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Demonstrate the used of DefinedSchemaNodes 3 | ; 4 | (define (get-timestamp) 5 | (NumberNode (current-time))) 6 | 7 | (DefineLink 8 | (DefinedSchemaNode "set timestamp") 9 | (PutLink 10 | (EvaluationLink (PredicateNode "event-timestamp") 11 | (ListLink (VariableNode "$ts"))) 12 | (ExecutionOutputLink 13 | (GroundedSchemaNode "scm: get-timestamp") 14 | (ListLink)))) 15 | 16 | ; (cog-execute! (DefinedSchemaNode "set timestamp")) 17 | -------------------------------------------------------------------------------- /tests/query/disco-dancers.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; disco-dancers.scm 3 | ; 4 | ; Test the addition of implict clauses for variables appearing in 5 | ; virtual clauses but not otherwise groundable. Per bug #2516 6 | ; 7 | 8 | (use-modules (opencog)) 9 | (use-modules (opencog exec)) 10 | 11 | (Concept "alice") 12 | (Concept "bob") 13 | 14 | (define variables (VariableList 15 | (TypedVariable 16 | (Variable "person1") 17 | (Type "ConceptNode")) 18 | (TypedVariable 19 | (Variable "person2") 20 | (Type "ConceptNode")))) 21 | 22 | (define target (Not (Identical 23 | (Variable "person1") 24 | (Variable "person2") ))) 25 | 26 | ; This should not throw... 27 | (define (get-dancers) (Get variables target)) 28 | 29 | ; This should work... 30 | ; (cog-execute! (get-dancers)) 31 | -------------------------------------------------------------------------------- /tests/query/disco-vars.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; disco-vars.scm 3 | ; 4 | ; Several patterns with implicit clauses. 5 | ; 6 | ; Prior to issue #2516, these were considered to be ill-formed 7 | ; search patterns, because they lacked explicit clauses that 8 | ; asserted the presence of a variable in the atompsace. However, 9 | ; it seems to be OK to assume implicit presence, when it is not 10 | ; declared explicity. So, in fact, everything below should be 11 | ; considered to be valid. 12 | 13 | (use-modules (opencog)) 14 | 15 | (define (B) 16 | (GetLink 17 | (VariableList (VariableNode "$A") (VariableNode "$B")) 18 | (AndLink 19 | (EqualLink (VariableNode "$A") (VariableNode "$B"))))) 20 | 21 | (define (Ba) 22 | (GetLink 23 | (VariableList (VariableNode "$A") (VariableNode "$B")) 24 | (AndLink 25 | (PresentLink (VariableNode "$A")) 26 | (EqualLink (VariableNode "$A") (VariableNode "$B"))))) 27 | 28 | (define (Bu) 29 | (GetLink 30 | (VariableList (VariableNode "$A") (VariableNode "$B") (VariableNode "$C")) 31 | (AndLink 32 | (InheritanceLink (VariableNode "$A") (VariableNode "$B")) 33 | (EqualLink (VariableNode "$A") (VariableNode "$C"))))) 34 | -------------------------------------------------------------------------------- /tests/query/dont-exec-simple.scm: -------------------------------------------------------------------------------- 1 | 2 | (use-modules (opencog) (opencog exec)) 3 | 4 | (define bad-and (AndLink (Concept "a") (Concept "b"))) 5 | 6 | ; Evaluating the below should just unwrap the DontExec 7 | (define dont-and (DontExec bad-and)) 8 | 9 | ; Evaluating the below should just return the bad-and 10 | (define put-and 11 | (Put (DontExec (AndLink (Variable "$x")(Variable "$y"))) 12 | (ListLink (Concept "a") (Concept "b")))) 13 | 14 | ; A multi-argument put whose EvaluationLink should not evaluate 15 | (define put-eval 16 | (Put (DontExec (EvaluationLink 17 | (PredicateNode "foo") 18 | (Variable "$x") 19 | (Variable "$y") 20 | (Variable "$z"))) 21 | (SetLink 22 | (ListLink (Concept "a") (Concept "b") (Concept "c")) 23 | (ListLink (Concept "d") (Concept "e") (Concept "f")) 24 | (ListLink (Concept "g") (Concept "h") (Concept "i")) 25 | (ListLink (Concept "j") (Concept "k") (Concept "l"))))) 26 | 27 | ; The result we expect from the above 28 | (define eval-expected (SetLink 29 | (Evaluation (Predicate "foo") (Concept "a") (Concept "b") (Concept "c")) 30 | (Evaluation (Predicate "foo") (Concept "d") (Concept "e") (Concept "f")) 31 | (Evaluation (Predicate "foo") (Concept "g") (Concept "h") (Concept "i")) 32 | (Evaluation (Predicate "foo") (Concept "j") (Concept "k") (Concept "l")))) 33 | -------------------------------------------------------------------------------- /tests/query/dont-exec.scm: -------------------------------------------------------------------------------- 1 | (define simple-bl 2 | (BindLink 3 | (AndLink) 4 | (Concept "Hello World"))) 5 | 6 | (EvaluationLink (stv 1 1) 7 | (PredicateNode "URE:BC:and-BIT") 8 | simple-bl) 9 | 10 | (define bl 11 | (BindLink 12 | (TypedVariableLink 13 | (VariableNode "$A") 14 | (TypeNode "BindLink") 15 | ) 16 | (EvaluationLink 17 | (PredicateNode "URE:BC:and-BIT") 18 | (VariableNode "$A") 19 | ) 20 | (DontExecLink 21 | (VariableNode "$A") 22 | ) 23 | ) 24 | ) 25 | -------------------------------------------------------------------------------- /tests/query/eval-default-tv.scm: -------------------------------------------------------------------------------- 1 | ;see comment section in EvalLinkDefaultTVUTest.cxxtest 2 | ;see the discurssion at https://github.com/opencog/atomspace/issues/1868 3 | 4 | (define (check-color object color) 5 | (if (string=? (cog-name object) "RedItem") 6 | (stv 0.55 0.55) 7 | (stv 0.45 0.45)) 8 | ) 9 | 10 | (define red-thing (ConceptNode "RedItem")) 11 | (define tr-thing (ConceptNode "TransparentItem")) 12 | 13 | (Inheritance (stv 1.0 0.999) red-thing (ConceptNode "colored")) 14 | (Inheritance (stv 1.0 0.999) tr-thing (ConceptNode "colored")) 15 | (Inheritance (stv 1.0 0.999) (ConceptNode "Red") (ConceptNode "Color")) 16 | 17 | (define has-color 18 | (EvaluationLink 19 | (GroundedPredicateNode "scm:check-color") 20 | (ListLink (VariableNode "$X") 21 | (VariableNode "$C")) 22 | ) 23 | ) 24 | 25 | 26 | (define query 27 | (BindLink 28 | (AndLink 29 | (InheritanceLink (VariableNode "$X") (ConceptNode "colored")) 30 | (InheritanceLink (VariableNode "$C") (ConceptNode "Color")) 31 | has-color 32 | ) 33 | has-color) 34 | ) 35 | -------------------------------------------------------------------------------- /tests/query/eval-lambda.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Verify that LambdaLink is handed properly, per discussion 3 | ; on mailing list. 4 | 5 | (use-modules (opencog) (opencog exec)) 6 | 7 | (State (Concept "stop light") (Concept "red light")) 8 | 9 | (define is-red-light 10 | (Evaluation 11 | (Lambda 12 | (VariableList (Variable "a") (Variable "b")) 13 | (Equal 14 | (Set (Variable "a")) 15 | (Get (Variable "x") (State (Variable "b") (Variable "x"))))) 16 | (List (Concept "red light") (Concept "stop light")))) 17 | 18 | (define meet-is-red-light 19 | (Evaluation 20 | (Lambda 21 | (VariableList (Variable "a") (Variable "b")) 22 | (Equal 23 | (Variable "a") 24 | (Meet (Variable "x") (State (Variable "b") (Variable "x"))))) 25 | (List (Concept "red light") (Concept "stop light")))) 26 | -------------------------------------------------------------------------------- /tests/query/exec-factorial.scm: -------------------------------------------------------------------------------- 1 | 2 | (use-modules (opencog) (opencog exec)) 3 | 4 | ; Compute the factorial of a NumberNode, using the classic 5 | ; recursive algorithm. 6 | ; 7 | (Define 8 | (DefinedSchema "factorial") 9 | (Lambda 10 | (TypedVariable (Variable "$n") (Type "NumberNode")) 11 | (Cond 12 | (GreaterThan (Variable "$n") (Number 0)) 13 | (Times 14 | (Variable "$n") 15 | (ExecutionOutput 16 | (DefinedSchema "factorial") 17 | (Minus (Variable "$n") (Number 1)))) 18 | (Number 1))) 19 | ) 20 | 21 | ; (cog-execute! (ExecutionOutput (DefinedSchema "factorial") (Number 5))) 22 | -------------------------------------------------------------------------------- /tests/query/exec-gsn.scm: -------------------------------------------------------------------------------- 1 | ;; Used by ExecutionOutputUTest::test_value 2 | 3 | (use-modules (opencog) (opencog exec)) 4 | 5 | ;; Grounds 6 | 7 | (Implication 8 | (Schema "sc-1") 9 | (Concept "a")) 10 | 11 | (Implication 12 | (Schema "sc-2") 13 | (Concept "b")) 14 | 15 | (Implication 16 | (Schema "sc-3") 17 | (Concept "c")) 18 | 19 | ;; Query 20 | 21 | (define (ret-handle A B) (Unordered A B)) 22 | (define (ret-link-value A B) (LinkValue A B)) 23 | (define (ret-truth-value A B) (SimpleTruthValue 0.6 0.3)) 24 | (define (ret-string-value A B) (StringValue (cog-name A) (cog-name B))) 25 | 26 | (define (make-exec-query fun) 27 | (Query 28 | (VariableList 29 | (TypedVariable (Variable "$schema") (Type 'SchemaNode)) 30 | (TypedVariable (Variable "$arg") (Type 'ConceptNode))) 31 | (Implication (Variable "$schema") (Variable "$arg")) 32 | (ExecutionOutput 33 | (GroundedSchema fun) 34 | (List (Variable "$schema") (Variable "$arg"))) 35 | )) 36 | 37 | (define exec-query-handle (make-exec-query "scm: ret-handle")) 38 | (define exec-query-link-value (make-exec-query "scm: ret-link-value")) 39 | (define exec-query-truth-value (make-exec-query "scm: ret-truth-value")) 40 | (define exec-query-string-value (make-exec-query "scm: ret-string-value")) 41 | -------------------------------------------------------------------------------- /tests/query/exec-implication-scope.scm: -------------------------------------------------------------------------------- 1 | (define (dummy x) x) 2 | 3 | (Evaluation 4 | (Predicate "P") 5 | (Concept "A")) 6 | 7 | (define bl 8 | (Bind 9 | (Present 10 | (Evaluation 11 | (Predicate "P") 12 | (Variable "$X"))) 13 | (ExecutionOutput 14 | (GroundedSchema "scm: dummy") 15 | (ImplicationScope 16 | (Evaluation 17 | (Predicate "P") 18 | (Variable "$X")) 19 | (Evaluation 20 | (Predicate "Q") 21 | (Variable "$X")))))) 22 | -------------------------------------------------------------------------------- /tests/query/exec-lambda.scm: -------------------------------------------------------------------------------- 1 | (define (dummy x) x) 2 | 3 | (define bl 4 | (BindLink 5 | (VariableList 6 | (TypedVariableLink 7 | (VariableNode "$V") 8 | (TypeNode "VariableNode") 9 | ) 10 | (TypedVariableLink 11 | (VariableNode "$B") 12 | (TypeNode "EvaluationLink") 13 | ) 14 | ) 15 | (AndLink 16 | (VariableNode "$V") 17 | (VariableNode "$B") 18 | ) 19 | (ExecutionOutputLink 20 | (GroundedSchemaNode "scm: dummy") 21 | (ListLink 22 | (QuoteLink 23 | (LambdaLink 24 | (UnquoteLink 25 | (VariableNode "$V") 26 | ) 27 | (UnquoteLink 28 | (VariableNode "$B") 29 | ) 30 | ) 31 | ) 32 | ) 33 | ) 34 | ) 35 | ) 36 | 37 | (Evaluation (Predicate "P") (Concept "A")) 38 | -------------------------------------------------------------------------------- /tests/query/exec.scm: -------------------------------------------------------------------------------- 1 | ;; Used by ExecutionOutputUTest::test_query_exec 2 | 3 | (use-modules (opencog) (opencog exec)) 4 | 5 | ;; Grounds 6 | 7 | (ExecutionOutput 8 | (Schema "sc-1") 9 | (Concept "a")) 10 | 11 | (ExecutionOutput 12 | (Schema "sc-2") 13 | (Concept "b")) 14 | 15 | (ExecutionOutput 16 | (Schema "sc-3") 17 | (Concept "c")) 18 | 19 | ;; Query 20 | 21 | (define exec-query 22 | (Get (ExecutionOutput (Variable "$schema") (Variable "$arg")))) 23 | 24 | (define quote-exec-query 25 | (Get 26 | (Quote 27 | (ExecutionOutput 28 | (Unquote (Variable "$schema")) 29 | (Unquote (Variable "$arg")))))) 30 | -------------------------------------------------------------------------------- /tests/query/executable-pattern.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Data and tests for Executable Pattern 3 | ; 4 | 5 | (use-modules (opencog) (opencog exec)) 6 | 7 | (PlusLink (NumberNode 3) (NumberNode 5)) 8 | 9 | (define plus-pattern 10 | (GetLink 11 | (VariableList 12 | (TypedVariableLink (VariableNode "$A") (TypeNode "NumberNode")) 13 | (TypedVariableLink (VariableNode "$B") (TypeNode "NumberNode"))) 14 | (Present (PlusLink (VariableNode "$A") (VariableNode "$B"))))) 15 | 16 | ; (cog-execute! plus-pattern) 17 | -------------------------------------------------------------------------------- /tests/query/get-link-eval.scm: -------------------------------------------------------------------------------- 1 | ; https://github.com/opencog/atomspace/issues/211 2 | 3 | (use-modules ((opencog exec))) 4 | 5 | (EvaluationLink 6 | (ConceptNode "arkle") 7 | (ConceptNode "barkle") 8 | (ConceptNode "curry")) 9 | 10 | (EvaluationLink 11 | (ConceptNode "glib") 12 | (ConceptNode "blab")) 13 | 14 | (define get 15 | (GetLink 16 | (VariableList (VariableNode "$a") (VariableNode "$b") 17 | (TypedVariableLink (VariableNode "$lnk") 18 | (TypeNode "EvaluationLink"))) 19 | (AndLink 20 | (VariableNode "$lnk") 21 | (EvaluationLink 22 | (VariableNode "$a") 23 | (VariableNode "$b")) 24 | (EqualLink 25 | (VariableNode "$lnk") 26 | (EvaluationLink 27 | (VariableNode "$a") 28 | (VariableNode "$b")))))) 29 | -------------------------------------------------------------------------------- /tests/query/get-link-glob.scm: -------------------------------------------------------------------------------- 1 | ; https://github.com/opencog/atomspace/issues/2400 2 | 3 | (use-modules ((opencog exec))) 4 | 5 | (ListLink 6 | (ConceptNode "glib") 7 | (PredicateNode "blab")) 8 | 9 | (define basic-get 10 | (GetLink 11 | (ListLink 12 | (GlobNode "$x")))) 13 | 14 | (define typed-get 15 | (GetLink 16 | (TypedVariableLink 17 | (GlobNode "$x") 18 | (TypeNode "ConceptNode")) 19 | (ListLink 20 | (GlobNode "$x")))) 21 | 22 | (define type-choice-get 23 | (GetLink 24 | (TypedVariableLink 25 | (GlobNode "$x") 26 | (TypeChoice 27 | (TypeNode "ConceptNode") 28 | (TypeNode "PredicateNode"))) 29 | (ListLink 30 | (GlobNode "$x")))) 31 | -------------------------------------------------------------------------------- /tests/query/glob-number.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; glob-number.scm 3 | ; 4 | ; Test arithmetic links with globs 5 | ; 6 | (use-modules (opencog) (opencog exec)) 7 | 8 | ; From issue #2528 9 | (PlusLink (Number "1") (Number "2") (Number "3") (Number "4")) 10 | 11 | (define glob-for-plus 12 | (BindLink 13 | (PlusLink 14 | (Number "1") (Glob "$star") (Number "4")) 15 | (PlusLink 16 | (Number "1") (Glob "$star") (Number "4") (Number "5")))) 17 | 18 | ; (cog-execute! glob-for-plus) should return (SetLink (Number "15")) 19 | 20 | ; From issue #2564 21 | (PlusLink (Number 3) (Number 10)) 22 | 23 | (define glob-for-ten 24 | (BindLink 25 | (Plus (Glob "$op") (Number 10)) 26 | (Times (Plus (Glob "$op") (Number 10)) (Number 30)))) 27 | 28 | ; (cog-execute! glob-for-ten) should return (SetLink (Number "390")) 29 | -------------------------------------------------------------------------------- /tests/query/glob-pivot.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; glob-pivot.scm 3 | ; 4 | ; Unit test for bug #2167 5 | ; 6 | (use-modules (opencog) (opencog exec)) 7 | 8 | (EvaluationLink 9 | (PredicateNode "pred-1") 10 | (ListLink 11 | (ConceptNode "blah") 12 | ) 13 | ) 14 | (EvaluationLink 15 | (PredicateNode "pred-2") 16 | (ListLink 17 | (ConceptNode "blah") 18 | ) 19 | ) 20 | 21 | (define glob-pivot 22 | (GetLink 23 | (TypedVariableLink 24 | (GlobNode "$G") 25 | (TypeIntersectionLink 26 | (TypeNode "ConceptNode") 27 | (IntervalLink 28 | (NumberNode 1) 29 | (NumberNode -1) 30 | ) 31 | ) 32 | ) 33 | (AndLink 34 | (EvaluationLink 35 | (PredicateNode "pred-1") 36 | (ListLink 37 | (GlobNode "$G") 38 | ) 39 | ) 40 | (EvaluationLink 41 | (PredicateNode "pred-2") 42 | (ListLink 43 | (GlobNode "$G") 44 | ) 45 | ) 46 | ) 47 | ) 48 | ) 49 | -------------------------------------------------------------------------------- /tests/query/ill-put.scm: -------------------------------------------------------------------------------- 1 | (use-modules (opencog logger)) 2 | 3 | ;; Well formed PutLink 4 | (define put-1 5 | (PutLink 6 | (LambdaLink 7 | (VariableNode "$X") 8 | (VariableNode "$X")) 9 | (ConceptNode "A")) 10 | ) 11 | 12 | ;; Ill formed PutLinks (only detectable at run-time) 13 | (define put-2 14 | (PutLink 15 | put-1 16 | (Concept "B")) 17 | ) 18 | (define put-3 19 | (PutLink 20 | put-2 21 | (Concept "C")) 22 | ) 23 | 24 | (define get-put 25 | (Get 26 | (TypedVariable 27 | (Variable "$P") 28 | (Type "PutLink")) 29 | (And 30 | (Variable "$P") 31 | (Evaluation 32 | (GroundedPredicate "scm: well-formed?") 33 | (Variable "$P")))) 34 | ) 35 | 36 | (define (well-formed? P) 37 | (cog-logger-debug "well-formed? P = ~a" P) 38 | (stv 1 1)) 39 | -------------------------------------------------------------------------------- /tests/query/is_closed.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; is_closed.scm for IsClosedUTest.cxxtest 3 | ; 4 | 5 | ;; Closed atom 6 | (Inheritance 7 | (Concept "A") 8 | (Concept "B")) 9 | 10 | ;; Open atom 11 | (Inheritance 12 | (Concept "A") 13 | (Variable "$freevar")) 14 | 15 | ;; Query all inheritance links 16 | (define query 17 | (Get 18 | (TypedVariable 19 | (Variable "$I") 20 | (Type 'Inheritance)) 21 | (Present (Variable "$I")))) 22 | 23 | ;; Query only inheritance links 24 | (define closed-query 25 | (Get 26 | (TypedVariable 27 | (Variable "$I") 28 | (Type 'Inheritance)) 29 | (And 30 | (Present (Variable "$I")) 31 | (IsClosed (Variable "$I"))))) 32 | -------------------------------------------------------------------------------- /tests/query/is_false.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; is_false.scm for IsFalseUTest.cxxtest 3 | ; 4 | 5 | ;; False atom 6 | (Concept "A" (stv 0 1)) 7 | 8 | ;; Non-false atom 9 | (Concept "B") 10 | 11 | ;; Query all concepts 12 | (define query 13 | (Get 14 | (TypedVariable 15 | (Variable "$C") 16 | (Type 'Concept)) 17 | (Present (Variable "$C")))) 18 | 19 | ;; Query only false concepts 20 | (define false-query 21 | (Get 22 | (TypedVariable 23 | (Variable "$C") 24 | (Type 'Concept)) 25 | (And 26 | (Present (Variable "$C")) 27 | (IsFalse (Variable "$C"))))) 28 | -------------------------------------------------------------------------------- /tests/query/is_true.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; is_true.scm for IsTrueUTest.cxxtest 3 | ; 4 | 5 | ;; True atom 6 | (Concept "A" (stv 1 1)) 7 | 8 | ;; Non-true atom 9 | (Concept "B") 10 | 11 | ;; Query all concepts 12 | (define query 13 | (Get 14 | (TypedVariable 15 | (Variable "$C") 16 | (Type 'Concept)) 17 | (Present (Variable "$C")))) 18 | 19 | ;; Query only true concepts 20 | (define true-query 21 | (Get 22 | (TypedVariable 23 | (Variable "$C") 24 | (Type 'Concept)) 25 | (And 26 | (Present (Variable "$C")) 27 | (IsTrue (Variable "$C"))))) 28 | -------------------------------------------------------------------------------- /tests/query/nested-and.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; nested-and.scm 3 | ; Test recursively-nested AndLinks 4 | ; 5 | (use-modules (opencog) (opencog exec)) 6 | 7 | (Evaluation (Predicate "has-a") 8 | (List (Concept "car") (Concept "battery"))) 9 | 10 | (Evaluation (Predicate "state") 11 | (List (Concept "battery") (Concept "dead"))) 12 | 13 | (define did-call #f) 14 | 15 | (define (foo x) 16 | (format #t "foo: ~A\n" x) 17 | (set! did-call #t) 18 | (stv 1 1)) 19 | 20 | (define nestand 21 | (Get 22 | (TypedVariable (Variable "$component") (Type 'Concept)) 23 | (And 24 | (And 25 | (Present 26 | (Evaluation (Predicate "has-a") 27 | (List (Concept "car") (Variable "$component")))) 28 | (Evaluation (GroundedPredicate "scm: foo") 29 | (List (Variable "$component")))) 30 | (And 31 | (Present 32 | (Evaluation (Predicate "state") 33 | (List (Variable "$component") (Concept "dead")))))))) 34 | 35 | ; (cog-execute! nestand) 36 | -------------------------------------------------------------------------------- /tests/query/present.scm: -------------------------------------------------------------------------------- 1 | 2 | (use-modules (opencog) (opencog exec)) 3 | 4 | (define get5 (GetLink 5 | (VariableList 6 | (TypedVariable (Variable "$num1") (Type 'NumberNode)) 7 | (TypedVariable (Variable "$num2") (Type 'NumberNode))) 8 | (And 9 | (Present (Variable "$num1")) 10 | (Present (Variable "$num2")) 11 | (Present (GreaterThan (Variable "$num1") (Variable "$num2")))))) 12 | 13 | ; Expected result from running the above 14 | (define ans5 (SetLink 15 | (ListLink 16 | (NumberNode 3) 17 | (NumberNode 2)))) 18 | 19 | ; Pattern to match 20 | (GreaterThanLink (Number 3) (Number 2)) 21 | 22 | ; Confounding AtomSpace content 23 | (Number 0) (Number 1) (Number 2) (Number 3) (Number 4) (Number 5) 24 | 25 | ; (cog-execute! g5) 26 | 27 | *unspecified* 28 | -------------------------------------------------------------------------------- /tests/query/query-exclusive.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; query-exclusive.scm -- ExclusiveLink usage example. 3 | ; 4 | (use-modules (opencog) (opencog exec)) 5 | 6 | (State (Concept "stop light") (Concept "red light")) 7 | 8 | ; Return empty set, if the light is red. 9 | ; In other words, (Exclusive (Concept "red light") (Variable "x")) 10 | ; is the same as (Not (Equal (Concept "red light") (Variable "x"))) 11 | (define exclude-red 12 | (Meet 13 | (Variable "x") 14 | (And 15 | (State (Concept "stop light") (Variable "x")) 16 | (Exclusive (Concept "red light") (Variable "x"))))) 17 | 18 | (define not-red 19 | (Meet 20 | (Variable "x") 21 | (And 22 | (State (Concept "stop light") (Variable "x")) 23 | (Not (Equal (Concept "red light") (Variable "x")))))) 24 | -------------------------------------------------------------------------------- /tests/query/query-meet.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; query-meet.scm -- MeetLink usage example. 3 | ; 4 | ; The MeetLink and the GetLink are both very similar ... 5 | 6 | (use-modules (opencog) (opencog exec)) 7 | 8 | ; ------------- 9 | ; Create three bits of "knowledge". 10 | (Evaluation 11 | (Predicate "foobar") (List (Concept "funny") (Concept "thing"))) 12 | (Evaluation 13 | (Predicate "foobar") (List (Concept "funny") (Concept "story"))) 14 | (Evaluation 15 | (Predicate "foobar") (List (Concept "funny") (Concept "joke"))) 16 | 17 | ; ------------- 18 | ; Define a simple query. It looks for the funny stuff. 19 | (define meet 20 | (Meet 21 | (TypedVariable (Variable "$x") (Type 'ConceptNode)) 22 | (Evaluation 23 | (Predicate "foobar") 24 | (List (Concept "funny") (Variable "$x"))) 25 | )) 26 | -------------------------------------------------------------------------------- /tests/query/query.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; query.scm -- QueryLink usage example. 3 | ; 4 | ; The QueryLink and the BindLink are both very similar ... 5 | 6 | (use-modules (opencog) (opencog exec)) 7 | 8 | ; ------------- 9 | ; Create three bits of "knowledge". 10 | (Evaluation 11 | (Predicate "foobar") (List (Concept "funny") (Concept "thing"))) 12 | (Evaluation 13 | (Predicate "foobar") (List (Concept "funny") (Concept "story"))) 14 | (Evaluation 15 | (Predicate "foobar") (List (Concept "funny") (Concept "joke"))) 16 | 17 | ; ------------- 18 | ; Define a simple query. It looks for the funny stuff, and attaches 19 | ; the result to an AnchorNode 20 | (define query 21 | (Query 22 | (TypedVariable (Variable "$x") (Type 'ConceptNode)) 23 | (Evaluation 24 | (Predicate "foobar") 25 | (List (Concept "funny") (Variable "$x"))) 26 | (ListLink 27 | (Anchor "*-query results-*") 28 | (Implication (Variable "$x") (Concept "laughable"))) 29 | )) 30 | -------------------------------------------------------------------------------- /tests/query/quote-crash.scm: -------------------------------------------------------------------------------- 1 | 2 | (use-modules (opencog)) 3 | (use-modules (opencog exec)) 4 | 5 | ; This is an infinite loop, except that the QuoteLink is supposed 6 | ; to stop the recursion. 7 | (define crasher 8 | (BindLink 9 | (VariableNode "$x") 10 | (ListLink 11 | (ConceptNode "And the answer is ...") 12 | (QuoteLink (VariableNode "$x"))))) 13 | 14 | ;; This is an infinite loop, because there are no type restrictions on 15 | ;; the variable, and the instantiator can get confused. 16 | (define infloop 17 | (BindLink 18 | (VariableNode "$x") 19 | (ListLink 20 | (ConceptNode "And the answer is ...") 21 | (VariableNode "$x")))) 22 | -------------------------------------------------------------------------------- /tests/query/quote-exec-getlink.scm: -------------------------------------------------------------------------------- 1 | (use-modules (opencog) (opencog exec)) 2 | 3 | (define (foo arg) 4 | (stv 1 1) 5 | ) 6 | 7 | (define z-eval 8 | (EvaluationLink 9 | (GroundedPredicateNode "scm: foo") 10 | (ListLink (Node "argument")))) 11 | 12 | (define z-def 13 | (DefineLink 14 | (DefinedPredicateNode "test") 15 | z-eval 16 | ) 17 | ) 18 | 19 | (define z-get 20 | (GetLink 21 | (TypedVariableLink 22 | (VariableNode "$effect") 23 | (TypeNode "ConceptNode") 24 | ) 25 | (EvaluationLink 26 | (PredicateNode "some property of dpn") 27 | (ListLink 28 | (QuoteLink (DefinedPredicateNode "test")) 29 | (VariableNode "$effect") 30 | ) 31 | ) 32 | ) 33 | ) 34 | 35 | (EvaluationLink 36 | (PredicateNode "some property of dpn") 37 | (ListLink 38 | (DefinedPredicateNode "test") 39 | (ConceptNode "result") 40 | ) 41 | ) 42 | -------------------------------------------------------------------------------- /tests/query/quote-glob.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; quote-glob.scm 3 | ; Unit test for issue #2583 4 | ; 5 | (use-modules (opencog) (opencog exec)) 6 | 7 | (PlusLink (Number 1) (Number 2) (Number 10)) 8 | 9 | (define quote-glob 10 | (Query 11 | (TypedVariable (Glob "$op") (Type 'NumberNode)) 12 | (Plus (Glob "$op") (Number 10)) 13 | (Quote (Plus (Unquote (Glob "$op")) (Number 10))))) 14 | 15 | ; Obviously expect this... 16 | (define expect 17 | (PlusLink (Number 1) (Number 2) (Number 10))) 18 | 19 | ; (cog-execute! quote-glob) 20 | -------------------------------------------------------------------------------- /tests/query/quote-gpn.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; quote-gpn.scm 3 | ; 4 | ; Test QuoteLink -- check for appropriate search scoping. 5 | ; 6 | 7 | ; some data 8 | (EvaluationLink 9 | (GroundedPredicateNode "scm:do_stuff") 10 | (ListLink 11 | (ConceptNode "thing-a") 12 | (ConceptNode "thing-b") 13 | ) 14 | ) 15 | 16 | ; The pattern below can confuse the search start, becuase 17 | ; the first constant link in the clause is the quote ... 18 | ; and that's won't provide the desired start ... 19 | (define bindy 20 | (BindLink 21 | (VariableNode "$stuff") 22 | (EvaluationLink 23 | (QuoteLink (GroundedPredicateNode "scm:do_stuff")) 24 | (VariableNode "$stuff") 25 | ) 26 | (VariableNode "$stuff") 27 | ) 28 | ) 29 | 30 | ; data to check Times matching 31 | (TimesLink 32 | (NumberNode 3) 33 | (NumberNode 5) 34 | ) 35 | 36 | ; Pattern uses QuoteLink to match TimesLink without 37 | ; making actual calculations 38 | (define get-times-link 39 | (GetLink 40 | (VariableList 41 | (VariableNode "$a") 42 | (VariableNode "$b") 43 | ) 44 | (QuoteLink 45 | (TimesLink 46 | (UnquoteLink (VariableNode "$a")) 47 | (UnquoteLink (VariableNode "$b")) 48 | ) 49 | ) 50 | ) 51 | ) 52 | -------------------------------------------------------------------------------- /tests/query/quote-impossible.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; quote-impossible.scm 3 | ; 4 | ; Currently triggers bug #1531 "Impossible situation" 5 | ; The problem is that the search tries to start within 6 | ; the QuoteLink, but do_term_up does not like that. 7 | ; 8 | (define imp 9 | (SatisfactionLink 10 | (TypedVariable 11 | (VariableNode "$A") 12 | (TypeNode "PredicateNode")) 13 | (AndLink 14 | (VariableNode "$A") 15 | (ImplicationScopeLink 16 | (VariableNode "$A") 17 | (QuoteLink 18 | (InheritanceLink 19 | (VariableNode "$x") 20 | (ConceptNode "criminal"))))))) 21 | 22 | (define (sat-imp) (cog-evaluate! imp)) 23 | -------------------------------------------------------------------------------- /tests/query/quote-scope.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; quote-scope.scm 3 | ; 4 | ; This shows up in the URE, as a meta-pattern searching for patterns. 5 | ; 6 | (use-modules (opencog) (opencog exec)) 7 | 8 | (ImplicationScope 9 | (TypedVariable (Variable "X") (Type 'Concept)) 10 | (Member (Variable "X") (Concept "foo")) 11 | (Member (Concept "bar") (Variable "X"))) 12 | 13 | (define quote-scope 14 | (Meet 15 | (VariableList 16 | (Variable "$P") 17 | (Variable "$Q") 18 | (TypedVariable 19 | (Variable "$TyVs") 20 | (TypeChoice (Type "TypedVariable") (Type "VariableList")))) 21 | (Present 22 | (Quote 23 | (ImplicationScope 24 | (Unquote (Variable "$TyVs")) 25 | (Unquote (Variable "$P")) 26 | (Unquote (Variable "$Q"))))))) 27 | 28 | ; (cog-execute! quote-scope) 29 | 30 | (define expect 31 | (List 32 | (Member (Variable "X") (Concept "foo")) 33 | (Member (Concept "bar") (Variable "X")) 34 | (TypedVariable (Variable "X") (Type 'Concept)))) 35 | -------------------------------------------------------------------------------- /tests/query/quote-self.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; quote-self.scm 3 | ; Unit test for issue #2583 4 | ; 5 | (use-modules (opencog) (opencog exec)) 6 | 7 | ; The Glob is undeclared .. and untyped... thus its free to 8 | ; match anything, including the implicand. 9 | ; 10 | (define self-ground 11 | (Query 12 | (Plus (Glob "$op") (Number 10)) 13 | (Quote (Plus (Unquote (Glob "$op")) (Number 10))))) 14 | 15 | ; The expected result .. this is not entirely obvious because 16 | ; it is hard to read, cause it's self-referential. First, the 17 | ; glob is grounded by unquote-glob. Then the quote-unquote is 18 | ; removed, and the unquote-glob is inserted. Thus we expect 19 | ; the below. 20 | (define expect 21 | (Plus (Unquote (Glob "$op")) (Number 10))) 22 | 23 | ; (cog-execute! self-ground) 24 | -------------------------------------------------------------------------------- /tests/query/quote-throw.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; quote-throw.scm 3 | ; 4 | ; Test invalid use of quote. 5 | ; 6 | 7 | (EvaluationLink 8 | (PredicateNode "all-var") 9 | (ListLink 10 | (VariableNode "$var-a") 11 | (VariableNode "$var-b") 12 | ) 13 | ) 14 | 15 | (define bindy 16 | (BindLink 17 | (VariableNode "$var-a") 18 | (EvaluationLink 19 | (VariableNode "$var-a") 20 | ; quote cannot have two things under it; this should cause 21 | ; an exception to be thrown from the pattern matcher. 22 | (QuoteLink 23 | (VariableNode "$var-a") 24 | (VariableNode "$var-b") 25 | ) 26 | ) 27 | (VariableNode "$var-a") 28 | ) 29 | ) 30 | -------------------------------------------------------------------------------- /tests/query/seq-trivial.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Some trivial sequences. 3 | 4 | (use-modules (opencog) (opencog exec)) 5 | 6 | (define get-something (Bind (True) (Concept "it's true"))) 7 | (define get-nothing (Bind (False) (Concept "it's false"))) 8 | (define get-not-true (Bind (Not (True)) (Concept "it's not true"))) 9 | (define get-not-false (Bind (Not (False)) (Concept "it's not false"))) 10 | -------------------------------------------------------------------------------- /tests/query/test-types.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | using namespace opencog; 5 | 6 | Type ANTI_LINK; 7 | Type AT_TIME_LINK; 8 | Type DEFINED_LINGUISTIC_CONCEPT_NODE; 9 | Type DEFINED_LINGUISTIC_RELATIONSHIP_NODE; 10 | Type DOCUMENT_NODE; 11 | Type FEATURE_LINK; 12 | Type FEATURE_NODE; 13 | Type HEBBIAN_LINK; 14 | Type LEMMA_LINK; 15 | Type LEMMA_NODE; 16 | Type LG_CONNECTOR_NODE; 17 | Type PARSE_LINK; 18 | Type PARSE_NODE; 19 | Type PART_OF_SPEECH_LINK; 20 | Type PART_OF_SPEECH_NODE; 21 | Type PREPOSITIONAL_RELATIONSHIP_NODE; 22 | Type REFERENCE_LINK; 23 | Type SEME_NODE; 24 | Type SENTENCE_NODE; 25 | Type TIME_NODE; 26 | Type WORD_INSTANCE_LINK; 27 | Type WORD_INSTANCE_NODE; 28 | Type WORD_NODE; 29 | Type WORD_SENSE_NODE; 30 | -------------------------------------------------------------------------------- /tests/scm/pm.scm: -------------------------------------------------------------------------------- 1 | ;; File to reproduce a bug when operating on multiple atomspaces 2 | ;; created from scheme. 3 | 4 | (use-modules (opencog)) 5 | (use-modules (opencog exec)) 6 | (use-modules (opencog logger)) 7 | 8 | ;; Create a new atomspace to not by-pass the problem (due to 9 | ;; WORK_AROUND_GUILE_20_GC_BUG in SchemeSmobAS.cc) 10 | (define post-init-as (cog-new-atomspace)) 11 | 12 | ;; AtomSpace use to produce the bug. It crashes as soon as it gets 13 | ;; prematurely deleted 14 | (define bug-as (cog-new-atomspace)) 15 | (cog-set-atomspace! bug-as) ;; <--- bug 16 | 17 | (define (my-precondition X) 18 | (stv 1 1)) 19 | 20 | (define query 21 | (Bind 22 | (TypedVariable (Variable "$X") (TypeNode "ConceptNode")) 23 | (AndLink 24 | (Evaluation ;; <--- bug 25 | (GroundedPredicate "scm: my-precondition") 26 | (Variable "$X") 27 | ) 28 | (Present (Variable "$X")) 29 | (Concept "I") 30 | ) 31 | (Concept "O") 32 | ) 33 | ) 34 | 35 | ;; Run and-bit-prior rule base over bug-as 36 | (define (run-bug i) 37 | (cog-logger-debug "run-bug ~a" i) 38 | (cog-execute! query) 39 | (gc)) ;; <--- precipitate the bug 40 | 41 | (for-each run-bug (iota 100)) 42 | -------------------------------------------------------------------------------- /tests/scm/scm-load-file-test-data.scm: -------------------------------------------------------------------------------- 1 | 2 | ; Test single-letter names; this was buggy. 3 | (Evaluation (Predicate "P") (List (Concept "A") (Concept "B"))) 4 | 5 | ; (Concept "B" (stv 1 1)) 6 | 7 | ; Test UTF-8 8 | (ListLink(ConceptNode "тестирование кода приводит к успеху") 9 | 10 | 11 | 12 | 13 | (ListLink 14 | 15 | 16 | 17 | (ConceptNode "Codeprüfung führt zum Erfolg")(ConceptNode "'''''''''1;"))) 18 | 19 | ; Test lines that wrap strangely 20 | (MemberLink 21 | (LexicalNode "AGXT") 22 | (ConceptNode "SMP0000055") 23 | )(MemberLink 24 | (LexicalNode "Uniprot:P21549") 25 | (ConceptNode "SMP0000055") 26 | )(EvaluationLink 27 | (PredicateNode "has_name");test comment at end of line 28 | (ListLink 29 | (ConceptNode "SMP0000055");;;;; here too. 30 | (ConceptNode "Alanine Metabolism"))) 31 | 32 | ;gaf-version: 2.1 33 | 34 | ; 35 | 36 | 37 | (MemberLink 38 | (LexicalNode "APOC4-APOC2") 39 | (ConceptNode "GO:0006629")) 40 | (EvaluationLink 41 | (PredicateNode "has_name") 42 | (ListLink 43 | (LexicalNode "APOC4-APOC2") 44 | (ConceptNode "Apolipoprotein C-II isoform 1") 45 | ) 46 | ) 47 | 48 | (MemberLink 49 | (LexicalNode "APOC4-APOC2") 50 | (ConceptNode "GO:0006869")) 51 | 52 | -------------------------------------------------------------------------------- /tests/scm/scm-opencog-test-runner-fail.scm: -------------------------------------------------------------------------------- 1 | (use-modules (opencog) 2 | (opencog test-runner)) 3 | 4 | (opencog-test-runner) 5 | (define t "opencog-test-runner-fail") 6 | 7 | ; Test that exit value is propageted correctly on fail. 8 | (test-begin t) 9 | 10 | ; The test could be written such that the atomspace isn't used, but since 11 | ; this test acts as an example for how to use the test-runner with cmake 12 | ; configuration, doing so will prevent showing how tests should be 13 | ; configured when the scheme code is a wrapper to a c++ library. 14 | (test-equal "Failing-test" (Node "a") (Link)) 15 | 16 | (test-end t) 17 | -------------------------------------------------------------------------------- /tests/scm/scm-opencog-test-runner-pass.scm: -------------------------------------------------------------------------------- 1 | (use-modules (opencog) 2 | (opencog test-runner)) 3 | 4 | (opencog-test-runner) 5 | (define t "opencog-test-runner-pass") 6 | 7 | ; Test that exit value is propageted correctly on pass. 8 | (test-begin t) 9 | 10 | ; The test could be written such that the atomspace isn't used, but since 11 | ; this test acts as an example for how to use the test-runner with cmake 12 | ; configuration, doing so will prevent showing how tests should be 13 | ; configured when the scheme code is a wrapper to a c++ library. 14 | (test-equal "Passing-test" (Node "a") (Node "a")) 15 | 16 | (test-end t) 17 | -------------------------------------------------------------------------------- /tests/scm/scm-python.scm: -------------------------------------------------------------------------------- 1 | 2 | (use-modules (opencog) (opencog test-runner)) 3 | (use-modules (opencog python)) 4 | 5 | (opencog-test-runner) 6 | (define t "opencog-python-sniff-test") 7 | 8 | (test-begin t) 9 | 10 | ; All that we do here is to make sure that python doesn't crash. 11 | ; `python-eval` returns whatever python returned, as a string. 12 | (define rc (python-eval "print ('Hello world\\n', 2+2)")) 13 | 14 | ; Python print itself evaluates to 'None'. But before that, it 15 | ; prints stuff to stdout, which we expect to see. 16 | (define expected "Hello world\n 4\nNone\n") 17 | 18 | ; CxxTest steals away stdout, and eats the result of the print 19 | ; statement. So if we are running this test in the CxxTest harness 20 | ; then there's no "Hello world" (but if you run it by hand, there is.) 21 | (define expected-in-cxxtest "None\n") 22 | 23 | (format #t "python-eval returned this: >>~A<<\n" rc) 24 | 25 | (test-assert "Oh no! python-eval is borken!" 26 | (or (string=? rc expected) 27 | (string=? rc expected-in-cxxtest))) 28 | 29 | (test-end t) 30 | -------------------------------------------------------------------------------- /tests/sheaf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ADD_GUILE_TEST(GraphExtents extents.scm) 3 | ADD_GUILE_TEST(LinearParser linear-parser.scm) 4 | --------------------------------------------------------------------------------