X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fmatita%2Fcontribs%2Fdama%2Fdama%2Fmodels%2Fq_bars.ma;h=de39589073d51967d81528130c9afa59c4e858c4;hb=b5564e329d48efa6c2ca01da18203def26a70294;hp=b5c62219c616edbca96710eaaa4cf35b3e3126e0;hpb=8f4162a9db17a597d4fba49eb957009fc0268378;p=helm.git 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 b5c62219c..de3958907 100644 --- a/helm/software/matita/contribs/dama/dama/models/q_bars.ma +++ b/helm/software/matita/contribs/dama/dama/models/q_bars.ma @@ -15,14 +15,14 @@ include "nat_ordered_set.ma". include "models/q_support.ma". include "models/list_support.ma". -include "cprop_connectives.ma". +include "logic/cprop_connectives.ma". -definition bar â â à â. +definition bar â â à (â à â). notation < "\rationals \sup 2" non associative with precedence 90 for @{'q2}. interpretation "Q x Q" 'q2 = (Prod Q Q). -definition empty_bar : bar â â©Qpos one,OQâª. +definition empty_bar : bar â â©Qpos one,â©OQ,OQâªâª. notation "\rect" with precedence 90 for @{'empty_bar}. interpretation "q0" 'empty_bar = empty_bar. @@ -55,7 +55,7 @@ record q_f : Type â { bars: list bar; bars_sorted : sorted q2_lt bars; bars_begin_OQ : nth_base bars O = OQ; - bars_end_OQ : nth_height bars (pred (\len bars)) = OQ + bars_end_OQ : nth_height bars (pred (\len bars)) = â©OQ,OQ⪠}. lemma len_bases_gt_O: âf.O < \len (bars f). @@ -75,46 +75,17 @@ cases (cmp_nat (\len l) i); apply (H2 n1); simplify in H3; apply (le_S_S_to_le ?? H3);] qed. -(* -lemma lt_n_plus_n_Sm : ân,m:nat.n < n + S m. -intros; rewrite > sym_plus; apply (le_S_S n (m+n)); apply (le_plus_n m n); qed. -*) - -(* -lemma all_bigger_can_concat_bigger: - âl1,l2,start,b,x,n. - (âi.i< len l1 â nth_base l1 i < \fst b) â - (âi.i< len l2 â \fst b ⤠nth_base l2 i) â - (âi.i< len l1 â start ⤠i â x ⤠nth_base l1 i) â - start ⤠n â n < len (l1@b::l2) â x ⤠\fst b â x ⤠nth_base (l1@b::l2) n. -intros; cases (cmp_nat n (len l1)); -[1: unfold nth_base; rewrite > (nth_concat_lt_len ????? H6); - apply (H2 n); assumption; -|2: rewrite > H6; unfold nth_base; rewrite > nth_len; assumption; -|3: unfold nth_base; rewrite > nth_concat_ge_len; [2: apply lt_to_le; assumption] - rewrite > len_concat in H4; simplify in H4; rewrite < plus_n_Sm in H4; - lapply linear le_S_S_to_le to H4 as K; rewrite > sym_plus in K; - lapply linear le_plus_to_minus to K as X; - generalize in match X; generalize in match (n - len l1); intro W; cases W; clear W X; - [intros; assumption] intros; - apply (q_le_trans ??? H5); apply (H1 n1); assumption;] -qed. -*) - - -inductive value_spec (f : q_f) (i : â) : â â nat â CProp â - value_of : âq,j. - nth_height (bars f) j = q â - nth_base (bars f) j < i â - (ân.j < n â n < \len (bars f) â i ⤠nth_base (bars f) n) â value_spec f i q j. - - -definition value : âf:q_f.âi:ratio.âp:â.âj.value_spec f (Qpos i) p j. -intros; letin P â (λx:bar.match q_cmp (Qpos i) (\fst x) with - [ q_leq _ â true - | q_gt _ â false]); +coinductive value_spec (f : q_f) (i : â) : â à â â CProp â +| value_of : âj,q. + nth_height (bars f) j = q â nth_base (bars f) j < i â + (ân.j < n â n < \len (bars f) â i ⤠nth_base (bars f) n) â value_spec f i q. + +definition value_lemma : âf:q_f.âi:ratio.âp:âÃâ.value_spec f (Qpos i) p. +intros; +letin P â + (λx:bar.match q_cmp (Qpos i) (\fst x) with[ q_leq _ â true| q_gt _ â false]); exists [apply (nth_height (bars f) (pred (find ? P (bars f) â)));] -exists [apply (pred (find ? P (bars f) â))] apply value_of; +apply (value_of ?? (pred (find ? P (bars f) â))); [1: reflexivity |2: cases (cases_find bar P (bars f) â); [1: cases i1 in H H1 H2 H3; simplify; intros; @@ -130,208 +101,50 @@ exists [apply (pred (find ? P (bars f) â))] apply value_of; unfold P in K; cases (q_cmp (Qpos i) (\fst (\nth (x::l) â (\len l)))) in K; simplify; intros; [destruct H2] assumption;] |3: intro; cases (cases_find bar P (bars f) â); intros; - [1: - -generalize in match (bars_begin_OQ f); generalize in match (bars_sorted f); -generalize in match (bars_end_OQ f); -cases (len_gt_non_empty ?? (len_bases_gt_O f)); simplify; -intros; -[1: - - -alias symbol "pi2" = "pair pi2". -alias symbol "pi1" = "pair pi1". -alias symbol "lt" (instance 7) = "Q less than". -alias symbol "leq" = "Q less or equal than". -letin value_spec_aux â ( - λf,i,q. And4 - (\fst q < len f) - (\snd q = nth_height f (\fst q)) - (nth_base f (\fst q) < i) - (ân.(\fst q) < n â n < len f â i ⤠nth_base f n)); -alias symbol "lt" (instance 5) = "Q less than". -letin value â ( - let rec value (acc: nat à â) (l : list bar) on l : nat à â â - match l with - [ nil â acc - | cons x tl â - match q_cmp (\fst x) (Qpos i) with - [ q_leq _ â value â©S (\fst acc), \snd x⪠tl - | q_gt _ â acc]] - in value : - âacc,l.âp:nat à â. - âstory. story @ l = bars f â S (\fst acc) = len story â - value_spec_aux story (Qpos i) acc â - value_spec_aux (story @ l) (Qpos i) p); -[4: clearbody value; unfold value_spec; - generalize in match (bars_begin_OQ f); - generalize in match (bars_sorted f); - cases (bars_not_nil f) in value; intros (value S); generalize in match (sorted_tail_bigger ?? S); - clear S; cases (value â©O,\snd x⪠l) (p Hp); intros; - exists[apply (\snd p)];exists [apply (\fst p)] simplify; - cases (Hp [x] (refl_eq ??) (refl_eq ??) ?) (Hg HV); - [unfold; split; [apply le_n|reflexivity|rewrite > H; apply q_pos_OQ;] - intros; cases n in H2 H3; [intro X; cases (not_le_Sn_O ? X)] - intros; cases (not_le_Sn_O ? (le_S_S_to_le (S n1) O H3))] - split;[rewrite > HV; reflexivity] split; [assumption;] - intros; cases n in H4 H5; intros [cases (not_le_Sn_O ? H4)] - apply (H3 (S n1)); assumption; -|1: unfold value_spec_aux; clear value value_spec_aux H2; intros; - cases H4; clear H4; split; - [1: apply (trans_lt ??? H5); rewrite > len_concat; simplify; apply lt_n_plus_n_Sm; - |2: unfold nth_height; rewrite > nth_concat_lt_len;[2:assumption]assumption; - |3: unfold nth_base; rewrite > nth_concat_lt_len;[2:assumption] - apply (q_le_lt_trans ???? H7); apply q_le_n; - |4: intros; (*clear H6 H5 H4 H l;*) lapply (bars_sorted f) as HS; - apply (all_bigger_can_concat_bigger story l1 (S (\fst p)));[6:apply q_lt_to_le]try assumption; - [1: rewrite < H2 in HS; cases (sorted_pivot ??? HS); assumption - |2: rewrite < H2 in HS; cases (sorted_pivot ??? HS); - intros; apply q_lt_to_le; apply H11; assumption; - |3: intros; apply H8; assumption;]] -|3: intro; rewrite > append_nil; intros; assumption; -|2: intros; cases (value â©S (\fst p),\snd b⪠l1); unfold; simplify; - cases (H6 (story@[b]) ???); - [1: rewrite > associative_append; apply H3; - |2: simplify; rewrite > H4; rewrite > len_concat; rewrite > sym_plus; reflexivity; - |4: rewrite < (associative_append ? story [b] l1); split; assumption; - |3: cases H5; clear H5; split; simplify in match (\snd ?); simplify in match (\fst ?); - [1: rewrite > len_concat; simplify; rewrite < plus_n_SO; apply le_S_S; assumption; - |2: - |3: - |4: ]]] - - - - - - - - - - -[5: clearbody value; - cases (q_cmp i (start f)); - [2: exists [apply â©O,OQâª] simplify; constructor 1; split; try assumption; - try reflexivity; apply q_lt_to_le; assumption; - |1: cases (bars f); [exists [apply â©O,OQâª] simplify; constructor 3; split;try assumption;reflexivity;] - cases (value â [i,start f] (b::l)) (p Hp); - cases (Hp (q_dist_ge_OQ ? ?)); clear Hp value; [cases H1; destruct H2] - cases H1; clear H1; lapply (sum_bases_O (b::l) (\fst p)) as H1; - [2: apply (q_le_trans ??? H2); rewrite > H; apply q_eq_to_le; - rewrite > q_d_x_x; reflexivity; - |1: exists [apply p] simplify; constructor 4; rewrite > H1; split; - try split; try rewrite > q_d_x_x; try autobatch depth=2; - [1: rewrite > H; rewrite > q_plus_sym; apply q_lt_plus; - rewrite > q_plus_minus; apply q_lt_plus_trans; [apply sum_bases_ge_OQ] - apply q_pos_lt_OQ; - |2: rewrite > H; rewrite > q_d_x_x; apply q_eq_to_le; reflexivity; - |3: rewrite > H; rewrite > q_d_x_x; apply q_lt_plus_trans; - try apply sum_bases_ge_OQ; apply q_pos_lt_OQ;]] - |3: cases (q_cmp i (start f+sum_bases (bars f) (len (bars f)))); - [1: exists [apply â©O,OQâª] simplify; constructor 2; split; try assumption; - try reflexivity; rewrite > H1; apply q_eq_to_le; reflexivity; - |3: exists [apply â©O,OQâª] simplify; constructor 2; split; try assumption; - try reflexivity; apply q_lt_to_le; assumption; - |2: generalize in match (refl_eq ? (bars f): bars f = bars f); - generalize in match (bars f) in ⢠(??? % â %); intro X; cases X; clear X; - intros; - [1: exists [apply â©O,OQâª] simplify; constructor 3; split; reflexivity; - |2: cases (value â [i,start f] (b::l)) (p Hp); - cases (Hp (q_dist_ge_OQ ? ?)); clear Hp value; [cases H3;destruct H4] - cases H3; clear H3; - exists [apply p]; constructor 4; split; try split; try assumption; - [1: intro X; destruct X; - |2: apply q_lt_to_le; assumption; - |3: rewrite < H2; assumption; - |4: cases (cmp_nat (\fst p) (len (bars f))); - [1:apply lt_to_le;rewrite