<commit_before>;; =====================================================================
;; Body
;; |-
;; LambdaLink
;;    V
;;    Body
;;
;; Wrap a Lambda around a closed atom (that is an atom without free
;; variables in it) and assign to the lambda the TV of the body. So
;; basically it create a constant predicate or schema.
;;
;; Note that in practice we actually match only premises already
;; wrapped in a LambdaLink as a workaround the current lack of
;; alpha-equivalence support.
;; ----------------------------------------------------------------------

(define lambda-grounded-construction-vardecl
  (VariableList
     (TypedVariableLink
        (VariableNode "$V")
        (TypeChoice
           (TypeNode "TypedVariableLink")
           (TypeNode "VariableList")
           (TypeNode "VariableNode")))
     (VariableNode "$B")))

(define lambda-grounded-construction-pattern
  (AndLink
     (QuoteLink (LambdaLink
        (UnquoteLink (VariableNode "$V"))
        (UnquoteLink (VariableNode "$B"))))
     (EvaluationLink
        (GroundedPredicateNode "scm: closed?")
        (VariableNode "$B"))))

(define lambda-grounded-construction-rewrite
  (ExecutionOutputLink
     (GroundedSchemaNode "scm: lambda-grounded-construction-formula")
     (ListLink
        (VariableNode "$B")
        (QuoteLink (LambdaLink
           (UnquoteLink (VariableNode "$V"))
           (UnquoteLink (VariableNode "$B")))))))

(define lambda-grounded-construction-rule
  (BindLink
     lambda-grounded-construction-vardecl
     lambda-grounded-construction-pattern
     lambda-grounded-construction-rewrite))

(define (lambda-grounded-construction-formula body lamb)
  (cog-set-tv! lamb (cog-tv body)))

(define (closed? atom)
  (bool->tv (cog-closed? atom)))

;; Name the rule
(define lambda-grounded-construction-rule-name
  (DefinedSchemaNode "lambda-grounded-construction-rule"))
(DefineLink lambda-grounded-construction-rule-name
  lambda-grounded-construction-rule)<commit_msg>Fix lambda-grounded-construction-rule for BC<commit_after>;; =====================================================================
;; Body
;; |-
;; LambdaLink
;;    V
;;    Body
;;
;; Wrap a Lambda around a closed atom (that is an atom without free
;; variables in it) and assign to the lambda the TV of the body. So
;; basically it create a constant predicate or schema.
;;
;; Note that in practice we actually match only premises already
;; wrapped in a LambdaLink as a workaround the current lack of
;; alpha-equivalence support.
;; ----------------------------------------------------------------------

(define lambda-grounded-construction-vardecl
  (VariableList
     (TypedVariableLink
        (VariableNode "$V")
        (TypeChoice
           (TypeNode "TypedVariableLink")
           (TypeNode "VariableList")
           (TypeNode "VariableNode")))
     (VariableNode "$B")))

(define lambda-grounded-construction-pattern
  (AndLink
     (VariableNode "$V")
     (VariableNode "$B")
     (EvaluationLink
        (GroundedPredicateNode "scm: lambda-grounded-construction-precondition")
        (VariableNode "$B"))))

(define lambda-grounded-construction-rewrite
  (ExecutionOutputLink
     (GroundedSchemaNode "scm: lambda-grounded-construction-formula")
     (ListLink
        (VariableNode "$B")
        (QuoteLink (LambdaLink
           (UnquoteLink (VariableNode "$V"))
           (UnquoteLink (VariableNode "$B")))))))

(define lambda-grounded-construction-rule
  (BindLink
     lambda-grounded-construction-vardecl
     lambda-grounded-construction-pattern
     lambda-grounded-construction-rewrite))

(define (lambda-grounded-construction-formula body lamb)
  (cog-set-tv! lamb (cog-tv body)))

(define (lambda-grounded-construction-precondition atom)
  (bool->tv (and (cog-closed? atom) (tv-positive-conf? (cog-tv atom)))))

;; Name the rule
(define lambda-grounded-construction-rule-name
  (DefinedSchemaNode "lambda-grounded-construction-rule"))
(DefineLink lambda-grounded-construction-rule-name
  lambda-grounded-construction-rule)
{'fraction_non_alphanumeric': 0.18035226990821135, 'fraction_numerical': 0.0, 'mean_word_length': 3.2397476340694005, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2887909', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1083, 'n_words': 286}