Questions tagged [spark-ada]

SPARK is a programming language developed to allow formal proof of the absence of run-time errors. SPARK overlaps sufficiently with Ada that all SPARK programs can be compiled with an Ada compiler.

SPARK Ada is a subset of the Ada programming language, and a toolkit, that supports formal proof. It is intended for use in systems that require high reliability and integrity.

54 questions
2
votes
3 answers

No Global Contract available for procedure / function

I've got a procedure within a SPARK module that calls the standard Ada-Text_IO.Put_Line. During proving I get the following warning warning: no Global contract available for "Put_Line". I do already know how to add the respective data dependency…
Simon
  • 594
  • 1
  • 6
  • 13
2
votes
1 answer

Tasking in SPARK requires sequential elaboration

I'm currently learning Ada during a university course on real-time programming languages and have a question about SPARK. I'm working on a project with a task that monitors an off-grid power supply. This task is crucial for machine safety and should…
Simon
  • 594
  • 1
  • 6
  • 13
1
vote
1 answer

How do I convince GNATprove that calling Integer'Value on the same input twice should produce the same result?

When parsing an integer from the same string twice, GNATprove doesn't accept that the same integer should be produced twice. How should I rectify this? Main file: with String_Problem; procedure Eq_Test is begin …
user3519580
  • 317
  • 2
  • 8
1
vote
2 answers

(SPARK Ada) Digits given as a element of type digits in range 0-9?

I am trying to create a decrement program in SPARK Ada. D1 to D3 are the input digits entered by the user and the program asks to decrement a 3 digit number by one and output 3 digits O1, O2, O3. I am not sure how to modify this to element of type…
Danny
  • 21
  • 4
1
vote
2 answers

How do I initialize a custom array type from the main file in Ada

I am an Ada noob, and am writing a simple function that takes a list of integers and decrements each element by 1. My bronze mode proof passes ok but trying to actually use the function in the main to see if it is actually doing what it is supposed…
HubertBlu
  • 747
  • 1
  • 7
  • 20
1
vote
1 answer

Create generic constrained array type in SPARK Ada

I would like to make a procedure to accept generic constrained arrays i.e. both ecgReadings and eegReadings: Types declarations: subtype ecgReadingsSize is Natural range 1..3; subtype eegReadingsSize is Natural range 1..10; subtype…
1
vote
3 answers

Ada GNATprove Command_Line.Argument precondition fail

I'm trying to write a simple verification code block to ensure the argument(Ada.Command_Line.Argument) and input from GetLine are valid, which in my case, I need all the characters in the input String to be numbers (0 to 9). main.adb: pragma…
Xixiang Wu
  • 33
  • 1
  • 3
1
vote
1 answer

Ravenscar Task / Program Termination in Native Compilation

As I understand it, one restriction of the Ravenscar profile is that tasks should not terminate. This certainly makes sense on bare metal, however when testing on a native system (as a executable program) it has the side effect that doing a…
jsinglet
  • 1,151
  • 7
  • 8
1
vote
1 answer

How to perform arithmetic contract operations on function taking in 2D array type as parameter in Ada

I have a function that should return the count of Islands found. I name this function Count_Islands that takes in a parameter of Map_Array of type Map, of which Map is an array of Islands. Islands is an enumerator type with set of Land, Water. I…
Simple_tech
  • 39
  • 10
1
vote
1 answer

How to write semantics in K framework for a language similar to ada-spark

I am working with K framework and trying to write semantics for a language similar to ada-spark and in that, I want to write semantics that involves allocation of memory and value when I declare an integer variable itself. Also for the same…
1
vote
1 answer

How to use Assert and loop_invariants

Specification: package PolyPack with SPARK_Mode is type Vector is array (Natural range <>) of Integer; function RuleHorner (X: Integer; A : Vector) return Integer with Pre => A'Length > 0 and A'Last < Integer'Last; end PolyPack ; I want to write…
1
vote
3 answers

Verifying loop termination

I want to prove that the loop in this procedure will terminate using the variant ( bound function) the variant will be I and the lower bound is 0 (I: = 0) on each repetition, the size of I will decrease till reached to lower bound 0 How can I prove…
Memo
  • 53
  • 6
1
vote
1 answer

Call to a volatile function in interfering context is not allowed in SPARK

I'm currently learning Ada during a university course on real-time programming languages and have a question about SPARK. I'm working on a project with a task that monitors an off-grid power supply. This task is crucial for machine safety and should…
Simon
  • 594
  • 1
  • 6
  • 13
1
vote
2 answers

Instantiating non-library-level package in SPARK Ada

How do I instantiate a non-library-level package in SPARK Ada? Say I have something like: subtype Die is Integer range 1..6; package Random_Die is new Ada.Numerics.Discrete_Random(Die); That gives me the errors: instantiation error at…
digitig
  • 1,989
  • 3
  • 25
  • 45
1
vote
1 answer

GNATprove: "postcondition might fail" in simple function

I want to write a simple function that finds the biggest number in given Integer array. Here is specification: package Maximum with SPARK_Mode is type Vector is array(Integer range <>) of Integer; function Maximum (A : in Vector) return…