]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/ground_2/lib/relations.ma
- ground_2: rtmap: disjointness relation
[helm.git] / matita / matita / contribs / lambdadelta / ground_2 / lib / relations.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 include "basics/relations.ma".
16 include "ground_2/xoa/xoa_props.ma".
17
18 (* GENERIC RELATIONS ********************************************************)
19
20 (* Inclusion ****************************************************************)
21
22 definition subR2 (S1) (S2): relation (relation2 S1 S2) ≝
23            λR1,R2. (∀a1,a2. R1 a1 a2 → R2 a1 a2).
24
25 interpretation "2-relation inclusion"
26    'subseteq R1 R2 = (subR2 ?? R1 R2).
27
28 definition subR3 (S1) (S2) (S3): relation (relation3 S1 S2 S3) ≝
29            λR1,R2. (∀a1,a2,a3. R1 a1 a2 a3 → R2 a1 a2 a3).
30
31 interpretation "3-relation inclusion"
32    'subseteq R1 R2 = (subR3 ??? R1 R2).
33
34 (* Properties of relations **************************************************)
35
36 definition relation5: Type[0] → Type[0] → Type[0] → Type[0] → Type[0] → Type[0]
37 ≝ λA,B,C,D,E.A→B→C→D→E→Prop.
38
39 definition relation6: Type[0] → Type[0] → Type[0] → Type[0] → Type[0] → Type[0] → Type[0]
40 ≝ λA,B,C,D,E,F.A→B→C→D→E→F→Prop.
41
42 (**) (* we dont use "∀a. reflexive … (R a)" since auto seems to dislike repeatd δ-expansion *)  
43 definition c_reflexive (A) (B): predicate (relation3 A B B) ≝
44                                 λR. ∀a,b. R a b b.
45
46 definition Decidable: Prop → Prop ≝ λR. R ∨ (R → ⊥).
47
48 definition Transitive: ∀A. ∀R: relation A. Prop ≝ λA,R.
49                        ∀a1,a0. R a1 a0 → ∀a2. R a0 a2 → R a1 a2.
50
51 definition left_cancellable: ∀A. ∀R: relation A. Prop ≝ λA,R.
52                              ∀a0,a1. R a0 a1 → ∀a2. R a0 a2 → R a1 a2.
53
54 definition right_cancellable: ∀A. ∀R: relation A. Prop ≝ λA,R.
55                               ∀a1,a0. R a1 a0 → ∀a2. R a2 a0 → R a1 a2.
56
57 definition pw_confluent2: ∀A. relation A → relation A → predicate A ≝ λA,R1,R2,a0.
58                           ∀a1. R1 a0 a1 → ∀a2. R2 a0 a2 →
59                           ∃∃a. R2 a1 a & R1 a2 a.
60
61 definition confluent2: ∀A. relation (relation A) ≝ λA,R1,R2.
62                        ∀a0. pw_confluent2 A R1 R2 a0.
63
64 definition transitive2: ∀A. ∀R1,R2: relation A. Prop ≝ λA,R1,R2.
65                         ∀a1,a0. R1 a1 a0 → ∀a2. R2 a0 a2 →
66                         ∃∃a. R2 a1 a & R1 a a2.
67
68 definition bi_confluent: ∀A,B. ∀R: bi_relation A B. Prop ≝ λA,B,R.
69                          ∀a0,a1,b0,b1. R a0 b0 a1 b1 → ∀a2,b2. R a0 b0 a2 b2 →
70                          ∃∃a,b. R a1 b1 a b & R a2 b2 a b.
71
72 definition lsub_trans: ∀A,B. relation2 (A→relation B) (relation A) ≝ λA,B,R1,R2.
73                        ∀L2,T1,T2. R1 L2 T1 T2 → ∀L1. R2 L1 L2 → R1 L1 T1 T2.
74
75 definition s_r_confluent1: ∀A,B. relation2 (A→relation B) (B→relation A) ≝ λA,B,R1,R2.
76                            ∀L1,T1,T2. R1 L1 T1 T2 → ∀L2. R2 T1 L1 L2 → R2 T2 L1 L2.
77
78 definition is_mono: ∀B:Type[0]. predicate (predicate B) ≝ 
79                     λB,R. ∀b1. R b1 → ∀b2. R b2 → b1 = b2.
80
81 definition is_inj2: ∀A,B:Type[0]. predicate (relation2 A B) ≝ 
82                     λA,B,R. ∀a1,b. R a1 b → ∀a2. R a2 b → a1 = a2.
83
84 (* Normal form and strong normalization *************************************)
85
86 definition NF: ∀A. relation A → relation A → predicate A ≝
87    λA,R,S,a1. ∀a2. R a1 a2 → S a1 a2.
88
89 definition NF_dec: ∀A. relation A → relation A → Prop ≝
90                    λA,R,S. ∀a1. NF A R S a1 ∨
91                    ∃∃a2. R … a1 a2 & (S a1 a2 → ⊥).
92
93 inductive SN (A) (R,S:relation A): predicate A ≝
94 | SN_intro: ∀a1. (∀a2. R a1 a2 → (S a1 a2 → ⊥) → SN A R S a2) → SN A R S a1
95 .
96
97 lemma NF_to_SN: ∀A,R,S,a. NF A R S a → SN A R S a.
98 #A #R #S #a1 #Ha1
99 @SN_intro #a2 #HRa12 #HSa12
100 elim HSa12 -HSa12 /2 width=1 by/
101 qed.
102
103 definition NF_sn: ∀A. relation A → relation A → predicate A ≝
104    λA,R,S,a2. ∀a1. R a1 a2 → S a1 a2.
105
106 inductive SN_sn (A) (R,S:relation A): predicate A ≝
107 | SN_sn_intro: ∀a2. (∀a1. R a1 a2 → (S a1 a2 → ⊥) → SN_sn A R S a1) → SN_sn A R S a2
108 .
109
110 lemma NF_to_SN_sn: ∀A,R,S,a. NF_sn A R S a → SN_sn A R S a.
111 #A #R #S #a2 #Ha2
112 @SN_sn_intro #a1 #HRa12 #HSa12
113 elim HSa12 -HSa12 /2 width=1 by/
114 qed.
115
116 (* Relations on unboxed triples *********************************************)
117
118 definition tri_RC: ∀A,B,C. tri_relation A B C → tri_relation A B C ≝
119                    λA,B,C,R,a1,b1,c1,a2,b2,c2. R … a1 b1 c1 a2 b2 c2 ∨
120                    ∧∧ a1 = a2 & b1 = b2 & c1 = c2.
121
122 lemma tri_RC_reflexive: ∀A,B,C,R. tri_reflexive A B C (tri_RC … R).
123 /3 width=1 by and3_intro, or_intror/ qed.