(* ========================================================================= *)
(* Set-theoretic hierarchy for modelling HOL inside itself. *)
(* ========================================================================= *)
let INJ_LEMMA = prove
(`(!x y. (f x = f y) ==> (x = y)) <=> (!x y. (f x = f y) <=> (x = y))`,
MESON_TAC[]);;
(* ------------------------------------------------------------------------- *)
(* Useful to have a niceish "function update" notation. *)
(* ------------------------------------------------------------------------- *)
parse_as_infix("|->",(12,"right"));;
let valmod = new_definition
`(x |-> a) (v:A->B) = \y. if y = x then a else v(y)`;;
let VALMOD = prove
(`!v x y a. ((x |-> y) v) a = if a = x then y else v(a)`,
let VALMOD_SWAP = prove
(`!v x y a b.
~(x = y) ==> ((x |-> a) ((y |-> b) v) = (y |-> b) ((x |-> a) v))`,
(* ------------------------------------------------------------------------- *)
(* A dummy finite type inadequately modelling ":ind". *)
(* ------------------------------------------------------------------------- *)
let ind_model_tybij =
new_type_definition "ind_model" ("mk_ind","dest_ind") ind_model_tybij_th;;
(* ------------------------------------------------------------------------- *)
(* Introduce a type whose universe is "inaccessible" starting from *)
(* "ind_model". Since "ind_model" is finite, we can just use any *)
(* infinite set. In order to make "ind_model" infinite, we would need *)
(* a new axiom. In order to keep things generic we try to deduce *)
(* everything from this one uniform "axiom". Note that even in the *)
(* infinite case, this can still be a small set in ZF terms, not a real *)
(* inaccessible cardinal. *)
(* ------------------------------------------------------------------------- *)
(****** Here's what we'd do in the infinite case
new_type("I",0);;
let I_AXIOM = new_axiom
`UNIV:ind_model->bool <_c UNIV:I->bool /\
(!s:A->bool. s <_c UNIV:I->bool ==> {t | t SUBSET s} <_c UNIV:I->bool)`;;
*******)
let inacc_tybij =
new_type_definition "I" ("mk_I","dest_I") inacc_tybij_th;;
let I_AXIOM = prove
(`UNIV:ind_model->bool <_c UNIV:I->bool /\
(!s:A->bool. s <_c UNIV:I->bool ==> {t | t
SUBSET s} <_c UNIV:I->bool)`,
(* ------------------------------------------------------------------------- *)
(* I is infinite and therefore admits an injective pairing. *)
(* ------------------------------------------------------------------------- *)
let I_PAIR = REWRITE_RULE[INJ_LEMMA]
(new_specification ["I_PAIR"] I_PAIR_EXISTS);;
(* ------------------------------------------------------------------------- *)
(* It also admits injections from "bool" and "ind_model". *)
(* ------------------------------------------------------------------------- *)
let I_BOOL = REWRITE_RULE[INJ_LEMMA]
(new_specification ["I_BOOL"] I_BOOL_EXISTS);;
let I_IND = REWRITE_RULE[INJ_LEMMA]
(new_specification ["I_IND"] I_IND_EXISTS);;
(* ------------------------------------------------------------------------- *)
(* And the injection from powerset of any accessible set. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Define a type for "levels" of our set theory. *)
(* ------------------------------------------------------------------------- *)
;
let setlevel_DISTINCT = distinctness "setlevel";;
let setlevel_INJ = injectivity "setlevel";;
(* ------------------------------------------------------------------------- *)
(* Now define a subset of I corresponding to each. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Show they all satisfy the cardinal limits. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Hence the injectivity of the mapping from powerset. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Now our universe of sets and (ur)elements. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Define an actual type V. *)
(* *)
(* This satisfies a suitable number of the ZF axioms. It isn't extensional *)
(* but we could then construct a quotient structure if desired. Anyway it's *)
(* only empty sets that aren't. A more significant difference is that we *)
(* have urelements and the hierarchy levels are all distinct rather than *)
(* being cumulative. *)
(* ------------------------------------------------------------------------- *)
let v_tybij =
new_type_definition "V" ("mk_V","dest_V") v_tybij_th;;
(* ------------------------------------------------------------------------- *)
(* Drop a level; test if something is a set. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Define some useful inversions. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Now all the critical relations. *)
(* ------------------------------------------------------------------------- *)
parse_as_infix("<:",(11,"right"));;
parse_as_infix("<=:",(12,"right"));;
(* ------------------------------------------------------------------------- *)
(* If something has members, it's a set. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Each level is nonempty. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Empty sets (or non-sets, of course) exist at all set levels. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Comprehension principle, with no change of levels. *)
(* ------------------------------------------------------------------------- *)
parse_as_infix("suchthat",(21,"left"));;
(* ------------------------------------------------------------------------- *)
(* Each setlevel exists as a set. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Conversely, set(s) belongs in the appropriate level. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Power set exists. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Pairing operation. *)
(* ------------------------------------------------------------------------- *)
let PAIR_INJ = prove
(`!x1 y1 x2 y2. (
pair x1 y1 =
pair x2 y2) <=> (x1 = x2) /\ (y1 = y2)`,
REPEAT GEN_TAC THEN EQ_TAC THENL [ALL_TAC; SIMP_TAC[]] THEN
REWRITE_TAC[
pair] THEN
DISCH_THEN(MP_TAC o AP_TERM `dest_V`) THEN REWRITE_TAC[
DEST_MK_PAIR] THEN
REWRITE_TAC[setlevel_INJ;
PAIR_EQ; I_PAIR] THEN
REWRITE_TAC[
level;
element] THEN MESON_TAC[
PAIR; CONJUNCT1 v_tybij]);;
(* ------------------------------------------------------------------------- *)
(* Decomposition functions. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* And the Cartesian product space. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Extensionality for sets at the same level. *)
(* ------------------------------------------------------------------------- *)
let SUBSET_ANTISYM_LEVEL = prove
(`!s t.
isaset s /\
isaset t /\ s <=: t /\ t <=: s ==> (s = t)`,
REPEAT GEN_TAC THEN
REPLICATE_TAC 2 (DISCH_THEN(CONJUNCTS_THEN2 ASSUME_TAC MP_TAC)) THEN
ASM_SIMP_TAC[
SUBSET_ALT] THEN
EVERY_ASSUM(MP_TAC o GSYM o MATCH_MP
SET_DECOMP) THEN
REPEAT STRIP_TAC THEN
MP_TAC(SPEC `s:V`
SET) THEN MP_TAC(SPEC `t:V`
SET) THEN
REPEAT(DISCH_THEN(SUBST1_TAC o SYM)) THEN
AP_TERM_TAC THEN BINOP_TAC THEN ASM_MESON_TAC[
SUBSET_ANTISYM]);;
(* ------------------------------------------------------------------------- *)
(* And hence for any nonempty sets. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Union set exists. I don't need this but if might be a sanity check. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Boolean stuff. *)
(* ------------------------------------------------------------------------- *)
let true_def = new_definition
`true = mk_V(Ur_bool,I_BOOL T)`;;
let false_def = new_definition
`false = mk_V(Ur_bool,I_BOOL F)`;;
(* ------------------------------------------------------------------------- *)
(* Ind stuff. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Axiom of choice (this is trivially so in HOL anyway, but...) *)
(* ------------------------------------------------------------------------- *)
let ch =
let th = prove
(`?ch. !s. (?x. x <: s) ==> ch(s) <: s`,
REWRITE_TAC[GSYM
SKOLEM_THM] THEN MESON_TAC[]) in
new_specification ["ch"]
th;;
(* ------------------------------------------------------------------------- *)
(* Sanity check lemmas. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Definition of function space. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Special case of treating a Boolean function as a set. *)
(* ------------------------------------------------------------------------- *)