]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambda/pointer_order.ma
- we introduced the pointer_step rc in the perspective of proving
[helm.git] / matita / matita / contribs / lambda / pointer_order.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 "pointer.ma".
16
17 (* POINTER ORDER ************************************************************)
18
19 (* Note: precedence relation on redex pointers: p ≺ q
20          to serve as base for the order relations: p < q and p ≤ q *)
21 inductive pprec: relation ptr ≝
22 | pprec_nil : ∀c,q.   pprec (◊) (c::q)
23 | ppprc_rc  : ∀p,q.   pprec (dx::p) (rc::q)
24 | ppprc_sn  : ∀p,q.   pprec (rc::p) (sn::q)
25 | pprec_comp: ∀c,p,q. pprec p q → pprec (c::p) (c::q)
26 | pprec_skip:         pprec (dx::◊) ◊
27 .
28
29 interpretation "'precedes' on pointers"
30    'prec p q = (pprec p q).
31
32 (* Note: this should go to core_notation *)
33 notation "hvbox(a break ≺ b)"
34    non associative with precedence 45
35    for @{ 'prec $a $b }.
36
37 lemma pprec_fwd_in_whd: ∀p,q. p ≺ q → in_whd q → in_whd p.
38 #p #q #H elim H -p -q // /2 width=1/
39 [ #p #q * #H destruct
40 | #p #q * #H destruct
41 | #c #p #q #_ #IHpq * #H destruct /3 width=1/
42 ]
43 qed-.
44
45 (* Note: this is p < q *)
46 definition plt: relation ptr ≝ TC … pprec.
47
48 interpretation "'less than' on redex pointers"
49    'lt p q = (plt p q).
50
51 lemma plt_step_rc: ∀p,q. p ≺ q → p < q.
52 /2 width=1/
53 qed.
54
55 lemma plt_nil: ∀c,p. ◊ < c::p.
56 /2 width=1/
57 qed.
58
59 lemma plt_skip: dx::◊ < ◊.
60 /2 width=1/
61 qed.
62
63 lemma plt_comp: ∀c,p,q. p < q → c::p < c::q.
64 #c #p #q #H elim H -q /3 width=1/ /3 width=3/
65 qed.
66
67 theorem plt_trans: transitive … plt.
68 /2 width=3/
69 qed-.
70
71 lemma plt_refl: ∀p. p < p.
72 #p elim p -p /2 width=1/
73 @(plt_trans … (dx::◊)) //
74 qed.
75
76 (* Note: this is p ≤ q *)
77 definition ple: relation ptr ≝ star … pprec.
78
79 interpretation "'less or equal to' on redex pointers"
80    'leq p q = (ple p q).
81
82 lemma ple_step_rc: ∀p,q. p ≺ q → p ≤ q.
83 /2 width=1/
84 qed.
85
86 lemma ple_step_sn: ∀p1,p,p2. p1 ≺ p → p ≤ p2 → p1 ≤ p2.
87 /2 width=3/
88 qed-.
89
90 lemma ple_rc: ∀p,q. dx::p ≤ rc::q.
91 /2 width=1/
92 qed.
93
94 lemma ple_sn: ∀p,q. rc::p ≤ sn::q.
95 /2 width=1/
96 qed.
97
98 lemma ple_skip: dx::◊ ≤ ◊.
99 /2 width=1/
100 qed.
101
102 lemma ple_nil: ∀p. ◊ ≤ p.
103 * // /2 width=1/
104 qed.
105
106 lemma ple_comp: ∀p1,p2. p1 ≤ p2 → ∀c. (c::p1) ≤ (c::p2).
107 #p1 #p2 #H elim H -p2 // /3 width=3/
108 qed.
109
110 lemma ple_skip_ple: ∀p. p ≤ ◊ → dx::p ≤ ◊.
111 #p #H @(star_ind_l ??????? H) -p //
112 #p #q #Hpq #_ #H @(ple_step_sn … H) -H /2 width=1/
113 qed.
114
115 theorem ple_trans: transitive … ple.
116 /2 width=3/
117 qed-.
118
119 lemma ple_cons: ∀p,q. dx::p ≤ sn::q.
120 #p #q
121 @(ple_trans … (rc::q)) /2 width=1/
122 qed.
123
124 lemma ple_dichotomy: ∀p1,p2:ptr. p1 ≤ p2 ∨ p2 ≤ p1.
125 #p1 elim p1 -p1
126 [ * /2 width=1/
127 | #c1 #p1 #IHp1 * /2 width=1/
128   * #p2 cases c1 -c1 /2 width=1/
129   elim (IHp1 p2) -IHp1 /3 width=1/
130 ]
131 qed-.
132
133 lemma in_whd_ple_nil: ∀p. in_whd p → p ≤ ◊.
134 #p #H @(in_whd_ind … H) -p // /2 width=1/
135 qed.
136
137 theorem in_whd_ple: ∀p. in_whd p → ∀q. p ≤ q.
138 #p #H @(in_whd_ind … H) -p //
139 #p #_ #IHp * /3 width=1/ * #q /2 width=1/
140 qed.
141
142 lemma ple_nil_inv_in_whd: ∀p. p ≤ ◊ → in_whd p.
143 #p #H @(star_ind_l ??????? H) -p // /2 width=3 by pprec_fwd_in_whd/
144 qed-.
145
146 lemma ple_inv_in_whd: ∀p. (∀q. p ≤ q) → in_whd p.
147 /2 width=1 by ple_nil_inv_in_whd/
148 qed-.