-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Since a few weeks ago, the proof for the char.zero_lt_d800 theorem in the core library has almost a trillion subterms if we count them as a tree:
open expr native
attribute [inline] bool.decidable_eq state.monad return
section
local attribute [inline] cmp cmp_using expr.decidable_rel
meta def mk_fast_expr_map {α} : rb_map expr α :=
rb_map.mk_core _ cmp
end
meta def expr.daglike_size (e : expr) : ℕ :=
let empty_set : rb_set expr := mk_fast_expr_map in
(e.fold empty_set $ λ e _ sts, sts.insert e).size
@[inline] private meta def set_size {α β} (a : α) (b : β) : state (rb_map α β) β :=
do m ← state.read, state.write $ m.insert a b, return b
private meta def treelike_size_core : expr → state (rb_map expr ℕ) ℕ | e :=
do m ← state.read, match m.find e with some s := return s | none := match e with
| (app a b) := do sa ← treelike_size_core a, sb ← treelike_size_core b, return $ sa + sb
| (elet _ t v b) := do st ← treelike_size_core t, sv ← treelike_size_core v,
sb ← treelike_size_core b, return $ st + sv + sb
| (pi _ _ d b) := do sd ← treelike_size_core d, sb ← treelike_size_core b, return $ sd + sb
| (lam _ _ d b) := do sd ← treelike_size_core d, sb ← treelike_size_core b, return $ sd + sb
| e := return 1
end >>= set_size e end
meta def expr.treelike_size (e : expr) : ℕ :=
(treelike_size_core e mk_fast_expr_map).1
#eval `(5+5+5+5+5+5+5).daglike_size
#eval `(5+5+5+5+5+5+5).treelike_size
open tactic
#eval do env ← get_env, decl ← returnex $ env.get ``char.zero_lt_d800,
trace $ "dag-like subterms: " ++ repr decl.value.daglike_size,
trace $ "tree-like subterms: " ++ repr (decl.value.treelike_size / 10^9) ++ " billion"
-- dag-like subterms: 344
-- tree-like subterms: 761 billionAccordingly, tc fails to type-check this theorem in reasonable time (I waited for 10 minutes although I suspect it would take much much longer). I have put the exported text file in a gist: lean init/data/char/basic.lean --export=char_zero_lt_d800.txt --only-export=char.zero_lt_d800.
Metadata
Metadata
Assignees
Labels
No labels