(* ========================================================================= *)
(* Binary expansions as a bijection between numbers and finite sets. *)
(* ========================================================================= *)
let BINARY_INDUCT = prove
(`!P. P 0 /\ (!n. P n ==> P(2 * n) /\ P(2 * n + 1)) ==> !n. P n`,
GEN_TAC THEN STRIP_TAC THEN MATCH_MP_TAC
num_WF THEN GEN_TAC THEN
STRIP_ASSUME_TAC(ARITH_RULE
`n = 0 \/ n DIV 2 < n /\ (n = 2 * n DIV 2 \/ n = 2 * n DIV 2 + 1)`) THEN
ASM_MESON_TAC[]);;
(* ------------------------------------------------------------------------- *)
(* The basic bijections. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Inverse property in one direction. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Inverse property in the other direction. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Also, bijections between restricted segments. *)
(* ------------------------------------------------------------------------- *)