I am formalizing a system that support pair of tuple and nat as input for function. However, I have some problem with the pair type in Coq.
From what I have learnt about Coq, pair is defined to be left-associative. i.e. (1, 2, 3)
and ((1, 2), 3)
have the same type of nat * nat * nat
. Sometimes, it can be treated as a 3-tuple of nat. One the other hand, (1, (2, 3))
has type nat * (nat * nat)
, which is a pair of nat and pair (or 2-tuple).
Idealy, I want to have a system that allows pair of nat and tuple and pair of tuple and nat. i.e. Both (1, (2, 3))
and ((1, 2), 3)
are differ from (1, 2, 3)
. Is there any suggested datatype in Coq for such model?
(1, 2, 3)
is just a nice notation for ((1, 2), 3)
, and nat * nat * nat
is just a nice notation for (nat * nat) * nat
. So this is already what you want.
If you want to see the parentheses, you should tick View -> Display parentheses in CoqIDE.
Note that if you wanted triple not encoded as pairs, you could define them as:
Record triple (A B C : Type): Type :=
{
t_fst : A;
t_snd : B;
t_trd : C
}