From: Enrico Tassi Date: Thu, 20 Nov 2008 15:55:08 +0000 (+0000) Subject: ... X-Git-Tag: make_still_working~4529 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=43cc715cc92ed10d665ee1cfe496531a30c8c460;p=helm.git ... --- diff --git a/helm/software/matita/library/dama/Makefile b/helm/software/matita/library/dama/Makefile deleted file mode 100644 index 92a16d1f0..000000000 --- a/helm/software/matita/library/dama/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -include ../../Makefile.defs - -DIR=$(shell basename $$PWD) - -$(DIR) all: - $(BIN)../matitac -$(DIR).opt opt all.opt: - $(BIN)../matitac.opt -clean: - $(BIN)../matitaclean -clean.opt: - $(BIN)../matitaclean.opt -depend: - $(BIN)../matitadep -dot && rm depends.dot -depend.opt: - $(BIN)../matitadep.opt -dot && rm depends.dot diff --git a/helm/software/matita/library/dama/models/q_bars.ma b/helm/software/matita/library/dama/models/q_bars.ma deleted file mode 100644 index 1d2107b7c..000000000 --- a/helm/software/matita/library/dama/models/q_bars.ma +++ /dev/null @@ -1,201 +0,0 @@ -(**************************************************************************) -(* ___ *) -(* ||M|| *) -(* ||A|| A project by Andrea Asperti *) -(* ||T|| *) -(* ||I|| Developers: *) -(* ||T|| The HELM team. *) -(* ||A|| http://helm.cs.unibo.it *) -(* \ / *) -(* \ / This file is distributed under the terms of the *) -(* v GNU General Public License Version 2 *) -(* *) -(**************************************************************************) - -include "nat_ordered_set.ma". -include "models/q_support.ma". -include "models/list_support.ma". -include "logic/cprop_connectives.ma". - -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,OQ〉〉. -notation "\rect" with precedence 90 for @{'empty_bar}. -interpretation "q0" 'empty_bar = empty_bar. - -notation < "\ldots\rect\square\EmptySmallSquare\ldots" with precedence 90 for @{'lq2}. -interpretation "lq2" 'lq2 = (list bar). - -definition q2_lt := mk_rel bar (λx,y:bar.\fst x < \fst y). - -interpretation "bar lt" 'lt x y = (rel_op _ q2_lt x y). - -lemma q2_trans : ∀a,b,c:bar. a < b → b < c → a < c. -intros 3; cases a; cases b; cases c; unfold q2_lt; simplify; intros; -apply (q_lt_trans ??? H H1); -qed. - -definition q2_trel := mk_trans_rel bar q2_lt q2_trans. - -interpretation "bar lt" 'lt x y = (FunClass_2_OF_trans_rel q2_trel x y). - -definition canonical_q_lt : rel bar → trans_rel ≝ λx:rel bar.q2_trel. - -coercion canonical_q_lt with nocomposites. - -interpretation "bar lt" 'lt x y = (FunClass_2_OF_trans_rel (canonical_q_lt _) x y). - -definition nth_base ≝ λf,n. \fst (\nth f ▭ n). -definition nth_height ≝ λf,n. \snd (\nth f ▭ n). - -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,OQ〉 -}. - -lemma len_bases_gt_O: ∀f.O < \len (bars f). -intros; generalize in match (bars_begin_OQ f); cases (bars f); intros; -[2: simplify; apply le_S_S; apply le_O_n; -|1: normalize in H; destruct H;] -qed. - -lemma all_bases_positive : ∀f:q_f.∀i. OQ < nth_base (bars f) (S i). -intro f; generalize in match (bars_begin_OQ f); generalize in match (bars_sorted f); -cases (len_gt_non_empty ?? (len_bases_gt_O f)); intros; -cases (cmp_nat (\len l) i); -[2: lapply (sorted_tail_bigger q2_lt ?? ▭ H ? H2) as K; - simplify in H1; rewrite < H1; apply K; -|1: simplify; elim l in i H2;[simplify; rewrite > nth_nil; apply (q_pos_OQ one)] - cases n in H3; intros; [simplify in H3; cases (not_le_Sn_O ? H3)] - apply (H2 n1); simplify in H3; apply (le_S_S_to_le ?? H3);] -qed. - -alias symbol "lt" (instance 9) = "Q less than". -alias symbol "lt" (instance 7) = "natural 'less than'". -alias symbol "lt" (instance 6) = "natural 'less than'". -alias symbol "lt" (instance 5) = "Q less than". -alias symbol "lt" (instance 4) = "natural 'less than'". -alias symbol "lt" (instance 2) = "natural 'less than'". -alias symbol "leq" = "Q less or equal than". -coinductive value_spec (f : list bar) (i : ℚ) : ℚ × ℚ → CProp ≝ -| value_of : ∀j,q. - nth_height f j = q → nth_base f j < i → j < \len f → - (∀n.n H6; - rewrite < H1; simplify; rewrite > nth_len; unfold match_pred; - cases (q_cmp (Qpos i) (\fst x)); simplify; - intros (X Hs); [2: destruct X] clear X; - cases (sorted_pivot q2_lt ??? ▭ Hs); - cut (\len l1 ≤ n) as Hn; [2: - rewrite > H1; cases i1 in H4; simplify; intro X; [2: assumption] - apply lt_to_le; assumption;] - unfold nth_base; rewrite > (nth_append_ge_len ????? Hn); - cut (n - \len l1 < \len (x::l2)) as K; [2: - simplify; rewrite > H1; rewrite > (?:\len l2 = \len f - \len (l1 @ [x]));[2: - rewrite > H6; repeat rewrite > len_append; simplify; - repeat rewrite < plus_n_Sm; rewrite < plus_n_O; simplify; - rewrite > sym_plus; rewrite < minus_plus_m_m; reflexivity;] - rewrite > len_append; rewrite > H1; simplify; rewrite < plus_n_SO; - apply le_S_S; clear H1 H6 H7 Hs H8 H9 Hn x l2 l1 H4 H3 H2 H; - elim (\len f) in i1 n H5; [cases (not_le_Sn_O ? H);] - simplify; cases n2; [ repeat rewrite < minus_n_O; apply le_S_S_to_le; assumption] - cases n1 in H1; [intros; rewrite > eq_minus_n_m_O; apply le_O_n] - intros; simplify; apply H; apply le_S_S_to_le; assumption;] - cases (n - \len l1) in K; simplify; intros; [ assumption] - lapply (H9 ? (le_S_S_to_le ?? H10)) as W; apply (q_le_trans ??? H7); - apply q_lt_to_le; apply W; - |2: cases (not_le_Sn_n i1); rewrite > H in ⊢ (??%); - apply (trans_le ??? ? H4); cases i1 in H3; intros; apply le_S_S; - [ apply le_O_n; | assumption]] -|3: unfold match_domain; cases (cases_find bar (match_pred i) f ▭); [ - cases i1 in H; intros; simplify; [assumption] - apply lt_S_to_lt; assumption;] - rewrite > H; cases (\len f) in len_bases_gt_O_f; intros; [cases (not_le_Sn_O ? H3)] - simplify; apply le_n; -|4: intros; unfold match_domain in H; cases (cases_find bar (match_pred i) f ▭) in H; simplify; intros; - [1: lapply (H3 n); [2: cases i1 in H4; intros [assumption] apply le_S; assumption;] - unfold match_pred in Hletin; cases (q_cmp (Qpos i) (\fst (\nth f ▭ n))) in Hletin; - simplify; intros; [destruct H6] assumption; - |2: destruct H; cases f in len_bases_gt_O_f H2 H3; clear H1; simplify; intros; - [cases (not_le_Sn_O ? H)] lapply (H1 n); [2: apply le_S; assumption] - unfold match_pred in Hletin; cases (q_cmp (Qpos i) (\fst (\nth (b::l) ▭ n))) in Hletin; - simplify; intros; [destruct H4] assumption;]] -qed. - -lemma bars_begin_lt_Qpos : ∀q,r. nth_base (bars q) O bars_begin_OQ; apply q_pos_OQ; -qed. - -lemma value : q_f → ratio → ℚ × ℚ. -intros; cases (value_lemma (bars q) ?? r); -[ apply bars_sorted. -| apply len_bases_gt_O; -| apply w; -| apply bars_begin_lt_Qpos;] -qed. - -lemma cases_value : ∀f,i. value_spec (bars f) (Qpos i) (value f i). -intros; unfold value; -cases (value_lemma (bars f) (bars_sorted f) (len_bases_gt_O f) i (bars_begin_lt_Qpos f i)); -assumption; -qed. - -definition same_values ≝ λl1,l2:q_f.∀input. value l1 input = value l2 input. - -definition same_bases ≝ λl1,l2:list bar. ∀i.\fst (\nth l1 ▭ i) = \fst (\nth l2 ▭ i). - -lemma same_bases_cons: ∀a,b,l1,l2. - same_bases l1 l2 → \fst a = \fst b → same_bases (a::l1) (b::l2). -intros; intro; cases i; simplify; [assumption;] apply (H n); -qed. - -alias symbol "lt" = "Q less than". -lemma unpos: ∀x:ℚ.OQ < x → ∃r:ratio.Qpos r = x. -intro; cases x; intros; [2:exists [apply r] reflexivity] -cases (?:False); -[ apply (q_lt_corefl ? H)| cases (q_lt_le_incompat ?? (q_neg_gt ?) (q_lt_to_le ?? H))] -qed. - -notation < "x \blacksquare" non associative with precedence 50 for @{'unpos $x}. -interpretation "hide unpos proof" 'unpos x = (unpos x _). - diff --git a/helm/software/matita/library/dama/models/q_copy.ma b/helm/software/matita/library/dama/models/q_copy.ma deleted file mode 100644 index de7384077..000000000 --- a/helm/software/matita/library/dama/models/q_copy.ma +++ /dev/null @@ -1,146 +0,0 @@ -(**************************************************************************) -(* ___ *) -(* ||M|| *) -(* ||A|| A project by Andrea Asperti *) -(* ||T|| *) -(* ||I|| Developers: *) -(* ||T|| The HELM team. *) -(* ||A|| http://helm.cs.unibo.it *) -(* \ / *) -(* \ / This file is distributed under the terms of the *) -(* v GNU General Public License Version 2 *) -(* *) -(**************************************************************************) - -include "models/q_bars.ma". - -(* move in nat/minus *) -lemma minus_lt : ∀i,j. i < j → j - i = S (j - S i). -intros 2; -apply (nat_elim2 ???? i j); simplify; intros; -[1: cases n in H; intros; rewrite < minus_n_O; [cases (not_le_Sn_O ? H);] - simplify; rewrite < minus_n_O; reflexivity; -|2: cases (not_le_Sn_O ? H); -|3: apply H; apply le_S_S_to_le; assumption;] -qed. - -alias symbol "lt" = "bar lt". -lemma inversion_sorted: - ∀a,l. sorted q2_lt (a::l) → Or (a < \hd ▭ l) (l = []). -intros 2; elim l; [right;reflexivity] left; inversion H1; intros; -[1,2:destruct H2| destruct H5; assumption] -qed. - -lemma inversion_sorted2: - ∀a,b,l. sorted q2_lt (a::b::l) → a < b. -intros; inversion H; intros; [1,2:destruct H1] destruct H4; assumption; -qed. - -let rec copy (l : list bar) on l : list bar ≝ - match l with - [ nil ⇒ [] - | cons x tl ⇒ 〈\fst x, 〈OQ,OQ〉〉 :: copy tl]. - -lemma sorted_copy: - ∀l:list bar.sorted q2_lt l → sorted q2_lt (copy l). -intro l; elim l; [apply (sorted_nil q2_lt)] simplify; -cases l1 in H H1; simplify; intros; [apply (sorted_one q2_lt)] -apply (sorted_cons q2_lt); [2: apply H; apply (sorted_tail q2_lt ?? H1);] -apply (inversion_sorted2 ??? H1); -qed. - -lemma len_copy: ∀l. \len (copy l) = \len l. -intro; elim l; [reflexivity] simplify; apply eq_f; assumption; -qed. - -lemma copy_same_bases: ∀l. same_bases l (copy l). -intros; elim l; [intro; reflexivity] intro; simplify; cases i; [reflexivity] -simplify; apply (H n); -qed. - -lemma copy_OQ : ∀l,n.nth_height (copy l) n = 〈OQ,OQ〉. -intro; elim l; [elim n;[reflexivity] simplify; assumption] -simplify; cases n; [reflexivity] simplify; apply (H n1); -qed. - -lemma prepend_sorted_with_same_head: - ∀r,x,l1,l2,d1,d2. - sorted r (x::l1) → sorted r l2 → - (r x (\nth l1 d1 O) → r x (\nth l2 d2 O)) → (l1 = [] → r x d1) → - sorted r (x::l2). -intros 8 (R x l1 l2 d1 d2 Sl1 Sl2); inversion Sl1; inversion Sl2; -intros; destruct; try assumption; [3: apply (sorted_one R);] -[1: apply sorted_cons;[2:assumption] apply H2; apply H3; reflexivity; -|2: apply sorted_cons;[2: assumption] apply H5; apply H6; reflexivity; -|3: apply sorted_cons;[2: assumption] apply H5; assumption; -|4: apply sorted_cons;[2: assumption] apply H8; apply H4;] -qed. - -lemma move_head_sorted: ∀x,l1,l2. - sorted q2_lt (x::l1) → sorted q2_lt l2 → nth_base l2 O = nth_base l1 O → - l1 ≠ [] → sorted q2_lt (x::l2). -intros; apply (prepend_sorted_with_same_head q2_lt x l1 l2 ▭ ▭); -try assumption; intros; unfold nth_base in H2; whd in H4; -[1: rewrite < H2 in H4; assumption; -|2: cases (H3 H4);] -qed. - - -lemma sort_q2lt_same_base: - ∀b,h1,h2,l. sorted q2_lt (〈b,h1〉::l) → sorted q2_lt (〈b,h2〉::l). -intros; cases (inversion_sorted ?? H); [2: rewrite > H1; apply (sorted_one q2_lt)] -lapply (sorted_tail q2_lt ?? H) as K; clear H; cases l in H1 K; simplify; intros; -[apply (sorted_one q2_lt);|apply (sorted_cons q2_lt);[2: assumption] apply H] -qed. - -lemma value_head : ∀a,l,i.Qpos i ≤ \fst a → value_simple (a::l) i = \snd a. -intros; unfold value_simple; unfold match_domain; cases (cases_find bar (match_pred i) (a::l) ▭); -[1: cases i1 in H2 H3 H4; intros; [reflexivity] lapply (H4 O) as K; [2: apply le_S_S; apply le_O_n;] - simplify in K; unfold match_pred in K; cases (q_cmp (Qpos i) (\fst a)) in K; - simplify; intros; [destruct H6] lapply (q_le_lt_trans ??? H H5) as K; cases (q_lt_corefl ? K); -|2: cases (?:False); lapply (H3 0); [2: simplify; apply le_S_S; apply le_O_n;] - unfold match_pred in Hletin; simplify in Hletin; cases (q_cmp (Qpos i) (\fst a)) in Hletin; - simplify; intros; [destruct H5] lapply (q_le_lt_trans ??? H H4); apply (q_lt_corefl ? Hletin);] -qed. - -lemma value_unit : ∀x,i. value_simple [x] i = \snd x. -intros; unfold value_simple; unfold match_domain; -cases (cases_find bar (match_pred i) [x] ▭); -[1: cases i1 in H; intros; [reflexivity] simplify in H; - cases (not_le_Sn_O ? (le_S_S_to_le ?? H)); -|2: simplify in H; destruct H; reflexivity;] -qed. - -lemma value_tail : - ∀a,b,l,i.\fst a < Qpos i → \fst b ≤ Qpos i → value_simple (a::b::l) i = value_simple (b::l) i. -intros; unfold value_simple; unfold match_domain; -cases (cases_find bar (match_pred i) (a::b::l) ▭); -[1: cases i1 in H3 H2 H4 H5; intros 1; simplify in ⊢ (? ? (? ? %) ?→?); unfold in ⊢ (? ? % ?→?); intros; - [1: cases (?:False); cases (q_cmp (Qpos i) (\fst a)) in H3; simplify; intros;[2: destruct H6] - apply (q_lt_corefl ? (q_lt_le_trans ??? H H3)); - |2: - -normalize in ⊢ (? ? % ?→?); simplify; -[1: rewrite > (value_head); - -lemma value_copy : - ∀l,i.rewrite > (value_u - value_simple (copy l) i = 〈OQ,OQ〉. -intros; elim l; -[1: reflexivity; -|2: cases l1 in H; intros; simplify in ⊢ (? ? (? % ?) ?); - [1: rewrite > (value_unit); reflexivity; - |2: cases (q_cmp (\fst b) (Qpos i)); - - change with (\fst ▭ = \lamsimplify in ⊢ (? ? (? % ?) ?); unfold value_simple; unfold match_domain; - cases (cases_find bar (match_pred i) [〈\fst x,〈OQ,OQ〉〉] ▭); - [1: simplify in H1:(??%%); - - unfold match_pred; - rewrite > (value_unit 〈\fst a,〈OQ,OQ〉〉); reflexivity; -|2: intros; simplify in H2 H3 H4 ⊢ (? ? (? % ? ? ? ?) ?); - cases (q_cmp (Qpos i) (\fst b)); - [2: rewrite > (value_tail ??? H2 H3 ? H4 H1); apply H; - |1: rewrite > (value_head ??? H2 H3 ? H4 H1); reflexivity]] -qed. - \ No newline at end of file diff --git a/helm/software/matita/library/dama/models/q_rebase.ma b/helm/software/matita/library/dama/models/q_rebase.ma deleted file mode 100644 index f8243d6d1..000000000 --- a/helm/software/matita/library/dama/models/q_rebase.ma +++ /dev/null @@ -1,299 +0,0 @@ -(**************************************************************************) -(* ___ *) -(* ||M|| *) -(* ||A|| A project by Andrea Asperti *) -(* ||T|| *) -(* ||I|| Developers: *) -(* ||T|| The HELM team. *) -(* ||A|| http://helm.cs.unibo.it *) -(* \ / *) -(* \ / This file is distributed under the terms of the *) -(* v GNU General Public License Version 2 *) -(* *) -(**************************************************************************) - -include "russell_support.ma". -include "models/q_copy.ma". -(* -definition rebase_spec ≝ - λl1,l2:q_f.λp:q_f × q_f. - And3 - (same_bases (bars (\fst p)) (bars (\snd p))) - (same_values l1 (\fst p)) - (same_values l2 (\snd p)). - -inductive rebase_cases : list bar → list bar → (list bar) × (list bar) → Prop ≝ -| rb_fst_full : ∀b,h1,xs. - rebase_cases (〈b,h1〉::xs) [] 〈〈b,h1〉::xs,〈b,〈OQ,OQ〉〉::copy xs〉 -| rb_snd_full : ∀b,h1,ys. - rebase_cases [] (〈b,h1〉::ys) 〈〈b,〈OQ,OQ〉〉::copy ys,〈b,h1〉::ys〉 -| rb_all_full : ∀b,h1,h2,h3,h4,xs,ys,r1,r2. - \snd(\last ▭ (〈b,h1〉::xs)) = \snd(\last ▭ (〈b,h3〉::r1)) → - \snd(\last ▭ (〈b,h2〉::ys)) = \snd(\last ▭ (〈b,h4〉::r2)) → - rebase_cases (〈b,h1〉::xs) (〈b,h2〉::ys) 〈〈b,h3〉::r1,〈b,h4〉::r2〉 -| rb_all_full_l : ∀b1,b2,h1,h2,xs,ys,r1,r2. - \snd(\last ▭ (〈b1,h1〉::xs)) = \snd(\last ▭ (〈b1,h1〉::r1)) → - \snd(\last ▭ (〈b2,h2〉::ys)) = \snd(\last ▭ (〈b1,h2〉::r2)) → - b1 < b2 → - rebase_cases (〈b1,h1〉::xs) (〈b2,h2〉::ys) 〈〈b1,h1〉::r1,〈b1,〈OQ,OQ〉〉::r2〉 -| rb_all_full_r : ∀b1,b2,h1,h2,xs,ys,r1,r2. - \snd(\last ▭ (〈b1,h1〉::xs)) = \snd(\last ▭ (〈b2,h1〉::r1)) → - \snd(\last ▭ (〈b2,h2〉::ys)) = \snd(\last ▭ (〈b2,h2〉::r2)) → - b2 < b1 → - rebase_cases (〈b1,h1〉::xs) (〈b2,h2〉::ys) 〈〈b2,〈OQ,OQ〉〉::r1,〈b2,h2〉::r2〉 -| rb_all_empty : rebase_cases [] [] 〈[],[]〉. - -alias symbol "pi2" = "pair pi2". -alias symbol "pi1" = "pair pi1". -alias symbol "leq" = "natural 'less or equal to'". -inductive rebase_spec_aux_p (l1, l2:list bar) (p:(list bar) × (list bar)) : Prop ≝ -| prove_rebase_spec_aux: - rebase_cases l1 l2 p → - (sorted q2_lt (\fst p)) → - (sorted q2_lt (\snd p)) → - (same_bases (\fst p) (\snd p)) → - (same_values_simpl l1 (\fst p)) → - (same_values_simpl l2 (\snd p)) → - rebase_spec_aux_p l1 l2 p. - -lemma aux_preserves_sorting: - ∀b,b3,l2,l3,w. rebase_cases l2 l3 w → - sorted q2_lt (b::l2) → sorted q2_lt (b3::l3) → \fst b3 = \fst b → - sorted q2_lt (\fst w) → sorted q2_lt (\snd w) → - same_bases (\fst w) (\snd w) → - sorted q2_lt (b :: \fst w). -intros 6; cases H; simplify; intros; clear H; -[ apply (sorted_cons q2_lt); [2:assumption] apply (inversion_sorted2 ??? H1); -| apply (sorted_cons q2_lt); [2:assumption] - whd; rewrite < H3; apply (inversion_sorted2 ??? H2); -| apply (sorted_cons q2_lt); [2:assumption] apply (inversion_sorted2 ??? H3); -| apply (sorted_cons q2_lt); [2:assumption] apply (inversion_sorted2 ??? H4); -| apply (sorted_cons q2_lt); [2:assumption] - whd; rewrite < H6; apply (inversion_sorted2 ??? H5); -| apply (sorted_one q2_lt);] -qed. - -lemma aux_preserves_sorting2: - ∀b,b3,l2,l3,w. rebase_cases l2 l3 w → - sorted q2_lt (b::l2) → sorted q2_lt (b3::l3) → \fst b3 = \fst b → - sorted q2_lt (\fst w) → sorted q2_lt (\snd w) → same_bases (\fst w) (\snd w) → - sorted q2_lt (b :: \snd w). -intros 6; cases H; simplify; intros; clear H; -[ apply (sorted_cons q2_lt); [2:assumption] apply (inversion_sorted2 ??? H1); -| apply (sorted_cons q2_lt); [2:assumption] - whd; rewrite < H3; apply (inversion_sorted2 ??? H2); -| apply (sorted_cons q2_lt); [2: assumption] apply (inversion_sorted2 ??? H3); -| apply (sorted_cons q2_lt); [2: assumption] apply (inversion_sorted2 ??? H4); -| apply (sorted_cons q2_lt); [2: assumption] - whd; rewrite < H6; apply (inversion_sorted2 ??? H5); -| apply (sorted_one q2_lt);] -qed. -*) - - - -definition rebase_spec_aux ≝ - λl1,l2 - :list bar.λp:(list bar) × (list bar). - sorted q2_lt l1 → (\snd (\last ▭ l1) = 〈OQ,OQ〉) → - sorted q2_lt l2 → (\snd (\last ▭ l2) = 〈OQ,OQ〉) → - rebase_spec_aux_p l1 l2 p. - -alias symbol "lt" = "Q less than". -alias symbol "Q" = "Rationals". -axiom q_unlimited: ∀x:ℚ.∃y:ratio.x (value_unit 〈b1,h1〉) in K; - rewrite > (value_unit 〈b2,〈OQ,OQ〉〉) in K; assumption; -|2: intros; unfold in H3; lapply depth=0 (H3 H1 ? H2 ?) as K; [1,2:simplify; autobatch] - clear H3; cases (q_halving b1 (b1 + \fst p)) (w Pw); cases w in Pw; intros; - [cases (q_lt_le_incompat ?? POS); apply q_lt_to_le; cases H3; - apply (q_lt_trans ???? H4); assumption; - |3: elim H3; lapply (q_lt_trans ??? H H4); lapply (q_lt_trans ??? POS Hletin); - cases (q_not_OQ_lt_Qneg ? Hletin1); - | cases H3; lapply (K r); - [2: simplify; assumption - |3: simplify; apply (q_lt_trans ???? H4); assumption; - |rewrite > (value_head b1,h1 .. q) in Hletin; - - - - (* MANCA che le basi sono positive, - poi con halving prendi tra b1 e \fst p e hai h1=OQ,OQ*) - - -definition eject ≝ - λP.λp:∃x:(list bar) × (list bar).P x.match p with [ex_introT p _ ⇒ p]. -coercion eject. -definition inject ≝ λP.λp:(list bar) × (list bar).λh:P p. ex_introT ? P p h. -coercion inject with 0 1 nocomposites. - -definition rebase: ∀l1,l2:q_f.∃p:q_f × q_f.rebase_spec l1 l2 p. -intros 2 (f1 f2); cases f1 (b1 Hs1 Hb1 He1); cases f2 (b2 Hs2 Hb2 He2); clear f1 f2; -alias symbol "leq" = "natural 'less or equal to'". -alias symbol "minus" = "Q minus". -letin aux ≝ ( -let rec aux (l1,l2:list bar) (n : nat) on n : (list bar) × (list bar) ≝ -match n with -[ O ⇒ 〈[], []〉 -| S m ⇒ - match l1 with - [ nil ⇒ 〈copy l2, l2〉 - | cons he1 tl1 ⇒ - match l2 with - [ nil ⇒ 〈l1, copy l1〉 - | cons he2 tl2 ⇒ - let base1 ≝ \fst he1 in - let base2 ≝ \fst he2 in - let height1 ≝ \snd he1 in - let height2 ≝ \snd he2 in - match q_cmp base1 base2 with - [ q_leq Hp1 ⇒ - match q_cmp base2 base1 with - [ q_leq Hp2 ⇒ - let rc ≝ aux tl1 tl2 m in - 〈he1 :: \fst rc,he2 :: \snd rc〉 - | q_gt Hp ⇒ - let rest ≝ base2 - base1 in - let rc ≝ aux tl1 (〈rest,height2〉 :: tl2) m in - 〈〈base1,height1〉 :: \fst rc,〈base1,height2〉 :: \snd rc〉] - | q_gt Hp ⇒ - let rest ≝ base1 - base2 in - let rc ≝ aux (〈rest,height1〉 :: tl1) tl2 m in - 〈〈base2,height1〉 :: \fst rc,〈base2,height2〉 :: \snd rc〉]]]] -in aux : ∀l1,l2,m.∃z.\len l1 + \len l2 ≤ m → rebase_spec_aux l1 l2 z); -[7: clearbody aux; cases (aux b1 b2 (\len b1 + \len b2)) (res Hres); - exists; [split; constructor 1; [apply (\fst res)|5:apply (\snd res)]] - [1,4: apply hide; cases (Hres (le_n ?) Hs1 He1 Hs2 He2); assumption; - |2,5: apply hide; cases (Hres (le_n ?) Hs1 He1 Hs2 He2); clear Hres aux; - lapply (H3 O) as K; clear H1 H2 H3 H4 H5; unfold nth_base; - cases H in K He1 He2 Hb1 Hb2; simplify; intros; assumption; - |3,6: apply hide; cases (Hres (le_n ?) Hs1 He1 Hs2 He2); clear Hres aux; - cases H in He1 He2; simplify; intros; - [1,6,8,12: assumption; - |2,7: rewrite > len_copy; generalize in match (\len ?); intro X; - cases X; [1,3: reflexivity] simplify; - [apply (copy_OQ ys n);|apply (copy_OQ xs n);] - |3,4: rewrite < H6; assumption; - |5: cases r1 in H6; simplify; intros; [reflexivity] rewrite < H6; assumption; - |9,11: rewrite < H7; assumption; - |10: cases r2 in H7; simplify; intros; [reflexivity] rewrite < H7; assumption]] - split; cases (Hres (le_n ?) Hs1 He1 Hs2 He2); clear Hres; unfold same_values; intros; - [1: assumption - |2,3: simplify in match (\snd 〈?,?〉); simplify in match (\fst 〈?,?〉); - apply same_values_simpl_to_same_values; assumption] -|3: cut (\fst b3 = \fst b) as E; [2: apply q_le_to_le_to_eq; assumption] - clear H6 H5 H4 H3 He2 Hb2 Hs2 b2 He1 Hb1 Hs1 b1; cases (aux l2 l3 n1) (rc Hrc); - clear aux; intro K; simplify in K; rewrite H3; cases r1 in H6; intros [2:reflexivity] - use same_values_unit_OQ; - - |2: simplify in H3:(??%) ⊢ %; rewrite > H3; rewrite > len_copy; elim (\len ys); [reflexivity] - symmetry; apply (copy_OQ ys n2); - | cases H8 in H5 H7; simplify; intros; [2,6:reflexivity|3,4,5: assumption] - simplify; rewrite > H5; rewrite > len_copy; elim (\len xs); [reflexivity] - symmetry; apply (copy_OQ xs n2);] - |2: apply (aux_preserves_sorting ? b3 ??? H8); assumption; - |3: apply (aux_preserves_sorting2 ? b3 ??? H8); try assumption; - try reflexivity; cases (inversion_sorted ?? H4);[2:rewrite >H3; apply (sorted_one q2_lt);] - cases l2 in H3 H4; intros; [apply (sorted_one q2_lt)] - apply (sorted_cons q2_lt);[2:apply (sorted_tail q2_lt ?? H3);] whd; - rewrite > E; assumption; - |4: apply I - |5: apply I - |6: intro; elim i; intros; simplify; solve [symmetry;assumption|apply H13] - |7: unfold; intros; clear H9 H10 H11 H12 H13; simplify in Hi1 Hi2 H16 H18; - cases H8 in H14 H15 H17 H3 H16 H18 H5 H6; - simplify in match (\fst 〈?,?〉); simplify in match (\snd 〈?,?〉); intros; - [1: reflexivity; - |2: simplify in H3; rewrite > (value_unit b); rewrite > H3; symmetry; - cases b in H3 H12 Hi2; intros 2; simplify in H12; rewrite > H12; - intros; change in ⊢ (? ? (? % ? ? ? ?) ?) with (copy (〈q,〈OQ,OQ〉〉::〈b1,〈OQ,OQ〉〉::ys)); - apply (value_copy (〈q,〈OQ,OQ〉〉::〈b1,〈OQ,OQ〉〉::ys)); - |3: apply (same_value_tail b b1 h1 h3 xs r1 input); assumption; - |4: apply (same_value_tail b b1 h1 h1 xs r1 input); assumption; - |5: simplify in H9; STOP - - |6: reflexivity;] - - ] - |8: - - -include "Q/q/qtimes.ma". - -let rec area (l:list bar) on l ≝ - match l with - [ nil ⇒ OQ - | cons he tl ⇒ area tl + Qpos (\fst he) * ⅆ[OQ,\snd he]]. - -alias symbol "pi1" = "exT \fst". -alias symbol "minus" = "Q minus". -alias symbol "exists" = "CProp exists". -definition minus_spec_bar ≝ - λf,g,h:list bar. - same_bases f g → len f = len g → - ∀s,i:ℚ. \snd (\fst (value (mk_q_f s h) i)) = - \snd (\fst (value (mk_q_f s f) i)) - \snd (\fst (value (mk_q_f s g) i)). - -definition minus_spec ≝ - λf,g:q_f. - ∃h:q_f. - ∀i:ℚ. \snd (\fst (value h i)) = - \snd (\fst (value f i)) - \snd (\fst (value g i)). - -definition eject_bar : ∀P:list bar → CProp.(∃l:list bar.P l) → list bar ≝ - λP.λp.match p with [ex_introT x _ ⇒ x]. -definition inject_bar ≝ ex_introT (list bar). - -coercion inject_bar with 0 1 nocomposites. -coercion eject_bar with 0 0 nocomposites. - -lemma minus_q_f : ∀f,g. minus_spec f g. -intros; -letin aux ≝ ( - let rec aux (l1, l2 : list bar) on l1 ≝ - match l1 with - [ nil ⇒ [] - | cons he1 tl1 ⇒ - match l2 with - [ nil ⇒ [] - | cons he2 tl2 ⇒ 〈\fst he1, \snd he1 - \snd he2〉 :: aux tl1 tl2]] - in aux : ∀l1,l2 : list bar.∃h.minus_spec_bar l1 l2 h); -[2: intros 4; simplify in H3; destruct H3; -|3: intros 4; simplify in H3; cases l1 in H2; [2: intro X; simplify in X; destruct X] - intros; rewrite > (value_OQ_e (mk_q_f s []) i); [2: reflexivity] - rewrite > q_elim_minus; rewrite > q_plus_OQ; reflexivity; -|1: cases (aux l2 l3); unfold in H2; intros 4; - simplify in ⊢ (? ? (? ? ? (? ? ? (? % ?))) ?); - cases (q_cmp i (s + Qpos (\fst b))); - - - -definition excess ≝ - λf,g.∃i.\snd (\fst (value f i)) < \snd (\fst (value g i)). - diff --git a/helm/software/matita/library/dama/models/q_support.ma b/helm/software/matita/library/dama/models/q_support.ma deleted file mode 100644 index 4f27f398a..000000000 --- a/helm/software/matita/library/dama/models/q_support.ma +++ /dev/null @@ -1,122 +0,0 @@ -(**************************************************************************) -(* ___ *) -(* ||M|| *) -(* ||A|| A project by Andrea Asperti *) -(* ||T|| *) -(* ||I|| Developers: *) -(* ||T|| The HELM team. *) -(* ||A|| http://helm.cs.unibo.it *) -(* \ / *) -(* \ / This file is distributed under the terms of the *) -(* v GNU General Public License Version 2 *) -(* *) -(**************************************************************************) - -include "Q/q/qtimes.ma". -include "Q/q/qplus.ma". -include "logic/cprop_connectives.ma". - -interpretation "Q" 'Q = Q. - -(* group over Q *) -axiom qp : ℚ → ℚ → ℚ. - -interpretation "Q plus" 'plus x y = (qp x y). -interpretation "Q minus" 'minus x y = (qp x (Qopp y)). - -axiom q_plus_OQ: ∀x:ℚ.x + OQ = x. -axiom q_plus_sym: ∀x,y:ℚ.x + y = y + x. -axiom q_plus_minus: ∀x.x - x = OQ. -axiom q_plus_assoc: ∀x,y,z.x + (y + z) = x + y + z. -axiom q_opp_plus: ∀x,y,z:Q. Qopp (y + z) = Qopp y + Qopp z. - -(* order over Q *) -axiom qlt : ℚ → ℚ → Prop. -axiom qle : ℚ → ℚ → Prop. -interpretation "Q less than" 'lt x y = (qlt x y). -interpretation "Q less or equal than" 'leq x y = (qle x y). - -inductive q_comparison (a,b:ℚ) : CProp ≝ - | q_leq : a ≤ b → q_comparison a b - | q_gt : b < a → q_comparison a b. - -axiom q_cmp:∀a,b:ℚ.q_comparison a b. - -inductive q_le_elimination (a,b:ℚ) : CProp ≝ -| q_le_from_eq : a = b → q_le_elimination a b -| q_le_from_lt : a < b → q_le_elimination a b. - -axiom q_le_cases : ∀x,y:ℚ.x ≤ y → q_le_elimination x y. - -axiom q_le_to_le_to_eq : ∀x,y. x ≤ y → y ≤ x → x = y. - -axiom q_le_plus_l: ∀a,b,c:ℚ. a ≤ c - b → a + b ≤ c. -axiom q_le_plus_r: ∀a,b,c:ℚ. a - b ≤ c → a ≤ c + b. -axiom q_lt_plus_l: ∀a,b,c:ℚ. a < c - b → a + b < c. -axiom q_lt_plus_r: ∀a,b,c:ℚ. a - b < c → a < c + b. - -axiom q_lt_opp_opp: ∀a,b.b < a → Qopp a < Qopp b. - -axiom q_le_n: ∀x. x ≤ x. -axiom q_lt_to_le: ∀a,b:ℚ.a < b → a ≤ b. - -axiom q_lt_corefl: ∀x:Q.x < x → False. -axiom q_lt_le_incompat: ∀x,y:Q.x < y → y ≤ x → False. - -axiom q_neg_gt: ∀r:ratio.Qneg r < OQ. -axiom q_pos_OQ: ∀x.OQ < Qpos x. - -axiom q_lt_trans: ∀x,y,z:Q. x < y → y < z → x < z. -axiom q_lt_le_trans: ∀x,y,z:Q. x < y → y ≤ z → x < z. -axiom q_le_lt_trans: ∀x,y,z:Q. x ≤ y → y < z → x < z. -axiom q_le_trans: ∀x,y,z:Q. x ≤ y → y ≤ z → x ≤ z. - -axiom q_le_lt_OQ_plus_trans: ∀x,y:Q.OQ ≤ x → OQ < y → OQ < x + y. -axiom q_lt_le_OQ_plus_trans: ∀x,y:Q.OQ < x → OQ ≤ y → OQ < x + y. -axiom q_le_OQ_plus_trans: ∀x,y:Q.OQ ≤ x → OQ ≤ y → OQ ≤ x + y. - -axiom q_leWl: ∀x,y,z.OQ ≤ x → x + y ≤ z → y ≤ z. -axiom q_ltWl: ∀x,y,z.OQ ≤ x → x + y < z → y < z. - -(* distance *) -axiom q_dist : ℚ → ℚ → ℚ. - -notation "hbox(\dd [term 19 x, break term 19 y])" with precedence 90 -for @{'distance $x $y}. -interpretation "ℚ distance" 'distance x y = (q_dist x y). - -axiom q_d_ge_OQ : ∀x,y:ℚ. OQ ≤ ⅆ[x,y]. -axiom q_d_OQ: ∀x:Q.ⅆ[x,x] = OQ. -axiom q_d_noabs: ∀x,y. x ≤ y → ⅆ[y,x] = y - x. -axiom q_d_sym: ∀x,y. ⅆ[x,y] = ⅆ[y,x]. - -lemma q_2opp: ∀x:ℚ.Qopp (Qopp x) = x. -intros; cases x; reflexivity; qed. - -(* derived *) -lemma q_lt_canc_plus_r: - ∀x,y,z:Q.x + z < y + z → x < y. -intros; rewrite < (q_plus_OQ y); rewrite < (q_plus_minus z); -rewrite > q_plus_assoc; apply q_lt_plus_r; rewrite > q_2opp; assumption; -qed. - -lemma q_lt_inj_plus_r: - ∀x,y,z:Q.x < y → x + z < y + z. -intros; apply (q_lt_canc_plus_r ?? (Qopp z)); -do 2 rewrite < q_plus_assoc; 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_le_n; -|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_plus_minus in H1; do 2 rewrite > q_plus_OQ in H1; assumption; -qed.