X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=matita%2Flibrary%2Fdecidable_kit%2Fdecidable.ma;h=1b2b1fc42423554734d34cd74fa41b544e1fbfdc;hb=a5bfa65b18a876fca982270f673c686a7d124f65;hp=3aaa4a6ae51420415aeac5c8615214f847d4b8a3;hpb=5831a523c30368128dc7337835bc1e694b2ff095;p=helm.git diff --git a/matita/library/decidable_kit/decidable.ma b/matita/library/decidable_kit/decidable.ma index 3aaa4a6ae..1b2b1fc42 100644 --- a/matita/library/decidable_kit/decidable.ma +++ b/matita/library/decidable_kit/decidable.ma @@ -56,6 +56,11 @@ intros (b); cases b; [ constructor 1; reflexivity | constructor 2;] unfold Not; intros (H); destruct H; qed. +lemma prove_reflect : ∀P:Prop.∀b:bool. + (b = true → P) → (b = false → ¬P) → reflect P b. +intros 2 (P b); cases b; intros; [left|right] autobatch. +qed. + (* ### standard connectives/relations with reflection predicate ### *) definition negb : bool → bool ≝ λb.match b with [ true ⇒ false | false ⇒ true]. @@ -69,22 +74,16 @@ definition andb : bool → bool → bool ≝ λa,b:bool. match a with [ true ⇒ b | false ⇒ false ]. lemma andbP : ∀a,b:bool. reflect (a = true ∧ b = true) (andb a b). -intros (a b); -generalize in match (refl_eq ? (andb a b)); -generalize in match (andb a b) in ⊢ (? ? ? % → %); intros 1 (c); -cases c; intros (H); [ apply reflect_true | apply reflect_false ]; -generalize in match H; clear H; -cases a; simplify; -[1: intros (E); rewrite > E; split; reflexivity -|2: intros (ABS); destruct ABS -|3: intros (E); rewrite > E; unfold Not; intros (ABS); decompose; destruct H1 -|4: intros (E); unfold Not; intros (ABS); decompose; destruct H] +intros (a b); apply prove_reflect; cases a; cases b; simplify; intros (H); +[1,2,3,4: rewrite > H; split; reflexivity; +|5,6,7,8: unfold Not; intros (H1); cases H1; + [destruct H|destruct H3|destruct H2|destruct H2]] qed. lemma andbPF : ∀a,b:bool. reflect (a = false ∨ b = false) (negb (andb a b)). -intros (a b); cases a; cases b; simplify; -[1: apply reflect_false | *: apply reflect_true ] -[unfold Not; intros (H); cases H; destruct H1|right|left|left] reflexivity; +intros (a b); apply prove_reflect; cases a; cases b; simplify; intros (H); +[1,2,3,4: rewrite > H; [1,2:right|3,4:left] reflexivity +|5,6,7,8: unfold Not; intros (H1); [2,3,4: destruct H]; cases H1; destruct H2] qed. definition orb : bool → bool → bool ≝ @@ -97,7 +96,7 @@ intros (a b); cases a; cases b; simplify; qed. lemma orbC : ∀a,b. orb a b = orb b a. -intros (a b); cases a; cases b; auto. qed. +intros (a b); cases a; cases b; autobatch. qed. lemma lebP: ∀x,y. reflect (x ≤ y) (leb x y). intros (x y); generalize in match (leb_to_Prop x y); @@ -110,7 +109,7 @@ intros (n); apply (p2bT ? ? (lebP ? ?)); apply le_n; qed. lemma lebW : ∀n,m. leb (S n) m = true → leb n m = true. intros (n m H); lapply (b2pT ? ? (lebP ? ?) H); clear H; -apply (p2bT ? ? (lebP ? ?)); auto. +apply (p2bT ? ? (lebP ? ?)); apply lt_to_le; assumption. qed. definition ltb ≝ λx,y.leb (S x) y. @@ -120,7 +119,7 @@ intros (x y); apply (lebP (S x) y); qed. lemma ltb_refl : ∀n.ltb n n = false. -intros (n); apply (p2bF ? ? (ltbP ? ?)); auto; +intros (n); apply (p2bF ? ? (ltbP ? ?)); autobatch; qed. (* ### = between booleans as <-> in Prop ### *) @@ -140,8 +139,8 @@ qed. lemma leb_eqb : ∀n,m. orb (eqb n m) (leb (S n) m) = leb n m. intros (n m); apply bool_to_eq; split; intros (H); -[1:cases (b2pT ? ? (orbP ? ?) H); [2: auto] - rewrite > (eqb_true_to_eq ? ? H1); auto +[1:cases (b2pT ? ? (orbP ? ?) H); [2: autobatch] + rewrite > (eqb_true_to_eq ? ? H1); autobatch |2:cases (b2pT ? ? (lebP ? ?) H); [ elim n; [reflexivity|assumption] | simplify; rewrite > (p2bT ? ? (lebP ? ?) H1); rewrite > orbC ] @@ -150,7 +149,8 @@ qed. (* OUT OF PLACE *) -lemma ltW : ∀n,m. n < m → n < (S m). intros; auto. qed. +lemma ltW : ∀n,m. n < m → n < (S m). +intros; unfold lt; unfold lt in H; autobatch. qed. lemma ltbW : ∀n,m. ltb n m = true → ltb n (S m) = true. intros (n m H); letin H1 ≝ (b2pT ? ? (ltbP ? ?) H); clearbody H1;