refactor(library/data/nat/basic): mark some theorems as protected to avoid overloading

This commit is contained in:
Leonardo de Moura 2015-10-14 12:27:09 -07:00
parent 0aaa8a9770
commit 6df31d3406
68 changed files with 195 additions and 262 deletions

View file

@ -25,7 +25,7 @@ Here is an example
#+BEGIN_SRC lean #+BEGIN_SRC lean
import data.nat import data.nat
open nat open nat algebra
constants a b c d e : nat. constants a b c d e : nat.
axiom Ax1 : a = b. axiom Ax1 : a = b.
axiom Ax2 : b = c + 1. axiom Ax2 : b = c + 1.
@ -53,7 +53,7 @@ some form of transitivity. It can even combine different relations.
#+BEGIN_SRC lean #+BEGIN_SRC lean
import data.nat import data.nat
open nat open nat algebra
theorem T2 (a b c : nat) (H1 : a = b) (H2 : b = c + 1) : a ≠ 0 theorem T2 (a b c : nat) (H1 : a = b) (H2 : b = c + 1) : a ≠ 0
:= calc a = b : H1 := calc a = b : H1

View file

@ -242,7 +242,7 @@ an additional indent for every line after the first, as in the following
example: example:
#+BEGIN_SRC lean #+BEGIN_SRC lean
import data.nat import data.nat
open nat eq open nat eq algebra
theorem add_right_inj {n m k : nat} : n + m = n + k → m = k := theorem add_right_inj {n m k : nat} : n + m = n + k → m = k :=
nat.induction_on n nat.induction_on n
(take H : 0 + m = 0 + k, (take H : 0 + m = 0 + k,

View file

@ -752,7 +752,7 @@ of two even numbers is an even number.
#+BEGIN_SRC lean #+BEGIN_SRC lean
import data.nat import data.nat
open nat open nat algebra
namespace hide namespace hide
definition even (a : nat) := ∃ b, a = 2*b definition even (a : nat) := ∃ b, a = 2*b
@ -762,7 +762,7 @@ of two even numbers is an even number.
exists.intro (w1 + w2) exists.intro (w1 + w2)
(calc a + b = 2*w1 + b : {Hw1} (calc a + b = 2*w1 + b : {Hw1}
... = 2*w1 + 2*w2 : {Hw2} ... = 2*w1 + 2*w2 : {Hw2}
... = 2*(w1 + w2) : eq.symm !mul.left_distrib))) ... = 2*(w1 + w2) : eq.symm !left_distrib)))
end hide end hide
#+END_SRC #+END_SRC
@ -774,7 +774,7 @@ With this macro we can write the example above in a more natural way
#+BEGIN_SRC lean #+BEGIN_SRC lean
import data.nat import data.nat
open nat open nat algebra
namespace hide namespace hide
definition even (a : nat) := ∃ b, a = 2*b definition even (a : nat) := ∃ b, a = 2*b
@ -784,6 +784,6 @@ With this macro we can write the example above in a more natural way
exists.intro (w1 + w2) exists.intro (w1 + w2)
(calc a + b = 2*w1 + b : {Hw1} (calc a + b = 2*w1 + b : {Hw1}
... = 2*w1 + 2*w2 : {Hw2} ... = 2*w1 + 2*w2 : {Hw2}
... = 2*(w1 + w2) : eq.symm !mul.left_distrib) ... = 2*(w1 + w2) : eq.symm !left_distrib)
end hide end hide
#+END_SRC #+END_SRC

View file

@ -131,10 +131,14 @@ definition add_comm_monoid.to_comm_monoid {A : Type} [s : add_comm_monoid A] : c
section add_comm_monoid section add_comm_monoid
variables [s : add_comm_monoid A]
include s
theorem add_comm_three {A : Type} [s : add_comm_monoid A] (a b c : A) : a + b + c = c + b + a := theorem add_comm_three (a b c : A) : a + b + c = c + b + a :=
by rewrite [{a + _}add.comm, {_ + c}add.comm, -*add.assoc] by rewrite [{a + _}add.comm, {_ + c}add.comm, -*add.assoc]
theorem add.comm4 : ∀ (n m k l : A), n + m + (k + l) = n + k + (m + l) :=
comm4 add.comm add.assoc
end add_comm_monoid end add_comm_monoid
/- group -/ /- group -/

View file

@ -81,7 +81,7 @@ theorem pow_mul (a : A) (m : ) : ∀ n, a^(m * n) = (a^m)^n
| (succ n) := by rewrite [nat.mul_succ, pow_add, pow_succ', pow_mul] | (succ n) := by rewrite [nat.mul_succ, pow_add, pow_succ', pow_mul]
theorem pow_comm (a : A) (m n : ) : a^m * a^n = a^n * a^m := theorem pow_comm (a : A) (m n : ) : a^m * a^n = a^n * a^m :=
by rewrite [-*pow_add, nat.add.comm] by rewrite [-*pow_add, add.comm]
end monoid end monoid
@ -219,7 +219,7 @@ theorem one_nmul (a : A) : 1 ⬝ a = a := pow_one a
theorem add_nmul (m n : ) (a : A) : (m + n) ⬝ a = (m ⬝ a) + (n ⬝ a) := pow_add a m n theorem add_nmul (m n : ) (a : A) : (m + n) ⬝ a = (m ⬝ a) + (n ⬝ a) := pow_add a m n
theorem mul_nmul (m n : ) (a : A) : (m * n) ⬝ a = m ⬝ (n ⬝ a) := eq.subst (nat.mul.comm n m) (pow_mul a n m) theorem mul_nmul (m n : ) (a : A) : (m * n) ⬝ a = m ⬝ (n ⬝ a) := eq.subst (mul.comm n m) (pow_mul a n m)
theorem nmul_comm (m n : ) (a : A) : (m ⬝ a) + (n ⬝ a) = (n ⬝ a) + (m ⬝ a) := pow_comm a m n theorem nmul_comm (m n : ) (a : A) : (m ⬝ a) + (n ⬝ a) = (n ⬝ a) + (m ⬝ a) := pow_comm a m n

View file

@ -7,7 +7,7 @@ Type class for encodable types.
Note that every encodable type is countable. Note that every encodable type is countable.
-/ -/
import data.fintype data.list data.list.sort data.sum data.nat.div data.countable data.equiv data.finset import data.fintype data.list data.list.sort data.sum data.nat.div data.countable data.equiv data.finset
open option list nat function open option list nat function algebra
structure encodable [class] (A : Type) := structure encodable [class] (A : Type) :=
(encode : A → nat) (decode : nat → option A) (encodek : ∀ a, decode (encode a) = some a) (encode : A → nat) (decode : nat → option A) (encodek : ∀ a, decode (encode a) = some a)

View file

@ -7,7 +7,7 @@ This file demonstrates how to encode vectors using indexed inductive families.
In standard library we do not use this approach. In standard library we do not use this approach.
-/ -/
import data.nat data.list data.fin import data.nat data.list data.fin
open nat prod fin open nat prod fin algebra
inductive vector (A : Type) : nat → Type := inductive vector (A : Type) : nat → Type :=
| nil {} : vector A zero | nil {} : vector A zero

View file

@ -446,7 +446,7 @@ assert aux₁ : ∀ {v₁ v₂}, v₁ < n → v₂ < m → v₁ + v₂ * n < n*m
take v₁ v₂, assume h₁ h₂, take v₁ v₂, assume h₁ h₂,
have nat.succ v₂ ≤ m, from succ_le_of_lt h₂, have nat.succ v₂ ≤ m, from succ_le_of_lt h₂,
assert nat.succ v₂ * n ≤ m * n, from mul_le_mul_right _ this, assert nat.succ v₂ * n ≤ m * n, from mul_le_mul_right _ this,
have v₂ * n + n ≤ n * m, by rewrite [-add_one at this, mul.right_distrib at this, one_mul at this, mul.comm m n at this]; exact this, have v₂ * n + n ≤ n * m, by rewrite [-add_one at this, right_distrib at this, one_mul at this, mul.comm m n at this]; exact this,
assert v₁ + (v₂ * n + n) < n + n * m, from add_lt_add_of_lt_of_le h₁ this, assert v₁ + (v₂ * n + n) < n + n * m, from add_lt_add_of_lt_of_le h₁ this,
have v₁ + v₂ * n + n < n * m + n, by rewrite [add.assoc, add.comm (n*m) n]; exact this, have v₁ + v₂ * n + n < n * m + n, by rewrite [add.assoc, add.comm (n*m) n]; exact this,
lt_of_add_lt_add_right this, lt_of_add_lt_add_right this,

View file

@ -191,7 +191,7 @@ begin
induction s with a s' H IH, induction s with a s' H IH,
rewrite [Sum_empty, card_empty, zero_mul], rewrite [Sum_empty, card_empty, zero_mul],
rewrite [Sum_insert_of_not_mem _ H, IH, card_insert_of_not_mem H, add.comm, rewrite [Sum_insert_of_not_mem _ H, IH, card_insert_of_not_mem H, add.comm,
mul.right_distrib, one_mul] right_distrib, one_mul]
end end
theorem Sum_one_eq_card (s : finset A) : (∑ x ∈ s, (1 : nat)) = card s := theorem Sum_one_eq_card (s : finset A) : (∑ x ∈ s, (1 : nat)) = card s :=

View file

@ -94,7 +94,7 @@ lemma length_all_lists : ∀ {n : nat}, length (@all_lists_of_len A _ n) = (card
| 0 := calc length [[]] = 1 : length_cons | 0 := calc length [[]] = 1 : length_cons
| (succ n) := calc length _ = card A * length (all_lists_of_len n) : length_cons_all | (succ n) := calc length _ = card A * length (all_lists_of_len n) : length_cons_all
... = card A * (card A ^ n) : length_all_lists ... = card A * (card A ^ n) : length_all_lists
... = (card A ^ n) * card A : nat.mul.comm ... = (card A ^ n) * card A : mul.comm
... = (card A) ^ (succ n) : pow_succ' ... = (card A) ^ (succ n) : pow_succ'

View file

@ -370,16 +370,16 @@ calc
... = nat_abs a : abstr_repr ... = nat_abs a : abstr_repr
theorem padd_pneg (p : × ) : padd p (pneg p) ≡ (0, 0) := theorem padd_pneg (p : × ) : padd p (pneg p) ≡ (0, 0) :=
show pr1 p + pr2 p + 0 = pr2 p + pr1 p + 0, from !nat.add.comm ▸ rfl show pr1 p + pr2 p + 0 = pr2 p + pr1 p + 0, from !nat.add_comm ▸ rfl
theorem padd_padd_pneg (p q : × ) : padd (padd p q) (pneg q) ≡ p := theorem padd_padd_pneg (p q : × ) : padd (padd p q) (pneg q) ≡ p :=
calc pr1 p + pr1 q + pr2 q + pr2 p calc pr1 p + pr1 q + pr2 q + pr2 p
= pr1 p + (pr1 q + pr2 q) + pr2 p : nat.add.assoc = pr1 p + (pr1 q + pr2 q) + pr2 p : algebra.add.assoc
... = pr1 p + (pr1 q + pr2 q + pr2 p) : nat.add.assoc ... = pr1 p + (pr1 q + pr2 q + pr2 p) : algebra.add.assoc
... = pr1 p + (pr2 q + pr1 q + pr2 p) : nat.add.comm ... = pr1 p + (pr2 q + pr1 q + pr2 p) : algebra.add.comm
... = pr1 p + (pr2 q + pr2 p + pr1 q) : by rewrite add.right_comm ... = pr1 p + (pr2 q + pr2 p + pr1 q) : algebra.add.right_comm
... = pr1 p + (pr2 p + pr2 q + pr1 q) : nat.add.comm ... = pr1 p + (pr2 p + pr2 q + pr1 q) : algebra.add.comm
... = pr2 p + pr2 q + pr1 q + pr1 p : nat.add.comm ... = pr2 p + pr2 q + pr1 q + pr1 p : algebra.add.comm
theorem add.left_inv (a : ) : -a + a = 0 := theorem add.left_inv (a : ) : -a + a = 0 :=
have H : repr (-a + a) ≡ repr 0, from have H : repr (-a + a) ≡ repr 0, from
@ -450,21 +450,25 @@ theorem equiv_mul_prep {xa ya xb yb xn yn xm ym : }
nat.add.cancel_right (calc nat.add.cancel_right (calc
xa*xn+ya*yn + (xb*ym+yb*xm) + (yb*xn+xb*yn + (xb*xn+yb*yn)) xa*xn+ya*yn + (xb*ym+yb*xm) + (yb*xn+xb*yn + (xb*xn+yb*yn))
= xa*xn+ya*yn + (yb*xn+xb*yn) + (xb*ym+yb*xm + (xb*xn+yb*yn)) : by rewrite add.comm4 = xa*xn+ya*yn + (yb*xn+xb*yn) + (xb*ym+yb*xm + (xb*xn+yb*yn)) : by rewrite add.comm4
... = xa*xn+ya*yn + (yb*xn+xb*yn) + (xb*xn+yb*yn + (xb*ym+yb*xm)) : by rewrite {xb*ym+yb*xm +_}nat.add.comm ... = xa*xn+ya*yn + (yb*xn+xb*yn) + (xb*xn+yb*yn + (xb*ym+yb*xm)) : by rewrite {xb*ym+yb*xm +_}nat.add_comm
... = xa*xn+yb*xn + (ya*yn+xb*yn) + (xb*xn+xb*ym + (yb*yn+yb*xm)) : by exact !congr_arg2 add.comm4 add.comm4 ... = xa*xn+yb*xn + (ya*yn+xb*yn) + (xb*xn+xb*ym + (yb*yn+yb*xm)) : by exact !congr_arg2 !add.comm4 !add.comm4
... = ya*xn+xb*xn + (xa*yn+yb*yn) + (xb*yn+xb*xm + (yb*xn+yb*ym)) : by rewrite[-+mul.left_distrib,-+mul.right_distrib]; exact H1 ▸ H2 ▸ rfl ... = ya*xn+xb*xn + (xa*yn+yb*yn) + (xb*yn+xb*xm + (yb*xn+yb*ym)) : by rewrite[-+left_distrib,-+right_distrib]; exact H1 ▸ H2 ▸ rfl
... = ya*xn+xa*yn + (xb*xn+yb*yn) + (xb*yn+yb*xn + (xb*xm+yb*ym)) : by exact !congr_arg2 add.comm4 add.comm4 ... = ya*xn+xa*yn + (xb*xn+yb*yn) + (xb*yn+yb*xn + (xb*xm+yb*ym)) : by exact !congr_arg2 !add.comm4 !add.comm4
... = xa*yn+ya*xn + (xb*xn+yb*yn) + (xb*yn+yb*xn + (xb*xm+yb*ym)) : by rewrite {xa*yn + _}nat.add.comm ... = xa*yn+ya*xn + (xb*xn+yb*yn) + (xb*yn+yb*xn + (xb*xm+yb*ym)) : by rewrite {xa*yn + _}nat.add_comm
... = xa*yn+ya*xn + (xb*xn+yb*yn) + (yb*xn+xb*yn + (xb*xm+yb*ym)) : by rewrite {xb*yn + _}nat.add.comm ... = xa*yn+ya*xn + (xb*xn+yb*yn) + (yb*xn+xb*yn + (xb*xm+yb*ym)) : by rewrite {xb*yn + _}nat.add_comm
... = xa*yn+ya*xn + (yb*xn+xb*yn) + (xb*xn+yb*yn + (xb*xm+yb*ym)) : by rewrite add.comm4 ... = xa*yn+ya*xn + (yb*xn+xb*yn) + (xb*xn+yb*yn + (xb*xm+yb*ym)) : by rewrite (!add.comm4)
... = xa*yn+ya*xn + (yb*xn+xb*yn) + (xb*xm+yb*ym + (xb*xn+yb*yn)) : by rewrite {xb*xn+yb*yn + _}nat.add.comm ... = xa*yn+ya*xn + (yb*xn+xb*yn) + (xb*xm+yb*ym + (xb*xn+yb*yn)) : by rewrite {xb*xn+yb*yn + _}nat.add_comm
... = xa*yn+ya*xn + (xb*xm+yb*ym) + (yb*xn+xb*yn + (xb*xn+yb*yn)) : by rewrite add.comm4) ... = xa*yn+ya*xn + (xb*xm+yb*ym) + (yb*xn+xb*yn + (xb*xn+yb*yn)) : by rewrite add.comm4)
theorem pmul_congr {p p' q q' : × } : p ≡ p' → q ≡ q' → pmul p q ≡ pmul p' q' := equiv_mul_prep theorem pmul_congr {p p' q q' : × } : p ≡ p' → q ≡ q' → pmul p q ≡ pmul p' q' := equiv_mul_prep
theorem pmul_comm (p q : × ) : pmul p q = pmul q p := theorem pmul_comm (p q : × ) : pmul p q = pmul q p :=
show (_,_) = (_,_), from !congr_arg2 show (_,_) = (_,_),
(!congr_arg2 !mul.comm !mul.comm) (!nat.add.comm ⬝ (!congr_arg2 !mul.comm !mul.comm)) begin
congruence,
{ congruence, repeat rewrite mul.comm },
{ rewrite algebra.add.comm, congruence, repeat rewrite mul.comm }
end
theorem mul.comm (a b : ) : a * b = b * a := theorem mul.comm (a b : ) : a * b = b * a :=
eq_of_repr_equiv_repr eq_of_repr_equiv_repr
@ -476,9 +480,11 @@ eq_of_repr_equiv_repr
private theorem pmul_assoc_prep {p1 p2 q1 q2 r1 r2 : } : private theorem pmul_assoc_prep {p1 p2 q1 q2 r1 r2 : } :
((p1*q1+p2*q2)*r1+(p1*q2+p2*q1)*r2, (p1*q1+p2*q2)*r2+(p1*q2+p2*q1)*r1) = ((p1*q1+p2*q2)*r1+(p1*q2+p2*q1)*r2, (p1*q1+p2*q2)*r2+(p1*q2+p2*q1)*r1) =
(p1*(q1*r1+q2*r2)+p2*(q1*r2+q2*r1), p1*(q1*r2+q2*r1)+p2*(q1*r1+q2*r2)) := (p1*(q1*r1+q2*r2)+p2*(q1*r2+q2*r1), p1*(q1*r2+q2*r1)+p2*(q1*r1+q2*r2)) :=
by rewrite[+mul.left_distrib,+mul.right_distrib,*mul.assoc]; begin
exact (congr_arg2 pair (!add.comm4 ⬝ (!congr_arg !nat.add.comm)) rewrite[+left_distrib,+right_distrib,*algebra.mul.assoc],
(!add.comm4 ⬝ (!congr_arg !nat.add.comm))) exact (congr_arg2 pair (!add.comm4 ⬝ (!congr_arg !nat.add_comm))
(!add.comm4 ⬝ (!congr_arg !nat.add_comm)))
end
theorem pmul_assoc (p q r: × ) : pmul (pmul p q) r = pmul p (pmul q r) := pmul_assoc_prep theorem pmul_assoc (p q r: × ) : pmul (pmul p q) r = pmul p (pmul q r) := pmul_assoc_prep
@ -502,7 +508,11 @@ mul.comm a 1 ▸ mul_one a
private theorem mul_distrib_prep {a1 a2 b1 b2 c1 c2 : } : private theorem mul_distrib_prep {a1 a2 b1 b2 c1 c2 : } :
((a1+b1)*c1+(a2+b2)*c2, (a1+b1)*c2+(a2+b2)*c1) = ((a1+b1)*c1+(a2+b2)*c2, (a1+b1)*c2+(a2+b2)*c1) =
(a1*c1+a2*c2+(b1*c1+b2*c2), a1*c2+a2*c1+(b1*c2+b2*c1)) := (a1*c1+a2*c2+(b1*c1+b2*c2), a1*c2+a2*c1+(b1*c2+b2*c1)) :=
by rewrite[+mul.right_distrib] ⬝ (!congr_arg2 !add.comm4 !add.comm4) begin
rewrite +right_distrib, congruence,
{rewrite add.comm4},
{rewrite add.comm4}
end
theorem mul.right_distrib (a b c : ) : (a + b) * c = a * c + b * c := theorem mul.right_distrib (a b c : ) : (a + b) * c = a * c + b * c :=
eq_of_repr_equiv_repr eq_of_repr_equiv_repr

View file

@ -162,10 +162,10 @@ or.elim (nat.lt_or_ge m (n * k))
have (-[1+m] + n * k) div k = -[1+m] div k + n, from calc have (-[1+m] + n * k) div k = -[1+m] div k + n, from calc
(-[1+m] + n * k) div k (-[1+m] + n * k) div k
= of_nat ((k * n - (m + 1)) div k) : = of_nat ((k * n - (m + 1)) div k) :
by rewrite [add.comm, neg_succ_of_nat_eq, of_nat_div, nat.mul.comm k n, by rewrite [add.comm, neg_succ_of_nat_eq, of_nat_div, algebra.mul.comm k n,
of_nat_sub H3] of_nat_sub H3]
... = of_nat (n - m div k - 1) : ... = of_nat (n - m div k - 1) :
nat.mul_sub_div_of_lt (!nat.mul.comm ▸ m_lt_nk) nat.mul_sub_div_of_lt (!nat.mul_comm ▸ m_lt_nk)
... = -[1+m] div k + n : ... = -[1+m] div k + n :
by rewrite [nat.sub_sub, of_nat_sub H4, add.comm, sub_eq_add_neg, by rewrite [nat.sub_sub, of_nat_sub H4, add.comm, sub_eq_add_neg,
!neg_succ_of_nat_div (of_nat_lt_of_nat_of_lt H2), !neg_succ_of_nat_div (of_nat_lt_of_nat_of_lt H2),

View file

@ -6,7 +6,7 @@ Authors: Leonardo de Moura, Haitao Zhang
List combinators. List combinators.
-/ -/
import data.list.basic data.equiv import data.list.basic data.equiv
open nat prod decidable function helper_tactics open nat prod decidable function helper_tactics algebra
namespace list namespace list
variables {A B C : Type} variables {A B C : Type}
@ -368,7 +368,7 @@ theorem length_product : ∀ (l₁ : list A) (l₂ : list B), length (product l
| (x::l₁) l₂ := | (x::l₁) l₂ :=
assert length (product l₁ l₂) = length l₁ * length l₂, from length_product l₁ l₂, assert length (product l₁ l₂) = length l₁ * length l₂, from length_product l₁ l₂,
by rewrite [product_cons, length_append, length_cons, by rewrite [product_cons, length_append, length_cons,
length_map, this, mul.right_distrib, one_mul, add.comm] length_map, this, right_distrib, one_mul, add.comm]
end product end product
-- new for list/comb dependent map theory -- new for list/comb dependent map theory

View file

@ -102,15 +102,15 @@ general m
/- addition -/ /- addition -/
theorem add_zero [simp] (n : ) : n + 0 = n := protected theorem add_zero [simp] (n : ) : n + 0 = n :=
rfl rfl
theorem add_succ [simp] (n m : ) : n + succ m = succ (n + m) := theorem add_succ [simp] (n m : ) : n + succ m = succ (n + m) :=
rfl rfl
theorem zero_add [simp] (n : ) : 0 + n = n := protected theorem zero_add [simp] (n : ) : 0 + n = n :=
nat.induction_on n nat.induction_on n
!add_zero !nat.add_zero
(take m IH, show 0 + succ m = succ m, from (take m IH, show 0 + succ m = succ m, from
calc calc
0 + succ m = succ (0 + m) : add_succ 0 + succ m = succ (0 + m) : add_succ
@ -118,15 +118,15 @@ nat.induction_on n
theorem succ_add [simp] (n m : ) : (succ n) + m = succ (n + m) := theorem succ_add [simp] (n m : ) : (succ n) + m = succ (n + m) :=
nat.induction_on m nat.induction_on m
(!add_zero ▸ !add_zero) (!nat.add_zero ▸ !nat.add_zero)
(take k IH, calc (take k IH, calc
succ n + succ k = succ (succ n + k) : add_succ succ n + succ k = succ (succ n + k) : add_succ
... = succ (succ (n + k)) : IH ... = succ (succ (n + k)) : IH
... = succ (n + succ k) : add_succ) ... = succ (n + succ k) : add_succ)
theorem add.comm [simp] (n m : ) : n + m = m + n := protected theorem add_comm [simp] (n m : ) : n + m = m + n :=
nat.induction_on m nat.induction_on m
(by rewrite [add_zero, zero_add]) (by rewrite [nat.add_zero, nat.zero_add])
(take k IH, calc (take k IH, calc
n + succ k = succ (n+k) : add_succ n + succ k = succ (n+k) : add_succ
... = succ (k + n) : IH ... = succ (k + n) : IH
@ -135,9 +135,9 @@ nat.induction_on m
theorem succ_add_eq_succ_add (n m : ) : succ n + m = n + succ m := theorem succ_add_eq_succ_add (n m : ) : succ n + m = n + succ m :=
!succ_add ⬝ !add_succ⁻¹ !succ_add ⬝ !add_succ⁻¹
theorem add.assoc [simp] (n m k : ) : (n + m) + k = n + (m + k) := protected theorem add_assoc [simp] (n m k : ) : (n + m) + k = n + (m + k) :=
nat.induction_on k nat.induction_on k
(by rewrite +add_zero) (by rewrite +nat.add_zero)
(take l IH, (take l IH,
calc calc
(n + m) + succ l = succ ((n + m) + l) : add_succ (n + m) + succ l = succ ((n + m) + l) : add_succ
@ -145,19 +145,16 @@ nat.induction_on k
... = n + succ (m + l) : add_succ ... = n + succ (m + l) : add_succ
... = n + (m + succ l) : add_succ) ... = n + (m + succ l) : add_succ)
theorem add.left_comm [simp] : Π (n m k : ), n + (m + k) = m + (n + k) := protected theorem add.left_comm : Π (n m k : ), n + (m + k) = m + (n + k) :=
left_comm add.comm add.assoc left_comm nat.add_comm nat.add_assoc
theorem add.right_comm : Π (n m k : ), n + m + k = n + k + m := protected theorem add.right_comm : Π (n m k : ), n + m + k = n + k + m :=
right_comm add.comm add.assoc right_comm nat.add_comm nat.add_assoc
theorem add.comm4 : Π {n m k l : }, n + m + (k + l) = n + k + (m + l) :=
comm4 add.comm add.assoc
theorem add.cancel_left {n m k : } : n + m = n + k → m = k := theorem add.cancel_left {n m k : } : n + m = n + k → m = k :=
nat.induction_on n nat.induction_on n
(take H : 0 + m = 0 + k, (take H : 0 + m = 0 + k,
!zero_add⁻¹ ⬝ H ⬝ !zero_add) !nat.zero_add⁻¹ ⬝ H ⬝ !nat.zero_add)
(take (n : ) (IH : n + m = n + k → m = k) (H : succ n + m = succ n + k), (take (n : ) (IH : n + m = n + k → m = k) (H : succ n + m = succ n + k),
have succ (n + m) = succ (n + k), have succ (n + m) = succ (n + k),
from calc from calc
@ -168,7 +165,7 @@ nat.induction_on n
IH this) IH this)
theorem add.cancel_right {n m k : } (H : n + m = k + m) : n = k := theorem add.cancel_right {n m k : } (H : n + m = k + m) : n = k :=
have H2 : m + n = m + k, from !add.comm ⬝ H ⬝ !add.comm, have H2 : m + n = m + k, from !nat.add_comm ⬝ H ⬝ !nat.add_comm,
add.cancel_left H2 add.cancel_left H2
theorem eq_zero_of_add_eq_zero_right {n m : } : n + m = 0 → n = 0 := theorem eq_zero_of_add_eq_zero_right {n m : } : n + m = 0 → n = 0 :=
@ -183,20 +180,20 @@ nat.induction_on n
!succ_ne_zero) !succ_ne_zero)
theorem eq_zero_of_add_eq_zero_left {n m : } (H : n + m = 0) : m = 0 := theorem eq_zero_of_add_eq_zero_left {n m : } (H : n + m = 0) : m = 0 :=
eq_zero_of_add_eq_zero_right (!add.comm ⬝ H) eq_zero_of_add_eq_zero_right (!nat.add_comm ⬝ H)
theorem eq_zero_and_eq_zero_of_add_eq_zero {n m : } (H : n + m = 0) : n = 0 ∧ m = 0 := theorem eq_zero_and_eq_zero_of_add_eq_zero {n m : } (H : n + m = 0) : n = 0 ∧ m = 0 :=
and.intro (eq_zero_of_add_eq_zero_right H) (eq_zero_of_add_eq_zero_left H) and.intro (eq_zero_of_add_eq_zero_right H) (eq_zero_of_add_eq_zero_left H)
theorem add_one [simp] (n : ) : n + 1 = succ n := theorem add_one [simp] (n : ) : n + 1 = succ n :=
!add_zero ▸ !add_succ !nat.add_zero ▸ !add_succ
theorem one_add (n : ) : 1 + n = succ n := theorem one_add (n : ) : 1 + n = succ n :=
!zero_add ▸ !succ_add !nat.zero_add ▸ !succ_add
/- multiplication -/ /- multiplication -/
theorem mul_zero [simp] (n : ) : n * 0 = 0 := protected theorem mul_zero [simp] (n : ) : n * 0 = 0 :=
rfl rfl
theorem mul_succ [simp] (n m : ) : n * succ m = n * m + n := theorem mul_succ [simp] (n m : ) : n * succ m = n * m + n :=
@ -204,75 +201,75 @@ rfl
-- commutativity, distributivity, associativity, identity -- commutativity, distributivity, associativity, identity
theorem zero_mul [simp] (n : ) : 0 * n = 0 := protected theorem zero_mul [simp] (n : ) : 0 * n = 0 :=
nat.induction_on n nat.induction_on n
!mul_zero !nat.mul_zero
(take m IH, !mul_succ ⬝ !add_zero ⬝ IH) (take m IH, !mul_succ ⬝ !nat.add_zero ⬝ IH)
theorem succ_mul [simp] (n m : ) : (succ n) * m = (n * m) + m := theorem succ_mul [simp] (n m : ) : (succ n) * m = (n * m) + m :=
nat.induction_on m nat.induction_on m
(by rewrite mul_zero) (by rewrite nat.mul_zero)
(take k IH, calc (take k IH, calc
succ n * succ k = succ n * k + succ n : mul_succ succ n * succ k = succ n * k + succ n : mul_succ
... = n * k + k + succ n : IH ... = n * k + k + succ n : IH
... = n * k + (k + succ n) : add.assoc ... = n * k + (k + succ n) : nat.add_assoc
... = n * k + (succ n + k) : add.comm ... = n * k + (succ n + k) : nat.add_comm
... = n * k + (n + succ k) : succ_add_eq_succ_add ... = n * k + (n + succ k) : succ_add_eq_succ_add
... = n * k + n + succ k : add.assoc ... = n * k + n + succ k : nat.add_assoc
... = n * succ k + succ k : mul_succ) ... = n * succ k + succ k : mul_succ)
theorem mul.comm [simp] (n m : ) : n * m = m * n := protected theorem mul_comm [simp] (n m : ) : n * m = m * n :=
nat.induction_on m nat.induction_on m
(!mul_zero ⬝ !zero_mul⁻¹) (!nat.mul_zero ⬝ !nat.zero_mul⁻¹)
(take k IH, calc (take k IH, calc
n * succ k = n * k + n : mul_succ n * succ k = n * k + n : mul_succ
... = k * n + n : IH ... = k * n + n : IH
... = (succ k) * n : succ_mul) ... = (succ k) * n : succ_mul)
theorem mul.right_distrib (n m k : ) : (n + m) * k = n * k + m * k := protected theorem right_distrib (n m k : ) : (n + m) * k = n * k + m * k :=
nat.induction_on k nat.induction_on k
(calc (calc
(n + m) * 0 = 0 : mul_zero (n + m) * 0 = 0 : nat.mul_zero
... = 0 + 0 : add_zero ... = 0 + 0 : nat.add_zero
... = n * 0 + 0 : mul_zero ... = n * 0 + 0 : nat.mul_zero
... = n * 0 + m * 0 : mul_zero) ... = n * 0 + m * 0 : nat.mul_zero)
(take l IH, calc (take l IH, calc
(n + m) * succ l = (n + m) * l + (n + m) : mul_succ (n + m) * succ l = (n + m) * l + (n + m) : mul_succ
... = n * l + m * l + (n + m) : IH ... = n * l + m * l + (n + m) : IH
... = n * l + m * l + n + m : add.assoc ... = n * l + m * l + n + m : nat.add_assoc
... = n * l + n + m * l + m : add.right_comm ... = n * l + n + m * l + m : nat.add.right_comm
... = n * l + n + (m * l + m) : add.assoc ... = n * l + n + (m * l + m) : nat.add_assoc
... = n * succ l + (m * l + m) : mul_succ ... = n * succ l + (m * l + m) : mul_succ
... = n * succ l + m * succ l : mul_succ) ... = n * succ l + m * succ l : mul_succ)
theorem mul.left_distrib (n m k : ) : n * (m + k) = n * m + n * k := protected theorem left_distrib (n m k : ) : n * (m + k) = n * m + n * k :=
calc calc
n * (m + k) = (m + k) * n : mul.comm n * (m + k) = (m + k) * n : nat.mul_comm
... = m * n + k * n : mul.right_distrib ... = m * n + k * n : nat.right_distrib
... = n * m + k * n : mul.comm ... = n * m + k * n : nat.mul_comm
... = n * m + n * k : mul.comm ... = n * m + n * k : nat.mul_comm
theorem mul.assoc [simp] (n m k : ) : (n * m) * k = n * (m * k) := protected theorem mul_assoc [simp] (n m k : ) : (n * m) * k = n * (m * k) :=
nat.induction_on k nat.induction_on k
(calc (calc
(n * m) * 0 = n * (m * 0) : mul_zero) (n * m) * 0 = n * (m * 0) : nat.mul_zero)
(take l IH, (take l IH,
calc calc
(n * m) * succ l = (n * m) * l + n * m : mul_succ (n * m) * succ l = (n * m) * l + n * m : mul_succ
... = n * (m * l) + n * m : IH ... = n * (m * l) + n * m : IH
... = n * (m * l + m) : mul.left_distrib ... = n * (m * l + m) : nat.left_distrib
... = n * (m * succ l) : mul_succ) ... = n * (m * succ l) : mul_succ)
theorem mul_one [simp] (n : ) : n * 1 = n := protected theorem mul_one [simp] (n : ) : n * 1 = n :=
calc calc
n * 1 = n * 0 + n : mul_succ n * 1 = n * 0 + n : mul_succ
... = 0 + n : mul_zero ... = 0 + n : nat.mul_zero
... = n : zero_add ... = n : nat.zero_add
theorem one_mul [simp] (n : ) : 1 * n = n := protected theorem one_mul [simp] (n : ) : 1 * n = n :=
calc calc
1 * n = n * 1 : mul.comm 1 * n = n * 1 : nat.mul_comm
... = n : mul_one ... = n : nat.mul_one
theorem eq_zero_or_eq_zero_of_mul_eq_zero {n m : } : n * m = 0 → n = 0 m = 0 := theorem eq_zero_or_eq_zero_of_mul_eq_zero {n m : } : n * m = 0 → n = 0 m = 0 :=
nat.cases_on n nat.cases_on n
@ -293,22 +290,21 @@ open algebra
protected definition comm_semiring [reducible] [trans_instance] : algebra.comm_semiring nat := protected definition comm_semiring [reducible] [trans_instance] : algebra.comm_semiring nat :=
⦃algebra.comm_semiring, ⦃algebra.comm_semiring,
add := nat.add, add := nat.add,
add_assoc := nat.add_assoc,
add_assoc := add.assoc,
zero := nat.zero, zero := nat.zero,
zero_add := zero_add, zero_add := nat.zero_add,
add_zero := add_zero, add_zero := nat.add_zero,
add_comm := add.comm, add_comm := nat.add_comm,
mul := nat.mul, mul := nat.mul,
mul_assoc := mul.assoc, mul_assoc := nat.mul_assoc,
one := nat.succ nat.zero, one := nat.succ nat.zero,
one_mul := one_mul, one_mul := nat.one_mul,
mul_one := mul_one, mul_one := nat.mul_one,
left_distrib := mul.left_distrib, left_distrib := nat.left_distrib,
right_distrib := mul.right_distrib, right_distrib := nat.right_distrib,
zero_mul := zero_mul, zero_mul := nat.zero_mul,
mul_zero := mul_zero, mul_zero := nat.mul_zero,
mul_comm := mul.comm⦄ mul_comm := nat.mul_comm⦄
end nat end nat
section section

View file

@ -263,7 +263,7 @@ else
(calc (calc
((z * x) div (z * y)) * (z * y) + (z * x) mod (z * y) = z * x : eq_div_mul_add_mod ((z * x) div (z * y)) * (z * y) + (z * x) mod (z * y) = z * x : eq_div_mul_add_mod
... = z * (x div y * y + x mod y) : eq_div_mul_add_mod ... = z * (x div y * y + x mod y) : eq_div_mul_add_mod
... = z * (x div y * y) + z * (x mod y) : mul.left_distrib ... = z * (x div y * y) + z * (x mod y) : left_distrib
... = (x div y) * (z * y) + z * (x mod y) : mul.left_comm) ... = (x div y) * (z * y) + z * (x mod y) : mul.left_comm)
theorem mul_div_mul_right {x z y : } (zpos : z > 0) : (x * z) div (y * z) = x div y := theorem mul_div_mul_right {x z y : } (zpos : z > 0) : (x * z) div (y * z) = x div y :=
@ -286,7 +286,7 @@ or.elim (eq_zero_or_pos z)
(calc (calc
((z * x) div (z * y)) * (z * y) + (z * x) mod (z * y) = z * x : eq_div_mul_add_mod ((z * x) div (z * y)) * (z * y) + (z * x) mod (z * y) = z * x : eq_div_mul_add_mod
... = z * (x div y * y + x mod y) : eq_div_mul_add_mod ... = z * (x div y * y + x mod y) : eq_div_mul_add_mod
... = z * (x div y * y) + z * (x mod y) : mul.left_distrib ... = z * (x div y * y) + z * (x mod y) : left_distrib
... = (x div y) * (z * y) + z * (x mod y) : mul.left_comm))) ... = (x div y) * (z * y) + z * (x mod y) : mul.left_comm)))
theorem mul_mod_mul_right (x z y : ) : (x * z) mod (y * z) = (x mod y) * z := theorem mul_mod_mul_right (x z y : ) : (x * z) mod (y * z) = (x mod y) * z :=
@ -300,7 +300,7 @@ theorem mul_mod_eq_mod_mul_mod (m n k : nat) : (m * n) mod k = ((m mod k) * n) m
calc calc
(m * n) mod k = (((m div k) * k + m mod k) * n) mod k : eq_div_mul_add_mod (m * n) mod k = (((m div k) * k + m mod k) * n) mod k : eq_div_mul_add_mod
... = ((m mod k) * n) mod k : ... = ((m mod k) * n) mod k :
by rewrite [mul.right_distrib, mul.right_comm, add.comm, add_mul_mod_self] by rewrite [right_distrib, mul.right_comm, add.comm, add_mul_mod_self]
theorem mul_mod_eq_mul_mod_mod (m n k : nat) : (m * n) mod k = (m * (n mod k)) mod k := theorem mul_mod_eq_mul_mod_mod (m n k : nat) : (m * n) mod k = (m * (n mod k)) mod k :=
!mul.comm ▸ !mul.comm ▸ !mul_mod_eq_mod_mul_mod !mul.comm ▸ !mul.comm ▸ !mul_mod_eq_mod_mul_mod
@ -558,7 +558,7 @@ calc
... = ((n - k div m) * m - (k mod m + 1)) div m : ... = ((n - k div m) * m - (k mod m + 1)) div m :
by rewrite [mul.comm m, mul_sub_right_distrib] by rewrite [mul.comm m, mul_sub_right_distrib]
... = ((n - k div m - 1) * m + m - (k mod m + 1)) div m : ... = ((n - k div m - 1) * m + m - (k mod m + 1)) div m :
by rewrite [H3 at {1}, mul.right_distrib, nat.one_mul] by rewrite [H3 at {1}, right_distrib, nat.one_mul]
... = ((n - k div m - 1) * m + (m - (k mod m + 1))) div m : {add_sub_assoc H5 _} ... = ((n - k div m - 1) * m + (m - (k mod m + 1))) div m : {add_sub_assoc H5 _}
... = (m - (k mod m + 1)) div m + (n - k div m - 1) : ... = (m - (k mod m + 1)) div m + (n - k div m - 1) :
by rewrite [add.comm, (add_mul_div_self H4)] by rewrite [add.comm, (add_mul_div_self H4)]
@ -610,7 +610,7 @@ lemma div_lt_of_ne_zero : ∀ {n : nat}, n ≠ 0 → n div 2 < n
| (succ n) h := | (succ n) h :=
begin begin
apply div_lt_of_lt_mul, apply div_lt_of_lt_mul,
rewrite [-add_one, mul.right_distrib], rewrite [-add_one, right_distrib],
change n + 1 < (n * 1 + n) + (1 + 1), change n + 1 < (n * 1 + n) + (1 + 1),
rewrite [mul_one, -add.assoc], rewrite [mul_one, -add.assoc],
apply add_lt_add_right, apply add_lt_add_right,

View file

@ -6,7 +6,7 @@ Author: Leonardo de Moura
Show that tail recursive fib is equal to standard one. Show that tail recursive fib is equal to standard one.
-/ -/
import data.nat import data.nat
open nat open nat algebra
definition fib : nat → nat definition fib : nat → nat
| 0 := 1 | 0 := 1

View file

@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura Author: Leonardo de Moura
-/ -/
import data.nat import data.nat
open nat open nat algebra
definition partial_sum : nat → nat definition partial_sum : nat → nat
| 0 := 0 | 0 := 0
@ -19,10 +19,10 @@ rfl
lemma two_mul_partial_sum_eq : ∀ n, 2 * partial_sum n = (succ n) * n lemma two_mul_partial_sum_eq : ∀ n, 2 * partial_sum n = (succ n) * n
| 0 := by reflexivity | 0 := by reflexivity
| (succ n) := calc | (succ n) := calc
2 * (succ n + partial_sum n) = 2 * succ n + 2 * partial_sum n : mul.left_distrib 2 * (succ n + partial_sum n) = 2 * succ n + 2 * partial_sum n : left_distrib
... = 2 * succ n + succ n * n : two_mul_partial_sum_eq ... = 2 * succ n + succ n * n : two_mul_partial_sum_eq
... = 2 * succ n + n * succ n : mul.comm ... = 2 * succ n + n * succ n : mul.comm
... = (2 + n) * succ n : mul.right_distrib ... = (2 + n) * succ n : right_distrib
... = (n + 2) * succ n : add.comm ... = (n + 2) * succ n : add.comm
... = (succ (succ n)) * succ n : rfl ... = (succ (succ n)) * succ n : rfl

View file

@ -6,7 +6,7 @@ Authors: Floris van Doorn, Leonardo de Moura, Jeremy Avigad
The order relation on the natural numbers. The order relation on the natural numbers.
-/ -/
import data.nat.basic algebra.ordered_ring import data.nat.basic algebra.ordered_ring
open eq.ops open eq.ops algebra
namespace nat namespace nat
@ -73,7 +73,7 @@ theorem lt_add_of_pos_right {n k : } (H : k > 0) : n < n + k :=
theorem mul_le_mul_left {n m : } (k : ) (H : n ≤ m) : k * n ≤ k * m := theorem mul_le_mul_left {n m : } (k : ) (H : n ≤ m) : k * n ≤ k * m :=
obtain (l : ) (Hl : n + l = m), from le.elim H, obtain (l : ) (Hl : n + l = m), from le.elim H,
have k * n + k * l = k * m, by rewrite [-mul.left_distrib, Hl], have k * n + k * l = k * m, by rewrite [-left_distrib, Hl],
le.intro this le.intro this
theorem mul_le_mul_right {n m : } (k : ) (H : n ≤ m) : n * k ≤ m * k := theorem mul_le_mul_right {n m : } (k : ) (H : n ≤ m) : n * k ≤ m * k :=

View file

@ -185,7 +185,7 @@ lemma even_add_of_even_of_even {n m} : even n → even m → even (n+m) :=
suppose even n, suppose even m, suppose even n, suppose even m,
obtain k₁ (hk₁ : n = 2 * k₁), from exists_of_even `even n`, obtain k₁ (hk₁ : n = 2 * k₁), from exists_of_even `even n`,
obtain k₂ (hk₂ : m = 2 * k₂), from exists_of_even `even m`, obtain k₂ (hk₂ : m = 2 * k₂), from exists_of_even `even m`,
even_of_exists (exists.intro (k₁+k₂) (by rewrite [hk₁, hk₂, mul.left_distrib])) even_of_exists (exists.intro (k₁+k₂) (by rewrite [hk₁, hk₂, left_distrib]))
lemma even_add_of_odd_of_odd {n m} : odd n → odd m → even (n+m) := lemma even_add_of_odd_of_odd {n m} : odd n → odd m → even (n+m) :=
suppose odd n, suppose odd m, suppose odd n, suppose odd m,

View file

@ -45,7 +45,7 @@ theorem le_pow_self {x : } (H : x > 1) : ∀ i, i ≤ x^i
succ j = j + 1 : rfl succ j = j + 1 : rfl
... ≤ x^j + 1 : add_le_add_right (le_pow_self j) ... ≤ x^j + 1 : add_le_add_right (le_pow_self j)
... ≤ x^j + x^j : add_le_add_left h₁ ... ≤ x^j + x^j : add_le_add_left h₁
... = x^j * (1 + 1) : by rewrite [mul.left_distrib, *mul_one] ... = x^j * (1 + 1) : by rewrite [left_distrib, *mul_one]
... = x^j * 2 : rfl ... = x^j * 2 : rfl
... ≤ x^j * x : mul_le_mul_left _ `x ≥ 2` ... ≤ x^j * x : mul_le_mul_left _ `x ≥ 2`
... = x^(succ j) : pow_succ' ... = x^(succ j) : pow_succ'

View file

@ -6,7 +6,7 @@ Authors: Floris van Doorn, Jeremy Avigad
Subtraction on the natural numbers, as well as min, max, and distance. Subtraction on the natural numbers, as well as min, max, and distance.
-/ -/
import .order import .order
open eq.ops open eq.ops algebra
namespace nat namespace nat
@ -144,11 +144,11 @@ calc
... = n * m - n * k : {!mul.comm} ... = n * m - n * k : {!mul.comm}
theorem mul_self_sub_mul_self_eq (a b : nat) : a * a - b * b = (a + b) * (a - b) := theorem mul_self_sub_mul_self_eq (a b : nat) : a * a - b * b = (a + b) * (a - b) :=
by rewrite [mul_sub_left_distrib, *mul.right_distrib, mul.comm b a, add.comm (a*a) (a*b), add_sub_add_left] by rewrite [mul_sub_left_distrib, *right_distrib, mul.comm b a, add.comm (a*a) (a*b), add_sub_add_left]
theorem succ_mul_succ_eq (a : nat) : succ a * succ a = a*a + a + a + 1 := theorem succ_mul_succ_eq (a : nat) : succ a * succ a = a*a + a + a + 1 :=
calc succ a * succ a = (a+1)*(a+1) : by rewrite [add_one] calc succ a * succ a = (a+1)*(a+1) : by rewrite [add_one]
... = a*a + a + a + 1 : by rewrite [mul.right_distrib, mul.left_distrib, one_mul, mul_one] ... = a*a + a + a + 1 : by rewrite [right_distrib, left_distrib, one_mul, mul_one]
/- interaction with inequalities -/ /- interaction with inequalities -/
@ -458,7 +458,7 @@ H ▸ !dist.triangle_inequality
theorem dist_mul_right (n k m : ) : dist (n * k) (m * k) = dist n m * k := theorem dist_mul_right (n k m : ) : dist (n * k) (m * k) = dist n m * k :=
assert ∀ n m, dist n m = n - m + (m - n), from take n m, rfl, assert ∀ n m, dist n m = n - m + (m - n), from take n m, rfl,
by rewrite [this, this n m, mul.right_distrib, *mul_sub_right_distrib] by rewrite [this, this n m, right_distrib, *mul_sub_right_distrib]
theorem dist_mul_left (k n m : ) : dist (k * n) (k * m) = k * dist n m := theorem dist_mul_left (k n m : ) : dist (k * n) (k * m) = k * dist n m :=
begin rewrite [mul.comm k n, mul.comm k m, dist_mul_right, mul.comm] end begin rewrite [mul.comm k n, mul.comm k m, dist_mul_right, mul.comm] end

View file

@ -177,7 +177,7 @@ theorem one_mul (n : +) : pone * n = n :=
begin begin
apply pnat.eq, apply pnat.eq,
unfold pone, unfold pone,
rewrite [mul.def, ↑nat_of_pnat, one_mul] rewrite [mul.def, ↑nat_of_pnat, algebra.one_mul]
end end
theorem pone_le (n : +) : pone ≤ n := theorem pone_le (n : +) : pone ≤ n :=
@ -256,13 +256,13 @@ begin
end end
theorem mul.assoc (a b c : +) : a * b * c = a * (b * c) := theorem mul.assoc (a b c : +) : a * b * c = a * (b * c) :=
pnat.eq !nat.mul.assoc pnat.eq !mul.assoc
theorem mul.comm (a b : +) : a * b = b * a := theorem mul.comm (a b : +) : a * b = b * a :=
pnat.eq !nat.mul.comm pnat.eq !mul.comm
theorem add.assoc (a b c : +) : a + b + c = a + (b + c) := theorem add.assoc (a b c : +) : a + b + c = a + (b + c) :=
pnat.eq !nat.add.assoc pnat.eq !add.assoc
theorem mul_le_mul_left (p q : +) : q ≤ p * q := theorem mul_le_mul_left (p q : +) : q ≤ p * q :=
begin begin

View file

@ -276,7 +276,7 @@ private theorem canon_bound {s : seq} (Hs : regular s) (n : +) : abs (s n)
by rewrite [add.comm 1 (abs (s pone)), rat.add.comm 1, rat.add.assoc] by rewrite [add.comm 1 (abs (s pone)), rat.add.comm 1, rat.add.assoc]
... ≤ of_nat (ubound (abs (s pone))) + (1 + 1) : algebra.add_le_add_right (!ubound_ge) ... ≤ of_nat (ubound (abs (s pone))) + (1 + 1) : algebra.add_le_add_right (!ubound_ge)
... = of_nat (ubound (abs (s pone)) + (1 + 1)) : of_nat_add ... = of_nat (ubound (abs (s pone)) + (1 + 1)) : of_nat_add
... = of_nat (ubound (abs (s pone)) + 1 + 1) : nat.add.assoc ... = of_nat (ubound (abs (s pone)) + 1 + 1) : algebra.add.assoc
... = rat_of_pnat (K s) : by esimp ... = rat_of_pnat (K s) : by esimp
theorem bdd_of_regular {s : seq} (H : regular s) : ∃ b : , ∀ n : +, s n ≤ b := theorem bdd_of_regular {s : seq} (H : regular s) : ∃ b : , ∀ n : +, s n ≤ b :=

View file

@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura Author: Leonardo de Moura
-/ -/
import data.nat data.list data.equiv import data.nat data.list data.equiv
open nat function option open nat function option algebra
definition stream (A : Type) := nat → A definition stream (A : Type) := nat → A

View file

@ -7,7 +7,7 @@ Tuples are lists of a fixed size.
It is implemented as a subtype. It is implemented as a subtype.
-/ -/
import logic data.list data.fin import logic data.list data.fin
open nat list subtype function open nat list subtype function algebra
definition tuple [reducible] (A : Type) (n : nat) := {l : list A | length l = n} definition tuple [reducible] (A : Type) (n : nat) := {l : list A | length l = n}

View file

@ -105,7 +105,7 @@ exists.intro N
proposition converges_to_seq_offset_left {X : → M} {y : M} (k : ) (H : X ⟶ y in ) : proposition converges_to_seq_offset_left {X : → M} {y : M} (k : ) (H : X ⟶ y in ) :
(λ n, X (k + n)) ⟶ y in := (λ n, X (k + n)) ⟶ y in :=
have aux : (λ n, X (k + n)) = (λ n, X (n + k)), from funext (take n, by rewrite nat.add.comm), have aux : (λ n, X (k + n)) = (λ n, X (n + k)), from funext (take n, by rewrite add.comm),
by+ rewrite aux; exact converges_to_seq_offset k H by+ rewrite aux; exact converges_to_seq_offset k H
proposition converges_to_seq_offset_succ {X : → M} {y : M} (H : X ⟶ y in ) : proposition converges_to_seq_offset_succ {X : → M} {y : M} (H : X ⟶ y in ) :
@ -127,7 +127,7 @@ exists.intro (N + k)
proposition converges_to_seq_of_converges_to_seq_offset_left proposition converges_to_seq_of_converges_to_seq_offset_left
{X : → M} {y : M} {k : } (H : (λ n, X (k + n)) ⟶ y in ) : {X : → M} {y : M} {k : } (H : (λ n, X (k + n)) ⟶ y in ) :
X ⟶ y in := X ⟶ y in :=
have aux : (λ n, X (k + n)) = (λ n, X (n + k)), from funext (take n, by rewrite nat.add.comm), have aux : (λ n, X (k + n)) = (λ n, X (n + k)), from funext (take n, by rewrite add.comm),
by+ rewrite aux at H; exact converges_to_seq_of_converges_to_seq_offset H by+ rewrite aux at H; exact converges_to_seq_of_converges_to_seq_offset H
proposition converges_to_seq_of_converges_to_seq_offset_succ proposition converges_to_seq_of_converges_to_seq_offset_succ

View file

@ -85,12 +85,12 @@ begin
cases k with k', cases k with k',
{rewrite [*choose_self, one_mul, mul_one]}, {rewrite [*choose_self, one_mul, mul_one]},
{have H : 1 < succ (succ k'), from succ_lt_succ !zero_lt_succ, {have H : 1 < succ (succ k'), from succ_lt_succ !zero_lt_succ,
rewrite [one_mul, choose_zero_succ, choose_eq_zero_of_lt H, zero_mul]}}, krewrite [one_mul, choose_zero_succ, choose_eq_zero_of_lt H, zero_mul]}},
intro k, intro k,
cases k with k', cases k with k',
{rewrite [choose_zero_right, choose_one_right]}, {rewrite [choose_zero_right, choose_one_right]},
rewrite [choose_succ_succ (succ n), mul.right_distrib, -ih (succ k')], rewrite [choose_succ_succ (succ n), right_distrib, -ih (succ k')],
rewrite [choose_succ_succ at {1}, mul.left_distrib, *succ_mul (succ n), mul_succ, -ih k'], rewrite [choose_succ_succ at {1}, left_distrib, *succ_mul (succ n), mul_succ, -ih k'],
rewrite [*add.assoc, add.left_comm (choose n _)] rewrite [*add.assoc, add.left_comm (choose n _)]
end end

View file

@ -278,7 +278,7 @@ eq_of_veq begin rewrite [↑rotl, val_madd], esimp [mk_mod], rewrite [ mod_add_m
lemma rotl_compose : ∀ {n : nat} {j k : nat}, (@rotl n j) ∘ (rotl k) = rotl (j + k) lemma rotl_compose : ∀ {n : nat} {j k : nat}, (@rotl n j) ∘ (rotl k) = rotl (j + k)
| 0 := take j k, funext take i, elim0 i | 0 := take j k, funext take i, elim0 i
| (succ n) := take j k, funext take i, eq.symm begin | (succ n) := take j k, funext take i, eq.symm begin
rewrite [*rotl_succ', mul.left_distrib, -(@madd_mk_mod n (n*j)), madd_assoc], rewrite [*rotl_succ', left_distrib, -(@madd_mk_mod n (n*j)), madd_assoc],
end end
lemma rotr_rotl : ∀ {n : nat} (m : nat) {i : fin n}, rotr m (rotl m i) = i lemma rotr_rotl : ∀ {n : nat} (m : nat) {i : fin n}, rotr m (rotl m i) = i

View file

@ -120,7 +120,7 @@ private theorem mult_pow_mul {p n : } (i : ) (pgt1 : p > 1) (npos : n > 0)
mult p (p^i * n) = i + mult p n := mult p (p^i * n) = i + mult p n :=
begin begin
induction i with [i, ih], induction i with [i, ih],
{rewrite [pow_zero, one_mul, zero_add]}, {krewrite [pow_zero, one_mul, zero_add]},
have p > 0, from lt.trans zero_lt_one pgt1, have p > 0, from lt.trans zero_lt_one pgt1,
have psin_pos : p^(succ i) * n > 0, from mul_pos (!pow_pos_of_pos this) npos, have psin_pos : p^(succ i) * n > 0, from mul_pos (!pow_pos_of_pos this) npos,
have p p^(succ i) * n, by rewrite [pow_succ, mul.assoc]; apply dvd_mul_right, have p p^(succ i) * n, by rewrite [pow_succ, mul.assoc]; apply dvd_mul_right,
@ -175,7 +175,7 @@ calc
theorem mult_pow {p m : } (n : ) (mpos : m > 0) (primep : prime p) : mult p (m^n) = n * mult p m := theorem mult_pow {p m : } (n : ) (mpos : m > 0) (primep : prime p) : mult p (m^n) = n * mult p m :=
begin begin
induction n with n ih, induction n with n ih,
rewrite [pow_zero, mult_one_right, zero_mul], krewrite [pow_zero, mult_one_right, zero_mul],
rewrite [pow_succ, mult_mul primep mpos (!pow_pos_of_pos mpos), ih, succ_mul, add.comm] rewrite [pow_succ, mult_mul primep mpos (!pow_pos_of_pos mpos), ih, succ_mul, add.comm]
end end

View file

@ -43,9 +43,6 @@ add_test(NAME "lean_eqn_macro"
add_test(NAME "lean_print_notation" add_test(NAME "lean_print_notation"
WORKING_DIRECTORY "${LEAN_SOURCE_DIR}/../tests/lean/extra" WORKING_DIRECTORY "${LEAN_SOURCE_DIR}/../tests/lean/extra"
COMMAND bash "./test_single.sh" "${CMAKE_CURRENT_BINARY_DIR}/lean" "print_tests.lean") COMMAND bash "./test_single.sh" "${CMAKE_CURRENT_BINARY_DIR}/lean" "print_tests.lean")
add_test(NAME "auto_completion_issue_422"
WORKING_DIRECTORY "${LEAN_SOURCE_DIR}/../tests/lean/extra"
COMMAND bash "./ac_bug.sh" "${CMAKE_CURRENT_BINARY_DIR}/lean")
add_test(NAME "issue_597" add_test(NAME "issue_597"
WORKING_DIRECTORY "${LEAN_SOURCE_DIR}/../tests/lean/extra" WORKING_DIRECTORY "${LEAN_SOURCE_DIR}/../tests/lean/extra"
COMMAND bash "./issue_597.sh" "${CMAKE_CURRENT_BINARY_DIR}/lean") COMMAND bash "./issue_597.sh" "${CMAKE_CURRENT_BINARY_DIR}/lean")

View file

@ -1,5 +1,5 @@
import data.nat import data.nat
open nat open nat algebra
example (a b c : nat) : a = 2 → b = 3 → a + b + c = c + 5 := example (a b c : nat) : a = 2 → b = 3 → a + b + c = c + 5 :=
begin begin

View file

@ -1,19 +0,0 @@
#!/bin/sh
# Regression test for issue https://github.com/leanprover/lean/issues/422
set -e
if [ $# -ne 1 ]; then
echo "Usage: ac_bug.sh [lean-executable-path]"
exit 1
fi
LEAN=$1
export LEAN_PATH=../../../library:.
for f in `ls ac_bug*.input`; do
echo "testing $f..."
"$LEAN" --server-trace "$f" > "$f.produced.out"
if grep "nat.mul.assoc" "$f.produced.out"; then
echo "FAILED"
exit 1
fi
rm -f -- "$f.produced.out"
done
echo "done"

View file

@ -1,9 +0,0 @@
VISIT ac_bug.lean
SYNC 4
import data.nat
namespace nat
check mul.as
exit
WAIT
FINDP 3
mul.as

View file

@ -1,9 +0,0 @@
VISIT ac_bug.lean
SYNC 4
import data.nat
namespace nat
check mul.as
end nat
WAIT
FINDP 3
mul.as

View file

@ -1,10 +0,0 @@
VISIT ac_bug.lean
SYNC 5
import data.nat
namespace nat
check mul.as
end
nat
WAIT
FINDP 3
mul.as

View file

@ -1,10 +0,0 @@
VISIT ac_bug.lean
SYNC 5
import data.nat
namespace nat
check mul.as
def a := 10
end nat
WAIT
FINDP 3
mul.as

View file

@ -1,9 +0,0 @@
VISIT ac_bug.lean
SYNC 4
import data.nat
namespace nat
check mul.as
def a := 10
WAIT
FINDP 3
mul.as

View file

@ -1,10 +0,0 @@
VISIT ac_bug.lean
SYNC 5
import data.nat
namespace nat
check mul.as
def a := 10
exit
WAIT
FINDP 3
mul.as

View file

@ -1,5 +1,5 @@
import data.nat import data.nat
open nat open nat algebra
example (a b c d : nat) : a + b = 0 → b = 0 → c + 1 + a = 1 → d = c - 1 → d = 0 := example (a b c d : nat) : a + b = 0 → b = 0 → c + 1 + a = 1 → d = c - 1 → d = 0 :=
begin begin
@ -14,7 +14,7 @@ begin
rewrite aeq0 at h₃, rewrite aeq0 at h₃,
rewrite add_zero at h₃, rewrite add_zero at h₃,
rewrite add_succ at h₃, rewrite add_succ at h₃,
rewrite add_zero at h₃, krewrite add_zero at h₃,
injection h₃, exact a_1 injection h₃, exact a_1
end, end,
rewrite ceq at h₄, rewrite ceq at h₄,

View file

@ -1,7 +1,7 @@
VISIT consume_args.lean VISIT consume_args.lean
SYNC 7 SYNC 7
import logic data.nat.basic import logic data.nat.basic
open nat eq.ops open nat eq.ops algebra
theorem tst (a b c : nat) : a + b + c = a + c + b := theorem tst (a b c : nat) : a + b + c = a + c + b :=
calc a + b + c = a + (b + c) : !add.assoc calc a + b + c = a + (b + c) : !add.assoc

View file

@ -44,7 +44,7 @@ b
a + c + b = a + (c + b) a + c + b = a + (c + b)
-- ACK -- ACK
-- IDENTIFIER|7|33 -- IDENTIFIER|7|33
nat.add.assoc algebra.add.assoc
-- ACK -- ACK
-- TYPE|7|43 -- TYPE|7|43
a + c + b = a + (c + b) → a + (c + b) = a + c + b a + c + b = a + (c + b) → a + (c + b) = a + c + b

View file

@ -1,5 +1,5 @@
import data.nat import data.nat
open nat open nat algebra
definition foo (a b : nat) := a * b definition foo (a b : nat) := a * b

View file

@ -3,5 +3,5 @@ open nat
example (a b : nat) : 0 + a + 0 = a := example (a b : nat) : 0 + a + 0 = a :=
begin begin
rewrite [add_zero, zero_add,] rewrite [nat.add_zero, nat.zero_add,]
end end

View file

@ -1,5 +1,5 @@
import data.nat import data.nat
open nat open nat algebra
attribute nat.add [unfold 2] attribute nat.add [unfold 2]
attribute nat.rec_on [unfold 2] attribute nat.rec_on [unfold 2]

View file

@ -18,6 +18,6 @@ example (a b c : nat) : (a + 0 = 0 + a ∧ b + 0 = 0 + b) ∧ c = c :=
begin begin
apply and.intro, apply and.intro,
apply and.intro ;; (state; rewrite zero_add), apply and.intro ;; (state; rewrite nat.zero_add),
apply rfl apply rfl
end end

View file

@ -3,7 +3,7 @@ open nat
theorem zero_left (n : ) : 0 + n = n := theorem zero_left (n : ) : 0 + n = n :=
nat.induction_on n nat.induction_on n
!add_zero !nat.add_zero
(take m IH, show 0 + succ m = succ m, from (take m IH, show 0 + succ m = succ m, from
calc calc
0 + succ m = succ (0 + m) : add_succ 0 + succ m = succ (0 + m) : add_succ

View file

@ -1,11 +1,11 @@
import data.nat import data.nat
open nat open nat algebra
theorem tst (a b : nat) (H : a = 0) : a + b = b := theorem tst (a b : nat) (H : a = 0) : a + b = b :=
begin begin
revert H, revert H,
match a with match a with
| zero := λ H, by rewrite zero_add | zero := λ H, by krewrite zero_add
| (n+1) := λ H, nat.no_confusion H | (n+1) := λ H, nat.no_confusion H
end end
end end

View file

@ -2,4 +2,4 @@ import data.nat
open nat open nat
example (x : ) : 0 = x * 0 := example (x : ) : 0 = x * 0 :=
calc 0 = x * 0 : mul_zero calc 0 = x * 0 : nat.mul_zero

View file

@ -1,4 +1,5 @@
import data.nat import data.nat
open algebra
theorem tst2 (A B C D : Type) : (A × B) × (C × D) → C × B × A := theorem tst2 (A B C D : Type) : (A × B) × (C × D) → C × B × A :=
assume p : (A × B) × (C × D), assume p : (A × B) × (C × D),
@ -62,5 +63,5 @@ obtain y (Hy : b = 2*y), from H₂,
exists.intro exists.intro
(x+y) (x+y)
(calc a+b = 2*x + 2*y : by rewrite [Hx, Hy] (calc a+b = 2*x + 2*y : by rewrite [Hx, Hy]
... = 2*(x+y) : by rewrite mul.left_distrib) ... = 2*(x+y) : by rewrite left_distrib)
end hidden end hidden

View file

@ -1,5 +1,5 @@
import data.nat import data.nat
open nat open nat algebra
namespace foo namespace foo
@ -20,7 +20,7 @@ definition parity : Π (n : nat), Parity n
end, end,
begin begin
change (Parity (2*k + 2*1)), change (Parity (2*k + 2*1)),
rewrite -mul.left_distrib, rewrite -left_distrib,
apply (Parity.even (k+1)) apply (Parity.even (k+1))
end end
end end

View file

@ -12,7 +12,7 @@ print nat.rec
print classical.em print classical.em
print quot.lift print quot.lift
print nat.of_num print nat.of_num
print nat.add.assoc print nat.add_assoc
section section
parameter {A : Type} parameter {A : Type}

View file

@ -1,5 +1,5 @@
import data.nat.basic import data.nat.basic
open nat open nat algebra
theorem zero_left (n : ) : 0 + n = n := theorem zero_left (n : ) : 0 + n = n :=
nat.induction_on n nat.induction_on n

View file

@ -1,5 +1,5 @@
import data.nat import data.nat
open nat open nat algebra
section section
variables (a b c d e : nat) variables (a b c d e : nat)
@ -9,7 +9,7 @@ section
end end
example (x y : ) : (x + y) * (x + y) = x * x + y * x + x * y + y * y := example (x y : ) : (x + y) * (x + y) = x * x + y * x + x * y + y * y :=
by rewrite [*mul.left_distrib, *mul.right_distrib, -add.assoc] by rewrite [*left_distrib, *right_distrib, -add.assoc]
namespace tst namespace tst
definition even (a : nat) := ∃b, a = 2*b definition even (a : nat) := ∃b, a = 2*b
@ -19,7 +19,7 @@ exists.elim H1 (fun (w1 : nat) (Hw1 : a = 2*w1),
exists.elim H2 (fun (w2 : nat) (Hw2 : b = 2*w2), exists.elim H2 (fun (w2 : nat) (Hw2 : b = 2*w2),
exists.intro (w1 + w2) exists.intro (w1 + w2)
begin begin
rewrite [Hw1, Hw2, mul.left_distrib] rewrite [Hw1, Hw2, left_distrib]
end)) end))
theorem T2 (a b c : nat) (H1 : a = b) (H2 : b = c + 1) : a ≠ 0 := theorem T2 (a b c : nat) (H1 : a = b) (H2 : b = c + 1) : a ≠ 0 :=

View file

@ -1,5 +1,5 @@
import data.nat import data.nat
open nat open nat algebra
variables (f : nat → nat → nat → nat) (a b c : nat) variables (f : nat → nat → nat → nat) (a b c : nat)
example (H₁ : a = b) (H₂ : f b a b = 0) : f a a a = 0 := example (H₁ : a = b) (H₂ : f b a b = 0) : f a a a = 0 :=

View file

@ -3,4 +3,4 @@ open nat
constant f : nat → nat constant f : nat → nat
theorem tst1 (x y : nat) (H1 : (λ z, z + 0) x = y) : f x = f y := theorem tst1 (x y : nat) (H1 : (λ z, z + 0) x = y) : f x = f y :=
by rewrite [▸* at H1, add_zero at H1, H1] by rewrite [▸* at H1, nat.add_zero at H1, H1]

View file

@ -1,5 +1,5 @@
import data.nat import data.nat
open nat open nat algebra
constant f : nat → nat constant f : nat → nat
example (x y : nat) (H1 : (λ z, z + 0) x = y) : f x = f y := example (x y : nat) (H1 : (λ z, z + 0) x = y) : f x = f y :=

View file

@ -8,5 +8,5 @@ attribute of_num [unfold 1]
example (x y : nat) (H1 : f x 0 0 = 0) : x = 0 := example (x y : nat) (H1 : f x 0 0 = 0) : x = 0 :=
begin begin
rewrite [↑f at H1, 4>add_zero at H1, H1] rewrite [↑f at H1, 4>nat.add_zero at H1, H1]
end end

View file

@ -1,5 +1,5 @@
import data.nat import data.nat
open nat open nat algebra
set_option rewriter.syntactic true set_option rewriter.syntactic true

View file

@ -1,5 +1,5 @@
import data.nat import data.nat
open nat open nat algebra
theorem tst (x : nat) (H1 : x = 0) : x = 0 := theorem tst (x : nat) (H1 : x = 0) : x = 0 :=
begin begin

View file

@ -1,15 +1,15 @@
import data.nat import data.nat
namespace foo namespace foo
attribute nat.add.assoc [simp] attribute nat.add_assoc [simp]
print nat.add.assoc print nat.add_assoc
end foo end foo
print nat.add.assoc print nat.add_assoc
namespace foo namespace foo
print nat.add.assoc print nat.add_assoc
attribute nat.add.comm [simp] attribute nat.add_comm [simp]
open nat open nat
print "---------" print "---------"
print [simp] print [simp]

View file

@ -1,5 +1,5 @@
import data.nat import data.nat
open nat open nat algebra
example : ∀ a b : nat, a + b = b + a := example : ∀ a b : nat, a + b = b + a :=
show ∀ a b : nat, a + b = b + a show ∀ a b : nat, a + b = b + a

View file

@ -7,7 +7,7 @@ structure semigroup [class] (A : Type) :=
mk {} :: (mul: A → A → A) (mul_assoc : associative mul) mk {} :: (mul: A → A → A) (mul_assoc : associative mul)
definition nat_semigroup [instance] : semigroup nat := definition nat_semigroup [instance] : semigroup nat :=
semigroup.mk nat.mul nat.mul.assoc semigroup.mk nat.mul nat.mul_assoc
example (a b c : nat) : (a * b) * c = a * (b * c) := example (a b c : nat) : (a * b) * c = a * (b * c) :=
semigroup.mul_assoc a b c semigroup.mul_assoc a b c
@ -15,7 +15,7 @@ semigroup.mul_assoc a b c
structure semigroup2 (A : Type) := structure semigroup2 (A : Type) :=
mk () :: (mul: A → A → A) (mul_assoc : associative mul) mk () :: (mul: A → A → A) (mul_assoc : associative mul)
definition s := semigroup2.mk nat nat.mul nat.mul.assoc definition s := semigroup2.mk nat nat.mul nat.mul_assoc
example (a b c : nat) : (a * b) * c = a * (b * c) := example (a b c : nat) : (a * b) * c = a * (b * c) :=
semigroup2.mul_assoc nat s a b c semigroup2.mul_assoc nat s a b c

View file

@ -12,7 +12,7 @@ structure s3 (A : Type) extends s1 A, s2 A :=
definition v1 : s1 nat := {| s1, x := 10, y := 10, h := rfl |} definition v1 : s1 nat := {| s1, x := 10, y := 10, h := rfl |}
definition v2 : s2 nat := {| s2, mul := nat.add, one := zero |} definition v2 : s2 nat := {| s2, mul := nat.add, one := zero |}
definition v3 : s3 nat := {| s3, mul_one := add_zero, v1, v2 |} definition v3 : s3 nat := {| s3, mul_one := nat.add_zero, v1, v2 |}
example : s3.x v3 = 10 := rfl example : s3.x v3 = 10 := rfl
example : s3.y v3 = 10 := rfl example : s3.y v3 = 10 := rfl

View file

@ -1,4 +1,5 @@
import data.nat import data.nat
open algebra
example (a b c : Prop) : a → b → c → a ∧ b ∧ c := example (a b c : Prop) : a → b → c → a ∧ b ∧ c :=
begin begin

View file

@ -18,7 +18,7 @@ private definition fib_fast_aux : nat → nat → nat → nat
| (succ n) i j := fib_fast_aux n j (j+i) | (succ n) i j := fib_fast_aux n j (j+i)
lemma fib_fast_aux_lemma : ∀ n m, fib_fast_aux n (fib m) (fib (succ m)) = fib (succ (n + m)) lemma fib_fast_aux_lemma : ∀ n m, fib_fast_aux n (fib m) (fib (succ m)) = fib (succ (n + m))
| 0 m := by rewrite zero_add | 0 m := by rewrite nat.zero_add
| (succ n) m := | (succ n) m :=
begin begin
have ih : fib_fast_aux n (fib (succ m)) (fib (succ (succ m))) = fib (succ (n + succ m)), from fib_fast_aux_lemma n (succ m), have ih : fib_fast_aux n (fib (succ m)) (fib (succ (succ m))) = fib (succ (n + succ m)), from fib_fast_aux_lemma n (succ m),

View file

@ -1,5 +1,5 @@
import data.nat import data.nat
open nat open nat algebra
example (a b : nat) : a = b → 0 + a = 0 + b := example (a b : nat) : a = b → 0 + a = 0 + b :=
begin begin

View file

@ -12,7 +12,7 @@
import logic data.nat import logic data.nat
-- import congr -- import congr
open nat open nat algebra
-- open congr -- open congr
open eq.ops eq open eq.ops eq

View file

@ -1,5 +1,5 @@
import data.nat import data.nat
open nat open nat algebra
definition f (a b : nat) := a + b definition f (a b : nat) := a + b