summaryrefslogtreecommitdiff
path: root/Test/dafny0/TypeSynonyms.dfy
blob: 85beb3404e0ed0337347672fd18740e3b15b153b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// RUN: %dafny /compile:0 /print:"%t.print" /dprint:"%t.dprint" "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

type MyType<A> = int

type Int = int

type PairaBools = (bool, bool)

datatype List<T> = Nil | Cons(T, List)

type Synonym0<T,U> = List<T>

type Synonym1<T> = List  // type argument of List filled in automatically

type Synonym2<A> = List<A>

type Synonym3<B> = Synonym4

type Synonym4<C> = Synonym2<C>

type Synonym5<A,B> = List

function Plus(x: Int, y: int): Int
{
  x + y
}

method Next(s: Synonym1) returns (u: Synonym1)
{
  match s
  case Nil => u := Nil;
  case Cons(_, tail) => u := tail;
}

method Add<W>(t: W, s: Synonym1) returns (u: Synonym1)
{
  u := Cons(t, Nil);
}

function Skip(s: Synonym3): Synonym0
{
  match s
  case Nil => Nil
  case Cons(_, tail) => tail
}

type MyMap = map<int, map<real, bool>>

predicate MyMapProperty(m: MyMap, x: int)
{
  x in m && real(x) in m[x] && m[x][real(x)]
}