Misc
From Stdlib Require Import Utf8 Arith Psatz.
Import List.ListNotations.
Open Scope list.
Global Hint Resolve Nat.le_0_l : core.
Global Hint Resolve Nat.lt_0_succ : core.
Global Hint Resolve Nat.lt_succ_diag_r : core.
Notation "x '∈' l" := (List.In x l) (at level 70).
Notation "x '∉' l" := (¬ List.In x l) (at level 70).
Notation "E ⊂ F" := (List.incl E F) (at level 70).
Notation "x ≠? y" := (negb (Nat.eqb x y)) (at level 70) : nat_scope.
Definition comp {A B C} (f : B → C) (g : A → B) x := f (g x).
Tactic Notation "flia" hyp_list(Hs) := clear - Hs; lia.
Notation "x ≤ y ≤ z" := (x ≤ y ∧ y ≤ z)%nat (at level 70, y at next level) :
nat_scope.
Notation "x < y ≤ z" := (x < y ∧ y ≤ z)%nat (at level 70, y at next level) :
nat_scope.
Notation "x ≤ y < z" := (x ≤ y ∧ y < z)%nat (at level 70, y at next level) :
nat_scope.
Notation "x < y < z" := (x < y ∧ y < z)%nat (at level 70, y at next level).
Notation "a ≡ b 'mod' c" := (a mod c = b mod c) (at level 70, b at level 36).
Notation "a ≢ b 'mod' c" := (a mod c ≠ b mod c) (at level 70, b at level 36).
Theorem Nat_sub_sub_swap : ∀ a b c, a - b - c = a - c - b.
Theorem Nat_mod_add_l_mul_r : ∀ a b c,
(c × b + a) mod b = a mod b.
Theorem List_app_cons : ∀ A la lb (b : A), la ++ b :: lb = la ++ [b] ++ lb.
Theorem List_nth_nil : ∀ A i (d : A), List.nth i [] d = d.
Theorem List_nth_0_cons : ∀ A (a : A) la d, List.nth 0 (a :: la) d = a.
Theorem List_length_cons : ∀ A (a : A) la, length (a :: la) = S (length la).
Theorem List_cons_is_app : ∀ {A} (a : A) la, a :: la = [a] ++ la.
Theorem List_map_nth' : ∀ {A B} a b (f : A → B) l n,
n < length l → List.nth n (List.map f l) b = f (List.nth n l a).
Theorem List_fold_left_map :
∀ A B C (f : A → B → A) (g : C → B) (l : list C) a,
List.fold_left f (List.map g l) a = List.fold_left (λ c b, f c (g b)) l a.
Theorem List_fold_left_ext_in : ∀ A B (f g : A → B → A) l a,
(∀ b c, b ∈ l → f c b = g c b)
→ List.fold_left f l a = List.fold_left g l a.
Theorem Nat_mul_2_l : ∀ n, 2 × n = n + n.
Theorem Nat_sub_succ_1 : ∀ n, S n - 1 = n.
Theorem Nat_div_less_small : ∀ n a b,
n × b ≤ a < (n + 1) × b
→ a / b = n.
Theorem if_bool_if_dec : ∀ A (b : bool) (x y : A),
(if b then x else y) =
if Sumbool.sumbool_of_bool b then x else y.
Theorem if_eqb_eq_dec : ∀ {A} i j (a b : A),
(if i =? j then a else b) = (if Nat.eq_dec i j then a else b).
Theorem if_ltb_lt_dec : ∀ A i j (a b : A),
(if i <? j then a else b) = (if lt_dec i j then a else b).
Theorem if_leb_le_dec : ∀ A i j (a b : A),
(if i <=? j then a else b) = (if le_dec i j then a else b).
Definition equality {A} (eqb : A → A → bool) := ∀ a b, eqb a b = true ↔ a = b.
Theorem equality_refl {A} {eqb : A → _} : equality eqb → ∀ a, eqb a a = true.
Theorem NoDup_app_comm {A} : ∀ l l' : list A,
List.NoDup (l ++ l') → List.NoDup (l' ++ l).
Theorem NoDup_app_remove_l :
∀ A (l l' : list A), List.NoDup (l ++ l') → List.NoDup l'.
Theorem NoDup_app_remove_r :
∀ A (l l' : list A), List.NoDup (l ++ l') → List.NoDup l.
Theorem NoDup_app_iff : ∀ A (l l' : list A),
List.NoDup (l ++ l') ↔
List.NoDup l ∧ List.NoDup l' ∧ (∀ a, a ∈ l → a ∉ l').
Theorem List_nth_succ_cons : ∀ {A} (a : A) la i,
List.nth (S i) (a :: la) = List.nth i la.
Definition unsome {A} (d : A) o :=
match o with
| Some x ⇒ x
| None ⇒ d
end.
Theorem List_seq_cut3 : ∀ i sta len,
i ∈ List.seq sta len
→ List.seq sta len =
List.seq sta (i - sta) ++ [i] ++ List.seq (S i) (sta + len - S i).
Theorem List_app_eq_app' :
∀ (X : Type) (x1 x2 y1 y2 : list X),
length x1 = length y1
→ x1 ++ x2 = y1 ++ y2
→ x1 = y1 ∧ x2 = y2.
Theorem List_skipn_is_cons : ∀ {A} (d : A) la n,
n < length la
→ List.skipn n la = List.nth n la d :: List.skipn (S n) la.
Theorem List_nth_skipn : ∀ A (l : list A) i j d,
List.nth i (List.skipn j l) d = List.nth (i + j) l d.
Theorem List_length_map_seq : ∀ A (f : _ → A) a len,
length (List.map f (List.seq a len)) = len.
Theorem List_map_nth_seq : ∀ {A} d (la : list A),
la = List.map (λ i, List.nth i la d) (List.seq 0 (length la)).
Theorem List_last_nth : ∀ A (la : list A) d,
List.last la d = List.nth (length la - 1) la d.
Theorem List_eq_rev_nil {A} : ∀ (l : list A), List.rev l = [] → l = [].
Theorem List_last_rev : ∀ A (l : list A) d,
List.last (List.rev l) d = List.hd d l.
Theorem List_rev_symm :
∀ A (la lb : list A), List.rev la = lb → la = List.rev lb.
Theorem List_nth_app_repeat_r :
∀ A (d : A) i n la,
List.nth i (la ++ List.repeat d n) d = List.nth i la d.
Theorem min_add_sub_max : ∀ a b, min (a + (b - a)) (b + (a - b)) = max a b.
Theorem List_in_combine_same :
∀ A (i j : A) l, (i, j) ∈ List.combine l l → i = j.
Theorem List_map_seq : ∀ A (f : _ → A) sta len,
List.map f (List.seq sta len) =
List.map (λ i, f (sta + i)) (List.seq 0 len).
Definition bool_of_sumbool {A B : Prop} (P : sumbool A B) :=
match P with
| left _ _ ⇒ true
| right _ _ ⇒ false
end.
Definition sumbool_or {A B C D : Prop} (P : sumbool A B) (Q : sumbool C D) :=
orb (bool_of_sumbool P) (bool_of_sumbool Q).
Definition sumbool_and {A B C D : Prop} (P : sumbool A B) (Q : sumbool C D) :=
andb (bool_of_sumbool P) (bool_of_sumbool Q).
Notation "a ∨∨ b" := (sumbool_or a b) (at level 85).
Notation "a ∧∧ b" := (sumbool_and a b) (at level 80).
Theorem Nat_fact_succ : ∀ n, fact (S n) = S n × fact n.
Theorem Nat_succ_sub_succ_r : ∀ a b, b < a → a - b = S (a - S b).
Theorem fold_not : ∀ (P : Prop), not P → P → False.
Theorem Tauto_match_nat_same : ∀ A a (b : A),
match a with 0 ⇒ b | S _ ⇒ b end = b.
This page has been generated by coqdoc