From 200bb81b91b7c4ebf479906d09c290353c763289 Mon Sep 17 00:00:00 2001 From: Enrico Tassi Date: Sat, 28 Jun 2008 11:28:34 +0000 Subject: [PATCH] some more work to factorize out uninteresting parts of the proof... still to close the key lemma... --- .../contribs/dama/dama/models/q_bars.ma | 4 +- .../contribs/dama/dama/models/q_function.ma | 210 +++++++++--------- .../contribs/dama/dama/models/q_support.ma | 14 ++ 3 files changed, 125 insertions(+), 103 deletions(-) diff --git a/helm/software/matita/contribs/dama/dama/models/q_bars.ma b/helm/software/matita/contribs/dama/dama/models/q_bars.ma index d0d043f47..efa45f7f3 100644 --- a/helm/software/matita/contribs/dama/dama/models/q_bars.ma +++ b/helm/software/matita/contribs/dama/dama/models/q_bars.ma @@ -137,11 +137,11 @@ intro; elim l; simplify; intros; qed. lemma sum_bases_O: - ∀l:q_f.∀x.sum_bases (bars l) x ≤ OQ → x = O. + ∀l.∀x.sum_bases l x ≤ OQ → x = O. intros; cases x in H; [intros; reflexivity] intro; cases (?:False); cases (q_le_cases ?? H); [1: apply (q_lt_corefl OQ); rewrite < H1 in ⊢ (?? %); -|2: apply (q_lt_antisym ??? H1);] clear H H1; cases (bars l); +|2: apply (q_lt_antisym ??? H1);] clear H H1; cases l; simplify; apply q_lt_plus_trans; try apply q_pos_lt_OQ; try apply (sum_bases_ge_OQ []); diff --git a/helm/software/matita/contribs/dama/dama/models/q_function.ma b/helm/software/matita/contribs/dama/dama/models/q_function.ma index d3d63233c..a58a82b1f 100644 --- a/helm/software/matita/contribs/dama/dama/models/q_function.ma +++ b/helm/software/matita/contribs/dama/dama/models/q_function.ma @@ -36,7 +36,7 @@ whd in ⊢ (% → ?); simplify in H3; |2: whd in ⊢ (% → ?); intro; rewrite > H8; clear H8 H4; rewrite > H7; clear H7; rewrite > (?:\fst w1 = O); [reflexivity] symmetry; apply le_n_O_to_eq; - rewrite > (sum_bases_O (mk_q_f init (〈w,OQ〉::bars l1)) (\fst w1)); [apply le_n] + rewrite > (sum_bases_O (〈w,OQ〉::bars l1) (\fst w1)); [apply le_n] clear H6 w2; simplify in H5:(? ? (? ? %)); destruct H3; rewrite > q_d_x_x in H5; assumption;] |2: intros; cases (value l1 input); simplify in ⊢ (? ? (? ? ? %) ?); @@ -52,7 +52,7 @@ whd in ⊢ (% → ?); simplify in H3; simplify in ⊢ (? ? ? (? ? ? (? ? % ? ?))); cut (\fst w1 = S (\fst w2)) as Key; [rewrite > Key; reflexivity;] cut (\fst w2 = O); [2: clear H10; - symmetry; apply le_n_O_to_eq; rewrite > (sum_bases_O l1 (\fst w2)); [apply le_n] + symmetry; apply le_n_O_to_eq; rewrite > (sum_bases_O (bars l1) (\fst w2)); [apply le_n] apply (q_le_trans ??? H9); rewrite < H4; rewrite > q_d_x_x; apply q_eq_to_le; reflexivity;] rewrite > Hcut; clear Hcut H10 H9; simplify in H5 H6; @@ -91,6 +91,95 @@ whd in ⊢ (% → ?); simplify in H3; axiom nth_nil: ∀T,n.∀d:T. nth [] d n = d. + +lemma case1 : + ∀init,st,input,l. + init q_d_sym; rewrite > q_d_noabs; [2: + apply (q_le_trans ? st); apply q_lt_to_le; assumption] +do 2 rewrite > q_elim_minus; rewrite > q_plus_assoc; +intro X; lapply (q_lt_canc_plus_r ??? X) as Y; +simplify in Y; cases (?:False); +apply (q_lt_corefl st); apply (q_lt_trans ??? H1); +apply (q_lt_le_trans ??? Y); rewrite > q_plus_sym; rewrite > q_plus_OQ; +apply q_eq_to_le; reflexivity; +qed. + +lemma case2: + ∀a,l1,init,st,input,n. + init < st → st < input → + sum_bases (a::l1) n + (st-init) ≤ ⅆ[input,init] → + ⅆ[input,st] < sum_bases l1 O + Qpos (\fst a) → + n = O. +intros; cut (input - st < Qpos (\fst a)) as H6';[2: + rewrite < q_d_noabs;[2:apply q_lt_to_le; assumption] + rewrite > q_d_sym; apply (q_lt_le_trans ??? H3); + rewrite > q_plus_sym; rewrite > q_plus_OQ; + apply q_eq_to_le; reflexivity] clear H3; +generalize in match H2; rewrite > q_d_sym; rewrite > q_d_noabs; + [2: apply (q_le_trans ? st); apply q_lt_to_le; assumption] +do 2 rewrite > q_elim_minus; rewrite > q_plus_assoc; intro X; +lapply (q_le_canc_plus_r ??? X) as Y; clear X; +lapply (q_le_inj_plus_r ?? (Qopp st) Y) as X; clear Y; +cut (input + Qopp st < Qpos (\fst a)) as H6''; + [2: rewrite < q_elim_minus; assumption;] clear H6'; +generalize in match (q_le_lt_trans ??? X H6''); clear X H6''; +rewrite < q_plus_assoc; rewrite < q_elim_minus; +rewrite > q_plus_minus; rewrite > q_plus_OQ; cases n; intro X; [reflexivity] +cases (?:False); +apply (q_lt_le_incompat (sum_bases l1 n1) OQ);[2: apply sum_bases_ge_OQ;] +apply (q_lt_canc_plus_r ?? (Qpos (\fst a))); +rewrite >(q_plus_sym OQ); rewrite > q_plus_OQ; apply X; +qed. + +lemma case3: + ∀init,st,input,l1,a,n. + init q_elim_minus; + rewrite < q_plus_assoc; rewrite > (q_plus_sym (Qopp ?)); + rewrite < q_elim_minus; rewrite > q_plus_minus; rewrite > q_plus_OQ; + apply q_eq_to_le; reflexivity;] clear H3; + rewrite > q_elim_minus; apply (q_lt_canc_plus_r ?? ⅆ[input,st]); + rewrite < q_plus_assoc; rewrite > (q_plus_sym (Qopp ?)); + rewrite < q_elim_minus; rewrite > q_plus_minus; rewrite > q_plus_OQ; + apply (q_le_lt_trans ??? H7'); clear H7'; rewrite > q_elim_minus; + rewrite > q_plus_sym; apply q_lt_inj_plus_r; + rewrite > q_plus_sym; apply q_lt_plus; rewrite > q_elim_opp; + rewrite > q_plus_sym; apply (q_lt_canc_plus_r ?? (Qpos a)); + rewrite < q_plus_assoc; rewrite > (q_plus_sym (Qopp ?)); + rewrite < q_elim_minus; rewrite > q_plus_minus; rewrite > q_plus_OQ; + apply (q_lt_le_trans ??? H2); rewrite > (q_plus_sym OQ); rewrite > q_plus_OQ; + rewrite > q_plus_sym; apply q_eq_to_le; reflexivity;] +generalize in match Hcut; clear H2 H3 Hcut; +rewrite > q_d_sym; rewrite > q_d_noabs; [2:apply q_lt_to_le; assumption] +rewrite > q_d_sym; rewrite > q_d_noabs; [2: apply (q_le_trans ? st); apply q_lt_to_le; assumption] +rewrite < q_plus_sym; rewrite < q_elim_minus; +rewrite > (q_elim_minus input init); +rewrite > q_minus_distrib; rewrite > q_elim_opp; +rewrite > (q_elim_minus input st); +rewrite > q_minus_distrib; rewrite > q_elim_opp; +repeat rewrite > q_elim_minus; +rewrite < q_plus_assoc in ⊢ (??% → ?); +rewrite > (q_plus_sym (Qopp input) init); +rewrite > q_plus_assoc; +rewrite < q_plus_assoc in ⊢ (??(?%?) → ?); +rewrite > (q_plus_sym (Qopp init) init); +rewrite < (q_elim_minus init); rewrite >q_plus_minus; +rewrite > q_plus_OQ; rewrite > (q_plus_sym st); +rewrite < q_plus_assoc; +rewrite < (q_plus_OQ (Qopp input + st)) in ⊢ (??% → ?); +rewrite > (q_plus_sym ? OQ); intro X; +lapply (q_lt_canc_plus_r ??? X) as Y; clear X; +apply (q_lt_le_incompat ?? Y); apply sum_bases_ge_OQ; +qed. + lemma key: ∀init,input,l1,w1,w2,w. Qpos w = start l1 - init → @@ -101,109 +190,28 @@ lemma key: sum_bases (bars l1) w2 ≤ ⅆ[input,start l1] → ⅆ[input,start l1] < sum_bases (bars l1) (S w2) → \snd (nth (bars l1) ▭ w2) = \snd (nth (〈w,OQ〉::bars l1) ▭ w1). -intros 4 (init input l); cases l (st l); +intros 3 (init input l); cases l (st l); change in match (start (mk_q_f st l)) with st; change in match (bars (mk_q_f st l)) with l; -elim l; +elim l; clear l; [1: rewrite > nth_nil; cases w1 in H4; - [1: rewrite > q_d_sym; rewrite > q_d_noabs; [2: - apply (q_le_trans ? st); apply q_lt_to_le; assumption] - do 2 rewrite > q_elim_minus; rewrite > q_plus_assoc; - intro X; lapply (q_lt_canc_plus_r ??? X) as Y; - simplify in Y; cases (?:False); - apply (q_lt_corefl st); apply (q_lt_trans ??? H2); - apply (q_lt_le_trans ??? Y); rewrite > q_plus_sym; rewrite > q_plus_OQ; - apply q_eq_to_le; reflexivity; + [1: intro X; cases (case1 ?????? X); assumption; |2: intros; simplify; rewrite > nth_nil; reflexivity;] -|2: FACTORIZE w1>0 - - (* interesting case: init < start < input *) - intro; cases H8; clear H8; rewrite > H11; rewrite > H7; clear H11 H7; - simplify in H5 H6 ⊢ (? ? ? (? ? ? (? ? % ? ?))); - elim (\fst w2) in H9 H10; - [1: elim (\fst w1) in H5 H6; - [1: cases (?:False); clear H5 H8 H7; - apply (q_lt_antisym input (start l1)); [2: assumption] - rewrite > q_d_sym in H6; rewrite > q_d_noabs in H6; - [2: apply q_lt_to_le; assumption] - rewrite > q_plus_sym in H6; rewrite > q_plus_OQ in H6; - rewrite > H2 in H6; apply (q_lt_canc_plus_r ?? (Qopp init)); - do 2 rewrite < q_elim_minus; assumption; - |2: - - cut (\fst w1 = S (\fst w2)) as Key; [rewrite > Key; reflexivity;] - cases (\fst w1) in H5 H6; intros; [1: - cases (?:False); clear H5 H9 H10; - apply (q_lt_antisym input (start l1)); [2: assumption] - rewrite > q_d_sym in H6; rewrite > q_d_noabs in H6; - [2: apply q_lt_to_le; assumption] - rewrite > q_plus_sym in H6; rewrite > q_plus_OQ in H6; - rewrite > H2 in H6; apply (q_lt_canc_plus_r ?? (Qopp init)); - do 2 rewrite < q_elim_minus; assumption;] - apply eq_f; - cut (sum_bases (bars l1) (\fst w2) < sum_bases (bars l1) (S n));[2: - apply (q_le_lt_trans ??? H9); - apply (q_lt_trans ??? ? H6); - rewrite > q_d_sym; rewrite > q_d_noabs; [2:apply q_lt_to_le;assumption] - rewrite > q_d_sym; rewrite > q_d_noabs; [2:apply q_lt_to_le;assumption] - do 2 rewrite > q_elim_minus; rewrite > (q_plus_sym ? (Qopp init)); - apply q_lt_plus; rewrite > q_plus_sym; - rewrite > q_elim_minus; rewrite < q_plus_assoc; - rewrite < q_elim_minus; rewrite > q_plus_minus; - rewrite > q_plus_OQ; apply q_lt_opp_opp; assumption] - clear H9 H6; - cut (ⅆ[input,init] - Qpos w = ⅆ[input,start l1]);[2: - rewrite > q_d_sym; rewrite > q_d_noabs; [2:apply q_lt_to_le;assumption] - rewrite > q_d_sym; rewrite > q_d_noabs; [2:apply q_lt_to_le;assumption] - rewrite > H2; rewrite > (q_elim_minus (start ?)); - rewrite > q_minus_distrib; rewrite > q_elim_opp; - do 2 rewrite > q_elim_minus; - do 2 rewrite < q_plus_assoc; - rewrite > (q_plus_sym ? init); - rewrite > (q_plus_assoc ? init); - rewrite > (q_plus_sym ? init); - rewrite < (q_elim_minus init); rewrite > q_plus_minus; - rewrite > (q_plus_sym OQ); rewrite > q_plus_OQ; - rewrite < q_elim_minus; reflexivity;] - cut (sum_bases (bars l1) n < sum_bases (bars l1) (S (\fst w2)));[2: - apply (q_le_lt_trans ???? H10); rewrite < Hcut1; - rewrite > q_elim_minus; apply q_le_minus_r; rewrite > q_elim_opp; - assumption;] clear Hcut1 H5 H10; - generalize in match Hcut;generalize in match Hcut2;clear Hcut Hcut2; - apply (nat_elim2 ???? n (\fst w2)); - [3: intros (x y); apply eq_f; apply H5; clear H5; - [1: clear H7; apply sum_bases_lt_canc; assumption; - |2: clear H6; ] - |2: intros; cases (?:False); clear H6; - cases n1 in H5; intro; - [1: apply (q_lt_corefl ? H5); - |2: cases (bars l1) in H5; intro; - [1: simplify in H5; - apply (q_lt_le_incompat ?? (q_lt_canc_plus_r ??? H5)); - apply q_le_plus_trans; [apply sum_bases_ge_OQ] - apply q_le_OQ_Qpos; - |2: simplify in H5:(??%); - lapply (q_lt_canc_plus_r (sum_bases l (S n2)) ?? H5) as X; - apply (q_lt_le_incompat ?? X); apply sum_bases_ge_OQ]] - |1: intro; cases n1 [intros; reflexivity] intros; cases (?:False); - elim n2 in H5 H6; - - - elim (bars l1) 0; - [1: intro; elim n1; [reflexivity] cases (?:False); - - - intros; clear H5; - elim n1 in H6; [reflexivity] cases (?:False); - [1: apply (q_lt_corefl ? H5); - |2: cases (bars l1) in H5; intro; - [1: simplify in H5; - apply (q_lt_le_incompat ?? (q_lt_canc_plus_r ??? H5)); - apply q_le_plus_trans; [apply sum_bases_ge_OQ] - apply q_le_OQ_Qpos; - |2: simplify in H5:(??%); - lapply (q_lt_canc_plus_r (sum_bases l (S n2)) ?? H5) as X; - apply (q_lt_le_incompat ?? X); apply sum_bases_ge_OQ]] +|2: cases w1 in H4 H5; clear w1; + [1: intros (Y X); cases (case1 ?????? X); assumption; + |2: intros; simplify in H4 H5 H7 ⊢ %; + generalize in match H6; generalize in match H7; + generalize in match H4; generalize in match H5; clear H4 H5 H6 H7; + apply (nat_elim2 ???? w2 n); clear w2 n; intros; + [1: rewrite > (case2 a l1 init st input n); [reflexivity] + try rewrite < H1; assumption; + |2: simplify in H4 H7; cases (case3 ???????? H4 H7); assumption; + |3: (* dipende se vanno oltre la lunghezza di l1, + forse dovevo gestire il caso prima dell'induzione *) + simplify in ⊢ (? ? (? ? ? %) ?); + rewrite > (H (S m) ? w); [reflexivity] try assumption; +STOP + qed. diff --git a/helm/software/matita/contribs/dama/dama/models/q_support.ma b/helm/software/matita/contribs/dama/dama/models/q_support.ma index 2073c8a77..9d73f7ab9 100644 --- a/helm/software/matita/contribs/dama/dama/models/q_support.ma +++ b/helm/software/matita/contribs/dama/dama/models/q_support.ma @@ -109,3 +109,17 @@ rewrite > q_plus_minus; do 2 rewrite > q_plus_OQ; assumption; qed. +lemma q_le_inj_plus_r: + ∀x,y,z:Q.x ≤ y → x + z ≤ y + z. +intros;cases (q_le_cases ?? H); +[1: rewrite > H1; apply q_eq_to_le; reflexivity; +|2: apply q_lt_to_le; apply q_lt_inj_plus_r; assumption;] +qed. + +lemma q_le_canc_plus_r: + ∀x,y,z:Q.x + z ≤ y + z → x ≤ y. +intros; lapply (q_le_inj_plus_r ?? (Qopp z) H) as H1; +do 2 rewrite < q_plus_assoc in H1; +rewrite < q_elim_minus in H1; rewrite > q_plus_minus in H1; +do 2 rewrite > q_plus_OQ in H1; assumption; +qed. -- 2.39.2