Source code on Github
{-# OPTIONS --without-K --safe #-}
module Tactic.Solver.Ring.Tests.Comparison where
open import Algebra using (CommutativeSemiring)
open import Data.Nat.Properties using (+-*-commutativeSemiring)
import Data.Integer.Properties as ℤP
open import Data.List using (_∷_; [])
open import Relation.Binary using (Setoid)
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
open import Tactic.Solver.Ring using (solve-≈)
import Data.Nat.Tactic.RingSolver as NatSolver
import Data.Integer.Tactic.RingSolver as ℤSolver
import Algebra.Solver.Ring.NaturalCoefficients.Default as NCD
module ParamRing-ours {c ℓ} (R : CommutativeSemiring c ℓ) where
open CommutativeSemiring R
comm+ : ∀ a b → a + b ≈ b + a
comm+ = solve-≈ R
module ParamRing-stdlib {c ℓ} (R : CommutativeSemiring c ℓ) where
open NCD R
open CommutativeSemiring R
private module Eq = Setoid setoid
comm+-explicit : ∀ a b → a + b ≈ b + a
comm+-explicit = solve 2 (λ a b → a :+ b := b :+ a) Eq.refl
module AutoQuant-ours {c ℓ} (R : CommutativeSemiring c ℓ) where
open CommutativeSemiring R
open import Relation.Binary.Reasoning.Setoid setoid
closed-∀ : ∀ a b → a + b ≈ b + a
closed-∀ = solve-≈ R
with-patterns : ∀ a b → a + b ≈ b + a
with-patterns a = solve-≈ R
module AutoQuant-stdlib where
open import Data.Nat using (_+_; _*_)
closed-∀ : ∀ a b → a + b ≡ b + a
closed-∀ = NatSolver.solve-∀
with-patterns : ∀ a b → a + b ≡ b + a
with-patterns a b = NatSolver.solve (a ∷ b ∷ [])
module ConcreteRings-ours where
module ℕcase where
open import Data.Nat using (_+_; _*_)
distrib : ∀ a b c → a * (b + c) ≡ a * b + a * c
distrib = solve-≈ +-*-commutativeSemiring
module ℤcase where
open import Data.Integer using (_+_; _*_)
open CommutativeSemiring ℤP.+-*-commutativeSemiring using (_≈_)
assoc* : ∀ a b c → ((a * b) * c) ≈ (a * (b * c))
assoc* = solve-≈ ℤP.+-*-commutativeSemiring
module ℤbundle where
open CommutativeSemiring ℤP.+-*-commutativeSemiring
assoc* : ∀ a b c → ((a * b) * c) ≈ (a * (b * c))
assoc* = solve-≈ ℤP.+-*-commutativeSemiring
module ConcreteRings-stdlib where
module ℕcase where
open import Data.Nat using (_+_; _*_)
distrib : ∀ a b c → a * (b + c) ≡ a * b + a * c
distrib = NatSolver.solve-∀
module ℤcase where
open import Data.Integer using (_+_; _*_)
assoc* : ∀ a b c → ((a * b) * c) ≡ (a * (b * c))
assoc* = ℤSolver.solve-∀
module CongChain-ours where
open import Data.Nat using (_+_)
open CommutativeSemiring +-*-commutativeSemiring using (_≈_; +-congˡ; +-comm; trans)
trans-congˡ : ∀ a b c → a + (b + c) ≈ (a + c) + b
trans-congˡ a b c = trans (+-congˡ {x = a} (+-comm b c)) (solve-≈ +-*-commutativeSemiring)