-
Notifications
You must be signed in to change notification settings - Fork 63
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
Reducing the use of dependent types in saw-core #136
Comments
This is a bold proposal, Brian. Why throw the baby out with the bathwater, and instead just go ahead and mechanize the type system, evolving it with a goal toward improving/correcting those first four bullets? |
@kiniry Yes it is bold, but I wouldn't say we're throwing out the baby. I think we've kept our dependent type system much too long as a result of a sunk-cost fallacy, and we will have a much easier time going forward without it. If we keep our dependent types, then fixing the bullet points above will be a major original research project. We can't just take any existing dependent type system off the shelf, because we have a unique combination of special features: type-level proofs coexisting with recursive definitions; a large collection of built-in datatypes and primitive functions; a very complex (undecidable) equational theory involving natural numbers that the type system and unification/matching are supposed to take into account. In contrast, the "challenges" I listed above are basically just "extra things I'll have to implement", which I already know how to do. I should also point out that some "features" of a dependent type system are things that we really don't want. For example, with our dependent type system we must construct type equality proofs to cast values between types with equivalent size parameters; these are proofs that Cryptol's type checker (in coordination with z3) has already done. Currently we cheat by using the totally unsound In any dependently typed proof system, there is a balance between encoding properties in typing judgments vs proving separate theorems. I am basically proposing that we do size checking with separate proofs instead of with typing. We will already need to do separate proofs for array-bounds checking and other safety properties, so this just makes things more consistent. At the same time, getting rid of dependent types will make the semantics of saw-core vastly simpler and let us avoid some blatant unsoundnesses in the type system. |
We're probably not going to go this route; vector types with a size index are fairly well established by now. |
In particular, it would be beneficial to remove the size parameter from the saw-core
Vec
type, and have the type include vectors of all lengths (like the Haskell list type). We should consider removing other uses of dependent types as well.Problems caused by dependent types:
Nat
) during type checkingunsafeCoerce
is often necessary to circumvent the type system (e.g. in the Cryptol translator)Vec
)append
)Challenges:
The text was updated successfully, but these errors were encountered: