Ask Your Question

Revision history [back]

In Dafny, you can export members of a module by using the "export" keyword before the declaration of the member. For example, to export a function named Add from a module named MyModule, you would write:

module MyModule {
  export function Add(x: int, y: int): int
  {
    return x + y;
  }
}

This would allow you to use the Add function in other modules that have imported MyModule. You can import modules in Dafny using the "import" keyword followed by the name of the module. For example:

import MyModule;

method Main() {
  var sum := MyModule.Add(2, 3);
  assert sum == 5;
}

Here, we import the MyModule and use the exported Add function to compute the sum of 2 and 3.