Skip to content

Exponential blowup with Hint Unfold #14874

@cpitclaudel

Description

@cpitclaudel

Description of the problem

I'm running into performance issues with Hint Unfold. The following example shows eauto 10 going from 0.01 second to 1 second by adding one Hint Unfold, and to 1 minute by adding another hint:

Fixpoint exp (P: Prop) n :=
  match n with
  | O => P
  | S x => exp P x /\ exp P x
  end.

Create HintDb test discriminated.

Goal exp False 12.
  unfold exp.

  Time eauto 10.

  Hint Unfold plus : test.
  Time eauto 10 with test.

  Hint Unfold minus : test.
  Time eauto 10 with test.

The problem is that the first eauto exits immediately, whereas the second one explores an exponential number of permutations of "unfold plus". Here's part of the output of debug eauto:

Debug: 1 depth=5
Debug: 1.1 depth=4 unfold Nat.sub
Debug: 1.1.1 depth=3 unfold Nat.sub
Debug: 1.1.1.1 depth=2 unfold Nat.sub
Debug: 1.1.1.1.1 depth=1 unfold Nat.sub
Debug: 1.1.1.1.1.1 depth=0 unfold Nat.sub
Debug: 1.1.1.1.1.2 depth=0 unfold Nat.add
Debug: 1.1.1.1.1.3 depth=0 simple apply conj
Debug: 1.1.1.1.2 depth=1 unfold Nat.add
Debug: 1.1.1.1.2.1 depth=0 unfold Nat.sub
Debug: 1.1.1.1.2.2 depth=0 unfold Nat.add
Debug: 1.1.1.1.2.3 depth=0 simple apply conj
Debug: 1.1.1.1.3 depth=1 simple apply conj
Debug: 1.1.1.1.3.1 depth=0 unfold Nat.sub
Debug: 1.1.1.1.3.2 depth=0 unfold Nat.add
Debug: 1.1.1.1.3.3 depth=0 simple apply conj
Debug: 1.1.1.2 depth=2 unfold Nat.add
Debug: 1.1.1.2.1 depth=1 unfold Nat.sub
Debug: 1.1.1.2.1.1 depth=0 unfold Nat.sub
Debug: 1.1.1.2.1.2 depth=0 unfold Nat.add
Debug: 1.1.1.2.1.3 depth=0 simple apply conj
Debug: 1.1.1.2.2 depth=1 unfold Nat.add
Debug: 1.1.1.2.2.1 depth=0 unfold Nat.sub
Debug: 1.1.1.2.2.2 depth=0 unfold Nat.add
Debug: 1.1.1.2.2.3 depth=0 simple apply conj
Debug: 1.1.1.2.3 depth=1 simple apply conj
Debug: 1.1.1.2.3.1 depth=0 unfold Nat.sub
Debug: 1.1.1.2.3.2 depth=0 unfold Nat.add
Debug: 1.1.1.2.3.3 depth=0 simple apply conj
Debug: 1.1.1.3 depth=2 simple apply conj
Debug: 1.1.1.3.1 depth=1 unfold Nat.sub
Debug: 1.1.1.3.1.1 depth=0 unfold Nat.sub
Debug: 1.1.1.3.1.2 depth=0 unfold Nat.add
Debug: 1.1.1.3.1.3 depth=0 simple apply conj

Am I doing something wrong?

Coq Version

A recent master: 598628f
Also in 8.12.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind: performanceImprovements to performance and efficiency.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions