diff --git a/Tactic.ByEq.html b/Tactic.ByEq.html new file mode 100644 index 0000000..da322e7 --- /dev/null +++ b/Tactic.ByEq.html @@ -0,0 +1,60 @@ + +Tactic.ByEqSource code on Github
{-# OPTIONS --safe --without-K #-}
+module Tactic.ByEq where
+
+open import Meta hiding (TC)
+open import MetaPrelude
+open import Class.Functor.Core; open import Class.Functor.Instances
+open import Class.Monad.Core; open import Class.Monad.Instances
+open import Reflection using (TC; withNormalisation; inferType; unify)
+open import Reflection.Utils
+
+-- Introduce as many arguments as possible and then:
+--   1. for those of type `_ ≡ _`, unify with  `refl`
+--   2. ignore the rest of the arguments (unify with `_`)
+--   3. unify the hole with `refl`
+by-eq : Hole  TC 
+by-eq hole = do
+  ty  withNormalisation true $ inferType hole
+  let ps : Args Pattern
+      ps = argTys ty <&> fmap λ {(def (quote _≡_) _)  quote refl ; _  dot unknown}
+  unify hole $ pat-lam [ clause [] ps (quote refl ) ] []
+
+macro $by-eq = by-eq
+
+private
+  -- test that macro works
+  _ :  {n m k : }  n  m  m  k  n  k
+  _ = $by-eq
+
+  _ :  {n m k x y : }  n  m  x  y  m  n
+  _ = $by-eq
+
+  -- test that tactic arguments work
+  f : {@(tactic by-eq) _ :  {n m : }  n  m  m  n}  Bool  Bool
+  f = id
+
+  _ : f  where refl  refl} true  true
+  _ = refl
+
+  _ : f {$by-eq} true  true
+  _ = refl
+
+  _ : f true  true
+  _ = refl
+
+  -- test that normalisation works
+  Sym =  {n m : }  n  m  m  n
+
+  g : {@(tactic by-eq) _ : Sym}  Bool  Bool
+  g = id
+
+  _ : g  where refl  refl} true  true
+  _ = refl
+
+  _ : g {$by-eq} true  true
+  _ = refl
+
+  _ : g true  true
+  _ = refl
+
\ No newline at end of file diff --git a/Tactic.html b/Tactic.html index f62798a..6554132 100644 --- a/Tactic.html +++ b/Tactic.html @@ -5,16 +5,17 @@ open import Tactic.Rewrite public open import Tactic.Extra public open import Tactic.Existentials public +open import Tactic.ByEq public -open import Tactic.AnyOf public -open import Tactic.Assumption public -open import Tactic.Case public -open import Tactic.Constrs public -open import Tactic.EquationalReasoning public -open import Tactic.Eta public -open import Tactic.Intro public -open import Tactic.ReduceDec public +open import Tactic.AnyOf public +open import Tactic.Assumption public +open import Tactic.Case public +open import Tactic.Constrs public +open import Tactic.EquationalReasoning public +open import Tactic.Eta public +open import Tactic.Intro public +open import Tactic.ReduceDec public -open import Tactic.Derive.DecEq public -open import Tactic.Derive.Show public +open import Tactic.Derive.DecEq public +open import Tactic.Derive.Show public \ No newline at end of file diff --git a/typecheck.time b/typecheck.time index 74e4869..5a2a5f9 100644 --- a/typecheck.time +++ b/typecheck.time @@ -1,40 +1,41 @@ -TOTAL: 0m40s -Algebra/Function: 0m1s -MetaPrelude: 0m4s -Class/MonadError: 0m3s -Class/MonadReader: 0m0s +TOTAL: 3m23s +Algebra/Function: 0m10s +MetaPrelude: 1m23s +Class/MonadError: 0m40s +Class/MonadReader: 0m1s Reflection/Syntax: 0m0s -Reflection/Debug: 0m1s +Reflection/Debug: 0m0s Class/MonadTC: 0m1s Reflection/TCI: 0m0s Meta: 0m0s Reflection/Tactic: 0m0s -Reflection/Utils: 0m0s -Reflection/Utils/Debug: 0m1s +Reflection/Utils: 0m1s +Reflection/Utils/Debug: 0m0s Class/MonadError/Instances: 0m0s Class/MonadReader/Instances: 0m0s Class/MonadTC/Instances: 0m0s -Reflection/Utils/TCI: 0m3s +Reflection/Utils/TCI: 0m13s Reflection/Utils/TCM: 0m0s -Reflection/AlphaEquality: 0m1s -Reflection/AntiUnification: 0m0s +Reflection/AlphaEquality: 0m0s +Reflection/AntiUnification: 0m1s Tactic/Try: 0m1s Tactic/Rewrite: 0m1s -Tactic/Extra: 0m1s -Tactic/Existentials: 0m0s +Tactic/Extra: 0m0s +Tactic/Existentials: 0m1s +Tactic/ByEq: 0m0s Tactic/AnyOf: 0m0s Tactic/Defaults: 0m0s -Tactic/Assumption: 0m1s -Tactic/ClauseBuilder: 0m2s +Tactic/Assumption: 0m0s +Tactic/ClauseBuilder: 0m31s Tactic/Case: 0m1s Tactic/Constrs: 0m0s -Tactic/EquationalReasoning: 0m0s -Tactic/Eta: 0m1s +Tactic/EquationalReasoning: 0m1s +Tactic/Eta: 0m0s Tactic/Intro: 0m0s Tactic/ReduceDec: 0m1s Tactic/Derive: 0m1s -Tactic/Derive/TestTypes: 0m0s -Tactic/Derive/DecEq: 0m7s +Tactic/Derive/TestTypes: 0m1s +Tactic/Derive/DecEq: 0m6s Tactic/Derive/Show: 0m2s Tactic: 0m0s Main: 0m0s