Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new tests, minor adjustments #2

Merged
merged 1 commit into from Apr 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 5 additions & 10 deletions src/norm_coe.lean
Expand Up @@ -65,7 +65,7 @@ do
) <|> add_decl (declaration.thm new_n l ty task_e)

private meta def mk_cache : list name → tactic simp_lemmas :=
monad.foldl (λ s, s.add_simp ∘ new_name) simp_lemmas.mk
monad.foldl (λ s, s.add_simp ∘ new_name) simp_lemmas.mk

@[user_attribute]
meta def norm_coe_attr : user_attribute simp_lemmas :=
Expand Down Expand Up @@ -94,8 +94,8 @@ meta def simp_coe_attr : user_attribute simp_lemmas :=
meta def post_aux : expr → tactic (expr × expr)
| e@(expr.app (expr.app op x) y) :=
do
`(@coe %%α %%δ %%coe1 %%xx) ← return x | failed,
`(@coe %%β %%γ %%coe2 %%yy) ← return y | failed,
`(@coe %%α %%δ %%coe1 %%xx) ← return x,
`(@coe %%β %%γ %%coe2 %%yy) ← return y,
is_def_eq δ γ,

(do
Expand Down Expand Up @@ -135,12 +135,7 @@ meta def post (e : expr) : tactic (expr × expr) :=
do
(tmp_e, pr1) ← post_aux e <|> prod.mk e <$> mk_eq_refl e,

ty ← infer_type e,
let r := match ty with
| (expr.sort zero) := `iff
| _ := `eq
end,

r ← mcond (is_prop e) (return `iff) (return `eq),
s ← norm_coe_attr.get_cache,
(new_e, pr2) ← s.rewrite tmp_e failed r,

Expand Down Expand Up @@ -185,7 +180,7 @@ open tactic interactive interactive.types
open norm_coe

meta def assumption_mod_coe : tactic unit :=
tactic.assumption_mod_coe
tactic.assumption_mod_coe

meta def norm_coe1 (loc : parse location) : tactic unit :=
do
Expand Down
4 changes: 4 additions & 0 deletions src/tests.lean
Expand Up @@ -37,5 +37,9 @@ by {norm_coe1, refl}
example : (an : ℤ) = 1 → an = 1 := by {intro, assumption_mod_coe}
example : (an : ℤ) < 5 → an < 5 := by {intro, assumption_mod_coe}
example : an < 5 → (an : ℤ) < 5 := by {intro, assumption_mod_coe}
example : (an + 5) < 10 → (an : ℤ) + 5 < 10 := by {intro, assumption_mod_coe}
example : (an : ℤ) + 5 < 10 → (an + 5) < 10 := by {intro, assumption_mod_coe}
example : ((an + 5 : ℕ) : ℤ) < 10 → an + 5 < 10 := by {intro, assumption_mod_coe}
example : an + 5 < 10 → ((an + 5 : ℕ) : ℤ) < 10 := by {intro, assumption_mod_coe}

example : 1 = (az : ℚ) / (bz : ℚ) ↔ 1 = (az : ℝ) / (bz : ℝ) := sorry