@@ -23,7 +23,7 @@ module Copilot.Verifier
2323 ) where
2424
2525import Control.Lens (view , (^.) , to )
26- import Control.Monad (foldM , forM_ , when )
26+ import Control.Monad (foldM , forM_ , unless , when )
2727import Control.Monad.IO.Class (liftIO )
2828import Control.Monad.State (execStateT , lift , StateT (.. ))
2929import Data.Aeson (ToJSON )
@@ -33,7 +33,7 @@ import qualified Data.Text as Text
3333import qualified Data.Map.Strict as Map
3434import Data.IORef (newIORef , modifyIORef' , readIORef , IORef )
3535import qualified Text.LLVM.AST as L
36- import Data.List (genericLength )
36+ import Data.List (genericLength , sort )
3737import Data.List.NonEmpty (NonEmpty (.. ))
3838import qualified Data.List.NonEmpty as NE
3939import qualified Data.Vector as V
@@ -511,10 +511,26 @@ verifyStepBisimulation opts cruxOpts adapters csettings clRefs simctx llvmMod mo
511511 let prepTrigger (nm, guard, _) =
512512 do gv <- freshGlobalVar halloc (Text. pack (nm ++ " _called" )) NatRepr
513513 return (nm, gv, guard)
514- triggerGlobals <- mapM prepTrigger (CW4. triggerState prfbundle)
514+
515+ checkDuplicateTriggerNames :: [Name ] -> IO ()
516+ checkDuplicateTriggerNames triggers =
517+ traverse_ checkDuplicateTriggerName $ NE. group $ sort triggers
518+
519+ checkDuplicateTriggerName :: NonEmpty Name -> IO ()
520+ checkDuplicateTriggerName (trig :| dupTrigs) =
521+ unless (null dupTrigs) $
522+ fail $ unlines
523+ [ " The specification invokes the `" ++ trig ++
524+ " ` trigger function multiple times,"
525+ , " which copilot-verifier does not currently support."
526+ , " See https://github.com/Copilot-Language/copilot-verifier/issues/74."
527+ ]
528+ let triggerState = CW4. triggerState prfbundle
529+ checkDuplicateTriggerNames $ map (\ (nm,_,_) -> nm) triggerState
530+ triggerGlobals <- mapM prepTrigger triggerState
515531
516532 -- execute the step function
517- let overrides = zipWith (triggerOverride clRefs) triggerGlobals ( CW4. triggerState prfbundle)
533+ let overrides = zipWith (triggerOverride clRefs) triggerGlobals triggerState
518534 mem'' <- executeStep opts csettings clRefs simctx memVar mem' llvmMod modTrans triggerGlobals overrides (CW4. assumptions prfbundle) (CW4. sideConds prfbundle)
519535
520536 -- assert the poststate is in the relation
0 commit comments