├── .dockerignore ├── .gitignore ├── .larabot.conf ├── .sbtopts ├── CLA.txt ├── Dockerfile ├── FAQ.md ├── HOWTO_RELEASE.md ├── LICENSE ├── NOTICE ├── README.md ├── RELEASE_NOTES.md ├── _CoqProject ├── bin ├── bolts-tests.sh ├── build-slc-lib.sh ├── docker-release.sh ├── external-tests.sh ├── larabot_fetch_solc.sh ├── launcher.tmpl.sh ├── nix-run ├── package-standalone.sh ├── stainless-actors-tests.sh └── stainless.nix ├── build.sbt ├── core └── src │ ├── main │ └── scala │ │ └── stainless │ │ ├── Analysis.scala │ │ ├── Component.scala │ │ ├── Configuration.scala │ │ ├── Context.scala │ │ ├── MainHelpers.scala │ │ ├── Options.scala │ │ ├── Report.scala │ │ ├── Reporter.scala │ │ ├── ast │ │ ├── Constructors.scala │ │ ├── Deconstructors.scala │ │ ├── Definitions.scala │ │ ├── ExprOps.scala │ │ ├── Expressions.scala │ │ ├── Graphs.scala │ │ ├── Printers.scala │ │ ├── SymbolIdentifier.scala │ │ ├── SymbolOps.scala │ │ ├── TreeOps.scala │ │ ├── Trees.scala │ │ ├── TypeOps.scala │ │ └── Types.scala │ │ ├── codegen │ │ ├── CodeGeneration.scala │ │ ├── CompilationUnit.scala │ │ └── runtime │ │ │ ├── ADT.scala │ │ │ ├── Bag.scala │ │ │ ├── BigArray.scala │ │ │ ├── BigInt.scala │ │ │ ├── BitVector.scala │ │ │ ├── BoxedArray.scala │ │ │ ├── Exceptions.scala │ │ │ ├── GenericValues.scala │ │ │ ├── Lambda.scala │ │ │ ├── Map.scala │ │ │ ├── Monitor.scala │ │ │ ├── Rational.scala │ │ │ ├── RuntimeResources.scala │ │ │ ├── Set.scala │ │ │ ├── StringOps.scala │ │ │ └── Tuple.scala │ │ ├── evaluators │ │ ├── CodeGenEvaluator.scala │ │ ├── Evaluator.scala │ │ ├── EvaluatorAnalysis.scala │ │ ├── EvaluatorCheckFilter.scala │ │ ├── EvaluatorComponent.scala │ │ ├── EvaluatorReport.scala │ │ ├── FunctionSplitting.scala │ │ └── RecursiveEvaluator.scala │ │ ├── extraction │ │ ├── CheckingTransformer.scala │ │ ├── ExtractionCaches.scala │ │ ├── ExtractionPipeline.scala │ │ ├── imperative │ │ │ ├── AntiAliasing.scala │ │ │ ├── Definitions.scala │ │ │ ├── EffectsAnalyzer.scala │ │ │ ├── EffectsChecker.scala │ │ │ ├── GhostChecker.scala │ │ │ ├── GhostTraverser.scala │ │ │ ├── ImperativeCleanup.scala │ │ │ ├── ImperativeCodeElimination.scala │ │ │ ├── SymbolOps.scala │ │ │ ├── TransformerWithPC.scala │ │ │ ├── TransformerWithType.scala │ │ │ ├── Trees.scala │ │ │ ├── TypeOps.scala │ │ │ └── package.scala │ │ ├── inlining │ │ │ ├── FunctionInlining.scala │ │ │ ├── Trees.scala │ │ │ └── package.scala │ │ ├── innerclasses │ │ │ ├── Definitions.scala │ │ │ ├── DependencyGraph.scala │ │ │ ├── ExprOps.scala │ │ │ ├── GhostTraverser.scala │ │ │ ├── InnerClasses.scala │ │ │ ├── Trees.scala │ │ │ ├── TypeOps.scala │ │ │ ├── Types.scala │ │ │ └── package.scala │ │ ├── innerfuns │ │ │ ├── Definitions.scala │ │ │ ├── FunctionClosure.scala │ │ │ ├── GhostTraverser.scala │ │ │ ├── SymbolOps.scala │ │ │ ├── TransformerWithPC.scala │ │ │ ├── Trees.scala │ │ │ ├── TypeOps.scala │ │ │ └── package.scala │ │ ├── methods │ │ │ ├── DependencyGraph.scala │ │ │ ├── FieldAccessors.scala │ │ │ ├── GhostTraverser.scala │ │ │ ├── Laws.scala │ │ │ ├── MergeInvariants.scala │ │ │ ├── MethodLifting.scala │ │ │ ├── MutabilityAnalyzer.scala │ │ │ ├── Sealing.scala │ │ │ ├── SuperCalls.scala │ │ │ ├── SuperInvariants.scala │ │ │ ├── Trees.scala │ │ │ ├── TypeOps.scala │ │ │ ├── ValueClasses.scala │ │ │ └── package.scala │ │ ├── oo │ │ │ ├── AdtSpecialization.scala │ │ │ ├── ClassSymbols.scala │ │ │ ├── Definitions.scala │ │ │ ├── DependencyGraph.scala │ │ │ ├── ExtractionCaches.scala │ │ │ ├── ExtractionPipeline.scala │ │ │ ├── GhostTraverser.scala │ │ │ ├── RefinementLifting.scala │ │ │ ├── SymbolOps.scala │ │ │ ├── TransformerWithType.scala │ │ │ ├── Trees.scala │ │ │ ├── TypeEncoding.scala │ │ │ ├── TypeOps.scala │ │ │ └── package.scala │ │ ├── package.scala │ │ ├── smartcontracts │ │ │ ├── DependencyGraph.scala │ │ │ ├── EnvironmentBuilder.scala │ │ │ ├── HavocInjection.scala │ │ │ ├── InvariantInjection.scala │ │ │ ├── Trees.scala │ │ │ └── package.scala │ │ ├── termination │ │ │ ├── .scalafmt.conf │ │ │ ├── InductElimination.scala │ │ │ ├── SizedADTExtraction.scala │ │ │ ├── Trees.scala │ │ │ └── package.scala │ │ ├── throwing │ │ │ ├── ExceptionLifting.scala │ │ │ ├── Trees.scala │ │ │ └── package.scala │ │ ├── trace │ │ │ ├── Trace.scala │ │ │ ├── Trees.scala │ │ │ └── package.scala │ │ ├── utils │ │ │ ├── ConcurrentCaches.scala │ │ │ ├── DebugPipeline.scala │ │ │ ├── PositionChecker.scala │ │ │ └── SyntheticSorts.scala │ │ └── xlang │ │ │ ├── PartialFunctions.scala │ │ │ ├── SmartContractsSanitizer.scala │ │ │ ├── TreeSanitizer.scala │ │ │ ├── Trees.scala │ │ │ └── package.scala │ │ ├── frontend │ │ ├── BatchedCallBack.scala │ │ ├── CallBack.scala │ │ ├── DependencyResolver.scala │ │ ├── Frontend.scala │ │ ├── FrontendFactory.scala │ │ ├── Recovery.scala │ │ ├── SolidityCallBack.scala │ │ ├── SplitCallBack.scala │ │ ├── StainlessReports.scala │ │ ├── ThreadedFrontend.scala │ │ └── package.scala │ │ ├── macros │ │ └── FileProvider.scala │ │ ├── package.scala │ │ ├── solidity │ │ ├── SolidityOutput.scala │ │ ├── SolidityPrinter.scala │ │ ├── SolidityTree.scala │ │ └── package.scala │ │ ├── solvers │ │ ├── InoxEncoder.scala │ │ └── SolverFactory.scala │ │ ├── termination │ │ ├── ChainBuilder.scala │ │ ├── ChainProcessor.scala │ │ ├── ControlFlowAnalysis.scala │ │ ├── DatatypeChecker.scala │ │ ├── DecreasesProcessor.scala │ │ ├── LoopProcessor.scala │ │ ├── MeasureInference.scala │ │ ├── OrderingRelation.scala │ │ ├── ProcessingPipeline.scala │ │ ├── Processor.scala │ │ ├── RecursionProcessor.scala │ │ ├── RelationBuilder.scala │ │ ├── RelationProcessor.scala │ │ ├── SelfCallsProcessor.scala │ │ ├── SizeFunctions.scala │ │ ├── SolverProvider.scala │ │ ├── Strenghtener.scala │ │ ├── StructuralSize.scala │ │ ├── TerminationAnalysis.scala │ │ ├── TerminationChecker.scala │ │ ├── TerminationComponent.scala │ │ ├── TerminationReport.scala │ │ └── package.scala │ │ ├── transformers │ │ ├── GhostTraverser.scala │ │ ├── PartialEvaluator.scala │ │ ├── SimplifierWithPC.scala │ │ ├── SimplifierWithSolver.scala │ │ ├── Transformer.scala │ │ ├── TransformerWithPC.scala │ │ └── Traverser.scala │ │ ├── utils │ │ ├── AtomicMarks.scala │ │ ├── Caches.scala │ │ ├── Canonization.scala │ │ ├── CheckFilter.scala │ │ ├── DependenciesFinder.scala │ │ ├── FileWatcher.scala │ │ ├── JsonConvertions.scala │ │ ├── JsonUtils.scala │ │ ├── LibraryFilter.scala │ │ ├── Serialization.scala │ │ ├── StringUtils.scala │ │ ├── XLangDependenciesFinder.scala │ │ └── YesNoOnly.scala │ │ └── verification │ │ ├── AssertionInjector.scala │ │ ├── ChooseInjector.scala │ │ ├── CoqEncoder.scala │ │ ├── CoqExpression.scala │ │ ├── CoqIO.scala │ │ ├── CoqVerificationChecher.scala │ │ ├── DefaultTactic.scala │ │ ├── PartialEvaluation.scala │ │ ├── Tactic.scala │ │ ├── TypeChecker.scala │ │ ├── TypeCheckerContext.scala │ │ ├── TypeCheckerDerivation.scala │ │ ├── TypeCheckerUtils.scala │ │ ├── VCResultMessage.scala │ │ ├── VerificationAnalysis.scala │ │ ├── VerificationCache.scala │ │ ├── VerificationChecker.scala │ │ ├── VerificationComponent.scala │ │ ├── VerificationConditions.scala │ │ ├── VerificationGenerator.scala │ │ └── VerificationReport.scala │ ├── sphinx │ ├── .gitignore │ ├── Makefile │ ├── casestudies.rst │ ├── conf.py │ ├── coq.rst │ ├── faq.rst │ ├── gettingstarted.rst │ ├── ghost.rst │ ├── imperative.rst │ ├── index.rst │ ├── installation.rst │ ├── internals.rst │ ├── intro.rst │ ├── laws.rst │ ├── library.rst │ ├── limitations.rst │ ├── neon.rst │ ├── options.rst │ ├── purescala.rst │ ├── r │ ├── references.rst │ ├── smartcontracts.rst │ ├── static │ │ ├── images │ │ │ ├── pipeline.svg │ │ │ └── pipeline.txt │ │ └── stainless-library │ │ │ ├── index.html │ │ │ ├── index.js │ │ │ ├── lib │ │ │ ├── MaterialIcons-Regular.eot │ │ │ ├── MaterialIcons-Regular.ttf │ │ │ ├── MaterialIcons-Regular.woff │ │ │ ├── abstract_type.svg │ │ │ ├── class.svg │ │ │ ├── class_comp.svg │ │ │ ├── class_diagram.png │ │ │ ├── diagrams.css │ │ │ ├── diagrams.js │ │ │ ├── index.css │ │ │ ├── index.js │ │ │ ├── jquery.min.js │ │ │ ├── jquery.mousewheel.min.js │ │ │ ├── jquery.panzoom.min.js │ │ │ ├── lato-v11-latin-100.eot │ │ │ ├── lato-v11-latin-100.ttf │ │ │ ├── lato-v11-latin-100.woff │ │ │ ├── lato-v11-latin-regular.eot │ │ │ ├── lato-v11-latin-regular.ttf │ │ │ ├── lato-v11-latin-regular.woff │ │ │ ├── modernizr.custom.js │ │ │ ├── object.svg │ │ │ ├── object_comp.svg │ │ │ ├── object_comp_trait.svg │ │ │ ├── object_diagram.png │ │ │ ├── open-sans-v13-latin-400i.eot │ │ │ ├── open-sans-v13-latin-400i.ttf │ │ │ ├── open-sans-v13-latin-400i.woff │ │ │ ├── open-sans-v13-latin-700.eot │ │ │ ├── open-sans-v13-latin-700.ttf │ │ │ ├── open-sans-v13-latin-700.woff │ │ │ ├── open-sans-v13-latin-700i.eot │ │ │ ├── open-sans-v13-latin-700i.ttf │ │ │ ├── open-sans-v13-latin-700i.woff │ │ │ ├── open-sans-v13-latin-regular.eot │ │ │ ├── open-sans-v13-latin-regular.ttf │ │ │ ├── open-sans-v13-latin-regular.woff │ │ │ ├── ownderbg2.gif │ │ │ ├── ownerbg.gif │ │ │ ├── ownerbg2.gif │ │ │ ├── package.svg │ │ │ ├── ref-index.css │ │ │ ├── scheduler.js │ │ │ ├── source-code-pro-v6-latin-700.eot │ │ │ ├── source-code-pro-v6-latin-700.ttf │ │ │ ├── source-code-pro-v6-latin-700.woff │ │ │ ├── source-code-pro-v6-latin-regular.eot │ │ │ ├── source-code-pro-v6-latin-regular.ttf │ │ │ ├── source-code-pro-v6-latin-regular.woff │ │ │ ├── template.css │ │ │ ├── template.js │ │ │ ├── trait.svg │ │ │ ├── trait_comp.svg │ │ │ ├── trait_diagram.png │ │ │ └── type_diagram.png │ │ │ └── stainless │ │ │ ├── annotation │ │ │ ├── erasable.html │ │ │ ├── extern.html │ │ │ ├── ghost.html │ │ │ ├── ignore.html │ │ │ ├── index.html │ │ │ ├── indexedAt.html │ │ │ ├── induct.html │ │ │ ├── inlineOnce.html │ │ │ ├── invariant.html │ │ │ ├── isabelle$$constructor.html │ │ │ ├── isabelle$$fullBody.html │ │ │ ├── isabelle$$function.html │ │ │ ├── isabelle$$lemma.html │ │ │ ├── isabelle$$noBody.html │ │ │ ├── isabelle$$proof.html │ │ │ ├── isabelle$$script.html │ │ │ ├── isabelle$$typ.html │ │ │ ├── isabelle$.html │ │ │ ├── keep.html │ │ │ ├── law.html │ │ │ ├── library.html │ │ │ ├── mutable.html │ │ │ ├── opaque.html │ │ │ ├── partialEval.html │ │ │ ├── pure.html │ │ │ └── wrapping.html │ │ │ ├── collection │ │ │ ├── $colon$colon$.html │ │ │ ├── CMap.html │ │ │ ├── ConcRope$$Append.html │ │ │ ├── ConcRope$$CC.html │ │ │ ├── ConcRope$$Conc$.html │ │ │ ├── ConcRope$$Conc.html │ │ │ ├── ConcRope$$Empty.html │ │ │ ├── ConcRope$$Single.html │ │ │ ├── ConcRope$.html │ │ │ ├── Cons.html │ │ │ ├── List$.html │ │ │ ├── List.html │ │ │ ├── ListOps$.html │ │ │ ├── ListSpecs$.html │ │ │ ├── Nil.html │ │ │ ├── Queue$.html │ │ │ ├── Queue.html │ │ │ ├── QueueSpecs$.html │ │ │ └── index.html │ │ │ ├── equations │ │ │ ├── index.html │ │ │ ├── package$$EqEvidence.html │ │ │ ├── package$$EqProof.html │ │ │ ├── package$$ProofOps.html │ │ │ └── package$$RAEqEvidence.html │ │ │ ├── index.html │ │ │ ├── io │ │ │ ├── FileInputStream$.html │ │ │ ├── FileInputStream.html │ │ │ ├── FileOutputStream$.html │ │ │ ├── FileOutputStream.html │ │ │ ├── StdIn$.html │ │ │ ├── StdOut$.html │ │ │ ├── index.html │ │ │ └── package$$State.html │ │ │ ├── lang │ │ │ ├── $tilde$greater$greater.html │ │ │ ├── $tilde$greater.html │ │ │ ├── Bag$.html │ │ │ ├── Bag.html │ │ │ ├── Either.html │ │ │ ├── Left.html │ │ │ ├── Map$.html │ │ │ ├── Map.html │ │ │ ├── MutableMap$.html │ │ │ ├── MutableMap.html │ │ │ ├── None.html │ │ │ ├── Option$.html │ │ │ ├── Option.html │ │ │ ├── PartialFunction$.html │ │ │ ├── Rational$.html │ │ │ ├── Rational.html │ │ │ ├── Real$.html │ │ │ ├── Real.html │ │ │ ├── Right.html │ │ │ ├── Set$.html │ │ │ ├── Set.html │ │ │ ├── Some.html │ │ │ ├── StaticChecks$$Ensuring.html │ │ │ ├── StaticChecks$.html │ │ │ ├── StrOps$.html │ │ │ ├── index.html │ │ │ ├── package$$BigInt$.html │ │ │ ├── package$$BooleanDecorations.html │ │ │ ├── package$$Exception.html │ │ │ ├── package$$Passes.html │ │ │ ├── package$$SpecsDecorations.html │ │ │ ├── package$$StringDecorations.html │ │ │ ├── package$$Throwing.html │ │ │ └── package$$WhileDecorations.html │ │ │ ├── math │ │ │ ├── Nat$.html │ │ │ ├── Nat.html │ │ │ └── index.html │ │ │ ├── proof │ │ │ ├── BoundedQuantifiers$.html │ │ │ ├── Internal$$WithProof.html │ │ │ ├── Internal$$WithRel.html │ │ │ ├── Internal$.html │ │ │ ├── index.html │ │ │ ├── package$$ProofOps.html │ │ │ └── package$$RelReasoning.html │ │ │ └── util │ │ │ ├── Random$$State.html │ │ │ ├── Random$.html │ │ │ └── index.html │ ├── themes │ │ └── stanford_theme │ │ │ ├── __init__.py │ │ │ ├── breadcrumbs.html │ │ │ ├── footer.html │ │ │ ├── layout.html │ │ │ ├── layout_old.html │ │ │ ├── search.html │ │ │ ├── searchbox.html │ │ │ ├── static │ │ │ ├── css │ │ │ │ ├── badge_only.css │ │ │ │ ├── copied_wy_variables.css │ │ │ │ └── theme.css │ │ │ ├── fonts │ │ │ │ ├── Inconsolata-Bold.ttf │ │ │ │ ├── Inconsolata-Regular.ttf │ │ │ │ ├── Lato-Bold.ttf │ │ │ │ ├── Lato-Regular.ttf │ │ │ │ ├── RobotoSlab-Bold.ttf │ │ │ │ ├── RobotoSlab-Regular.ttf │ │ │ │ ├── UbuntuMono-Bold.ttf │ │ │ │ ├── UbuntuMono-BoldItalic.ttf │ │ │ │ ├── UbuntuMono-Italic.ttf │ │ │ │ ├── UbuntuMono-Regular.ttf │ │ │ │ ├── fontawesome-webfont.eot │ │ │ │ ├── fontawesome-webfont.svg │ │ │ │ ├── fontawesome-webfont.ttf │ │ │ │ └── fontawesome-webfont.woff │ │ │ └── js │ │ │ │ ├── modernizr.min.js │ │ │ │ └── theme.js │ │ │ ├── theme.conf │ │ │ └── versions.html │ ├── tutorial.rst │ ├── verification.rst │ └── wrap.rst │ └── test │ └── scala │ └── stainless │ └── evaluators │ └── CodeGenEvaluatorSuite.scala ├── frontends ├── algebra │ └── src │ │ └── main │ │ └── stainless │ │ └── algebra │ │ ├── AbelianGroup.scala │ │ ├── BoundedJoinSemilattice.scala │ │ ├── BoundedMeetSemilattice.scala │ │ ├── Eq.scala │ │ ├── Group.scala │ │ ├── JoinSemilattice.scala │ │ ├── MeetSemilattice.scala │ │ ├── Monoid.scala │ │ ├── PartialOrder.scala │ │ ├── Ring.scala │ │ ├── Semigroup.scala │ │ ├── TotalOrder.scala │ │ ├── ops │ │ ├── ConcRope.scala │ │ └── List.scala │ │ └── proofs │ │ └── List.scala ├── benchmarks │ ├── coq │ │ ├── .gitignore │ │ ├── Acc.scala │ │ ├── AddingPositiveNumbers.scala │ │ ├── AdvArith.scala │ │ ├── Arith.scala │ │ ├── DivisionByZero.scala │ │ ├── Fix.scala │ │ ├── Let.scala │ │ ├── ListExample.scala │ │ ├── MyTuple1.scala │ │ ├── MyTuple3.scala │ │ ├── MyTuple5.scala │ │ ├── MyTuple6.scala │ │ ├── Not.scala │ │ ├── PreInSpecs.scala │ │ └── wip │ │ │ ├── ADTInvariants1.scala │ │ │ ├── Anonymous.scala │ │ │ ├── BooleanOps.scala │ │ │ ├── Matching.scala │ │ │ ├── MyTuple2.scala │ │ │ ├── MyTuple4.scala │ │ │ ├── SetTest.scala │ │ │ └── Sets2.scala │ ├── dotty-specific │ │ ├── invalid │ │ │ └── ErasedTerms3.scala │ │ ├── typechecker │ │ │ └── Streams.scala │ │ ├── unchecked │ │ │ ├── Enums1.scala │ │ │ ├── Enums2.scala │ │ │ ├── ErasedTerms1.scala │ │ │ ├── ErasedTerms2.scala │ │ │ ├── ExternTypeDef.scala │ │ │ ├── GhostCaseClasses.scala │ │ │ └── GhostMatch.scala │ │ └── valid │ │ │ ├── ConstructorRefinement.scala │ │ │ ├── DependentFunTypes.scala │ │ │ ├── ExtensionMethods1.scala │ │ │ ├── IdentityRefinement.scala │ │ │ ├── OpaqueTypes1.scala │ │ │ ├── PositiveInt.scala │ │ │ ├── PositiveIntAlias.scala │ │ │ ├── RefinedTypeMember.scala │ │ │ └── SortedListHead.scala │ ├── extraction │ │ ├── invalid │ │ │ ├── AnonymousClassRefine.scala │ │ │ ├── BadAliasing.scala │ │ │ ├── BadOverride1.scala │ │ │ ├── BadOverride2.scala │ │ │ ├── BadOverride3.scala │ │ │ ├── BadPre1.scala │ │ │ ├── BadPre2.scala │ │ │ ├── BadPre3.scala │ │ │ ├── BadPre4.scala │ │ │ ├── BadPre5.scala │ │ │ ├── BadPre6.scala │ │ │ ├── BadPre7.scala │ │ │ ├── ClassBody.scala │ │ │ ├── CopyMut.scala │ │ │ ├── CtorParams.scala │ │ │ ├── EffectfulVal.scala │ │ │ ├── ExtendNonMutable.scala │ │ │ ├── FieldInheritance2.scala │ │ │ ├── GhostDafny.scala │ │ │ ├── GhostEffect1.scala │ │ │ ├── GhostEffect2.scala │ │ │ ├── GhostEffect3.scala │ │ │ ├── GhostPatmat.scala │ │ │ ├── ImpureLazy.scala │ │ │ ├── ImpureLazy2.scala │ │ │ ├── Initialization1.scala │ │ │ ├── Initialization2.scala │ │ │ ├── Initialization3.scala │ │ │ ├── Initialization4.scala │ │ │ ├── Initialization5.scala │ │ │ ├── InnerClass.scala │ │ │ ├── InnerClassCloseMut.scala │ │ │ ├── InnerClassEquality.scala │ │ │ ├── InnerClassFunClosure.scala │ │ │ ├── IntToBigInt.scala │ │ │ ├── IntToBigInt2.scala │ │ │ ├── LambdaMutation.scala │ │ │ ├── List1.scala │ │ │ ├── List2.scala │ │ │ ├── List3.scala │ │ │ ├── List4.scala │ │ │ ├── MapAliasing.scala │ │ │ ├── MissingAbstractOverride.scala │ │ │ ├── MultipleInheritance.scala │ │ │ ├── MutableField.scala │ │ │ ├── MutableMapUpdated.scala │ │ │ ├── MutateOld.scala │ │ │ ├── NonMutableFunTypeParameter.scala │ │ │ ├── NonMutableTypeParameter.scala │ │ │ ├── ObjectParent1.scala │ │ │ ├── ObjectParent2.scala │ │ │ ├── OldInBody.scala │ │ │ ├── OldInMeasure.scala │ │ │ ├── OldInPre.scala │ │ │ ├── Println.scala │ │ │ ├── Purity1.scala │ │ │ ├── Purity2.scala │ │ │ ├── Require.scala │ │ │ ├── SuperAbstract.scala │ │ │ ├── TraitVar1.scala │ │ │ └── TraitVarDefault.scala │ │ └── valid │ │ │ ├── AccessorFlags.scala │ │ │ ├── AnonymousClasses1.scala │ │ │ ├── AnonymousClasses2.scala │ │ │ ├── AnonymousClasses3.scala │ │ │ ├── Arrays.scala │ │ │ ├── BlockInPost.scala │ │ │ ├── CaseObject.scala │ │ │ ├── CaseObject2.scala │ │ │ ├── CaseObjectSuper.scala │ │ │ ├── CaseObjectTypeMember.scala │ │ │ ├── ClassBody.scala │ │ │ ├── ConstSemigroup.scala │ │ │ ├── ConstructorArgsBoxing1.bak │ │ │ ├── ConstructorArgsBoxing2.bak │ │ │ ├── ConstructorArgsBoxing3.bak │ │ │ ├── Copy.scala │ │ │ ├── DefaultParam.scala │ │ │ ├── ExternFallback1.scala │ │ │ ├── ExternFallback2.scala │ │ │ ├── Extraction1.scala │ │ │ ├── Extraction2.scala │ │ │ ├── Extraction3.scala │ │ │ ├── Extraction4.scala │ │ │ ├── GhostAssert.scala │ │ │ ├── GhostCaseClass.scala │ │ │ ├── GhostCheckerNoneGet.scala │ │ │ ├── GhostEffect1.scala │ │ │ ├── GhostEffect2.scala │ │ │ ├── GhostEffect3.scala │ │ │ ├── GhostFlow1.scala │ │ │ ├── GhostFlow2.scala │ │ │ ├── GhostFlow3.scala │ │ │ ├── GhostLet.scala │ │ │ ├── GhostMethods.scala │ │ │ ├── HighLow.scala │ │ │ ├── ImplicitArguments.scala │ │ │ ├── ImplicitInlining.scala │ │ │ ├── ImportStatements.scala │ │ │ ├── InnerClassLocalFun.scala │ │ │ ├── InnerClassTypeMember.scala │ │ │ ├── InnerClasses1.scala │ │ │ ├── InnerClasses2.scala │ │ │ ├── InnerClasses3.scala │ │ │ ├── InnerClasses4.scala │ │ │ ├── InnerClassesScope1.scala │ │ │ ├── InnerClassesScope2.scala │ │ │ ├── LazyVal.scala │ │ │ ├── LongList.scala │ │ │ ├── MapAliasing.scala │ │ │ ├── MethodInCaseObject.scala │ │ │ ├── MethodsCasts.scala │ │ │ ├── MutableTypeParameter.scala │ │ │ ├── NonGhostUpdate.scala │ │ │ ├── OldInPost.scala │ │ │ ├── PairBound.scala │ │ │ ├── PreInferrence.scala │ │ │ ├── RefinedInnerImperative.scala │ │ │ ├── StaticDefaultGetter.scala │ │ │ ├── SuperCall.scala │ │ │ ├── SuperCalls.scala │ │ │ ├── ToString.scala │ │ │ ├── TupleSelect.scala │ │ │ ├── TypeMembers0.scala │ │ │ ├── TypeMembers1.scala │ │ │ ├── TypeMembers2.scala │ │ │ ├── TypeMembers3.scala │ │ │ ├── TypeMembers4.scala │ │ │ ├── TypeMembers5.scala │ │ │ ├── TypeParams1.scala │ │ │ ├── TypeParams2.scala │ │ │ ├── TypeParams3.scala │ │ │ ├── Typedefs1.scala │ │ │ ├── Typedefs2.scala │ │ │ ├── UnitIfExpr.scala │ │ │ └── Variance.scala │ ├── imperative │ │ ├── invalid │ │ │ ├── AnyMut.scala │ │ │ ├── Array1.scala │ │ │ ├── Array2.scala │ │ │ ├── Array3.scala │ │ │ ├── Assert1.scala │ │ │ ├── Assert2.scala │ │ │ ├── Asserts2.scala │ │ │ ├── FunctionCaching.scala │ │ │ ├── HiddenEffect.scala │ │ │ ├── IfExpr1.scala │ │ │ ├── IfExpr2.scala │ │ │ ├── ImpureMethods.scala │ │ │ ├── LoopInv1.scala │ │ │ ├── LoopInv2.scala │ │ │ ├── MutableTrait.scala │ │ │ ├── NestedFunState1.scala │ │ │ ├── NestedFunState2.scala │ │ │ ├── Randomness.scala │ │ │ ├── SimpleImperative.scala │ │ │ ├── StdIn1.scala │ │ │ ├── StdIn2.scala │ │ │ ├── StdIn3.scala │ │ │ └── StdIn4.scala │ │ └── valid │ │ │ ├── ADTWithArray1.scala │ │ │ ├── ADTWithArray2.scala │ │ │ ├── ADTWithArray3.scala │ │ │ ├── AccessorMutation1.scala │ │ │ ├── AccessorMutation2.scala │ │ │ ├── Arithmetic.scala │ │ │ ├── Array1.scala │ │ │ ├── Array2.scala │ │ │ ├── Array3.scala │ │ │ ├── Array4.scala │ │ │ ├── Array5.scala │ │ │ ├── Array6.scala │ │ │ ├── Array7.scala │ │ │ ├── Array8.scala │ │ │ ├── Array9.scala │ │ │ ├── ArrayNested1.scala │ │ │ ├── ArrayNested2.scala │ │ │ ├── ArrayParamMutation1.scala │ │ │ ├── ArrayParamMutation2.scala │ │ │ ├── ArrayParamMutation3.scala │ │ │ ├── ArrayParamMutation4.scala │ │ │ ├── ArrayParamMutation5.scala │ │ │ ├── ArrayParamMutation6.scala │ │ │ ├── ArrayParamMutation7.scala │ │ │ ├── ArrayParamMutation8.scala │ │ │ ├── ArrayParamMutation9.scala │ │ │ ├── Assert1.scala │ │ │ ├── Assert2.scala │ │ │ ├── Assert3.scala │ │ │ ├── Assert4.scala │ │ │ ├── Assign1.scala │ │ │ ├── Blocks1.scala │ │ │ ├── ExpressionOrder1.scala │ │ │ ├── ExpressionOrder2.scala │ │ │ ├── FunInvocEvaluationOrder1.scala │ │ │ ├── FunInvocEvaluationOrder2.scala │ │ │ ├── FunInvocEvaluationOrder3.scala │ │ │ ├── FunctionCaching.scala │ │ │ ├── GuessNumber.scala │ │ │ ├── HigherOrderFunctionsMutableParams1.scala │ │ │ ├── HigherOrderFunctionsMutableParams10.scala │ │ │ ├── HigherOrderFunctionsMutableParams11.scala │ │ │ ├── HigherOrderFunctionsMutableParams12.scala │ │ │ ├── HigherOrderFunctionsMutableParams13.scala │ │ │ ├── HigherOrderFunctionsMutableParams14.scala │ │ │ ├── HigherOrderFunctionsMutableParams15.scala │ │ │ ├── HigherOrderFunctionsMutableParams16.scala │ │ │ ├── HigherOrderFunctionsMutableParams17.scala │ │ │ ├── HigherOrderFunctionsMutableParams18.scala │ │ │ ├── HigherOrderFunctionsMutableParams2.scala │ │ │ ├── HigherOrderFunctionsMutableParams3.scala │ │ │ ├── HigherOrderFunctionsMutableParams4.scala │ │ │ ├── HigherOrderFunctionsMutableParams5.scala │ │ │ ├── HigherOrderFunctionsMutableParams6.scala │ │ │ ├── HigherOrderFunctionsMutableParams7.scala │ │ │ ├── HigherOrderFunctionsMutableParams8.scala │ │ │ ├── HigherOrderFunctionsMutableParams9.scala │ │ │ ├── IfExpr1.scala │ │ │ ├── IfExpr2.scala │ │ │ ├── IfExpr3.scala │ │ │ ├── IfExpr4.scala │ │ │ ├── ImmutableOld.scala │ │ │ ├── Lambda1.scala │ │ │ ├── Lambda2.scala │ │ │ ├── LoopInv.scala │ │ │ ├── MultiArray1.scala │ │ │ ├── MultiArray2.scala │ │ │ ├── MultiArray3.scala │ │ │ ├── MultiArray4.scala │ │ │ ├── MultiArray5.scala │ │ │ ├── MultiArray6.scala │ │ │ ├── MultiArray7.scala │ │ │ ├── MutableMapInit.scala │ │ │ ├── MutableMapUpdated.scala │ │ │ ├── MutateMap.scala │ │ │ ├── MutateMapElement.scala │ │ │ ├── MutateNestedMapElement.scala │ │ │ ├── NestedFunParamsMutation1.scala │ │ │ ├── NestedFunParamsMutation2.scala │ │ │ ├── NestedFunParamsMutation3.scala │ │ │ ├── NestedFunState1.scala │ │ │ ├── NestedFunState10.scala │ │ │ ├── NestedFunState11.scala │ │ │ ├── NestedFunState2.scala │ │ │ ├── NestedFunState3.scala │ │ │ ├── NestedFunState4.scala │ │ │ ├── NestedFunState5.scala │ │ │ ├── NestedFunState6.scala │ │ │ ├── NestedFunState7.scala │ │ │ ├── NestedFunState8.scala │ │ │ ├── NestedFunState9.scala │ │ │ ├── NestedOld1.scala │ │ │ ├── NestedOld2.scala │ │ │ ├── NestedVar.scala │ │ │ ├── NoMutation.scala │ │ │ ├── ObjectHierarchyMutation1.scala │ │ │ ├── ObjectHierarchyMutation10.scala │ │ │ ├── ObjectHierarchyMutation11.scala │ │ │ ├── ObjectHierarchyMutation2.scala │ │ │ ├── ObjectHierarchyMutation3.scala │ │ │ ├── ObjectHierarchyMutation4.scala │ │ │ ├── ObjectHierarchyMutation5.scala │ │ │ ├── ObjectHierarchyMutation6.scala │ │ │ ├── ObjectHierarchyMutation7.scala │ │ │ ├── ObjectHierarchyMutation8.scala │ │ │ ├── ObjectHierarchyMutation9.scala │ │ │ ├── ObjectParamMutation1.scala │ │ │ ├── ObjectParamMutation2.scala │ │ │ ├── ObjectParamMutation3.scala │ │ │ ├── ObjectParamMutation4.scala │ │ │ ├── ObjectParamMutation5.scala │ │ │ ├── ObjectParamMutation6.scala │ │ │ ├── ObjectParamMutation7.scala │ │ │ ├── ObjectParamMutation8.scala │ │ │ ├── ObjectParamMutation9.scala │ │ │ ├── OldThis1.scala │ │ │ ├── OldThis2.scala │ │ │ ├── OldThis3.scala │ │ │ ├── OldThis4.scala │ │ │ ├── PatternGuards1.scala │ │ │ ├── PatternGuards2.scala │ │ │ ├── PatternMatchingAliasingMutation1.scala │ │ │ ├── PatternMatchingAliasingMutation2.scala │ │ │ ├── PatternMatchingAliasingMutation3.scala │ │ │ ├── PatternMatchingAliasingMutation4.scala │ │ │ ├── PatternMatchingAliasingMutation5.scala │ │ │ ├── PatternMatchingAliasingMutation6.scala │ │ │ ├── Sequencing1.scala │ │ │ ├── Sequencing2.scala │ │ │ ├── Sequencing3.scala │ │ │ ├── Sequencing4.scala │ │ │ ├── Sequencing5.scala │ │ │ ├── Sequencing6.scala │ │ │ ├── Sequencing7.scala │ │ │ ├── Sequencing8.scala │ │ │ ├── ShortCircuit.scala │ │ │ ├── Snapshot.scala │ │ │ ├── Snapshot2.scala │ │ │ ├── StdIn1.scala │ │ │ ├── TraitVar1.scala │ │ │ ├── TraitVar2.scala │ │ │ ├── TraitVar3.scala │ │ │ ├── Tutorial.scala │ │ │ ├── VarUpdate.scala │ │ │ ├── While1.scala │ │ │ ├── While2.scala │ │ │ ├── While3.scala │ │ │ ├── WhileAsFun1.scala │ │ │ ├── WhileAsFun2.scala │ │ │ └── WhileConditionSubexpression.scala │ ├── smartcontracts │ │ ├── failCompilation │ │ │ ├── CallWithEther1.scala │ │ │ ├── DuplicateIdentifier1.scala │ │ │ ├── DuplicateIdentifier2.scala │ │ │ ├── EnvironmentType1.scala │ │ │ ├── EnvironmentType2.scala │ │ │ ├── EnvironmentType3.scala │ │ │ ├── EnvironmentType4.scala │ │ │ ├── MappingType1.scala │ │ │ ├── MappingType2.scala │ │ │ ├── MappingType3.scala │ │ │ ├── MappingType4.scala │ │ │ ├── MappingType5.scala │ │ │ ├── MsgType1.scala │ │ │ ├── MsgType2.scala │ │ │ ├── MsgType3.scala │ │ │ ├── MsgType4.scala │ │ │ └── PublicMethodWithRequire.scala │ │ ├── failExtraction │ │ │ ├── ConcreteInterfaceMethod.scala │ │ │ ├── ContractInheritance.scala │ │ │ ├── NonFinalConstructor.scala │ │ │ ├── NonFinalInvariant.scala │ │ │ └── NonFinalMethod.scala │ │ ├── failVerification │ │ │ ├── FalseInvariant.scala │ │ │ ├── FieldMutated.scala │ │ │ ├── Overflow.scala │ │ │ ├── PrivateMethodInvalid.scala │ │ │ └── Reentrancy.scala │ │ └── valid │ │ │ ├── BasicContract.scala │ │ │ ├── BasicInterface.scala │ │ │ ├── BasicLibrary.scala │ │ │ ├── CallWithEther.scala │ │ │ ├── Candy.scala │ │ │ ├── Constructor.scala │ │ │ ├── ConstructorGlobalInvariant.scala │ │ │ ├── DuplicateIdentifier1.scala │ │ │ ├── DuplicateIdentifier2.scala │ │ │ ├── DynRequire.scala │ │ │ ├── EtherTransfer.scala │ │ │ ├── GhostParameter.scala │ │ │ ├── HavocInjectionPureMethod.scala │ │ │ ├── HavocInvariant.scala │ │ │ ├── InterfaceWithPost.scala │ │ │ ├── InvariantAcyclicity.scala │ │ │ ├── LoanContract │ │ │ ├── ERC20Token.scala │ │ │ ├── LoanContract.scala │ │ │ └── LoanContractInvariant.scala │ │ │ ├── MappingType1.scala │ │ │ ├── MappingType2.scala │ │ │ ├── MinimumToken │ │ │ ├── MinimumToken.scala │ │ │ └── MinimumTokenInvariant.scala │ │ │ ├── MsgSame.scala │ │ │ ├── OwnedContract.scala │ │ │ ├── PayWith.scala │ │ │ ├── PositiveUint.scala │ │ │ ├── PrivateMethodValid.scala │ │ │ ├── Resend.scala │ │ │ ├── TrueInvariant.scala │ │ │ ├── TwoContracts.scala │ │ │ ├── Types.scala │ │ │ ├── UnsafeCast.scala │ │ │ ├── UnsignedOperation.scala │ │ │ └── ValidReentrancy.scala │ ├── strictarithmetic │ │ ├── invalid │ │ │ ├── Overflow1.scala │ │ │ ├── Overflow10.scala │ │ │ ├── Overflow11.scala │ │ │ ├── Overflow12.scala │ │ │ ├── Overflow13.scala │ │ │ ├── Overflow2.scala │ │ │ ├── Overflow3.scala │ │ │ ├── Overflow4.scala │ │ │ ├── Overflow5.scala │ │ │ ├── Overflow6.scala │ │ │ ├── Overflow7.scala │ │ │ ├── Overflow8.scala │ │ │ ├── Overflow9.scala │ │ │ ├── StrictArithmetic1.scala │ │ │ ├── StrictArithmetic2.scala │ │ │ ├── StrictArithmetic3.scala │ │ │ ├── StrictArithmetic4.scala │ │ │ ├── Wrapping1.scala │ │ │ └── Wrapping2.scala │ │ └── valid │ │ │ ├── Overflow1.scala │ │ │ ├── StrictArithmetic1.scala │ │ │ ├── Wrapping1.scala │ │ │ └── Wrapping2.scala │ ├── termination │ │ ├── looping │ │ │ ├── Inconsistency.scala │ │ │ ├── Inconsistency2.scala │ │ │ ├── Inconsistency5.scala │ │ │ ├── LambdaCalculus.scala │ │ │ ├── NegativeDatatype.scala │ │ │ ├── NonStrictPositiveTypes.scala │ │ │ ├── NonStrictPositiveTypesIR.scala │ │ │ ├── Numeric1.scala │ │ │ ├── Numeric2.scala │ │ │ ├── Numeric3.scala │ │ │ ├── OddEven.scala │ │ │ ├── Queue.scala │ │ │ ├── Term.scala │ │ │ ├── Termination_failling1.scala │ │ │ ├── UniversalEquality.scala │ │ │ ├── WrongFibonacci.scala │ │ │ ├── Zeros.scala │ │ │ ├── Zeros2.scala │ │ │ └── Zeros3.scala │ │ └── valid │ │ │ ├── Ackermann.scala │ │ │ ├── AliasPartial.scala │ │ │ ├── AnyDown.scala │ │ │ ├── BinomialHeap.scala │ │ │ ├── BottomUpMergeSort.scala │ │ │ ├── ChurchNum.scala │ │ │ ├── Consistent.scala │ │ │ ├── ConstantPropagation.scala │ │ │ ├── CountTowardsZero.scala │ │ │ ├── CyclicFibStream.scala │ │ │ ├── CyclicHammingStream.scala │ │ │ ├── Deque.scala │ │ │ ├── Fibonacci.scala │ │ │ ├── FiniteStreams.scala │ │ │ ├── Foldr.scala │ │ │ ├── HOTermination.scala │ │ │ ├── HOTest.scala │ │ │ ├── HammingMemoized.scala │ │ │ ├── Indirect.scala │ │ │ ├── IndirectHO.scala │ │ │ ├── IndirectIntro.scala │ │ │ ├── Knapsack.scala │ │ │ ├── LazyNumericalRep.scala │ │ │ ├── LazySelectionSort.scala │ │ │ ├── LazyTree.scala │ │ │ ├── ListWithSize.scala │ │ │ ├── Loop2.scala │ │ │ ├── Map.scala │ │ │ ├── McCarthy91.scala │ │ │ ├── MergeSortTermination.scala │ │ │ ├── NNF.scala │ │ │ ├── NNFSimple.scala │ │ │ ├── NestedLoop.scala │ │ │ ├── Numeric1.scala │ │ │ ├── OddEvenComplex.scala │ │ │ ├── OddEvenMoreComplex.scala │ │ │ ├── OddEvenSimple.scala │ │ │ ├── PackratParsing.scala │ │ │ ├── Partial.scala │ │ │ ├── Patterns.scala │ │ │ ├── Queue.scala │ │ │ ├── QuickSort.scala │ │ │ ├── RealTimeQueue.scala │ │ │ ├── RedBlackTree.scala │ │ │ ├── SimpInterpret.scala │ │ │ ├── Streams.scala │ │ │ ├── Termination_passing1.scala │ │ │ ├── ToChurch.scala │ │ │ ├── UpDown.scala │ │ │ ├── Viterbi.scala │ │ │ └── XPlus2N.scala │ ├── typechecker │ │ └── valid │ │ │ ├── AbstractPost.scala │ │ │ ├── AbstractRefinementMap.scala │ │ │ ├── Acc.scala │ │ │ ├── Ackermann.scala │ │ │ ├── AliasPartial.scala │ │ │ ├── AmortizedQueue.scala │ │ │ ├── AnyDown.scala │ │ │ ├── AssociativeFold.scala │ │ │ ├── AssociativeList.scala │ │ │ ├── BalancedParentheses.scala │ │ │ ├── BasicReal.scala │ │ │ ├── BestRealTypes.scala │ │ │ ├── BigIntMonoidLaws.scala │ │ │ ├── BinarySearch.scala │ │ │ ├── BinomialHeap.scala │ │ │ ├── BitsTricks.scala │ │ │ ├── BooleanOps.scala │ │ │ ├── BottomUpMergeSort.scala │ │ │ ├── Bytes.scala │ │ │ ├── ChurchNum.scala │ │ │ ├── Client.scala │ │ │ ├── CountTowardsZero.scala │ │ │ ├── Countable.scala │ │ │ ├── Deque.scala │ │ │ ├── DivisionByZero.scala │ │ │ ├── EffectfulPost.scala │ │ │ ├── EitherLaws.scala │ │ │ ├── ExternPost.scala │ │ │ ├── Factorial.scala │ │ │ ├── Fibonacci.scala │ │ │ ├── FiniteSort.scala │ │ │ ├── FiniteStreams.scala │ │ │ ├── FlatMap.scala │ │ │ ├── Foldr.scala │ │ │ ├── FoolProofAdder.scala │ │ │ ├── Formulas.scala │ │ │ ├── GodelNumbering.scala │ │ │ ├── HOInvocations.scala │ │ │ ├── HammingMemoized.scala │ │ │ ├── Heaps.scala │ │ │ ├── IndexOfInjective.scala │ │ │ ├── IndirectHO.scala │ │ │ ├── InnerClassTypeMember.scala │ │ │ ├── InsertionSort.scala │ │ │ ├── IntSet.scala │ │ │ ├── IntSetProp.scala │ │ │ ├── IntSetUnit.scala │ │ │ ├── Justify.scala │ │ │ ├── Knapsack.scala │ │ │ ├── LazyNumericalRep.scala │ │ │ ├── LazySelectionSort.scala │ │ │ ├── List.scala │ │ │ ├── ListMonad.scala │ │ │ ├── ListMonoidLaws.scala │ │ │ ├── ListWithSize.scala │ │ │ ├── LiteralMaps.scala │ │ │ ├── Longs.scala │ │ │ ├── LoopInv.scala │ │ │ ├── Map.scala │ │ │ ├── MapGetOrElse2.scala │ │ │ ├── MapGetPlus.scala │ │ │ ├── McCarthy91.scala │ │ │ ├── Mean.scala │ │ │ ├── MergeSort.scala │ │ │ ├── MergeSort2.scala │ │ │ ├── MergeSortTermination.scala │ │ │ ├── Methods.scala │ │ │ ├── MicroTests │ │ │ ├── ADTInvariants1.scala │ │ │ ├── ADTInvariants2.scala │ │ │ ├── ADTInvariants3.scala │ │ │ ├── ADTInvariants4.scala │ │ │ ├── ADTWithArray1.scala │ │ │ ├── ADTWithArray2.scala │ │ │ ├── ADTWithArray4.scala │ │ │ ├── ADTWithArray5.scala │ │ │ ├── ADTWithArray6.scala │ │ │ ├── AbstractClasses.scala │ │ │ ├── AddingPositiveNumbers.scala │ │ │ ├── Anonymous.scala │ │ │ ├── Array1.scala │ │ │ ├── Array2.scala │ │ │ ├── Array3.scala │ │ │ ├── Array4.scala │ │ │ ├── Array5.scala │ │ │ ├── ArrayLiterals.scala │ │ │ ├── ArrayUpdated.scala │ │ │ ├── Asserts1.scala │ │ │ ├── BVDivSemantics.scala │ │ │ ├── BVDivisionByZero.scala │ │ │ ├── BVDivisionByZero2.scala │ │ │ ├── CallByName1.scala │ │ │ ├── CaseObject1.scala │ │ │ ├── Closures.scala │ │ │ ├── Closures2.scala │ │ │ ├── ConcreteClass.scala │ │ │ ├── Copy.scala │ │ │ ├── CopyInv.scala │ │ │ ├── Extern1.scala │ │ │ ├── Extern2.scala │ │ │ ├── Field1.scala │ │ │ ├── Field2.scala │ │ │ ├── FieldInheritance.scala │ │ │ ├── FinalMethod.scala │ │ │ ├── Generics.scala │ │ │ ├── Generics1.scala │ │ │ ├── IgnoredField.scala │ │ │ ├── ImmutableTrait.scala │ │ │ ├── InstanceOf1.scala │ │ │ ├── Issue803.scala │ │ │ ├── LambdaEquality.scala │ │ │ ├── Lambdas.scala │ │ │ ├── Lambdas2.scala │ │ │ ├── Laws0.scala │ │ │ ├── Laws1.scala │ │ │ ├── Laws2.scala │ │ │ ├── Lists1.scala │ │ │ ├── Lists2.scala │ │ │ ├── Lists3.scala │ │ │ ├── Lists4.scala │ │ │ ├── Lists5.scala │ │ │ ├── Lists6.scala │ │ │ ├── Loop2.scala │ │ │ ├── MatchExh.scala │ │ │ ├── MatchGuard.scala │ │ │ ├── Monads1.scala │ │ │ ├── Monads3.scala │ │ │ ├── MyMap.scala │ │ │ ├── MyTuple1.scala │ │ │ ├── MyTuple2.scala │ │ │ ├── MyTuple3.scala │ │ │ ├── MyTuple4.scala │ │ │ ├── MyTuple5.scala │ │ │ ├── MyTuple6.scala │ │ │ ├── Nested1.scala │ │ │ ├── Nested10.scala │ │ │ ├── Nested11.scala │ │ │ ├── Nested12.scala │ │ │ ├── Nested13.scala │ │ │ ├── Nested14.scala │ │ │ ├── Nested15.scala │ │ │ ├── Nested16.scala │ │ │ ├── Nested17.scala │ │ │ ├── Nested18.scala │ │ │ ├── Nested2.scala │ │ │ ├── Nested3.scala │ │ │ ├── Nested4.scala │ │ │ ├── Nested5.scala │ │ │ ├── Nested6.scala │ │ │ ├── Nested7.scala │ │ │ ├── Nested8.scala │ │ │ ├── Nested9.scala │ │ │ ├── NestedLoop.scala │ │ │ ├── Opaque.scala │ │ │ ├── PureMethods.scala │ │ │ ├── RealDivisionByZero.scala │ │ │ ├── SetIsEmpty.scala │ │ │ ├── Sets1.scala │ │ │ ├── Sets2.scala │ │ │ ├── StaticChecks1.scala │ │ │ ├── StaticChecks2.scala │ │ │ ├── Subtyping1.scala │ │ │ ├── Subtyping2.scala │ │ │ ├── SuperCall1.scala │ │ │ ├── SuperCall2.scala │ │ │ ├── SuperCall3.scala │ │ │ ├── SuperCall4.scala │ │ │ ├── SuperCall5.scala │ │ │ ├── SuperCall6.scala │ │ │ ├── TestPartialFunction.scala │ │ │ ├── TestPartialFunction2.scala │ │ │ ├── TestPartialFunction3.scala │ │ │ ├── Unapply.scala │ │ │ ├── Unit1.scala │ │ │ └── Unit2.scala │ │ │ ├── Monoid.scala │ │ │ ├── MySet.scala │ │ │ ├── NNF.scala │ │ │ ├── NNFSimple.scala │ │ │ ├── NatMonoidLaws.scala │ │ │ ├── NaturalBuiltin.scala │ │ │ ├── NotEquals.scala │ │ │ ├── Numeric1.scala │ │ │ ├── OddEven.scala │ │ │ ├── OddEvenComplex.scala │ │ │ ├── OddEvenMoreComplex.scala │ │ │ ├── OptionMonad.scala │ │ │ ├── Overrides.scala │ │ │ ├── PackratParsing.scala │ │ │ ├── ParBalance.scala │ │ │ ├── PartialCompiler.scala │ │ │ ├── PartialKVTrace.scala │ │ │ ├── PartitionExample.scala │ │ │ ├── Patterns.scala │ │ │ ├── Peano.scala │ │ │ ├── PositiveMap.scala │ │ │ ├── PostConditionInTuple.scala │ │ │ ├── PreInSpecs.scala │ │ │ ├── PropositionalLogic.scala │ │ │ ├── Queue.scala │ │ │ ├── QuickSort.scala │ │ │ ├── QuickSortFilter.scala │ │ │ ├── RealTimeQueue.scala │ │ │ ├── RedBlackTree.scala │ │ │ ├── SearchLinkedList.scala │ │ │ ├── Shorts.scala │ │ │ ├── SimpInterpret.scala │ │ │ ├── StableSorter.scala │ │ │ ├── Termination_passing1.scala │ │ │ ├── ToChurch.scala │ │ │ ├── Trees1.scala │ │ │ ├── UpDown.scala │ │ │ ├── Viterbi.scala │ │ │ └── XPlus2N.scala │ └── verification │ │ ├── invalid │ │ ├── ADTInvariantCheck.scala │ │ ├── ADTInvariants.scala │ │ ├── ADTWithArray1.scala │ │ ├── ADTWithArray2.scala │ │ ├── AbstractRefinementMap.scala │ │ ├── Acc.scala │ │ ├── AddNaturals1.scala │ │ ├── AddNaturals2.scala │ │ ├── AddNaturals3.scala │ │ ├── AddNaturals4.scala │ │ ├── AddingNegativeNumbers.scala │ │ ├── AddingPositiveNumbers.scala │ │ ├── Array1.scala │ │ ├── Array2.scala │ │ ├── Array3.scala │ │ ├── Array4.scala │ │ ├── Array5.scala │ │ ├── Array6.scala │ │ ├── Array7.scala │ │ ├── Asserts1.scala │ │ ├── AssociativityProperties.scala │ │ ├── BVDivision2.scala │ │ ├── BVDivisionByZero.scala │ │ ├── BVRemainderByZero.scala │ │ ├── BadConcRope.scala │ │ ├── BigArray.scala │ │ ├── BigIntMonoidLaws.scala │ │ ├── BinarySearch1.scala │ │ ├── BinarySearch2.scala │ │ ├── BinarySearch3.scala │ │ ├── BinarySearchTreeQuant.scala │ │ ├── BodyEnsuring.scala │ │ ├── BraunTree.scala │ │ ├── Bytes.scala │ │ ├── CallByName1.scala │ │ ├── CharCompare.scala │ │ ├── Choose1.scala │ │ ├── Choose2.scala │ │ ├── ContainerTest.scala │ │ ├── CopyInv.scala │ │ ├── DisrespectfulOverride.scala │ │ ├── DisrespectfulOverride2.scala │ │ ├── DivisionByZero.scala │ │ ├── EnsuringBoolean.scala │ │ ├── Equations1.scala │ │ ├── Equations2.scala │ │ ├── Equations3.scala │ │ ├── Existentials.scala │ │ ├── ExternFallbackMut.scala │ │ ├── ExternFun.scala │ │ ├── ExternMut.scala │ │ ├── FieldInheritance.scala │ │ ├── FiniteSort.scala │ │ ├── ForallAssoc.scala │ │ ├── Generics.scala │ │ ├── Generics2.scala │ │ ├── HOInvocations.scala │ │ ├── HiddenOverride.scala │ │ ├── InsertionSort.scala │ │ ├── IntSet.scala │ │ ├── IntSetUnit.scala │ │ ├── LambdaEquality2.scala │ │ ├── LambdaPrecondition.scala │ │ ├── Laws1.scala │ │ ├── ListOperations.scala │ │ ├── Lists.scala │ │ ├── MatchExh.scala │ │ ├── Mean.scala │ │ ├── ModuloByZero.scala │ │ ├── MyTuple1.scala │ │ ├── MyTuple2.scala │ │ ├── MyTuple3.scala │ │ ├── Nested15.scala │ │ ├── Overrides.scala │ │ ├── ParentInvariant.scala │ │ ├── PartialSplit.scala │ │ ├── Passes1.scala │ │ ├── Passes2.scala │ │ ├── PositiveMap.scala │ │ ├── PositiveMap2.scala │ │ ├── PreInPre.scala │ │ ├── PreInSpecs.scala │ │ ├── PropositionalLogic.scala │ │ ├── README │ │ ├── RealDivisionByZero.scala │ │ ├── RealNonDiscrete.scala │ │ ├── RedBlackTree2.scala │ │ ├── RemainderByZero.scala │ │ ├── SimpleQuantification2.scala │ │ ├── SpecWithExtern.scala │ │ ├── StaticChecks1.scala │ │ ├── StaticChecks2.scala │ │ ├── StaticChecks3.scala │ │ ├── SuperInvariants.scala │ │ ├── TestLazinessOfAnd.scala │ │ ├── Unapply1.scala │ │ ├── Unit1.scala │ │ └── ValueClassesInv.scala │ │ ├── unchecked │ │ ├── AbstractRefinementMap2.scala │ │ ├── HOInvocations2.scala │ │ ├── InductTacticTest.scala │ │ ├── Monotonic.scala │ │ ├── Postcondition.scala │ │ ├── RedBlackTree.scala │ │ ├── SimpleQuantification.scala │ │ ├── SimpleQuantification3.scala │ │ └── Unapply2.scala │ │ └── valid │ │ ├── ADTInvariants1.scala │ │ ├── ADTInvariants2.scala │ │ ├── ADTInvariants3.scala │ │ ├── ADTInvariants4.scala │ │ ├── ADTWithArray1.scala │ │ ├── ADTWithArray2.scala │ │ ├── ADTWithArray4.scala │ │ ├── ADTWithArray5.scala │ │ ├── ADTWithArray6.scala │ │ ├── AbstractClasses.scala │ │ ├── AbstractRefinementMap.scala │ │ ├── Acc.scala │ │ ├── Actors.scala │ │ ├── AddingPositiveNumbers.scala │ │ ├── AdtSpecializationUnapply.scala │ │ ├── AdtSpecializationUnapply2.scala │ │ ├── AmortizedQueue.scala │ │ ├── Anonymous.scala │ │ ├── AnonymousClasses1.scala │ │ ├── AnonymousClasses2.scala │ │ ├── AnonymousClasses3.scala │ │ ├── Array1.scala │ │ ├── Array2.scala │ │ ├── Array3.scala │ │ ├── Array4.scala │ │ ├── Array5.scala │ │ ├── ArrayLiterals.scala │ │ ├── ArraySlice.scala │ │ ├── ArrayUpdated.scala │ │ ├── Asserts1.scala │ │ ├── AssociativeList.scala │ │ ├── AssociativityProperties.scala │ │ ├── BVDivSemantics.scala │ │ ├── BVDivisionByZero.scala │ │ ├── BVDivisionByZero2.scala │ │ ├── BVMaxInterpret.scala │ │ ├── BasicReal.scala │ │ ├── BestRealTypes.scala │ │ ├── BigIntMonoidLaws.scala │ │ ├── BigIntRing.scala │ │ ├── BinarySearch.scala │ │ ├── BinarySearchTreeQuant.scala │ │ ├── BinarySearchTreeQuant2.scala │ │ ├── BitsTricks.scala │ │ ├── BitsTricksSlow.scala │ │ ├── BooleanOps.scala │ │ ├── Bytes.scala │ │ ├── CallByName1.scala │ │ ├── CaseObject1.scala │ │ ├── ChooseLIA.scala │ │ ├── ChooseWithWitness.scala │ │ ├── Client.scala │ │ ├── Closures.scala │ │ ├── Closures2.scala │ │ ├── Composition.scala │ │ ├── ConcRope.scala │ │ ├── ConcTree.scala │ │ ├── ConcreteClass.scala │ │ ├── ContMonad.scala │ │ ├── ContainerTest.scala │ │ ├── Copy.scala │ │ ├── Copy2.scala │ │ ├── CopyInv.scala │ │ ├── Count.scala │ │ ├── Countable.scala │ │ ├── Countable2.scala │ │ ├── CovariantList.scala │ │ ├── DivisionByZero.scala │ │ ├── EffectfulPost.scala │ │ ├── EitherLaws.scala │ │ ├── Equations.scala │ │ ├── Existentials.scala │ │ ├── Extern1.scala │ │ ├── Extern2.scala │ │ ├── ExternField.scala │ │ ├── ExternFieldPure.scala │ │ ├── Factorial.scala │ │ ├── Field1.scala │ │ ├── Field2.scala │ │ ├── FieldInheritance.scala │ │ ├── Filter.scala │ │ ├── FinalMethod.scala │ │ ├── FiniteSort.scala │ │ ├── FlatMap.scala │ │ ├── FoldAssociative.scala │ │ ├── FoolProofAdder.scala │ │ ├── ForallAssoc.scala │ │ ├── ForallWithBlock.scala │ │ ├── Formulas.scala │ │ ├── FunctionMaps.scala │ │ ├── FunctionMapsObj.scala │ │ ├── Generics.scala │ │ ├── Generics1.scala │ │ ├── GoodInitialization.scala │ │ ├── HOInvocations.scala │ │ ├── HOInvocations2.scala │ │ ├── Havoc.scala │ │ ├── Heaps.scala │ │ ├── ImmutableTrait.scala │ │ ├── InnerClassTypeMember.scala │ │ ├── InnerClasses0.scala │ │ ├── InnerClasses1.scala │ │ ├── InnerClasses2.scala │ │ ├── InnerClasses3.scala │ │ ├── InnerClasses4.scala │ │ ├── InnerClasses5.scala │ │ ├── Insert.scala │ │ ├── InsertionSort.scala │ │ ├── InstanceOf1.scala │ │ ├── IntSet.scala │ │ ├── IntSetInv.scala │ │ ├── IntSetProp.scala │ │ ├── IntSetUnit.scala │ │ ├── Iterables.scala │ │ ├── Justify.scala │ │ ├── LambdaEquality.scala │ │ ├── Lambdas.scala │ │ ├── Lambdas2.scala │ │ ├── LastDynAssert.scala │ │ ├── LawTypeArgsElim.scala │ │ ├── Laws0.scala │ │ ├── Laws1.scala │ │ ├── Laws2.scala │ │ ├── LetAliasing.scala │ │ ├── ListMonoidLaws.scala │ │ ├── ListOperations.scala │ │ ├── Lists1.scala │ │ ├── Lists2.scala │ │ ├── Lists3.scala │ │ ├── Lists4.scala │ │ ├── Lists5.scala │ │ ├── Lists6.scala │ │ ├── LiteralMaps.scala │ │ ├── Longs.scala │ │ ├── ManyInvariants.scala │ │ ├── MapDiff.scala │ │ ├── MapGetOrElse2.scala │ │ ├── MapGetPlus.scala │ │ ├── MatchExh.scala │ │ ├── MatchGuard.scala │ │ ├── Mean.scala │ │ ├── MergeSort.scala │ │ ├── MergeSort2.scala │ │ ├── Methods.scala │ │ ├── Monads1.scala │ │ ├── Monads2.scala │ │ ├── Monads3.scala │ │ ├── Monoid.scala │ │ ├── Monotonic.scala │ │ ├── Monotonicity.scala │ │ ├── MsgQueue.scala │ │ ├── MyMap.scala │ │ ├── MySet.scala │ │ ├── MyTuple1.scala │ │ ├── MyTuple2.scala │ │ ├── MyTuple3.scala │ │ ├── MyTuple4.scala │ │ ├── MyTuple5.scala │ │ ├── MyTuple6.scala │ │ ├── NatMonoidLaws.scala │ │ ├── NaturalBuiltin.scala │ │ ├── Nested1.scala │ │ ├── Nested10.scala │ │ ├── Nested11.scala │ │ ├── Nested12.scala │ │ ├── Nested13.scala │ │ ├── Nested14.scala │ │ ├── Nested15.scala │ │ ├── Nested16.scala │ │ ├── Nested17.scala │ │ ├── Nested18.scala │ │ ├── Nested2.scala │ │ ├── Nested3.scala │ │ ├── Nested4.scala │ │ ├── Nested5.scala │ │ ├── Nested6.scala │ │ ├── Nested7.scala │ │ ├── Nested8.scala │ │ ├── Nested9.scala │ │ ├── NotEquals.scala │ │ ├── Opaque.scala │ │ ├── Overrides.scala │ │ ├── ParBalance.scala │ │ ├── PartialCompiler.scala │ │ ├── PartialKVTrace.scala │ │ ├── Passes1.scala │ │ ├── Passes2.scala │ │ ├── Peano.scala │ │ ├── PositiveMap.scala │ │ ├── PositiveMap2.scala │ │ ├── Postcondition.scala │ │ ├── PreInSpecs.scala │ │ ├── Predicate.scala │ │ ├── PropositionalLogic.scala │ │ ├── PureMethods.scala │ │ ├── QuantifierUnification.scala │ │ ├── QuickSort.scala │ │ ├── QuickSortFilter.scala │ │ ├── README │ │ ├── RealDivisionByZero.scala │ │ ├── RedBlackTree.scala │ │ ├── Reverse.scala │ │ ├── SearchLinkedList.scala │ │ ├── SetIsEmpty.scala │ │ ├── Sets1.scala │ │ ├── Sets2.scala │ │ ├── Shorts.scala │ │ ├── SimpleQuantification.scala │ │ ├── Size.scala │ │ ├── Sorted.scala │ │ ├── StableSorter.scala │ │ ├── StateMachine.scala │ │ ├── StaticChecks1.scala │ │ ├── StaticChecks2.scala │ │ ├── Subtyping1.scala │ │ ├── Subtyping2.scala │ │ ├── SuperCall1.scala │ │ ├── SuperCall2.scala │ │ ├── SuperCall3.scala │ │ ├── SuperCall4.scala │ │ ├── SuperCall5.scala │ │ ├── SuperCall6.scala │ │ ├── TestPartialFunction.scala │ │ ├── TestPartialFunction2.scala │ │ ├── TestPartialFunction3.scala │ │ ├── TransitiveQuantification.scala │ │ ├── Trees1.scala │ │ ├── Unapply.scala │ │ ├── Unit1.scala │ │ ├── Unit2.scala │ │ ├── ValueClasses.scala │ │ ├── ValueClassesInv.scala │ │ └── Zero.scala ├── common │ ├── README │ └── src │ │ ├── it │ │ └── scala │ │ │ └── stainless │ │ │ ├── ExtractionSuite.scala │ │ │ └── verification │ │ │ └── ComponentTestSuite.scala │ │ └── test │ │ ├── resources │ │ ├── AbstractValOverrides.scala │ │ ├── GhostOverrides.scala │ │ ├── SoundEquality.scala │ │ └── SoundInvariants.scala │ │ └── scala │ │ └── stainless │ │ ├── InputUtils.scala │ │ ├── TestContext.scala │ │ ├── ast │ │ ├── ExplicitNumericPromotionSuite.scala │ │ ├── LawsLibrarySuite.scala │ │ ├── LibraryLookupSuite.scala │ │ ├── OpaqueSuite.scala │ │ ├── TreeSanitizerSuite.scala │ │ └── TupleExtractionSuite.scala │ │ └── verification │ │ ├── InliningOnceSuite.scala │ │ └── InliningSuite.scala ├── dotty │ └── src │ │ └── main │ │ └── scala │ │ └── stainless │ │ └── frontends │ │ └── dotc │ │ ├── ASTExtractors.scala │ │ ├── CodeExtraction.scala │ │ └── SymbolsContext.scala ├── library │ └── stainless │ │ ├── annotation │ │ ├── annotations.scala │ │ └── isabelle.scala │ │ ├── collection │ │ ├── CMap.scala │ │ ├── ConcRope.scala │ │ ├── List.scala │ │ ├── ListMap.scala │ │ └── Queue.scala │ │ ├── equations │ │ └── package.scala │ │ ├── io │ │ ├── FileInputStream.scala │ │ ├── FileOutputStream.scala │ │ ├── StdIn.scala │ │ ├── StdOut.scala │ │ └── package.scala │ │ ├── lang │ │ ├── Bag.scala │ │ ├── Either.scala │ │ ├── Map.scala │ │ ├── MutableMap.scala │ │ ├── Option.scala │ │ ├── PartialFunction.scala │ │ ├── Rational.scala │ │ ├── Real.scala │ │ ├── Set.scala │ │ ├── StaticChecks.scala │ │ ├── StrOps.scala │ │ └── package.scala │ │ ├── math │ │ ├── Nat.scala │ │ └── package.scala │ │ ├── proof │ │ ├── BoundedQuantifiers.scala │ │ ├── Internal.scala │ │ └── package.scala │ │ ├── smartcontracts │ │ └── package.scala │ │ └── util │ │ └── Random.scala ├── scalac │ └── src │ │ ├── it │ │ └── scala │ │ │ └── stainless │ │ │ ├── GhostRewriteSuite.scala │ │ │ ├── LibrarySuite.scala │ │ │ ├── ScalacExtractionSuite.scala │ │ │ ├── ScalacGhostChecks.scala │ │ │ ├── smartcontracts │ │ │ ├── SmartContractCompilationSuite.scala │ │ │ ├── SmartContractSuite.scala │ │ │ ├── SmartContractVerificationSuite.scala │ │ │ └── package.scala │ │ │ ├── termination │ │ │ └── TerminationSuite.scala │ │ │ └── verification │ │ │ ├── ImperativeSuite.scala │ │ │ ├── StrictArithmeticSuite.scala │ │ │ ├── TerminationVerificationSuite.scala │ │ │ ├── TypeCheckerSuite.scala │ │ │ ├── UncheckedSuite.scala │ │ │ └── VerificationSuite.scala │ │ └── main │ │ ├── resources │ │ └── scalac-plugin.xml │ │ └── scala │ │ └── stainless │ │ └── frontends │ │ └── scalac │ │ ├── ASTExtractors.scala │ │ ├── CodeExtraction.scala │ │ ├── FragmentChecker.scala │ │ ├── GhostAccessRewriter.scala │ │ ├── ScalaCompiler.scala │ │ ├── SimpleReporter.scala │ │ ├── StainlessExtraction.scala │ │ └── StainlessPlugin.scala └── stainless-dotty │ └── src │ ├── it │ └── scala │ │ └── stainless │ │ ├── DottyExtractionSuite.scala │ │ └── DottyVerificationSuite.scala │ └── main │ └── scala │ └── stainless │ └── frontends │ └── dotc │ ├── DottyCompiler.scala │ └── StainlessExtraction.scala ├── project ├── build.properties └── plugins.sbt ├── sbt-plugin ├── project │ └── build.properties └── src │ ├── main │ └── scala │ │ └── ch │ │ └── epfl │ │ └── lara │ │ └── sbt │ │ └── stainless │ │ └── StainlessPlugin.scala │ └── sbt-test │ └── sbt-plugin │ ├── ghost │ ├── actor-tests │ │ └── src │ │ │ └── main │ │ │ └── scala │ │ │ ├── Actors.scala │ │ │ └── Counter.scala │ ├── basic │ │ └── TestGhost1.scala │ ├── build.sbt │ ├── project │ │ ├── build.properties │ │ └── plugins.sbt │ └── test │ └── simple │ ├── build.sbt │ ├── disabled │ └── src │ │ └── main │ │ └── scala │ │ └── Extern1.scala │ ├── failure │ └── src │ │ └── main │ │ └── scala │ │ └── BadPre1.scala │ ├── project │ ├── TestPlugin.scala │ └── plugins.sbt │ ├── success │ └── src │ │ └── main │ │ └── scala │ │ ├── ADTInvariants1.scala │ │ └── Extern1.scala │ └── test ├── slc-lib ├── Booleans.v ├── CoqMakefile.conf ├── Ints.v ├── Lib.v ├── PropBool.v ├── Sets.v ├── Tactics.v ├── Unfolding.v ├── _CoqProject ├── configure └── obsolete │ └── stdppSets.v ├── stainless.conf.default └── unmanaged ├── scalaz3-mac-64-2.12.jar └── scalaz3-unix-64-2.12.jar /.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /.sbtopts: -------------------------------------------------------------------------------- 1 | -Dsbt.io.implicit.relative.glob.conversion=allow 2 | -J-Xss512M 3 | -J-Xms1024M 4 | -J-Xmx12G 5 | -J-XX:MaxMetaspaceSize=512M 6 | -J-XX:+UseCodeCacheFlushing 7 | -J-XX:ReservedCodeCacheSize=256M 8 | -------------------------------------------------------------------------------- /_CoqProject: -------------------------------------------------------------------------------- 1 | -R slc-lib SLC 2 | -------------------------------------------------------------------------------- /bin/bolts-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | TEST_DIR=$1 6 | echo "Moving to $TEST_DIR" 7 | mkdir -p "$TEST_DIR" 8 | cd "$TEST_DIR" || exit 1 9 | 10 | git clone https://github.com/epfl-lara/bolts 11 | 12 | cd bolts || exit 1 13 | 14 | bash ./run-tests.sh 15 | 16 | cd ../.. || true 17 | 18 | -------------------------------------------------------------------------------- /bin/build-slc-lib.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cd slc-lib 4 | ./configure 5 | make 6 | cd .. 7 | -------------------------------------------------------------------------------- /bin/nix-run: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | HERE="`dirname $0`" 4 | 5 | nix-shell $HERE/stainless.nix -A stainlessEnv 6 | -------------------------------------------------------------------------------- /bin/stainless.nix: -------------------------------------------------------------------------------- 1 | let 2 | pkgs = import {}; 3 | stdenv = pkgs.stdenv; 4 | in rec { 5 | stainlessEnv = stdenv.mkDerivation rec { 6 | name = "stainless-env"; 7 | shellHook = '' 8 | alias cls=clear 9 | ''; 10 | buildInputs = with pkgs; [ 11 | stdenv 12 | sbt 13 | openjdk 14 | z3 15 | ]; 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/scala/stainless/Options.scala: -------------------------------------------------------------------------------- 1 | package stainless 2 | 3 | import java.io.File 4 | import scala.util.Try 5 | import inox.OptionDef 6 | 7 | abstract class FileOptionDef extends OptionDef[File] { 8 | val parser = { 9 | case "" => None 10 | case "false" => None 11 | case path => Try(new File(path)).toOption 12 | } 13 | 14 | val usageRhs = "FILE" 15 | } 16 | -------------------------------------------------------------------------------- /core/src/main/scala/stainless/ast/Types.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | package stainless.ast 4 | 5 | trait Types extends inox.ast.Types { self: Trees => 6 | 7 | sealed case class ArrayType(base: Type) extends Type 8 | 9 | } 10 | -------------------------------------------------------------------------------- /core/src/main/scala/stainless/codegen/runtime/ADT.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | package stainless.codegen.runtime 4 | 5 | trait ADT { 6 | def __getRead(): Int 7 | 8 | def productElements(): Array[AnyRef] 9 | 10 | def productName(): String 11 | } 12 | -------------------------------------------------------------------------------- /core/src/main/scala/stainless/codegen/runtime/Exceptions.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | package stainless.codegen.runtime 4 | 5 | /** Such exceptions are thrown when the evaluator encounters a runtime error, 6 | * for instance `.get` with an undefined key on a map. */ 7 | class CodeGenRuntimeException(msg: String) extends Exception(msg) 8 | -------------------------------------------------------------------------------- /core/src/main/scala/stainless/codegen/runtime/Lambda.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | package stainless.codegen.runtime 4 | 5 | abstract class Lambda { 6 | def apply(args: Array[AnyRef]): AnyRef 7 | } 8 | -------------------------------------------------------------------------------- /core/src/main/scala/stainless/extraction/imperative/TypeOps.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | package stainless 4 | package extraction 5 | package imperative 6 | 7 | trait TypeOps extends oo.TypeOps { 8 | override protected val trees: Trees 9 | } 10 | 11 | -------------------------------------------------------------------------------- /core/src/main/scala/stainless/extraction/innerfuns/TypeOps.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | package stainless 4 | package extraction 5 | package innerfuns 6 | 7 | trait TypeOps extends ast.TypeOps { 8 | override protected val trees: Trees 9 | } 10 | -------------------------------------------------------------------------------- /core/src/main/scala/stainless/extraction/termination/.scalafmt.conf: -------------------------------------------------------------------------------- 1 | align = some 2 | maxColumn = 110 3 | -------------------------------------------------------------------------------- /core/src/sphinx/.gitignore: -------------------------------------------------------------------------------- 1 | _build 2 | -------------------------------------------------------------------------------- /core/src/sphinx/internals.rst: -------------------------------------------------------------------------------- 1 | .. _internals: 2 | 3 | Stainless' Internals 4 | ==================== 5 | 6 | The main component of Stainless and the dataflow in its pipeline: 7 | 8 | .. image:: static/images/pipeline.svg 9 | :width: 90% 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /core/src/sphinx/r: -------------------------------------------------------------------------------- 1 | make html 2 | -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/MaterialIcons-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/MaterialIcons-Regular.eot -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/MaterialIcons-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/MaterialIcons-Regular.ttf -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/MaterialIcons-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/MaterialIcons-Regular.woff -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/class_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/class_diagram.png -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/lato-v11-latin-100.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/lato-v11-latin-100.eot -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/lato-v11-latin-100.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/lato-v11-latin-100.ttf -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/lato-v11-latin-100.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/lato-v11-latin-100.woff -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/lato-v11-latin-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/lato-v11-latin-regular.eot -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/lato-v11-latin-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/lato-v11-latin-regular.ttf -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/lato-v11-latin-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/lato-v11-latin-regular.woff -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/object_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/object_diagram.png -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-400i.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-400i.eot -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-400i.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-400i.ttf -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-400i.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-400i.woff -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-700.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-700.eot -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-700.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-700.ttf -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-700.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-700.woff -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-700i.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-700i.eot -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-700i.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-700i.ttf -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-700i.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-700i.woff -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-regular.eot -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-regular.ttf -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/open-sans-v13-latin-regular.woff -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/ownderbg2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/ownderbg2.gif -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/ownerbg.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/ownerbg.gif -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/ownerbg2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/ownerbg2.gif -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/source-code-pro-v6-latin-700.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/source-code-pro-v6-latin-700.eot -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/source-code-pro-v6-latin-700.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/source-code-pro-v6-latin-700.ttf -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/source-code-pro-v6-latin-700.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/source-code-pro-v6-latin-700.woff -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/source-code-pro-v6-latin-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/source-code-pro-v6-latin-regular.eot -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/source-code-pro-v6-latin-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/source-code-pro-v6-latin-regular.ttf -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/source-code-pro-v6-latin-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/source-code-pro-v6-latin-regular.woff -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/trait_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/trait_diagram.png -------------------------------------------------------------------------------- /core/src/sphinx/static/stainless-library/lib/type_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/static/stainless-library/lib/type_diagram.png -------------------------------------------------------------------------------- /core/src/sphinx/themes/stanford_theme/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Stanford ReadTheDocs theme for Sphinx documentation generator. 3 | """ 4 | import os 5 | 6 | __version__ = '1.0' 7 | __version_full__ = __version__ 8 | 9 | 10 | def get_html_theme_path(): 11 | """Return list of HTML theme paths.""" 12 | cur_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) 13 | return cur_dir 14 | -------------------------------------------------------------------------------- /core/src/sphinx/themes/stanford_theme/static/css/copied_wy_variables.css: -------------------------------------------------------------------------------- 1 | 2 | 3 | /*# sourceMappingURL=copied_wy_variables.css.map */ 4 | -------------------------------------------------------------------------------- /core/src/sphinx/themes/stanford_theme/static/fonts/Inconsolata-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/themes/stanford_theme/static/fonts/Inconsolata-Bold.ttf -------------------------------------------------------------------------------- /core/src/sphinx/themes/stanford_theme/static/fonts/Inconsolata-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/themes/stanford_theme/static/fonts/Inconsolata-Regular.ttf -------------------------------------------------------------------------------- /core/src/sphinx/themes/stanford_theme/static/fonts/Lato-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/themes/stanford_theme/static/fonts/Lato-Bold.ttf -------------------------------------------------------------------------------- /core/src/sphinx/themes/stanford_theme/static/fonts/Lato-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/themes/stanford_theme/static/fonts/Lato-Regular.ttf -------------------------------------------------------------------------------- /core/src/sphinx/themes/stanford_theme/static/fonts/RobotoSlab-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/themes/stanford_theme/static/fonts/RobotoSlab-Bold.ttf -------------------------------------------------------------------------------- /core/src/sphinx/themes/stanford_theme/static/fonts/RobotoSlab-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/themes/stanford_theme/static/fonts/RobotoSlab-Regular.ttf -------------------------------------------------------------------------------- /core/src/sphinx/themes/stanford_theme/static/fonts/UbuntuMono-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/themes/stanford_theme/static/fonts/UbuntuMono-Bold.ttf -------------------------------------------------------------------------------- /core/src/sphinx/themes/stanford_theme/static/fonts/UbuntuMono-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/themes/stanford_theme/static/fonts/UbuntuMono-BoldItalic.ttf -------------------------------------------------------------------------------- /core/src/sphinx/themes/stanford_theme/static/fonts/UbuntuMono-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/themes/stanford_theme/static/fonts/UbuntuMono-Italic.ttf -------------------------------------------------------------------------------- /core/src/sphinx/themes/stanford_theme/static/fonts/UbuntuMono-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/themes/stanford_theme/static/fonts/UbuntuMono-Regular.ttf -------------------------------------------------------------------------------- /core/src/sphinx/themes/stanford_theme/static/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/themes/stanford_theme/static/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /core/src/sphinx/themes/stanford_theme/static/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/themes/stanford_theme/static/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /core/src/sphinx/themes/stanford_theme/static/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/core/src/sphinx/themes/stanford_theme/static/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /core/src/sphinx/themes/stanford_theme/theme.conf: -------------------------------------------------------------------------------- 1 | [theme] 2 | inherit = basic 3 | stylesheet = css/theme.css 4 | 5 | [options] 6 | typekit_id = hiw1hhg 7 | analytics_id = 8 | sticky_navigation = False 9 | logo_only = 10 | collapse_navigation = False 11 | display_version = True 12 | navigation_depth = 4 13 | prev_next_buttons_location = bottom 14 | -------------------------------------------------------------------------------- /frontends/algebra/src/main/stainless/algebra/Semigroup.scala: -------------------------------------------------------------------------------- 1 | package stainless.algebra 2 | 3 | import stainless.annotation._ 4 | 5 | @library 6 | abstract class Semigroup[A] { 7 | def combine(x: A, y: A): A 8 | 9 | @law 10 | def law_associativity(x: A, y: A, z: A): Boolean = { 11 | combine(combine(x, y), z) == combine(x, combine(y, z)) 12 | } 13 | } -------------------------------------------------------------------------------- /frontends/benchmarks/coq/.gitignore: -------------------------------------------------------------------------------- 1 | cache/ 2 | -------------------------------------------------------------------------------- /frontends/benchmarks/coq/AddingPositiveNumbers.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2016 EPFL, Lausanne */ 2 | 3 | object AddingPositiveNumbers { 4 | 5 | //this should not overflow 6 | def additionSound(x: BigInt, y: BigInt): BigInt = { 7 | require(x >= 0 && y >= 0) 8 | x + y 9 | } ensuring(_ >= 0) 10 | 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/coq/AdvArith.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2016 EPFL, Lausanne */ 2 | 3 | 4 | object AdvArithmetic { 5 | 6 | def test(a: BigInt, b: BigInt, c: BigInt): BigInt = { 7 | require(a > b && c > BigInt(0)) 8 | c * a 9 | } ensuring( _ > c * b ) 10 | 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/coq/Arith.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2016 EPFL, Lausanne */ 2 | 3 | 4 | object Arithmetic { 5 | 6 | def test(a: BigInt, b: BigInt, c: BigInt): BigInt = { 7 | require(a > b && c > BigInt(0)) 8 | c + a 9 | } ensuring( _ > c + b ) 10 | 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/coq/Fix.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object Fix { 4 | def myfix(i: BigInt, j: BigInt):BigInt = { 5 | require(i > 0) 6 | myfix(i+1, j+1) 7 | } ensuring(res => (res > 0)) 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/coq/Let.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2018 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object LetTest { 6 | def test(x:BigInt) = { 7 | require(x > 0) 8 | val i = x + 1 9 | i + x 10 | } ensuring { res => res > 1 } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/coq/ListExample.scala: -------------------------------------------------------------------------------- 1 | import stainless.collection._ 2 | 3 | object Example { 4 | def tails[T] (l: List[T]) : List[List[T]] = l match { 5 | case Cons(_, tl) => Cons(tl, tails(tl)) 6 | case Nil() => List(Nil()) 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/coq/MyTuple1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2016 EPFL, Lausanne */ 2 | 3 | object MyTuple1 { 4 | 5 | def foo(): BigInt = { 6 | val t = (BigInt(1), true, BigInt(3)) 7 | val a1 = t._1 8 | val a2 = t._2 9 | val a3 = t._3 10 | a3 11 | } ensuring( _ == 3) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/coq/MyTuple3.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2016 EPFL, Lausanne */ 2 | 3 | object MyTuple3 { 4 | 5 | def foo(): Int = { 6 | val t = ((2, 3), true) 7 | t._1._2 8 | } ensuring( _ == 3) 9 | 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/coq/MyTuple6.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2016 EPFL, Lausanne */ 2 | 3 | object MyTuple6 { 4 | 5 | def foo(t: (Int, Int)): (Int, Int) = { 6 | require(t._1 > 0 && t._2 > 1) 7 | t 8 | } ensuring(res => res._1 > 0 && res._2 > 1) 9 | 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/coq/Not.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object Test { 4 | 5 | def f(x: Boolean) = { 6 | require(x) 7 | !x 8 | } ensuring (y => !y) 9 | } -------------------------------------------------------------------------------- /frontends/benchmarks/coq/wip/ADTInvariants1.scala: -------------------------------------------------------------------------------- 1 | 2 | object ADTInvariants1 { 3 | 4 | case class Positive(i: BigInt) { 5 | require(i > 0) 6 | } 7 | 8 | def theorem(f: Positive => Positive) = { 9 | f(Positive(1)) 10 | } ensuring(res => res.i > 0) 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/coq/wip/Anonymous.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2016 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Anonymous { 6 | def test(x: BigInt) = { 7 | require(x > 0) 8 | val i = (a: BigInt) => a + 1 9 | i(x) + i(2) 10 | } ensuring { res => res > 0 } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/coq/wip/Matching.scala: -------------------------------------------------------------------------------- 1 | object Matching { 2 | 3 | sealed abstract class X 4 | case class A() extends X 5 | case class B() extends X 6 | 7 | def theorem(x: X) = x match { 8 | case A() => assert(x == A()) 9 | case B() => assert(x == A()) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/coq/wip/MyTuple2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2016 EPFL, Lausanne */ 2 | 3 | object MyTuple2 { 4 | 5 | sealed abstract class A 6 | case class B(i: Int) extends A 7 | case class C(a: A) extends A 8 | 9 | def foo(): Int = { 10 | val t = (B(2), C(B(3))) 11 | t match { 12 | case (B(x), C(y)) => x 13 | } 14 | } ensuring(_ == 2) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/coq/wip/MyTuple4.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2016 EPFL, Lausanne */ 2 | 3 | 4 | object MyTuple4 { 5 | 6 | sealed abstract class A 7 | case class B(i: Int) extends A 8 | case class C(a: A) extends A 9 | 10 | def foo(): Int = { 11 | val t = (1, (C(B(4)), 2), 3) 12 | val (a1, (C(B(x)), a2), a3) = t 13 | x 14 | } ensuring( _ == 4) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/dotty-specific/unchecked/Enums1.scala: -------------------------------------------------------------------------------- 1 | 2 | import stainless.lang._ 3 | 4 | object Enums1 { 5 | 6 | enum Color { 7 | case Red, Green, Blue 8 | } 9 | 10 | def test(c: Color) = { 11 | assert(c == Color.Red || c == Color.Green || c == Color.Blue) 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/dotty-specific/unchecked/Enums2.scala: -------------------------------------------------------------------------------- 1 | 2 | import stainless.lang._ 3 | 4 | object Enums1 { 5 | 6 | enum Option[+T] { 7 | case Some(x: T) extends Option[T] 8 | case None extends Option[Nothing] 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/dotty-specific/unchecked/ErasedTerms2.scala: -------------------------------------------------------------------------------- 1 | 2 | import stainless.lang._ 3 | import stainless.annotation.ghost 4 | 5 | object ErasedTerms2 { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /frontends/benchmarks/dotty-specific/valid/ExtensionMethods1.scala: -------------------------------------------------------------------------------- 1 | 2 | import stainless.lang._ 3 | 4 | object ExtensionMethods1 { 5 | 6 | case class Rectangle(x: BigInt, y: BigInt) 7 | 8 | def (r: Rectangle) perimeter: BigInt = r.x * 2 + r.y * 2 9 | 10 | def test = { 11 | val rectangle = Rectangle(10, 20) 12 | assert(rectangle.perimeter == 60) 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/dotty-specific/valid/IdentityRefinement.scala: -------------------------------------------------------------------------------- 1 | 2 | object IdentityRefinement { 3 | type Neg = { x: Int => x < 0 } 4 | 5 | def id[T](x: T): T = x 6 | 7 | def f() = id[{x: Int => x > 0}](1) + id[Neg](-1) 8 | } 9 | 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/dotty-specific/valid/PositiveInt.scala: -------------------------------------------------------------------------------- 1 | 2 | import stainless.lang._ 3 | 4 | object PositiveInt { 5 | 6 | case class Foo(n: { m: Int => m > 0 }) { 7 | def bar: Int = n 8 | } 9 | 10 | def test(foo: Foo) = { 11 | assert(foo.bar > 0) 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/dotty-specific/valid/SortedListHead.scala: -------------------------------------------------------------------------------- 1 | import scala.language.implicitConversions 2 | 3 | import stainless.lang._ 4 | import stainless.collection._ 5 | 6 | object SortedListHead { 7 | 8 | def foo(list: { l: List[BigInt] => ListOps.isSorted(l) && l.length > BigInt(2) }) 9 | : { res: (BigInt, BigInt) => res._1 <= res._2 } = { 10 | (list.head, list.tail.head) 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/AnonymousClassRefine.scala: -------------------------------------------------------------------------------- 1 | 2 | import stainless.lang._ 3 | 4 | object AnonymousClassesRefine { 5 | 6 | abstract class Foo { 7 | def bar: Int 8 | } 9 | 10 | def stuff: Boolean = { 11 | val foo = new Foo { 12 | def bar: Int = 1 13 | val baz: Boolean = true 14 | } 15 | 16 | foo.baz 17 | }.holds 18 | 19 | } 20 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/BadOverride1.scala: -------------------------------------------------------------------------------- 1 | object BadOverride1 { 2 | sealed abstract class Abs { 3 | require(x != 0) 4 | val x: Int 5 | } 6 | case class AbsInvalid() extends Abs { 7 | def x: Int = 1 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/BadOverride2.scala: -------------------------------------------------------------------------------- 1 | object BadOverride2 { 2 | sealed abstract class Abs { 3 | val y: Int 4 | } 5 | case class AbsInvalid() extends Abs { 6 | val y: Int = 2 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/BadOverride3.scala: -------------------------------------------------------------------------------- 1 | object BadOverride3 { 2 | sealed abstract class AAA { 3 | def f: BigInt 4 | } 5 | 6 | case class BBB() extends AAA { 7 | val f: BigInt = 0 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/BadPre1.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | import stainless.lang._ 3 | 4 | object BadPre1 { 5 | def reqreq(x: BigInt, y: BigInt): BigInt = { 6 | require(x > 0) 7 | require(y > 0) // should be rejected 8 | x + y 9 | } ensuring { _ > 0 } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/BadPre2.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | import stainless.lang._ 3 | 4 | object BadPre2 { 5 | def decreq(x: BigInt): BigInt = { 6 | decreases(x) 7 | require(x >= 0) // should be rejected 8 | if (x == 0) BigInt(0) else decreq(x - x) 9 | } ensuring { _ == 0 } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/BadPre3.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | import stainless.lang._ 3 | 4 | object BadPre3 { 5 | def reqfooreq(x: BigInt): BigInt = { 6 | require(x > 0) 7 | x + 1 8 | require(x < 0) // should be rejected 9 | assert(false) 10 | x 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/BadPre4.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | import stainless.lang._ 3 | 4 | object BadPre4 { 5 | def decreq(x: BigInt): BigInt = { 6 | decreases(x) 7 | decreases(x + 1) // should be rejected 8 | if (x == 0) BigInt(0) else decreq(x - x) 9 | } ensuring { _ == 0 } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/BadPre5.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | import stainless.lang._ 3 | 4 | object BadPre5 { 5 | def lambda(x: BigInt): BigInt = { 6 | 7 | val f: BigInt => BigInt = { y => 8 | require(x > y) 9 | require(x > y) // should be rejected 10 | y 11 | } 12 | 13 | f(x / 2) 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/BadPre6.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | import stainless.lang._ 3 | 4 | object BadPre6 { 5 | def outer(x: BigInt): BigInt = { 6 | 7 | def inner(y: BigInt): BigInt = { 8 | require(x > y) 9 | require(x > y) // should be rejected 10 | y 11 | } 12 | 13 | inner(x / 2) 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/BadPre7.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | import stainless.lang._ 3 | 4 | object BadPre7 { 5 | 6 | case class C(x: BigInt) { 7 | def method: BigInt = { 8 | require(x > 0) 9 | require(x > 0) // should be rejected 10 | x 11 | } 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/ClassBody.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | object Top { 4 | "abcdef" // not allowed here 5 | 6 | def bar(x: Int): Unit = () 7 | 8 | bar(42) // not allowed here 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/CopyMut.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object CopyMut { 4 | 5 | case class Toto(var x: Int) 6 | 7 | case class Foo(bar: Int, var toto: Toto) { 8 | def double: Foo = this.copy(bar = bar * 2) 9 | } 10 | 11 | def prop = (Foo(41, Toto(1)).double.bar == 84).holds 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/CtorParams.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | //constructor parameters are not allowed 4 | abstract class MyClass(x: String) { 5 | } 6 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/EffectfulVal.scala: -------------------------------------------------------------------------------- 1 | 2 | object EffectfulVal { 3 | 4 | import stainless.util.Random 5 | 6 | case class Test(state: Random.State) { 7 | val rand = Random.nextBigInt(state) 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/ExtendNonMutable.scala: -------------------------------------------------------------------------------- 1 | // A should be annotated with @mutable 2 | trait A 3 | 4 | case class B(var x: BigInt) extends A { 5 | def f() = () 6 | } -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/GhostEffect1.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | import stainless.annotation._ 3 | 4 | object GhostEffect1 { 5 | 6 | import stainless.util.Random 7 | 8 | case class App(state: Random.State) { 9 | def doStuff(@ghost ignoreMe: BigInt): BigInt = { 10 | Random.nextBigInt(state) 11 | } 12 | 13 | def foo = doStuff(Random.nextBigInt(state)) 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/GhostEffect2.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | import stainless.annotation._ 3 | 4 | object GhostEffect2 { 5 | 6 | import stainless.util.Random 7 | 8 | def bar(implicit state: Random.State) = { 9 | @ghost val test = Random.nextBigInt 10 | () 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/GhostEffect3.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | import stainless.annotation._ 3 | 4 | object GhostEffect3 { 5 | 6 | import stainless.util.Random 7 | 8 | case class Foo(@ghost value: BigInt) 9 | 10 | def bar: Foo = { 11 | implicit val state = Random.newState 12 | Foo(Random.nextBigInt(state)) 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/ImpureLazy.scala: -------------------------------------------------------------------------------- 1 | object ImpureLazy { 2 | def f() = { 3 | var x = 0 4 | lazy val hello = { x = x + 1 } 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/ImpureLazy2.scala: -------------------------------------------------------------------------------- 1 | object ImpureLazy2 { 2 | def f(): Int = { 3 | var counter = 0 4 | lazy val x = { 5 | counter = counter + 1 6 | counter 7 | } 8 | counter + x + x 9 | } ensuring (_ == 2) 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/Initialization1.scala: -------------------------------------------------------------------------------- 1 | object Initialization1 { 2 | case class InitA() { 3 | val x = y 4 | val y = 0 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/Initialization2.scala: -------------------------------------------------------------------------------- 1 | object Initialization2 { 2 | case class Hello() { 3 | val message = answer + 3 4 | val answer = 42 5 | } 6 | def getM: Int = { 7 | new Hello().message 8 | } ensuring (_ == 45) 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/Initialization3.scala: -------------------------------------------------------------------------------- 1 | object Initialization3 { 2 | case class NoThis() { 3 | val nothis: Boolean = h() 4 | 5 | def f(): NoThis = this 6 | def h(): Boolean = f().nothis 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/Initialization4.scala: -------------------------------------------------------------------------------- 1 | object Initialization4 { 2 | case class NoThis() { 3 | val nothis = f() 4 | val g = 1 5 | 6 | def f() = this.g 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/Initialization5.scala: -------------------------------------------------------------------------------- 1 | object Initialization5 { 2 | case class NoThis() { 3 | val nothis1 = f() 4 | val nothis2 = 0 5 | 6 | def f() = g(this) 7 | def g(nt: NoThis) = nt.nothis2 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/InnerClass.scala: -------------------------------------------------------------------------------- 1 | 2 | object InnerClass { 3 | 4 | trait TraitOuter { 5 | case class TraitInner() 6 | } 7 | 8 | abstract class ClassOuter { 9 | case class ClassInner() 10 | } 11 | 12 | case class CaseOuter() { 13 | case class CaseInner() 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/InnerClassCloseMut.scala: -------------------------------------------------------------------------------- 1 | 2 | object InnerClassCloseMut { 3 | 4 | abstract class Test { 5 | def foo: Int 6 | } 7 | 8 | def test: Int = { 9 | var x: Int = 1 10 | 11 | case class Wrong() extends Test { 12 | def foo = { 13 | x = x + 1 14 | x 15 | } 16 | } 17 | 18 | Wrong().foo 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/InnerClassFunClosure.scala: -------------------------------------------------------------------------------- 1 | 2 | object InnerClassFunClosure { 3 | 4 | abstract class Foo { 5 | def bar: Int 6 | } 7 | 8 | def mkFoo(n: Int) = { 9 | def go(x: Int): Int = { 10 | x + n 11 | } 12 | 13 | new Foo { 14 | def bar = go(100) 15 | } 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/IntToBigInt.scala: -------------------------------------------------------------------------------- 1 | object IntToBigInt { 2 | def f(i: BigInt) = i 3 | def g(i: Int) = f(i) 4 | } 5 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/IntToBigInt2.scala: -------------------------------------------------------------------------------- 1 | object IntToBigInt2 { 2 | def g(i: Int) = BigInt(i) 3 | } 4 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/LambdaMutation.scala: -------------------------------------------------------------------------------- 1 | object LambdaMutation { 2 | def f() = { 3 | var x = 0 4 | val g = () => { x = x + 1 } 5 | g() 6 | assert(x == 1) 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/List1.scala: -------------------------------------------------------------------------------- 1 | //no import of stainless.collection.List 2 | 3 | object List1 { 4 | def foobar[T](l: List[T]) = { 5 | require(l.size > 0) 6 | l.head 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/List2.scala: -------------------------------------------------------------------------------- 1 | //no import of stainless.collection.List 2 | 3 | object List2 { 4 | def foobar = Nil 5 | } 6 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/List3.scala: -------------------------------------------------------------------------------- 1 | //no import of stainless.collection.List 2 | 3 | object List3 { 4 | def foobar = 1 :: Nil 5 | } 6 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/List4.scala: -------------------------------------------------------------------------------- 1 | //no import of stainless.collection.List 2 | 3 | object List4 { 4 | def foobar = List(1, 2) 5 | } 6 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/MultipleInheritance.scala: -------------------------------------------------------------------------------- 1 | 2 | import stainless.lang._ 3 | import stainless.annotation._ 4 | 5 | object MultipleInheritance { 6 | 7 | trait Foo1 8 | trait Foo2 9 | case class Bar() extends Foo1 with Foo2 10 | 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/MutableMapUpdated.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object MutableMapUpdated { 4 | case class A(var x: BigInt) 5 | 6 | def f(m: MutableMap[BigInt,A], a: A) = { 7 | // not allowed due to the creation of aliases between `m` and the result 8 | val u = m.updated(0, a) 9 | () 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/MutateOld.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object BreakImperative { 4 | case class Toto(var x: BigInt) { 5 | def inc(): Unit = { 6 | x += 1 7 | } ensuring { _ => 8 | old(this).x += 1 9 | old(this).x == x 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/NonMutableFunTypeParameter.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | 3 | object NonMutableFunTypeParameter { 4 | def f[T](t: T) = t 5 | 6 | @mutable 7 | trait A 8 | 9 | // cannot instantiate f[T] with mutable type A 10 | def g(a: A) = f(a) 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/NonMutableTypeParameter.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | 3 | trait NonMutableTypeParameters[X,Y] 4 | trait MutableTypeParameter[@mutable X] extends NonMutableTypeParameters[X, X] { 5 | def f() = () 6 | } 7 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/ObjectParent1.scala: -------------------------------------------------------------------------------- 1 | 2 | object ObjectParent1 { 3 | abstract class Foo 4 | object bar extends Foo 5 | } 6 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/ObjectParent2.scala: -------------------------------------------------------------------------------- 1 | 2 | object ObjectParent2 { 3 | trait Foo 4 | object bar extends Foo 5 | } 6 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/OldInBody.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object Main { 4 | def f(thiss: A, oldThiss: A) = thiss != oldThiss 5 | case class A(var s: BigInt) { 6 | def g() = { 7 | s = s + 1 8 | assert(f(this, old(this))) 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/OldInMeasure.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object OldInMeasure { 4 | def f(x: Int): Int = { 5 | decreases(old(x)) 6 | x 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/OldInPre.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object OldInPre { 4 | def f(x: Int): Int = { 5 | require(old(x) == x) 6 | x 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/Println.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | sealed abstract class Foo { 4 | def foo(): Unit = println("a") 5 | } 6 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/Require.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | object Require { 4 | require(1 > 0) // not allowed inside objects 5 | } 6 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/SuperAbstract.scala: -------------------------------------------------------------------------------- 1 | 2 | object SuperAbstract { 3 | 4 | sealed abstract class A { 5 | def hello: BigInt 6 | } 7 | 8 | case class B() extends A { 9 | override def hello = super.hello + 1 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/invalid/TraitVarDefault.scala: -------------------------------------------------------------------------------- 1 | object Imperative { 2 | trait Box { 3 | var v = BigInt(0) 4 | def load(x: BigInt) = { 5 | v = x 6 | } 7 | } 8 | 9 | case class A(var f: BigInt) 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/AccessorFlags.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | 3 | trait AccessorFlags { 4 | @ghost var x: BigInt 5 | } 6 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/BlockInPost.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | import stainless.proof._ 3 | 4 | object Foo { 5 | def foo(): Boolean = { 6 | true 7 | }.holds { 8 | check(1 == 1) 9 | true 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/CaseObject.scala: -------------------------------------------------------------------------------- 1 | object CaseObject { 2 | case class S() 3 | 4 | abstract class A 5 | case object Main extends A { 6 | val s: S = S() 7 | 8 | def f(x: S): S = x match { 9 | case S() => S() 10 | case _ => s 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/CaseObject2.scala: -------------------------------------------------------------------------------- 1 | abstract class CaseObjectA 2 | case object CaseObjectC extends CaseObjectA 3 | 4 | object CaseObjectMain { 5 | def f(): CaseObjectA = CaseObjectC 6 | } 7 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/CaseObjectSuper.scala: -------------------------------------------------------------------------------- 1 | 2 | object CaseObjectSuper { 3 | 4 | abstract class SomeSuperClass { 5 | def anInteger: Int = 40 6 | } 7 | 8 | case object SomeCaseObject extends SomeSuperClass { 9 | override def anInteger: Int = super.anInteger + 2 10 | } 11 | 12 | def someTest = { 13 | assert(SomeCaseObject.anInteger == 42) 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/CaseObjectTypeMember.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | trait One { 4 | type T 5 | def f(): Option[T] 6 | } 7 | 8 | case object OneImpl extends One { 9 | type T = BigInt 10 | def f(): Option[T] = None() 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/ClassBody.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | abstract class Top { 4 | require(1 > 0) 5 | 6 | def bar(x: Int): Unit = () 7 | } 8 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/ConstructorArgsBoxing1.bak: -------------------------------------------------------------------------------- 1 | 2 | import stainless.lang._ 3 | import stainless.collection._ 4 | 5 | object ConstructorArgsBoxing1 { 6 | case class A() 7 | 8 | sealed abstract class AnyFoo 9 | case class Foo[T](x: T) extends AnyFoo 10 | 11 | val a: AnyFoo = Foo(A()) 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/ConstructorArgsBoxing2.bak: -------------------------------------------------------------------------------- 1 | 2 | import stainless.lang._ 3 | import stainless.collection._ 4 | 5 | object ConstructorArgsBoxing2 { 6 | case class A() 7 | case class B() 8 | 9 | sealed abstract class AnyFoo 10 | case class Foo[T](x: T) extends AnyFoo 11 | 12 | val a: AnyFoo = Foo(A()) 13 | val b: AnyFoo = Foo(B()) 14 | 15 | val list0: List[AnyFoo] = List(a, b) 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/Copy.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object Copy { 4 | 5 | case class Foo(bar: Int, var toto: Boolean) { 6 | def double: Foo = this.copy(bar = bar * 2) 7 | } 8 | 9 | def prop = (Foo(41, true).double.bar == 82).holds 10 | 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/DefaultParam.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object DefaultParam { 4 | 5 | case class Foo(bar: Int, var toto: Boolean) { 6 | def plus(x: Int = 1): Foo = Foo(bar + x, true) 7 | } 8 | 9 | def abc = (Foo(41, true).plus().bar == 42).holds 10 | 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/Extraction1.scala: -------------------------------------------------------------------------------- 1 | import stainless.collection._ 2 | import stainless.lang._ 3 | 4 | object Extraction1 { 5 | 6 | def wrongTheorem[A](l: List[A], x: A): Boolean = { 7 | l.content == l.content - x 8 | }.holds 9 | 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/Extraction2.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object Extraction2 { 4 | 5 | def test[T](p: T => Boolean): Boolean = { 6 | forall (p) 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/Extraction3.scala: -------------------------------------------------------------------------------- 1 | 2 | object Extraction3 { 3 | def f() = { 4 | assert(true) 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/Extraction4.scala: -------------------------------------------------------------------------------- 1 | 2 | object Extraction4 { 3 | 4 | trait NoCtor[A] 5 | 6 | } 7 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/GhostCheckerNoneGet.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | 3 | trait GhostCheckerNoneGet { 4 | @ghost 5 | var x: BigInt 6 | 7 | @ghost 8 | final def increment() = { 9 | x = x + 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/GhostEffect2.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | import stainless.annotation._ 3 | 4 | object GhostEffect2 { 5 | 6 | import stainless.util.Random 7 | 8 | def bar(implicit state: Random.State) = { 9 | val rand = Random.nextBigInt 10 | @ghost val test = rand + 1 11 | () 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/GhostEffect3.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | import stainless.annotation._ 3 | 4 | object GhostEffect3 { 5 | 6 | import stainless.util.Random 7 | 8 | case class Foo(@ghost value: BigInt) 9 | 10 | def bar: Foo = { 11 | implicit val state = Random.newState 12 | val rand = Random.nextBigInt(state) 13 | Foo(rand) 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/GhostFlow1.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | import stainless.lang._ 3 | import stainless.collection._ 4 | 5 | object GhostFlow1 { 6 | case class Ghost(@ghost var p: BigInt) { 7 | def f(x: BigInt) = { 8 | ghost { 9 | p = p + 1 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/GhostFlow3.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | import stainless.annotation._ 3 | 4 | object GhostFlow3 { 5 | case class Ghost(@ghost var x: BigInt) { 6 | @ghost 7 | def f() = { 8 | val y = x // Right-hand side of non-ghost variable cannot be ghost 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/GhostLet.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | import stainless.lang.StaticChecks._ 3 | 4 | object GhostLet { 5 | case class A() { 6 | def |:(x: Int): Boolean = true 7 | } 8 | 9 | object A { 10 | def f(@ghost x: Int, e: A) = assert(x |: e) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/HighLow.scala: -------------------------------------------------------------------------------- 1 | abstract class High[A] { 2 | def zero: A // works if commented 3 | } 4 | 5 | abstract class Mid[A] extends High[A] { 6 | def one: A 7 | } 8 | 9 | case class Low() extends Mid[BigInt] { 10 | override def zero: BigInt = 0 // works if commented 11 | override def one: BigInt = 1 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/ImplicitInlining.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object ImplicitInline { 4 | implicit class BD(val underlying: Boolean) { 5 | def f(): Unit = () 6 | } 7 | 8 | @inline 9 | def inlinedFunction() = true.f() 10 | 11 | def caller() = inlinedFunction() 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/InnerClassTypeMember.scala: -------------------------------------------------------------------------------- 1 | 2 | object InnerClassTypeMember { 3 | 4 | abstract class Foo { 5 | type Bar 6 | def baz(b: BigInt): Bar 7 | } 8 | 9 | def foo: Foo = { 10 | case class LocalFoo() extends Foo { 11 | type Bar = BigInt 12 | def baz(b: BigInt): Bar = b + 41 13 | } 14 | LocalFoo() 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/MethodInCaseObject.scala: -------------------------------------------------------------------------------- 1 | object MethodInCaseObject { 2 | case object O { 3 | def m() = () 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/MethodsCasts.scala: -------------------------------------------------------------------------------- 1 | object bug { 2 | 3 | abstract class Cap[S] { 4 | def init: Fig[Unit, S] 5 | } 6 | 7 | case class Foo() 8 | case class Fig[A, B]() 9 | 10 | case object Tak extends Cap[Foo] { 11 | def init: Fig[Unit, Foo] = Fig[Unit, Foo]() 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/MutableTypeParameter.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | 3 | @mutable 4 | trait MutableTypeParameters[@mutable X,Y] 5 | trait NonMutableTypeParameter[X] extends MutableTypeParameters[X, X] { 6 | def f() = () 7 | } 8 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/NonGhostUpdate.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | 3 | object NonGhostUpdate { 4 | case class C( 5 | @ghost a: BigInt, 6 | b: BigInt, 7 | @ghost c: BigInt, 8 | d: BigInt, 9 | @ghost e: BigInt 10 | ) 11 | 12 | def nonGhostUpdate(c: C): C = { 13 | c.copy(d = 0) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/OldInPost.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object Main { 4 | case class A(var x: BigInt) 5 | 6 | def f(a: A): BigInt = { 7 | a.x = a.x + 1 8 | a.x 9 | } ensuring (_ > old(a).x) 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/PairBound.scala: -------------------------------------------------------------------------------- 1 | object PairBound { 2 | case class Pair[A](x: A, y: A) 3 | 4 | def makePair1[A, B >: A](x: A, y: B): Pair[B] = { 5 | Pair[B](x, y) 6 | } 7 | 8 | def makePair2[B, A <: B](x: A, y: B): Pair[B] = { 9 | Pair[B](x, y) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/PreInferrence.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object PreInferrence { 4 | def isForall(b: Boolean): (Boolean => Boolean) => Boolean = { 5 | (p: Boolean => Boolean) => b == forall(p) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/RefinedInnerImperative.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | 3 | object RefinedInnerImperative { 4 | 5 | @mutable 6 | trait A 7 | 8 | case class Counter(var x: BigInt) { 9 | def reset() = x = 0 10 | } 11 | 12 | case class B(val c: Counter) extends A { 13 | def f() = { 14 | while(true) { 15 | c.reset() 16 | } 17 | } 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/StaticDefaultGetter.scala: -------------------------------------------------------------------------------- 1 | object StaticDefaultGetter { 2 | 3 | def foo(x: Boolean = true): Boolean = x 4 | 5 | def bar(): Unit = { 6 | require(foo()) 7 | () 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/SuperCall.scala: -------------------------------------------------------------------------------- 1 | 2 | import stainless.lang._ 3 | 4 | object SuperCall { 5 | 6 | sealed abstract class Base { 7 | def method(x: BigInt): BigInt = x 8 | } 9 | 10 | case class Override() extends Base { 11 | override def method(x: BigInt): BigInt = { 12 | super.method(x) + 1 13 | } 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/ToString.scala: -------------------------------------------------------------------------------- 1 | object ToString { 2 | abstract class A { 3 | def toString: String 4 | def fooBar: Int 5 | } 6 | 7 | case class C(s: String) extends A { 8 | override def toString: String = s 9 | override def fooBar: Int = 42 10 | } 11 | 12 | case class Auto(s: String) { 13 | override def toString: String = s 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/TupleSelect.scala: -------------------------------------------------------------------------------- 1 | 2 | case class Pair(_1: BigInt, _2: BigInt, _3: BigInt) 3 | 4 | object test { 5 | 6 | def prop = { 7 | val p = Pair(1, 2, 3) 8 | assert(p._1 == 1) 9 | assert(p._2 == 2) 10 | assert(p._3 == 3) 11 | 12 | val q = (1, 2, 3) 13 | assert(q._1 == 1) 14 | assert(q._2 == 2) 15 | assert(q._3 == 3) 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/TypeMembers0.scala: -------------------------------------------------------------------------------- 1 | 2 | object TypeMembers0 { 3 | 4 | sealed abstract class Foo { 5 | type Bar 6 | def x: Bar 7 | } 8 | 9 | case class SomeFoo() extends Foo { 10 | type Bar = Int 11 | def x: Bar = 42 12 | } 13 | 14 | def test(sf: SomeFoo) = { 15 | assert(sf.x == 42) 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/TypeMembers1.scala: -------------------------------------------------------------------------------- 1 | 2 | object TypeMembers1 { 3 | 4 | abstract class Foo { 5 | type Bar 6 | def x: Bar 7 | } 8 | 9 | case class SomeFoo() extends Foo { 10 | type Bar = Int 11 | def x: Int = 42 12 | } 13 | 14 | def test(sf: SomeFoo) = { 15 | assert(sf.x == 42) 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/TypeMembers5.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object TypeMembers5 { 4 | 5 | type Env = String => Option[Int] 6 | 7 | def update(env: Env, s: String, v: Int): Env = { 8 | (s1: String) => if (s1 == s) Some(v) else env(s1) 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/TypeParams1.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | object TypeParams1 { 4 | sealed abstract class Base[T] 5 | case class Bar() extends Base[Int] 6 | } 7 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/TypeParams2.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object TypeParams2 { 4 | abstract class Test[A] { 5 | def something: A 6 | } 7 | 8 | case class FooBar[B, C](b: B, c: C) extends Test[B] { 9 | def something: B = b 10 | } 11 | 12 | def test = { 13 | FooBar(true, 42).something == true 14 | }.holds 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/UnitIfExpr.scala: -------------------------------------------------------------------------------- 1 | 2 | object UnitIfExpr { 3 | 4 | case class Wrap[A,B](f: A => B) { 5 | def apply(k: A): B = { 6 | f(k) 7 | } 8 | } 9 | 10 | def untyped(f: Wrap[BigInt,BigInt]): Unit = { 11 | if (f(0) < 0) { 12 | f(0) 13 | } 14 | 15 | f(0) 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /frontends/benchmarks/extraction/valid/Variance.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | // covariant is disallowed 4 | abstract class Variance1[+T] 5 | 6 | // contravariance is disallowed 7 | abstract class Variance2[-T] 8 | 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/invalid/Array1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Array1 { 4 | 5 | def foo(): Int = { 6 | val a = Array.fill(5)(0) 7 | a(2) = 3 8 | a(2) 9 | } ensuring(_ == 0) 10 | 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/invalid/Array2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Array2 { 4 | 5 | def foo(): Int = { 6 | val a = Array.fill(5)(0) 7 | a(2) = 3 8 | a.length 9 | } ensuring(_ == 4) 10 | 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/invalid/Assert1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | /* Copyright 2009-2019 EPFL, Lausanne */ 4 | 5 | object Assert1 { 6 | 7 | def foo(): Int = { 8 | var a = 0 9 | a += 1 10 | assert(a == 0) 11 | a 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/invalid/Assert2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Assert2 { 4 | 5 | def foo(): Int = { 6 | var a = 0 7 | assert(a == 1) 8 | a += 1 9 | a 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/invalid/Asserts2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.annotation._ 4 | import stainless.lang._ 5 | 6 | object Asserts2 { 7 | 8 | def assert1(i: BigInt): BigInt = { // we might define assert like so 9 | require(i >= 0) 10 | i 11 | } 12 | 13 | def sum(to: BigInt): BigInt = { 14 | assert1(to) 15 | to 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/invalid/HiddenEffect.scala: -------------------------------------------------------------------------------- 1 | trait HiddenEffect { 2 | var x: BigInt 3 | 4 | def f(): BigInt 5 | 6 | def g() = { 7 | val x0 = x 8 | f() 9 | assert(x == x0) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/invalid/IfExpr1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object IfExpr1 { 4 | 5 | def foo(): Int = { 6 | var a = 1 7 | var b = 2 8 | if({a = a + 1; a != b}) 9 | a = a + 3 10 | else 11 | b = a + b 12 | a 13 | } ensuring(_ == 3) 14 | 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/invalid/IfExpr2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object IfExpr2 { 4 | 5 | def foo(): Int = { 6 | var a = 1 7 | var b = 2 8 | if(a < b) { 9 | a = a + 3 10 | b = b + 2 11 | a = a + b 12 | } 13 | a 14 | } ensuring(_ == 0) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/invalid/ImpureMethods.scala: -------------------------------------------------------------------------------- 1 | trait ImpureMethods { 2 | var x: BigInt 3 | 4 | def f(): BigInt 5 | 6 | def g() = { 7 | val a = f() 8 | val b = f() 9 | assert(a == b) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/invalid/StdIn1.scala: -------------------------------------------------------------------------------- 1 | import stainless.io._ 2 | 3 | object StdIn1 { 4 | 5 | def alwaysPos: Int = { 6 | implicit val state = stainless.io.newState 7 | StdIn.readInt 8 | } ensuring(_ >= 0) 9 | 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/invalid/StdIn2.scala: -------------------------------------------------------------------------------- 1 | import stainless.io._ 2 | 3 | object StdIn2 { 4 | 5 | def anyTwoNumbers: Boolean = { 6 | implicit val state = stainless.io.newState 7 | val n1 = StdIn.readInt 8 | val n2 = StdIn.readInt 9 | 10 | n1 == n2 11 | } ensuring(res => res) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/invalid/StdIn3.scala: -------------------------------------------------------------------------------- 1 | import stainless.io._ 2 | 3 | object StdIn3 { 4 | 5 | //should be invalid because of MinInt 6 | def abs: Int = { 7 | implicit val state = stainless.io.newState 8 | val n = StdIn.readInt 9 | if(n < 0) -n else n 10 | } ensuring(_ >= 0) 11 | 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/invalid/StdIn4.scala: -------------------------------------------------------------------------------- 1 | import stainless.io._ 2 | 3 | object StdIn4 { 4 | 5 | def readBoolCanBeFalse: Boolean = { 6 | implicit val state = stainless.io.newState 7 | StdIn.readBoolean 8 | } ensuring(res => res) 9 | 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/ADTWithArray1.scala: -------------------------------------------------------------------------------- 1 | object ADTWithArray1 { 2 | 3 | case class A(a: Array[Int]) 4 | 5 | def foo(a: A): Unit = { 6 | require(a.a.length > 0) 7 | a.a(0) = 10 8 | } 9 | 10 | def test(): Int = { 11 | val a = A(Array(1,2,3)) 12 | foo(a) 13 | a.a(0) 14 | } ensuring(_ == 10) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/ADTWithArray2.scala: -------------------------------------------------------------------------------- 1 | object ADTWithArray2 { 2 | 3 | case class A(a: Array[Int], size: Int) 4 | 5 | def foo(a: A): Unit = { 6 | require(a.a.length > 0 && a.a.length == a.size) 7 | a.a(0) = 10 8 | } 9 | 10 | def test(): Int = { 11 | val a = A(Array(1,2,3), 3) 12 | foo(a) 13 | a.a(0) 14 | } ensuring(_ == 10) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/ADTWithArray3.scala: -------------------------------------------------------------------------------- 1 | object ADTWithArray3 { 2 | 3 | case class A(var x: Int) 4 | case class B(a: Array[A]) 5 | 6 | def foo(b: B): Unit = { 7 | require(b.a.length > 0) 8 | b.a(0).x = 12 9 | } 10 | 11 | def test(): B = { 12 | val b = B(Array(A(1),A(2),A(3))) 13 | foo(b) 14 | b 15 | } ensuring(b => b.a(0).x == 12) 16 | 17 | } 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Array1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Array1 { 4 | 5 | def foo(): Int = { 6 | val a = Array.fill(5)(0) 7 | a(2) = 3 8 | a(2) 9 | } ensuring(_ == 3) 10 | 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Array2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Array2 { 4 | 5 | def foo(): Int = { 6 | val a = Array.fill(5)(0) 7 | a(2) = 3 8 | a.length 9 | } ensuring(_ == 5) 10 | 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Array3.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Array3 { 6 | 7 | def foo(): Int = { 8 | val a = Array.fill(5)(3) 9 | var i = 0 10 | var sum = 0 11 | (while(i < a.length) { 12 | sum = sum + a(i) 13 | i = i + 1 14 | }) invariant(i >= 0) 15 | sum 16 | } ensuring(_ == 15) 17 | 18 | } 19 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Array4.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Array4 { 6 | 7 | def foo(a: Array[Int]): Int = { 8 | var i = 0 9 | var sum = 0 10 | (while(i < a.length) { 11 | sum = sum + a(i) 12 | i = i + 1 13 | }) invariant(i >= 0) 14 | sum 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Array6.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Array6 { 6 | 7 | def test(): Int = { 8 | var c = 1 9 | val a = Array(0,1,2,3) 10 | a({ 11 | if(a(0) == 0) { c = c+1; 1} 12 | else { c = c+2; 2} 13 | }) = { c = c*2; -1} 14 | c 15 | } ensuring(res => res == 4) 16 | 17 | } 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Array8.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object Array8 { 4 | 5 | def bar(): Boolean = { 6 | val a = foo() 7 | a.length == 5 8 | }.holds 9 | 10 | @inline 11 | def foo(): Array[Int] = { 12 | Array.fill(5)(0) 13 | } ensuring { res => res(0) == 0 } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Array9.scala: -------------------------------------------------------------------------------- 1 | object Array9 { 2 | 3 | def g(a: Array[Int]): Array[Int] = { 4 | require(a.length > 0) 5 | a.updated(0, 10) 6 | } 7 | 8 | def test(): Int = { 9 | val b = Array(1,2,3,4) 10 | val c = g(b) 11 | c(0) 12 | } ensuring(_ == 10) 13 | 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/ArrayNested1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object ArrayNested1 { 6 | 7 | def test(): Int = { 8 | 9 | var a = Array(1, 2, 0) 10 | 11 | def nested(): Unit = { 12 | require(a.length == 3) 13 | a = a.updated(1, 5) 14 | } 15 | 16 | nested() 17 | a(1) 18 | 19 | } ensuring(_ == 5) 20 | 21 | } 22 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/ArrayNested2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object ArrayNested2 { 6 | 7 | def test(): Int = { 8 | 9 | val a = Array(1, 2, 0) 10 | 11 | def nested(): Unit = { 12 | require(a.length == 3) 13 | a(2) = 5 14 | } 15 | 16 | nested() 17 | a(2) 18 | 19 | } ensuring(_ == 5) 20 | 21 | } 22 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/ArrayParamMutation1.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | import stainless.annotation._ 3 | 4 | object ArrayParamMutation1 { 5 | 6 | def update(a: Array[BigInt]): Unit = { 7 | require(a.length > 0) 8 | a(0) = 10 9 | } 10 | 11 | def f(): BigInt = { 12 | val a = Array.fill(10)(BigInt(0)) 13 | update(a) 14 | a(0) 15 | } ensuring(res => res == 10) 16 | 17 | } 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/ArrayParamMutation2.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object ArrayParamMutation2 { 4 | 5 | def rec(a: Array[BigInt]): BigInt = { 6 | require(a.length > 1 && a(0) >= 0) 7 | if(a(0) == 0) 8 | a(1) 9 | else { 10 | a(0) = a(0) - 1 11 | a(1) = a(1) + a(0) 12 | rec(a) 13 | } 14 | } ensuring(res => a(0) == 0) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Assert1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Assert1 { 4 | 5 | def foo(): Int = { 6 | var a = 0 7 | a += 1 8 | assert(a == 1) 9 | a 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Assert2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Assert2 { 4 | 5 | def foo(): Int = { 6 | var a = 0 7 | assert(a == 0) 8 | a += 1 9 | a 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Assert3.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Assert3 { 6 | 7 | def test(i: Int): Int = { 8 | var j = i 9 | 10 | assert(j == i) 11 | j += 1 12 | assert(j == i + 1) 13 | j += 2 14 | assert(j == i + 3) 15 | 16 | j 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Assert4.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object Assert4 { 4 | 5 | case class T(var x: BigInt) { 6 | def f() = { 7 | x = x + 1 8 | false ==> { assert(false); true } 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Assign1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Assign1 { 4 | 5 | def foo(): Int = { 6 | var a = 0 7 | val tmp = a + 1 8 | a = a + 2 9 | a = a + tmp 10 | a = a + 4 11 | a 12 | } ensuring(_ == 7) 13 | 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Blocks1.scala: -------------------------------------------------------------------------------- 1 | object Blocks1 { 2 | 3 | //this used to crash as we would simplify away the final Unit, and get a typing 4 | //error during the solving part 5 | def test(a: BigInt): Unit = { 6 | 42 7 | () 8 | } ensuring(_ => a == (a + a - a)) 9 | 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/ExpressionOrder1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object ExpressionOrder1 { 6 | 7 | def test1 = { 8 | var x = 0 9 | 10 | def bar(y: Int) = { 11 | def fun(z: Int) = 1 * x * (y + z) 12 | 13 | fun(3) 14 | } 15 | 16 | bar(2) == 0 17 | }.holds 18 | 19 | } 20 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/ExpressionOrder2.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object ExpressionOrder2 { 4 | 5 | def testArrayAccess() = { 6 | val a = Array(0, 1, 2, 3) 7 | val b = Array(9, 9, 9) 8 | var c = 666 9 | val i = 9 10 | val x = (if (i != 9) b else { c = 0; a })(if (i == 9) { c = c + 1; 0 } else 1) 11 | 12 | x == 0 && c == 1 13 | }.holds 14 | 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/HigherOrderFunctionsMutableParams18.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object HigherOrderFunctionsMutableParams18 { 4 | 5 | case class A(var x: Int) 6 | case class F(f: (A) => Int) 7 | 8 | val inc = F(a => { 9 | a.x += 1 10 | a.x 11 | }) 12 | 13 | def test(a: A): Int = { 14 | inc.f(a) 15 | } ensuring((res: Int) => a.x == old(a).x + 1) 16 | 17 | } 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/IfExpr1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | import stainless.annotation._ 3 | 4 | object IfExpr1 { 5 | 6 | def foo(): Int = { 7 | var a = 1 8 | var b = 2 9 | if({a = a + 1; a != b}) 10 | a = a + 3 11 | else 12 | b = a + b 13 | a 14 | } ensuring(_ == 2) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/IfExpr2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | import stainless.annotation._ 3 | 4 | object IfExpr2 { 5 | 6 | def foo(): Int = { 7 | var a = 1 8 | var b = 2 9 | if(a < b) { 10 | a = a + 3 11 | b = b + 2 12 | a = a + b 13 | } 14 | a 15 | } ensuring(_ == 8) 16 | 17 | } 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/IfExpr3.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object IfExpr3 { 4 | 5 | def foo(a: Int): Int = { 6 | 7 | if(a > 0) { 8 | var a = 1 9 | var b = 2 10 | a = 3 11 | a + b 12 | } else { 13 | 5 14 | //var a = 3 15 | //var b = 1 16 | //b = b + 1 17 | //a + b 18 | } 19 | } ensuring(_ == 5) 20 | 21 | } 22 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/IfExpr4.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object IfExpr4 { 4 | 5 | def foo(a: Int): Int = { 6 | 7 | if(a > 0) { 8 | var a = 1 9 | var b = 2 10 | a = 3 11 | a + b 12 | } else { 13 | var a = 3 14 | var b = 1 15 | b = b + 1 16 | a + b 17 | } 18 | } ensuring(_ == 5) 19 | 20 | } 21 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/ImmutableOld.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object ImmutableOld { 4 | case class Test(i: BigInt) 5 | def test(t: Test): BigInt = { 6 | t.i 7 | } ensuring (_ == old(t).i) 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Lambda1.scala: -------------------------------------------------------------------------------- 1 | object Lambda1 { 2 | 3 | def test(): Int = { 4 | val x = 2 5 | val cl = ((y: Int) => { 6 | var z = y 7 | z = z + x 8 | z 9 | }) 10 | cl(4) 11 | } ensuring(_ == 6) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/MultiArray1.scala: -------------------------------------------------------------------------------- 1 | object MultiArray1 { 2 | 3 | def test: Int = { 4 | 5 | val b: Array[Array[Int]] = Array.fill(10)(Array.fill(10)(0)) 6 | 7 | b(0)(0) 8 | } ensuring(_ == 0) 9 | 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/MultiArray2.scala: -------------------------------------------------------------------------------- 1 | object MultiArray2 { 2 | 3 | def test: Int = { 4 | 5 | val b: Array[Array[Int]] = Array.fill(10)(Array.fill(10)(0)) 6 | 7 | b(0)(0) = 10 8 | 9 | b(0)(0) 10 | } ensuring(_ == 10) 11 | 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/MultiArray3.scala: -------------------------------------------------------------------------------- 1 | object MultiArray3 { 2 | 3 | def test: Int = { 4 | 5 | val b: Array[Array[Int]] = Array.fill(10)(Array.fill(10)(0)) 6 | 7 | b(2)(3) = 10 8 | 9 | b(2)(3) 10 | } ensuring(_ == 10) 11 | 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/MultiArray4.scala: -------------------------------------------------------------------------------- 1 | object MultiArray4 { 2 | 3 | def foo(b: Array[Array[Int]]): Int = { 4 | require(b.length >= 10 && b(2).length >= 10) 5 | b(2)(3) = 13 6 | b(2)(3) 7 | } ensuring(_ == 13) 8 | 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/MultiArray5.scala: -------------------------------------------------------------------------------- 1 | object MultiArray5 { 2 | 3 | def foo(b: Array[Array[Int]]): Int = { 4 | require(b.length >= 10 && b(2).length >= 10) 5 | b(2)(3) = 13 6 | b(2)(3) 7 | } ensuring(_ == 13) 8 | 9 | 10 | def test: Int = { 11 | val a: Array[Array[Int]] = Array.fill(10)(Array.fill(10)(0)) 12 | foo(a) 13 | a(2)(3) 14 | } ensuring(_ == 13) 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/MultiArray6.scala: -------------------------------------------------------------------------------- 1 | object MultiArray6 { 2 | 3 | def foo(b: Array[Int]): Int = { 4 | require(b.length >= 10) 5 | b(3) = 13 6 | b(3) 7 | } ensuring(_ == 13) 8 | 9 | 10 | def test: Int = { 11 | val a: Array[Array[Int]] = Array.fill(10)(Array.fill(10)(0)) 12 | foo(a(2)) 13 | a(2)(3) 14 | } ensuring(_ == 13) 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/MutableMapUpdated.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object MutableMapUpdated { 4 | def f(m: MutableMap[BigInt, BigInt]) = { 5 | val m1 = m.duplicate() 6 | m(0) = 5 7 | assert(m == m1.updated(0,5)) 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/MutateMap.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object MutateMap { 4 | 5 | case class A(var x: BigInt) 6 | 7 | def f(m: MutableMap[BigInt, A], a: A) = { 8 | require(a.x == 100) 9 | m(0) = a 10 | assert(m(0).x == 100) 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/MutateMapElement.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object MutateMapElement { 4 | 5 | case class A(var x: BigInt) 6 | 7 | def f(m: MutableMap[BigInt, A]) = { 8 | m(0).x = 100 9 | assert(m(0).x == 100) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/MutateNestedMapElement.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object MutateNestedMapElement { 4 | 5 | case class A(var x: BigInt) 6 | 7 | def f(m: MutableMap[BigInt, MutableMap[BigInt, A]]) = { 8 | m(0)(0).x = 100 9 | assert(m(0)(0).x == 100) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/NestedFunParamsMutation1.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object NestedFunParamsMutation1 { 4 | 5 | def f(): Int = { 6 | def g(a: Array[Int]): Unit = { 7 | require(a.length > 0) 8 | a(0) = 10 9 | } 10 | 11 | val a = Array(1,2,3,4) 12 | g(a) 13 | a(0) 14 | } ensuring(_ == 10) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/NestedFunParamsMutation3.scala: -------------------------------------------------------------------------------- 1 | object NestedFunParamsMutation3 { 2 | 3 | case class Counter(var i: BigInt) { 4 | def reset() = { 5 | i = 0 6 | } 7 | } 8 | 9 | 10 | def main(c: Counter): Unit = { 11 | 12 | def sub(): Unit = { 13 | c.reset() 14 | } 15 | sub() 16 | assert(c.i == 0) 17 | } 18 | 19 | } 20 | 21 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/NestedFunState10.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object NestedFunState10 { 4 | 5 | def foo(): Unit = { 6 | 7 | var i = 0 8 | 9 | def getI = i 10 | 11 | (while(i < 10) { 12 | i += 1 13 | }) invariant(getI >= 0) 14 | 15 | assert(i == 10) 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/NestedFunState2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object NestedFunState2 { 4 | 5 | def countConst(): Int = { 6 | 7 | var counter = 0 8 | 9 | def inc(): Unit = { 10 | counter += 1 11 | } 12 | 13 | inc() 14 | inc() 15 | inc() 16 | counter 17 | } ensuring(_ == 3) 18 | 19 | } 20 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/NestedFunState8.scala: -------------------------------------------------------------------------------- 1 | object NestedFunState8 { 2 | 3 | def test() = { 4 | var local = 0 5 | def foo(a: Int): Boolean = { local == a } 6 | 7 | local += 1 8 | assert(foo(1)) 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/NestedFunState9.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object NestedFunState9 { 4 | def test() = { 5 | var c = 0 6 | 7 | def foo(x: Int) = { 8 | require(c == 8) 9 | x 10 | } 11 | 12 | c = c+8 13 | foo(c) 14 | 15 | } ensuring(_ == 8) 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/NestedOld1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object NestedOld1 { 6 | 7 | def test(): Int = { 8 | var counter = 0 9 | 10 | def inc(): Unit = { 11 | counter += 1 12 | } ensuring(_ => counter == old(counter) + 1) 13 | 14 | inc() 15 | counter 16 | } ensuring(_ == 1) 17 | 18 | } 19 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/NestedVar.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object NestedVar { 4 | 5 | def foo(): Int = { 6 | val a = 3 7 | def rec(x: Int): Int = { 8 | var b = 3 9 | var c = 3 10 | if(x > 0) 11 | b = 2 12 | else 13 | c = 2 14 | c+b 15 | } 16 | rec(a) 17 | } ensuring(_ == 5) 18 | 19 | } 20 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/NoMutation.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object test { 4 | case class Test(var value: Int) 5 | 6 | def stuff(x: Test): Unit = () 7 | 8 | def test(x: Test) = { 9 | stuff(x) 10 | x.value 11 | } ensuring { _ == old(x).value } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/ObjectHierarchyMutation1.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object ObjectHierarchyMutation1 { 4 | 5 | case class A(var y: Int) 6 | case class B(a: A) 7 | 8 | def update(b: B): Int = { 9 | b.a.y = 17 10 | b.a.y 11 | } ensuring(res => res == 17) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/ObjectHierarchyMutation2.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object ObjectHierarchyMutation2 { 4 | 5 | case class A(var y: Int) 6 | case class B(a: A) 7 | 8 | def update(b: B): Int = { 9 | b.a.y = 17 10 | b.a.y 11 | } 12 | 13 | def f(): Int = { 14 | val b = B(A(10)) 15 | update(b) 16 | b.a.y 17 | } ensuring(res => res == 17) 18 | 19 | } 20 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/ObjectHierarchyMutation5.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object ObjectHierarchyMutation5 { 4 | 5 | case class A(var x: Int) 6 | case class B(a: A) 7 | case class C(b: B) 8 | 9 | def updateA(a: A): Unit = { 10 | a.x = 43 11 | } 12 | 13 | def update(c: C): Int = { 14 | updateA(c.b.a) 15 | c.b.a.x 16 | } ensuring(res => res == 43) 17 | 18 | } 19 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/ObjectHierarchyMutation8.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object ObjectHierarchyMutation8 { 4 | 5 | case class A(var x: Int) 6 | case class B(a: A) 7 | 8 | def updateB(b: B): Unit = { 9 | b.a.x = 42 10 | } 11 | 12 | def updateA(a: A): Unit = { 13 | updateB(B(a)) 14 | } ensuring(_ => a.x == 42) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/ObjectParamMutation1.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object ObjectParamMutation1 { 4 | 5 | case class A(var y: Int) 6 | 7 | def update(a: A): Int = { 8 | a.y = 12 9 | a.y 10 | } ensuring(res => res == 12) 11 | 12 | def f(): Int = { 13 | val a = A(10) 14 | update(a) 15 | a.y 16 | } ensuring(res => res == 12) 17 | 18 | } 19 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/ObjectParamMutation2.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object ObjectParamMutation2 { 4 | 5 | case class A(var y: Int) 6 | 7 | def update(a: A): Unit = { 8 | a.y = 12 9 | } ensuring(_ => a.y == 12) 10 | 11 | def f(): Int = { 12 | val a = A(10) 13 | update(a) 14 | a.y 15 | } ensuring(res => res == 12) 16 | 17 | } 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/ObjectParamMutation3.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object ObjectParamMutation3 { 4 | 5 | case class A(var y: Int) 6 | 7 | def update(a: A): Unit = { 8 | a.y = a.y + 3 9 | } ensuring(_ => a.y == old(a).y + 3) 10 | 11 | def f(): Int = { 12 | val a = A(10) 13 | update(a) 14 | a.y 15 | } ensuring(res => res == 13) 16 | 17 | } 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/ObjectParamMutation6.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object ObjectParamMutation6 { 4 | 5 | case class A(var x: BigInt) 6 | 7 | def inc(a: A): Unit = { 8 | a.x += 1 9 | } ensuring(_ => a.x == old(a).x + 1) 10 | 11 | def f(): BigInt = { 12 | val a = A(0) 13 | inc(a); inc(a); inc(a) 14 | a.x 15 | } ensuring(res => res == 3) 16 | 17 | } 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/ObjectParamMutation8.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object ObjectParamMutation8 { 4 | 5 | case class A[B](var y: B) 6 | 7 | def update[B](a: A[B], b: B): B = { 8 | a.y = b 9 | a.y 10 | } ensuring(res => res == b) 11 | 12 | def f(): Int = { 13 | val a = A(10) 14 | update(a, 12) 15 | a.y 16 | } ensuring(res => res == 12) 17 | 18 | } 19 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/ObjectParamMutation9.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object ObjectParamMutation9 { 4 | 5 | case class A(var x: Int) 6 | 7 | def foo(y: Int, a: A): Unit = { 8 | a.x = y 9 | } 10 | 11 | def update(a: A): Unit = { 12 | foo(10, a) 13 | } ensuring(_ => a.x == 10) 14 | 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/OldThis1.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object OldThis1 { 4 | 5 | case class A(var x: Int) { 6 | def foo(y: Int): Unit = { 7 | x += y 8 | } ensuring(_ => x == old(this).x + y) 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/OldThis2.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object OldThis2 { 4 | 5 | case class B(var x: Int) 6 | 7 | case class A(b: B) { 8 | def foo(y: Int): Unit = { 9 | b.x += y 10 | } ensuring(_ => b.x == old(this).b.x + y) 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/OldThis3.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object OldThis3 { 4 | 5 | case class A(var a: Int) { 6 | def foo(b: Int): Unit = { 7 | a + b // no assignement 8 | () 9 | } ensuring(_ => a == old(this).a) 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/OldThis4.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object OldThis4 { 4 | 5 | case class A(var a: Int) { 6 | def foo(b: Int): Unit = { 7 | b + b // a never used 8 | () 9 | } ensuring(_ => a == old(this).a) 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/PatternGuards1.scala: -------------------------------------------------------------------------------- 1 | object PatternGuards1 { 2 | 3 | def test(y: Int): Int = { 4 | var x = y 5 | def foo(): Boolean = x > 10 6 | 7 | x = x + 1 8 | 9 | x match { 10 | case z if x > 11 => z 11 | case _ => 12 12 | } 13 | } ensuring(_ > 11) 14 | 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/PatternGuards2.scala: -------------------------------------------------------------------------------- 1 | object PatternGuards2 { 2 | 3 | def test(y: Int): Int = { 4 | var x = y 5 | def foo(): Boolean = x > 10 6 | 7 | x = x + 1 8 | 9 | x match { 10 | case z if foo() => x 11 | case _ => 11 12 | } 13 | } ensuring(_ > 10) 14 | 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Sequencing1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Sequencing1 { 4 | 5 | def test(): Int = { 6 | var x = 0 7 | x += 1 8 | x *= 2 9 | x 10 | } ensuring(x => x == 2) 11 | 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Sequencing2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Sequencing2 { 4 | 5 | def test(): Int = { 6 | var x = 0 7 | x += 5 8 | x *= 10 9 | x 10 | } ensuring(x => x == 50) 11 | 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Sequencing3.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Sequencing3 { 4 | 5 | def f(x: Int): Int = { 6 | require(x < 10) 7 | x 8 | } 9 | 10 | def test(): Int = { 11 | var x = 0 12 | f(x) 13 | x += 5 14 | f(x) 15 | x += 5 16 | 17 | x 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Sequencing4.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Sequencing4 { 4 | 5 | def test(): Int = { 6 | var x = 5 7 | 8 | {x = x + 1; x} + {x = x * 2; x} 9 | 10 | } ensuring(res => res == 18) 11 | 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Sequencing5.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Sequencing5 { 4 | 5 | 6 | def test(): (Int, Int, Int) = { 7 | var x = 5 8 | 9 | ( 10 | {x = x + 1; x}, 11 | {x = x * 2; x}, 12 | {x = x - 1; x} 13 | ) 14 | 15 | } ensuring(res => res._1 == 6 && res._2 == 12 && res._3 == 11) 16 | 17 | } 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Sequencing7.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Sequencing7 { 4 | 5 | def test(): Int = { 6 | var x = 5 7 | 8 | {x = x + 1; x} 9 | {x = x * 2; x} 10 | {x = x - 1; x} 11 | 12 | x 13 | 14 | } ensuring(res => res == 11) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Sequencing8.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Sequencing8 { 4 | 5 | def test(): Int = { 6 | var x = 5 7 | 8 | (x = x + 1, (x = x * 2, (x = x - 1, x = x * 2))) 9 | 10 | x 11 | } ensuring(res => res == 22) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Snapshot.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | import stainless.lang.StaticChecks._ 3 | import stainless.annotation._ 4 | 5 | trait Snapshot { 6 | var x: BigInt 7 | 8 | def f() = { 9 | require(x == 0) 10 | @ghost val old = snapshot(this) 11 | x = 1 12 | assert(old.x == 0) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/Snapshot2.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | import stainless.lang.StaticChecks._ 3 | import stainless.annotation._ 4 | 5 | trait Snapshot2 { 6 | var x: BigInt 7 | 8 | def f() = { 9 | require(x == 2) 10 | @ghost val other = snapshot(this) 11 | ghost { other.x = 5 } 12 | assert(x == 2) 13 | assert(other.x == 5) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/StdIn1.scala: -------------------------------------------------------------------------------- 1 | import stainless.io._ 2 | 3 | object StdIn1 { 4 | 5 | def abs: BigInt = { 6 | implicit val state = stainless.io.newState 7 | val n = StdIn.readBigInt 8 | if(n < 0) -n else n 9 | } ensuring(_ >= 0) 10 | 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/TraitVar3.scala: -------------------------------------------------------------------------------- 1 | object TraitVar3 { 2 | case class A(var a: BigInt) 3 | 4 | trait TraitVar { 5 | var v: A 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/VarUpdate.scala: -------------------------------------------------------------------------------- 1 | trait VarUpdate { 2 | var x: BigInt 3 | 4 | def f() = { 5 | x = 0 6 | assert(x == 0) 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/While1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | import stainless.annotation._ 3 | 4 | object While1 { 5 | 6 | def foo(): Int = { 7 | var a = 0 8 | var i = 0 9 | while(i < 10) { 10 | a = a + 1 11 | i = i + 1 12 | } 13 | a 14 | } ensuring(_ == 10) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/While2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object While2 { 4 | 5 | def foo(): Int = { 6 | var a = 0 7 | var i = 0 8 | while(i < 10) { 9 | a = a + i 10 | i = i + 1 11 | } 12 | a 13 | } ensuring(_ == 45) 14 | 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/imperative/valid/While3.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object While3 { 4 | 5 | def foo(): Int = { 6 | var a = 0 7 | var i = 0 8 | while({i = i+2; i <= 10}) { 9 | a = a + i 10 | i = i - 1 11 | } 12 | a 13 | } ensuring(_ == 54) 14 | 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failCompilation/DuplicateIdentifier1.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | 3 | trait DuplicateIdentifier1 extends Contract { 4 | def foo(i: Uint256) = { 5 | val i: Uint256 = Uint256.ZERO 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failCompilation/DuplicateIdentifier2.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | 3 | trait DuplicateIdentifier2 extends Contract { 4 | def foo() = { 5 | val i: Uint256 = Uint256.ZERO 6 | if (true) { 7 | val i: Uint256 = Uint256.ZERO 8 | true 9 | } else false 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failCompilation/EnvironmentType1.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | import stainless.annotation._ 3 | 4 | trait EnvironmentType1 extends Contract { 5 | var e1: Environment 6 | val e2: Environment 7 | } 8 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failCompilation/EnvironmentType2.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | import stainless.annotation._ 3 | 4 | trait EnvironmentType2 extends Contract { 5 | @extern 6 | def foo: Environment = ??? 7 | } 8 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failCompilation/EnvironmentType3.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | 3 | trait EnvironmentType3 extends Contract { 4 | def foo(e: Environment) = ??? 5 | } 6 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failCompilation/EnvironmentType4.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | import stainless.lang._ 3 | 4 | trait EnvironmentType4 extends Contract { 5 | def foo() = { 6 | val e: Environment = Environment(MutableMap.withDefaultValue(Uint256.ZERO)) 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failCompilation/MappingType1.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | import stainless.lang._ 3 | 4 | trait MappingType1 extends Contract { 5 | var m: MutableMap[Address, Uint256] 6 | 7 | def foo() = { 8 | m 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failCompilation/MappingType2.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | import stainless.lang._ 3 | 4 | trait MappingType2 extends Contract { 5 | def foo() = { 6 | val m: MutableMap[Address, Uint256] = MutableMap.withDefaultValue(Uint256.ZERO) 7 | true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failCompilation/MappingType3.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | 3 | trait MappingType3 extends Contract { 4 | def foo(m: MutableMap[Address, Uint256]) = { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failCompilation/MappingType4.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | 3 | trait MappingType4 extends Contract { 4 | val m: MutableMap[Address, MutableMap[Address, Uint256]] 5 | 6 | def foo() = { 7 | m(Address(0)) = MutableMap.withDefaultValue(Uint256.ZERO) 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failCompilation/MappingType5.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | 3 | trait MappingType5 extends Contract { 4 | var m: MutableMap[Address, Uint256] 5 | 6 | def foo() = { 7 | m = MutableMap.withDefaultValue(Uint256.ZERO) 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failCompilation/MsgType1.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | 3 | trait MsgType1 extends Contract { 4 | var m1: Msg 5 | val m2: Msg 6 | } 7 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failCompilation/MsgType2.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | import stainless.annotation._ 3 | 4 | trait MsgType2 extends Contract { 5 | 6 | @extern 7 | def foo(): Msg = ??? 8 | 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failCompilation/MsgType3.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | import stainless.annotation._ 3 | 4 | trait MsgType3 extends Contract { 5 | @extern 6 | def foo(msg: Msg) = ??? 7 | } 8 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failCompilation/MsgType4.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | 3 | trait MsgType4 extends Contract { 4 | def foo() = { 5 | val m: Msg = Msg(address(this), Uint256.ZERO) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failCompilation/PublicMethodWithRequire.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | import stainless.annotation._ 3 | 4 | trait PublicMethodRequire extends Contract { 5 | @solidityPublic 6 | final def foo() = { 7 | require(true) 8 | 9 | true 10 | } 11 | } -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failExtraction/ConcreteInterfaceMethod.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | 3 | trait ConcreteInterfaceMethod extends ContractInterface { 4 | def f(): Unit = () 5 | } 6 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failExtraction/ContractInheritance.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | 3 | trait InheritedContract extends ContractInterface 4 | trait InheritingContract extends InheritedContract 5 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failExtraction/NonFinalConstructor.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | 3 | trait NonFinalConstructor extends Contract { 4 | def constructor(): Unit = () 5 | } 6 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failExtraction/NonFinalInvariant.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | 3 | trait NonFinalInvariant extends Contract { 4 | def invariant(): Boolean = true 5 | } 6 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failExtraction/NonFinalMethod.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | 3 | trait NonFinalMethod extends Contract { 4 | def f(): Unit = () 5 | } 6 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failVerification/FalseInvariant.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | import stainless.annotation._ 3 | 4 | trait FalseInvariant extends Contract { 5 | var x: BigInt 6 | 7 | @solidityPublic 8 | final def increment() = { 9 | x = x + 1 10 | } 11 | 12 | @ghost 13 | final def invariant(): Boolean = false 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/failVerification/Overflow.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | import stainless.annotation._ 3 | 4 | @wrapping // disable --strict-arithmetic checks inside the trait 5 | object Test { 6 | @solidityPublic 7 | final def f(a: Uint256, b: Uint256) = { 8 | assert(a + b >= a) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/valid/BasicContract.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | import stainless.annotation._ 3 | 4 | trait BasicContract extends Contract { 5 | val other: Address 6 | 7 | @solidityView 8 | @solidityPublic 9 | final def foo(): Address = { 10 | other 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/valid/BasicInterface.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | 3 | trait BasicInterface extends ContractInterface { 4 | def foo(): Unit 5 | def bar(): Boolean 6 | } 7 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/valid/BasicLibrary.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | import stainless.annotation._ 3 | 4 | @solidityLibrary("BasicLibrary") 5 | object BasicLibrary { 6 | @solidityPure 7 | @solidityPublic 8 | def foo() = true 9 | 10 | @solidityPure 11 | @solidityPublic 12 | def bar() = false 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/valid/DuplicateIdentifier1.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | import stainless.annotation._ 3 | 4 | trait DuplicateIdentifier1 extends Contract { 5 | val i: Uint256 6 | 7 | @solidityPure 8 | @solidityPublic 9 | final def foo(@ghost i: Uint256) = true 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/valid/DuplicateIdentifier2.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | import stainless.annotation._ 3 | 4 | trait DuplicateIdentifier2 extends Contract { 5 | val i: Uint256 6 | 7 | @solidityPure 8 | @solidityPublic 9 | final def foo() = { 10 | val i: Boolean = true 11 | i 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/valid/GhostParameter.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | import stainless.annotation._ 3 | 4 | trait GhostParameter extends Contract { 5 | 6 | @solidityPure 7 | @solidityPublic 8 | final def f(@ghost a: Uint256) = { 9 | } 10 | 11 | @solidityPure 12 | @solidityPublic 13 | final def g() = f(Uint256.ZERO) 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/valid/LoanContract/ERC20Token.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | 3 | trait ERC20Token extends ContractInterface { 4 | def transfer(to: Address, amount: Uint256): Boolean 5 | def balanceOf(from: Address): Uint256 6 | } 7 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/valid/MappingType1.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | import stainless.lang._ 3 | import stainless.annotation._ 4 | 5 | trait MappingType1 extends Contract { 6 | var m: MutableMap[Address, Uint256] 7 | 8 | @solidityPublic 9 | final def foo() = { 10 | m(Address(0)) = Uint256("50") 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/valid/MappingType2.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | import stainless.lang._ 3 | import stainless.annotation._ 4 | 5 | trait MappingType2 extends Contract { 6 | var m: MutableMap[Address, MutableMap[Address, Uint256]] 7 | 8 | @solidityPublic 9 | final def foo() = { 10 | m(Address(1))(Address(0)) = Uint256("50") 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/valid/MsgSame.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | import stainless.annotation._ 3 | 4 | trait MsgSame extends Contract { 5 | @solidityPublic 6 | @solidityView 7 | final def f() = g(Msg.sender) 8 | 9 | @solidityPrivate 10 | @solidityView 11 | final def g(a: Address) = { 12 | dynRequire(a == Msg.sender) 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/valid/PositiveUint.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | import stainless.annotation._ 3 | import stainless.lang.StaticChecks._ 4 | 5 | trait PositiveUint extends Contract { 6 | @solidityPure 7 | @solidityPublic 8 | final def test(@ghost a: Uint256) = { 9 | assert(a >= Uint256.ZERO) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/valid/Resend.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | import stainless.annotation._ 3 | 4 | trait Resend extends Contract { 5 | @solidityPayable 6 | @solidityPublic 7 | final def resend() = { 8 | val caller = Msg.sender 9 | val receivedAmount = Msg.value 10 | 11 | caller.transfer(receivedAmount) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/smartcontracts/valid/TrueInvariant.scala: -------------------------------------------------------------------------------- 1 | import stainless.smartcontracts._ 2 | import stainless.annotation._ 3 | 4 | trait TrueInvariant extends Contract { 5 | var x: BigInt 6 | 7 | @solidityPublic 8 | final def increment() = { 9 | x = x + 1 10 | } 11 | 12 | @ghost 13 | final def invariant: Boolean = true 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/strictarithmetic/invalid/Overflow1.scala: -------------------------------------------------------------------------------- 1 | 2 | object Overflow1 { 3 | 4 | def foo1(x: Int): Int = { 5 | x + 1 6 | } 7 | 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/strictarithmetic/invalid/Overflow10.scala: -------------------------------------------------------------------------------- 1 | 2 | object Overflow10 { 3 | 4 | def foo10(x: Int, y: Int): Int = { 5 | x * y 6 | } 7 | 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/strictarithmetic/invalid/Overflow11.scala: -------------------------------------------------------------------------------- 1 | 2 | object Overflow11 { 3 | 4 | def foo11(): Int = { 5 | val x = 500000 6 | val y = 500000 7 | x * y 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/strictarithmetic/invalid/Overflow12.scala: -------------------------------------------------------------------------------- 1 | 2 | object Overflow12 { 3 | 4 | def foo12(x: Int): Int = { 5 | -x 6 | } 7 | 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/strictarithmetic/invalid/Overflow13.scala: -------------------------------------------------------------------------------- 1 | 2 | object Overflow13 { 3 | 4 | def foo13(x: Int, y: Int) = { 5 | require(y != 0) 6 | x / y 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/strictarithmetic/invalid/Overflow2.scala: -------------------------------------------------------------------------------- 1 | 2 | object Overflow2 { 3 | 4 | def foo2(x: Int): Int = { 5 | x + (-1) 6 | } 7 | 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/strictarithmetic/invalid/Overflow3.scala: -------------------------------------------------------------------------------- 1 | 2 | object Overflow3 { 3 | 4 | def foo3(x: Int): Int = { 5 | x - 1 6 | } 7 | 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/strictarithmetic/invalid/Overflow4.scala: -------------------------------------------------------------------------------- 1 | 2 | object Overflow4 { 3 | 4 | def foo4(x: Int): Int = { 5 | x - (-1) 6 | } 7 | 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/strictarithmetic/invalid/Overflow5.scala: -------------------------------------------------------------------------------- 1 | 2 | object Overflow5 { 3 | 4 | def foo5(x: Int, y: Int): Int = { 5 | x + y 6 | } 7 | 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/strictarithmetic/invalid/Overflow6.scala: -------------------------------------------------------------------------------- 1 | 2 | object Overflow6 { 3 | 4 | def foo6(x: Int, y: Int): Int = { 5 | x - y 6 | } 7 | 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/strictarithmetic/invalid/Overflow7.scala: -------------------------------------------------------------------------------- 1 | 2 | object Overflow7 { 3 | 4 | def foo7(x: Int): Int = { 5 | x * 2 6 | } 7 | 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/strictarithmetic/invalid/Overflow8.scala: -------------------------------------------------------------------------------- 1 | 2 | object Overflow8 { 3 | 4 | def foo8(x: Int): Int = { 5 | x * 3 6 | } 7 | 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/strictarithmetic/invalid/Overflow9.scala: -------------------------------------------------------------------------------- 1 | 2 | object Overflow9 { 3 | 4 | def foo9(x: Int): Int = { 5 | x * 4 6 | } 7 | 8 | } 9 | -------------------------------------------------------------------------------- /frontends/benchmarks/strictarithmetic/invalid/StrictArithmetic1.scala: -------------------------------------------------------------------------------- 1 | 2 | object StrictArithmetic1 { 3 | 4 | def foo1(x: Int, y: Int) = { 5 | x << y 6 | } 7 | 8 | } 9 | 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/strictarithmetic/invalid/StrictArithmetic2.scala: -------------------------------------------------------------------------------- 1 | 2 | object StrictArithmetic2 { 3 | 4 | def foo2(x: Int, y: Int) = { 5 | x >> y 6 | } 7 | 8 | } 9 | 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/strictarithmetic/invalid/StrictArithmetic3.scala: -------------------------------------------------------------------------------- 1 | 2 | object StrictArithmetic3 { 3 | 4 | def foo3(x: Int, y: Int) = { 5 | x >>> y 6 | } 7 | 8 | } 9 | 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/strictarithmetic/invalid/StrictArithmetic4.scala: -------------------------------------------------------------------------------- 1 | 2 | object StrictArithmetic4 { 3 | 4 | // Test: should find at least x % 0 as a counter example 5 | def foo4(x: Int, y: Int) = { 6 | x % y 7 | } 8 | 9 | } 10 | 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/strictarithmetic/invalid/Wrapping1.scala: -------------------------------------------------------------------------------- 1 | import stainless.math._ 2 | 3 | object Wrapping1 { 4 | 5 | def foo1(x: Int, y: Int) = wrapping { 6 | x << y // Still invalid 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/strictarithmetic/invalid/Wrapping2.scala: -------------------------------------------------------------------------------- 1 | import stainless.math._ 2 | import stainless.annotation._ 3 | 4 | object Wrapping2 { 5 | 6 | @wrapping 7 | def foo1(x: Int, y: Int) = { 8 | x << y // Still invalid 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/strictarithmetic/valid/Wrapping1.scala: -------------------------------------------------------------------------------- 1 | import stainless.math._ 2 | import stainless.annotation._ 3 | 4 | object Wrapping1 { 5 | 6 | def double1(x: Int) = wrapping { 7 | x + x // OK 8 | } 9 | 10 | @wrapping 11 | def double2(x: Int) = { 12 | x + x // OK 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/strictarithmetic/valid/Wrapping2.scala: -------------------------------------------------------------------------------- 1 | import stainless.math._ 2 | import stainless.annotation._ 3 | 4 | object Wrapping2 { 5 | 6 | def double1(x: Int, y: Int) = wrapping { 7 | x + y - (x * 2 - y * 10) // OK 8 | } 9 | 10 | @wrapping 11 | def double2(x: Int, y: Int) = { 12 | x + y - (x * 2 - y * 10) // OK 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/termination/looping/Inconsistency.scala: -------------------------------------------------------------------------------- 1 | object Inconsistency { 2 | def looping(c: BigInt): Boolean = !decode(c)(c) 3 | def decode(c: BigInt): BigInt => Boolean = looping _ 4 | def encode(f: BigInt => Boolean): BigInt = 0 5 | 6 | def theorem() = { 7 | looping(encode(looping _)) // reduces to !looping(encode(looping _)), etc. 8 | assert(false) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/termination/looping/NegativeDatatype.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object NegativeDatatype { 4 | sealed abstract class Code 5 | case class Fold(f: Code => Boolean) extends Code 6 | 7 | def looping(c: Code): Boolean = c match { 8 | case Fold(f) => !f(c) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/termination/looping/NonStrictPositiveTypes.scala: -------------------------------------------------------------------------------- 1 | object NonStrictPositiveTypes { 2 | case class A(m: (A => Boolean) => Boolean) 3 | 4 | def looping(): A => Boolean = y => y.m(looping()) 5 | def x(): A = A(p => p(x())) 6 | 7 | // looping()(x()) reduces to x().m(looping()) and 8 | // x().m(looping()) reduces to looping()(x()) (does not terminate) 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/termination/looping/Numeric1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Numeric1 { 6 | // division by 0 loops 7 | def looping(x: Int, y: Int): Int = { 8 | if (x < y) 0 9 | else 1 + looping(x - y, y) 10 | } 11 | } 12 | 13 | // vim: set ts=4 sw=4 et: 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/termination/looping/Numeric2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Numeric2 { 6 | def looping1(x: Int): Int = looping2(x - 1) 7 | 8 | def looping2(x: Int): Int = looping3(x - 1) 9 | 10 | def looping3(x: Int): Int = looping4(x - 1) 11 | 12 | def looping4(x: Int): Int = looping1(x + 3) 13 | } 14 | 15 | // vim: set ts=4 sw=4 et: 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/termination/looping/Numeric3.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Numeric3 { 6 | def looping(x: Int) : Int = if (x > 0) looping(x - 1) else looping(2) 7 | } 8 | 9 | 10 | // vim: set ts=4 sw=4 et: 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/termination/looping/OddEven.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | 4 | object OddEven { 5 | 6 | def looping_isOdd(n: BigInt): Boolean = { 7 | looping_isEven(n-1) 8 | } ensuring { res => (n % 2 == 1) == res } 9 | 10 | def looping_isEven(n: BigInt): Boolean = { 11 | looping_isOdd(n-1) 12 | } ensuring { res => (n % 2 == 0) == res } 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/termination/looping/WrongFibonacci.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | 4 | object Fibonacci { 5 | 6 | def looping_fib(n: BigInt): BigInt = { 7 | looping_fib(n-1) + looping_fib(n-2) 8 | } ensuring {res => res == (5*n + 1)*(5*n - 1)} 9 | 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/termination/looping/Zeros2.scala: -------------------------------------------------------------------------------- 1 | object Zeros2 { 2 | case class SCons(x: BigInt, tail: () => SCons) 3 | def looping(): SCons = SCons(0, () => looping().tail()) 4 | } 5 | -------------------------------------------------------------------------------- /frontends/benchmarks/termination/looping/Zeros3.scala: -------------------------------------------------------------------------------- 1 | object Zeros3 { 2 | case class SCons(tail: () => SCons) 3 | def looping(): SCons = SCons(() => SCons(() => looping().tail().tail())) 4 | } 5 | -------------------------------------------------------------------------------- /frontends/benchmarks/termination/valid/Ackermann.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object Ackermann { 4 | def ackermann(m: BigInt, n: BigInt): BigInt = { 5 | require(m >= 0 && n >= 0) 6 | if (m == 0) n + 1 7 | else if (n == 0) ackermann(m - 1, 1) 8 | else ackermann(m - 1, ackermann(m, n - 1)) 9 | } ensuring (_ >= 0) 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/termination/valid/AliasPartial.scala: -------------------------------------------------------------------------------- 1 | /* From L. Ledesma-Garza and A. Rybalchenko */ 2 | 3 | import stainless.lang._ 4 | 5 | object AliasPartial { 6 | def f(x: BigInt)(y: BigInt): BigInt = { 7 | if (x > 0) f(x - 1)(y) 8 | else lambda(y) 9 | } 10 | 11 | def lambda(x: BigInt): BigInt = x + 1 12 | 13 | def g(x: BigInt) = f(1)(x) 14 | 15 | def main = g(2) 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/termination/valid/Consistent.scala: -------------------------------------------------------------------------------- 1 | object Consistent { 2 | 3 | def test(a: Int): Int = { 4 | val neverApplied = () => test(a) 5 | 0 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /frontends/benchmarks/termination/valid/CountTowardsZero.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | 4 | object Test { 5 | def f(x: BigInt): BigInt = { 6 | if (x == 0) { 7 | BigInt(0) 8 | } else if (x > 0) { 9 | f(x-1)+2 10 | } else if (x < 0) { 11 | f(x+1)-2 12 | } else { 13 | BigInt(33) 14 | } 15 | } ensuring (_ == x*2) 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/termination/valid/IndirectHO.scala: -------------------------------------------------------------------------------- 1 | /* From ESOP 2014, Kuwahara et al */ 2 | 3 | import stainless.lang._ 4 | 5 | object IndirectHO { 6 | 7 | def app(h: () => () => Unit): () => Unit = h() 8 | 9 | def f(n: BigInt): () => Unit = { 10 | if (n > 0) { 11 | app(() => f(n - 1)) 12 | } else { 13 | () => () 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/termination/valid/Loop2.scala: -------------------------------------------------------------------------------- 1 | /* From ESOP 2014, Kuwahara et al */ 2 | 3 | import stainless.lang._ 4 | import stainless.util._ 5 | 6 | object Loop2 { 7 | 8 | import Random._ 9 | 10 | def f(m: BigInt, n: BigInt)(implicit state: State): BigInt = { 11 | val r = Random.nextBigInt 12 | if (r > 0 && m > 0) f(m - 1, n) 13 | else if (r <= 0 && n > 0) f(m, n - 1) 14 | else 0 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/termination/valid/NestedLoop.scala: -------------------------------------------------------------------------------- 1 | /* From ESOP 2014, Kuwahara et al */ 2 | 3 | import stainless.lang._ 4 | 5 | object NestedLoop { 6 | 7 | def loop1(n: BigInt): BigInt = { 8 | if (n > 0) loop1(n - 1) else 0 9 | } 10 | 11 | def loop2(n: BigInt): BigInt = { 12 | if (n > 0) loop1(n) + loop2(n - 1) else 0 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/AbstractPost.scala: -------------------------------------------------------------------------------- 1 | trait AbstractPost { 2 | def inv(): Boolean = (??? : Boolean) 3 | 4 | def f(): Unit = { 5 | (??? : Unit) 6 | } ensuring(_ => inv()) 7 | } 8 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/Ackermann.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object Ackermann { 4 | def ackermann(m: BigInt, n: BigInt): BigInt = { 5 | require(m >= 0 && n >= 0) 6 | decreases(m, n) 7 | if (m == 0) n + 1 8 | else if (n == 0) ackermann(m - 1, 1) 9 | else ackermann(m - 1, ackermann(m, n - 1)) 10 | } ensuring (_ >= 0) 11 | } 12 | 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/CountTowardsZero.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object Test { 4 | def f(x: BigInt): BigInt = { 5 | decreases(if (x < 0) -x else x) 6 | if (x == 0) { 7 | BigInt(0) 8 | } else if (x > 0) { 9 | f(x-1)+2 10 | } else if (x < 0) { 11 | f(x+1)-2 12 | } else { 13 | BigInt(33) 14 | } 15 | } ensuring (_ == x*2) 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/EffectfulPost.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object EffectfulPost { 4 | case class Foo(var bar: Int) 5 | 6 | def mutateFoo(foo: Foo): Boolean = { 7 | foo.bar = foo.bar + 1 8 | foo.bar > 10 9 | } 10 | 11 | def test = { 12 | true 13 | } ensuring { _ => 14 | val foo = Foo(0) 15 | val after = mutateFoo(foo) 16 | after == false 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/FoolProofAdder.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.annotation._ 4 | import stainless.lang._ 5 | 6 | object FoolProofAdder { 7 | 8 | def foolProofAdder(x: BigInt): BigInt = { 9 | require(x > 0) 10 | x + BigInt(999999) + BigInt("999999999999999") 11 | } ensuring(_ > 0) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/Mean.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.annotation._ 4 | import stainless.lang._ 5 | 6 | object Mean { 7 | 8 | def mean(x: Int, y: Int): Int = { 9 | require(x <= y && x >= 0 && y >= 0) 10 | x + (y - x)/2 11 | } ensuring(m => m >= x && m <= y) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/ADTInvariants1.scala: -------------------------------------------------------------------------------- 1 | 2 | object ADTInvariants1 { 3 | 4 | case class Positive(i: BigInt) { 5 | require(i > 0) 6 | } 7 | 8 | def theorem(f: Positive => Positive) = { 9 | f(Positive(1)) 10 | } ensuring(res => res.i > 0) 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/ADTWithArray1.scala: -------------------------------------------------------------------------------- 1 | import stainless.collection._ 2 | 3 | object ADTWithArray1 { 4 | 5 | case class A1(x: Int) 6 | 7 | case class B(t: Array[A1]) 8 | 9 | def test(b: B): A1 = { 10 | require(b.t.length > 0 && b.t(0).x > 0) 11 | b.t(0) 12 | } ensuring(a => a.x >= 0) 13 | 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/ADTWithArray2.scala: -------------------------------------------------------------------------------- 1 | import stainless.collection._ 2 | 3 | object ADTWithArray2 { 4 | 5 | case class A1(x: Int) 6 | 7 | case class B(t: Array[A1]) 8 | 9 | def test(b: B): Int = { 10 | require(b.t.length > 2) 11 | b.t.length 12 | } ensuring(a => a > 0) 13 | 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/ADTWithArray4.scala: -------------------------------------------------------------------------------- 1 | object ADTWithArray4 { 2 | 3 | case class A(x: Int) 4 | case class B(a: Array[A]) 5 | 6 | def foo(b: B): Int = { 7 | require(b.a.length > 0) 8 | b.a(0).x 9 | } 10 | 11 | def test(): Int = { 12 | val b = B(Array(A(1),A(2),A(3))) 13 | foo(b) 14 | } ensuring(_ == 1) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/ADTWithArray5.scala: -------------------------------------------------------------------------------- 1 | import stainless.collection._ 2 | 3 | object ADTWithArray5 { 4 | 5 | case class HashTable(table: Array[BigInt]) { 6 | require(table.length > 0) 7 | 8 | def apply(index: Int): BigInt = { 9 | require(index >= 0 && index < table.length) 10 | table(index) 11 | } 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/ADTWithArray6.scala: -------------------------------------------------------------------------------- 1 | object ADTWithArray6 { 2 | 3 | case class A(x: Int) 4 | 5 | case class B(content: Array[A]) { 6 | require(content.length > 0) 7 | 8 | def update(y: Int): B = { 9 | B(Array(A(y))) 10 | } ensuring(res => res.content(0).x == y) 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/AbstractClasses.scala: -------------------------------------------------------------------------------- 1 | object AbstractClasses { 2 | abstract class A 3 | 4 | case class Wrapper(a: A) { 5 | def g() = f(a) 6 | } 7 | 8 | def f(a: A) = true 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/AddingPositiveNumbers.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object AddingPositiveNumbers { 4 | 5 | //this should not overflow 6 | def additionSound(x: BigInt, y: BigInt): BigInt = { 7 | require(x >= 0 && y >= 0) 8 | x + y 9 | } ensuring(_ >= 0) 10 | 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/Anonymous.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Anonymous { 6 | def test(x: BigInt) = { 7 | require(x > 0) 8 | val i = (a: BigInt) => a + 1 9 | i(x) + i(2) 10 | } ensuring { res => res > 0 } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/Array1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Array1 { 6 | 7 | def foo(a: Array[Int]): Int = { 8 | require(a.length > 2 && a(2) == 5) 9 | a(2) 10 | } ensuring(_ == 5) 11 | 12 | def bar(): Int = { 13 | val a = Array.fill(5)(5) 14 | foo(a) 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/Array2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Array2 { 4 | 5 | def foo(a: Array[Int]): Array[Int] = { 6 | require(a.length >= 2) 7 | a.updated(1, 3) 8 | } ensuring(res => res.length == a.length && res(1) == 3) 9 | 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/Array3.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Array3 { 4 | 5 | def foo(i: Int): Array[Int] = { 6 | require(i > 0) 7 | val a = Array.fill(i)(0) 8 | a 9 | } ensuring(res => res.length == i) 10 | 11 | def bar(i: Int): Int = { 12 | require(i > 0) 13 | val b = foo(i) 14 | b(0) 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/Array4.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Array4 { 6 | 7 | def foo(x: Int): Int = { 8 | require(x >= 0) 9 | val a = Array(0,0,x,0,0) 10 | a(2) 11 | } ensuring(_ >= 0) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/Array5.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Array5 { 6 | 7 | def foo(): Int = { 8 | val x = 10 9 | val a = Array(0,0,x,0,0) 10 | a(2) 11 | } ensuring(_ >= 0) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/ArrayLiterals.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object ArrayLiterals { 6 | def foo(): Int = { 7 | val b : Array[Int] = Array[Int](1,2,3) 8 | val a : Array[Int] = Array(1,2,3) 9 | a.length 10 | } ensuring { _ > 0 } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/BVDivisionByZero.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | import stainless.collection._ 5 | import stainless._ 6 | 7 | object BVDivisionByZero { 8 | 9 | def noDivByZero(x: Int): Boolean = { 10 | (x / 10 == 10) 11 | } 12 | 13 | def noRemByZero(x: BigInt): Boolean = { 14 | (x % 10 == 10) 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/BVDivisionByZero2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | import stainless.collection._ 5 | import stainless._ 6 | 7 | object BVDivisionByZero2 { 8 | 9 | def division(x: Int, y: Int): Int = { 10 | require(y != 0) 11 | x / y 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/CallByName1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object CallByName1 { 6 | def add(a: => Int, b: => Int): Int = a + b 7 | 8 | def test(): Int = { 9 | add(1,2) 10 | } ensuring (_ == 3) 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/Closures.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Closures { 6 | def addX(x: Int): Int => Int = { 7 | (a: Int) => a + x 8 | } 9 | 10 | def test(x: Int): Boolean = { 11 | val add1 = addX(1) 12 | val add2 = addX(2) 13 | add1(add2(1)) == 4 14 | }.holds 15 | } 16 | 17 | // vim: set ts=4 sw=4 et: 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/ConcreteClass.scala: -------------------------------------------------------------------------------- 1 | case class ConcreteClass() { 2 | def f() = 0 3 | def g() = { 4 | assert(f() == 0) 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/CopyInv.scala: -------------------------------------------------------------------------------- 1 | 2 | object CopyInv { 3 | 4 | case class Foo(x: BigInt) { 5 | require(x > 0) 6 | } 7 | 8 | def prop(foo: Foo, y: BigInt) = { 9 | require(y > 1) 10 | foo.copy(x = y) 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/Field1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Field1 { 4 | 5 | abstract sealed class A 6 | case class B(size: Int) extends A 7 | 8 | def foo(): Int = { 9 | val b = B(3) 10 | b.size 11 | } ensuring(_ == 3) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/Field2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Field2 { 4 | 5 | abstract sealed class A 6 | case class B(length: Int) extends A 7 | 8 | def foo(): Int = { 9 | val b = B(3) 10 | b.length 11 | } ensuring(_ == 3) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/FinalMethod.scala: -------------------------------------------------------------------------------- 1 | trait FinalMethod { 2 | final def f() = 0 3 | 4 | def g() = { 5 | assert(f() == 0) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/MatchGuard.scala: -------------------------------------------------------------------------------- 1 | object MatchGuard { 2 | sealed abstract class Nat 3 | case object Zero extends Nat 4 | case class Succ(n: Nat) extends Nat 5 | 6 | def f(n: Nat): Boolean = n match { 7 | case Zero => true 8 | case Succ(n2) if { assert(n == Succ(n2)); true } => true 9 | case _ => true 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/MyTuple1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object MyTuple1 { 4 | 5 | def foo(): Int = { 6 | val t = (1, true, 3) 7 | val a1 = t._1 8 | val a2 = t._2 9 | val a3 = t._3 10 | a3 11 | } ensuring( _ == 3) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/MyTuple2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object MyTuple2 { 4 | 5 | sealed abstract class A 6 | case class B(i: Int) extends A 7 | case class C(a: A) extends A 8 | 9 | def foo(): Int = { 10 | val t = (B(2), C(B(3))) 11 | t match { 12 | case (B(x), C(y)) => x 13 | } 14 | } ensuring(_ == 2) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/MyTuple3.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object MyTuple3 { 4 | 5 | def foo(): Int = { 6 | val t = ((2, 3), true) 7 | t._1._2 8 | } ensuring( _ == 3) 9 | 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/MyTuple4.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | 4 | object MyTuple4 { 5 | 6 | sealed abstract class A 7 | case class B(i: Int) extends A 8 | case class C(a: A) extends A 9 | 10 | def foo(): Int = { 11 | val t = (1, (C(B(4)), 2), 3) 12 | val (a1, (C(B(x)), a2), a3) = t 13 | x 14 | } ensuring( _ == 4) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/MyTuple6.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object MyTuple6 { 4 | 5 | def foo(t: (Int, Int)): (Int, Int) = { 6 | require(t._1 > 0 && t._2 > 1) 7 | t 8 | } ensuring(res => res._1 > 0 && res._2 > 1) 9 | 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/Nested1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Nested1 { 4 | 5 | def foo(i: Int): Int = { 6 | val n = i 7 | def rec1(j: Int) = i + j + n 8 | def rec2(j: Int) = { 9 | def rec3(k: Int) = k + j + i 10 | rec3(5) 11 | } 12 | rec2(2) 13 | } ensuring(i + 7 == _) 14 | 15 | } 16 | 17 | // vim: set ts=4 sw=4 et: 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/Nested10.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Nested10 { 4 | 5 | def foo(i: Int): Int = { 6 | val n = 2 7 | def rec1(j: Int) = { 8 | i + j + n 9 | } 10 | def rec2(j: Int) = { 11 | rec1(j) 12 | } 13 | rec2(2) 14 | } ensuring(i + 4 == _) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/Nested11.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Nested11 { 4 | 5 | sealed abstract class A 6 | case class B(b: Int) extends A 7 | 8 | def foo(i: Int): Int = { 9 | val b: A = B(3) 10 | def rec1(j: Int) = b match { 11 | case B(b) => i + j + b 12 | } 13 | rec1(2) 14 | } ensuring(i + 5 == _) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/Nested18.scala: -------------------------------------------------------------------------------- 1 | object Nested18 { 2 | 3 | def test(a: BigInt): BigInt = { 4 | require(a > 0) 5 | def f(b: BigInt): BigInt = { 6 | def g(c: BigInt): BigInt = { 7 | require(a > 0) 8 | c 9 | } 10 | g(b) 11 | } 12 | f(12) 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/Nested2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Nested2 { 4 | 5 | def foo(a: BigInt): BigInt = { 6 | require(a >= 0) 7 | val b = a + 2 8 | def rec1(c: BigInt): BigInt = { 9 | require(c >= 0) 10 | b + c 11 | } 12 | rec1(2) 13 | } ensuring(_ > 0) 14 | 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/Nested5.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Nested5 { 4 | 5 | def foo(a: Int): Int = { 6 | require(a >= 0) 7 | def bar(b: Int): Int = { 8 | require(b > 0) 9 | b + 3 10 | } ensuring(a >= 0 && _ == b + 3) 11 | bar(2) 12 | } ensuring(a >= 0 && _ == 5) 13 | 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/Opaque.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | import stainless.collection._ 3 | import stainless.lang._ 4 | 5 | object Opaque { 6 | 7 | @opaque 8 | def size[A](list: List[A]): BigInt = { 9 | decreases(list) 10 | list match { 11 | case Cons(x, xs) => 1 + size(xs) 12 | case _ => BigInt(0) 13 | } 14 | } ensuring (_ >= BigInt(0)) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/PureMethods.scala: -------------------------------------------------------------------------------- 1 | trait PureMethods { 2 | def f(): BigInt 3 | 4 | def g() = { 5 | val a = f() 6 | val b = f() 7 | assert(a == b) 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/RealDivisionByZero.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | import stainless.collection._ 5 | import stainless._ 6 | 7 | object RealDivisionByZero { 8 | 9 | def noDivByZero(x: Real): Boolean = { 10 | (x / Real(10) == Real(10)) 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/StaticChecks1.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | import stainless.lang.StaticChecks._ 3 | 4 | object StaticChecks1 { 5 | 6 | def add(n: BigInt, m: BigInt): BigInt = { 7 | require(n >= 0 && m >= 0) 8 | decreases(m) 9 | if(m == 0) n else add(n, m-1) + 1 10 | } ensuring((res: BigInt) => res >= 0) 11 | 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/StaticChecks2.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | import stainless.lang.StaticChecks._ 3 | 4 | object StaticChecks2 { 5 | 6 | def add(n: BigInt, m: BigInt): BigInt = { 7 | require(n >= 0 && m >= 0) 8 | decreases(m) 9 | var res = if(m == 0) n else add(n, m-1) + 1 10 | assert(res >= 0) 11 | res 12 | } ensuring((res: BigInt) => res >= 0) 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/Unit1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Unit1 { 4 | 5 | def foo(): Unit = ({ 6 | () 7 | }) ensuring(r => true) 8 | 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MicroTests/Unit2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Unit2 { 4 | 5 | def foo(u: Unit): Unit = { 6 | u 7 | } ensuring(res => true) 8 | 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/MySet.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object MySet { 6 | 7 | def set1(): Boolean = { 8 | val s = Set(1, 2, 3, 4) 9 | s.contains(3) 10 | }.holds 11 | 12 | def set2(): Boolean = { 13 | val s1 = Set[Int]() 14 | val s2 = Set.empty[Int] 15 | s1 == s2 16 | }.holds 17 | 18 | } 19 | -------------------------------------------------------------------------------- /frontends/benchmarks/typechecker/valid/PostConditionInTuple.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | 3 | object PostConditionInTuple { 4 | @extern 5 | def dynAssert(cond: Boolean): Unit = { 6 | (??? : Unit) 7 | } ensuring(cond) 8 | 9 | def f() = { 10 | (dynAssert(false), 0) 11 | } ensuring(_ => false) 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/ADTInvariants.scala: -------------------------------------------------------------------------------- 1 | /* Coypright 2009-2018 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object ADTInvariants { 6 | case class Positive(var x: BigInt) { 7 | require(x >= 0) 8 | } 9 | 10 | def decrease(f: BigInt => Positive, i: BigInt) = { 11 | val p = f(i) 12 | p.x = -1 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/ADTWithArray1.scala: -------------------------------------------------------------------------------- 1 | object ADTWithArray1 { 2 | 3 | case class A(x: Int) 4 | 5 | case class B(content: Array[A]) { 6 | require(content.length > 0) 7 | 8 | def contains(y: Int): Boolean = { 9 | require(content.length > 0) 10 | content(0).x == y 11 | } ensuring(res => res) 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/ADTWithArray2.scala: -------------------------------------------------------------------------------- 1 | import stainless.collection._ 2 | 3 | object ADTWithArray2 { 4 | 5 | case class B(content: Array[List[BigInt]]) { 6 | require(content.length > 0 && content.length < 100) 7 | 8 | def contains(y: BigInt): Boolean = { 9 | y >= 0 10 | } ensuring(res => res == content(0).contains(y)) 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/AddNaturals1.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | import stainless.annotation._ 3 | import stainless.collection._ 4 | 5 | object AddNaturals1 { 6 | def addNaturals(nats: List[Int]): Int = { 7 | require(nats forall (_ >= 0)) // input list contains nonnegative Ints 8 | nats.foldLeft(0)(_ + _) 9 | } ensuring(_ >= 0) // function result is a nonnegative Int 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/AddNaturals3.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | import stainless.annotation._ 3 | import stainless.collection._ 4 | 5 | object AddNaturals3 { 6 | def addTwoNaturals(x: Int, y: Int): Int = { 7 | require(x >= 0 && y >= 0) 8 | x + y 9 | } ensuring(_ >= 0) 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/AddingNegativeNumbers.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | package test.resources.regression.verification.purescala.invalid 4 | 5 | object AddingNegativeNumbers { 6 | 7 | def additionOverflow(x: Int, y: Int): Int = { 8 | require(x <= 0 && y <= 0) 9 | x + y 10 | } ensuring(_ <= 0) 11 | 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/AddingPositiveNumbers.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object AddingPositiveNumbers { 4 | 5 | //this should overflow with bit vectors 6 | def additionOverflow(x: Int, y: Int): Int = { 7 | require(x >= 0 && y >= 0) 8 | x + y 9 | } ensuring(_ >= 0) 10 | 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/Array1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Array1 { 6 | 7 | def foo(a: Array[Int]): Int = { 8 | a(2) 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/Array2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Array2 { 6 | 7 | def foo(a: Array[Int]): Int = { 8 | require(a.length > 2) 9 | a(2) 10 | } ensuring(_ == 0) 11 | 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/Array3.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Array3 { 6 | def find(c: Array[Int], i: Int): Int = { 7 | require(i >= 0) 8 | if(c(i) == i) 9 | 42 10 | else 11 | 12 12 | } ensuring(_ > 0) 13 | 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/Array4.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Array4 { 6 | 7 | def foo(a: Array[Int]): Int = { 8 | val tmp = a.updated(0, 0) 9 | tmp(0) 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/Array5.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Array5 { 6 | 7 | def foo(a: Array[Int]): Int = { 8 | a(2) 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/Array6.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Array6 { 6 | 7 | def foo(a: Array[Int]): Int = { 8 | require(a.length > 2) 9 | a(2) 10 | } ensuring(_ == 0) 11 | 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/Array7.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Array7 { 6 | 7 | def foo(a: Array[Int]): Int = { 8 | require(a.length > 0) 9 | val a2 = a.updated(1, 2) 10 | a2(0) 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/BVDivision2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | import stainless.collection._ 5 | import stainless._ 6 | 7 | object BVDivision2 { 8 | 9 | def division(x: Int, y: Int): Int = { 10 | x / y 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/BVDivisionByZero.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | import stainless.collection._ 5 | import stainless._ 6 | 7 | object BVDivisionByZero { 8 | 9 | def divByZero(x: Int): Boolean = { 10 | (x / 0 == 10) 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/BVRemainderByZero.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | import stainless.collection._ 5 | import stainless._ 6 | 7 | object BVRemainderByZero { 8 | 9 | def remByZero(x: Int): Boolean = { 10 | (x % 0 == 10) 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/BigArray.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.annotation._ 4 | import stainless.lang._ 5 | 6 | object BigArray { 7 | 8 | def big(a: Array[Int]): Int = { 9 | require(a.length >= 10 && a(7) == 42) 10 | a.length 11 | } ensuring(_ <= 1000000000) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/BodyEnsuring.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object BodyEnsuring { 4 | def f(): () => Boolean = { 5 | () => { 6 | false 7 | }.holds 8 | } 9 | 10 | def g() = { 11 | assert(f()()) 12 | assert(false) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/Bytes.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Bytes { 6 | 7 | def test(b: Byte) = { 8 | require(b % 2 != 0) 9 | if (b > 0) 0 else 1 10 | } 11 | 12 | def fun(b: Byte) = test(b) 13 | 14 | def gun(b: Byte, c: Byte) = { 15 | b + c 16 | } ensuring { res => -128 <= res && res <= 127 } 17 | 18 | } 19 | 20 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/CharCompare.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object CharCompare { 6 | def cmp(c1: Char, c2: Char): Boolean = { c1 < c2 }.holds 7 | } 8 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/Choose2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Choose2 { 6 | 7 | def test(x: BigInt): BigInt = { 8 | 9 | choose[BigInt]((y: BigInt) => { 10 | val z = y + 2 11 | z == y 12 | }) 13 | 14 | } ensuring(_ == x + 2) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/ContainerTest.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | 3 | object ContainerTest { 4 | case class Box(var value: BigInt) 5 | case class Container[T](t: T) 6 | 7 | @extern 8 | def f2(b: Container[Box]): Unit = ??? 9 | 10 | def g2(b: Container[Box]) = { 11 | val b0 = b 12 | f2(b) 13 | assert(b == b0) // fails because `Container` is mutable 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/CopyInv.scala: -------------------------------------------------------------------------------- 1 | 2 | object CopyInv { 3 | 4 | case class Foo(x: BigInt) { 5 | require(x > 0) 6 | } 7 | 8 | def prop(foo: Foo, y: BigInt) = { 9 | foo.copy(x = y) 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/DisrespectfulOverride.scala: -------------------------------------------------------------------------------- 1 | object DisrespectfulOverride { 2 | abstract class A { 3 | def f(): BigInt = { 4 | ??? : BigInt 5 | } ensuring(_ > 0) 6 | } 7 | 8 | case class C() extends A { 9 | override def f() = 0 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/DisrespectfulOverride2.scala: -------------------------------------------------------------------------------- 1 | object DisrespectfulOverride2 { 2 | abstract class A { 3 | def f(): BigInt = { 4 | ??? : BigInt 5 | } ensuring(_ > 0) 6 | } 7 | 8 | abstract class B extends A 9 | 10 | case class C() extends B { 11 | override def f() = 0 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/DivisionByZero.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | import stainless.collection._ 5 | import stainless._ 6 | 7 | object DivisionByZero { 8 | 9 | def divByZero(x: BigInt): Boolean = { 10 | (x / BigInt(0) == BigInt(10)) 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/EnsuringBoolean.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless._ 4 | import stainless.lang._ 5 | import stainless.annotation._ 6 | import scala.language.postfixOps 7 | object EnsuringBoolean { 8 | def congR(x: BigInt)(implicit mod: BigInt): Unit = { 9 | require(mod >= 1); 10 | () 11 | } ensuring(false) 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/ExternFun.scala: -------------------------------------------------------------------------------- 1 | 2 | import stainless.lang._ 3 | import stainless.annotation._ 4 | 5 | object ExternFun { 6 | 7 | @extern 8 | def stuff(x: BigInt): BigInt = x 9 | 10 | def test(n: BigInt) = { 11 | stuff(n) == n 12 | }.holds 13 | 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/HiddenOverride.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | 3 | trait HiddenOverride { 4 | def f() = 0 5 | 6 | def g() = { 7 | val x = f() 8 | // f may have been overridden, so the assert doesn't always hold 9 | assert(x == 0) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/LambdaPrecondition.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object LambdaPreconditions { 4 | def a() = { 5 | require(false) 6 | false 7 | }.holds 8 | 9 | def f(b: Boolean): () => Boolean = { 10 | if (b) a 11 | else () => true 12 | } 13 | 14 | def g() = { 15 | assert(f(true)()) 16 | assert(false) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/Mean.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.annotation._ 4 | import stainless.lang._ 5 | 6 | object Mean { 7 | 8 | def meanOverflow(x: Int, y: Int): Int = { 9 | require(x <= y && x >= 0 && y >= 0) 10 | (x + y)/2 11 | } ensuring(m => m >= x && m <= y) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/ModuloByZero.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | import stainless.collection._ 5 | import stainless._ 6 | 7 | object ModuloByZero { 8 | 9 | def modByZero(x: BigInt): Boolean = { 10 | (x mod BigInt(0)) == BigInt(10) 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/MyTuple1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object MyTuple1 { 4 | 5 | def foo(): Int = { 6 | val t = (1, true, 3) 7 | val a1 = t._1 8 | val a2 = t._2 9 | val a3 = t._3 10 | a3 11 | } ensuring( _ == 1) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/MyTuple2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object MyTuple2 { 4 | 5 | abstract class A 6 | case class B(i: Int) extends A 7 | case class C(a: A) extends A 8 | 9 | def foo(): Int = { 10 | val t = (B(2), C(B(3))) 11 | t match { 12 | case (B(x), C(y)) => x 13 | } 14 | } ensuring( _ == 3) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/MyTuple3.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object MyTuple3 { 4 | 5 | def foo(t: (Int, Int)): (Int, Int) = { 6 | t 7 | } ensuring(res => res._1 > 0 && res._2 > 1) 8 | 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/Passes1.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object Passes1 { 4 | 5 | def abs(n: BigInt): BigInt = { 6 | if (n < 0) -n else n 7 | } ensuring { res => 8 | res >= 0 && 9 | ((n, res) passes { 10 | case BigInt(-42) => BigInt(0) 11 | }) 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/PreInPre.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | import stainless.collection._ 3 | 4 | object PreInPre { 5 | 6 | @induct 7 | def f(t: List[BigInt], st: BigInt): Unit = { 8 | require(t.head == st) 9 | () 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/README: -------------------------------------------------------------------------------- 1 | This particular directory contains PureScala programs that have *at least* one 2 | failing verification condition. 3 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/RealDivisionByZero.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | import stainless.collection._ 5 | import stainless._ 6 | 7 | object RealDivisionByZero { 8 | 9 | def divByZero(x: Real): Boolean = { 10 | (x / Real(0) == Real(10)) 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/RealNonDiscrete.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | import stainless.annotation._ 5 | 6 | object RealNonDiscrete { 7 | 8 | def nonDiscrete(x: Real): Boolean = { 9 | require(x > Real(1) && x < Real(3)) 10 | x == Real(2) 11 | }.holds 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/RemainderByZero.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | import stainless.collection._ 5 | import stainless._ 6 | 7 | object RemainderByZero { 8 | 9 | def remByZero(x: BigInt): Boolean = { 10 | (x % BigInt(0) == BigInt(10)) 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/SimpleQuantification2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object SimpleQuantification2 { 6 | 7 | def failling(f: BigInt => BigInt) = { 8 | require(forall((a: BigInt) => a > 0 ==> f(a) > 1)) 9 | f(1) + f(2) 10 | } ensuring { res => res > 4 } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/StaticChecks1.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang.StaticChecks._ 2 | 3 | object StaticChecks1 { 4 | 5 | def add(n: BigInt, m: BigInt): BigInt = { 6 | require(n >= 0 && m >= 0) 7 | if(m == 0) n else add(n, m-2) + 1 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/StaticChecks2.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang.StaticChecks._ 2 | 3 | object StaticChecks2 { 4 | 5 | def foo(n: BigInt, m: BigInt) = { 6 | assert(n + m > n) 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/StaticChecks3.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang.StaticChecks._ 2 | 3 | object StaticChecks3 { 4 | 5 | def add(n: BigInt, m: BigInt): BigInt = { 6 | require(n >= 0) 7 | n + m 8 | } ensuring { _ >= 0 } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/SuperInvariants.scala: -------------------------------------------------------------------------------- 1 | 2 | object SuperInvariants { 3 | 4 | sealed abstract class Foo { 5 | require(x != 0) 6 | val x: BigInt 7 | } 8 | 9 | case class Bar(x: BigInt) extends Foo { 10 | require(x != 1) 11 | } 12 | 13 | def bad0: Foo = Bar(0) // invalid 14 | def bad1: Foo = Bar(1) // invalid 15 | def ok2: Foo = Bar(2) // valid 16 | 17 | } 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/invalid/Unit1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Unit1 { 4 | 5 | def foo(u: Unit): Unit = ({ 6 | u 7 | }) ensuring(res => false) 8 | 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/unchecked/SimpleQuantification.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object SimpleQuantification { 6 | 7 | def failling(f: BigInt => BigInt) = { 8 | require(forall((a: BigInt) => a > 0 ==> f(a) > 0)) 9 | f(-1) 10 | } ensuring { res => res > 0 } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/unchecked/SimpleQuantification3.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object SimpleQuantification3 { 6 | 7 | def failling(f: BigInt => BigInt, g: BigInt => BigInt, x: BigInt) = { 8 | require(forall((a: BigInt, b: BigInt) => f(a) + g(a) > 0)) 9 | if(x < 0) f(x) + g(x) 10 | else x 11 | } ensuring { res => res > 0 } 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/ADTInvariants1.scala: -------------------------------------------------------------------------------- 1 | 2 | object ADTInvariants1 { 3 | 4 | case class Positive(i: BigInt) { 5 | require(i > 0) 6 | } 7 | 8 | def theorem(f: Positive => Positive) = { 9 | f(Positive(1)) 10 | } ensuring(res => res.i > 0) 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/ADTInvariants4.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object ADTInvariants4 { 4 | abstract class Foo { 5 | def bar: Option[Bar] 6 | } 7 | 8 | case class Bar(bar: Option[Bar]) extends Foo { 9 | require(bar.isDefined) 10 | } 11 | 12 | def test(foo: Foo): Boolean = (foo match { 13 | case Bar(b) => b.nonEmpty 14 | case _ => true 15 | }).holds 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/ADTWithArray1.scala: -------------------------------------------------------------------------------- 1 | import stainless.collection._ 2 | 3 | object ADTWithArray1 { 4 | 5 | case class A1(x: Int) 6 | 7 | case class B(t: Array[A1]) 8 | 9 | def test(b: B): A1 = { 10 | require(b.t.length > 0 && b.t(0).x > 0) 11 | b.t(0) 12 | } ensuring(a => a.x >= 0) 13 | 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/ADTWithArray2.scala: -------------------------------------------------------------------------------- 1 | import stainless.collection._ 2 | 3 | object ADTWithArray2 { 4 | 5 | case class A1(x: Int) 6 | 7 | case class B(t: Array[A1]) 8 | 9 | def test(b: B): Int = { 10 | require(b.t.length > 2) 11 | b.t.length 12 | } ensuring(a => a > 0) 13 | 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/ADTWithArray4.scala: -------------------------------------------------------------------------------- 1 | object ADTWithArray4 { 2 | 3 | case class A(x: Int) 4 | case class B(a: Array[A]) 5 | 6 | def foo(b: B): Int = { 7 | require(b.a.length > 0) 8 | b.a(0).x 9 | } 10 | 11 | def test(): Int = { 12 | val b = B(Array(A(1),A(2),A(3))) 13 | foo(b) 14 | } ensuring(_ == 1) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/ADTWithArray5.scala: -------------------------------------------------------------------------------- 1 | import stainless.collection._ 2 | 3 | object ADTWithArray5 { 4 | 5 | case class HashTable(table: Array[BigInt]) { 6 | require(table.length > 0) 7 | 8 | def apply(index: Int): BigInt = { 9 | require(index >= 0 && index < table.length) 10 | table(index) 11 | } 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/ADTWithArray6.scala: -------------------------------------------------------------------------------- 1 | object ADTWithArray6 { 2 | 3 | case class A(x: Int) 4 | 5 | case class B(content: Array[A]) { 6 | require(content.length > 0) 7 | 8 | def update(y: Int): B = { 9 | B(Array(A(y))) 10 | } ensuring(res => res.content(0).x == y) 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/AbstractClasses.scala: -------------------------------------------------------------------------------- 1 | object AbstractClasses { 2 | abstract class A 3 | 4 | case class Wrapper(a: A) { 5 | def g() = f(a) 6 | } 7 | 8 | def f(a: A) = true 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/AddingPositiveNumbers.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object AddingPositiveNumbers { 4 | 5 | //this should not overflow 6 | def additionSound(x: BigInt, y: BigInt): BigInt = { 7 | require(x >= 0 && y >= 0) 8 | x + y 9 | } ensuring(_ >= 0) 10 | 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/Anonymous.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Anonymous { 6 | def test(x: BigInt) = { 7 | require(x > 0) 8 | val i = (a: BigInt) => a + 1 9 | i(x) + i(2) 10 | } ensuring { res => res > 0 } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/Array1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Array1 { 6 | 7 | def foo(a: Array[Int]): Int = { 8 | require(a.length > 2 && a(2) == 5) 9 | a(2) 10 | } ensuring(_ == 5) 11 | 12 | def bar(): Int = { 13 | val a = Array.fill(5)(5) 14 | foo(a) 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/Array2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Array2 { 4 | 5 | def foo(a: Array[Int]): Array[Int] = { 6 | require(a.length >= 2) 7 | a.updated(1, 3) 8 | } ensuring(res => res.length == a.length && res(1) == 3) 9 | 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/Array3.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Array3 { 4 | 5 | def foo(i: Int): Array[Int] = { 6 | require(i > 0) 7 | val a = Array.fill(i)(0) 8 | a 9 | } ensuring(res => res.length == i) 10 | 11 | def bar(i: Int): Int = { 12 | require(i > 0) 13 | val b = foo(i) 14 | b(0) 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/Array4.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Array4 { 6 | 7 | def foo(x: Int): Int = { 8 | require(x >= 0) 9 | val a = Array(0,0,x,0,0) 10 | a(2) 11 | } ensuring(_ >= 0) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/Array5.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Array5 { 6 | 7 | def foo(): Int = { 8 | val x = 10 9 | val a = Array(0,0,x,0,0) 10 | a(2) 11 | } ensuring(_ >= 0) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/ArrayLiterals.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object ArrayLiterals { 6 | def foo(): Int = { 7 | val b : Array[Int] = Array[Int](1,2,3) 8 | val a : Array[Int] = Array(1,2,3) 9 | a.length 10 | } ensuring { _ > 0 } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/BVDivisionByZero.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | import stainless.collection._ 5 | import stainless._ 6 | 7 | object BVDivisionByZero { 8 | 9 | def noDivByZero(x: Int): Boolean = { 10 | (x / 10 == 10) 11 | } 12 | 13 | def noRemByZero(x: BigInt): Boolean = { 14 | (x % 10 == 10) 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/BVDivisionByZero2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | import stainless.collection._ 5 | import stainless._ 6 | 7 | object BVDivisionByZero2 { 8 | 9 | def division(x: Int, y: Int): Int = { 10 | require(y != 0) 11 | x / y 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/CallByName1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object CallByName1 { 6 | def add(a: => Int, b: => Int): Int = a + b 7 | 8 | def test(): Int = { 9 | add(1,2) 10 | } ensuring (_ == 3) 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/ChooseLIA.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object ChooseLIA { 6 | 7 | def test(x: BigInt): BigInt = { 8 | choose[BigInt]((y: BigInt) => { 9 | val z = x + 2 10 | z == y 11 | }) 12 | } ensuring(_ == x + 2) 13 | 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/Closures.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object Closures { 6 | def addX(x: Int): Int => Int = { 7 | (a: Int) => a + x 8 | } 9 | 10 | def test(x: Int): Boolean = { 11 | val add1 = addX(1) 12 | val add2 = addX(2) 13 | add1(add2(1)) == 4 14 | }.holds 15 | } 16 | 17 | // vim: set ts=4 sw=4 et: 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/ConcreteClass.scala: -------------------------------------------------------------------------------- 1 | case class ConcreteClass() { 2 | def f() = 0 3 | def g() = { 4 | assert(f() == 0) 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/ContainerTest.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | 3 | object ContainerTest { 4 | case class Container[@mutable T](t: T) 5 | 6 | @extern 7 | def f(b: Container[BigInt]): Unit = ??? 8 | 9 | def g(b: Container[BigInt]) = { 10 | val b0 = b 11 | f(b) 12 | assert(b == b0) // succeeds because `Container[BigInt]` is immutable 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/CopyInv.scala: -------------------------------------------------------------------------------- 1 | 2 | object CopyInv { 3 | 4 | case class Foo(x: BigInt) { 5 | require(x > 0) 6 | } 7 | 8 | def prop(foo: Foo, y: BigInt) = { 9 | require(y > 1) 10 | foo.copy(x = y) 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/EffectfulPost.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object EffectfulPost { 4 | case class Foo(var bar: Int) 5 | 6 | def mutateFoo(foo: Foo): Boolean = { 7 | foo.bar = foo.bar + 1 8 | foo.bar > 10 9 | } 10 | 11 | def test = { 12 | true 13 | } ensuring { _ => 14 | val foo = Foo(0) 15 | val after = mutateFoo(foo) 16 | after == false 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/Field1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Field1 { 4 | 5 | abstract sealed class A 6 | case class B(size: Int) extends A 7 | 8 | def foo(): Int = { 9 | val b = B(3) 10 | b.size 11 | } ensuring(_ == 3) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/Field2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Field2 { 4 | 5 | abstract sealed class A 6 | case class B(length: Int) extends A 7 | 8 | def foo(): Int = { 9 | val b = B(3) 10 | b.length 11 | } ensuring(_ == 3) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/FinalMethod.scala: -------------------------------------------------------------------------------- 1 | trait FinalMethod { 2 | final def f() = 0 3 | 4 | def g() = { 5 | assert(f() == 0) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/FoolProofAdder.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.annotation._ 4 | import stainless.lang._ 5 | 6 | object FoolProofAdder { 7 | 8 | def foolProofAdder(x: BigInt): BigInt = { 9 | require(x > 0) 10 | x + BigInt(999999) + BigInt("999999999999999") 11 | } ensuring(_ > 0) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/ForallWithBlock.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object ForallWithBlock { 4 | def g(w: BigInt) = true 5 | 6 | def f() = { 7 | assert(forall((w: BigInt) => { g(w); true })) 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/GoodInitialization.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | 3 | object GoodInitialization { 4 | case class A(x: BigInt) { 5 | val y = x 6 | val z = y + y 7 | } 8 | def f(z: BigInt) = { 9 | assert(A(21).z == 42) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/LastDynAssert.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | 3 | object LastDynAssert { 4 | @extern 5 | def dynAssert(cond: Boolean): Unit = { 6 | (??? : Unit) 7 | } ensuring(cond) 8 | 9 | def f() = { 10 | dynAssert(false) 11 | (dynAssert(false), 0) 12 | assert(false) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/ManyInvariants.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | import stainless.annotation._ 3 | 4 | object ManyInvariants { 5 | 6 | case class Foo(x: Int) { 7 | @invariant 8 | def positive = x > 0 9 | 10 | @invariant 11 | def not42 = x != 42 12 | } 13 | 14 | def test = { 15 | Foo(1) 16 | } 17 | 18 | } 19 | 20 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/MapDiff.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang._ 2 | 3 | object MapDiff { 4 | 5 | def test(m: Map[Int, Int]): Unit = { 6 | require(m.contains(1) && m.contains(2) && m.contains(3)) 7 | val m2 = m -- Set(1, 2) 8 | assert(!m2.contains(1)) 9 | assert(!m2.contains(2)) 10 | assert(m2.contains(3)) 11 | assert(m2(3) == m(3)) 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/MatchGuard.scala: -------------------------------------------------------------------------------- 1 | object MatchGuard { 2 | sealed abstract class Nat 3 | case object Zero extends Nat 4 | case class Succ(n: Nat) extends Nat 5 | 6 | def f(n: Nat): Boolean = n match { 7 | case Zero => true 8 | case Succ(n2) if { assert(n == Succ(n2)); true } => true 9 | case _ => true 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/Mean.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.annotation._ 4 | import stainless.lang._ 5 | 6 | object Mean { 7 | 8 | def mean(x: Int, y: Int): Int = { 9 | require(x <= y && x >= 0 && y >= 0) 10 | x + (y - x)/2 11 | } ensuring(m => m >= x && m <= y) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/MySet.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | 5 | object MySet { 6 | 7 | def set1(): Boolean = { 8 | val s = Set(1, 2, 3, 4) 9 | s.contains(3) 10 | }.holds 11 | 12 | def set2(): Boolean = { 13 | val s1 = Set[Int]() 14 | val s2 = Set.empty[Int] 15 | s1 == s2 16 | }.holds 17 | 18 | } 19 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/MyTuple1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object MyTuple1 { 4 | 5 | def foo(): Int = { 6 | val t = (1, true, 3) 7 | val a1 = t._1 8 | val a2 = t._2 9 | val a3 = t._3 10 | a3 11 | } ensuring( _ == 3) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/MyTuple2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object MyTuple2 { 4 | 5 | sealed abstract class A 6 | case class B(i: Int) extends A 7 | case class C(a: A) extends A 8 | 9 | def foo(): Int = { 10 | val t = (B(2), C(B(3))) 11 | t match { 12 | case (B(x), C(y)) => x 13 | } 14 | } ensuring(_ == 2) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/MyTuple3.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object MyTuple3 { 4 | 5 | def foo(): Int = { 6 | val t = ((2, 3), true) 7 | t._1._2 8 | } ensuring( _ == 3) 9 | 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/MyTuple4.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | 4 | object MyTuple4 { 5 | 6 | sealed abstract class A 7 | case class B(i: Int) extends A 8 | case class C(a: A) extends A 9 | 10 | def foo(): Int = { 11 | val t = (1, (C(B(4)), 2), 3) 12 | val (a1, (C(B(x)), a2), a3) = t 13 | x 14 | } ensuring( _ == 4) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/MyTuple6.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object MyTuple6 { 4 | 5 | def foo(t: (Int, Int)): (Int, Int) = { 6 | require(t._1 > 0 && t._2 > 1) 7 | t 8 | } ensuring(res => res._1 > 0 && res._2 > 1) 9 | 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/Nested1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Nested1 { 4 | 5 | def foo(i: Int): Int = { 6 | val n = i 7 | def rec1(j: Int) = i + j + n 8 | def rec2(j: Int) = { 9 | def rec3(k: Int) = k + j + i 10 | rec3(5) 11 | } 12 | rec2(2) 13 | } ensuring(i + 7 == _) 14 | 15 | } 16 | 17 | // vim: set ts=4 sw=4 et: 18 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/Nested10.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Nested10 { 4 | 5 | def foo(i: Int): Int = { 6 | val n = 2 7 | def rec1(j: Int) = { 8 | i + j + n 9 | } 10 | def rec2(j: Int) = { 11 | rec1(j) 12 | } 13 | rec2(2) 14 | } ensuring(i + 4 == _) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/Nested11.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Nested11 { 4 | 5 | sealed abstract class A 6 | case class B(b: Int) extends A 7 | 8 | def foo(i: Int): Int = { 9 | val b: A = B(3) 10 | def rec1(j: Int) = b match { 11 | case B(b) => i + j + b 12 | } 13 | rec1(2) 14 | } ensuring(i + 5 == _) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/Nested18.scala: -------------------------------------------------------------------------------- 1 | object Nested18 { 2 | 3 | def test(a: BigInt): BigInt = { 4 | require(a > 0) 5 | def f(b: BigInt): BigInt = { 6 | def g(c: BigInt): BigInt = { 7 | require(a > 0) 8 | c 9 | } 10 | g(b) 11 | } 12 | f(12) 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/Nested2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Nested2 { 4 | 5 | def foo(a: BigInt): BigInt = { 6 | require(a >= 0) 7 | val b = a + 2 8 | def rec1(c: BigInt): BigInt = { 9 | require(c >= 0) 10 | b + c 11 | } 12 | rec1(2) 13 | } ensuring(_ > 0) 14 | 15 | } 16 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/Nested5.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Nested5 { 4 | 5 | def foo(a: Int): Int = { 6 | require(a >= 0) 7 | def bar(b: Int): Int = { 8 | require(b > 0) 9 | b + 3 10 | } ensuring(a >= 0 && _ == b + 3) 11 | bar(2) 12 | } ensuring(a >= 0 && _ == 5) 13 | 14 | } 15 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/Opaque.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | import stainless.collection._ 3 | 4 | object Opaque { 5 | 6 | @opaque 7 | def size[A](list: List[A]): BigInt = (list match { 8 | case x :: xs => 1 + size(xs) 9 | case _ => BigInt(0) 10 | }) ensuring (_ >= BigInt(0)) 11 | 12 | } 13 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/PureMethods.scala: -------------------------------------------------------------------------------- 1 | trait PureMethods { 2 | def f(): BigInt 3 | 4 | def g() = { 5 | val a = f() 6 | val b = f() 7 | assert(a == b) 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/README: -------------------------------------------------------------------------------- 1 | This particular directory contains PureScala programs that can be entirely 2 | proved correct by Stainless. 3 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/RealDivisionByZero.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | import stainless.lang._ 4 | import stainless.collection._ 5 | import stainless._ 6 | 7 | object RealDivisionByZero { 8 | 9 | def noDivByZero(x: Real): Boolean = { 10 | (x / Real(10) == Real(10)) 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/StaticChecks1.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang.StaticChecks._ 2 | 3 | object StaticChecks1 { 4 | 5 | def add(n: BigInt, m: BigInt): BigInt = { 6 | require(n >= 0 && m >= 0) 7 | if(m == 0) n else add(n, m-1) + 1 8 | } ensuring((res: BigInt) => res >= 0) 9 | 10 | } 11 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/StaticChecks2.scala: -------------------------------------------------------------------------------- 1 | import stainless.lang.StaticChecks._ 2 | 3 | object StaticChecks2 { 4 | 5 | def add(n: BigInt, m: BigInt): BigInt = { 6 | require(n >= 0 && m >= 0) 7 | var res = if(m == 0) n else add(n, m-1) + 1 8 | assert(res >= 0) 9 | res 10 | } ensuring((res: BigInt) => res >= 0) 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/Unit1.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Unit1 { 4 | 5 | def foo(): Unit = ({ 6 | () 7 | }) ensuring(r => true) 8 | 9 | } 10 | -------------------------------------------------------------------------------- /frontends/benchmarks/verification/valid/Unit2.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | object Unit2 { 4 | 5 | def foo(u: Unit): Unit = { 6 | u 7 | } ensuring(res => true) 8 | 9 | } 10 | -------------------------------------------------------------------------------- /frontends/common/README: -------------------------------------------------------------------------------- 1 | We include these common test sources to both the scala and dotty frontends through sbt. 2 | -------------------------------------------------------------------------------- /frontends/common/src/test/resources/AbstractValOverrides.scala: -------------------------------------------------------------------------------- 1 | 2 | object AbstractValsOverrideOk { 3 | 4 | abstract class Abs { 5 | val x: Int 6 | val y: Int 7 | def z: Int 8 | } 9 | 10 | abstract class Sub extends Abs { 11 | def z: Int = 42 12 | } 13 | 14 | case class Ok(x: Int, y: Int) extends Sub 15 | } 16 | 17 | -------------------------------------------------------------------------------- /frontends/library/stainless/io/package.scala: -------------------------------------------------------------------------------- 1 | /* Copyright 2009-2019 EPFL, Lausanne */ 2 | 3 | package stainless 4 | 5 | import scala.language.implicitConversions 6 | 7 | import stainless.annotation._ 8 | import stainless.lang.StaticChecks._ 9 | 10 | package object io { 11 | 12 | @library 13 | case class State(var seed: BigInt) 14 | 15 | @library 16 | def newState: State = State(0) 17 | } 18 | 19 | -------------------------------------------------------------------------------- /frontends/scalac/src/main/resources/scalac-plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | stainless-plugin 3 | stainless.frontends.scalac.StainlessPlugin 4 | -------------------------------------------------------------------------------- /project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.3.8 2 | -------------------------------------------------------------------------------- /project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.3.2") 2 | 3 | addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0") 4 | 5 | addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.3") 6 | 7 | addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0") 8 | 9 | addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.4.0") 10 | 11 | addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.5") 12 | -------------------------------------------------------------------------------- /sbt-plugin/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.3.0 2 | -------------------------------------------------------------------------------- /sbt-plugin/src/sbt-test/sbt-plugin/ghost/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.3.0 2 | -------------------------------------------------------------------------------- /sbt-plugin/src/sbt-test/sbt-plugin/ghost/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("ch.epfl.lara" % "sbt-stainless" % sys.props("plugin.version")) -------------------------------------------------------------------------------- /sbt-plugin/src/sbt-test/sbt-plugin/ghost/test: -------------------------------------------------------------------------------- 1 | > basic/run 2 | $ exists basic/target/scala-2.12/classes/test/Main.class 3 | $ absent basic/target/sneakyGhostCalled basic/target/insideGhostCalled 4 | > actor-tests/compile 5 | -------------------------------------------------------------------------------- /sbt-plugin/src/sbt-test/sbt-plugin/simple/failure/src/main/scala/BadPre1.scala: -------------------------------------------------------------------------------- 1 | import stainless.annotation._ 2 | import stainless.lang._ 3 | 4 | object BadPre1 { 5 | def reqreq(x: BigInt, y: BigInt): BigInt = { 6 | require(x > 0) 7 | require(y > 0) // should be rejected 8 | x + y 9 | } ensuring { _ > 0 } 10 | } 11 | -------------------------------------------------------------------------------- /sbt-plugin/src/sbt-test/sbt-plugin/simple/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("ch.epfl.lara" % "sbt-stainless" % sys.props("plugin.version")) -------------------------------------------------------------------------------- /sbt-plugin/src/sbt-test/sbt-plugin/simple/success/src/main/scala/ADTInvariants1.scala: -------------------------------------------------------------------------------- 1 | 2 | object ADTInvariants1 { 3 | 4 | case class Positive(i: BigInt) { 5 | require(i > 0) 6 | } 7 | 8 | def theorem(f: Positive => Positive) = { 9 | f(Positive(1)) 10 | } ensuring(res => res.i > 0) 11 | } 12 | -------------------------------------------------------------------------------- /sbt-plugin/src/sbt-test/sbt-plugin/simple/test: -------------------------------------------------------------------------------- 1 | > assertLogMessage 2 | > success/compile 3 | # check that a module on which stainless verification passes compiles fine (i.e., binaries are produced) 4 | $ exists success/target/scala-2.12/classes/Extern1.class 5 | # > failure/checkScalaFailures 6 | -------------------------------------------------------------------------------- /slc-lib/_CoqProject: -------------------------------------------------------------------------------- 1 | -Q . SLC 2 | -------------------------------------------------------------------------------- /slc-lib/configure: -------------------------------------------------------------------------------- 1 | coq_makefile -Q . SLC *.v -o Makefile TIMED = true TIMEFMT = "\"\$*: %es\"" 2 | -------------------------------------------------------------------------------- /stainless.conf.default: -------------------------------------------------------------------------------- 1 | # The settings below correspond to the various 2 | # options listed by `stainless --help` 3 | 4 | vc-cache = true 5 | debug = ["verification"] 6 | timeout = 30 7 | check-models = true 8 | print-ids = false 9 | print-types = false 10 | batched = true 11 | -------------------------------------------------------------------------------- /unmanaged/scalaz3-mac-64-2.12.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/unmanaged/scalaz3-mac-64-2.12.jar -------------------------------------------------------------------------------- /unmanaged/scalaz3-unix-64-2.12.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epfl-lara/smart/28fed34c645f52b4d4e0551798d5dae26d546908/unmanaged/scalaz3-unix-64-2.12.jar --------------------------------------------------------------------------------