Functor Syntax is not working

The following code shows the two schemas and a functor between them. However, the basic syntax of the functor is throwing errors. Can someone help me with this?

using Catlab, Catlab.Theories, Catlab.CategoricalAlgebra
@present Sch1(FreeSchema) begin
  (N1, N2)::Ob
  f::Hom(N1,N2)

  (Name, Salary, Age)::AttrType
  name::Attr(N1, Name)
  salary::Attr(N1, Salary)
  age::Attr(N2, Age)
end

@present Sch2(FreeSchema) begin
  N::Ob
  (Name, Salary, Age)::AttrType
  name::Attr(N, Name)
  salary::Attr(N, Salary)
  age::Attr(N, Age)
end

using Test

using Catlab, Catlab.Graphs, Catlab.CategoricalAlgebra
using Catlab.Programs.DiagrammaticPrograms
using Catlab.Programs.DiagrammaticPrograms: NamedGraph
using Catlab.WiringDiagrams.CPortGraphs

F = @finfunctor Sch1 Sch2 begin
    N1 => N;
    N2 => N
end

Error

Object N1 is not assigned Stacktrace: [1] error(s::String)*

I don’t know anything about Catlab, but as a general note it will be easier to help if you paste the code as text rather than a screenshot.

1 Like

Thanks will edit it

Hope this is not too late, but here is how to use @finfunctor to make a functor between those two schemas (small categories) and then use it to preform a data migration on instances of data on those schemas (Sch1 to Sch2), which is what I assume you were working towards. On Catlab v0.15.3 (we can just use a single using Catlab to import everything now).

using Catlab

@present Sch1(FreeSchema) begin
  (N1, N2)::Ob
  f::Hom(N1,N2)

  (Name, Salary, Age)::AttrType
  name::Attr(N1, Name)
  salary::Attr(N1, Salary)
  age::Attr(N2, Age)
end

@present Sch2(FreeSchema) begin
  N::Ob
  (Name, Salary, Age)::AttrType
  name::Attr(N, Name)
  salary::Attr(N, Salary)
  age::Attr(N, Age)
end

F = @finfunctor Sch1 Sch2 begin
    N1 => N
    N2 => N
    f => id(N)
    Name => Name
    Salary => Salary
    Age => Age
    name => name
    salary => salary
    age => age
end

@acset_type Sch1Data(Sch1)
@acset_type Sch2Data(Sch2)

sch1_data = @acset Sch1Data{String,Int,Int} begin
    N1 = 3
    N2 = 3
    f = [1,2,3]
    name = ["Alice", "Bob", "Carol"]
    salary = [300, 400, 500]
    age = [25, 30, 35]
end

Σ = SigmaMigrationFunctor(F, Sch1Data{String,Int,Int}, Sch2Data{String,Int,Int})
Σ(sch1_data)