Tuples: Tuples are of the form $(v_1, \dots, v_n)$. The are indexed by natural numbers, which means that we can access its elements by $(v_1, \dots, v_n)(i)=v_i$. One way to create a set of tuples from sets $S_1, \dots, S_n$ is by this notation: $\prod_{i=1}^n S_i$

My question: Now, I want to achieve the same for records. Records are of the form $(x_1=v_1, \dots, x_n=v_n)$, where $x_1, \dots, x_n$ are variable names. We can access its elements by those variable names: $(x_1=v_1, \dots, x_n=v_n)(x_i)=v_i$.

How can I now create a set of records from some sets? In particular, if I have sets $S_1, \dots, S_n$, what is the standard notation for $\{ (x_1=v_1, \dots, x_n=v_n) \mid \forall i \in [n]: v_i \in S_i \}$?

A possible solution: I guess it would help to embed sets $S$ into tuples by something like $(x=S) := \{(x=v) \mid v \in S\}$. Then, I could use $\prod_{i=1}^n (x_i=S_i)$ to achieve what I want.

But is this the standard way? Or are there better ways?

Edit: Some context: I want to give semantics to a programming language. For this, it is convenient to model the set of states by a set of records. If I have a state $\sigma$ and want to evaluate a variable $x$ in that state, I can simply use that variable's name, as in $\sigma(x)$.

  • $\begingroup$ Why not considring simply a couple of tuples ? $((x_1,…,x_n),(v_1,…,v_n))$ $\endgroup$ – Mauro ALLEGRANZA May 5 '17 at 14:04
  • $\begingroup$ This sounds to me as if you are trying to find mathematical language for a programming construct (for example, the ability to specify arguments with name-value pairs rather than by position). There may not be a "right" answer. It might help if you provided more context, perhaps a use case. $\endgroup$ – Ethan Bolker May 5 '17 at 14:10
  • $\begingroup$ @MauroALLEGRANZA I think that would still be quite inconvenient. In order to define what I want (in my notation $\prod_{i=1}^n (x_i = S_i)$), I would have to write something like (in your notation) $\{ (x_1, \dots, x_n) \} \times \prod_{i=1}^n S_i$ $\endgroup$ – Peter May 5 '17 at 14:23

A record can be considered a function defined on the set of variable names. So you would define the set $I =\{x_1, \dots,x_n\}$ of variable names and write $S_x$ for the set of values the variable $x$ can take. The set of records is written $\prod_{x\in I} S_x$. For a record $r$ in this set, you can use $r(x)$ or $r_x$ for the value of the entry $x$.

The notation $(x_1 = v_1,\dots,x_n=v_n)$ for a record would not be standard, but you could certainly define it. (I would use something like $(x_1\mapsto v_1,\dots,x_n\mapsto v_n)$ instead.) If your variable names are ordered (as they implicitly are by their names $x_1$,$x_2$, etc. you might also get away with the shorthand $(v_1,\dots,v_n)$, leaving the variable names implicit.

| cite | improve this answer | |
  • $\begingroup$ Your answer is very helpful if the sets $S_i$ are themselves indexes by variables, as in $S_{x_i}$. But what if both the sets and the variables are indexed by integers, as in $S_1, \dots, S_n$ and $x_1, \dots, x_n$? $\endgroup$ – Peter May 7 '17 at 14:25
  • 1
    $\begingroup$ I would try to change the indices of the sets $S_i$ (I don’t know how much influence you have there); the indices of the variables do not matter in this case, you can forget about them after defining the set $I$. If these indices are important to you for some reason, you can also define a helper function $h$ that maps each variable to its index, i.e. $h(x_i)=i$. Then the set of records is $\prod_{x\in I} S_{h(x)}$ or you can use $h$ to index into tuples using variables, i.e. a record is the composition $(v_1, \dots, v_n)\circ h$ and its value at $x_i$ is $(v_1, \dots, v_n)(h(x_i))=v_i$. $\endgroup$ – Eike Schulte May 7 '17 at 18:34

The notion of a "variable name" seems a lot to me like a random variable, which is a function from a set of outcomes $\Omega$ to a set of real numbers. So each variable $x_k$ would be a function $x_k:\Omega\to\mathbb R$, i.e. you'd have a rule that tells you the value of $x_k(\omega)$ for each $\omega\in\Omega$.

Given sets $S_1,...,S_n$, your desired set is expressed as

$$\{\omega\in\Omega:(x_1(\omega),...,x_n(\omega))\in S_1\times\ldots S_n\}$$

| cite | improve this answer | |
  • $\begingroup$ Since I want to use this in the context of semantics for a programming language (see edit), this is not really what I want... $\endgroup$ – Peter May 5 '17 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.