Representing a nested loop in set notation

554 Views Asked by At

I am trying to represent a set of rules using set notation. Each rule has the following format: $i.l.T^{i}_{l}$

This is a small example showing what I would like to represent using an expression.

If $S = \{i_{1},i_{2}\}$, $L^{i_{1}} = \{ l_{a}, l_{b} \}$ and $L^{i_{2}} = \{ l_{b}, l_{c} \}$;

$ T^{i}_{l}$ = represents the set of target agents selected with $i$ and $l$ as input

Full set of rules: $R = \{ (i_{1}. l_{a}.T^{i_{1}}_{l_{a}}),(i_{1}. l_{b}.T^{i_{1}}_{l_{b}}),(i_{2}. l_{b}.T^{i_{2}}_{l_{b}}),(i_{2}. l_{c}.T^{i_{2}}_{l_{c}}), \}$

Below is the logic for generating the set of rules.

R <- {}
For each i in S:
    L <- get the set of links i can form
    For each l in L(i)
       t <- T(i,l) //Get set of target agents of i under link l
       i.l.T //create this rule
       R.add(i.l.T)

So far I have managed to get this far.

I am not sure if I have got it right. Especially whether I capture different values of $l$ correctly for each $i$

$R =\{ i.l.T{^i}_{l} |(\forall i \in S) ( \forall l \in L^{i})\} $

1

There are 1 best solutions below

0
On

The following structure may or may not be an answer - since I may not understand your specification.

I think your set $R$ of rules has elements that are ordered triples $(i, l, t)$ where $i$ ranges over $S$, $l$ ranges over a set of "links" that depends on the value of $i$ and $t$ is a "rule" computed from $i$ and $l$ using the function $T$ (unspecified in your pseudocode).

It might be better to think of the rules not as a set but as a function $T$ from pairs $(s,L(s))$ to "rules", where $L(s)$ is the function that computes the "links" available for $s \in S$.

That said, whether an answer to your question is useful will depend on what you plan to do with it. A formal mathematical statement about your "rules" may be necessary if you want to try to prove something about them, but may be more confusing than your English or pseudocode if what you want is just a description.