Closed kendroe closed 6 years ago
Using dsimp
should get rid of those projections for you.
@kendroe The right place for questions like is Zulip, https://leanprover.zulipchat.com/.
There are various bugs in your code:
prod.fst
and prod.mk
some
(it dropped you into the option
monad)The modification below works.
open tactic
meta def simplifyProd : expr → expr
| `(prod.fst (prod.mk %%a %%b)) := a
| (expr.app a b) := expr.app (simplifyProd a) (simplifyProd b)
| (expr.lam v b t e) := expr.lam v b (simplifyProd t) (simplifyProd e)
| (expr.pi v b t e) := expr.pi v b (simplifyProd t) (simplifyProd e)
| x := x
theorem testit (f:ℕ) (s:ℕ) :
(f,s).fst=f :=
begin
do {
t ← target,
trace "Start",
trace t,
let tq := (simplifyProd t),
trace tq,
change tq
},
refl
end
@avigad @cipher1024 Thanks.
Since this is not a bug, I am closing this issue.
Prerequisites
Description
A simple meta program to simplify a product expression fails. The program generates no errors.
Steps to Reproduce
Try the following program:
meta def simplifyProd : expr → expr | (expr.app (expr.app (expr.app
(prod.fst) tt1a) tt1b) (expr.app (expr.app (expr.app (expr.app
(prod.mk) tt1) tt2) a) b)) := a | (expr.app a b) := expr.app (simplifyProd a) (simplifyProd b) | (expr.lam v b t e) := expr.lam v b (simplifyProd t) (simplifyProd e) | (expr.pi v b t e) := expr.pi v b (simplifyProd t) (simplifyProd e) | x := xtheorem testit (f:ℕ) (s:ℕ) : (f,s).fst=f := begin do { t ← target, trace "Start", trace t.to_raw_fmt, tq ← some (simplifyProd t), trace tq.to_raw_fmt, change tq }, refl end
Expected behavior: [What you expect to happen]
tq should have the expression "f=f"
Actual behavior: [What actually happens]
tq gets the expression (f,s).fs=f
Reproduces how often: [What percentage of the time does it reproduce?]
always
Versions
Lean 3.4.1
Additional Information