Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
6ea05d4
cryptol-saw-core: Keep equality constraints in imported Cryptol types.
brianhuffman Apr 27, 2026
77bda42
cryptol-saw-core: Mark constraint `PTrue` as not erased.
brianhuffman Apr 28, 2026
87df55a
cryptol-saw-core: Keep geq (>=) constraints in Cryptol types.
brianhuffman Apr 29, 2026
970a336
cryptol-saw-core: Keep neq (!=) constraints in Cryptol types.
brianhuffman Apr 29, 2026
d55cc42
cryptol-saw-core: Keep `fin` constraints in Cryptol types.
brianhuffman Apr 29, 2026
9d96979
cryptol-saw-core: Add SAWCore proofs for PFin rules.
brianhuffman Apr 30, 2026
d1cfdb1
intTests: Add new regression test `test_cryptol_fromto`.
brianhuffman Apr 30, 2026
3e83cd8
cryptol-saw-core: Remove `unsafeAssumeCryptolProp` axiom.
brianhuffman May 12, 2026
fe4c3ae
saw-core: Move lemma `ltNat_0_right` into `Prelude.sawcore`.
brianhuffman May 13, 2026
7346696
cryptol-saw-core: Reimplement `PFin` to make Rocq export happy.
brianhuffman May 13, 2026
8eacc15
cryptol-saw-core: Redefine `PFin` again without using a Pi type.
brianhuffman May 13, 2026
a0ebb6f
saw-central: Make `llvm_ffi_setup` work with numeric type constraints.
brianhuffman May 13, 2026
0b98359
cryptol-saw-core: Use `unsafeAssert` instead of declaring new axioms.
brianhuffman May 13, 2026
e6838d2
saw-core-rocq: Translate unsafeAssume variants using Ltac.
brianhuffman May 13, 2026
bd7b281
crux-mir-comp: Generate proof terms to discharge numeric constraints.
brianhuffman May 19, 2026
2107a0e
cryptol-saw-core: Add proof of `PFin_downward_closed`.
brianhuffman Jun 4, 2026
544f692
saw-core-rocq-tests: Update expected outputs.
brianhuffman Jul 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions crux-mir-comp/src/Mir/Cryptol.hs
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,43 @@ cryptolRun name (CryFunArgs (CryFunArgs' tpArgs ctrs normArgs)) retShp funcTerm
toListFC getConst <$>
Ctx.zipWithM getNormArg normArgs (Ctx.drop tpArgsSize normArgsSize argsCtx)


let allTerms = tpTerms ++ argTerms
let
-- We have already checked that all numeric type constraints
-- concretely evaluate to true; thus we should be able to
-- discharge the constraints in SAWCore by reflexivity.
proveProp :: Cry.Prop -> IO SAW.Term
proveProp p =
case p of
(Cry.pIsEqual -> Just (m, _)) ->
-- Constraint `m == n` is translated as `Eq Num m n`
case Cry.tIsNum (Cry.apSubst su m) of
Just i ->
do t <- SAW.scGlobalDef sc "Cryptol.Num"
i' <- SAW.scNat sc (fromIntegral i)
x <- SAW.scGlobalApply sc "Prelude.TCNum" [i']
SAW.scGlobalApply sc "Prelude.Refl" [t, x]
Nothing -> fail "Invalid size parameter"
(Cry.pIsNeq -> Just _) ->
-- `PNeq m n` is defined as `Eq Bool (tcEqual m n) False`
do t <- SAW.scBoolType sc
x <- SAW.scBool sc False
SAW.scGlobalApply sc "Prelude.Refl" [t, x]
(Cry.pIsGeq -> Just _) ->
-- `PGeq m n` is defined as `Eq Bool (tcLt m n) False`
do t <- SAW.scBoolType sc
x <- SAW.scBool sc False
SAW.scGlobalApply sc "Prelude.Refl" [t, x]
(Cry.pIsFin -> Just _) ->
-- `PFin n` is defined as `Eq Bool (tcFin n) True`
do t <- SAW.scBoolType sc
x <- SAW.scBool sc True
SAW.scGlobalApply sc "Prelude.Refl" [t, x]
_ ->
fail $ "Unsupported constraint form: " ++ show (pp p)

proofTerms <- liftIO $ traverse proveProp ctrs

let allTerms = tpTerms ++ proofTerms ++ argTerms
appTerm <- liftIO (SAW.scApplyAll sc funcTerm allTerms)
liftIO $ termToReg sym appTerm retShp

Expand Down
Loading
Loading