Skip to content

Commit 8e6eb32

Browse files
committed
Respond to review comments
1 parent 3582846 commit 8e6eb32

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

cryptol-saw-core/src/Verifier/SAW/TypedTerm.hs

+5-9
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,7 @@ mkTypedTerm sc trm = do
7272
-- This operation fails if the type of the argument does
7373
-- not match the function.
7474
applyTypedTerm :: SharedContext -> TypedTerm -> TypedTerm -> IO TypedTerm
75-
applyTypedTerm sc (TypedTerm _tp t1) (TypedTerm _ t2) =
76-
do trm <- scApply sc t1 t2
77-
ty <- scTypeCheckError sc trm
78-
ct <- scCryptolType sc ty
79-
let ttt = case ct of
80-
Nothing -> TypedTermOther ty
81-
Just (Left k) -> TypedTermKind k
82-
Just (Right t) -> TypedTermSchema (C.tMono t)
83-
return (TypedTerm ttt trm)
75+
applyTypedTerm sc x y = applyTypedTerms sc x [y]
8476

8577
-- | Apply a 'TypedTerm' to a list of arguments. This operation fails
8678
-- if the first 'TypedTerm' does not have a function type of
@@ -90,6 +82,10 @@ applyTypedTerms :: SharedContext -> TypedTerm -> [TypedTerm] -> IO TypedTerm
9082
applyTypedTerms sc (TypedTerm _ fn) args =
9183
do trm <- foldM (scApply sc) fn (map ttTerm args)
9284
ty <- scTypeCheckError sc trm
85+
-- NB, scCryptolType can behave in strange ways due to the non-injectivity
86+
-- of the mapping from Cryptol to SAWCore types. Perhaps we would be better
87+
-- to combine the incoming type information instead of applying and then
88+
-- reconstructing here.
9389
ct <- scCryptolType sc ty
9490
let ttt = case ct of
9591
Nothing -> TypedTermOther ty

src/SAWScript/Builtins.hs

+8
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,14 @@ congruence_for tt =
643643
congTm <- io $ build_congruence sc (ttTerm tt)
644644
io $ mkTypedTerm sc congTm
645645

646+
-- | Given an input term, construct another term that
647+
-- represents a congruence law for that term.
648+
-- This term will be a Curry-Howard style theorem statement
649+
-- that can be dispatched to solvers, and should have
650+
-- type "Prop".
651+
--
652+
-- This will only work for terms that represent non-dependent
653+
-- functions.
646654
build_congruence :: SharedContext -> Term -> IO Term
647655
build_congruence sc tm =
648656
do ty <- scTypeOf sc tm

0 commit comments

Comments
 (0)