From 24cc2e4786b2344e092e412f56e96c6971ab60d8 Mon Sep 17 00:00:00 2001
From: Robbert Krebbers <mail@robbertkrebbers.nl>
Date: Thu, 17 Aug 2017 19:26:06 +0200
Subject: [PATCH] Use simple apply in f_equiv and solve_proper.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

As suggested by Pierre-Marie Pédrot in the Coq-club thread:

  [Coq-Club] Very slow failing apply

To work arround some performance issues in Iris.
---
 theories/tactics.v | 44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/theories/tactics.v b/theories/tactics.v
index 9195ec96..f775ad80 100644
--- a/theories/tactics.v
+++ b/theories/tactics.v
@@ -286,39 +286,39 @@ Ltac f_equiv :=
   | H : ?R ?x ?y |- ?R2 (match ?x with _ => _ end) (match ?y with _ => _ end) =>
      destruct H
   (* First assume that the arguments need the same relation as the result *)
-  | |- ?R (?f _) _ => apply (_ : Proper (R ==> R) f)
-  | |- ?R (?f _ _) _ => apply (_ : Proper (R ==> R ==> R) f)
-  | |- ?R (?f _ _ _) _ => apply (_ : Proper (R ==> R ==> R ==> R) f)
-  | |- ?R (?f _ _ _ _) _ => apply (_ : Proper (R ==> R ==> R ==> R ==> R) f)
+  | |- ?R (?f _) _ => simple apply (_ : Proper (R ==> R) f)
+  | |- ?R (?f _ _) _ => simple apply (_ : Proper (R ==> R ==> R) f)
+  | |- ?R (?f _ _ _) _ => simple apply (_ : Proper (R ==> R ==> R ==> R) f)
+  | |- ?R (?f _ _ _ _) _ => simple apply (_ : Proper (R ==> R ==> R ==> R ==> R) f)
   (* For the case in which R is polymorphic, or an operational type class,
   like equiv. *)
-  | |- (?R _) (?f _) _ => apply (_ : Proper (R _ ==> _) f)
-  | |- (?R _ _) (?f _) _ => apply (_ : Proper (R _ _ ==> _) f)
-  | |- (?R _ _ _) (?f _) _ => apply (_ : Proper (R _ _ _ ==> _) f)
-  | |- (?R _) (?f _ _) _ => apply (_ : Proper (R _ ==> R _ ==> _) f)
-  | |- (?R _ _) (?f _ _) _ => apply (_ : Proper (R _ _ ==> R _ _ ==> _) f)
-  | |- (?R _ _ _) (?f _ _) _ => apply (_ : Proper (R _ _ _ ==> R _ _ _ ==> _) f)
-  | |- (?R _) (?f _ _ _) _ => apply (_ : Proper (R _ ==> R _ ==> R _ ==> _) f)
-  | |- (?R _ _) (?f _ _ _) _ => apply (_ : Proper (R _ _ ==> R _ _ ==> R _ _ ==> _) f)
-  | |- (?R _ _ _) (?f _ _ _) _ => apply (_ : Proper (R _ _ _ ==> R _ _ _ R _ _ _ ==> _) f)
-  | |- (?R _) (?f _ _ _ _) _ => apply (_ : Proper (R _ ==> R _ ==> R _ ==> R _ ==> _) f)
-  | |- (?R _ _) (?f _ _ _ _) _ => apply (_ : Proper (R _ _ ==> R _ _ ==> R _ _ ==> R _ _ ==> _) f)
-  | |- (?R _ _ _) (?f _ _ _ _) _ => apply (_ : Proper (R _ _ _ ==> R _ _ _ R _ _ _ ==> R _ _ _ ==> _) f)
+  | |- (?R _) (?f _) _ => simple apply (_ : Proper (R _ ==> _) f)
+  | |- (?R _ _) (?f _) _ => simple apply (_ : Proper (R _ _ ==> _) f)
+  | |- (?R _ _ _) (?f _) _ => simple apply (_ : Proper (R _ _ _ ==> _) f)
+  | |- (?R _) (?f _ _) _ => simple apply (_ : Proper (R _ ==> R _ ==> _) f)
+  | |- (?R _ _) (?f _ _) _ => simple apply (_ : Proper (R _ _ ==> R _ _ ==> _) f)
+  | |- (?R _ _ _) (?f _ _) _ => simple apply (_ : Proper (R _ _ _ ==> R _ _ _ ==> _) f)
+  | |- (?R _) (?f _ _ _) _ => simple apply (_ : Proper (R _ ==> R _ ==> R _ ==> _) f)
+  | |- (?R _ _) (?f _ _ _) _ => simple apply (_ : Proper (R _ _ ==> R _ _ ==> R _ _ ==> _) f)
+  | |- (?R _ _ _) (?f _ _ _) _ => simple apply (_ : Proper (R _ _ _ ==> R _ _ _ R _ _ _ ==> _) f)
+  | |- (?R _) (?f _ _ _ _) _ => simple apply (_ : Proper (R _ ==> R _ ==> R _ ==> R _ ==> _) f)
+  | |- (?R _ _) (?f _ _ _ _) _ => simple apply (_ : Proper (R _ _ ==> R _ _ ==> R _ _ ==> R _ _ ==> _) f)
+  | |- (?R _ _ _) (?f _ _ _ _) _ => simple apply (_ : Proper (R _ _ _ ==> R _ _ _ R _ _ _ ==> R _ _ _ ==> _) f)
   (* Next, try to infer the relation. Unfortunately, there is an instance
      of Proper for (eq ==> _), which will always be matched. *)
   (* TODO: Can we exclude that instance? *)
   (* TODO: If some of the arguments are the same, we could also
      query for "pointwise_relation"'s. But that leads to a combinatorial
      explosion about which arguments are and which are not the same. *)
-  | |- ?R (?f _) _ => apply (_ : Proper (_ ==> R) f)
-  | |- ?R (?f _ _) _ => apply (_ : Proper (_ ==> _ ==> R) f)
-  | |- ?R (?f _ _ _) _ => apply (_ : Proper (_ ==> _ ==> _ ==> R) f)
-  | |- ?R (?f _ _ _ _) _ => apply (_ : Proper (_ ==> _ ==> _ ==> _ ==> R) f)
+  | |- ?R (?f _) _ => simple apply (_ : Proper (_ ==> R) f)
+  | |- ?R (?f _ _) _ => simple apply (_ : Proper (_ ==> _ ==> R) f)
+  | |- ?R (?f _ _ _) _ => simple apply (_ : Proper (_ ==> _ ==> _ ==> R) f)
+  | |- ?R (?f _ _ _ _) _ => simple apply (_ : Proper (_ ==> _ ==> _ ==> _ ==> R) f)
    (* In case the function symbol differs, but the arguments are the same,
       maybe we have a pointwise_relation in our context. *)
-  | H : pointwise_relation _ ?R ?f ?g |- ?R (?f ?x) (?g ?x) => apply H
+  | H : pointwise_relation _ ?R ?f ?g |- ?R (?f ?x) (?g ?x) => simple apply H
   end;
-  try reflexivity.
+  try simple apply reflexivity.
 
 (* The tactic [solve_proper_unfold] unfolds the first head symbol, so that
 we proceed by repeatedly using [f_equiv]. *)
-- 
GitLab