1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "logic/cprop.ma".
17 nrecord powerset (A: setoid) : Type[1] ≝ { mem_op:> unary_morphism1 A CPROP }.
19 interpretation "powerset" 'powerset A = (powerset A).
21 interpretation "subset construction" 'subset \eta.x =
22 (mk_powerset ? (mk_unary_morphism1 ? CPROP x ?)).
24 interpretation "mem" 'mem a S = (mem_op ? S a).
26 ndefinition subseteq ≝ λA:setoid.λU,V.∀a:A. a ∈ U → a ∈ V.
28 interpretation "subseteq" 'subseteq U V = (subseteq ? U V).
30 ntheorem subseteq_refl: ∀A.∀S:Ω \sup A.S ⊆ S.
31 #A; #S; #x; #H; nassumption;
34 ntheorem subseteq_trans: ∀A.∀S1,S2,S3: Ω \sup A. S1 ⊆ S2 → S2 ⊆ S3 → S1 ⊆ S3.
35 #A; #S1; #S2; #S3; #H12; #H23; #x; #H;
36 napply H23; napply H12; nassumption;
39 ndefinition powerset_setoid1: setoid → setoid1.
42 | napply mk_equivalence_relation1
43 [ #A; #B; napply (∀x. iff (x ∈ A) (x ∈ B))
44 | nwhd; #x; #x0; napply mk_iff; #H; nassumption
45 | nwhd; #x; #y; #H; #A; napply mk_iff; #K
46 [ napply (fi ?? (H ?)) | napply (if ?? (H ?)) ]
48 | nwhd; #A; #B; #C; #H1; #H2; #H3; napply mk_iff; #H4
49 [ napply (if ?? (H2 ?)); napply (if ?? (H1 ?)); nassumption
50 | napply (fi ?? (H1 ?)); napply (fi ?? (H2 ?)); nassumption]##]
53 unification hint 0 (∀A.(λx,y.True) (Ω \sup A) (carr1 (powerset_setoid1 A))).
55 ndefinition mem: ∀A:setoid. binary_morphism1 A (powerset_setoid1 A) CPROP.
56 #A; napply mk_binary_morphism1
57 [ napply (λa.λA.a ∈ A)
58 | #a; #a'; #B; #B'; #Ha; #HB; napply mk_iff; #H
59 [ napply (. (†Ha^-1)); (* CSC: notation for ∈ not working *)
60 napply (if ?? (HB ?)); nassumption
61 | napply (. (†Ha)); napply (fi ?? (HB ?)); nassumption]##]
64 unification hint 0 (∀A,x,S. (λx,y.True) (mem_op A x S) (fun21 ??? (mem A) S x)).
66 ndefinition overlaps ≝ λA.λU,V:Ω \sup A.∃x:A.x ∈ U ∧ x ∈ V.
68 interpretation "overlaps" 'overlaps U V = (overlaps ? U V).
70 ndefinition intersects ≝ λA:Type[0].λU,V:A → CProp[0]. λx. U x ∧ V x.
72 interpretation "intersects" 'intersects U V = (intersects ? U V).
74 (* dovrebbe essere un binario? *)
75 ndefinition intersects_ok: ∀A. Ω \sup A → Ω \sup A → Ω \sup A.
76 #A; #U; #V; napply mk_powerset; napply mk_unary_morphism1
77 [ napply (intersects ? (mem_op ? U) (mem_op ? V))
78 | #a; #a'; #H; napply mk_iff; *; #H1; #H2
79 [ nwhd; napply (. ((H^-1‡#)‡(H^-1‡#))); nwhd; napply conj; nassumption
80 | nwhd; napply (. ((H‡#)‡(H‡#))); nwhd; napply conj; nassumption]
83 unification hint 0 (∀A.∀U,V: Ω \sup A.∀w.(λx,y.True)
84 (intersects A U V w) (fun11 ?? (mem_op ? (intersects_ok A U V)) w)).
86 nlemma test: ∀A. ∀U,V: Ω \sup A. ∀x,x':A. x=x' → (U ∩ V) x → (U ∩ V) x'.
87 #A; #U; #V; #x; #x'; #H; #p;
88 nwhd in ⊢ (? ? % % ?);
89 (* l'unification hint non funziona *)
90 nchange with (? ∈ (intersects_ok ? ? ?));
96 ndefinition union ≝ λA.λU,V:Ω \sup A. {x | x ∈ U ∨ x ∈ V }.
98 interpretation "union" 'union U V = (union ? U V).
100 ndefinition singleton ≝ λA:setoid.λa:A.{b | a=b}.
102 interpretation "singleton" 'singl a = (singleton ? a).*)
105 (* qui non funziona una cippa *)
106 ndefinition image: ∀A,B. (carr A → carr B) → Ω \sup A → Ω \sup B ≝
107 λA,B:setoid.λf:carr A → carr B.λSa:Ω \sup A.
108 {y | ∃x. x ∈ Sa ∧ eq_rel (carr B) (eq B) ? ?(*(f x) y*)}.
109 ##[##2: napply (f x); ##|##3: napply y]
110 #a; #a'; #H; nwhd; nnormalize; (* per togliere setoid1_of_setoid *) napply (mk_iff ????);
111 *; #x; #Hx; napply (ex_intro … x)
112 [ napply (. (#‡(#‡#)));
114 ndefinition counter_image: ∀A,B. (A → B) → Ω \sup B → Ω \sup A ≝
115 λA,B,f,Sb. {x | ∃y. y ∈ Sb ∧ f x = y}.