lean2/tests/lean/simp3.lean

100 lines
2.4 KiB
Text
Raw Normal View History

definition double x := x + x
(*
function show(x) print(x) end
local t1 = parse_lean("0 ≠ 1")
show(simplify(t1))
local t2 = parse_lean("3 ≥ 2")
show(simplify(t2))
local t3 = parse_lean("double (double 2) + 1")
show(simplify(t3))
local t4 = parse_lean("0 = 1")
show(simplify(t4))
*)
(*
local opt = options({"simplifier", "unfold"}, true, {"simplifier", "eval"}, false)
local t1 = parse_lean("double (double 2) + 1 ≥ 3")
show(simplify(t1, 'default', get_environment(), context(), opt))
*)
set_opaque Nat::ge false
add_rewrite Nat::add_assoc
add_rewrite Nat::distributer
add_rewrite Nat::distributel
(*
local opt = options({"simplifier", "unfold"}, true, {"simplifier", "eval"}, false)
local t1 = parse_lean("2 * double (double 2) + 1 ≥ 3")
show(simplify(t1, 'default', get_environment(), context(), opt))
*)
variables a b c d : Nat
import if_then_else
add_rewrite if_true
add_rewrite if_false
add_rewrite if_a_a
add_rewrite Nat::add_zeror
add_rewrite Nat::add_zerol
add_rewrite eq_id
(*
local t1 = parse_lean("(a + b) * (c + d)")
local r, pr = simplify(t1)
print(r)
print(pr)
*)
theorem congr2_congr1 {A B C : TypeU} {f g : A → B} (h : B → C) (Hfg : f = g) (a : A) :
congr2 h (congr1 a Hfg) = congr2 (λ x, h (x a)) Hfg
:= proof_irrel (congr2 h (congr1 a Hfg)) (congr2 (λ x, h (x a)) Hfg)
theorem congr2_congr2 {A B C : TypeU} {a b : A} (f : A → B) (h : B → C) (Hab : a = b) :
congr2 h (congr2 f Hab) = congr2 (λ x, h (f x)) Hab
:= proof_irrel (congr2 h (congr2 f Hab)) (congr2 (λ x, h (f x)) Hab)
theorem congr1_congr2 {A B C : TypeU} {a b : A} (f : A → B → C) (Hab : a = b) (c : B):
congr1 c (congr2 f Hab) = congr2 (λ x, f x c) Hab
:= proof_irrel (congr1 c (congr2 f Hab)) (congr2 (λ x, f x c) Hab)
rewrite_set proofsimp
add_rewrite congr2_congr1 congr2_congr2 congr1_congr2 : proofsimp
(*
local t2 = parse_lean("(if a > 0 then b else b + 0) + 10 = (if a > 0 then b else b) + 10")
local r, pr = simplify(t2)
print(r)
print(pr)
show(simplify(pr, 'proofsimp'))
*)
(*
local t1 = parse_lean("(a + b) * (a + b)")
local t2 = simplify(t1)
print(t2)
*)
-- add_rewrite imp_truer imp_truel imp_falsel imp_falser not_true not_false
-- print rewrite_set
(*
local t1 = parse_lean("true → false")
print(simplify(t1))
*)
(*
local t1 = parse_lean("true → true")
print(simplify(t1))
*)
(*
local t1 = parse_lean("false → false")
print(simplify(t1))
*)
(*
local t1 = parse_lean("true ↔ false")
print(simplify(t1))
*)