]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/ground/lib/stream_eq.ma
propagating the arithmetics library, partial commit
[helm.git] / matita / matita / contribs / lambdadelta / ground / lib / stream_eq.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/notation/relations/ringeq_3.ma".
16 include "ground/lib/stream.ma".
17
18 (* EXTENSIONAL EQUIVALENCE FOR STREAMS **************************************)
19
20 coinductive stream_eq (A): relation (stream A) ≝
21 | stream_eq_cons: ∀t1,t2,b1,b2. b1 = b2 → stream_eq A t1 t2 → stream_eq A (b1⨮t1) (b2⨮t2)
22 .
23
24 interpretation
25   "extensional equivalence (streams)"
26   'RingEq A t1 t2 = (stream_eq A t1 t2).
27
28 definition stream_eq_repl (A) (R:relation …) ≝
29            ∀t1,t2. t1 ≗{A} t2 → R t1 t2.
30
31 definition stream_eq_repl_back (A) (R:predicate …) ≝
32            ∀t1. R t1 → ∀t2. t1 ≗{A} t2 → R t2.
33
34 definition stream_eq_repl_fwd (A) (R:predicate …) ≝
35            ∀t1. R t1 → ∀t2. t2 ≗{A} t1 → R t2.
36
37 (* Basic inversions *********************************************************)
38
39 lemma stream_eq_inv_cons: ∀A,t1,t2. t1 ≗{A} t2 →
40                           ∀u1,u2,a1,a2. a1⨮u1 = t1 → a2⨮u2 = t2 →
41                           u1 ≗ u2 ∧ a1 = a2.
42 #A #t1 #t2 * -t1 -t2
43 #t1 #t2 #b1 #b2 #Hb #Ht #u1 #u2 #a1 #a2 #H1 #H2 destruct /2 width=1 by conj/
44 qed-.
45
46 (* Basic constructions ******************************************************)
47
48 corec lemma stream_eq_refl: ∀A. reflexive … (stream_eq A).
49 #A * #b #t @stream_eq_cons //
50 qed.
51
52 corec lemma stream_eq_sym: ∀A. symmetric … (stream_eq A).
53 #A #t1 #t2 * -t1 -t2
54 #t1 #t2 #b1 #b2 #Hb #Ht @stream_eq_cons /2 width=1 by/
55 qed-.
56
57 lemma stream_eq_repl_sym: ∀A,R. stream_eq_repl_back A R → stream_eq_repl_fwd A R.
58 /3 width=3 by stream_eq_sym/ qed-.
59
60 (* Main constructions *******************************************************)
61
62 corec theorem stream_eq_trans: ∀A. Transitive … (stream_eq A).
63 #A #t1 #t * -t1 -t
64 #t1 #t #b1 #b * #Ht1 * #b2 #t2 #H cases (stream_eq_inv_cons A … H) -H -b
65 /3 width=7 by stream_eq_cons/
66 qed-.
67
68 theorem stream_eq_canc_sn: ∀A,t,t1,t2. t ≗ t1 → t ≗ t2 → t1 ≗{A} t2.
69 /3 width=3 by stream_eq_trans, stream_eq_sym/ qed-.
70
71 theorem stream_eq_canc_dx: ∀A,t,t1,t2. t1 ≗ t → t2 ≗ t → t1 ≗{A} t2.
72 /3 width=3 by stream_eq_trans, stream_eq_sym/ qed-.