]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambda/terms/pointer.ma
lambda: some refactoring + support for subsets of subterms started
[helm.git] / matita / matita / contribs / lambda / terms / pointer.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 "terms/term.ma".
16
17 (* POINTER ******************************************************************)
18
19 (* Policy: pointer step metavariables: c *)
20 (* Note: this is a step of a path in the tree representation of a term:
21          rc (rectus)  : proceed on the argument of an abstraction
22          sn (sinister): proceed on the left argument of an application
23          dx (dexter)  : proceed on the right argument of an application
24 *)
25 inductive ptr_step: Type[0] ≝
26 | rc: ptr_step
27 | sn: ptr_step
28 | dx: ptr_step
29 .
30
31 definition is_dx: predicate ptr_step ≝ λc. dx = c.
32
33 (* Policy: pointer metavariables: p, q *)
34 (* Note: this is a path in the tree representation of a term, heading to a redex *)
35 definition ptr: Type[0] ≝ list ptr_step.
36
37 (* Note: a redex is "in whd" when is not under an abstraction nor in the lefr argument of an application *)
38 definition in_whd: predicate ptr ≝ All … is_dx.
39
40 lemma in_whd_ind: ∀R:predicate ptr. R (◊) →
41                   (∀p. in_whd p → R p → R (dx::p)) →
42                   ∀p. in_whd p → R p.
43 #R #H #IH #p elim p -p // -H *
44 #p #IHp * #H1 #H2 destruct /3 width=1/
45 qed-.
46
47 definition compatible_rc: predicate (ptr→relation term) ≝ λR.
48                           ∀p,A1,A2. R p A1 A2 → R (rc::p) (𝛌.A1) (𝛌.A2).
49
50 definition compatible_sn: predicate (ptr→relation term) ≝ λR.
51                           ∀p,B1,B2,A. R p B1 B2 → R (sn::p) (@B1.A) (@B2.A).
52
53 definition compatible_dx: predicate (ptr→relation term) ≝ λR.
54                           ∀p,B,A1,A2. R p A1 A2 → R (dx::p) (@B.A1) (@B.A2).