X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=matita%2Fmatita%2Fcontribs%2Flambdadelta%2Fground%2Flib%2Flist_length.ma;h=e4df2ae4df2637746456ae41874fec02c9d0740a;hb=6f1b6f85a78d4c8da42f035f433fe4b85962bd9b;hp=ab736bdd4196e6733d764464d2357a0fbb926c17;hpb=68b4f2490c12139c03760b39895619e63b0f38c9;p=helm.git diff --git a/matita/matita/contribs/lambdadelta/ground/lib/list_length.ma b/matita/matita/contribs/lambdadelta/ground/lib/list_length.ma index ab736bdd4..e4df2ae4d 100644 --- a/matita/matita/contribs/lambdadelta/ground/lib/list_length.ma +++ b/matita/matita/contribs/lambdadelta/ground/lib/list_length.ma @@ -12,44 +12,55 @@ (* *) (**************************************************************************) -include "ground/lib/arith.ma". +include "ground/notation/functions/verticalbars_1.ma". include "ground/lib/list.ma". +include "ground/arith/nat_succ.ma". -(* LENGTH OF A LIST *********************************************************) +(* LENGTH FOR LISTS *********************************************************) -rec definition length A (l:list A) on l ≝ match l with -[ nil ⇒ 0 -| cons _ l ⇒ ↑(length A l) +rec definition list_length A (l:list A) on l ≝ match l with +[ list_empty ⇒ 𝟎 +| list_lcons _ l ⇒ ↑(list_length A l) ]. -interpretation "length (list)" - 'card l = (length ? l). +interpretation + "length (lists)" + 'VerticalBars l = (list_length ? l). -(* Basic properties *********************************************************) +(* Basic constructions ******************************************************) -lemma length_nil (A:Type[0]): |nil A| = 0. +lemma list_length_empty (A:Type[0]): + ❘list_empty A❘ = 𝟎. // qed. -lemma length_cons (A:Type[0]) (l:list A) (a:A): |a⨮l| = ↑|l|. +lemma list_length_lcons (A:Type[0]) (l:list A) (a:A): + ❘a⨮l❘ = ↑❘l❘. // qed. -(* Basic inversion lemmas ***************************************************) +(* Basic inversions *********************************************************) -lemma length_inv_zero_dx (A:Type[0]) (l:list A): |l| = 0 → l = Ⓔ. -#A * // #a #l >length_cons #H destruct +lemma list_length_inv_zero_dx (A:Type[0]) (l:list A): + ❘l❘ = 𝟎 → l = ⓔ. +#A * // #a #l >list_length_lcons #H +elim (eq_inv_nsucc_zero … H) qed-. -lemma length_inv_zero_sn (A:Type[0]) (l:list A): 0 = |l| → l = Ⓔ. -/2 width=1 by length_inv_zero_dx/ qed-. +lemma list_length_inv_zero_sn (A:Type[0]) (l:list A): + (𝟎) = ❘l❘ → l = ⓔ. +/2 width=1 by list_length_inv_zero_dx/ qed-. -lemma length_inv_succ_dx (A:Type[0]) (l:list A) (x): |l| = ↑x → - ∃∃tl,a. x = |tl| & l = a ⨮ tl. +lemma list_length_inv_succ_dx (A:Type[0]) (l:list A) (x): + ❘l❘ = ↑x → + ∃∃tl,a. x = ❘tl❘ & l = a ⨮ tl. #A * -[ #x >length_nil #H destruct -| #a #l #x >length_cons #H destruct /2 width=4 by ex2_2_intro/ +[ #x >list_length_empty #H + elim (eq_inv_zero_nsucc … H) +| #a #l #x >list_length_lcons #H + /3 width=4 by eq_inv_nsucc_bi, ex2_2_intro/ ] qed-. -lemma length_inv_succ_sn (A:Type[0]) (l:list A) (x): ↑x = |l| → - ∃∃tl,a. x = |tl| & l = a ⨮ tl. -/2 width=1 by length_inv_succ_dx/ qed. +lemma list_length_inv_succ_sn (A:Type[0]) (l:list A) (x): + ↑x = ❘l❘ → + ∃∃tl,a. x = ❘tl❘ & l = a ⨮ tl. +/2 width=1 by list_length_inv_succ_dx/ qed-.