1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "ground/notation/relations/ringeq_3.ma".
16 include "ground/lib/stream.ma".
18 (* EXTENSIONAL EQUIVALENCE FOR STREAMS **************************************)
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)
25 "extensional equivalence (streams)"
26 'RingEq A t1 t2 = (stream_eq A t1 t2).
28 definition stream_eq_repl (A) (R:relation …) ≝
29 ∀t1,t2. t1 ≗{A} t2 → R t1 t2.
31 definition stream_eq_repl_back (A) (R:predicate …) ≝
32 ∀t1. R t1 → ∀t2. t1 ≗{A} t2 → R t2.
34 definition stream_eq_repl_fwd (A) (R:predicate …) ≝
35 ∀t1. R t1 → ∀t2. t2 ≗{A} t1 → R t2.
37 (* Basic inversions *********************************************************)
39 lemma stream_eq_inv_cons: ∀A,t1,t2. t1 ≗{A} t2 →
40 ∀u1,u2,a1,a2. a1⨮u1 = t1 → a2⨮u2 = t2 →
43 #t1 #t2 #b1 #b2 #Hb #Ht #u1 #u2 #a1 #a2 #H1 #H2 destruct /2 width=1 by conj/
46 (* Basic constructions ******************************************************)
48 corec lemma stream_eq_refl: ∀A. reflexive … (stream_eq A).
49 #A * #b #t @stream_eq_cons //
52 corec lemma stream_eq_sym: ∀A. symmetric … (stream_eq A).
54 #t1 #t2 #b1 #b2 #Hb #Ht @stream_eq_cons /2 width=1 by/
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-.
60 (* Main constructions *******************************************************)
62 corec theorem stream_eq_trans: ∀A. Transitive … (stream_eq A).
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/
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-.
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-.