File: test.vpr

package info (click to toggle)
kf6-syntax-highlighting 6.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 47,568 kB
  • sloc: xml: 197,750; cpp: 12,850; python: 3,023; sh: 955; perl: 546; ruby: 488; pascal: 393; javascript: 161; php: 150; jsp: 132; lisp: 131; haskell: 124; ada: 119; ansic: 107; makefile: 96; f90: 94; ml: 85; cobol: 81; yacc: 71; csh: 62; erlang: 54; sql: 51; java: 47; objc: 37; awk: 31; asm: 30; tcl: 29; fortran: 18; cs: 10
file content (151 lines) | stat: -rw-r--r-- 2,738 bytes parent folder | download
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import "foo.tdf"
import "foo.txt"
import "foo.txt"

domain Foo[T] {
    axiom named { forall x: Int:: {lookup(x)} len(lookup(x)) == foobar(x) }
    axiom { forall x: Int :: {lookup(x)} {len(lookup(x))} len(lookup(x)) == foobar(x) } // anonymous
}

// this is a comment

/* This is also
 * another multi-line comment
 * With a string "string" and
 * an import "foo.bar" inside */

// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/publicdomain/zero/1.0/

import "empty.sil"

method test1(xs: Seq[Ref]) {
  inhale forall i: Int :: 0 <= i && i < |xs| ==> xs[i].f != 0
}

function $(n: Ref, m: Ref): Node

domain Foo[T] {
    function enc(arg: T): Foo[T]
    function dec(arg: Foo[T]): T

    axiom ax_Dec {
        forall arg: T ::
            dec( enc(arg) ) == arg
    }

    axiom ax_Enc {
        forall arg: Foo[T] ::
        { enc( dec(arg) ), foo(bar, i) }
            {  dec(arg) }
                enc( dec(arg) ) == arg
    }
}

function myFunc(arg: Int): Int
    requires true || false
    ensures arg <= 0 ==> result == -1
    ensures arg > 0  ==> result == arg
{
    arg > 0 ? arg : myFunc(arg - 1)
}

field value: Int
field next: Ref

predicate list(xs: Ref) {
    acc(xs.value) && acc(xs.next)
    && ( list(xs.next) )
}

define myPureMacro(abc) abc

define myStmtMacro(abc) {
    inhale abc
    exhale abc
}

method smokeTest() {

    inhale false; exhale false
    assume false; assert false

    //magic wands
    var s: Set[Int]
    assert s setminus s != s

}

//:: special comment
/*
        gfdgfd
*/

method testHighlights() returns ( res: Set[Seq[Multiset[Foo[Int]]]] )
    requires true
    ensures false
{
    var a: Int; var b: Bool; var c: Ref; var d: Rational; var e: Perm
    var x: Seq[Int]; var y: Set[Int]; var z: Multiset[Int]
    var t1: Set[Int] := Set(a, 1, 2)
    var t2: Seq[Int] := Seq(a, a, a)
    var t3: Multiset[Int] := Multiset(a, a, 0, 0, 0)

    assert myFunc(331) > -2

    myStmtMacro( myFunc(331) == -331 )

    while ( true )
        invariant true
    {
        var aa: Ref
        aa := null
        var bb: Int
        bb := 33
    }

    if ( true ) {
        assert true
    } elseif ( false ) {
        assert false
    } else {
        assert true
    }

    //forperm r: Ref :: true
    //exists
    //forall
    assert ! false
    assert 0  +321 - 0 -321 == 0
}

field f:Int

method test02(x: Ref)
  requires acc(x.f, write)
  ensures acc(x.f, write)
{
  define A true
  define B acc(x.f, write)

  package A --* B
  wand w := A --* B

  //apply w

    label my_lbl

    goto my_lbl

    fresh x

    var p: Perm

    var r: Ref; r := new (*)

    constraining ( p ) {
        exhale acc(x.f, p)
    }

    assert 0 == ( let a == (11 + 22) in a+a )
}