2014-01-20 07:26:34 +00:00
|
|
|
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")
|
2014-01-27 23:02:05 +00:00
|
|
|
show(simplify(t1, 'default', opt))
|
2014-01-20 07:26:34 +00:00
|
|
|
*)
|
|
|
|
|
|
|
|
set_opaque Nat::ge false
|
2014-01-31 03:11:58 +00:00
|
|
|
rewrite_set basic
|
|
|
|
add_rewrite Nat::add_assoc Nat::distributer Nat::distributel : basic
|
2014-01-20 07:26:34 +00:00
|
|
|
|
|
|
|
(*
|
|
|
|
local opt = options({"simplifier", "unfold"}, true, {"simplifier", "eval"}, false)
|
|
|
|
local t1 = parse_lean("2 * double (double 2) + 1 ≥ 3")
|
2014-01-31 03:11:58 +00:00
|
|
|
show(simplify(t1, "basic", opt))
|
2014-01-20 07:26:34 +00:00
|
|
|
*)
|
|
|
|
|
|
|
|
variables a b c d : Nat
|
|
|
|
|
2014-01-31 03:11:58 +00:00
|
|
|
add_rewrite if_true if_false if_a_a Nat::add_zeror Nat::add_zerol eq_id : basic
|
2014-01-20 07:26:34 +00:00
|
|
|
|
|
|
|
(*
|
|
|
|
local t1 = parse_lean("(a + b) * (c + d)")
|
2014-01-31 03:11:58 +00:00
|
|
|
local r, pr = simplify(t1, "basic")
|
2014-01-20 07:26:34 +00:00
|
|
|
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")
|
2014-01-31 03:11:58 +00:00
|
|
|
local r, pr = simplify(t2, "basic")
|
2014-01-20 07:26:34 +00:00
|
|
|
print(r)
|
|
|
|
print(pr)
|
|
|
|
show(simplify(pr, 'proofsimp'))
|
|
|
|
*)
|
|
|
|
|
|
|
|
|
|
|
|
(*
|
|
|
|
local t1 = parse_lean("(a + b) * (a + b)")
|
2014-01-31 03:11:58 +00:00
|
|
|
local t2 = simplify(t1, "basic")
|
2014-01-20 07:26:34 +00:00
|
|
|
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")
|
2014-01-31 03:11:58 +00:00
|
|
|
print(simplify(t1, "basic"))
|
2014-01-20 07:26:34 +00:00
|
|
|
*)
|
|
|
|
|
|
|
|
(*
|
|
|
|
local t1 = parse_lean("true → true")
|
2014-01-31 03:11:58 +00:00
|
|
|
print(simplify(t1, "basic"))
|
2014-01-20 07:26:34 +00:00
|
|
|
*)
|
|
|
|
|
|
|
|
(*
|
|
|
|
local t1 = parse_lean("false → false")
|
2014-01-31 03:11:58 +00:00
|
|
|
print(simplify(t1, "basic"))
|
2014-01-20 07:26:34 +00:00
|
|
|
*)
|
|
|
|
|
|
|
|
(*
|
|
|
|
local t1 = parse_lean("true ↔ false")
|
2014-01-31 03:11:58 +00:00
|
|
|
print(simplify(t1, "basic"))
|
2014-01-20 07:26:34 +00:00
|
|
|
*)
|