mirror of
https://github.com/Smaug123/agdaproofs
synced 2025-10-11 14:48:42 +00:00
Semiring solver (#50)
This commit is contained in:
@@ -8,28 +8,3 @@ module Numbers.Integers.Definition where
|
||||
data ℤ : Set where
|
||||
nonneg : ℕ → ℤ
|
||||
negSucc : ℕ → ℤ
|
||||
|
||||
data ℤSimple : Set where
|
||||
negativeSucc : (a : ℕ) → ℤSimple
|
||||
positiveSucc : (a : ℕ) → ℤSimple
|
||||
zZero : ℤSimple
|
||||
|
||||
convertZ : ℤ → ℤSimple
|
||||
convertZ (nonneg zero) = zZero
|
||||
convertZ (nonneg (succ x)) = positiveSucc x
|
||||
convertZ (negSucc x) = negativeSucc x
|
||||
|
||||
convertZ' : ℤSimple → ℤ
|
||||
convertZ' (negativeSucc a) = negSucc a
|
||||
convertZ' (positiveSucc a) = nonneg (succ a)
|
||||
convertZ' zZero = nonneg 0
|
||||
|
||||
zIsZ : (a : ℤ) → convertZ' (convertZ a) ≡ a
|
||||
zIsZ (nonneg zero) = refl
|
||||
zIsZ (nonneg (succ x)) = refl
|
||||
zIsZ (negSucc x) = refl
|
||||
|
||||
zIsZ' : (a : ℤSimple) → convertZ (convertZ' a) ≡ a
|
||||
zIsZ' (negativeSucc a) = refl
|
||||
zIsZ' (positiveSucc a) = refl
|
||||
zIsZ' zZero = refl
|
||||
|
@@ -10,6 +10,7 @@ open import Numbers.Naturals.Addition
|
||||
open import Numbers.Naturals.Order
|
||||
open import Numbers.Naturals.Multiplication
|
||||
open import Numbers.Naturals.Exponentiation
|
||||
open import Numbers.Naturals.Subtraction
|
||||
open import Semirings.Definition
|
||||
open import Monoids.Definition
|
||||
|
||||
@@ -20,6 +21,7 @@ module Numbers.Naturals.Naturals where
|
||||
open Numbers.Naturals.Multiplication using (_*N_ ; multiplicationNIsCommutative) public
|
||||
open Numbers.Naturals.Exponentiation using (_^N_) public
|
||||
open Numbers.Naturals.Order using (_<N_ ; le; succPreservesInequality; succIsPositive; addingIncreases; zeroNeverGreater; noIntegersBetweenXAndSuccX; a<SuccA; canRemoveSuccFrom<N) public
|
||||
open Numbers.Naturals.Subtraction using (_-N'_) public
|
||||
|
||||
ℕSemiring : Semiring 0 1 _+N_ _*N_
|
||||
Monoid.associative (Semiring.monoid ℕSemiring) a b c = equalityCommutative (additionNIsAssociative a b c)
|
||||
|
27
Numbers/Naturals/Subtraction.agda
Normal file
27
Numbers/Naturals/Subtraction.agda
Normal file
@@ -0,0 +1,27 @@
|
||||
{-# OPTIONS --warning=error --safe --without-K #-}
|
||||
|
||||
open import LogicalFormulae
|
||||
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
|
||||
open import WellFoundedInduction
|
||||
open import Functions
|
||||
open import Orders
|
||||
open import Numbers.Naturals.Definition
|
||||
open import Numbers.Naturals.Addition
|
||||
open import Numbers.Naturals.Order
|
||||
open import Numbers.Naturals.Multiplication
|
||||
open import Numbers.Naturals.Exponentiation
|
||||
open import Semirings.Definition
|
||||
open import Monoids.Definition
|
||||
open import Maybe
|
||||
|
||||
module Numbers.Naturals.Subtraction where
|
||||
|
||||
_-N'_ : (a b : ℕ) → Maybe ℕ
|
||||
zero -N' zero = yes 0
|
||||
zero -N' succ b = no
|
||||
succ a -N' zero = yes (succ a)
|
||||
succ a -N' succ b = a -N' b
|
||||
|
||||
subtractZero : (a : ℕ) → a -N' 0 ≡ yes a
|
||||
subtractZero zero = refl
|
||||
subtractZero (succ a) = refl
|
Reference in New Issue
Block a user