]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/static_2/syntax/sh_lt.ma
update in delayed_updating
[helm.git] / matita / matita / contribs / lambdadelta / static_2 / syntax / sh_lt.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 "ground/arith/nat_lt_minus.ma".
16 include "static_2/syntax/sh_props.ma".
17
18 (* SORT HIERARCHY ***********************************************************)
19
20 (* strict monotonicity condition *)
21 record sh_lt (h): Prop ≝
22 {
23   sh_next_lt: ∀s. s < ⇡[h]s
24 }.
25
26 (* Basic properties *********************************************************)
27
28 lemma sh_nexts_le (h): sh_lt h → ∀s,n. s ≤ ⇡*[h,n]s.
29 #h #Hh #s #n @(nat_ind_succ … n) -n [ // ] #n #IH <sh_nexts_succ
30 lapply (sh_next_lt … Hh (⇡*[h,n]s)) #H
31 lapply (nle_nlt_trans … IH H) -IH -H /2 width=2 by nlt_des_le/
32 qed.
33
34 lemma sh_nexts_lt (h): sh_lt h → ∀s,n. s < ⇡*[h,↑n]s.
35 #h #Hh #s #n <sh_nexts_succ
36 lapply (sh_nexts_le … Hh s n) #H
37 @(nle_nlt_trans … H) /2 width=1 by sh_next_lt/
38 qed.
39
40 lemma sh_lt_nexts_inv_lt (h): sh_lt h →
41       ∀s,n1,n2. ⇡*[h,n1]s < ⇡*[h,n2]s → n1 < n2.
42 #h #Hh
43 @pull_2 #n1
44 @(nat_ind_succ … n1) -n1
45 [ #s #n2 @(nat_ind_succ … n2) -n2
46   [ #H elim (nlt_inv_refl … H)
47   | #n2 #_ //
48   ]
49 | #n1 #IH #s #n2 @(nat_ind_succ … n2) -n2
50   [ <sh_nexts_zero #H
51     elim (nlt_inv_refl s)
52     /3 width=3 by sh_nexts_lt, nlt_trans/
53   | #n2 #_ <sh_nexts_succ_next <sh_nexts_succ_next #H
54     /3 width=2 by nlt_succ_bi/
55   ]
56 ]
57 qed-.
58
59 lemma sh_lt_acyclic (h): sh_lt h → sh_acyclic h.
60 #h #Hh
61 @mk_sh_acyclic
62 @pull_2 #n1
63 @(nat_ind_succ … n1) -n1
64 [ #s #n2 @(nat_ind_succ … n2) -n2 [ // ] #n2 #_ <sh_nexts_zero #H
65   elim (nlt_inv_refl s) >H in ⊢ (??%); -H
66   /2 width=1 by sh_nexts_lt/
67 | #n1 #IH #s #n2 @(nat_ind_succ … n2) -n2
68   [ <sh_nexts_zero #H -IH
69     elim (nlt_inv_refl s) <H in ⊢ (??%); -H
70     /2 width=1 by sh_nexts_lt/
71   | #n2 #_ <sh_nexts_succ_next <sh_nexts_succ_next #H
72     lapply (IH … H) -IH -H //
73   ]
74 ]
75 qed.
76
77 lemma sh_lt_dec (h): sh_lt h → sh_decidable h.
78 #h #Hh
79 @mk_sh_decidable #s1 #s2
80 elim (nat_split_lt_ge s2 s1) #Hs
81 [ @or_intror * #n #H destruct
82   @(nlt_ge_false … Hs) /2 width=1 by sh_nexts_le/ (**) (* full auto too slow *)
83 | @(nle_ind_sn … Hs) -s1 -s2 #s1 #s2 #IH #Hs12
84   elim (nat_split_lt_eq_gt s2 (⇡[h]s1)) #Hs21 destruct
85   [ elim (nle_split_lt_eq … Hs12) -Hs12 #Hs12 destruct
86     [ -IH @or_intror * #n #H destruct
87       generalize in match Hs21; -Hs21
88       >sh_nexts_unit #H
89       lapply (sh_lt_nexts_inv_lt … Hh … H) -H #H
90       <(nle_inv_zero_dx n) in Hs12;
91       /2 width=2 by nlt_inv_refl, nle_inv_succ_bi/
92     | /3 width=2 by ex_intro, or_introl/
93     ]
94   | -IH @or_introl @(ex_intro … 𝟏) // (**) (* auto fails *)
95   | lapply (nlt_trans s1 ??? Hs21) [ /2 width=1 by sh_next_lt/ ] -Hs12 #Hs12
96     elim (IH (s2-⇡[h]s1)) -IH
97     [3: /3 width=1 by sh_next_lt, nlt_minus_bi_sn/ ]
98     <nminus_minus_dx_refl_sn [2,4: /2 width=1 by nlt_des_le/ ] -Hs21
99     [ * #n #H destruct
100       @or_introl @(ex_intro … (↑n)) //
101     | #H1 @or_intror * #n #H2 @H1 -H1 destruct
102       generalize in match Hs12; -Hs12
103       >(sh_nexts_zero h s1) in ⊢ (?%?→?); #H
104       lapply (sh_lt_nexts_inv_lt … Hh … H) -H #H
105       >(nlt_des_gen … H) -H
106       @(ex_intro … (↓n)) //
107     ]
108   ]
109 ]
110 qed-.