Open RyanGlScott opened 3 months ago
As an intermediate step towards fixing this issue, it would be worth translating each recursive Cryptol definition into its own, bespoke SAWCore fixpoint axiom. For example, we could translate the following Cryptol function:
xs = [True] # xs
Into the SAWCore that looks like the following:
primitive xs : Stream Bool
-- xs == [True] # xs
axiom xs_unfold = Eq (Stream Bool)
xs
(ecCat (TCNum 1) TCInf Bool True xs)
Where xs_unfold
corresponds to the unfold_fix_once
proof tactic, but specialized for the definition of xs
. This approach would have a couple of advantages:
fix
function (which could come from any number of different places).
Currently, all recursive Cryptol functions are translated to SAWCore definitions involving the
fix
primitive. This poses several issues, including:fix
is unsound (see #2088). We should try to minimize uses offix
so that we can reduce the trusted code base.fix
function cannot be translated to Coq, so the less we usefix
in the Cryptol->SAWCore translation, the more Cryptol definitions we can port to Coq.In order to accomplish this, we will need to identify which recursive Cryptol definitions are guaranteed to terminate after a certain number of iterations and translate them to well-founded recursion primitives in SAWCore. For example, one common pattern is the "take a finite number of elements from an infinite stream pattern", e.g.,
While
[0 ...]
is an infinite sequence (and will never terminate on its own), the overall expressiontake`{5} [0 ...]
does terminate. We should identify this pattern and translate it to a SAWCore term that computes a finite prefix of[0 ...]
.