to serve as base for the order relations: p < q and p ≤ q *)
inductive pprec: relation ptr ≝
| pprec_nil : ∀c,q. pprec (◊) (c::q)
-| ppprc_rc : ∀p,q. pprec (dx::p) (rc::q)
-| ppprc_sn : ∀p,q. pprec (dx::p) (sn::q)
+| ppprc_cons: ∀p,q. pprec (dx::p) (sn::q)
| pprec_comp: ∀c,p,q. pprec p q → pprec (c::p) (c::q)
| pprec_skip: pprec (dx::◊) ◊
.
lemma pprec_fwd_in_head: ∀p,q. p ≺ q → in_head q → in_head p.
#p #q #H elim H -p -q // /2 width=1/
[ #p #q * #H destruct
-| #p #q * #H destruct
| #c #p #q #_ #IHpq * #H destruct /3 width=1/
]
qed-.
interpretation "'less than' on redex pointers"
'lt p q = (plt p q).
+lemma plt_step_rc: ∀p,q. p ≺ q → p < q.
+/2 width=1/
+qed.
+
+lemma plt_nil: ∀c,p. ◊ < c::p.
+/2 width=1/
+qed.
+
+lemma plt_skip: dx::◊ < ◊.
+/2 width=1/
+qed.
+
+lemma plt_comp: ∀c,p,q. p < q → c::p < c::q.
+#c #p #q #H elim H -q /3 width=1/ /3 width=3/
+qed.
+
+theorem plt_trans: transitive … plt.
+/2 width=3/
+qed-.
+
+lemma plt_refl: ∀p. p < p.
+#p elim p -p /2 width=1/
+@(plt_trans … (dx::◊)) //
+qed.
+
(* Note: this is p ≤ q *)
definition ple: relation ptr ≝ star … pprec.
#p #q #Hpq #_ #H @(ple_step_sn … H) -H /2 width=1/
qed.
+lemma ple_dichotomy: ∀p1,p2:ptr. p1 ≤ p2 ∨ p2 ≤ p1.
+#p1 elim p1 -p1
+[ * /2 width=1/
+| #c1 #p1 #IHp1 * /2 width=1/
+ * #p2 cases c1 -c1 /2 width=1/
+ elim (IHp1 p2) -IHp1 /3 width=1/
+]
+qed-.
+
lemma in_head_ple_nil: ∀p. in_head p → p ≤ ◊.
#p #H @(in_head_ind … H) -p // /2 width=1/
qed.