Require Export List.
Require Export Setoid.
Unset Standard Proposition Elimination Names.
(* This is a construction of the free group on a set of generators, as the set of reduced words where a letter is a generator or its formal inverse.  The proof given here that the construction works is attributed to van der Waerden. The essential idea is: for each letter we define an automorphism on the set of reduced words, in such a way that inverse letters give inverse automorphisms. Then any reduced word W gives an automorphism which sends the empty string to W; and equivalent words give equal automorphisms. Therefore, no two reduced words are equivalent, and associativity of multiplication reduces to associativity of function composition (or to associativity of concatenation). *)
Section FreeGroups.
Variable generators: Type.
Hypothesis generator_eq_dec: forall g1 g2:generators,
{ g1=g2 } + { g1<>g2 }.
Inductive alphabet: Type :=
| intro_gen: generators -> alphabet
| intro_gen_inv: generators -> alphabet.
Definition group_str := list alphabet.
Definition opposite (letter:alphabet) :=
match letter with
| intro_gen a => intro_gen_inv a
| intro_gen_inv a => intro_gen a
end.

Lemma opposite_involution: forall a:alphabet,
opposite (opposite a) = a.