# Assert ssu goal with guards

**URL:** <https://swi-prolog.discourse.group/t/assert-ssu-goal-with-guards/9598>\
**Category:** Nice to know\
**Created:** [May 7, 2026, 2:17pm UTC](https://swi-prolog.discourse.group/t/assert-ssu-goal-with-guards/9598 "2026-05-07T14:17:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kwon-young](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/kwon-young/32/4841_2.png) [@kwon-young](https://swi-prolog.discourse.group/u/kwon-young)\
**Post date:** [May 7, 2026, 2:17pm UTC](https://swi-prolog.discourse.group/t/assert-ssu-goal-with-guards/9598/1 "2026-05-07T14:17:30Z")

</div>

Does anybody know how to assert a dynamic Single-Sided Unification (SSU) clause with a guard ?  
Trying to do an assert with an SSU goal with guards results in an exception:

```prolog
?- assertz(((toto, true) => true)).
ERROR: No permission to modify static procedure `(',')/2'
ERROR: Defined at /home/kwon-young/prog/swipl-devel/install/lib/swipl/boot/init.pl:400
ERROR: In:
ERROR: [12] assertz((toto,true=>true))
ERROR: [11] toplevel_call(user:user: ...) at /home/kwon-young/prog/swipl-devel/install/lib/s
wipl/boot/toplevel.pl:1519

```

Trying to expand the SSU goal with a guard results in the exact same expression:

```prolog
?- expand_term(((toto, true) => true), T).
T = (toto, true=>true).

```

---

<div class="post-metadata">

**Author:** ![kwon-young](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/kwon-young/32/4841_2.png) [@kwon-young](https://swi-prolog.discourse.group/u/kwon-young)\
**Post date:** [May 7, 2026, 2:41pm UTC](https://swi-prolog.discourse.group/t/assert-ssu-goal-with-guards/9598/2 "2026-05-07T14:41:44Z")

</div>

Just found out. Turns out the transformation is done in [swipl-devel/boot/init.pl at 5433f58c67578560e2474cbaa2985eda1350b5b7 · SWI-Prolog/swipl-devel · GitHub](https://github.com/SWI-Prolog/swipl-devel/blob/5433f58c67578560e2474cbaa2985eda1350b5b7/boot/init.pl#L4019)

I believe we need to do that transformation ourselves, so I made this little helper predicate:

```prolog
assert_ssu((Head, Guard) => Body) =>
   assertz(?=>(Head, (Guard, !, Body))).
assert_ssu(Head => Body) =>
   assertz(Head => Body).

```

adapt as you wish 🙂
