From b21e69503571272a5f35cf84c731994f3e921a3a Mon Sep 17 00:00:00 2001 From: Greg Brown Date: Tue, 29 Nov 2022 14:36:13 +0000 Subject: Move indexed setoids and functions out of Soat. --- soat.ipkg | 5 ++-- src/Data/Morphism/Indexed.idr | 13 ++++++++++ src/Data/Setoid/Indexed.idr | 36 +++++++++++++++++++++++++++ src/Soat/Data/Product.idr | 4 +-- src/Soat/FirstOrder/Algebra.idr | 7 +++--- src/Soat/FirstOrder/Term.idr | 5 ++-- src/Soat/Relation.idr | 46 ----------------------------------- src/Soat/SecondOrder/Algebra.idr | 3 ++- src/Soat/SecondOrder/Algebra/Lift.idr | 3 ++- 9 files changed, 63 insertions(+), 59 deletions(-) create mode 100644 src/Data/Morphism/Indexed.idr create mode 100644 src/Data/Setoid/Indexed.idr delete mode 100644 src/Soat/Relation.idr diff --git a/soat.ipkg b/soat.ipkg index c42996f..7d584ac 100644 --- a/soat.ipkg +++ b/soat.ipkg @@ -2,13 +2,14 @@ package soat authors = "Greg Brown" sourcedir = "src" -modules = Data.Setoid +modules = Data.Morphism.Indexed + , Data.Setoid + , Data.Setoid.Indexed , Soat.Data.Product , Soat.Data.Sublist , Soat.FirstOrder.Algebra , Soat.FirstOrder.Signature , Soat.FirstOrder.Term - , Soat.Relation , Soat.SecondOrder.Algebra , Soat.SecondOrder.Algebra.Lift , Soat.SecondOrder.Signature diff --git a/src/Data/Morphism/Indexed.idr b/src/Data/Morphism/Indexed.idr new file mode 100644 index 0000000..c271c90 --- /dev/null +++ b/src/Data/Morphism/Indexed.idr @@ -0,0 +1,13 @@ +module Data.Morphism.Indexed + +import Data.Setoid.Indexed + +public export +IFunc : {a : Type} -> (x, y : a -> Type) -> Type +IFunc {a} x y = (i : a) -> x i -> y i + +public export +record IFunction {a : Type} (x, y : ISetoid a) where + constructor MkIFunction + func : IFunc x.U y.U + cong : (i : a) -> {u, v : x.U i} -> x.relation i u v -> y.relation i (func i u) (func i v) diff --git a/src/Data/Setoid/Indexed.idr b/src/Data/Setoid/Indexed.idr new file mode 100644 index 0000000..df5606d --- /dev/null +++ b/src/Data/Setoid/Indexed.idr @@ -0,0 +1,36 @@ +module Data.Setoid.Indexed + +import public Data.Setoid + +%default total + +public export +IRel : {a : Type} -> (a -> Type) -> Type +IRel {a = a} x = (i : a) -> x i -> x i -> Type + +public export +IReflexive : {a : Type} -> (x : a -> Type) -> IRel x -> Type +IReflexive x rel = (i : a) -> Reflexive (x i) (rel i) + +public export +ISymmetric : {a : Type} -> (x : a -> Type) -> IRel x -> Type +ISymmetric x rel = (i : a) -> Symmetric (x i) (rel i) + +public export +ITransitive : {a : Type} -> (x : a -> Type) -> IRel x -> Type +ITransitive x rel = (i : a) -> Transitive (x i) (rel i) + +public export +IEquivalence : {a : Type} -> (x : a -> Type) -> IRel x -> Type +IEquivalence x rel = (i : a) -> Setoid.Equivalence (x i) (rel i) + +public export +record ISetoid (a : Type) where + constructor MkISetoid + 0 U : a -> Type + 0 relation : IRel U + equivalence : IEquivalence U relation + +public export +isetoid : (a -> Type) -> ISetoid a +isetoid u = MkISetoid u (\_ => Equal) (\_ => equiv) diff --git a/src/Soat/Data/Product.idr b/src/Soat/Data/Product.idr index 1582d02..f392a2d 100644 --- a/src/Soat/Data/Product.idr +++ b/src/Soat/Data/Product.idr @@ -1,8 +1,8 @@ module Soat.Data.Product -import Control.Relation import Data.List.Elem -import Soat.Relation +import Data.Morphism.Indexed +import Data.Setoid.Indexed %default total diff --git a/src/Soat/FirstOrder/Algebra.idr b/src/Soat/FirstOrder/Algebra.idr index 4b40cee..6f25f59 100644 --- a/src/Soat/FirstOrder/Algebra.idr +++ b/src/Soat/FirstOrder/Algebra.idr @@ -1,10 +1,9 @@ module Soat.FirstOrder.Algebra -import Control.Relation - -import Soat.Data.Product +import Data.Morphism.Indexed +import Data.Setoid.Indexed +import public Soat.Data.Product import Soat.FirstOrder.Signature -import Soat.Relation %default total %hide Control.Relation.Equivalence diff --git a/src/Soat/FirstOrder/Term.idr b/src/Soat/FirstOrder/Term.idr index 2712c88..07ab248 100644 --- a/src/Soat/FirstOrder/Term.idr +++ b/src/Soat/FirstOrder/Term.idr @@ -1,14 +1,13 @@ module Soat.FirstOrder.Term -import Control.Relation +import Data.Morphism.Indexed +import Data.Setoid.Indexed import Soat.Data.Product import Soat.FirstOrder.Algebra import Soat.FirstOrder.Signature -import Soat.Relation %default total -%hide Control.Relation.Equivalence public export data Term : (0 sig : Signature) -> (0 _ : sig.T -> Type) -> sig.T -> Type where diff --git a/src/Soat/Relation.idr b/src/Soat/Relation.idr deleted file mode 100644 index 9826d60..0000000 --- a/src/Soat/Relation.idr +++ /dev/null @@ -1,46 +0,0 @@ -module Soat.Relation - -import public Data.Setoid - -%default total - -public export -IRel : {a : Type} -> (a -> Type) -> Type -IRel {a = a} x = (i : a) -> x i -> x i -> Type - -public export -IReflexive : {a : Type} -> (x : a -> Type) -> IRel x -> Type -IReflexive x rel = (i : a) -> Reflexive (x i) (rel i) - -public export -ISymmetric : {a : Type} -> (x : a -> Type) -> IRel x -> Type -ISymmetric x rel = (i : a) -> Symmetric (x i) (rel i) - -public export -ITransitive : {a : Type} -> (x : a -> Type) -> IRel x -> Type -ITransitive x rel = (i : a) -> Transitive (x i) (rel i) - -public export -IEquivalence : {a : Type} -> (x : a -> Type) -> IRel x -> Type -IEquivalence x rel = (i : a) -> Setoid.Equivalence (x i) (rel i) - -public export -record ISetoid (a : Type) where - constructor MkISetoid - 0 U : a -> Type - 0 relation : IRel U - equivalence : IEquivalence U relation - -public export -isetoid : (a -> Type) -> ISetoid a -isetoid u = MkISetoid u (\_ => Equal) (\_ => equiv) - -public export -IFunc : {a : Type} -> (x, y : a -> Type) -> Type -IFunc {a} x y = (i : a) -> x i -> y i - -public export -record IFunction {a : Type} (x, y : ISetoid a) where - constructor MkIFunction - func : IFunc x.U y.U - cong : (i : a) -> {u, v : x.U i} -> x.relation i u v -> y.relation i (func i u) (func i v) diff --git a/src/Soat/SecondOrder/Algebra.idr b/src/Soat/SecondOrder/Algebra.idr index 50b65e0..c506c85 100644 --- a/src/Soat/SecondOrder/Algebra.idr +++ b/src/Soat/SecondOrder/Algebra.idr @@ -1,10 +1,11 @@ module Soat.SecondOrder.Algebra +import Data.Morphism.Indexed +import Data.Setoid.Indexed import Data.List.Elem import Soat.Data.Product import Soat.Data.Sublist -import Soat.Relation import Soat.SecondOrder.Signature public export diff --git a/src/Soat/SecondOrder/Algebra/Lift.idr b/src/Soat/SecondOrder/Algebra/Lift.idr index 00d453a..b08eb0e 100644 --- a/src/Soat/SecondOrder/Algebra/Lift.idr +++ b/src/Soat/SecondOrder/Algebra/Lift.idr @@ -1,12 +1,13 @@ module Soat.SecondOrder.Algebra.Lift import Data.List.Elem +import Data.Morphism.Indexed +import Data.Setoid.Indexed import Soat.Data.Product import Soat.Data.Sublist import Soat.FirstOrder.Algebra import Soat.FirstOrder.Term -import Soat.Relation import Soat.SecondOrder.Algebra import Soat.SecondOrder.Signature.Lift -- cgit v1.2.3