OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-atomspace / tests / query / meet-link-embed.scm

66 lines · scm ref:
;
; Data and tests for MeetLink with embedded variable decls.
;

(use-modules (opencog))

(Inheritance (Concept "Ben") (Concept "human"))
(Inheritance (Concept "Linas") (Concept "human"))
(Inheritance (Concept "Sparky") (Concept "dog"))

(define is-human
	(Meet
		(Present (Inheritance (Variable "$H") (Concept "human")))))

; (cog-execute! is-human)

;; Two variables, including type restrictions
(define is-something
	(Meet
		(And
			(Present (Inheritance (Variable "$A") (Variable "$B")))
			(TypedVariable (Variable "$A") (Type 'Concept))
		)))

; (cog-execute! is-something)

;; An empty TypeChoice means the variable can have no type at all.
;; This is the same as the bottom type. It's also the same as
;;   (TypeChoice (Type 'Notype))
;; See https://github.com/opencog/atomspace/issues/2490
(define is-nothing
	(Meet
		(And
			(Present (Inheritance (Variable "$H") (Concept "human")))
			(TypedVariable (Variable "$H") (TypeChoice))
		)))

; (cog-execute! is-nothing)

;; --------------------------------------------------------------

(define g-take-contain
	(Meet
		(And
			(Present
				(Edge
					(Predicate "take")
					(List (Variable "$X") (Concept "treatment-1"))))
			(TypedVariable (Variable "$X") (Type "Concept"))
			(Present
				(Edge
					(Predicate "contain")
					(List (Concept "treatment-1") (Variable "$Z"))))
			(TypedVariable (Variable "$Z") (Type "Concept"))
		)))

; (cog-execute! g-take-contain)

(Edge
	(Predicate "take")
	(List (Concept "John") (Concept "treatment-1")))

(Edge
	(Predicate "contain")
	(List (Concept "treatment-1") (Concept "compound-A")))