├── .circleci └── config.yml ├── .gitignore ├── AUTHORS ├── CMakeLists.txt ├── LICENSE ├── README.md ├── TODO ├── cmake ├── CMakeLists.txt ├── OpenCogAtomTypes.cmake ├── OpenCogCython.cmake ├── OpenCogFunctions.cmake ├── OpenCogGenCxxTypes.cmake ├── OpenCogGenOCamlTypes.cmake ├── OpenCogGenPythonTypes.cmake ├── OpenCogGenScmTypes.cmake ├── OpenCogGenTypes.cmake ├── OpenCogGenWrapper.cmake ├── OpenCogGuile.cmake ├── OpenCogMacros.cmake └── OpenCogOCaml.cmake ├── doc ├── CMakeLists.txt ├── Doxyfile ├── HaskellDoc.cmake ├── README.archlinux ├── README.gentoo ├── README.osx ├── README.win32 ├── README_to_doxygen.sh └── doxydoc │ ├── bldtargets.dox │ ├── fsstructure.dox │ ├── layout.ini │ ├── libatomspace.dox │ ├── libhaskell.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 │ ├── episodic-space.scm │ ├── except.scm │ ├── execute.scm │ ├── factorial.scm │ ├── flow-formulas.scm │ ├── flow-futures.scm │ ├── flow-string.scm │ ├── flows.scm │ ├── formulas.scm │ ├── frame.scm │ ├── get-put.scm │ ├── gperf.scm │ ├── knowledge.scm │ ├── logging.scm │ ├── multi-space.scm │ ├── my_py_func.py │ ├── parallel.scm │ ├── persist-buffer.scm │ ├── persist-file.scm │ ├── persist-multi.scm │ ├── persist-proxy.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 │ ├── table.csv │ ├── table.scm │ ├── threaded.scm │ ├── truthvalues.scm │ └── values.scm ├── c++-guile │ ├── CMakeLists.txt │ ├── ExampleSCM.cc │ ├── ExampleSCM.h │ ├── PrimitiveExample.cc │ ├── README.md │ ├── opencog │ │ └── example.scm │ └── run-example.scm ├── c++ │ ├── CMakeLists.txt │ ├── README.md │ └── basic.cc ├── foreign │ ├── README.md │ ├── prolog-datalog.scm │ └── sexpr-query.scm ├── haskell │ ├── README.md │ ├── example.hs │ ├── example_multiple_atoms.hs │ ├── example_multiple_atomspaces.hs │ ├── example_multithreading.hs │ └── example_pattern_matcher.hs ├── ocaml │ ├── README.md │ ├── basics.ml │ └── query.ml ├── pattern-matcher │ ├── README.md │ ├── absent.scm │ ├── always.scm │ ├── choice.scm │ ├── condition.scm │ ├── deduction-engine.scm │ ├── define.scm │ ├── dot-product.scm │ ├── filter-strings.scm │ ├── filter-value.scm │ ├── filter.scm │ ├── fsm-basic.scm │ ├── fsm-full.scm │ ├── fsm-mealy.scm │ ├── glob.scm │ ├── gpn.scm │ ├── group-by.scm │ ├── gsn-truth.scm │ ├── gsn.scm │ ├── markov-chain.scm │ ├── presence.scm │ ├── put-filter.scm │ ├── query.scm │ ├── recognizer.scm │ ├── recursive.scm │ ├── satisfaction.scm │ ├── sequence.scm │ ├── type-signature.scm │ ├── unify.scm │ ├── value-of.scm │ ├── vector-column.scm │ └── virtual.scm ├── python │ ├── README.md │ ├── __init__.py │ ├── create_atoms.py │ ├── create_atoms_lowlevel.py │ ├── ground │ │ ├── ground.py │ │ └── mymodule.py │ ├── nameserver_example.py │ ├── scheme_sharing.py │ ├── scheme_timer.py │ ├── stop_go.py │ ├── storage_tutorial.py │ └── vector_tutorial.py └── type-system │ ├── CMakeLists.txt │ ├── README.md │ ├── apps │ ├── CMakeLists.txt │ ├── chemain.cc │ ├── chemy_hello.py │ └── hello-chem.scm │ └── demo-types │ ├── CMakeLists.txt │ ├── Carbon14Node.cc │ ├── Carbon14Node.h │ ├── ChemTypes.cc │ ├── chem_types.script │ ├── chempydemo.pyx │ └── demo-types.scm ├── lib ├── AtomSpaceConfig.cmake.in ├── CMakeLists.txt ├── atomspace.pc.in └── buildbot-master.cfg ├── 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 │ ├── columnvec │ │ ├── CMakeLists.txt │ │ ├── FloatColumn.cc │ │ ├── FloatColumn.h │ │ ├── LinkColumn.cc │ │ ├── LinkColumn.h │ │ ├── README.md │ │ ├── SexprColumn.cc │ │ ├── SexprColumn.h │ │ ├── TransposeColumn.cc │ │ └── TransposeColumn.h │ ├── core │ │ ├── AbsentLink.cc │ │ ├── AbsentLink.h │ │ ├── CMakeLists.txt │ │ ├── Checkers.cc │ │ ├── CondLink.cc │ │ ├── CondLink.h │ │ ├── Context.cc │ │ ├── Context.h │ │ ├── DefineLink.cc │ │ ├── DefineLink.h │ │ ├── DeleteLink.cc │ │ ├── DeleteLink.h │ │ ├── DontExecLink.cc │ │ ├── DontExecLink.h │ │ ├── FindUtils.cc │ │ ├── FindUtils.h │ │ ├── FreeLink.cc │ │ ├── FreeLink.h │ │ ├── FreeVariables.cc │ │ ├── FreeVariables.h │ │ ├── FunctionLink.cc │ │ ├── FunctionLink.h │ │ ├── GrantLink.cc │ │ ├── GrantLink.h │ │ ├── LambdaLink.cc │ │ ├── LambdaLink.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 │ │ ├── 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 │ │ ├── CMakeLists.txt │ │ ├── EvaluationLink.cc │ │ ├── EvaluationLink.h │ │ ├── ExecutionOutputLink.cc │ │ ├── ExecutionOutputLink.h │ │ ├── Force.cc │ │ ├── Force.h │ │ ├── GroundedProcedureNode.h │ │ ├── Instantiator.cc │ │ ├── Instantiator.h │ │ └── README.md │ ├── flow │ │ ├── CMakeLists.txt │ │ ├── CollectionOfLink.cc │ │ ├── CollectionOfLink.h │ │ ├── ConcatenateLink.cc │ │ ├── ConcatenateLink.h │ │ ├── FilterLink.cc │ │ ├── FilterLink.h │ │ ├── FormulaPredicateLink.cc │ │ ├── FormulaPredicateLink.h │ │ ├── IncomingOfLink.cc │ │ ├── IncomingOfLink.h │ │ ├── IncrementValueLink.cc │ │ ├── IncrementValueLink.h │ │ ├── LinkSignatureLink.cc │ │ ├── LinkSignatureLink.h │ │ ├── NumberOfLink.cc │ │ ├── NumberOfLink.h │ │ ├── PromiseLink.cc │ │ ├── PromiseLink.h │ │ ├── SetTVLink.cc │ │ ├── SetTVLink.h │ │ ├── SetValueLink.cc │ │ ├── SetValueLink.h │ │ ├── SizeOfLink.cc │ │ ├── SizeOfLink.h │ │ ├── SplitLink.cc │ │ ├── SplitLink.h │ │ ├── StreamValueOfLink.cc │ │ ├── StreamValueOfLink.h │ │ ├── StringOfLink.cc │ │ ├── StringOfLink.h │ │ ├── TruthValueOfLink.cc │ │ ├── TruthValueOfLink.h │ │ ├── TypeOfLink.cc │ │ ├── TypeOfLink.h │ │ ├── ValueOfLink.cc │ │ ├── ValueOfLink.h │ │ ├── ValueShimLink.cc │ │ └── ValueShimLink.h │ ├── foreign │ │ ├── CMakeLists.txt │ │ ├── DatalogAST.cc │ │ ├── DatalogAST.h │ │ ├── ForeignAST.cc │ │ ├── ForeignAST.h │ │ ├── README.md │ │ ├── SexprAST.cc │ │ └── SexprAST.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 │ ├── join │ │ ├── CMakeLists.txt │ │ ├── JoinLink.cc │ │ └── JoinLink.h │ ├── parallel │ │ ├── CMakeLists.txt │ │ ├── ExecuteThreadedLink.cc │ │ ├── ExecuteThreadedLink.h │ │ ├── ParallelLink.cc │ │ ├── ParallelLink.h │ │ ├── PureExecLink.cc │ │ ├── PureExecLink.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 │ │ ├── BoolOpLink.cc │ │ ├── BoolOpLink.h │ │ ├── CMakeLists.txt │ │ ├── DecimateLink.cc │ │ ├── DecimateLink.h │ │ ├── DivideLink.cc │ │ ├── DivideLink.h │ │ ├── ElementOfLink.cc │ │ ├── ElementOfLink.h │ │ ├── FoldLink.cc │ │ ├── FoldLink.h │ │ ├── ImpulseLink.cc │ │ ├── ImpulseLink.h │ │ ├── MaxLink.cc │ │ ├── MaxLink.h │ │ ├── MinLink.cc │ │ ├── MinLink.h │ │ ├── MinusLink.cc │ │ ├── MinusLink.h │ │ ├── NumericFunctionLink.cc │ │ ├── NumericFunctionLink.h │ │ ├── PlusLink.cc │ │ ├── PlusLink.h │ │ ├── README.md │ │ ├── TimesLink.cc │ │ └── TimesLink.h │ ├── rule │ │ ├── CMakeLists.txt │ │ ├── ConclusionOfLink.cc │ │ ├── ConclusionOfLink.h │ │ ├── PremiseOfLink.cc │ │ ├── PremiseOfLink.h │ │ ├── RuleLink.cc │ │ ├── RuleLink.h │ │ ├── VardeclOfLink.cc │ │ └── VardeclOfLink.h │ ├── truthvalue │ │ ├── CMakeLists.txt │ │ ├── CountTruthValue.cc │ │ ├── CountTruthValue.h │ │ ├── FormulaTruthValue.cc │ │ ├── FormulaTruthValue.h │ │ ├── README.md │ │ ├── SimpleTruthValue.cc │ │ ├── SimpleTruthValue.h │ │ ├── TruthValue.cc │ │ └── TruthValue.h │ └── value │ │ ├── BoolValue.cc │ │ ├── BoolValue.h │ │ ├── CMakeLists.txt │ │ ├── ContainerValue.cc │ │ ├── ContainerValue.h │ │ ├── FloatValue.cc │ │ ├── FloatValue.h │ │ ├── FormulaStream.cc │ │ ├── FormulaStream.h │ │ ├── FutureStream.cc │ │ ├── FutureStream.h │ │ ├── LinkStreamValue.cc │ │ ├── LinkStreamValue.h │ │ ├── LinkValue.cc │ │ ├── LinkValue.h │ │ ├── QueueValue.cc │ │ ├── QueueValue.h │ │ ├── README.md │ │ ├── RandomStream.cc │ │ ├── RandomStream.h │ │ ├── StreamValue.cc │ │ ├── StreamValue.h │ │ ├── StringValue.cc │ │ ├── StringValue.h │ │ ├── UnisetValue.cc │ │ ├── UnisetValue.h │ │ ├── Value.cc │ │ ├── Value.h │ │ ├── ValueFactory.cc │ │ ├── ValueFactory.h │ │ ├── VoidValue.cc │ │ └── VoidValue.h ├── atomspace │ ├── AtomSpace.cc │ ├── AtomSpace.h │ ├── AtomTable.cc │ ├── CMakeLists.txt │ ├── Frame.cc │ ├── Frame.h │ ├── README-DeepSpace.md │ ├── README.md │ ├── Transient.cc │ ├── Transient.h │ ├── TypeIndex.cc │ ├── TypeIndex.h │ └── version.h ├── cython │ ├── CMakeLists.txt │ ├── PyIncludeWrapper.h │ ├── PythonEval.cc │ ├── PythonEval.h │ ├── PythonSCM.cc │ ├── README.md │ ├── executioncontext │ │ ├── CMakeLists.txt │ │ ├── Context.cc │ │ └── Context.h │ └── opencog │ │ ├── CMakeLists.txt │ │ ├── ExecuteStub.cc │ │ ├── ExecuteStub.h │ │ ├── PyScheme.cc │ │ ├── PyScheme.h │ │ ├── Utilities.cc │ │ ├── Utilities.h │ │ ├── __init__.py │ │ ├── atom.pyx │ │ ├── atomspace.pxd │ │ ├── atomspace.pyx │ │ ├── atomspace_details.pyx │ │ ├── bool_value.pyx │ │ ├── execute.pxd │ │ ├── execute.pyx │ │ ├── float_value.pyx │ │ ├── link_value.pyx │ │ ├── load-file.cc │ │ ├── load-file.h │ │ ├── logger.pxd │ │ ├── logger.pyx │ │ ├── nameserver.pyx │ │ ├── python.scm │ │ ├── scheme.pyx │ │ ├── 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 │ │ └── opencog │ │ ├── exec.scm │ │ ├── logger.scm │ │ ├── randgen.scm │ │ └── type-utils.scm ├── 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 ├── ocaml │ ├── CMakeLists.txt │ ├── CamlWrap.cc │ ├── CamlWrap.h │ ├── META │ ├── README.md │ ├── atomese.ml │ └── atomspace.ml ├── query │ ├── CMakeLists.txt │ ├── ContinuationMixin.cc │ ├── ContinuationMixin.h │ ├── 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 │ │ ├── atom-docs.scm │ │ ├── core-docs.scm │ │ ├── debug-trace.scm │ │ ├── file-utils.scm │ │ ├── repl-shell.scm │ │ ├── tv.scm │ │ ├── types.scm │ │ └── utilities.scm │ │ ├── extension.scm │ │ └── test-runner.scm └── sheaf │ ├── README.md │ ├── attic │ ├── CMakeLists.txt │ ├── README.md │ ├── 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 │ ├── linear-parser.scm │ ├── make-section.scm │ ├── mpg-parser.scm │ ├── mst-parser.scm │ ├── sections.scm │ ├── sheaf.scm │ ├── tests │ │ ├── CMakeLists.txt │ │ ├── extents.scm │ │ └── linear-parser.scm │ └── vo-graph.scm │ └── docs │ ├── README.md │ ├── ccg.lyx │ ├── ccg.pdf │ ├── coli-2024 │ ├── README.md │ ├── ccg-coli.lyx │ ├── clv3.layout │ └── coli-cover-letter.lyx │ ├── connectors-and-variables.lyx │ ├── connectors-and-variables.pdf │ ├── factorization.lyx │ ├── factorization.pdf │ ├── feature.lyx │ ├── feature.pdf │ ├── graphics │ ├── LG-inference.dia │ ├── LG-inference.eps │ ├── bad-graph.dia │ ├── bad-graph.eps │ ├── chain.dia │ ├── chain.eps │ ├── coproduct.dia │ ├── coproduct.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 │ ├── graph-6.dia │ ├── graph-6.eps │ ├── hedgehog.dia │ ├── hedgehog.eps │ ├── history.dia │ ├── history.eps │ ├── hypergraph-wide.dia │ ├── hypergraph-wide.eps │ ├── hypergraph.dia │ ├── hypergraph.eps │ ├── inference.dia │ ├── inference.eps │ ├── joe-mary-v1-wide.dia │ ├── joe-mary-v1-wide.eps │ ├── joe-mary-v1.dia │ ├── joe-mary-v1.eps │ ├── joe-mary-v2-wide.dia │ ├── joe-mary-v2-wide.eps │ ├── joe-mary-v2.dia │ ├── joe-mary-v2.eps │ ├── krebs.svg │ ├── link-grammar.png │ ├── loop-4-legs.dia │ ├── loop-4-legs.eps │ ├── metagraph-new.dia │ ├── metagraph-new.eps │ ├── metagraph-weak.dia │ ├── metagraph-weak.eps │ ├── metagraph-wide.dia │ ├── metagraph-wide.eps │ ├── metagraph.dia │ ├── metagraph.eps │ ├── metaquery-wide.dia │ ├── metaquery-wide.eps │ ├── metaquery.dia │ ├── metaquery.eps │ ├── org-chart-wide.dia │ ├── org-chart-wide.eps │ ├── org-chart.dia │ ├── org-chart.eps │ ├── parsing.dia │ ├── parsing.eps │ ├── partial-index.dia │ ├── partial-index.eps │ ├── phosphorylation.svg │ ├── polymorph.dia │ ├── polymorph.eps │ ├── product-students.dia │ ├── product-students.eps │ ├── product.dia │ ├── product.eps │ ├── project.dia │ ├── project.eps │ ├── puzzle-beta-reduce-wide.dia │ ├── puzzle-beta-reduce-wide.eps │ ├── puzzle-beta-reduce.dia │ ├── puzzle-beta-reduce.eps │ ├── puzzle-connected.dia │ ├── puzzle-connected.eps │ ├── puzzle-function.dia │ ├── puzzle-function.eps │ ├── puzzle-left.dia │ ├── puzzle-left.eps │ ├── puzzle-right.dia │ ├── puzzle-right.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 │ └── tods-2024 │ ├── README.md │ ├── acmart.layout │ ├── ccs.tex │ ├── ram-cpu-tods.lyx │ ├── ram-cpu-tods.pdf │ └── tods-cover-letter.lyx ├── pyproject.toml ├── scripts ├── .gdbinit ├── .gdbinit-print-opencog ├── README.md ├── benchmark_utests.sh ├── combine_lcov.sh ├── helgrind.guile.suppressions ├── query │ └── benchmark_query.sh ├── run_lcov.sh ├── valgrind.boost.suppressions ├── valgrind.guile.suppressions ├── valgrind.link-grammar.suppressions ├── valgrind.logger.suppressions └── valgrind.python.suppressions └── tests ├── CMakeLists.txt ├── atoms ├── AlphaConvertUTest.cxxtest ├── BetaReduceUTest.cxxtest ├── CMakeLists.txt ├── HashUTest.cxxtest ├── RandomUTest.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 ├── columnvec │ ├── CMakeLists.txt │ ├── float-column-test.scm │ ├── link-column-test.scm │ ├── sexpr-column-test.scm │ └── transpose-column-test.scm ├── core │ ├── CMakeLists.txt │ ├── CheckersUTest.cxxtest │ ├── CondLinkUTest.cxxtest │ ├── DefineLinkUTest.cxxtest │ ├── DeleteLinkUTest.cxxtest │ ├── FindUtilsUTest.cxxtest │ ├── FreeLinkUTest.cxxtest │ ├── NumberNodeUTest.cxxtest │ ├── PutLinkUTest.cxxtest │ ├── QuotationUTest.cxxtest │ ├── RewriteLinkUTest.cxxtest │ ├── ScopeLinkUTest.cxxtest │ ├── StateLinkUTest.cxxtest │ ├── TypeIntersectionUTest.cxxtest │ ├── TypeUtilsUTest.cxxtest │ ├── VariablesUTest.cxxtest │ ├── condlink.scm │ ├── grant-test.scm │ ├── present-test.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-recursive-test.scm │ ├── put-tricky.scm │ └── quotations.scm ├── evaluation │ ├── CMakeLists.txt │ ├── EqualLinkUTest.cxxtest │ ├── ExclusiveLinkUTest.cxxtest │ ├── IdenticalLinkUTest.cxxtest │ ├── MemberLinkUTest.cxxtest │ └── SubsetLinkUTest.cxxtest ├── execution │ ├── CMakeLists.txt │ ├── DefinedSchemaUTest.cxxtest │ └── defined-schema.scm ├── flow │ ├── CMakeLists.txt │ ├── DynamicUTest.cxxtest │ ├── FilterLinkUTest.cxxtest │ ├── FormulaUTest.cxxtest │ ├── SetTVUTest.cxxtest │ ├── SetValueUTest.cxxtest │ ├── StreamValueOfUTest.cxxtest │ ├── ValueOfUTest.cxxtest │ ├── collection-of-test.scm │ ├── concatenate-test.scm │ ├── dynamic.scm │ ├── filter-float-test.scm │ ├── filter-glob-test.scm │ ├── filter-link.scm │ ├── filter-rule-test.scm │ ├── filter-strings-test.scm │ ├── filter-value-test.scm │ ├── formulas.scm │ ├── futures.scm │ ├── incoming-of-test.scm │ ├── increment-value-test.scm │ ├── set-tv-flow.scm │ ├── set-value-flow.scm │ ├── split-test.scm │ └── string-of-test.scm ├── foreign │ ├── CMakeLists.txt │ ├── datalog-basic-test.scm │ └── sexpr-query-test.scm ├── grounded │ ├── CMakeLists.txt │ └── GroundedSchemaLocalUTest.cxxtest ├── hash.scm ├── join │ ├── 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 ├── 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 │ ├── bool-library-test.scm │ ├── element-of-test.scm │ └── math-library-test.scm ├── rule │ ├── CMakeLists.txt │ └── rule-test.scm ├── truthvalue │ ├── CMakeLists.txt │ ├── SimpleTruthValueUTest.cxxtest │ ├── TVUTest.cxxtest │ └── tv-test.scm └── value │ ├── CMakeLists.txt │ ├── StreamUTest.cxxtest │ ├── ValueUTest.cxxtest │ ├── VoidValueUTest.cxxtest │ └── stream.scm ├── atomspace ├── AtomSpaceUTest.cxxtest ├── AtomTableUTest.cxxtest ├── CMakeLists.txt ├── COWSpaceUTest.cxxtest ├── EpisodicSpaceUTest.cxxtest ├── HashMixUTest.cxxtest ├── MultiSpaceUTest.cxxtest ├── ReAddUTest.cxxtest ├── RemoveUTest.cxxtest ├── UseCountUTest.cxxtest ├── cover-basic-delete-test.scm ├── cover-basic-test.scm ├── cover-delete-test.scm ├── cover-incoming-test.scm ├── cover-space-test.scm ├── deep-space-test.scm ├── frame-incoming-test.scm ├── recover-stack-test.scm └── recover-test.scm ├── cython ├── CMakeLists.txt ├── PythonEvalUTest.cxxtest ├── PythonUtilitiesUTest.cxxtest ├── README.md ├── atomspace │ ├── test_atom.py │ ├── test_atomspace.py │ ├── test_boolvalue.py │ ├── test_callback_arity.py │ ├── test_do_execute.py │ ├── test_exception.py │ ├── test_floatvalue.py │ ├── test_linkvalue.py │ ├── test_linkvalue_containing_atoms.py │ ├── test_nameserver.py │ └── test_stringvalue.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 ├── query ├── AbsentUTest.cxxtest ├── AlwaysUTest.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 ├── ChemTypes.cc ├── ChoiceLinkUTest.cxxtest ├── ClassicalBooleanUTest.cxxtest ├── ConstantClausesUTest.cxxtest ├── DeepTypeUTest.cxxtest ├── DefineUTest.cxxtest ├── DisconnectedUTest.cxxtest ├── DontExecUTest.cxxtest ├── EinsteinUTest.cxxtest ├── EvalLinkDefaultTVUTest.cxxtest ├── EvaluationUTest.cxxtest ├── ExecutionOutputUTest.cxxtest ├── FiniteStateMachineUTest.cxxtest ├── FormulaPredicateUTest.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 ├── PresentUTest.cxxtest ├── QueryUTest.cxxtest ├── QuoteUTest.cxxtest ├── RecognizerUTest.cxxtest ├── ScopeUTest.cxxtest ├── SequenceUTest.cxxtest ├── SparseUTest.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 ├── 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 ├── chem_types.script ├── 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 ├── dot-choice-test.scm ├── dot-identical-test.scm ├── dot-lambda-test.scm ├── dot-mashup-test.scm ├── dot-product-test.scm ├── eval-default-tv.scm ├── eval-equal.scm ├── eval-lambda.scm ├── eval-var.scm ├── evaluation.scm ├── exec-factorial.scm ├── exec-gsn.scm ├── exec-lambda-get.scm ├── exec-lambda.scm ├── exec.scm ├── executable-pattern.scm ├── finite-state-machine.scm ├── formula-predicate.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 ├── group-by-test.scm ├── ill-put.scm ├── implication-introduction.scm ├── imply.h ├── is_closed.scm ├── is_false.scm ├── is_true.scm ├── marginals-test.scm ├── match-link.scm ├── meet-link-value-test.scm ├── multi-space-test.scm ├── nested-and.scm ├── no-exception-analysis.scm ├── no-exception.scm ├── or-bind-test.scm ├── or-eval-test.scm ├── or-link-test.scm ├── or-more-test.scm ├── present-monotonicity.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-start-test.scm ├── quote-throw.scm ├── quote-var.scm ├── recognizer.scm ├── recursive-test.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 ├── signature-test.scm ├── sparse-list.scm ├── sparse-react-ordered.scm ├── sparse-react.scm ├── sparse-rinf.scm ├── sparse.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 ├── unify-test.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 ├── SCMUtf8StringUTest.cxxtest ├── SCMUtilsUTest.cxxtest ├── as-of-atom.scm ├── copy-atom-test.scm ├── inline-values.scm ├── pm.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 /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 | OpenCogGenCxxTypes.cmake 5 | OpenCogGenOCamlTypes.cmake 6 | OpenCogGenPythonTypes.cmake 7 | OpenCogGenScmTypes.cmake 8 | OpenCogGenTypes.cmake 9 | OpenCogGenWrapper.cmake 10 | OpenCogGuile.cmake 11 | OpenCogOCaml.cmake 12 | OpenCogMacros.cmake 13 | OpenCogFunctions.cmake 14 | DESTINATION 15 | ${DATADIR}/cmake/) 16 | -------------------------------------------------------------------------------- /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(OpenCogAtomTypes) 4 | INCLUDE(OpenCogGuile) 5 | INCLUDE(OpenCogCython) 6 | -------------------------------------------------------------------------------- /cmake/OpenCogMacros.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Backwards-compatibility wrapper 3 | INCLUDE(OpenCogAtomTypes) 4 | -------------------------------------------------------------------------------- /cmake/OpenCogOCaml.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # commented out because ti doesn't seem to do anything. 3 | # 4 | ## Convert one ml file to an mli file. 5 | ## Additional arguments are dependencies 6 | # 7 | #MACRO(OCAML_MAKE_INTERFACE name) 8 | # SET(DEPENDS ${name}) 9 | # 10 | # # Allow the user to specify dependencies as optional arguments 11 | # SET(DEPENDS ${DEPENDS} ${ARGN}) 12 | # 13 | # ADD_CUSTOM_COMMAND( 14 | # OUTPUT ${name}i 15 | # COMMAND ${CMAKE_OCaml_FIND} ocamlc -i ${name} >> ${name}i 16 | # DEPENDS ${DEPENDS} 17 | # WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 18 | # COMMENT "Building the ${name}i file" 19 | # ) 20 | # 21 | # list(APPEND ADDITIONAL_MAKE_CLEAN_FILES "${name}i") 22 | #ENDMACRO() 23 | # 24 | -------------------------------------------------------------------------------- /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 | Opencog depends on the following packages. 6 | 7 | g++ cmake guile cxxtest 8 | 9 | Optionally, install python and cython 10 | 11 | ---------------------------------------------------------- 12 | -------------------------------------------------------------------------------- /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 8 | 9 | ---------------------------------------------------------- 10 | 11 | Additionally, it depends on the following non-official packages: 12 | 13 | cxxtest 14 | 15 | which are available in the 'vendor' directory. To install them, issue 16 | the following commands: 17 | 18 | prompt# cd 19 | prompt# ebuild vendor/cxxtest/gentoo/dev-cpp/cxxtest/cxxtest*.ebuild install qmerge 20 | 21 | ---------------------------------------------------------- 22 | 23 | Opencog also depends on the following packages: 24 | 25 | dev-scheme/guile -- needed for scheme bindings 26 | -------------------------------------------------------------------------------- /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 | ADD_SUBDIRECTORY (type-system) 4 | -------------------------------------------------------------------------------- /examples/atomspace/except.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; except.scm -- Catching exceptions from bad code. 3 | ; 4 | ; Code that is invoked by ExecutionOutputLink can be buggy; exceptions 5 | ; will be thrown. This exceptions can be caught and handled in scheme. 6 | ; 7 | ; See `execute.scm` for more `cog-execute!` examples. 8 | ; 9 | 10 | (use-modules (opencog) (opencog exec)) 11 | 12 | ; First, just give it some broken junk. See what happens. 13 | (cog-execute! 14 | (ExecutionOutput 15 | (GroundedSchema "py:b0rk3n_junk") 16 | (List 17 | (Concept "1") 18 | (Concept "2")))) 19 | 20 | ; C++ exceptions are converted into scheme exceptions, and can be 21 | ; caught, as usual. 22 | (catch 23 | #t 24 | (lambda () 25 | (cog-execute! 26 | (ExecutionOutput 27 | (GroundedSchema "py:b0rk3n_junk") 28 | (List 29 | (Concept "1") 30 | (Concept "2"))))) 31 | (lambda (key . args) 32 | (display "Ohhh noooo Mr. Bill!!! ") (display key) 33 | (newline) 34 | (display "Sluggo says to ... ") (display args) 35 | (newline) (newline) 36 | )) 37 | 38 | 39 | ; Exception-producing code, but for mal-formed scheme. 40 | ; 41 | (cog-execute! 42 | (ExecutionOutput 43 | (GroundedSchema "scm:(((((uber-badf") 44 | (List 45 | (Concept "1") 46 | (Concept "2")))) 47 | -------------------------------------------------------------------------------- /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 their 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(f'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 | return TruthValue(1.0/av, 1.0/bv) 29 | -------------------------------------------------------------------------------- /examples/atomspace/table.csv: -------------------------------------------------------------------------------- 1 | # 2 | # This is a simple demo CSV file. 3 | # It contains a table of data, in comma-separated-value format. 4 | # You can also use tab-separated values. 5 | # 6 | # This table contains a text column header. 7 | # The column labels can be anything. 8 | # If the header is absent, default labels will be generated. 9 | # 10 | b1, b2, b3, flt1, flt2, lbl 11 | 12 | # Now for some data. Three columns of binary numbers, 13 | # Two floats, and one column of strings. 14 | 0, 0, 1, 3.3, 4.4, "one" 15 | 0, 0, 1, 4.4, 5.5, "one" 16 | 0, 1, 1, 3.4, 6.5, "three" 17 | 1, 0, 1, 2.4, 7.5, "five" 18 | 19 | # T and F are maybe better for binary ... 20 | T, F, T, 4, 9, "five" 21 | T, T, F, 5, 11, "six" 22 | T, T, T, 2, 8.9, "seven" 23 | -------------------------------------------------------------------------------- /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 | * Example wrapper for creating guile modules. 5 | */ 6 | 7 | #ifndef _OPENCOG_EXAMPLE_SCM_H 8 | #define _OPENCOG_EXAMPLE_SCM_H 9 | 10 | #include 11 | 12 | namespace opencog { 13 | 14 | class ExampleSCM : public ModuleWrap 15 | { 16 | protected: 17 | virtual void init(void); 18 | public: 19 | ExampleSCM(void); 20 | }; 21 | 22 | } 23 | 24 | extern "C" { 25 | // This function will be called to initialize the module. 26 | void opencog_example_init(void); 27 | }; 28 | 29 | #endif // _OPENCOG_EXAMPLE_SCM_H 30 | -------------------------------------------------------------------------------- /examples/c++-guile/README.md: -------------------------------------------------------------------------------- 1 | 2 | C++ to Guile wrapper examples 3 | ----------------------------- 4 | 5 | The `PrimitiveExample.cc` file demonstrates how to wrap C++ class 6 | methods with guile (scheme) wrappers. It also shows how to call guile 7 | functions from C++ code, using the `SchemeEval` evaluator. 8 | 9 | Compile the example with `make examples` in the `build` directory. The 10 | resulting executable is in `build/examples/c++-guile/PrimitiveExample`. 11 | Note: running the example prints a hefty stack trace, *on purpose*! 12 | Do not be alarmed! 13 | 14 | To make such functions accessible to scheme programs, they need to be 15 | encapsulated in a guile module. This is done in three parts: 16 | * `ExampleSCM.cc` shows the C++ code, and how to wrap it into a module. 17 | * `opencog/example.scm` shows the scheme boilerplate to load and 18 | initialize that module. 19 | * `run-example.scm` shows how users can run the wrappers. 20 | -------------------------------------------------------------------------------- /examples/c++-guile/opencog/example.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; OpenCog Example module 3 | ; 4 | 5 | ; The name of the module must be the same as the name used in the 6 | ; `define_scheme_primitive` call in the C++ code. 7 | (define-module (opencog example)) 8 | 9 | ; The first argument is the C++ library, and the second is the 10 | ; initialization routine to call. If the library is installed into 11 | ; the default shared library search path (i.e. /usr/local/lib/opencog), 12 | ; then the sring-append is not needed. However, we are not installing 13 | ; the example library, and so the explicit path is needed. 14 | (load-extension 15 | (string-append (getcwd) "/examples/c++-guile/libexample") 16 | "opencog_example_init") 17 | 18 | ; If the module was installed, then this would be enough: 19 | ; (load-extension "libexample" "opencog_example_init") 20 | -------------------------------------------------------------------------------- /examples/c++-guile/run-example.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Example of calling the wrapped c++ code. 3 | ; Run this example by starting guile, and then cut-n-pasting the 4 | ; code below. Alternately, run `guile -l run-example.scm` 5 | ; 6 | 7 | ; By default, guile modules are installed at 8 | ; /usr/local/share/guile/site/3.0 9 | ; which is one of the paths that appear in the %load-path guile 10 | ; variable. However, since we are not installing this example, we 11 | ; need to tell guile where to find it. 12 | 13 | (add-to-load-path "../examples/c++-guile") 14 | 15 | ; Print the list of load paths 16 | %load-path 17 | 18 | ; Alternately, the below will also work. 19 | ; (add-to-load-path (string-append (getcwd) "../examples/c++-guile")) 20 | 21 | ; Now, load the modules, as normal. 22 | (use-modules (opencog)) 23 | (use-modules (opencog example)) 24 | 25 | ; Call the two wrapped functions, found in `ExampleSCM.cc` 26 | (hey-print (Concept "a")) 27 | (hey-printmore (Concept "a")) 28 | 29 | ; A fancier example, showing that `hey-printmore` really does return 30 | ; the TruthValue. 31 | (define b (Concept "bbb" (SimpleTruthValue 0.6 0.8))) 32 | (hey-printmore b) 33 | 34 | ; The End. That's all folks! 35 | -------------------------------------------------------------------------------- /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++/README.md: -------------------------------------------------------------------------------- 1 | 2 | C++ Coding Examples 3 | =================== 4 | 5 | These examples can be built by saying, in the `build` directory, 6 | ``` 7 | make examples 8 | ``` 9 | 10 | The resulting binaries will be placed in `build/examples/c++`. 11 | 12 | The examples can also be compiled by hand. The `basic.cc` example can be 13 | compiled as: 14 | ``` 15 | g++ -std=c++17 -c basic.cc 16 | g++ -o basic basic.o -L/usr/local/lib/opencog -latom_types -latombase -latomspace 17 | ``` 18 | 19 | To run it, just say: 20 | ``` 21 | $ ./basic 22 | ``` 23 | -------------------------------------------------------------------------------- /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 | AtomSpacePtr as = createAtomSpace(); 15 | 16 | // Create a ConceptNode Atom, place it in the AtomSpace. 17 | Handle h = as->add_atom(Concept("foobar")); 18 | 19 | // Print it, take a look: 20 | printf("The new Atom is %s\n\n", h->to_short_string().c_str()); 21 | 22 | // A more verbose print: 23 | printf("The new Atom and its hash: %s\n\n", h->to_string().c_str()); 24 | 25 | // Print the atomspace contents. 26 | // Note that Atom ID's (64-bit hashes) are printed. 27 | printf("The AtomSpace contains this:\n%s\n", as->to_string().c_str()); 28 | 29 | // Create an EvaluationLink Atom, place it in the AtomSpace. 30 | as->add_atom( 31 | Evaluation( 32 | Predicate("bling"), 33 | List( 34 | Concept("foo"), 35 | Concept("bar")))); 36 | 37 | printf("Now the AtomSpace contains this:\n%s\n", as->to_string().c_str()); 38 | } 39 | -------------------------------------------------------------------------------- /examples/foreign/prolog-datalog.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; prolog-datalog.scm 3 | ; 4 | ; DataLog is a subset of ProLog, consisting of declarative statements 5 | ; only. This demo shows how DataLog statements expand into Atomese. 6 | ; 7 | ; --------------- 8 | 9 | (use-modules (opencog)) 10 | 11 | 12 | ; Create some simple declarations. Syntax-compatible with SWI-Prolog. 13 | ; 14 | ; Assertion of fact. 15 | (DatalogAst "likes(john, mary).") 16 | 17 | ; Take a look at how the above was converted into Atomese 18 | (cog-outgoing-atom (DatalogAst "likes(john, mary).") 0) 19 | 20 | ; Various other types of expressions. 21 | ; Horn clause: Sue is a girl if she is the daughter of Mary. 22 | (DatalogAst "girl(sue) :- daughter(sue,mary).") 23 | 24 | ; Rule: a clause containing variables. 25 | (DatalogAst "friends(X, Y) :- likes(X, Y), likes(Y, X).") 26 | 27 | ; Nested facts 28 | (DatalogAst "likes('John', car(bmw)).") 29 | 30 | ; -------- 31 | ; The End. That's all, folks! 32 | -------------------------------------------------------------------------------- /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: "...cannot 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/ocaml/basics.ml: -------------------------------------------------------------------------------- 1 | (** 2 | * basics.ml -- The most basic example of using the AtomSpace. 3 | * 4 | * Demos some of the basic OCaml API. 5 | *) 6 | 7 | #use "atomese.ml" ;; 8 | 9 | (* Create a foo node *) 10 | concept "foo" ;; 11 | 12 | (* Print the AtomSpace contents *) 13 | cog_print_atomspace () ;; 14 | 15 | (* Create a few more nodes, and a link *) 16 | let f = concept "foo" ;; 17 | let b = concept "bar" ;; 18 | let l = list_link [ f; b] ;; 19 | 20 | (* Take a look, again *) 21 | cog_print_atomspace () ;; 22 | 23 | (* Create a rather convetional evaluation link *) 24 | let e = evaluation [ predicate "likely"; l] ;; 25 | 26 | (* Get the string s-expression for it *) 27 | atom_sexpr e ;; 28 | 29 | (* That's all folks! *) 30 | -------------------------------------------------------------------------------- /examples/ocaml/query.ml: -------------------------------------------------------------------------------- 1 | (** 2 | * query.ml -- A simple query example. 3 | * 4 | * Example of performing AtomSpace queries in OCaml. 5 | *) 6 | #use "atomese.ml" ;; 7 | 8 | (* Populate the AtomSpace with contents *) 9 | evaluation [ 10 | predicate "likely"; 11 | list_link [ 12 | concept "foo" ; 13 | concept "bar" ] 14 | ] ;; 15 | 16 | evaluation [ 17 | predicate "perhaps"; 18 | list_link [ 19 | concept "sunny" ; 20 | concept "outdoors" ] 21 | ] ;; 22 | 23 | (* Take a look at the atomspace *) 24 | cog_print_atomspace () ;; 25 | 26 | (* Build a simple query *) 27 | let qry = 28 | meet [ 29 | variable_list [ 30 | typed_variable [ 31 | variable "?x" ; 32 | type_node "Concept" ]] ; 33 | present [ 34 | evaluation [ 35 | predicate "perhaps"; 36 | list_link [ 37 | variable "?x" ; 38 | concept "outdoors" ]]]] ;; 39 | 40 | (* Run the query *) 41 | cog_execute qry ;; 42 | 43 | (* That's all folks! *) 44 | -------------------------------------------------------------------------------- /examples/pattern-matcher/choice.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; choice.scm -- Using the ChoiceLink to explore alternatives. 3 | ; 4 | ; A very simple example of using the ChoiceLink. 5 | ; 6 | 7 | ; Populate the AtomSpace with some data 8 | (Evaluation 9 | (Predicate "has-color") 10 | (List 11 | (Concept "apple") 12 | (Concept "green"))) 13 | 14 | (Evaluation 15 | (Predicate "has-color") 16 | (List 17 | (Concept "banana") 18 | (Concept "yellow"))) 19 | 20 | (Evaluation 21 | (Predicate "has-color") 22 | (List 23 | (Concept "strawberry") 24 | (Concept "red"))) 25 | 26 | ; Look for fruit that is red or green. 27 | ; This won't work; although it looks nice, the ChoiceLink cannot 28 | ; be used in this way. Sorry. 29 | (define find-fruit 30 | (Get 31 | (Evaluation 32 | (Predicate "has-color") 33 | (List 34 | (Variable "$fruit") 35 | (Choice 36 | (Concept "red") 37 | (Concept "green")))))) 38 | 39 | 40 | ; This will work; the ChoiceLink appears at the top. 41 | (define find-fruit 42 | (Get 43 | (Choice 44 | (Evaluation 45 | (Predicate "has-color") 46 | (List 47 | (Variable "$fruit") 48 | (Concept "red"))) 49 | (Evaluation 50 | (Predicate "has-color") 51 | (List 52 | (Variable "$fruit") 53 | (Concept "green")))))) 54 | 55 | ; Run the query: 56 | (cog-execute! find-fruit) 57 | 58 | ; The answer will be what you expect. 59 | -------------------------------------------------------------------------------- /examples/python/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Cosmo Harrigan' 2 | -------------------------------------------------------------------------------- /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/scheme_sharing.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # 3 | # scheme_sharing.py 4 | # 5 | """ 6 | Demonstration of mixing python and scheme Atomese. 7 | """ 8 | 9 | from opencog.atomspace import * 10 | from opencog.type_constructors import * 11 | from opencog.scheme_wrapper import * 12 | 13 | # Create an AtomSpace, and let the python type constructors 14 | # know about it. 15 | asp = AtomSpace() 16 | set_default_atomspace(asp) 17 | 18 | # Add an Atom to the AtomSpace, using python 19 | ConceptNode("this is a test") 20 | 21 | # Print the AtomSpace contents, using scheme: 22 | scheme_eval(asp, '(cog-prt-atomspace)') 23 | scheme_eval(asp, 24 | '(format #t "Yes this is really scheme: ~A\n" (+ 2 2))') 25 | 26 | # Add an Atom, using scheme. The scheme_eval_h() function returns 27 | # a handle to that Atom, and python can use that handle, just as if 28 | # that Atom was created natively, in python. Both are the same Atom. 29 | foo_atom = scheme_eval_h(asp, '(Concept "foo")') 30 | print("In python it looks like this:", foo_atom) 31 | 32 | # Dump the AtomSpace contents into a list. You'll find both Atoms 33 | # are in there. 34 | print("The AtomSpace contains:" , list(asp)) 35 | 36 | # THE END. That's All, Folks! 37 | -------------------------------------------------------------------------------- /examples/python/scheme_timer.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 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 _ 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/type-system/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY (apps) 2 | ADD_SUBDIRECTORY (demo-types) 3 | -------------------------------------------------------------------------------- /examples/type-system/apps/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Demo chemistry apps. 3 | # 4 | # The chem_types.h file is written to the build directory 5 | INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}) 6 | 7 | ADD_EXECUTABLE(cpp-types-demo 8 | chemain.cc 9 | ) 10 | 11 | TARGET_LINK_LIBRARIES(cpp-types-demo 12 | ${OPENCOG_atomspace_LIRARIES} 13 | chem-demo-types 14 | atomspace 15 | ) 16 | -------------------------------------------------------------------------------- /examples/type-system/apps/hello-chem.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Example chemistry app, in scheme 3 | ; 4 | (use-modules (opencog) (opencog exec)) 5 | (use-modules (opencog demo-types)) 6 | 7 | (define dihydrogen-monoxide 8 | (Molecule 9 | (SB 10 | (O "big man oxygen") 11 | (H "one proton")) 12 | (SB 13 | (O "big man oxygen") 14 | (H "another proton")) 15 | )) 16 | 17 | (format #t "Look ma! See what I made! This: ~A\n" dihydrogen-monoxide) 18 | 19 | (define radioactive (Carbon14Node "wood")) 20 | 21 | (define decay-products (cog-execute! radioactive)) 22 | 23 | (format #t "The C14 decay products are:\n~A\n" decay-products) 24 | 25 | ; The end! 26 | ; That's all folks! 27 | -------------------------------------------------------------------------------- /examples/type-system/demo-types/ChemTypes.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * ChemTypes.cc 3 | * 4 | * Boilerplate for a C++ shared library holding custom Atom Types. 5 | * 6 | * The "chem_types.definitions" and "chem_types.inheritance" files 7 | * are autogenerated; they are created in the build directory when 8 | * they are created. The full path name is needed, so that they can 9 | * be found in that directory. These are used by the "atom_types.cc" 10 | * file to create the required C++ shared library entries. 11 | */ 12 | 13 | #include "examples/type-system/demo-types/chem_types.definitions" 14 | 15 | #define INHERITANCE_FILE "examples/type-system/demo-types/chem_types.inheritance" 16 | #define INITNAME chem_types_init 17 | 18 | #include 19 | -------------------------------------------------------------------------------- /examples/type-system/demo-types/chempydemo.pyx: -------------------------------------------------------------------------------- 1 | #!python 2 | #cython: language_level=3 3 | # 4 | # chempydemo.pyx 5 | # 6 | # Example cython file showing how to define a python module 7 | # containing the custom Atom Types. The cython compiler will 8 | # convert this into the C++ file `chempydemo.cpp` which is 9 | # then compiled into a shared object. The shared object can 10 | # be loaded and used as a python module. See the `apps` directory 11 | # for an example of using this. 12 | 13 | from opencog.atomspace import get_refreshed_types 14 | from opencog.utilities import add_node, add_link 15 | 16 | # The chem_types_init() function is defined in the ChemTypes.cc file. 17 | # Calling it causes the shared library defining the type constructors 18 | # to be loaded. 19 | cdef extern : 20 | void chem_types_init() 21 | 22 | chem_types_init() 23 | types = get_refreshed_types() 24 | 25 | # This file is located in the build directory; it is generated by 26 | # the CMake scripts. 27 | include "examples/type-system/demo-types/chem_types.pyx" 28 | -------------------------------------------------------------------------------- /examples/type-system/demo-types/demo-types.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; OpenCog example module exposing new Atom Types. 3 | ; 4 | ; The code below is all "boilerplate" -- keep the general form, and 5 | ; adjust the various names and paths to suit your needs. The various 6 | ; names and paths here *must* match those in the CMakefile. 7 | ; 8 | (define-module (opencog demo-types)) 9 | 10 | (use-modules (opencog)) 11 | (use-modules (opencog chemodemo-config)) 12 | 13 | ; Load the C library that calls the classserver to load the types. 14 | ; The library is `libchem-demo-types` and the library constructor 15 | ; is `chem_types_init`. 16 | (load-extension 17 | (string-append opencog-ext-path-chemodemo "libchem-demo-types") 18 | "chem_types_init") 19 | 20 | ; The path below is the path of the installed types file. 21 | ; Typically, it will be 22 | ; /usr/local/share/guile/site/3.0/opencog/demo-types/chem_types.scm 23 | (include-from-path "opencog/demo-types/chem_types.scm") 24 | -------------------------------------------------------------------------------- /lib/atomspace.pc.in: -------------------------------------------------------------------------------- 1 | 2 | atomspace.pc: 3 | prefix=@CMAKE_INSTALL_PREFIX@ 4 | exec_prefix=${prefix} 5 | includedir=${prefix}/include 6 | libdir=${exec_prefix}/lib/opencog 7 | 8 | Name: AtomSpace 9 | Description: The AtomSpace Hypergraph Database 10 | Version: @SEMANTIC_VERSION@ 11 | Cflags: -I${includedir} 12 | Libs: -L${libdir} -latomspace 13 | -------------------------------------------------------------------------------- /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 | 16 | # Guile/scheme API bindings and utilities 17 | IF (HAVE_GUILE) 18 | ADD_SUBDIRECTORY (guile) 19 | ADD_SUBDIRECTORY (scm) 20 | ENDIF (HAVE_GUILE) 21 | 22 | # Python3 API bindings. 23 | IF (HAVE_CYTHON) 24 | ADD_SUBDIRECTORY (cython) 25 | ENDIF (HAVE_CYTHON) 26 | 27 | # Haskell bindings. 28 | IF (HAVE_STACK) 29 | ADD_SUBDIRECTORY (haskell) 30 | ENDIF (HAVE_STACK) 31 | 32 | # OCaml bindings. 33 | IF (HAVE_OCAML) 34 | ADD_SUBDIRECTORY (ocaml) 35 | ENDIF (HAVE_OCAML) 36 | 37 | IF (HAVE_GUILE) 38 | WRITE_GUILE_CONFIG(${GUILE_BIN_DIR}/opencog/as-config.scm SCM_CONFIG TRUE) 39 | 40 | WRITE_GUILE_CONFIG(${GUILE_BIN_DIR}/opencog/as-config-installable.scm SCM_CONFIG FALSE) 41 | INSTALL(FILES ${GUILE_BIN_DIR}/opencog/as-config-installable.scm DESTINATION ${GUILE_SITE_DIR}/opencog RENAME as-config.scm) 42 | ENDIF (HAVE_GUILE) 43 | -------------------------------------------------------------------------------- /opencog/atoms/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY (atom_types) 2 | ADD_SUBDIRECTORY (value) 3 | ADD_SUBDIRECTORY (base) 4 | ADD_SUBDIRECTORY (columnvec) 5 | ADD_SUBDIRECTORY (core) 6 | ADD_SUBDIRECTORY (execution) 7 | ADD_SUBDIRECTORY (flow) 8 | ADD_SUBDIRECTORY (foreign) 9 | ADD_SUBDIRECTORY (grounded) 10 | ADD_SUBDIRECTORY (join) 11 | ADD_SUBDIRECTORY (parallel) 12 | ADD_SUBDIRECTORY (pattern) 13 | ADD_SUBDIRECTORY (reduct) 14 | ADD_SUBDIRECTORY (rule) 15 | ADD_SUBDIRECTORY (truthvalue) 16 | -------------------------------------------------------------------------------- /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/columnvec/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 (columnvec 6 | FloatColumn.cc 7 | LinkColumn.cc 8 | SexprColumn.cc 9 | TransposeColumn.cc 10 | ) 11 | 12 | # Without this, parallel make will race and crap up the generated files. 13 | ADD_DEPENDENCIES(columnvec opencog_atom_types) 14 | 15 | TARGET_LINK_LIBRARIES(columnvec 16 | atomcore 17 | atombase 18 | ${COGUTIL_LIBRARY} 19 | ) 20 | 21 | INSTALL (TARGETS columnvec EXPORT AtomSpaceTargets 22 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog" 23 | ) 24 | 25 | INSTALL (FILES 26 | FloatColumn.h 27 | LinkColumn.h 28 | SexprColumn.h 29 | TransposeColumn.h 30 | DESTINATION "include/opencog/atoms/columnvec" 31 | ) 32 | -------------------------------------------------------------------------------- /opencog/atoms/columnvec/README.md: -------------------------------------------------------------------------------- 1 | Conversion to columns 2 | --------------------- 3 | GPU's are inherently SIMD machines, and want to get their data either 4 | as long lists of uniform rows, or as long columns -- e.g. Apache Arrow 5 | The intended use of the classes here is to facilitate the feeding of 6 | sparse vector data into Apache Arrow. 7 | 8 | To be more precise: any given pattern search over the AtomSpace will 9 | resuls in a long vector of matching results. Attached to each item in 10 | this vector will be some data, often floating point data. Thus, a goal 11 | is to perform the search, convert the search results to s-expressions 12 | (which are to be used as a UUID for an Atom), forming one column, and 13 | then grab some numeric data out of each result, forming a second 14 | floating-point vector column. 15 | -------------------------------------------------------------------------------- /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 | ) 11 | 12 | # Without this, parallel make will race and crap up the generated files. 13 | ADD_DEPENDENCIES(execution opencog_atom_types) 14 | 15 | TARGET_LINK_LIBRARIES(execution 16 | parallel 17 | clearbox 18 | atomflow 19 | atomcore 20 | atombase 21 | ) 22 | 23 | INSTALL (TARGETS execution 24 | EXPORT AtomSpaceTargets 25 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog") 26 | 27 | INSTALL (FILES 28 | EvaluationLink.h 29 | ExecutionOutputLink.h 30 | Force.h 31 | GroundedProcedureNode.h 32 | Instantiator.h 33 | DESTINATION "include/opencog/atoms/execution" 34 | ) 35 | -------------------------------------------------------------------------------- /opencog/atoms/execution/Force.h: -------------------------------------------------------------------------------- 1 | /* 2 | * opencog/atoms/execution/Force.h 3 | * 4 | * Copyright (C) 2013,2015,2016 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_EXECUTION_FORCE_H 24 | #define _OPENCOG_EXECUTION_FORCE_H 25 | 26 | #include 27 | 28 | namespace opencog 29 | { 30 | /** \addtogroup grp_atomspace 31 | * @{ 32 | */ 33 | 34 | // Handy-dandy utility function 35 | Handle force_execute(AtomSpace*, const Handle&, bool silent=false); 36 | 37 | /** @}*/ 38 | } 39 | 40 | #endif // _OPENCOG_EXECUTION_FORCE_H 41 | -------------------------------------------------------------------------------- /opencog/atoms/foreign/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 (foreign 6 | # DatalogAST.cc 7 | ForeignAST.cc 8 | SexprAST.cc 9 | ) 10 | 11 | # Without this, parallel make will race and crap up the generated files. 12 | ADD_DEPENDENCIES(foreign opencog_atom_types) 13 | 14 | TARGET_LINK_LIBRARIES(foreign 15 | #datalog 16 | atombase 17 | ${COGUTIL_LIBRARY} 18 | ) 19 | 20 | INSTALL (TARGETS foreign EXPORT AtomSpaceTargets 21 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog" 22 | ) 23 | 24 | INSTALL (FILES 25 | DatalogAST.h 26 | ForeignAST.h 27 | SexprAST.h 28 | DESTINATION "include/opencog/atoms/foreign" 29 | ) 30 | -------------------------------------------------------------------------------- /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 | GroundedPredicateNode.cc 7 | GroundedSchemaNode.cc 8 | LibraryManager.cc 9 | LibraryRunner.cc 10 | ) 11 | 12 | IF (HAVE_GUILE) 13 | TARGET_SOURCES(grounded PRIVATE DLScheme.cc) 14 | TARGET_SOURCES(grounded PRIVATE SCMRunner.cc) 15 | ENDIF (HAVE_GUILE) 16 | 17 | IF (HAVE_CYTHON) 18 | INCLUDE_DIRECTORIES(${Python3_INCLUDE_DIRS}) 19 | TARGET_SOURCES(grounded PRIVATE DLPython.cc) 20 | TARGET_SOURCES(grounded PRIVATE PythonRunner.cc) 21 | ENDIF (HAVE_CYTHON) 22 | 23 | # Without this, parallel make will race and crap up the generated files. 24 | ADD_DEPENDENCIES(grounded opencog_atom_types) 25 | 26 | TARGET_LINK_LIBRARIES(grounded 27 | atombase 28 | ) 29 | 30 | INSTALL (TARGETS grounded 31 | EXPORT AtomSpaceTargets 32 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog") 33 | 34 | INSTALL (FILES 35 | GroundedPredicateNode.h 36 | GroundedSchemaNode.h 37 | LibraryManager.h 38 | DESTINATION "include/opencog/atoms/grounded" 39 | ) 40 | -------------------------------------------------------------------------------- /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/join/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 (join 6 | JoinLink.cc 7 | ) 8 | 9 | # Without this, parallel make will race and crap up the generated files. 10 | ADD_DEPENDENCIES(join opencog_atom_types) 11 | 12 | TARGET_LINK_LIBRARIES(join 13 | atomcore 14 | atombase 15 | ${COGUTIL_LIBRARY} 16 | ) 17 | 18 | INSTALL (TARGETS join EXPORT AtomSpaceTargets 19 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog" 20 | ) 21 | 22 | INSTALL (FILES 23 | JoinLink.h 24 | DESTINATION "include/opencog/atoms/join" 25 | ) 26 | -------------------------------------------------------------------------------- /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 | PureExecLink.cc 9 | ThreadJoinLink.cc 10 | ) 11 | 12 | # Without this, parallel make will race and crap up the generated files. 13 | ADD_DEPENDENCIES(parallel opencog_atom_types) 14 | 15 | TARGET_LINK_LIBRARIES(parallel 16 | atomcore 17 | atombase 18 | ) 19 | 20 | INSTALL (TARGETS parallel 21 | EXPORT AtomSpaceTargets 22 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog") 23 | 24 | INSTALL (FILES 25 | ExecuteThreadedLink.h 26 | ParallelLink.h 27 | PureExecLink.h 28 | ThreadJoinLink.h 29 | DESTINATION "include/opencog/atoms/parallel" 30 | ) 31 | -------------------------------------------------------------------------------- /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 | rule 27 | atomcore 28 | atombase 29 | ${COGUTIL_LIBRARY} 30 | ) 31 | 32 | INSTALL (TARGETS pattern EXPORT AtomSpaceTargets 33 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog" 34 | ) 35 | 36 | INSTALL (FILES 37 | BindLink.h 38 | DualLink.h 39 | GetLink.h 40 | MeetLink.h 41 | PatternLink.h 42 | Pattern.h 43 | PatternTerm.h 44 | PatternUtils.h 45 | QueryLink.h 46 | SatisfactionLink.h 47 | DESTINATION "include/opencog/atoms/pattern" 48 | ) 49 | -------------------------------------------------------------------------------- /opencog/atoms/reduct/AccumulateLink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * opencog/atoms/reduct/AccumulateLink.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_ACCUMULATE_LINK_H 10 | #define _OPENCOG_ACCUMULATE_LINK_H 11 | 12 | #include 13 | 14 | namespace opencog 15 | { 16 | /** \addtogroup grp_atomspace 17 | * @{ 18 | */ 19 | 20 | /** 21 | * The AccumulateLink implements a sum over a numeric series. 22 | * (Accumulate (Number a b c)) is just a+b+c. 23 | */ 24 | class AccumulateLink : public NumericFunctionLink 25 | { 26 | protected: 27 | void init(void); 28 | 29 | public: 30 | AccumulateLink(const Handle&); 31 | AccumulateLink(const HandleSeq&&, Type=ACCUMULATE_LINK); 32 | 33 | AccumulateLink(const AccumulateLink&) = delete; 34 | AccumulateLink& operator=(const AccumulateLink&) = delete; 35 | 36 | virtual ValuePtr execute(AtomSpace*, bool); 37 | 38 | static Handle factory(const Handle&); 39 | }; 40 | 41 | LINK_PTR_DECL(AccumulateLink) 42 | #define createAccumulateLink CREATE_DECL(AccumulateLink) 43 | 44 | /** @}*/ 45 | } 46 | 47 | #endif // _OPENCOG_ACCUMULATE_LINK_H 48 | -------------------------------------------------------------------------------- /opencog/atoms/reduct/BoolOpLink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * opencog/atoms/reduct/BoolOpLink.h 3 | * 4 | * Copyright (C) 2015,2018,2022 Linas Vepstas 5 | * All Rights Reserved 6 | * SPDX-License-Identifier: AGPL-3.0-or-later 7 | */ 8 | 9 | #ifndef _OPENCOG_BOOL_OP_LINK_H 10 | #define _OPENCOG_BOOL_OP_LINK_H 11 | 12 | #include 13 | 14 | namespace opencog 15 | { 16 | /** \addtogroup grp_atomspace 17 | * @{ 18 | */ 19 | 20 | /** 21 | * The BoolOpLink implements the logical operators on vectors of bools. 22 | * OrderedLink version. 23 | */ 24 | class BoolOpLink : public Link 25 | { 26 | protected: 27 | void init(void); 28 | 29 | public: 30 | BoolOpLink(const HandleSeq&&, Type); 31 | 32 | BoolOpLink(const BoolOpLink&) = delete; 33 | BoolOpLink& operator=(const BoolOpLink&) = delete; 34 | 35 | virtual bool is_executable() const { return true; } 36 | virtual ValuePtr execute(AtomSpace*, bool); 37 | 38 | static Handle factory(const Handle&); 39 | }; 40 | 41 | LINK_PTR_DECL(BoolOpLink) 42 | #define createBoolOpLink CREATE_DECL(BoolOpLink) 43 | 44 | /** @}*/ 45 | } 46 | 47 | #endif // _OPENCOG_BOOL_OP_LINK_H 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 | BoolOpLink.cc 9 | DecimateLink.cc 10 | DivideLink.cc 11 | ElementOfLink.cc 12 | FoldLink.cc 13 | ImpulseLink.cc 14 | MaxLink.cc 15 | MinLink.cc 16 | MinusLink.cc 17 | NumericFunctionLink.cc 18 | PlusLink.cc 19 | TimesLink.cc 20 | ) 21 | 22 | # Without this, parallel make will race and crap up the generated files. 23 | ADD_DEPENDENCIES(clearbox opencog_atom_types) 24 | 25 | TARGET_LINK_LIBRARIES(clearbox 26 | atom_types 27 | atomcore 28 | atombase 29 | value 30 | ${COGUTIL_LIBRARY} 31 | ) 32 | 33 | INSTALL (TARGETS clearbox EXPORT AtomSpaceTargets 34 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog" 35 | ) 36 | 37 | INSTALL (FILES 38 | AccumulateLink.h 39 | ArithmeticLink.h 40 | BoolOpLink.h 41 | DecimateLink.h 42 | DivideLink.h 43 | ElementOfLink.h 44 | FoldLink.h 45 | ImpulseLink.h 46 | MaxLink.h 47 | MinLink.h 48 | MinusLink.h 49 | NumericFunctionLink.h 50 | PlusLink.h 51 | TimesLink.h 52 | DESTINATION "include/opencog/atoms/reduct" 53 | ) 54 | -------------------------------------------------------------------------------- /opencog/atoms/reduct/DivideLink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * opencog/atoms/reduct/DivideLink.h 3 | * 4 | * Copyright (C) 2015,2018 Linas Vepstas 5 | * All Rights Reserved 6 | * SPDX-License-Identifier: AGPL-3.0-or-later 7 | */ 8 | 9 | #ifndef _OPENCOG_DIVIDE_LINK_H 10 | #define _OPENCOG_DIVIDE_LINK_H 11 | 12 | #include 13 | 14 | namespace opencog 15 | { 16 | /** \addtogroup grp_atomspace 17 | * @{ 18 | */ 19 | 20 | /** 21 | * The DivideLink implements the arithmetic operation of "divide". 22 | */ 23 | class DivideLink : public TimesLink 24 | { 25 | protected: 26 | void init(void); 27 | 28 | ValuePtr kons(AtomSpace*, bool, const ValuePtr&, const ValuePtr&) const; 29 | public: 30 | DivideLink(const Handle& a, const Handle& b); 31 | DivideLink(const HandleSeq&&, Type=DIVIDE_LINK); 32 | 33 | DivideLink(const DivideLink&) = delete; 34 | DivideLink& operator=(const DivideLink&) = delete; 35 | 36 | static Handle factory(const Handle&); 37 | }; 38 | 39 | LINK_PTR_DECL(DivideLink) 40 | #define createDivideLink CREATE_DECL(DivideLink) 41 | 42 | /** @}*/ 43 | } 44 | 45 | #endif // _OPENCOG_DIVIDE_LINK_H 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 NumericFunctionLink 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 | LINK_PTR_DECL(MaxLink) 41 | #define createMaxLink CREATE_DECL(MaxLink) 42 | 43 | /** @}*/ 44 | } 45 | 46 | #endif // _OPENCOG_MAX_LINK_H 47 | -------------------------------------------------------------------------------- /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 NumericFunctionLink 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 | LINK_PTR_DECL(MinLink) 41 | #define createMinLink CREATE_DECL(MinLink) 42 | 43 | /** @}*/ 44 | } 45 | 46 | #endif // _OPENCOG_MIN_LINK_H 47 | -------------------------------------------------------------------------------- /opencog/atoms/reduct/MinusLink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * opencog/atoms/reduct/MinusLink.h 3 | * 4 | * Copyright (C) 2015, 2018 Linas Vepstas 5 | * All Rights Reserved 6 | * SPDX-License-Identifier: AGPL-3.0-or-later 7 | */ 8 | 9 | #ifndef _OPENCOG_MINUS_LINK_H 10 | #define _OPENCOG_MINUS_LINK_H 11 | 12 | #include 13 | 14 | namespace opencog 15 | { 16 | /** \addtogroup grp_atomspace 17 | * @{ 18 | */ 19 | 20 | /** 21 | * The MinusLink implements the arithmetic operation of "minus" 22 | */ 23 | class MinusLink : public PlusLink 24 | { 25 | protected: 26 | void init(void); 27 | 28 | ValuePtr kons(AtomSpace*, bool, const ValuePtr&, const ValuePtr&) const; 29 | public: 30 | MinusLink(const Handle& a, const Handle& b); 31 | MinusLink(const HandleSeq&&, Type=MINUS_LINK); 32 | 33 | MinusLink(const MinusLink&) = delete; 34 | MinusLink& operator=(const MinusLink&) = delete; 35 | 36 | static Handle factory(const Handle&); 37 | }; 38 | 39 | LINK_PTR_DECL(MinusLink) 40 | #define createMinusLink CREATE_DECL(MinusLink) 41 | 42 | /** @}*/ 43 | } 44 | 45 | #endif // _OPENCOG_MINUS_LINK_H 46 | -------------------------------------------------------------------------------- /opencog/atoms/reduct/PlusLink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * opencog/atoms/reduct/PlusLink.h 3 | * 4 | * Copyright (C) 2015, 2018 Linas Vepstas 5 | * All Rights Reserved 6 | * SPDX-License-Identifier: AGPL-3.0-or-later 7 | */ 8 | 9 | #ifndef _OPENCOG_PLUS_LINK_H 10 | #define _OPENCOG_PLUS_LINK_H 11 | 12 | #include 13 | 14 | namespace opencog 15 | { 16 | /** \addtogroup grp_atomspace 17 | * @{ 18 | */ 19 | 20 | /** 21 | * The PlusLink implements the arithmetic operation of "plus" 22 | */ 23 | class PlusLink : public ArithmeticLink 24 | { 25 | protected: 26 | static Handle zero; 27 | virtual ValuePtr kons(AtomSpace*, bool, 28 | const ValuePtr&, const ValuePtr&) const; 29 | 30 | void init(void); 31 | 32 | public: 33 | PlusLink(const Handle& a, const Handle& b); 34 | PlusLink(const HandleSeq&&, Type=PLUS_LINK); 35 | 36 | PlusLink(const PlusLink&) = delete; 37 | PlusLink& operator=(const PlusLink&) = delete; 38 | 39 | static Handle factory(const Handle&); 40 | }; 41 | 42 | LINK_PTR_DECL(PlusLink) 43 | #define createPlusLink CREATE_DECL(PlusLink) 44 | 45 | /** @}*/ 46 | } 47 | 48 | #endif // _OPENCOG_PLUS_LINK_H 49 | -------------------------------------------------------------------------------- /opencog/atoms/reduct/TimesLink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * opencog/atoms/reduct/TimesLink.h 3 | * 4 | * Copyright (C) 2015, 2018 Linas Vepstas 5 | * All Rights Reserved 6 | * SPDX-License-Identifier: AGPL-3.0-or-later 7 | */ 8 | 9 | #ifndef _OPENCOG_TIMES_LINK_H 10 | #define _OPENCOG_TIMES_LINK_H 11 | 12 | #include 13 | 14 | namespace opencog 15 | { 16 | /** \addtogroup grp_atomspace 17 | * @{ 18 | */ 19 | 20 | /** 21 | * The TimesLink implements the arithmetic operation of "times". 22 | */ 23 | class TimesLink : public ArithmeticLink 24 | { 25 | protected: 26 | static Handle one; 27 | ValuePtr kons(AtomSpace*, bool, 28 | const ValuePtr&, const ValuePtr&) const; 29 | 30 | void init(void); 31 | 32 | public: 33 | TimesLink(const HandleSeq&&, Type=TIMES_LINK); 34 | TimesLink(const Handle& a, const Handle& b); 35 | 36 | TimesLink(const TimesLink&) = delete; 37 | TimesLink& operator=(const TimesLink&) = delete; 38 | 39 | static Handle factory(const Handle&); 40 | }; 41 | 42 | LINK_PTR_DECL(TimesLink) 43 | #define createTimesLink CREATE_DECL(TimesLink) 44 | 45 | /** @}*/ 46 | } 47 | 48 | #endif // _OPENCOG_TIMES_LINK_H 49 | -------------------------------------------------------------------------------- /opencog/atoms/rule/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 (rule 6 | ConclusionOfLink.cc 7 | PremiseOfLink.cc 8 | RuleLink.cc 9 | VardeclOfLink.cc 10 | ) 11 | 12 | # Without this, parallel make will race and crap up the generated files. 13 | ADD_DEPENDENCIES(rule opencog_atom_types) 14 | 15 | TARGET_LINK_LIBRARIES(rule 16 | atomcore 17 | atombase 18 | ${COGUTIL_LIBRARY} 19 | ) 20 | 21 | INSTALL (TARGETS rule EXPORT AtomSpaceTargets 22 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog" 23 | ) 24 | 25 | INSTALL (FILES 26 | ConclusionOfLink.h 27 | PremiseOfLink.h 28 | RuleLink.h 29 | VardeclOfLink.h 30 | DESTINATION "include/opencog/atoms/rule" 31 | ) 32 | -------------------------------------------------------------------------------- /opencog/atoms/truthvalue/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_LIBRARY (truthvalue 2 | CountTruthValue.cc 3 | FormulaTruthValue.cc 4 | SimpleTruthValue.cc 5 | TruthValue.cc 6 | ) 7 | 8 | # Without this, parallel make will race and crap up the generated files. 9 | ADD_DEPENDENCIES(truthvalue opencog_atom_types) 10 | 11 | TARGET_LINK_LIBRARIES(truthvalue 12 | value 13 | ${COGUTIL_LIBRARY} 14 | ) 15 | 16 | INSTALL (TARGETS truthvalue EXPORT AtomSpaceTargets 17 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog" 18 | ) 19 | 20 | INSTALL (FILES 21 | CountTruthValue.h 22 | FormulaTruthValue.h 23 | SimpleTruthValue.h 24 | TruthValue.h 25 | DESTINATION "include/opencog/atoms/truthvalue" 26 | ) 27 | -------------------------------------------------------------------------------- /opencog/atoms/value/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) 2 | 3 | ADD_LIBRARY (value 4 | Value.cc 5 | BoolValue.cc 6 | ContainerValue.cc 7 | FloatValue.cc 8 | FormulaStream.cc 9 | FutureStream.cc 10 | LinkStreamValue.cc 11 | LinkValue.cc 12 | QueueValue.cc 13 | RandomStream.cc 14 | StreamValue.cc 15 | StringValue.cc 16 | UnisetValue.cc 17 | ValueFactory.cc 18 | VoidValue.cc 19 | ) 20 | 21 | # Without this, parallel make will race and crap up the generated files. 22 | ADD_DEPENDENCIES(value opencog_atom_types) 23 | 24 | TARGET_LINK_LIBRARIES(value 25 | atom_types 26 | ${COGUTIL_LIBRARY} 27 | ) 28 | 29 | INSTALL (TARGETS value EXPORT AtomSpaceTargets 30 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog" 31 | ) 32 | 33 | INSTALL (FILES 34 | BoolValue.h 35 | ContainerValue.h 36 | FloatValue.h 37 | FormulaStream.h 38 | FutureStream.h 39 | LinkStreamValue.h 40 | LinkValue.h 41 | QueueValue.h 42 | RandomStream.h 43 | StreamValue.h 44 | StringValue.h 45 | UnisetValue.h 46 | Value.h 47 | ValueFactory.h 48 | VoidValue.h 49 | DESTINATION "include/opencog/atoms/value" 50 | ) 51 | -------------------------------------------------------------------------------- /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 (0 == args.size() or 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/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 5 29 | 30 | #ifndef GIT_COMMIT_HASH 31 | #define ATOMSPACE_VERSION_STRING "5.0.5" 32 | #else 33 | #define ATOMSPACE_VERSION_STRING "5.0.5-" GIT_COMMIT_HASH 34 | #endif 35 | 36 | 37 | #endif // _OPENCOG_ATOMSPACE_VER_H 38 | -------------------------------------------------------------------------------- /opencog/cython/PyIncludeWrapper.h: -------------------------------------------------------------------------------- 1 | 2 | #ifdef HAVE_CYTHON 3 | 4 | // XXX Cython currently conflicts with standard C library definitions. 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 | * Python3, any version 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 python3-nose 13 | ``` 14 | or with `easy_install`: 15 | ``` 16 | sudo easy_install cython nose3 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 | AtomSpacePtr get_context_atomspace() { 8 | if (current.empty()) 9 | return nullptr; 10 | return current.back(); 11 | } 12 | 13 | void push_context_atomspace(AtomSpacePtr asp) { 14 | current.push_back(asp); 15 | } 16 | 17 | void push_context_atomspace(ValuePtr vasp) { 18 | AtomSpacePtr asp = AtomSpaceCast(vasp); 19 | current.push_back(asp); 20 | } 21 | 22 | AtomSpacePtr pop_context_atomspace() { 23 | AtomSpacePtr result = get_context_atomspace(); 24 | current.pop_back(); 25 | return result; 26 | } 27 | 28 | void clear_context(){ 29 | current.clear(); 30 | } 31 | 32 | } // namespace 33 | -------------------------------------------------------------------------------- /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 | AtomSpacePtr get_context_atomspace(); 11 | void push_context_atomspace(AtomSpacePtr atomspace); 12 | void push_context_atomspace(ValuePtr atomspace); 13 | AtomSpacePtr pop_context_atomspace(); 14 | void clear_context(); 15 | } 16 | 17 | #endif // _OPENCOG_CONTEXT_H 18 | -------------------------------------------------------------------------------- /opencog/cython/opencog/ExecuteStub.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "ExecuteStub.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/ExecuteStub.h: -------------------------------------------------------------------------------- 1 | /* 2 | * opencog/cython/opencog/ExecuteStub.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_EXECUTESTUB_H 24 | #define _OPENCOG_EXECUTESTUB_H 25 | 26 | 27 | namespace opencog { 28 | 29 | ValuePtr do_execute(AtomSpace*, Handle); 30 | 31 | } // namespace opencog 32 | 33 | 34 | #endif // _OPENCOG_EXECUTESTUB_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 | ValuePtr eval_scheme_as(const std::string &); 16 | 17 | } // namespace opencog 18 | 19 | #endif // _OPENCOG_PYTHON_SCHEME_H 20 | 21 | -------------------------------------------------------------------------------- /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 "bool_value.pyx" 12 | include "float_value.pyx" 13 | include "string_value.pyx" 14 | include "atom.pyx" 15 | include "nameserver.pyx" 16 | include "link_value.pyx" 17 | -------------------------------------------------------------------------------- /opencog/cython/opencog/bool_value.pyx: -------------------------------------------------------------------------------- 1 | 2 | def createBoolValue(arg): 3 | cdef shared_ptr[cBoolValue] c_ptr 4 | if (isinstance(arg, list)): 5 | c_ptr.reset(new cBoolValue(BoolValue.list_of_bool_to_vector(arg))) 6 | else: 7 | c_ptr.reset(new cBoolValue(arg)) 8 | return BoolValue(PtrHolder.create(c_ptr)) 9 | 10 | cdef class BoolValue(Value): 11 | 12 | def to_list(self): 13 | return BoolValue.vector_of_bool_to_list( 14 | &((self.get_c_value_ptr().get()).value())) 15 | 16 | @staticmethod 17 | cdef vector[bool] list_of_bool_to_vector(list python_list): 18 | cdef vector[bool] cpp_vector 19 | cdef bool 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_bool_to_list(const vector[bool]* 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | def execute_atom(AtomSpace atomspace, Atom atom): 11 | return atomspace.execute(atom) 12 | 13 | def evaluate_atom(AtomSpace atomspace, Atom atom): 14 | if atom is None: 15 | raise ValueError("evaluate_atom atom is: None") 16 | cdef tv_ptr result_tv_ptr = c_evaluate_atom( 17 | atomspace.atomspace, deref(atom.handle) 18 | ) 19 | cdef cTruthValue* result_tv = result_tv_ptr.get() 20 | cdef strength_t strength = deref(result_tv).get_mean() 21 | cdef confidence_t confidence = deref(result_tv).get_confidence() 22 | return TruthValue(strength, confidence) 23 | -------------------------------------------------------------------------------- /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/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/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/ocaml/atomese.ml: -------------------------------------------------------------------------------- 1 | 2 | (** The top-level glue to automate everything for users. 3 | * Basically, this avoids having the user to type boring 4 | * stuff at the interpreter prompt. 5 | *) 6 | 7 | (* Make sure we get to the install directory *) 8 | #directory "/usr/local/lib/opencog/ocaml/" ;; 9 | 10 | (* Do a hard load. I was unable to get 11 | * #use "topfind";; #require "atomese" ;; 12 | * to work correctly *) 13 | 14 | #load "atomspace.cma" ;; 15 | open Atomspace ;; 16 | open Atoms ;; 17 | open Storage ;; 18 | 19 | (* There is a different printer for each interface! 20 | * That's because each interface declares a distinct 21 | * type atom = Atom ;; perhaps this is a bug? Perhaps 22 | * type atom should appear in it's own mli file? 23 | * I couldn't make it work, so we have this instead. 24 | *) 25 | #install_printer Atoms.atom_prettyprt ;; 26 | #install_printer Storage.atom_prettyprt ;; 27 | -------------------------------------------------------------------------------- /opencog/ocaml/atomspace.ml: -------------------------------------------------------------------------------- 1 | 2 | (* Every interface has to use this same typedef. Even then, 3 | * there are weird breakages. I can't figure it out. 4 | *) 5 | type atom = Atom ;; (* | Node of string | Link of atom list;; *) 6 | 7 | (** Signature declarations *) 8 | external cog_print_atomspace : unit -> unit = "print_atomspace" ;; 9 | 10 | (** 11 | * Oh dear. Bug. Each new interface has to duplicate these methods! 12 | * This is quite ugly & impractical. I do not yet understand how to 13 | * fix this. 14 | *) 15 | external cog_execute : atom -> atom = "execute" ;; 16 | external cog_execute : Atoms.atom -> Atoms.atom = "execute" ;; 17 | 18 | external atom_sexpr : atom -> string = "atom_to_sexpr" ;; 19 | external atom_sexpr : Atoms.atom -> string = "atom_to_sexpr" ;; 20 | 21 | external atom_printer : atom -> string = "atom_string_printer" ;; 22 | external atom_printer : Atoms.atom -> string = "atom_string_printer" ;; 23 | -------------------------------------------------------------------------------- /opencog/query/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # Build the query-engine library 3 | ADD_LIBRARY(query-engine 4 | ContinuationMixin.cc 5 | InitiateSearchMixin.cc 6 | NextSearchMixin.cc 7 | PatternMatchEngine.cc 8 | Recognizer.cc 9 | RewriteMixin.cc 10 | Satisfier.cc 11 | SatisfyMixin.cc 12 | TermMatchMixin.cc 13 | ) 14 | 15 | # Optionally enable debug logging for the pattern matcher. 16 | # TARGET_COMPILE_OPTIONS(query-engine PRIVATE -DQDEBUG=1) 17 | 18 | # Optionally enable multi-threaded pattern matcher. Experimental. 19 | # TARGET_COMPILE_OPTIONS(query-engine PRIVATE -DUSE_THREADED_PATTERN_ENGINE=1) 20 | 21 | ADD_DEPENDENCIES(query-engine 22 | opencog_atom_types 23 | ) 24 | 25 | TARGET_LINK_LIBRARIES(query-engine 26 | execution 27 | ) 28 | 29 | INSTALL (TARGETS query-engine 30 | EXPORT AtomSpaceTargets 31 | DESTINATION "lib${LIB_DIR_SUFFIX}/opencog") 32 | 33 | INSTALL (FILES 34 | ContinuationMixin.h 35 | Implicator.h 36 | InitiateSearchMixin.h 37 | PatternMatchCallback.h 38 | PatternMatchEngine.h 39 | RewriteMixin.h 40 | Satisfier.h 41 | SatisfyMixin.h 42 | TermMatchMixin.h 43 | DESTINATION "include/opencog/query" 44 | ) 45 | -------------------------------------------------------------------------------- /opencog/scm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # No CMakeLists.txt in dir: 2 | #ADD_SUBDIRECTORY (wires) 3 | 4 | # About the COMPILE flag in the macros below: 5 | # It causes the guild compiler to run and build a compiled version of 6 | # the module. It works. But guile does not actually use this compiled 7 | # version, because, after install, it finds that the sources have a 8 | # newer timestamp. I don't feel like wrestling with this right now, 9 | # so ... for just right now, disable this. It should be fixed and 10 | # re-enabled. 11 | 12 | ADD_GUILE_MODULE (FILES 13 | opencog.scm 14 | opencog/base/apply.scm 15 | opencog/base/atom-cache.scm 16 | opencog/base/atom-docs.scm 17 | opencog/base/core-docs.scm 18 | opencog/base/debug-trace.scm 19 | opencog/base/file-utils.scm 20 | opencog/base/repl-shell.scm 21 | opencog/base/tv.scm 22 | opencog/base/types.scm 23 | opencog/base/utilities.scm 24 | DEPENDS opencog_atom_types smob 25 | # COMPILE 26 | ) 27 | 28 | # Each of the files below are distinct modules. They need to be 29 | # compiled separately. 30 | 31 | ADD_GUILE_MODULE (FILES 32 | opencog/extension.scm 33 | # COMPILE 34 | ) 35 | 36 | ADD_GUILE_MODULE (FILES 37 | opencog/test-runner.scm 38 | # COMPILE 39 | ) 40 | -------------------------------------------------------------------------------- /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 a handful 7 | of extensions. Most extensions live with the C++ code that implements 8 | them, and not here. 9 | -------------------------------------------------------------------------------- /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/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/sheaf/attic/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 | # COMPILE 11 | ) 12 | -------------------------------------------------------------------------------- /opencog/sheaf/attic/README.md: -------------------------------------------------------------------------------- 1 | MST & MPG Parsers 2 | ----------------- 3 | The code here provided an implementation of the "sheaf" ideas presented 4 | in the directory below. This code is now unused and is obsolete. The 5 | [opencog/learn](https://github.com/opencog/learn) project provides a 6 | superior implementation of the general ideas. 7 | 8 | The code here still works; it is still usable. It is hard to imagine 9 | any circumstances that would bring it back to life, but perhaps there 10 | might be some, as more abstract domains are tackled. It's placed here, 11 | rather than buried in git history, as a memorium. 12 | -------------------------------------------------------------------------------- /opencog/sheaf/attic/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/sheaf/attic/bench-mst/boruvka-101.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opencog/atomspace/4cfaa16cb765adc613eb28ae766397fee90b14e9/opencog/sheaf/attic/bench-mst/boruvka-101.png -------------------------------------------------------------------------------- /opencog/sheaf/attic/bench-mst/boruvka-701K.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opencog/atomspace/4cfaa16cb765adc613eb28ae766397fee90b14e9/opencog/sheaf/attic/bench-mst/boruvka-701K.png -------------------------------------------------------------------------------- /opencog/sheaf/attic/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 | (use-modules (ice-9 format)) 9 | 10 | ; The files are loaded in pipeline order. 11 | ; In general, the later files depend on definitions contained 12 | ; in the earlier files. 13 | (include-from-path "opencog/sheaf/sections.scm") 14 | (include-from-path "opencog/sheaf/vo-graph.scm") 15 | (include-from-path "opencog/sheaf/linear-parser.scm") 16 | (include-from-path "opencog/sheaf/mst-parser.scm") 17 | (include-from-path "opencog/sheaf/mpg-parser.scm") 18 | (include-from-path "opencog/sheaf/make-section.scm") 19 | -------------------------------------------------------------------------------- /opencog/sheaf/attic/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ADD_GUILE_TEST(GraphExtents extents.scm) 3 | ADD_GUILE_TEST(LinearParser linear-parser.scm) 4 | -------------------------------------------------------------------------------- /opencog/sheaf/docs/ccg.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opencog/atomspace/4cfaa16cb765adc613eb28ae766397fee90b14e9/opencog/sheaf/docs/ccg.pdf -------------------------------------------------------------------------------- /opencog/sheaf/docs/coli-2024/README.md: -------------------------------------------------------------------------------- 1 | 2 | Submission to Computational Linguistics 3 | --------------------------------------- 4 | https://cljournal.org/ 5 | https://cljournal.org/submissions.html 6 | https://direct.mit.edu/coli 7 | 8 | My ORCID: https://orcid.org/0000-0002-2557-740X 9 | 10 | CoLi LaTeX HOWTO 11 | ----------------- 12 | * Style guideline: https://cljournal.org/style.html 13 | * Copy `clv3.cls` to `/usr/share/texmf/tex/latex/` 14 | * Run `sudo texhash` 15 | * Copy `clv3.layout` to `~/.lyx/layouts/` 16 | * Run reconfigure and restart LyX 17 | * Select clv3 in Document->Settings->Document Class 18 | 19 | 20 | Errors: 21 | ------- 22 | * `Use of \x doesn't match its definition.` 23 | Document Settings -> PDF Properties -> disable Hyperref support 24 | -------------------------------------------------------------------------------- /opencog/sheaf/docs/coli-2024/clv3.layout: -------------------------------------------------------------------------------- 1 | #% Do not delete the line below; configure depends on this 2 | # \DeclareLaTeXClass[clv3]{CoLi_Article} 3 | 4 | # Read the definitions from article.layout (yes, really) 5 | Input stdclass.inc 6 | -------------------------------------------------------------------------------- /opencog/sheaf/docs/connectors-and-variables.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opencog/atomspace/4cfaa16cb765adc613eb28ae766397fee90b14e9/opencog/sheaf/docs/connectors-and-variables.pdf -------------------------------------------------------------------------------- /opencog/sheaf/docs/factorization.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opencog/atomspace/4cfaa16cb765adc613eb28ae766397fee90b14e9/opencog/sheaf/docs/factorization.pdf -------------------------------------------------------------------------------- /opencog/sheaf/docs/feature.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opencog/atomspace/4cfaa16cb765adc613eb28ae766397fee90b14e9/opencog/sheaf/docs/feature.pdf -------------------------------------------------------------------------------- /opencog/sheaf/docs/graphics/corn-field.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opencog/atomspace/4cfaa16cb765adc613eb28ae766397fee90b14e9/opencog/sheaf/docs/graphics/corn-field.jpg -------------------------------------------------------------------------------- /opencog/sheaf/docs/graphics/cornstalk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opencog/atomspace/4cfaa16cb765adc613eb28ae766397fee90b14e9/opencog/sheaf/docs/graphics/cornstalk.jpg -------------------------------------------------------------------------------- /opencog/sheaf/docs/graphics/directed-graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opencog/atomspace/4cfaa16cb765adc613eb28ae766397fee90b14e9/opencog/sheaf/docs/graphics/directed-graph.png -------------------------------------------------------------------------------- /opencog/sheaf/docs/graphics/link-grammar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opencog/atomspace/4cfaa16cb765adc613eb28ae766397fee90b14e9/opencog/sheaf/docs/graphics/link-grammar.png -------------------------------------------------------------------------------- /opencog/sheaf/docs/graphics/sheaf-of-papers.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opencog/atomspace/4cfaa16cb765adc613eb28ae766397fee90b14e9/opencog/sheaf/docs/graphics/sheaf-of-papers.jpg -------------------------------------------------------------------------------- /opencog/sheaf/docs/graphics/sheaf-of-stalks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opencog/atomspace/4cfaa16cb765adc613eb28ae766397fee90b14e9/opencog/sheaf/docs/graphics/sheaf-of-stalks.jpg -------------------------------------------------------------------------------- /opencog/sheaf/docs/graphics/stack-jigsaw-puzzle-pieces.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opencog/atomspace/4cfaa16cb765adc613eb28ae766397fee90b14e9/opencog/sheaf/docs/graphics/stack-jigsaw-puzzle-pieces.jpg -------------------------------------------------------------------------------- /opencog/sheaf/docs/learning.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opencog/atomspace/4cfaa16cb765adc613eb28ae766397fee90b14e9/opencog/sheaf/docs/learning.pdf -------------------------------------------------------------------------------- /opencog/sheaf/docs/mereology.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opencog/atomspace/4cfaa16cb765adc613eb28ae766397fee90b14e9/opencog/sheaf/docs/mereology.pdf -------------------------------------------------------------------------------- /opencog/sheaf/docs/ram-cpu.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opencog/atomspace/4cfaa16cb765adc613eb28ae766397fee90b14e9/opencog/sheaf/docs/ram-cpu.pdf -------------------------------------------------------------------------------- /opencog/sheaf/docs/sheaf-axioms.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opencog/atomspace/4cfaa16cb765adc613eb28ae766397fee90b14e9/opencog/sheaf/docs/sheaf-axioms.pdf -------------------------------------------------------------------------------- /opencog/sheaf/docs/sheaves.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opencog/atomspace/4cfaa16cb765adc613eb28ae766397fee90b14e9/opencog/sheaf/docs/sheaves.pdf -------------------------------------------------------------------------------- /opencog/sheaf/docs/tensors.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opencog/atomspace/4cfaa16cb765adc613eb28ae766397fee90b14e9/opencog/sheaf/docs/tensors.pdf -------------------------------------------------------------------------------- /opencog/sheaf/docs/tods-2024/acmart.layout: -------------------------------------------------------------------------------- 1 | #% Do not delete the line below; configure depends on this 2 | # \DeclareLaTeXClass[acmart]{ACM_Article} 3 | 4 | # Read the definitions from article.layout (yes, really) 5 | Input stdclass.inc 6 | -------------------------------------------------------------------------------- /opencog/sheaf/docs/tods-2024/ram-cpu-tods.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opencog/atomspace/4cfaa16cb765adc613eb28ae766397fee90b14e9/opencog/sheaf/docs/tods-2024/ram-cpu-tods.pdf -------------------------------------------------------------------------------- /scripts/.gdbinit: -------------------------------------------------------------------------------- 1 | # 2 | # guile garbage collection uses these. Ignore them. 3 | # 4 | handle SIGPWR noprint nostop 5 | handle SIGXCPU noprint nostop 6 | -------------------------------------------------------------------------------- /scripts/README.md: -------------------------------------------------------------------------------- 1 | 2 | How to use gdb 3 | -------------- 4 | Copy either `.gbdinit` or `.gdbinit-print-opencog` to `~/.gbdinit` 5 | That is, to your home directory. 6 | 7 | 8 | How to use Valgrind suppressions 9 | -------------------------------- 10 | Using valgrind with opencog can be tricky, because many spurious messages 11 | are created. These can be suppressed with suppression files, like so: 12 | ``` 13 | valgrind --suppressions=../scripts/valgrind.guile.suppressions \ 14 | --suppressions=../scripts/valgrind.python.suppressions \ 15 | --suppressions=../scripts/valgrind.boost.suppressions \ 16 | --suppressions=../scripts/valgrind.logger.suppressions \ 17 | --suppressions=../scripts/valgrind.link-grammar.suppressions \ 18 | 19 | ``` 20 | where `` is probably `opencog/server/cogserver` 21 | 22 | Memory leaks: `valgrind --leak-check=full` 23 | 24 | Memory non-leaks: `valgrind --leak-check=full --show-leak-kinds=all` 25 | 26 | Memory profile: `valgrind --tool=massif` 27 | 28 | CPU profile: `valgrind --tool=callgrind` 29 | 30 | then: `callgrind_annotate callgrind.out.nnnn` 31 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /scripts/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 | -------------------------------------------------------------------------------- /scripts/valgrind.link-grammar.suppressions: -------------------------------------------------------------------------------- 1 | { 2 | 3 | Memcheck:Cond 4 | ... 5 | fun:pp_knowledge_open 6 | ... 7 | } 8 | -------------------------------------------------------------------------------- /scripts/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 | -------------------------------------------------------------------------------- /tests/atoms/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ADD_SUBDIRECTORY (atom_types) 3 | ADD_SUBDIRECTORY (base) 4 | ADD_SUBDIRECTORY (core) 5 | ADD_SUBDIRECTORY (evaluation) 6 | ADD_SUBDIRECTORY (execution) 7 | ADD_SUBDIRECTORY (rule) 8 | ADD_SUBDIRECTORY (join) 9 | ADD_SUBDIRECTORY (parallel) 10 | ADD_SUBDIRECTORY (truthvalue) 11 | ADD_SUBDIRECTORY (value) 12 | ADD_SUBDIRECTORY (reduct) 13 | ADD_SUBDIRECTORY (flow) 14 | ADD_SUBDIRECTORY (columnvec) 15 | ADD_SUBDIRECTORY (pattern) 16 | ADD_SUBDIRECTORY (foreign) 17 | 18 | LINK_LIBRARIES( 19 | atombase 20 | atomspace 21 | ) 22 | 23 | ADD_CXXTEST(AlphaConvertUTest) 24 | ADD_CXXTEST(BetaReduceUTest) 25 | 26 | IF (HAVE_GUILE) 27 | LINK_LIBRARIES(smob) 28 | ADD_CXXTEST(HashUTest) 29 | ADD_CXXTEST(RandomUTest) 30 | ENDIF (HAVE_GUILE) 31 | -------------------------------------------------------------------------------- /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_GEN_CXX_ATOMTYPES(test_types.script 15 | test_types.h 16 | test_types.definitions 17 | test_types.inheritance) 18 | 19 | OPENCOG_GEN_SCM_ATOMTYPES(test_types.script test_types.scm) 20 | OPENCOG_GEN_PYTHON_ATOMTYPES(test_types.script test_types.pyx) 21 | 22 | ADD_CUSTOM_TARGET(test_atom_types 23 | DEPENDS test_types.h test_types.scm test_types.pyx) 24 | 25 | # The atom_types.h file is written to the build directory 26 | INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}) 27 | 28 | ADD_LIBRARY (test-types SHARED 29 | test_types.h 30 | TestTypes.cc 31 | ) 32 | 33 | # Without this, parallel make will race and crap up the generated files. 34 | ADD_DEPENDENCIES(test-types test_atom_types) 35 | 36 | TARGET_LINK_LIBRARIES(test-types 37 | ${ATOMSPACE_atomtypes_LIBRARY} 38 | ) 39 | 40 | ADD_CXXTEST(FactoryUTest) 41 | TARGET_LINK_LIBRARIES(FactoryUTest test-types) 42 | -------------------------------------------------------------------------------- /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/columnvec/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # Basic column tests 3 | ADD_GUILE_TEST(FloatColumnTest float-column-test.scm) 4 | ADD_GUILE_TEST(LinkColumnTest link-column-test.scm) 5 | ADD_GUILE_TEST(SexprColumnTest sexpr-column-test.scm) 6 | ADD_GUILE_TEST(TransposeColumnTest transpose-column-test.scm) 7 | -------------------------------------------------------------------------------- /tests/atoms/columnvec/link-column-test.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; link-column-test.scm -- Verify that LinkColumn works. 3 | ; 4 | (use-modules (opencog) (opencog exec)) 5 | (use-modules (opencog test-runner)) 6 | 7 | (opencog-test-runner) 8 | (define tname "link-column-test") 9 | (test-begin tname) 10 | 11 | ; ------------------------------------------------------------ 12 | ; Serialize in list form. 13 | 14 | (define itli (list 15 | (Item "a") 16 | (Item "b") 17 | (Item "c") 18 | (Item "d"))) 19 | (define itcol (LinkColumn (List itli))) 20 | (define itvec (cog-execute! itcol)) 21 | (format #t "Item list vect: ~A\n" itvec) 22 | (test-assert "Item list vect" (equal? itvec (LinkValue itli))) 23 | 24 | ; ------------------------------------------------------------ 25 | ; Serialize numbers, in direct form. 26 | 27 | (define dircol (LinkColumn itli)) 28 | (define dirvec (cog-execute! dircol)) 29 | (format #t "Direct item vect: ~A\n" dirvec) 30 | (test-assert "Direct vect" (equal? dirvec (LinkValue itli))) 31 | 32 | ; ------------------------------------------------------------ 33 | (test-end tname) 34 | (opencog-test-end) 35 | -------------------------------------------------------------------------------- /tests/atoms/core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | LINK_LIBRARIES( 3 | atomcore 4 | atomspace 5 | ) 6 | 7 | ADD_CXXTEST(CheckersUTest) 8 | ADD_CXXTEST(FindUtilsUTest) 9 | ADD_CXXTEST(NumberNodeUTest) 10 | ADD_CXXTEST(TypeIntersectionUTest) 11 | ADD_CXXTEST(TypeUtilsUTest) 12 | ADD_CXXTEST(VariablesUTest) 13 | 14 | ADD_CXXTEST(DefineLinkUTest) 15 | ADD_CXXTEST(DeleteLinkUTest) 16 | ADD_CXXTEST(StateLinkUTest) 17 | 18 | IF(HAVE_GUILE) 19 | LINK_LIBRARIES(execution smob) 20 | 21 | ADD_CXXTEST(FreeLinkUTest) 22 | ADD_CXXTEST(CondLinkUTest) 23 | ADD_CXXTEST(ScopeLinkUTest) 24 | ADD_CXXTEST(RewriteLinkUTest) 25 | ADD_CXXTEST(PutLinkUTest) 26 | ADD_CXXTEST(QuotationUTest) 27 | 28 | ADD_GUILE_TEST(GrantTest grant-test.scm) 29 | ADD_GUILE_TEST(PutRecursiveTest put-recursive-test.scm) 30 | ADD_GUILE_TEST(PresentTest present-test.scm) 31 | ENDIF(HAVE_GUILE) 32 | -------------------------------------------------------------------------------- /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/core/put-recursive-test.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; put-recursive-test.scm -- test for crash on recursive PutLink 3 | ; 4 | (use-modules (opencog) (opencog exec)) 5 | (use-modules (opencog test-runner)) 6 | 7 | (opencog-test-runner) 8 | (define tname "put-recursive-test") 9 | (test-begin tname) 10 | 11 | ; Define a recursive Schema 12 | (Define 13 | (DefinedSchema "is-a relation") 14 | (Lambda 15 | (VariableList (Variable "this") (Variable "that")) 16 | (SequentialOr 17 | (Inheritance (Variable "this") (Variable "that")) 18 | (SequentialAnd 19 | (Inheritance (Variable "this") (Variable "middle")) 20 | (Put (DefinedSchema "is-a relation") 21 | (List (Variable "middle") (Variable "that"))))))) 22 | 23 | ; Attempt to use it 24 | (define is-it 25 | (Put 26 | (DefinedSchema "is-a relation") 27 | (List (Concept "human") (Concept "chordate")))) 28 | 29 | (cog-execute! is-it) 30 | 31 | ; If we reached this part without crashing, we're good. 32 | (test-assert "no crash" #t) 33 | 34 | (test-end tname) 35 | 36 | (opencog-test-end) 37 | -------------------------------------------------------------------------------- /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 | IF (HAVE_GUILE) 2 | LINK_LIBRARIES(execution smob atomspace) 3 | 4 | ADD_CXXTEST(DefinedSchemaUTest) 5 | ENDIF (HAVE_GUILE) 6 | -------------------------------------------------------------------------------- /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 | IF (HAVE_GUILE) 11 | ADD_GUILE_TEST(CollectionOfTest collection-of-test.scm) 12 | ADD_GUILE_TEST(IncomingOfTest incoming-of-test.scm) 13 | 14 | LINK_LIBRARIES(execution smob) 15 | ADD_CXXTEST(FormulaUTest) 16 | ADD_CXXTEST(SetTVUTest) 17 | ADD_CXXTEST(SetValueUTest) 18 | ADD_CXXTEST(DynamicUTest) 19 | ADD_CXXTEST(FilterLinkUTest) 20 | 21 | ADD_GUILE_TEST(IncrementValueTest increment-value-test.scm) 22 | ADD_GUILE_TEST(FilterGlobTest filter-glob-test.scm) 23 | ADD_GUILE_TEST(FilterValueTest filter-value-test.scm) 24 | ADD_GUILE_TEST(FilterFloatTest filter-float-test.scm) 25 | ADD_GUILE_TEST(FilterRuleTest filter-rule-test.scm) 26 | ADD_GUILE_TEST(StringOfTest string-of-test.scm) 27 | ADD_GUILE_TEST(FilterStringsTest filter-strings-test.scm) 28 | ADD_GUILE_TEST(ConcatenateTest concatenate-test.scm) 29 | ADD_GUILE_TEST(SplitTest split-test.scm) 30 | ENDIF (HAVE_GUILE) 31 | -------------------------------------------------------------------------------- /tests/atoms/flow/incoming-of-test.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; incoming-of-test.scm -- Verify that IncomingOfLink works. 3 | ; 4 | 5 | (use-modules (opencog) (opencog exec)) 6 | (use-modules (opencog test-runner)) 7 | 8 | (opencog-test-runner) 9 | (define tname "incoming-of-test") 10 | (test-begin tname) 11 | 12 | (define ea (Evaluation (Predicate "foo") (Concept "bar"))) 13 | (define eb (Evaluation (Predicate "foo") (Concept "zub"))) 14 | (define lf (List (Predicate "foo") (Concept "boing"))) 15 | 16 | (define inc-foo (IncomingOf (Predicate "foo"))) 17 | 18 | ; We expect all four above. 19 | (test-assert "all-inc" 20 | (equal? (cog-arity (cog-execute! inc-foo)) 4)) 21 | 22 | (define inc-evl (IncomingOf (Predicate "foo") (Type 'EvaluationLink))) 23 | 24 | ; We expect only two. 25 | (test-assert "inc-evl" 26 | (equal? (cog-arity (cog-execute! inc-evl)) 2)) 27 | 28 | ; Play a game -- convert it to a set. 29 | (define super-set (cog-execute! (CollectionOf inc-foo))) 30 | (test-assert "inc-super" 31 | (equal? super-set (Set ea eb lf inc-foo inc-evl))) 32 | 33 | (test-end tname) 34 | 35 | (opencog-test-end) 36 | -------------------------------------------------------------------------------- /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 (FloatValueOf foo key))) 21 | 22 | ; Try out some math 23 | (define square (SetValue bar kee 24 | (Times (FloatValueOf foo key) (FloatValueOf 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 | (FloatValueOf foo key))) 38 | ; 39 | ; -------- THE END ----------- 40 | -------------------------------------------------------------------------------- /tests/atoms/foreign/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # Tests 3 | 4 | ADD_GUILE_TEST(SexprQueryTest sexpr-query-test.scm) 5 | 6 | 7 | # Comment out until someone cares. 8 | # This works great, except that it depends on getting linked to 9 | # code that is provided by the storage module, which is done only 10 | # after the atomspace is built. So I think we need to move 11 | # things to there .... including the crazy atom types ... which 12 | # probably belong in their own crazy ast diretory. 13 | # 14 | # ADD_GUILE_TEST(DatalogBasicTest datalog-basic-test.scm) 15 | -------------------------------------------------------------------------------- /tests/atoms/grounded/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | LINK_LIBRARIES(grounded execution smob atomspace) 2 | 3 | ADD_CXXTEST(GroundedSchemaLocalUTest) 4 | -------------------------------------------------------------------------------- /tests/atoms/join/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | IF (HAVE_GUILE) 3 | LINK_LIBRARIES(join smob execution atomspace) 4 | ADD_CXXTEST(JoinLinkUTest) 5 | ADD_CXXTEST(BlueJoinUTest) 6 | ADD_CXXTEST(TrueJoinUTest) 7 | ADD_CXXTEST(CompoundJoinUTest) 8 | ADD_CXXTEST(GPNJoinUTest) 9 | ENDIF (HAVE_GUILE) 10 | -------------------------------------------------------------------------------- /tests/atoms/join/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/join/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/join/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/join/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/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/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 | 9 | ADD_GUILE_TEST(BoolLibraryTest bool-library-test.scm) 10 | ADD_GUILE_TEST(MathLibraryTest math-library-test.scm) 11 | ADD_GUILE_TEST(ElementOfTest element-of-test.scm) 12 | ENDIF(HAVE_GUILE) 13 | -------------------------------------------------------------------------------- /tests/atoms/rule/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # Tests 3 | 4 | ADD_GUILE_TEST(RuleTest rule-test.scm) 5 | -------------------------------------------------------------------------------- /tests/atoms/truthvalue/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | LINK_LIBRARIES( 3 | atomspace 4 | value 5 | ) 6 | 7 | ADD_CXXTEST(SimpleTruthValueUTest) 8 | 9 | IF (HAVE_GUILE) 10 | LINK_LIBRARIES(smob) 11 | ADD_CXXTEST(TVUTest) 12 | ENDIF (HAVE_GUILE) 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 | atomspace 3 | value 4 | atombase 5 | ) 6 | 7 | # Tests in order of increasing functional complexity/dependency 8 | ADD_CXXTEST(ValueUTest) 9 | ADD_CXXTEST(VoidValueUTest) 10 | 11 | IF (HAVE_GUILE) 12 | ADD_CXXTEST(StreamUTest) 13 | TARGET_LINK_LIBRARIES(StreamUTest smob) 14 | ENDIF (HAVE_GUILE) 15 | 16 | -------------------------------------------------------------------------------- /tests/atomspace/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | LINK_LIBRARIES( 3 | atombase 4 | atomspace 5 | ) 6 | 7 | ADD_CXXTEST(HashMixUTest) 8 | ADD_CXXTEST(AtomTableUTest) 9 | ADD_CXXTEST(AtomSpaceUTest) 10 | ADD_CXXTEST(UseCountUTest) 11 | ADD_CXXTEST(MultiSpaceUTest) 12 | ADD_CXXTEST(EpisodicSpaceUTest) 13 | ADD_CXXTEST(COWSpaceUTest) 14 | ADD_CXXTEST(RemoveUTest) 15 | ADD_CXXTEST(ReAddUTest) 16 | 17 | IF (HAVE_GUILE) 18 | ADD_GUILE_TEST(CoverBasic cover-basic-test.scm) 19 | ADD_GUILE_TEST(DeepSpace deep-space-test.scm) 20 | ADD_GUILE_TEST(FrameIncoming frame-incoming-test.scm) 21 | ADD_GUILE_TEST(CoverSpace cover-space-test.scm) 22 | ADD_GUILE_TEST(CoverIncoming cover-incoming-test.scm) 23 | ADD_GUILE_TEST(CoverDelete cover-delete-test.scm) 24 | ADD_GUILE_TEST(CoverBasicDelete cover-basic-delete-test.scm) 25 | ADD_GUILE_TEST(RecoverTest recover-test.scm) 26 | ADD_GUILE_TEST(RecoverStackTest recover-stack-test.scm) 27 | ENDIF (HAVE_GUILE) 28 | -------------------------------------------------------------------------------- /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 | ``` 15 | export PYTHONPATH=${PROJECT_BINARY_DIR}/opencog/cython 16 | ``` 17 | or, if installed: 18 | ``` 19 | export PYTHONPATH=/usr/local/lib/python3.9/dist-packages/opencog:${PYTHON} 20 | ``` 21 | 22 | Some test functions are in `tests/cython/bindlink/test_functions.py` 23 | Thus, you'll also need: 24 | ``` 25 | export PYTHONPATH=tests/cython/bindlink PROJECT_SOURCE_DIR=. 26 | ``` 27 | 28 | Then from atomspace root source dir execute: 29 | 30 | ``` 31 | nosetests3 -vs ./tests/cython/ 32 | nosetests3 -vs ./tests/cython/atomspace/ 33 | nosetests3 -vs ./tests/cython/bindlink/ 34 | nosetests3 -vs ./tests/cython/guile/ 35 | nosetests3 -vs ./tests/cython/utilities/ 36 | ``` 37 | -------------------------------------------------------------------------------- /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/opencog/atomspace/4cfaa16cb765adc613eb28ae766397fee90b14e9/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/query/ChemTypes.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * ChemTypes.cc 3 | * 4 | * Atom Types needed unit testing. 5 | * 6 | * Copyright (c) 2009, 2014 Linas Vepstas 7 | */ 8 | 9 | #include "tests/query/chem_types.definitions" 10 | 11 | #define INHERITANCE_FILE "tests/query/chem_types.inheritance" 12 | #define INITNAME chem_types_init 13 | 14 | #include 15 | -------------------------------------------------------------------------------- /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/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 | 37 | ; This is the test to be done: 38 | ; (equal? (cog-execute! bigger-dummy) stfu) 39 | -------------------------------------------------------------------------------- /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 | ; Expected result of above 29 | (define expected 30 | (List (Concept "node1") (Concept "name1"))) 31 | -------------------------------------------------------------------------------- /tests/query/buggy-selfgnd.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; In this case, the instantiator tried to instantiate and add a new 3 | ; BindLink atom to Atomspace, throwing exception. More details here: 4 | ; https://github.com/opencog/atomspace/issues/210 5 | 6 | (EvaluationLink 7 | (ConceptNode "arkle") 8 | (ConceptNode "barkle") 9 | (ConceptNode "curry")) 10 | 11 | (EvaluationLink 12 | (ConceptNode "glib") 13 | (ConceptNode "blab")) 14 | 15 | ; This is a kind-of-ish poorly-formed expression. 16 | ; When the EqualLink is evaluated, its arguments are executed first. 17 | ; If $lnk was bound to the BindLink (which it could be, because there 18 | ; is no type restriction on $lnk), this causes the BindLink to be run 19 | ; again .. and again .. infinite regress. 20 | ; 21 | ; To avoid infinite regress, use IdenticalLink instead of EqualLink. 22 | (define bnd 23 | (BindLink 24 | (AndLink 25 | (VariableNode "$lnk") 26 | (EvaluationLink 27 | (VariableNode "$a") 28 | (VariableNode "$b")) 29 | ; (EqualLink 30 | (IdenticalLink 31 | (VariableNode "$lnk") 32 | (EvaluationLink 33 | (VariableNode "$a") 34 | (VariableNode "$b") 35 | ) 36 | )) 37 | (VariableNode "$lnk") 38 | ) 39 | ) 40 | -------------------------------------------------------------------------------- /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 implicit 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 explicitly. 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-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-eager: 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-monotonicity.scm: -------------------------------------------------------------------------------- 1 | ;; Query 2 | (define query 3 | (let* ( 4 | ;; Constants 5 | (R (Predicate "R")) 6 | (A (Execution (Schema "A"))) 7 | ;; Variables 8 | (P (Variable "$P")) 9 | (Q (Variable "$Q")) 10 | ;; Clauses 11 | (P→Q (Quote 12 | (Implication 13 | (Unquote P) 14 | (Unquote Q)))) 15 | (Q∧A (And Q A)) 16 | (Q∧A→R (Implication 17 | Q∧A 18 | R))) 19 | ;; Query 20 | (Get 21 | (VariableSet P Q) 22 | (Present P→Q Q∧A→R)))) 23 | 24 | ;; KB 25 | 26 | ;; Culprit 27 | (Implication 28 | (And 29 | (Predicate "Qbis") ; Culprit 30 | (Execution (Schema "A")) 31 | ) 32 | (Predicate "R")) 33 | 34 | ;; Premises 35 | (Implication 36 | (Predicate "P") 37 | (Predicate "Q")) 38 | (Implication 39 | (And 40 | (Predicate "Q") 41 | (Execution (Schema "A")) 42 | ) 43 | (Predicate "R")) 44 | -------------------------------------------------------------------------------- /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") ; Variable decl 10 | (VariableNode "$x") ; body 11 | (ListLink 12 | (ConceptNode "And the answer is ...") 13 | (QuoteLink (VariableNode "$x"))))) 14 | 15 | ; (cog-execute! crasher) 16 | 17 | ;; This is an infinite loop, because there are no type restrictions on 18 | ;; the variable, and the instantiator can get confused. 19 | (define infloop 20 | (BindLink 21 | (VariableNode "$x") ; Variable decl 22 | (VariableNode "$x") ; body 23 | (ListLink 24 | (ConceptNode "And the answer is ...") 25 | (VariableNode "$x")))) 26 | 27 | ; (cog-execute! infloop) 28 | -------------------------------------------------------------------------------- /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, because 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 | (RuleLink 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-nest.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; quote-nest.scm 3 | ; 4 | ; Test nested quoted variables. The pattern will search for 5 | ; several quoted variables. 6 | ; 7 | 8 | (EvaluationLink 9 | (PredicateNode "similar") 10 | (ListLink 11 | (ConceptNode "apple") 12 | (ConceptNode "banana") 13 | ) 14 | ) 15 | 16 | (EvaluationLink 17 | (PredicateNode "similar") 18 | (ListLink 19 | (ConceptNode "orange") 20 | (ConceptNode "apple") 21 | ) 22 | ) 23 | 24 | (EvaluationLink 25 | (PredicateNode "similar") 26 | (ListLink 27 | (ConceptNode "apple") 28 | (ConceptNode "grape") 29 | ) 30 | ) 31 | 32 | (EvaluationLink 33 | (PredicateNode "similar") 34 | (ListLink 35 | (VariableNode "$var-a") 36 | (ConceptNode "banana") 37 | ) 38 | ) 39 | 40 | (EvaluationLink 41 | (PredicateNode "all-var") 42 | (ListLink 43 | (VariableNode "$var-a") 44 | (VariableNode "$var-b") 45 | ) 46 | ) 47 | 48 | (EvaluationLink 49 | (PredicateNode "similar") 50 | (ListLink 51 | (VariableNode "$var-a") 52 | (VariableNode "$wrong-var-b") 53 | ) 54 | ) 55 | 56 | (define bindy 57 | (BindLink 58 | (VariableNode "$var-a") 59 | (EvaluationLink 60 | (VariableNode "$var-a") 61 | (QuoteLink (ListLink 62 | (VariableNode "$var-a") 63 | (VariableNode "$var-b") 64 | )) 65 | ) 66 | (VariableNode "$var-a") 67 | ) 68 | ) 69 | 70 | -------------------------------------------------------------------------------- /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 | (Rule 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 | (Rule 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-start-test.scm: -------------------------------------------------------------------------------- 1 | ; 2 | ; quote-start-test.scm -- Verify a Quote appearing at the top level works. 3 | ; 4 | 5 | (use-modules (opencog) (opencog exec)) 6 | (use-modules (opencog test-runner)) 7 | 8 | (opencog-test-runner) 9 | (define tname "quote-start-test") 10 | (test-begin tname) 11 | 12 | (Evaluation (Predicate "foo") (Concept "bar")) 13 | 14 | (define qry 15 | (Get (TypedVariable (Variable "X") (Type 'Concept)) 16 | (Quote (Evaluation 17 | (Unquote (Predicate "foo")) 18 | (Unquote (Variable "X")))))) 19 | 20 | (test-assert "query for both" 21 | (equal? (cog-execute! qry) (Set (Concept "bar")))) 22 | 23 | (test-end tname) 24 | 25 | (opencog-test-end) 26 | -------------------------------------------------------------------------------- /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-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 | 18 | (opencog-test-end) 19 | -------------------------------------------------------------------------------- /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 | 18 | (opencog-test-end) 19 | -------------------------------------------------------------------------------- /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\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") ; None is no longer returned! 22 | (define expected-in-cxxtest "") 23 | 24 | (format #t "python-eval returned this: >>~A<<\n" rc) 25 | 26 | (test-assert "Oh no! python-eval is borken!" 27 | (or (string=? rc expected) 28 | (string=? rc expected-in-cxxtest))) 29 | 30 | (test-end t) 31 | 32 | (opencog-test-end) 33 | --------------------------------------------------------------------------------