Skip to content

Instantly share code, notes, and snippets.

@plt-amy
Created December 17, 2024 14:26
Show Gist options
  • Select an option

  • Save plt-amy/fe2a242891d730463d498e2bae1b4ec0 to your computer and use it in GitHub Desktop.

Select an option

Save plt-amy/fe2a242891d730463d498e2bae1b4ec0 to your computer and use it in GitHub Desktop.
From 681d6cab3a00f0a224b6a86af8e0765a27440fa4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Am=C3=A9lia=20Liao?= <me@amelia.how>
Date: Tue, 17 Dec 2024 11:26:35 -0300
Subject: [PATCH] speed up product solver
---
src/Cat/Diagram/Product/Solver.lagda.md | 42 ++++++++++++++++++++++---
1 file changed, 38 insertions(+), 4 deletions(-)
diff --git a/src/Cat/Diagram/Product/Solver.lagda.md b/src/Cat/Diagram/Product/Solver.lagda.md
index a78c33fba..a5540774d 100644
--- a/src/Cat/Diagram/Product/Solver.lagda.md
+++ b/src/Cat/Diagram/Product/Solver.lagda.md
@@ -510,12 +510,46 @@ macro
β†’ (π’ž : Precategory o β„“) (cartesian : βˆ€ X Y β†’ Product π’ž X Y)
β†’ Term β†’ Term β†’ TC ⊀
products-simpl! = Reflection.simpl-macro
+```
+
+<!--
+```agda
+module _ {o β„“} (C : Precategory o β„“) (cart : βˆ€ X Y β†’ Product C X Y) {x y : ⌞ C ⌟} {h1 h2 : C .Precategory.Hom x y} where
+ open Reflection
- products! : βˆ€ {o β„“}
- β†’ (π’ž : Precategory o β„“) (cartesian : βˆ€ X Y β†’ Product π’ž X Y)
- β†’ Term β†’ TC ⊀
- products! = Reflection.solve-macro
+ private
+ products-worker : Term β†’ TC ⊀
+ products-worker goal = withReconstructed true $ withNormalisation true do
+ `h1 ← wait-for-type =<< quoteTC h1
+ `h2 ← quoteTC h2
+ `x ← quoteTC x
+ `y ← quoteTC y
+
+ β€œcart” ← quoteTC cart
+
+ let
+ β€œx” = build-obj-expr `x
+ β€œy” = build-obj-expr `y
+ β€œlhs” = build-hom-expr `h1
+ β€œrhs” = build-hom-expr `h2
+
+ unify goal (Reflection.β€œsolve” unknown β€œcart” β€œx” β€œy” β€œlhs” β€œrhs”) <|> do
+ β€œcat” ← quoteTC C
+ vlhs ← normalise (β€œnf” β€œcat” β€œcart” β€œx” β€œy” β€œlhs”)
+ vrhs ← normalise (β€œnf” β€œcat” β€œcart” β€œx” β€œy” β€œrhs”)
+ typeError
+ [ "Could not equate the following expressions:\n "
+ , termErr `h1 , "\nAnd\n " , termErr `h2
+ , "\nReflected expressions\n "
+ , termErr β€œlhs” , "\nAnd\n " , termErr β€œrhs”
+ , strErr "\nComputed normal forms\n "
+ , termErr vlhs , strErr "\nAnd\n " , termErr vrhs
+ ]
+
+ products! : {@(tactic products-worker) p : h1 ≑ h2} β†’ h1 ≑ h2
+ products! {p = p} = p
```
+-->
# Demo
--
2.42.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment