lean4-htt/tests/lean/run/auto_quote1.lean
2016-10-01 12:57:56 -07:00

62 lines
1.4 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

example (a b c : nat) : a = b → b = c → c = a :=
begin
intros,
apply eq.symm,
apply eq.trans,
assumption,
assumption
end
example (a b c : nat) : a = b → b = c → c = a :=
begin
intro h1,
intro h2,
refine eq.symm (eq.trans h1 _),
exact h2
end
example (a b c : nat) : a = b → b = c → c = a :=
begin
intros h1 h2, -- we can optionally provide the names
refine eq.symm (eq.trans h1 _),
exact h2
end
example (a b c : nat) : a = b → b = c → c = a :=
begin
intro h1,
intro, -- optional argument
refine eq.symm (eq.trans h1 _),
assumption
end
constant addc {a b : nat} : a + b = b + a
constant addassoc {a b c : nat} : (a + b) + c = a + (b + c)
constant zadd (a : nat) : 0 + a = a
example (a b c : nat) : b = 0 → 0 + a + b + c = c + a :=
begin
intro h,
rewrite h, -- single rewrite
rewrite [zadd, @addc a 0, zadd, addc] -- sequence of rewrites
end
example (a b c : nat) : 0 = b → 0 + a + b + c = c + a :=
begin
intro h,
rewrite -h, -- single rewrite using symmetry
rw [zadd, @addc a 0, zadd, addc] -- rw is shorthand for rewrite
end
open nat
example : ∀ n m : , n + m = m + n :=
begin
intros n m,
induction m with m' ih,
{ -- Remark: Used change here to make sure nat.zero is replaced with polymorphic zero.
-- dsimp tactic should fix that in the future.
change n + 0 = 0 + n, rw zadd n },
{ change succ (n + m') = succ m' + n,
rw [succ_add, ih] }
end