summaryrefslogtreecommitdiff
path: root/Test/dafny0/ExistentialGuards.dfy
blob: 001acb554e91a4d5212057af93c2e94e62b6c4c3 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// RUN: %dafny /dprint:- "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

predicate P(n: int)

predicate R(r: real)

method M0()
{
  if x :| P(x) {
  }
}

method M1()
{
  if x: int :| P(x) {
  }
}

method M2()
{
  if x, y :| P(x) && R(y) {
  }
}

method M3()
{
  if x: int, y :| P(x) && R(y) {
  }
}

method M4()
{
  if x, y: real :| P(x) && R(y) {
  }
}

method M5()
{
  if x: int, y: real :| P(x) && R(y) {
  }
}

method M6()
{
  if x {:myattribute x, "hello"} :| P(x) {
  }
  if x, y {:myattribute y, "sveika"} :| P(x) && R(y) {
  }
  if x: int {:myattribute x, "chello"} :| P(x) {
  }
  if x {:myattribute x, "hola"} {:yourattribute x + x, "hej"} :| P(x) {
  }
}

method M7()
{
  if x :| P(x) {
  } else if * {
  } else if y :| R(y) {
  } else if y :| P(y) {
  }
}

method P0(m: int, n: int)
  requires m < n
{
  if {
    case x :| P(x) =>
    case x: int :| P(x) =>
    case x, y :| P(x) && R(y) =>
    case x: int, y :| P(x) && R(y) =>
    case m < n =>  // just to be different
    case x, y: real :| P(x) && R(y) =>
    case x: int, y: real :| P(x) && R(y) =>
  }
}

method P1(m: int, n: int)
  requires m < n
{
  if {
    case x {:myattribute x, "hello"} :| P(x) =>
    case x, y {:myattribute y, "sveika"} :| P(x) && R(y) =>
    case x: int {:myattribute x, "chello"} :| P(x) =>
    case x {:myattribute x, "hola"} {:yourattribute x + x, "hej"} :| P(x) =>
    case m < n =>
  }
}