# TLA+-like unchanged

**URL:** https://alloytools.discourse.group/t/tla-like-unchanged/358
**Category:** Uncategorized
**Created:** [June 14, 2023, 1:32pm UTC](https://alloytools.discourse.group/t/tla-like-unchanged/358 "2023-06-14T13:32:28Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![alexshirley](https://yyz2.discourse-cdn.com/free1/user_avatar/alloytools.discourse.group/alexshirley/32/173_2.png) [@alexshirley](https://alloytools.discourse.group/u/alexshirley)
#### Post date: [June 14, 2023, 1:32pm UTC](https://alloytools.discourse.group/t/tla-like-unchanged/358/1 "2023-06-14T13:32:28Z")

</div>

Hey All,

I’m trying to create a TLA±like unchanged function, but there are two problems that I seem to be having.

```plaintext
module unchanged[x]

pred unchanged[s:x]{
	s' = s
}

```

The first, is that I can’t seem to pass relationships as signatures like  
`open unchanged[file->directory]` or `open unchanged[file.directory]`

**How do pass a relationship as a parameter in a generic function?**

**Second, is there a way to have variadic functions?** For instance, if I wanted to have a stutter action for several variables, I need to do the following:

```plaintext
    unchanged[set1]
    unchanged[set2]
    unchanged[set3]

```

but what I really want is:

```plaintext
    unchanged[set1,set2,set3]

```

---

<div class="post-metadata">

### Author: ![grayswandyr](https://yyz2.discourse-cdn.com/free1/user_avatar/alloytools.discourse.group/grayswandyr/32/17_2.png) [@grayswandyr](https://alloytools.discourse.group/u/grayswandyr)
#### Post date: [June 14, 2023, 1:45pm UTC](https://alloytools.discourse.group/t/tla-like-unchanged/358/2 "2023-06-14T13:45:06Z")

</div>

> [@alexshirley](#):
>
> **How do pass a relationship as a parameter in a generic function?**

I suppose you meant generic _module_. It’s not possible. In my view, a richer module system for Alloy could have some benefits.

BUT, you can nonetheless create a unique `unchanged` **macro** (macros are a little documented extension [introduced in Alloy 4](https://alloytools.org/quickguide/macro.html)):

```auto
let unchanged[r] { ( r = (r)' ) }

```

Macros are brittle and prime should apply to all of `r` so I add parentheses.

> [@alexshirley](#):
>
> **Second, is there a way to have variadic functions?**

No. I also asked for them recently but I think it’s not in sight 🙂  
The [meta capabilities](https://alloytools.org/quickguide/meta.html) of Alloy are however going to be fixed and extended in the forthcoming version, which could help write _some_ predicates applying to various objects at once. Proper variadic predicates or macros will not be available however.

---

<div class="post-metadata">

### Author: ![alexshirley](https://yyz2.discourse-cdn.com/free1/user_avatar/alloytools.discourse.group/alexshirley/32/173_2.png) [@alexshirley](https://alloytools.discourse.group/u/alexshirley)
#### Post date: [June 15, 2023, 1:19pm UTC](https://alloytools.discourse.group/t/tla-like-unchanged/358/3 "2023-06-15T13:19:10Z")

</div>

You weren’t kidding when you said they were brittle. I ended up using the definition in multiple modules, and immediately ran into issues. I then tried to then have a single definition, like in the lowest module (thing `file` like in a `file, directory, os` hierarchy.

```plaintext
Name cannot be resolved; possible incorrect
function/predicate call; perhaps you used ( ) when you
should have used []

```

---

<div class="post-metadata">

### Author: ![grayswandyr](https://yyz2.discourse-cdn.com/free1/user_avatar/alloytools.discourse.group/grayswandyr/32/17_2.png) [@grayswandyr](https://alloytools.discourse.group/u/grayswandyr)
#### Post date: [June 15, 2023, 1:25pm UTC](https://alloytools.discourse.group/t/tla-like-unchanged/358/4 "2023-06-15T13:25:40Z")

</div>

Strange. Can you give a minimal working example?

---

<div class="post-metadata">

### Author: ![alexshirley](https://yyz2.discourse-cdn.com/free1/user_avatar/alloytools.discourse.group/alexshirley/32/173_2.png) [@alexshirley](https://alloytools.discourse.group/u/alexshirley)
#### Post date: [June 15, 2023, 1:47pm UTC](https://alloytools.discourse.group/t/tla-like-unchanged/358/5 "2023-06-15T13:47:52Z")

</div>

I found the problem, while trying to make a minimal example.

First, I was calling a field by it’s type and not by its name.  
Second, I was calling an object that was unreachable in the module (in a higher layer)
