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

Mapping creation and indexing #1296

Merged
merged 4 commits into from
Dec 12, 2024

Conversation

arnaudgolfouse
Copy link
Collaborator

I'm not a fan of the naming of unknown, but I don't really have a better idea.

Also this implies that logic code may create values ex nihilo. I assumed this was what we wanted ; but should we rather have a function

#[logic]
#[trusted]
fn conjure<T>() -> T { dead }

?

@jhjourdan
Copy link
Collaborator

Indexing: LGTM.

Creation of an arbitrary mapping: why cannot we use cst in your specific case?

In general, I think a function like your conjure is a good idea. I think there is no reason this should be restricted to Mapping. Actually, I think we should even go further, by having the equivalent of an epsilon function in Creusot, which would essentially let us eliminate existential quantifiers in ghost code.

@arnaudgolfouse
Copy link
Collaborator Author

Creation of an arbitrary mapping: why cannot we use cst in your specific case?

Because the type of values of that mapping is a generic type T, so I cannot create a value of type T (unless of course we add conjure).

In general, I think a function like your conjure is a good idea.

I'll add it then! We can think about an epsilon function later, but yes it is something that I wanted occasionally.

@arnaudgolfouse
Copy link
Collaborator Author

Btw what is our position on uninhabited types?

@arnaudgolfouse arnaudgolfouse force-pushed the mapping-create-index branch 2 times, most recently from 596d5b1 to b49120d Compare December 10, 2024 14:30
@jhjourdan
Copy link
Collaborator

Btw what is our position on uninhabited types?

Smt solvers and why3 don't support uninhabited types, they assume that all types are inhabited. It is rather heavy to encode uninhabited types in these tools, so I prefer not supporting them either.

This is the main reason why we don't encode type invariants as subset types.

@jhjourdan
Copy link
Collaborator

I'll add it then! We can think about an epsilon function later, but yes it is something that I wanted occasionally.

Why waiting for epsilon ? I don't expect it to be much more difficult than conjure, and I'd prefer not having two redundant features in the future.

@arnaudgolfouse arnaudgolfouse merged commit 505dedf into creusot-rs:master Dec 12, 2024
6 checks 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.

2 participants