]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/ground/relocation/pstream_istot.ma
propagating the arithmetics library, partial commit
[helm.git] / matita / matita / contribs / lambdadelta / ground / relocation / pstream_istot.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.tcs.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/notation/functions/apply_2.ma".
16 include "ground/arith/pnat_le_plus.ma".
17 include "ground/relocation/pstream_eq.ma".
18 include "ground/relocation/rtmap_istot.ma".
19
20 (* RELOCATION N-STREAM ******************************************************)
21
22 rec definition apply (i: pnat) on i: rtmap → pnat.
23 * #p #f cases i -i
24 [ @p
25 | #i lapply (apply i f) -apply -i -f
26   #i @(i+p)
27 ]
28 defined.
29
30 interpretation "functional application (nstream)"
31    'Apply f i = (apply i f).
32
33 (* Specific properties on at ************************************************)
34
35 lemma at_O1: ∀i2,f. @❪𝟏, i2⨮f❫ ≘ i2.
36 #i2 elim i2 -i2 /2 width=5 by at_refl, at_next/
37 qed.
38
39 lemma at_S1: ∀p,f,i1,i2. @❪i1, f❫ ≘ i2 → @❪↑i1, p⨮f❫ ≘ i2+p.
40 #p elim p -p /3 width=7 by at_push, at_next/
41 qed.
42
43 lemma at_total: ∀i1,f. @❪i1, f❫ ≘ f@❨i1❩.
44 #i1 elim i1 -i1
45 [ * // | #i #IH * /3 width=1 by at_S1/ ]
46 qed.
47
48 lemma at_istot: ∀f. 𝐓❪f❫.
49 /2 width=2 by ex_intro/ qed.
50
51 lemma at_plus2: ∀f,i1,i,p,q. @❪i1, p⨮f❫ ≘ i → @❪i1, (p+q)⨮f❫ ≘ i+q.
52 #f #i1 #i #p #q #H elim q -q
53 /2 width=5 by at_next/
54 qed.
55
56 (* Specific inversion lemmas on at ******************************************)
57
58 lemma at_inv_O1: ∀f,p,i2. @❪𝟏, p⨮f❫ ≘ i2 → p = i2.
59 #f #p elim p -p /2 width=6 by at_inv_ppx/
60 #p #IH #i2 #H elim (at_inv_xnx … H) -H [|*: // ]
61 #j2 #Hj * -i2 /3 width=1 by eq_f/
62 qed-.
63
64 lemma at_inv_S1: ∀f,p,j1,i2. @❪↑j1, p⨮f❫ ≘ i2 →
65                  ∃∃j2. @❪j1, f❫ ≘ j2 & j2+p = i2.
66 #f #p elim p -p /2 width=5 by at_inv_npx/
67 #p #IH #j1 #i2 #H elim (at_inv_xnx … H) -H [|*: // ]
68 #j2 #Hj * -i2 elim (IH … Hj) -IH -Hj
69 #i2 #Hi * -j2 /2 width=3 by ex2_intro/
70 qed-.
71
72 lemma at_inv_total: ∀f,i1,i2. @❪i1, f❫ ≘ i2 → f@❨i1❩ = i2.
73 /2 width=6 by at_mono/ qed-.
74
75 (* Spercific forward lemmas on at *******************************************)
76
77 lemma at_increasing_plus: ∀f,p,i1,i2. @❪i1, p⨮f❫ ≘ i2 → i1 + p ≤ ↑i2.
78 #f #p *
79 [ #i2 #H <(at_inv_O1 … H) -i2 //
80 | #i1 #i2 #H elim (at_inv_S1 … H) -H
81   #j1 #Ht * -i2 <pplus_succ_sn 
82   /4 width=2 by at_increasing, ple_plus_bi_dx, ple_succ_bi/
83 ]
84 qed-.
85
86 lemma at_fwd_id: ∀f,p,i. @❪i, p⨮f❫ ≘ i → 𝟏 = p.
87 #f #p #i #H elim (at_fwd_id_ex … H) -H
88 #g #H elim (push_inv_seq_dx … H) -H //
89 qed-.
90
91 (* Basic properties *********************************************************)
92
93 lemma apply_O1: ∀p,f. (p⨮f)@❨𝟏❩ = p.
94 // qed.
95
96 lemma apply_S1: ∀p,f,i. (p⨮f)@❨↑i❩ = f@❨i❩+p.
97 // qed.
98
99 lemma apply_eq_repl (i): eq_repl … (λf1,f2. f1@❨i❩ = f2@❨i❩).
100 #i elim i -i [2: #i #IH ] * #p1 #f1 * #p2 #f2 #H
101 elim (eq_inv_seq_aux … H) -H #Hp #Hf //
102 >apply_S1 >apply_S1 /3 width=1 by eq_f2/
103 qed.
104
105 lemma apply_S2: ∀f,i. (↑f)@❨i❩ = ↑(f@❨i❩).
106 * #p #f * //
107 qed.
108
109 (* Main inversion lemmas ****************************************************)
110
111 theorem apply_inj: ∀f,i1,i2,j. f@❨i1❩ = j → f@❨i2❩ = j → i1 = i2.
112 /2 width=4 by at_inj/ qed-.
113
114 corec theorem nstream_eq_inv_ext: ∀f1,f2. (∀i. f1@❨i❩ = f2@❨i❩) → f1 ≗ f2.
115 * #p1 #f1 * #p2 #f2 #Hf @stream_eq_cons
116 [ @(Hf (𝟏))
117 | @nstream_eq_inv_ext -nstream_eq_inv_ext #i
118   lapply (Hf (𝟏)) >apply_O1 >apply_O1 #H destruct
119   lapply (Hf (↑i)) >apply_S1 >apply_S1 #H
120   /3 width=2 by eq_inv_pplus_bi_dx, eq_inv_psucc_bi/
121 ]
122 qed-.