Debian Codegraph @

src/Function/Related/TypeIsomorphisms/Solver.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Automatic solver for equations over product and sum types
5 --
6 -- See examples at the bottom of the file for how to use this solver
7 ------------------------------------------------------------------------
8
9 {-# OPTIONS --cubical-compatible --safe #-}
10
11 module Function.Related.TypeIsomorphisms.Solver where
12
13 open import Algebra using (CommutativeSemiring)
14 import Algebra.Solver.Ring.NaturalCoefficients.Default
15 using (solve; con; _:*_; _:+_; _:=_)
16 open import Data.Empty.Polymorphic using (⊥)
17 open import Data.Product.Base using (_×_)
18 open import Data.Sum.Base using (_⊎_)
19 open import Data.Unit.Polymorphic using (⊤)
20 open import Level using (Level)
21 open import Function.Bundles using (_↔_)
22 open import Function.Properties.Inverse using (↔-refl)
23 open import Function.Related.Propositional as Related
24 open import Function.Related.TypeIsomorphisms using (×-⊎-commutativeSemiring)
25
26 ------------------------------------------------------------------------
27 -- The solver
28
29 module ×-⊎-Solver (k : SymmetricKind) {ℓ} =
30 Algebra.Solver.Ring.NaturalCoefficients.Default
31 (×-⊎-commutativeSemiring k ℓ)
32
33 ------------------------------------------------------------------------
34 -- Tests
35
36 private
37
38 -- A test of the solver above.
39
40 test : {ℓ : Level} (A B C : Set ℓ) →
41 (⊤ × A × (B ⊎ C)) ↔ (A × B ⊎ C × (⊥ ⊎ A))
42 test = solve 3 (λ A B C → con 1 :* (A :* (B :+ C)) :=
43 A :* B :+ C :* (con 0 :+ A))
44 ↔-refl
45 where open ×-⊎-Solver bijection