@@ -17,6 +17,13 @@ Notation "'Sigma' x .. y , p" :=
17
17
format "'[' 'Sigma' '/ ' x .. y , '/ ' p ']'")
18
18
: type_scope.
19
19
20
+ Fact skolem_trans {X Y} (p: X -> Y -> Prop ) :
21
+ (forall x, Sigma y, p x y) -> Sigma f, forall x, p x (f x).
22
+ Proof .
23
+ intros F.
24
+ exists (fun x => pi1 (F x)). intros x. exact (pi2 (F x)).
25
+ Qed .
26
+
20
27
(*** Injections and Bijections *)
21
28
22
29
@@ -256,39 +263,6 @@ Proof.
256
263
- right. congruence.
257
264
Qed .
258
265
259
- Fact R {X Y f g} :
260
- @inv (option X) (option Y) g f ->
261
- forall x, Sigma z, match f (Some x) with Some y => z = y | None => Some z = f None end .
262
- Proof .
263
- intros H x.
264
- destruct (f (Some x)) as [y|] eqn:E1.
265
- - exists y. reflexivity.
266
- - destruct (f None) as [y|] eqn:E2.
267
- + exists y. reflexivity.
268
- + exfalso. congruence.
269
- Qed .
270
-
271
- Fact R_inv {X Y f g} :
272
- forall (H1: @inv (option X) (option Y) g f)
273
- (H2: inv f g),
274
- inv (fun y => pi1 (R H2 y)) (fun x => pi1 (R H1 x)).
275
- Proof .
276
- intros H1 H2 x.
277
- destruct (R H1 x) as [y H3]; cbn.
278
- destruct (R H2 y) as [x' H4]; cbn.
279
- revert H3 H4.
280
- destruct (f (Some x)) as [y1|] eqn:E.
281
- - intros <-. rewrite <-E, H1. easy.
282
- - intros ->. rewrite H1. rewrite <-E, H1. congruence.
283
- Qed .
284
-
285
- Theorem bijection_option X Y :
286
- bijection (option X) (option Y) -> bijection X Y.
287
- Proof .
288
- intros [f g H1 H2].
289
- exists (fun y => pi1 (R H1 y)) (fun x => pi1 (R H2 x)); apply R_inv.
290
- Qed .
291
-
292
266
Goal forall X Y, bijection X Y -> bijection (option X) (option Y).
293
267
Proof .
294
268
intros X Y [f g H1 H2].
@@ -298,70 +272,59 @@ Proof.
298
272
- hnf. intros [y|]; congruence.
299
273
Qed .
300
274
301
- Fact skolem_trans {X Y} (p: X -> Y -> Prop ) :
302
- (forall x, Sigma y, p x y) -> Sigma f, forall x, p x (f x).
275
+ Definition lower' X Y (f: option X -> option Y) x z :=
276
+ match f (Some x) with
277
+ | Some y => z = y
278
+ | None => match f None with
279
+ | Some y => z = y
280
+ | None => False
281
+ end
282
+ end .
283
+
284
+ Definition lower X Y (f: option X -> option Y) f' :=
285
+ forall x, lower' X Y f x (f' x).
286
+
287
+ Fact lower_sig {X Y} f :
288
+ injective f -> sig (lower X Y f).
303
289
Proof .
304
- intros F.
305
- exists (fun x => pi1 (F x)). intros x. exact (pi2 (F x)).
290
+ intros H.
291
+ apply skolem_trans.
292
+ intros x. unfold lower'.
293
+ destruct (f (Some x)) as [y|] eqn:E1.
294
+ - eauto.
295
+ - destruct (f None) as [y|] eqn:E2.
296
+ + eauto.
297
+ + enough (Some x = None) by easy.
298
+ apply H. congruence.
306
299
Qed .
307
-
308
- Module Version2024.
309
300
310
- Definition lower' X Y (f: option X -> option Y) x z :=
311
- match f (Some x) with
312
- | Some y => z = y
313
- | None => match f None with
314
- | Some y => z = y
315
- | None => False
316
- end
317
- end .
318
-
319
- Definition lower X Y (f: option X -> option Y) f' :=
320
- forall x, lower' X Y f x (f' x).
301
+ Fact lem_lower X Y f g f' g' :
302
+ inv g f -> inv f g ->
303
+ lower X Y f f' -> lower Y X g g' -> inv g' f'.
304
+ Proof .
305
+ intros H1 H2 H3 H4 x.
306
+ specialize (H3 x). unfold lower' in H3.
307
+ destruct (f (Some x)) as [y|] eqn:E1.
308
+ - specialize (H4 y). unfold lower' in H4.
309
+ destruct (g (Some y)) as [x'|] eqn:E2; congruence.
310
+ - destruct (f None) as [y|] eqn:E2. 2:easy.
311
+ specialize (H4 y). unfold lower' in H4.
312
+ assert (E3: g (Some y) = None) by congruence.
313
+ rewrite E3 in H4.
314
+ destruct (g None) as [x'|] eqn:E4; congruence.
315
+ Qed .
321
316
322
-
323
- Fact lower_sig {X Y} f :
324
- injective f -> sig (lower X Y f).
325
- Proof .
326
- intros H.
327
- apply skolem_trans.
328
- intros x. unfold lower'.
329
- destruct (f (Some x)) as [y|] eqn:E1.
330
- - eauto.
331
- - destruct (f None) as [y|] eqn:E2.
332
- + eauto.
333
- + enough (Some x = None) by easy.
334
- apply H. congruence.
335
- Qed .
336
-
337
- Fact lem_lower X Y f g f' g' :
338
- inv g f -> inv f g ->
339
- lower X Y f f' -> lower Y X g g' -> inv g' f'.
340
- Proof .
341
- intros H1 H2 H3 H4 x.
342
- specialize (H3 x). unfold lower' in H3.
343
- destruct (f (Some x)) as [y|] eqn:E1.
344
- - specialize (H4 y). unfold lower' in H4.
345
- destruct (g (Some y)) as [x'|] eqn:E2; congruence.
346
- - destruct (f None) as [y|] eqn:E2. 2:easy.
347
- specialize (H4 y). unfold lower' in H4.
348
- assert (E3: g (Some y) = None) by congruence.
349
- rewrite E3 in H4.
350
- destruct (g None) as [x'|] eqn:E4; congruence.
351
- Qed .
317
+ Theorem bijection_option X Y :
318
+ bijection (option X) (option Y) -> bijection X Y.
319
+ Proof .
320
+ intros [f g H1 H2].
321
+ destruct (lower_sig f) as [f' H3].
322
+ { eapply inv_injective, H1. }
323
+ destruct (lower_sig g) as [g' H4].
324
+ { eapply inv_injective, H2. }
325
+ exists f' g'; eapply lem_lower; eassumption.
326
+ Qed .
352
327
353
- Theorem bijection_option X Y :
354
- bijection (option X) (option Y) -> bijection X Y.
355
- Proof .
356
- intros [f g H1 H2].
357
- destruct (lower_sig f) as [f' H3].
358
- { eapply inv_injective, H1. }
359
- destruct (lower_sig g) as [g' H4].
360
- { eapply inv_injective, H2. }
361
- exists f' g'; eapply lem_lower; eassumption.
362
- Qed .
363
- End Version2024.
364
-
365
328
(*** Numeral Types *)
366
329
367
330
Fixpoint num n : Type :=
0 commit comments