Skip to content

Conversation

cscaff
Copy link
Contributor

@cscaff cscaff commented Apr 14, 2025

This macro abstracts functions such as:

  1. CellularSheaf(vertex_stalks::Vector{Int}, edge_stalks::Vector{Int})
  2. set_edge_maps!(s::AbstractCellularSheaf, v1::Int, v2::Int, e::Int, rm1::AbstractMatrix, rm2::AbstractMatrix)

It accepts restriction map matrices as argument parameters and allows a user to declare vertex stalks and linear relations
representing edges in the cellular sheaf. For instance, a user can represent a triangular sheaf using the following julia code:

# Define restriction maps as matrices
A = [1 0 0 0]
B = [1 0 0 0]
C = [1 0 0 0]

# You can pass in the maps as follows: 

triangle = @cellular_sheaf A, B, C begin
    # You can define vertex stalks using the format: name::Stalk{dimension}
    x::Stalk{4}, y::Stalk{4}, z::Stalk{4}

    # Then, you can define your relations as equations:

    # For instance, in "A(x) == B(y)", x and y are incident vertices. A maps x to the shared edge stalk. B maps y to the shared edge stalk.
    A(x) == B(y)
    A(x) == C(z)
    B(y) == C(z)

end

The previous code is the same as writing:


c = CellularSheaf([4, 4, 4], [1, 1, 1])
set_edge_maps!(c, 1, 2, 1, C, C)
set_edge_maps!(c, 1, 3, 2, C, C)
set_edge_maps!(c, 2, 3, 3, C, C)

While the first example may appear like more lines of code, it is far easier to understand the pattern that is occuring, making it easier for developers
to quickly construct cellular sheaves. Likewise, because edge stalk dimensions are inferred, this provides a more disciplined approach to building sheaves,
leaving less room for errors.

@cscaff
Copy link
Contributor Author

cscaff commented Apr 14, 2025

Current Issue: Only multiple parameters are accepted into the macro. I need to fix this, but I'm too sleepy right now to make it work. Will fix when I am awake.

Copy link
Collaborator

@tylerhanks tylerhanks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks great! Just see my comment about the test at the very end. It would also be nice to add a few more tests for other graph topologies, e.g. path graph or star graph.

Added var declaration parsing functions to impliment.

Move branch to fork

Expr: Tuple correctly feeds into lower level parse function now... MLStyle dep added.

Created an ADT file in which stores the Sheaf ADT using MLStyle and StructTypes.

Wrote documentation for module identifier.

Added complete documentation for the AST abstract type.

Reordered file to run top-bottom.

Resolved minor issues.

Split product into two structs: restriction map and vertex stalk. Started building test file.

Simplified ADT to structs and proved creation of first ADT cellular sheaf expression in tests.

Created look up table for constructor.

Tested Var Redeclaration Exception.

Created helper function for throwing error when a linear relation contains an undefined var.

Created test for exceptions when var is undeclared in relation.

Modified dimension types to be integers. Edge stalk inference WIP.

Tested that inconsistent edge stalks throw exceptions.

Added error message for attempts to map wrong vertex stalk dimension.

Created test for wrong mapping.

created method for gathering vertex stalk dimensions.

Created system to gather vertex and edge stalks

Empty cellular sheaf can now be constructed.

Created method of storing vertex + edge dimensions for construction.

Starting on the parsing macro. Currently has errors

Modified Judgements into declarations that can hold data.

Modified minor test errors after judgement change.

Completed parse declaration function and added parse equation to do.

Fixed minor declaration parsing errors.

Removed declaration debugging prints.

Parse cellular sheaf now passes in escaped local vars and their names.

Modified parse_cellular_sheaf signature to accept multiple local args.

Cleaned up some error throwing.

Local parameters are now added to the AST.

Added root construction and constructor function.

Added type checking to constructor.

Moved Macro into seperate file that depends on ADT and CellularSheaves files.

First sheaf construction via macro complete!

Removed Debug statement.

Seperated construct into cleaner functions.

Added documentation to ADT file.

Added documentation to macro function.

Tested all exceptions in ADT testing file.

Added more tests. Need to fix an error where you need to pass more than one arg into macro.

Added exception for non matrices.

Adjusted minor teesting errors within ADT file.

Replaced accidental "Throws" w/ correct "Error" in Parser code.

Modified isEqual Func

Added support for singular arguments in macro.

Added error exceprtion for using macro without arguments.

Made minor test changes.

Removed unneeded StructTypes.

Literate File Created for Cellular Sheaf Macro

Renamed Sheaf Macro Guide Literate/Generated.

Modified Literate to remove unneeded example.

Added CFG to parser API docs.

Added Sheaf Error Types to the parser + constructor.
@cscaff cscaff force-pushed the cellular-sheaf-macro branch from 985765a to e2e5cb8 Compare April 28, 2025 18:29
@jpfairbanks
Copy link
Member

@cscaff let's get this merged on Monday, there are significant conflicts that I can't fix in the editor. If tests have to get done in another PR that is OK. I want to start using this code and so we need to this and #37 merged into main

@cscaff
Copy link
Contributor Author

cscaff commented May 4, 2025

@cscaff let's get this merged on Monday, there are significant conflicts that I can't fix in the editor. If tests have to get done in another PR that is OK. I want to start using this code and so we need to this and #37 merged into main

I have graduation tomorrow so I'll be pretty busy, but I'm trying to figure out how to fix the conflicts now. Not sure how to view this within VSCode. Looking up tutorials.

@cscaff
Copy link
Contributor Author

cscaff commented May 4, 2025

Ok, should be good! @jpfairbanks

@jpfairbanks jpfairbanks merged commit d80e45a into AlgebraicJulia:paper-crunch-time May 4, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants