I can't see quite what causes this, but there's a funky markdown bug apparent in my answer here:

<https://stackoverflow.com/a/10324330/659804>

The two Lisp-y code snippets should be formatted just the same, but the second one is messed up. I went over it a couple of times checking the spacing and couldn't make it right. The same thing seems to happen if I post the text here, so I've added it below.

---

You have to define them both as separate templates. Then you can store either `fact-id` or some other identifier for the "sub-fact" in the main fact, then join the main fact pattern with a "sub-fact" pattern using that value:

```
(defrule blue-eyed-person
    (person (name ?name) (eyes ?eyes))
    ?eyes <- (eyes (color blue))
    =>
    (printout t ?name " has blue eyes." crlf))

```

Or alternatively

```
(defrule blue-eyed-person
    (person (name ?name) (eyes ?eyes))

```

        (eyes (id ?eyes) (color blue))
 =>
 (printout t ?name " has blue eyes." crlf))