Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parsing sets and matrices in Oxide #628

Open
spritezs opened this issue Feb 3, 2025 · 18 comments
Open

parsing sets and matrices in Oxide #628

spritezs opened this issue Feb 3, 2025 · 18 comments
Assignees
Labels
area::conjure-oxide/ast Related to conjure_core and ast representation.

Comments

@spritezs
Copy link

spritezs commented Feb 3, 2025

Right now we can't parse matrices and sets in Oxide. The current DecisionVariable object is not enough for representing them (need to store their length) so we can either update it, or create a new Object. I will bring this up on Wednesday but please feel free to comment here.

@spritezs spritezs added the area::conjure-oxide/ast Related to conjure_core and ast representation. label Feb 3, 2025
@spritezs spritezs self-assigned this Feb 3, 2025
@niklasdewally
Copy link
Collaborator

niklasdewally commented Feb 3, 2025

Hi Tudor,

I will be working on representing matrices, and the framework which we will use to represent and rewrite them and other higher level types, such as sets.

@ozgurakgun and I have a loose plan of how we want to approach this, and I will share an RFC on this next week once I've tidied my ideas into a concrete proposal.

In short, we will be adding representation rules like in Conjure, and use these for matrices and SAT encodings as well as higher-level types. The former are Savile Row level constructs, which uses a different abstraction; however, we think that representation rules will also apply to these lower level concepts.

Oxide internally represents things differently than Conjure, and uses a very different programming style, so our big question for now is how do we port these concepts over in a way that makes sense in Rust.

@niklasdewally
Copy link
Collaborator

Would be good to discuss this on Wednesday, bearing in mind that there are still quite a lot of unknowns here.

@niklasdewally
Copy link
Collaborator

niklasdewally commented Feb 3, 2025

As matrix length and all that in essence is in the domain, you could add it as a new type of domain internally too?

That would also allow it to be used in lettings

@spritezs
Copy link
Author

spritezs commented Feb 3, 2025

I will come up with a rough implementation for lettings and discuss it on Wed.
But for stuff like "matrix indexed by" list(Domain, ",", "[]") "of" Domain we need to (from what I ve seen) at least create a new type of variable which can hold the additional info.

@ozgurakgun
Copy link
Contributor

I think it might make sense for you two to have a brief chat to coordinate?

For context, @spritezs is mainly interested in converting sets to matrices, but since matrices do not exist yet there is room for collaboration here.

@niklasdewally
Copy link
Collaborator

I think it might make sense for you two to have a brief chat to coordinate?

For context, @spritezs is mainly interested in converting sets to matrices, but since matrices do not exist yet there is room for collaboration here.

We should definitely coordinate on representation rules and all that then.

@ozgurakgun
Copy link
Contributor

Though I think @spritezs is initially thinking about how to extend the rust data types and extend the parser to read these in, so that shouldn't depend on the rule stuff.

@niklasdewally
Copy link
Collaborator

Though I think @spritezs is initially thinking about how to extend the rust data types and extend the parser to read these in, so that shouldn't depend on the rule stuff.

What I meant was that I'm not sure how representation rules will affect the symbol table, and whether we would need to do things in a specific way so that all the info is in the right places?

@spritezs
Copy link
Author

spritezs commented Feb 3, 2025

@niklasdewally isn't our first worry representing matrices in the AST? I think that is a good stepping stone. What do you think?

@niklasdewally
Copy link
Collaborator

@niklasdewally isn't our first worry representing matrices in the AST? I think that is a good stepping stone. What do you think?

That's as good a place as any to start :)

@niklasdewally
Copy link
Collaborator

niklasdewally commented Feb 3, 2025

As we are both working around the symbol table, it would be helpful to me if you could split this into several smaller PRs if possible (if you don't already do so) so that we can keep our branches in sync.

If I submit any symbol table changes this week, I'll @-you so that I don't break anything you are planning.

@spritezs
Copy link
Author

spritezs commented Feb 3, 2025

sounds great. i haven't thought about PRs so far so feel free to make some. i ll add additional ones along the way when i bump into issues.

If I submit any symbol table changes this week, I'll @-you so that I don't break anything you are planning.

same same. sounds good

@spritezs
Copy link
Author

spritezs commented Feb 4, 2025

@niklasdewally Oxide doesn't allow for 'letting' statements. I modified the 'parse_model.rs' file to allow for simple 'letting b be 3' statements.

Will show you tomorrow and push if it's up to standards. Will look into letting more complicated structures next. Cya tmr!

@niklasdewally
Copy link
Collaborator

@niklasdewally Oxide doesn't allow for 'letting' statements. I modified the 'parse_model.rs' file to allow for simple 'letting b be 3' statements.

Will show you tomorrow and push if it's up to standards. Will look into letting more complicated structures next. Cya tmr!

Your fork might not be up to date, I added lettings in #619 and #621

@spritezs
Copy link
Author

spritezs commented Feb 4, 2025

ok i think i pushed to the main repo instead of my own branch
sorry i l fix it now

@niklasdewally
Copy link
Collaborator

niklasdewally commented Feb 4, 2025

In particular, domain lettings, added in #621, can contain matrix domain declarations.

@spritezs
Copy link
Author

Before I start coding I wanted to make sure I understood what needed modifying.

In terms of 'searching' for a set, what I need to do is modify the Domain enum and add another possible value. What I ve thought of is: DomainSet(Vec), but I don't really know what a set can contain. Is it integers? If so can the set be DomainSet(Vec<Range>)?

@ozgurakgun
Copy link
Contributor

A set domain contains another domain in it. Remember the Domain type in Conjure we looked at together, that might help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area::conjure-oxide/ast Related to conjure_core and ast representation.
Projects
None yet
Development

No branches or pull requests

3 participants