Skip to content

Bug in issue code: Transitive isa Inference Fails with BadType Error Due to Restrictive Default Signature #78

@sivaji1012

Description

@sivaji1012

pip show hyperon
Name: hyperon
Version: 0.2.8+ga696c359
Summary: Hyperon API in Python
Home-page: https://github.com/trueagi-io/hyperon-experimental
Author:
Author-email:
License: MIT License
Location: /home/shivaji1012/AGI_Seed_Knowledge/.venv-agi/lib/python3.12/site-packages
Editable project location: /home/shivaji1012/hyperon-experimental/python
Requires:
Required-by:

Description:

When using a transitive inference rule for the isa predicate, a BadType error occurs. This happens because the interpreter appears to use a default, restrictive type signature for isa (-> Entity ...) that conflicts with the logic of the transitive rule, which needs to operate on untyped symbols.

The issue is reproducible in a clean environment (like the MeTTa dev playground) using the minimal example below.


Minimal Reproducible Example:

This self-contained script demonstrates the bug. It defines a minimal ontology with a transitive isa rule and then attempts to infer that a LivingAgent is an Entity.

;; Minimal script to reproduce the 'isa' inference bug.

;; --- Core Ontology ---
(: Type Type)
(: Entity Type)
(: Object Type)
(: Agent Type)
(: LivingAgent Type)
(: Pair Type)
(: TruthValue Type)
(subtype TruthValue Pair)

;; Using the restrictive signature that causes the error.
(: isa (-> Entity Type TruthValue Type))
(: subtype (-> Type Type TruthValue Type))

;; Transitive subtype and isa rules.
(subtype LivingAgent Agent (Pair 1.0 1.0))
(subtype Agent Object (Pair 1.0 1.0))
(subtype Object Entity (Pair 1.0 1.0))

(= (isa $x $B (Pair $s3 $c3))
    (and (isa $x $A (Pair $s1 $c1))
         (subtype $A $B (Pair $s2 $c2))
         (Pair (* $s1 $s2) (* $c1 $c2))))

;; --- Example Fact ---
(isa human-02 LivingAgent (Pair 0.9 0.8))

;; --- The Query That Fails ---
!(isa human-02 Entity (Pair $s $c))

Observed Behavior:

The query fails with a BadType error that originates from inside the transitive rule, indicating a conflict with the isa predicate's signature.

[(Error (isa human-02 $A#101 (Pair $s1#102 $c1#103)) BadType)]

Expected Behavior:

The query should successfully execute the chain of reasoning (human-02 -> LivingAgent -> Agent -> Object -> Entity) and return the calculated truth value. For example:

[(Pair 0.9 0.8)] 

Analysis & The Fix:

The error is resolved by making the isa predicate's signature more general. The inference rule needs to be able to work with an untyped Atom as its subject.

When the following line in the script:
(: isa (-> Entity Type TruthValue Type))

Is changed to:
(: isa (-> Atom Type TruthValue Type))

The query succeeds. This suggests the interpreter's default type checking for isa is too restrictive for the inference rule to function correctly.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions