Skip to content

Commit dbc48fa

Browse files
committed
Adress PR review (1)
1 parent 3038ff0 commit dbc48fa

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

theories/datatypes/List.ec

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
(* -------------------------------------------------------------------- *)
6-
require import AllCore StdOrder.
6+
require import AllCore.
77

88
(* -------------------------------------------------------------------- *)
99
type 'a list = [
@@ -470,22 +470,25 @@ proof.
470470
by case (hs = x) => /= _ //; rewrite addrC ltzS count_ge0.
471471
qed.
472472
473-
lemma count_impl ['a] (p1 p2 : 'a -> bool) (s : 'a list) :
473+
lemma le_in_count ['a] (p1 p2 : 'a -> bool) (s : 'a list) :
474474
(forall x, x \in s => p1 x => p2 x) =>
475475
count p1 s <= count p2 s.
476476
proof.
477-
elim: s => // x s IH h /=.
478-
apply IntOrder.ler_add.
479-
+ by apply /le_b2i /(h x) /in_cons.
480-
by apply IH => y hy; apply /(h y) /in_cons; rewrite hy.
477+
have ler_add: forall (x y z w: int), x <= z => y <= w => x + y <= z + w.
478+
+ move => x y z w h h'.
479+
by rewrite (lez_trans (x + w)) 1:lez_add2l 1:h' lez_add2r h.
480+
elim: s => // x s IH h /=.
481+
apply ler_add.
482+
+ by apply /le_b2i /(h x) /in_cons.
483+
by apply IH => y hy; apply /(h y) /in_cons; rewrite hy.
481484
qed.
482485

483-
lemma count_or ['a] (p1 p2 p : 'a -> bool) (s : 'a list) :
486+
lemma countU ['a] (p1 p2 p : 'a -> bool) (s : 'a list) :
484487
(forall x, x \in s => p x => p1 x \/ p2 x) =>
485488
count p s <= count p1 s + count p2 s.
486489
proof.
487-
elim s => // x s hind h /=.
488-
apply (lez_trans ((b2i (p1 x) + b2i (p2 x)) + (count p1 s + count p2 s))) => /#.
490+
elim s => // x s hind h /=.
491+
apply (lez_trans ((b2i (p1 x) + b2i (p2 x)) + (count p1 s + count p2 s))) => /#.
489492
qed.
490493
491494
op has (p : 'a -> bool) xs =

0 commit comments

Comments
 (0)