itauto unfolds definitions
While trying out itauto lia
on bedrock2, I ran into a case where it kept eating more and more RAM until I killed coqc at 5GB of RAM usage.
I haven't managed to isolate the RAM consumption issue yet (I suspect it requires dependent types that depend on large nat constants), but here's a simpler example that already exhibits some undesired behavior:
Require Import ZArith List.
Require Import Cdcl.Itauto.
Fixpoint compile(program: nat): list Z :=
match program with
| S n => Z.of_nat n :: compile n
| O => nil
end.
Axiom F: list Z -> list Z.
Goal F (compile 1000) = compile 1000 -> 0 = 0.
Proof. intros. Time itauto reflexivity. Qed. (* 0.206 secs *)
Goal F (compile 2000) = compile 2000 -> 0 = 0.
Proof. intros. Time itauto reflexivity. Qed. (* 0.754 secs *)
Goal F (compile 3000) = compile 3000 -> 0 = 0.
Proof. intros. Time itauto reflexivity. Qed. (* 1.678 secs *)
Goal F (compile 4000) = compile 4000 -> 0 = 0.
Proof. intros. Time itauto reflexivity. Qed. (* 2.987 secs *)
Axiom opaque_compile: nat -> list Z.
Goal F (opaque_compile 1000) = opaque_compile 1000 -> 0 = 0.
Proof. intros. Time itauto reflexivity. Qed. (* 0.016 secs *)
Goal F (opaque_compile 2000) = opaque_compile 2000 -> 0 = 0.
Proof. intros. Time itauto reflexivity. Qed. (* 0.029 secs *)
Goal F (opaque_compile 3000) = opaque_compile 3000 -> 0 = 0.
Proof. intros. Time itauto reflexivity. Qed. (* 0.042 secs *)
Goal F (opaque_compile 4000) = opaque_compile 4000 -> 0 = 0.
Proof. intros. Time itauto reflexivity. Qed. (* 0.055 secs *)
These timing numbers suggest that itauto reflexivity
does something like unfolding the definition of compile
.
In my experience, any tactic that tries to be smart and unfolds definitions in a way not controllable by the user will eventually become unusably slow.
Of course, sometimes some smart but uncontrollable unfolding is useful, but I'd say that this only works on very small goals, and firstorder lia
or firstorder congruence
already does that.
Therefore, I wonder if itauto
could guarantee its users that it never unfolds anything?