Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 3e9e4b6

Browse files
committed
refactor(*): move theorems and do minor polishing
1 parent da0c346 commit 3e9e4b6

File tree

6 files changed

+43
-55
lines changed

6 files changed

+43
-55
lines changed

data/bool.lean

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Author: Leonardo de Moura, Jeremy Avigad
55
-/
66

7-
-- TODO(Jeremy): these used to be proved by rec_simp. Write a special tactic for these, or
8-
-- get auto or super to do them.
9-
107
namespace bool
118

129
-- TODO(Jeremy): is this right?

data/list/basic.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ attribute [simp] concat
8484

8585
@[simp] theorem concat_nil (a : α) : concat [] a = [a] := rfl
8686

87-
@[simp] theorem concat_cons (a b : α) (l : list α) :
88-
concat (a :: l) b = a :: concat l b := rfl
87+
@[simp] theorem concat_cons (a b : α) (l : list α) : concat (a :: l) b = a :: concat l b := rfl
8988

9089
@[simp] theorem concat_ne_nil (a : α) (l : list α) : concat l a ≠ [] :=
9190
by induction l; intro h; contradiction

data/list/sort.lean

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,6 @@ Insertion sort and merge sort.
77
-/
88
import data.list.perm
99

10-
-- TODO(Jeremy): move this
11-
12-
namespace nat
13-
14-
theorem add_pos_left {m : ℕ} (h : m > 0) (n : ℕ) : m + n > 0 :=
15-
calc
16-
m + n > 0 + n : nat.add_lt_add_right h n
17-
... = n : nat.zero_add n
18-
... ≥ 0 : zero_le n
19-
20-
theorem add_pos_right (m : ℕ) {n : ℕ} (h : n > 0) : m + n > 0 :=
21-
begin rw add_comm, exact add_pos_left h m end
22-
23-
theorem add_pos_iff_pos_or_pos (m n : ℕ) : m + n > 0 ↔ m > 0 ∨ n > 0 :=
24-
iff.intro
25-
begin
26-
intro h,
27-
cases m with m,
28-
{simp [zero_add] at h, exact or.inr h},
29-
exact or.inl (succ_pos _)
30-
end
31-
begin
32-
intro h, cases h with mpos npos,
33-
{ apply add_pos_left mpos },
34-
apply add_pos_right _ npos
35-
end
36-
37-
theorem succ_le_succ_iff (m n : ℕ) : succ m ≤ succ n ↔ m ≤ n :=
38-
⟨le_of_succ_le_succ, succ_le_succ⟩
39-
40-
theorem lt_succ_iff_le (m n : ℕ) : m < succ n ↔ m ≤ n :=
41-
succ_le_succ_iff m n
42-
43-
end nat
44-
45-
46-
4710
namespace list
4811

4912
section sorted

data/nat/basic.lean

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import logic.basic
99

1010
universe u
1111

12-
open tactic
13-
1412
namespace nat
1513

1614
protected theorem eq_mul_of_div_eq_right {a b c : ℕ} (H1 : b ∣ a) (H2 : a / b = c) :
@@ -27,6 +25,35 @@ by rw mul_comm; exact nat.div_eq_iff_eq_mul_right H H'
2725

2826
protected theorem eq_mul_of_div_eq_left {a b c : ℕ} (H1 : b ∣ a) (H2 : a / b = c) :
2927
a = c * b :=
30-
by rw [mul_comm, nat.eq_mul_of_div_eq_right H1 H2]
28+
by rw [mul_comm, nat.eq_mul_of_div_eq_right H1 H2]
29+
30+
theorem add_pos_left {m : ℕ} (h : m > 0) (n : ℕ) : m + n > 0 :=
31+
calc
32+
m + n > 0 + n : nat.add_lt_add_right h n
33+
... = n : nat.zero_add n
34+
... ≥ 0 : zero_le n
35+
36+
theorem add_pos_right (m : ℕ) {n : ℕ} (h : n > 0) : m + n > 0 :=
37+
begin rw add_comm, exact add_pos_left h m end
38+
39+
theorem add_pos_iff_pos_or_pos (m n : ℕ) : m + n > 0 ↔ m > 0 ∨ n > 0 :=
40+
iff.intro
41+
begin
42+
intro h,
43+
cases m with m,
44+
{simp [zero_add] at h, exact or.inr h},
45+
exact or.inl (succ_pos _)
46+
end
47+
begin
48+
intro h, cases h with mpos npos,
49+
{ apply add_pos_left mpos },
50+
apply add_pos_right _ npos
51+
end
52+
53+
theorem succ_le_succ_iff (m n : ℕ) : succ m ≤ succ n ↔ m ≤ n :=
54+
⟨le_of_succ_le_succ, succ_le_succ⟩
55+
56+
theorem lt_succ_iff_le (m n : ℕ) : m < succ n ↔ m ≤ n :=
57+
succ_le_succ_iff m n
3158

3259
end nat

logic/basic.lean

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ theorem implies_intro (h : a) (h₂ : b) : a := h
5656

5757
theorem implies_false_iff (a : Prop) : (a → false) ↔ ¬ a := iff.rfl
5858

59+
theorem implies_and_iff (p q r : Prop) : (p → q ∧ r) ↔ (p → q) ∧ (p → r) :=
60+
iff.intro (λ h, ⟨λ hp, (h hp).left, λ hp, (h hp).right⟩) (λ h hp, ⟨h.left hp, h.right hp⟩)
61+
62+
theorem and_implies_iff (p q r : Prop) : (p ∧ q → r) ↔ (p → q → r) :=
63+
iff.intro (λ h hp hq, h ⟨hp, hq⟩) (λ h ⟨hp, hq⟩, h hp hq)
64+
65+
theorem iff_def (p q : Prop) : (p ↔ q) ↔ (p → q) ∧ (q → p) :=
66+
⟨ λh, ⟨h.1, h.2⟩, λ ⟨h₁, h₂⟩, ⟨h₁, h₂⟩ ⟩
67+
5968
/- not -/
6069

6170
theorem {u} not_elim {A : Sort u} (H1 : ¬a) (H2 : a) : A := absurd H2 H1
@@ -358,6 +367,9 @@ section bounded_quantifiers
358367
universe variable u
359368
variables {α : Type u} {r p q : α → Prop} {b : Prop}
360369

370+
theorem bexists_def {α : Type u} (p q : α → Prop) : (∃ x (h : p x), q x) ↔ ∃ x, p x ∧ q x :=
371+
⟨λ ⟨x, px, qx⟩, ⟨x, px, qx⟩, λ ⟨x, px, qx⟩, ⟨x, px, qx⟩⟩
372+
361373
theorem bexists.elim {b : Prop} (h : ∃ x : α, ∃ h : p x, q x) (h' : ∀ (a : α), p a → q a → b) :
362374
b :=
363375
exists.elim h (λ a h₁, exists.elim h₁ (h' a))

tactic/finish.lean

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,7 @@ declare_trace auto.done
2929
declare_trace auto.finish
3030

3131
-- TODO(Jeremy): move these
32-
theorem implies_and_iff (p q r : Prop) : (p → q ∧ r) ↔ (p → q) ∧ (p → r) :=
33-
iff.intro (λ h, ⟨λ hp, (h hp).left, λ hp, (h hp).right⟩) (λ h hp, ⟨h.left hp, h.right hp⟩)
3432

35-
theorem curry_iff (p q r : Prop) : (p ∧ q → r) ↔ (p → q → r) :=
36-
iff.intro (λ h hp hq, h ⟨hp, hq⟩) (λ h ⟨hp, hq⟩, h hp hq)
37-
38-
theorem iff_def (p q : Prop) : (p ↔ q) ↔ (p → q) ∧ (q → p) :=
39-
⟨ λh, ⟨h.1, h.2⟩, λ ⟨h₁, h₂⟩, ⟨h₁, h₂⟩ ⟩
40-
41-
theorem {u} bexists_def {α : Type u} (p q : α → Prop) : (∃ x (h : p x), q x) ↔ ∃ x, p x ∧ q x :=
42-
⟨λ ⟨x, px, qx⟩, ⟨x, px, qx⟩, λ ⟨x, px, qx⟩, ⟨x, px, qx⟩⟩
4333

4434
namespace tactic
4535

0 commit comments

Comments
 (0)