(* Sets *)
(* List operations *)
(* INDEX 2 [1;3;4;2] = 3 *)
(* Sum of the list elements *)
(* shift_left [1;2;3] = [2;3;1] *)
(* Returns the next element in the cyclic order:
NEXT_EL [1;3;2] 3 = 2
NEXT_EL [1;3;2] 2 = 1 *)
(* list_pairs [1;2;3] = {(1,2), (2,3), (3,1)} *)
(* Special lists *)
(* Faces *)
(* Hypermap maps *)
(* let n_list = new_definition `n_list ll d = (FST d, PREV_EL (FST d) (find_pair_list d ll))`;; *)
(* Hypermap definition *)
(* Define "good" lists *)
(* Some general theorems *)
let ALL_DISTINCT_ALT = prove(`!(h:A) t. (
ALL_DISTINCT ([]:(A)list) <=> T) /\ (
ALL_DISTINCT (CONS h t) <=>
ALL_DISTINCT t /\ ~(
MEM h t))`,
REPEAT STRIP_TAC THENL
[
REWRITE_TAC[
ALL_DISTINCT;
LENGTH] THEN
REWRITE_TAC[ARITH_RULE `~(i < 0)`];
ALL_TAC
] THEN
REWRITE_TAC[
ALL_DISTINCT] THEN
EQ_TAC THENL
[
REPEAT STRIP_TAC THENL
[
FIRST_X_ASSUM (MP_TAC o SPECL [`SUC i`; `SUC j`]) THEN
ASM_REWRITE_TAC[
LENGTH;
LT_SUC;
SUC_INJ] THEN
ASM_REWRITE_TAC[
EL;
TL];
ALL_TAC
] THEN
POP_ASSUM MP_TAC THEN REWRITE_TAC[
MEM_EXISTS_EL] THEN
STRIP_TAC THEN
FIRST_X_ASSUM (MP_TAC o SPECL [`0`; `SUC i`]) THEN
ASM_REWRITE_TAC[
LENGTH;
LT_SUC;
LT_0; GSYM
NOT_SUC] THEN
REWRITE_TAC[
EL;
HD;
TL];
ALL_TAC
] THEN
REPEAT STRIP_TAC THEN
POP_ASSUM MP_TAC THEN
DISJ_CASES_TAC (SPEC `i:num`
num_CASES) THENL
[
DISJ_CASES_TAC (SPEC `j:num`
num_CASES) THENL
[
UNDISCH_TAC `~(i = j:num)` THEN ASM_REWRITE_TAC[];
ALL_TAC
] THEN
POP_ASSUM CHOOSE_TAC THEN
ASM_REWRITE_TAC[
EL;
HD;
TL] THEN
DISCH_TAC THEN UNDISCH_TAC `~MEM (h:A) t` THEN
REWRITE_TAC[
MEM_EXISTS_EL] THEN
EXISTS_TAC `n:num` THEN ASM_REWRITE_TAC[] THEN
UNDISCH_TAC `j <
LENGTH (CONS (h:A) t)` THEN
ASM_REWRITE_TAC[
LENGTH;
LT_SUC];
ALL_TAC
] THEN
POP_ASSUM CHOOSE_TAC THEN
DISJ_CASES_TAC (SPEC `j:num`
num_CASES) THENL
[
ASM_REWRITE_TAC[
EL;
HD;
TL] THEN
DISCH_TAC THEN UNDISCH_TAC `~MEM (h:A) t` THEN
REWRITE_TAC[
MEM_EXISTS_EL] THEN
EXISTS_TAC `n:num` THEN ASM_REWRITE_TAC[] THEN
UNDISCH_TAC `i <
LENGTH (CONS (h:A) t)` THEN
ASM_REWRITE_TAC[
LENGTH;
LT_SUC];
ALL_TAC
] THEN
POP_ASSUM CHOOSE_TAC THEN
ASM_REWRITE_TAC[
EL;
TL] THEN
DISCH_TAC THEN
FIRST_X_ASSUM (MP_TAC o SPECL [`n:num`; `n':num`]) THEN
ANTS_TAC THENL
[
UNDISCH_TAC `i <
LENGTH (CONS (h:A) t)` THEN UNDISCH_TAC `j <
LENGTH (CONS (h:A) t)` THEN
UNDISCH_TAC `~(i = j:num)` THEN
ASM_SIMP_TAC[
LENGTH;
LT_SUC;
SUC_INJ];
ALL_TAC
] THEN
ASM_REWRITE_TAC[]);;