-
Notifications
You must be signed in to change notification settings - Fork 0
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
Rough draft of a database library, for discussion #76
base: main
Are you sure you want to change the base?
Conversation
#row_t:Type0 -> {|db_types row_t|} -> | ||
{|protocol_invariants|} -> db_pred:db_predicate row_t -> prop | ||
let has_db_invariants #row_t #db_t #invs db_pred = | ||
let db_local_state : local_state db = local_state_db row_t in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried to avoid needing this, but for some reason, can't get typeclass inference to work property to find an instance of local_state db, probably because db
doesn't depend on the row type. Maybe the db_types
need to be split into two parts, one that depends on the row type and one that doesn't?
Another general question is if we want to include support for deletion in some form from databases. My impression is that in most cases, this causes additional problems without much benefit, because uniqueness becomes much less useful in the presence of deletions, but I would be curious to hear if someone has applications for it. Of course, we can "fake" deletion by having a "deleted" flag as part of a row, and always query only for rows that are not deleted, which may be sufficient for any such applications, without needing a change to the library itself. |
I will have a deeper look later, but overall it seems that this could replace |
Yes, I believe that this is (will be, once it works) a strict generalization of |
…tar-extrinsic into qaphla/database_lib
This is a first attempt at a database library, which is not intended to work as is (and includes correspondingly many assumes, and a few admits), but rather as a starting point for discussion of what such a library should look like. There are a few main design decisions that I think are reasonable, but which are open for discussion, and also several questions where I'm not sure what the best thing to do is at this point, which are more relevant for discussion.
Design
A database consists of a main state, containing a list of state IDs, each of which points to a state containing a single "row" of the database.
Rows may have an arbitrary (user-specified) type, and corresponding local predicates specifying what is a valid row and how rows may be updated (not yet implementable), along with the usual
later
andknowable
lemmas.The database as a whole can take in a global predicate, which will be used to build the predicate for the main state, specifying some property over the list of rows pointed to by the main state. Similar to the
later
andknowable
lemmas, this comes with a pair of properties, making it possible to prove the global predicate for empty databases and when updating a database.The interface allows us to:
Open questions