Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2019
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.34 KB | None | 0 0
  1. Require Import Utf8 Setoid Classical.
  2.  
  3. Notation "'∃!' x .. y , p" :=
  4. (ex (unique (fun x => .. (ex (unique (fun y => p))) ..)))
  5. (at level 0, x binder, y binder).
  6. Notation "'p1'" := (proj1_sig) (at level 0).
  7.  
  8. Axiom set: Type.
  9. Declare Scope set_scope.
  10. Delimit Scope set_scope with set.
  11. Open Scope set.
  12.  
  13. Definition set_sig (P: set → Prop) := sig P.
  14. Definition proj1_set {P}: set_sig P → set := @proj1_sig _ _.
  15. Coercion proj1_set: set_sig >-> set.
  16.  
  17.  
  18. Axiom In: set → set → Prop.
  19. Notation "x ∈ y" := (In x y) (at level 10): set_scope.
  20. Infix "∉" := (λ x y, ¬ x ∈ y) (at level 10): set_scope.
  21.  
  22. Axiom empty_set: set_sig (λ X, ∀ x, x ∈ X ↔ False).
  23. Notation "'Ø'" := empty_set: set_scope.
  24. Notation " { } " := empty_set (only parsing): set_scope.
  25.  
  26. Definition subset X Y := ∀ a, a ∈ X → a ∈ Y.
  27. Infix "⊆" := subset (at level 10): set_scope.
  28.  
  29. Axiom Extensionality:
  30. ∀ X Y, (∀ a, a ∈ X ↔ a ∈ Y) ↔ X = Y.
  31. Axiom UnorderedPair:
  32. ∀ (X Y: set), set_sig (λ Z, ∀ a, a ∈ Z <-> a = X \/ a = Y).
  33.  
  34. Notation "{ x , y }" := (UnorderedPair x y) (at level 0): set_scope.
  35.  
  36. Definition singleton (X: set): set_sig (fun Y => ∀ a, a ∈ Y <-> a = X).
  37. Proof.
  38. pose {X, X}. destruct UnorderedPair. simpl in *. exists x.
  39. setoid_rewrite i. tauto.
  40. Defined.
  41. Notation "{ x }" := (singleton x): set_scope.
  42. Notation "{{ x }}" := (singleton x) (only parsing): set_scope.
  43.  
  44. Axiom Subsets:
  45. ∀ (P: set → Prop) X, set_sig (λ Y, ∀ a, a ∈ Y <-> a ∈ X ∧ P a).
  46.  
  47. Definition intersection X Y := Subsets (fun x => In x Y) X.
  48. Infix "∩" := intersection (at level 55, right associativity): set_scope.
  49.  
  50. Definition difference X Y := Subsets (λ x, ~ x ∈ Y) X.
  51. Infix "\" := difference (at level 50, no associativity): set_scope.
  52.  
  53. Axiom SumSet:
  54. ∀ X, set_sig (λ Y, ∀ a, a ∈ Y <-> ∃ z, z ∈ X ∧ a ∈ z).
  55.  
  56. Notation "∪ X" := (SumSet X) (at level 70): set_scope.
  57. Definition union X Y: set_sig (λ Z, ∀ a, a ∈ Z <-> a ∈ X \/ a ∈ Y).
  58. Proof.
  59. destruct (SumSet (p1 {X, Y})) as [sumset p]. destruct {X, Y} as [pair p0]. simpl in *.
  60. setoid_rewrite p0 in p. exists sumset. setoid_rewrite p.
  61. clear p p0. intuition.
  62. + destruct H. destruct H. destruct H. subst; auto. subst; auto.
  63. + exists X. auto.
  64. + exists Y. auto.
  65. Qed.
  66. Infix "∪" := union (at level 60, right associativity): set_scope.
  67. Notation "{ x , y , z , .. , v }" := (union .. (union (UnorderedPair x y) (singleton z) ) .. (singleton v)) (at level 0): set_scope.
  68.  
  69. Axiom PowerSet:
  70. ∀ X, set_sig (λ Y, ∀ a, a ∈ Y <-> a ⊆ X).
  71.  
  72. Axiom Infinity:
  73. set_sig (λ S, In (p1 Ø) S ∧ ∀ x, In x S → In (p1 {{ x }}) S).
  74.  
  75. Axiom Replacement:
  76. ∀ (P: set → set → Prop) (H: ∀ x, ∃! y, (P x y)) X,
  77. set_sig (λ Y, ∀ b, b ∈ Y <-> ∃ a, a ∈ X ∧ P a b).
  78.  
  79. Definition disjoint_sets X Y := ¬ ∃ z, z ∈ X ∧ z ∈ Y.
  80.  
  81. Axiom AxiomOfFoundation:
  82. ∀ X, X ≠ p1 Ø → set_sig (λ a, a ∈ X ∧ disjoint_sets a X).
  83.  
  84. Axiom AxiomOfChoice:
  85. ∀ X, set_sig (λ Y, ∀ a, a ∈ X ∧ a ≠ p1 Ø → (∃! u, (u ∈ a ∧ u ∈ Y))).
  86.  
  87. Theorem T x y: @eq set ({x, y} ∩ {{x}}) {{x}}.
  88. Proof.
  89. destruct singleton, UnorderedPair, intersection; simpl in *.
  90. apply Extensionality. setoid_rewrite i1. setoid_rewrite i.
  91. setoid_rewrite i0. tauto.
  92. Qed.
  93.  
  94. Theorem T0 {Px Py} (X: set_sig Px) (Y: set_sig Py) a: a ∈ X -> a ∈ (X ∪ Y).
  95. Proof.
  96. destruct X, union; simpl in *. pose (i a). intro. setoid_rewrite i0. auto.
  97. Defined.
  98.  
  99. Theorem T1 (a: set) {Px Py} (X: set_sig Px) (Y: set_sig Py): a ∈ X -> a ∈ Y -> a ∈ (X ∩ Y).
  100. Proof.
  101. destruct X, Y, intersection; simpl in *. pose (i a). intros. rewrite i0. auto.
  102. Defined.
  103.  
  104. Theorem T2 {Px Py Pz} (X: set_sig Px) (Y: set_sig Py) (Z: set_sig Pz):
  105. subset X Y -> subset Y Z -> subset X Z.
  106. Proof. unfold subset. intuition. Qed.
  107.  
  108. (* Exercises *)
  109.  
  110. Theorem E1213: ¬ ∃ x, ∀ y, y ∈ x.
  111. Proof.
  112. intro. destruct H as [S H].
  113. destruct (Subsets (λ x, ¬ x ∈ x) S).
  114. pose (i x). pose (H x). intuition.
  115. Qed.
  116.  
  117. Definition is_singleton A x := ∀ z, z ∈ A ↔ z = x.
  118.  
  119. Theorem E1214 x: ∃! A, (is_singleton A x).
  120. Proof.
  121. intros. destruct {{x}}. exists x0. unfold unique, is_singleton. intuition.
  122. apply (Extensionality x0 x'). intuition.
  123. + rewrite i in H0. rewrite H. auto.
  124. + rewrite i. rewrite H in H0. auto.
  125. Qed.
  126.  
  127. Definition E1214_0 x: ∃! A, (is_singleton A x).
  128. Proof.
  129. intros. destruct (Subsets (λ p, p = x) (PowerSet x)).
  130. exists x0. unfold unique, is_singleton in *.
  131. setoid_rewrite i. intuition.
  132. + subst. clear i. destruct (PowerSet x). simpl. rewrite i. unfold subset. auto.
  133. + destruct (PowerSet x). simpl in *. apply Extensionality. intuition.
  134. - rewrite H. rewrite i in H0. tauto.
  135. - rewrite i. rewrite H in H0. subst. intuition. rewrite i0. unfold subset. tauto.
  136. Qed.
  137.  
  138. Fixpoint F n: set :=
  139. match n with
  140. | O => Ø
  141. | S m => PowerSet (F m)
  142. end.
  143.  
  144. Theorem subset_of_empty_set x: subset x {} <-> x = {}.
  145. Proof.
  146. unfold subset. destruct empty_set. simpl.
  147. setoid_rewrite <- Extensionality.
  148. setoid_rewrite i.
  149. + intuition; eauto. rewrite H in H0; auto.
  150. Qed.
  151.  
  152. Theorem element_of_singleton x a: x ∈ {{a}} <-> x = a.
  153. Proof. destruct {{a}}. exact (i x). Qed.
  154.  
  155. Theorem T3 X Y:
  156. subset X Y -> ( Y = union X (Y \ X) )%set.
  157. Proof.
  158. intro. unfold subset in H. apply Extensionality.
  159. destruct (union X (Y \ X)) as [union H0]. destruct (Y \ X) as [difference H1]. simpl in *.
  160. setoid_rewrite H0. setoid_rewrite H1. clear union difference H1 H0.
  161. intuition. destruct (classic (a ∈ X)). auto. auto.
  162. Qed.
  163.  
  164. Theorem T4 x a b (H: a <> b) S: let X := {a, b} ∪ S in subset X {{x}} -> False.
  165. Proof.
  166. simpl. destruct union as [union H0]. simpl in *. destruct singleton as [singleton H1]. simpl in *.
  167. destruct {a, b} as [pair H2]. simpl in *. intro.
  168. unfold subset in *. setoid_rewrite H2 in H0. clear H2.
  169. setoid_rewrite H0 in H3. clear H0. setoid_rewrite H1 in H3. clear H1.
  170. apply H. clear H.
  171. assert (a = x). apply H3. auto.
  172. assert (b = x). apply H3. auto.
  173. congruence.
  174. Qed.
  175.  
  176. Theorem subset_of_singleton x a: subset x {{a}} <-> x = {} \/ x = {{a}}.
  177. Proof.
  178. destruct singleton as [singleton H]. simpl. destruct empty_set as [empty H0]. simpl.
  179. unfold subset. intuition.
  180. 2:{ rewrite H2 in H1. exfalso. eapply H0. eauto. }
  181. 2:{ rewrite <- H2. auto. }
  182. Admitted.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement