# Implicitly bound variables

**URL:** <https://swi-prolog.discourse.group/t/implicitly-bound-variables/8509>\
**Category:** Help!\
**Tags:** janus\
**Created:** [October 3, 2024, 9:59am UTC](https://swi-prolog.discourse.group/t/implicitly-bound-variables/8509 "2024-10-03T09:59:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pampelmuse76](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/pampelmuse76/32/6795_2.png) [@pampelmuse76](https://swi-prolog.discourse.group/u/pampelmuse76)\
**Post date:** [October 3, 2024, 9:59am UTC](https://swi-prolog.discourse.group/t/implicitly-bound-variables/8509/1 "2024-10-03T09:59:57Z")

</div>

I’m using: SWI-Prolog version 9.2.7

I want the code to:

```prolog
#!/usr/bin/python

import janus_swi as janus

query = janus.query("aggregate_all(count, between(0,3,X), C)")
print(query.next())

```

But what I’m getting is:  
janus\_swi.janus.PrologError: Arguments are not sufficiently instantiated

I have changed this to

```prolog
#!/usr/bin/python

import janus_swi as janus

query = janus.query("aggregate_all(count, between(0,3,_), C)")
print(query.next())

```

than it is working.  
But there are cases where I need more than one variable.  
eg. [Autumn Challenge 2024: Numbrix Puzzle - #6 by j4n\_bur53](https://swi-prolog.discourse.group/t/autumn-challenge-2024-numbrix-puzzle/8508/6)

```prolog
time(aggregate_all(count, (between(0,3,X), between(0,3,Y), path((X,Y), [(X,Y)])), C)).

```

Thank you

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [October 3, 2024, 11:53am UTC](https://swi-prolog.discourse.group/t/implicitly-bound-variables/8509/3 "2024-10-03T11:53:02Z")

</div>

> [@pampelmuse76](#):
>
> But there are cases where I need more than one variable.  
> eg.

All variables that do not start with an ‘\_’ are made part of the result and thus must be convertible to Python after the query succeeds. So, the solution is to use variables like `_MyVar` for variables that need to be in the query (because they appear multiple times) but you do not want in the answer.

I’d typically keep my query short and use a rule (clause) to do the complicated things. Now only the arguments are visible.

---

<div class="post-metadata">

**Author:** ![pampelmuse76](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/pampelmuse76/32/6795_2.png) [@pampelmuse76](https://swi-prolog.discourse.group/u/pampelmuse76)\
**Post date:** [October 3, 2024, 12:38pm UTC](https://swi-prolog.discourse.group/t/implicitly-bound-variables/8509/4 "2024-10-03T12:38:38Z")

</div>

Thank you very much this is working:

```prolog
aggregate_all(count, (between(0,3,_X), between(0,3,_Y), path((_X,_Y), [(_X,_Y)])), C)

```
