AlgebraicJulia / AlgebraicJulia/Catlab.jl

Two perspectives on composite objects

Đang mở
#103 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Julia
Star
724
Fork
73
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

For the purposes of abstraction, we often want to give a new name to an existing object. Like in GLA we sometimes want to treat `R^4` as a tuple of four scalars `otimes(R,R,R,R)` or as a single object for example `Vec(4)`. This is handy when thinking about block linear algebra examples where you think of `A:Vec(4) --> Vec(4)` as a diagram with one wire in and one wire out each carrying a single value of type `Vec(4)` as opposed to having 4 wires in and 4 wires out. But then you need to handle the isomorphism between `Vec(n)` and `otimes(R for i in 1:n)`. This type of abstraction is very natural to mathematicians and isn't handld in Catlab right now.

Another example of this comes up in KR/DBs were you have record types. If you modeled a database schema as a Presentation in terms of the primitive types you get something like this

```julia
@present DB(FreeBicategoryRelations) begin
Z::Ob # Int
R::Ob # Float
S::Ob # String

employer::Hom(S,S)
age::Hom(S,Z)
manager::Hom(S,S)
end
```
and then the age of my manager is captured by the query `compose(manager, age)`.

This is really modeling the specific database implementation, where the types are the SQL primitive types instead of the semantically meaningful types in the domain (aka business problem).

I think you would rather represent things like:
```julia
@present DB(FreeBicategoryRelations) begin
Z::Ob # Int
R::Ob # Float
S::Ob # String
P::Ob # Person
C::Ob # Company

# fields of the Person type
age::Hom(P,Z)
firstname::Hom(P, S)
lastname::Hom(P, S)

# fields of the Company type
corpname::Hom(C, S)
heaquarters::Hom(C, S)

# actual relations
employer::Hom(P,C)
manager::Hom(P,P)
end
```

In this case you can think of `P` as a subset of `otimes(S,S,Z)` either as a relation or as a new object that can be converted to and from `otimes(S,S,Z)` as needed.

I'm not sure exactly, but I think these are related problems. In general I have a two types that have a special relationship and I want to handle that relationship specially in the wiring diagrams rendering and the `functor` into the semantics category (BLAS code or SQL schemas).

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.