-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZF.v
271 lines (199 loc) · 7 KB
/
ZF.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
(** * Definition of ZF-Entailment *)
Require Import Tarski.
Require Import GeneralReflection.
(** ** Signature *)
Inductive ZF_Funcs : Type :=
| eset : ZF_Funcs
| pair : ZF_Funcs
| union : ZF_Funcs
| power : ZF_Funcs
| om : ZF_Funcs.
Definition ZF_fun_ar (f : ZF_Funcs) : nat :=
match f with
| eset => 0
| pair => 2
| union => 1
| power => 1
| om => 0
end.
Inductive ZF_Preds : Type :=
| elem : ZF_Preds
| equal : ZF_Preds.
Definition ZF_pred_ar (P : ZF_Preds) : nat :=
match P with _ => 2 end.
Instance ZF_func_sig : funcs_signature :=
{| syms := ZF_Funcs; ar_syms := ZF_fun_ar; |}.
Instance ZF_pred_sig : preds_signature :=
{| preds := ZF_Preds; ar_preds := ZF_pred_ar; |}.
Arguments Vector.nil {_}, _.
Arguments Vector.cons {_} _ {_} _, _ _ _ _.
Notation "¬ A" := (A --> ⊥) (at level 42).
Notation "A '<-->' B" := ((A --> B) ∧ (B --> A)) (at level 43).
(** ** Axioms *)
Notation "x ∈ y" := (atom ZF_func_sig ZF_pred_sig elem (Vector.cons x (Vector.cons y Vector.nil))) (at level 35).
Notation "x ≡ y" := (atom ZF_func_sig ZF_pred_sig equal (Vector.cons x (Vector.cons y Vector.nil))) (at level 35).
Notation "∅" := (func ZF_func_sig eset Vector.nil).
Notation "'ω'" := (func ZF_func_sig om Vector.nil).
Notation "{ x ; y }" := (func ZF_func_sig pair (Vector.cons x (Vector.cons y Vector.nil))) (at level 31).
Notation "⋃ x" := (func ZF_func_sig union (Vector.cons x Vector.nil)) (at level 32).
Notation "'PP' x" := (func ZF_func_sig power (Vector.cons x Vector.nil)) (at level 31).
Notation "x ∪ y" := (⋃ {x; y}) (at level 32).
Notation "'σ' x" := (x ∪ {x; x}) (at level 32).
Fixpoint shift n x :=
match n with
| O => x
| S n => subst_term ↑ (shift n x)
end.
Definition sub x y :=
∀ $0 ∈ x[↑] --> $0 ∈ y[↑].
Notation "x ⊆ y" := (sub x y) (at level 34).
Definition ax_ext :=
∀ ∀ $1 ⊆ $0 --> $0 ⊆ $1 --> $1 ≡ $0.
Definition ax_eset :=
∀ ¬ ($0 ∈ ∅).
Definition ax_pair :=
∀ ∀ ∀ $0 ∈ {$1; $2} <--> $0 ≡ $1 ∨ $0 ≡ $2.
Definition ax_union :=
∀ ∀ $0 ∈ ⋃ $1 <--> ∃ $0 ∈ $2 ∧ $1 ∈ $0.
Definition ax_power :=
∀ ∀ $0 ∈ PP $1 <--> $0 ⊆ $1.
Definition inductive x :=
∅ ∈ x ∧ ∀ $0 ∈ shift 1 x --> σ $0 ∈ shift 1 x.
Definition ax_om1 :=
inductive ω.
Definition ax_om2 :=
∀ inductive ($0) --> ω ⊆ $0.
Definition ax_sep phi :=
∀ ∃ ∀ $0 ∈ $1 <--> $0 ∈ $2 ∧ phi[$0.: Nat.add 3 >> var].
Definition fun_rel phi :=
∀ ∀ ∀ phi[$2.:($1)..] --> phi[$2.:($0)..] --> $1 ≡ $0.
Definition ax_rep phi :=
fun_rel phi --> ∀ ∃ ∀ $0 ∈ $1 <--> ∃ $0 ∈ $3 ∧ phi.
(** ** ZF-Models *)
Class ZF_Model :=
{
V :> Type ;
VI : interp V ;
V_ext : forall rho, rho ⊨ ax_ext ;
V_eset : forall rho, rho ⊨ ax_eset ;
V_pair : forall rho, rho ⊨ ax_pair ;
V_union : forall rho, rho ⊨ ax_union ;
V_power : forall rho, rho ⊨ ax_power ;
V_om1 : forall rho, rho ⊨ ax_om1 ;
V_om2 : forall rho, rho ⊨ ax_om2 ;
V_sep : forall phi rho, rho ⊨ ax_sep phi ;
V_rep : forall phi rho, rho ⊨ ax_rep phi ;
}.
Coercion V : ZF_Model >-> Sortclass.
Instance VI_instance (M : ZF_Model) : interp M := @VI M.
Notation "x i∈ y" := (@i_P _ _ _ VI elem (Vector.cons x (Vector.cons y Vector.nil))) (at level 20).
Notation "x i≡ y" := (@i_P _ _ _ VI equal (Vector.cons x (Vector.cons y Vector.nil))) (at level 20).
Notation "x i⊆ y" := (forall z, z i∈ x -> z i∈ y) (at level 20).
Notation "i∅" := (@i_f _ _ _ VI eset Vector.nil).
Notation "'iω'" := (@i_f _ _ _ VI om Vector.nil).
Notation "i{ x ; y }" := (@i_f _ _ _ VI pair (Vector.cons x (Vector.cons y Vector.nil))) (at level 10).
Notation "i⋃ x" := (@i_f _ _ _ VI union (Vector.cons x Vector.nil)) (at level 15).
Notation "'iPP' x" := (@i_f _ _ _ VI power (Vector.cons x Vector.nil)) (at level 15).
Notation "x i∪ y" := (i⋃ i{x; y}) (at level 16).
Notation "'iσ' x" := (x i∪ i{x; x}) (at level 15).
(* Extensional models interpret set equality as equality *)
Notation extensional M :=
(forall x y : M, x i≡ y <-> x = y).
(* Standard models contain only standard natural numbers *)
Fixpoint numeral {M : ZF_Model} n :=
match n with
| O => i∅
| S n => iσ (numeral n)
end.
Definition standard (M : ZF_Model) :=
forall x, x i∈ iω -> exists n, x = numeral n.
(** ** ZF-Entailment *)
Definition ZF_entails phi :=
forall (M : ZF_Model), extensional M -> forall rho, rho ⊨ phi.
(** ** Internal axioms *)
Section ZF.
Context { M : ZF_Model }.
MetaCoq Quote Definition qVM := (@V M).
Existing Instance config.default_checker_flags.
Instance ZF_reflector : tarski_reflector := {
fs := _;
ps := _;
D := _;
I := _;
emptyEnv := (fun _:nat => i∅);
isD := Checker.eq_term uGraph.init_graph qVM
}.
Print ZF_reflector.
Hypothesis VIEQ : extensional M.
Lemma M_ext (x y : M) :
x i⊆ y -> y i⊆ x -> x = y.
Proof.
rewrite <- VIEQ. apply (V_ext (fun _ => i∅)).
Qed.
Lemma M_eset x :
~ x i∈ i∅.
Proof.
specialize V_eset with (rho:=fun _ => i∅). cbn.
intros H1 H2. now apply (H1 x).
Qed.
Lemma M_pair x y z :
x i∈ i{y; z} <-> x = y \/ x = z.
Proof.
rewrite <- !VIEQ. apply V_pair with (rho:=fun _ => i∅).
Qed.
Lemma M_union x y :
x i∈ i⋃ y <-> exists z, z i∈ y /\ x i∈ z.
Proof.
apply V_union with (rho:=fun _ => i∅).
Qed.
Lemma M_power x y :
x i∈ iPP y <-> x i⊆ y.
Proof.
apply V_power with (rho:=fun _ => i∅).
Qed.
Definition M_inductive x :=
i∅ i∈ x /\ forall y, y i∈ x -> iσ y i∈ x.
Lemma M_om1 :
M_inductive iω.
Proof.
apply V_om1 with (rho:=fun _ => i∅).
Qed.
Lemma M_om2 x :
M_inductive x -> iω i⊆ x.
Proof.
apply V_om2 with (rho:=fun _ => i∅).
Qed.
Definition agrees_fun phi (P : M -> Prop) :=
forall x rho, P x <-> (x.:rho) ⊨ phi.
Lemma M_sep (P:naryProp 1) x :
representableP 1 P -> exists y, forall z, z i∈ y <-> z i∈ x /\ P z.
Proof.
intros [phi [rho Hp]]. specialize V_sep with (rho:=rho). cbn.
intros H. destruct (H phi x) as [y H']. clear H.
exists y. intros z. specialize (H' z). setoid_rewrite sat_comp in H'.
rewrite (sat_ext _ _ (xi:=z.:rho)) in H'; try now intros [].
firstorder.
Qed.
Definition functional (R : M -> M -> Prop) :=
forall x y y', R x y -> R x y' -> y = y'.
Definition representable__rel phi (R : M -> M -> Prop) :=
forall x y rho, R x y <-> (x.:(y.:rho)) ⊨ phi.
Notation def_rel R := (representableP 2 R).
(*exists phi rho, forall x y, R x y <-> (x.:(y.:rho)) ⊨ phi.*)
Definition M_is_rep R x y :=
forall v, v i∈ y <-> exists u, u i∈ x /\ R u v.
Lemma M_rep R x :
def_rel R -> functional R -> exists y, M_is_rep R x y.
Proof.
Admitted.
Lemma is_rep_unique R x y y' :
M_is_rep R x y -> M_is_rep R x y' -> y = y'.
Proof.
intros H1 H2. apply M_ext; intros v.
- intros H % H1. now apply H2.
- intros H % H2. now apply H1.
Qed.
Goal def_rel (fun x y => x i⊆ y).
representNP.
Qed.
End ZF.