| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Automatic solvers for equations over naturals |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
-- See README.Tactic.RingSolver for examples of how to use this solver |
| 8 |
|
| 9 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 10 |
|
| 11 |
module Data.Nat.Tactic.RingSolver where |
| 12 |
|
| 13 |
open import Agda.Builtin.Reflection using (Term; TC) |
| 14 |
|
| 15 |
open import Data.Maybe.Base using (just; nothing) |
| 16 |
open import Data.Nat.Base using (zero) |
| 17 |
open import Data.Nat.Properties using (+-*-commutativeSemiring) |
| 18 |
open import Level using (0ℓ) |
| 19 |
open import Data.Unit.Base using (⊤) |
| 20 |
open import Relation.Binary.PropositionalEquality.Core using (refl) |
| 21 |
|
| 22 |
import Tactic.RingSolver as Solver using (solve-∀-macro; solve-macro) |
| 23 |
import Tactic.RingSolver.Core.AlmostCommutativeRing as ACR |
| 24 |
|
| 25 |
------------------------------------------------------------------------ |
| 26 |
-- A module for automatically solving propositional equivalences |
| 27 |
-- containing _+_ and _*_ |
| 28 |
|
| 29 |
ring : ACR.AlmostCommutativeRing 0ℓ 0ℓ |
| 30 |
ring = ACR.fromCommutativeSemiring +-*-commutativeSemiring |
| 31 |
λ { zero → just refl; _ → nothing } |
| 32 |
|
| 33 |
macro |
| 34 |
solve-∀ : Term → TC ⊤ |
| 35 |
solve-∀ = Solver.solve-∀-macro (quote ring) |
| 36 |
|
| 37 |
macro |
| 38 |
solve : Term → Term → TC ⊤ |
| 39 |
solve n = Solver.solve-macro n (quote ring) |