packages feed

funcons-simple (empty) → 0.1.0.3

raw patch · 172 files changed

+6907/−0 lines, 172 filesdep +basedep +funcons-toolsdep +funcons-valuessetup-changed

Dependencies added: base, funcons-tools, funcons-values

Files

+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2015 L. Thomas van Binsbergen++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ funcons-simple.cabal view
@@ -0,0 +1,47 @@+-- Initial funcons-simple.cabal generated by cabal init.  For further +-- documentation, see http://haskell.org/cabal/users-guide/++name:                funcons-simple+version:             0.1.0.3+synopsis:            A modular interpreter for executing SIMPLE funcons +description:         +    The PLanCompS (<http://plancomps.org>) project has developed a component-based approach to formal semantics.+    A reusable component of language definition corresponds to a fundamental +    programming construct: a `funcon', which has a fixed operational interpretation.++    This package provides an interpreter for the funcons of SIMPLE <https://plancomps.github.io/CBS-beta/Languages-beta/SIMPLE/> extending the interpreter for the reusable funcons of /funcons-tools/ <https://hackage.haskell.org/package/funcons-tools>+    +homepage:            https://plancomps.github.io/CBS-beta/Languages-beta/SIMPLE/+license:             MIT+license-file:        LICENSE+author:              L. Thomas van Binsbergen and Neil Sculthorpe+maintainer:          L. Thomas van Binsbergen <ltvanbinsbergen@acm.org>+copyright:           Copyright (C) 2015 L. Thomas van Binsbergen and Neil Sculthorpe+category:            Compilers/Interpreters+-- copyright:           +build-type:          Simple+extra-source-files:   tests/Advanced/*.smp,+                      tests/Advanced/*.fct, +                      tests/Advanced/*.output, +                      tests/Basic/*.smp, +                      tests/Basic/*.fct, +                      tests/Basic/*.output,+                      tests/Kdiverse/*.smp,+                      tests/Kdiverse/*.fct,+                      tests/Kdiverse/*.output,+                      tests/Kdiverse/*.config,+                      tests/Kexceptions/*.smp +                      tests/Kexceptions/*.fct+                      tests/Kexceptions/*.output+                      tests/SIMPLE.config+                      tests/SIMPLE-interactive.config+                      tests/README.txt+cabal-version:       >=1.10++executable runfct-SIMPLE +  main-is:             Main.hs+  other-modules:       Funcons.SIMPLE.SIMPLE4Declarations.SIMPLE4Declarations, Funcons.SIMPLE.Library +  -- other-extensions:    +  build-depends:       base >=4.8 && <=5, funcons-tools >= 0.2.0.5, funcons-values >= 0.1.0.3+  hs-source-dirs:      src+  default-language:    Haskell2010
+ src/Funcons/SIMPLE/Library.hs view
@@ -0,0 +1,19 @@+module Funcons.SIMPLE.Library (+    funcons, entities, types,+   module Funcons.SIMPLE.SIMPLE4Declarations.SIMPLE4Declarations,+    ) where +import Funcons.EDSL+import Funcons.SIMPLE.SIMPLE4Declarations.SIMPLE4Declarations hiding (funcons,types,entities)+import qualified Funcons.SIMPLE.SIMPLE4Declarations.SIMPLE4Declarations+funcons = libUnions+    [+     Funcons.SIMPLE.SIMPLE4Declarations.SIMPLE4Declarations.funcons+    ]+entities = concat +    [+     Funcons.SIMPLE.SIMPLE4Declarations.SIMPLE4Declarations.entities+    ]+types = typeEnvUnions +    [+     Funcons.SIMPLE.SIMPLE4Declarations.SIMPLE4Declarations.types+    ]
+ src/Funcons/SIMPLE/SIMPLE4Declarations/SIMPLE4Declarations.hs view
@@ -0,0 +1,27 @@+-- GeNeRaTeD fOr: ../SIMPLE-cbs/SIMPLE//SIMPLE-4-Declarations/SIMPLE-4-Declarations.cbs+{-# LANGUAGE OverloadedStrings #-}++module Funcons.SIMPLE.SIMPLE4Declarations.SIMPLE4Declarations where++import Funcons.EDSL++import Funcons.Operations hiding (Values,libFromList)+entities = []++types = typeEnvFromList+    []++funcons = libFromList+    [("allocate-nested-vectors",StrictFuncon stepAllocate_nested_vectors)]++allocate_nested_vectors_ fargs = FApp "allocate-nested-vectors" (fargs)+stepAllocate_nested_vectors fargs =+    evalRules [rewrite1,rewrite2] []+    where rewrite1 = do+            let env = emptyEnv+            env <- vsMatch fargs [VPAnnotated (VPMetaVar "N") (TName "nats")] env+            rewriteTermTo (TApp "allocate-initialised-variable" [TApp "vectors" [TName "variables"],TApp "vector" [TApp "left-to-right-repeat" [TApp "allocate-variable" [TName "values"],TFuncon (FValue (Nat 1)),TVar "N"]]]) env+          rewrite2 = do+            let env = emptyEnv+            env <- vsMatch fargs [VPAnnotated (VPMetaVar "N") (TName "nats"),VPAnnotated (VPSeqVar "N+" PlusOp) (TSortSeq (TName "nats") PlusOp)] env+            rewriteTermTo (TApp "allocate-initialised-variable" [TApp "vectors" [TName "variables"],TApp "vector" [TApp "left-to-right-repeat" [TApp "allocate-nested-vectors" [TVar "N+"],TFuncon (FValue (Nat 1)),TVar "N"]]]) env
+ src/Main.hs view
@@ -0,0 +1,3 @@+import Funcons.Tools (mkMainWithLibraryEntitiesTypes)+import Funcons.SIMPLE.Library+main = mkMainWithLibraryEntitiesTypes funcons entities types
+ tests/Advanced/Advanced1.fct view
@@ -0,0 +1,45 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("fact",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (print (apply+           (assigned (bound ("fact")),+            tuple (decimal-natural ("5")))))))),+   assign+     (bound ("fact"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("n",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (if-else+           (is-equal+             (assigned (bound ("n")),+              decimal-natural ("1")),+            return (decimal-natural ("1")),+            return (integer-multiply+              (assigned (bound ("n")),+               apply+                 (assigned (bound ("fact")),+                  tuple (integer-subtract+                    (assigned (bound ("n")),+                     decimal-natural ("1"))))))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Advanced/Advanced1.output view
@@ -0,0 +1,19 @@+=== Program ===+function main () {+	print(fact(5));+}++function fact(n) {+	if (n == 1) {+		return 1;+	} else {+		return (n * fact(n-1));+	}+}+=== Output ===+Result:+null-value++Output Entity: standard-out+120+
+ tests/Advanced/Advanced1.smp view
@@ -0,0 +1,11 @@+function main () {+	print(fact(5));+}++function fact(n) {+	if (n == 1) {+		return 1;+	} else {+		return (n * fact(n-1));+	}+}
+ tests/Advanced/Advanced2.fct view
@@ -0,0 +1,54 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("fib",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (print (apply+           (assigned (bound ("fib")),+            tuple (decimal-natural ("6")))))))),+   assign+     (bound ("fib"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("n",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (if-else+           (is-equal+             (assigned (bound ("n")),+              decimal-natural ("0")),+            return (decimal-natural ("0")),+            if-else+              (is-equal+                (assigned (bound ("n")),+                 decimal-natural ("1")),+               return (decimal-natural ("1")),+               return (integer-add+                 (apply+                   (assigned (bound ("fib")),+                    tuple (integer-subtract+                      (assigned (bound ("n")),+                       decimal-natural ("1")))),+                  apply+                    (assigned (bound ("fib")),+                     tuple (integer-subtract+                       (assigned (bound ("n")),+                        decimal-natural ("2")))))))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Advanced/Advanced2.output view
@@ -0,0 +1,23 @@+=== Program ===+function main () {+	print(fib(6));+}++function fib(n) {+	if (n == 0) {+		return 0;+	} else {+		if (n == 1) {+			return 1;+		} else {+			return (fib(n-1) + fib(n-2));+		}+	}+}+=== Output ===+Result:+null-value++Output Entity: standard-out+8+
+ tests/Advanced/Advanced2.smp view
@@ -0,0 +1,15 @@+function main () {+	print(fib(6));+}++function fib(n) {+	if (n == 0) {+		return 0;+	} else {+		if (n == 1) {+			return 1;+		} else {+			return (fib(n-1) + fib(n-2));+		}+	}+}
+ tests/Advanced/Advanced3.fct view
@@ -0,0 +1,208 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("insertion_sort",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("a",+              allocate-nested-vectors (decimal-natural ("5"))),+            sequential+              (effect (give+                (decimal-natural ("5"),+                 sequential+                   (assign+                     (checked index+                       (integer-add+                         (1,+                          decimal-natural ("0")),+                        vector-elements (assigned (bound ("a")))),+                      given),+                    given))),+               effect (give+                 (decimal-natural ("4"),+                  sequential+                    (assign+                      (checked index+                        (integer-add+                          (1,+                           decimal-natural ("1")),+                         vector-elements (assigned (bound ("a")))),+                       given),+                     given))),+               effect (give+                 (decimal-natural ("1"),+                  sequential+                    (assign+                      (checked index+                        (integer-add+                          (1,+                           decimal-natural ("2")),+                         vector-elements (assigned (bound ("a")))),+                       given),+                     given))),+               effect (give+                 (decimal-natural ("8"),+                  sequential+                    (assign+                      (checked index+                        (integer-add+                          (1,+                           decimal-natural ("3")),+                         vector-elements (assigned (bound ("a")))),+                       given),+                     given))),+               effect (give+                 (decimal-natural ("7"),+                  sequential+                    (assign+                      (checked index+                        (integer-add+                          (1,+                           decimal-natural ("4")),+                         vector-elements (assigned (bound ("a")))),+                       given),+                     given))),+               effect (apply+                 (assigned (bound ("insertion_sort")),+                  tuple (assigned (bound ("a"))))),+               scope+                 (bind+                   ("i",+                    allocate-initialised-variable+                      (values,+                       decimal-natural ("0"))),+                  while+                    (is-less+                      (assigned (bound ("i")),+                       length (vector-elements (assigned (bound ("a"))))),+                     sequential+                       (print (assigned (checked index+                         (integer-add+                           (1,+                            assigned (bound ("i"))),+                          vector-elements (assigned (bound ("a")))))),+                        effect (give+                          (bound ("i"),+                           sequential+                             (assign+                               (given,+                                integer-add+                                  (assigned (given),+                                   1)),+                              assigned (given))))))))))))),+   assign+     (bound ("insertion_sort"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("a",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (scope+           (bind+             ("i",+              allocate-initialised-variable+                (values,+                 decimal-natural ("1"))),+            while+              (is-less+                (assigned (bound ("i")),+                 length (vector-elements (assigned (bound ("a"))))),+               sequential+                 (scope+                   (bind+                     ("val_i",+                      allocate-initialised-variable+                        (values,+                         assigned (checked index+                           (integer-add+                             (1,+                              assigned (bound ("i"))),+                            vector-elements (assigned (bound ("a"))))))),+                    scope+                      (bind+                        ("j",+                         allocate-initialised-variable+                           (values,+                            assigned (bound ("i")))),+                       sequential+                         (while+                           (if-else+                             (is-greater+                               (assigned (bound ("j")),+                                decimal-natural ("0")),+                              is-less+                                (assigned (bound ("val_i")),+                                 assigned (checked index+                                   (integer-add+                                     (1,+                                      integer-subtract+                                        (assigned (bound ("j")),+                                         decimal-natural ("1"))),+                                    vector-elements (assigned (bound ("a")))))),+                              false),+                            sequential+                              (effect (give+                                (assigned (checked index+                                  (integer-add+                                    (1,+                                     integer-subtract+                                       (assigned (bound ("j")),+                                        decimal-natural ("1"))),+                                   vector-elements (assigned (bound ("a"))))),+                                 sequential+                                   (assign+                                     (checked index+                                       (integer-add+                                         (1,+                                          assigned (bound ("j"))),+                                        vector-elements (assigned (bound ("a")))),+                                      given),+                                    given))),+                               effect (give+                                 (integer-subtract+                                   (assigned (bound ("j")),+                                    decimal-natural ("1")),+                                  sequential+                                    (assign+                                      (bound ("j"),+                                       given),+                                     given))))),+                          effect (give+                            (assigned (bound ("val_i")),+                             sequential+                               (assign+                                 (checked index+                                   (integer-add+                                     (1,+                                      assigned (bound ("j"))),+                                    vector-elements (assigned (bound ("a")))),+                                  given),+                                given)))))),+                  effect (give+                    (bound ("i"),+                     sequential+                       (assign+                         (given,+                          integer-add+                            (assigned (given),+                             1)),+                        assigned (given))))))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Advanced/Advanced3.output view
@@ -0,0 +1,37 @@+=== Program ===+function main() {+	+	var a[5];+	+	a[0] = 5;+	a[1] = 4;+	a[2] = 1;+	a[3] = 8;+	a[4] = 7;+	+	insertion_sort(a);+	+	for (var i = 0; i < sizeOf(a) ; ++i) {+		print(a[i]);+	}+	+}++function insertion_sort(a) {+  for (var i = 1; i < sizeOf(a); ++i) {+    var val_i = a[i];+    var j = i;+    while (j > 0 && val_i < a[j-1]) {+      a[j] = a[j-1];+      j = j-1;+    }+    a[j] = val_i;+  }+}+=== Output ===+Result:+null-value++Output Entity: standard-out+1,4,5,7,8+
+ tests/Advanced/Advanced3.smp view
@@ -0,0 +1,29 @@+function main() {+	+	var a[5];+	+	a[0] = 5;+	a[1] = 4;+	a[2] = 1;+	a[3] = 8;+	a[4] = 7;+	+	insertion_sort(a);+	+	for (var i = 0; i < sizeOf(a) ; ++i) {+		print(a[i]);+	}+	+}++function insertion_sort(a) {+  for (var i = 1; i < sizeOf(a); ++i) {+    var val_i = a[i];+    var j = i;+    while (j > 0 && val_i < a[j-1]) {+      a[j] = a[j-1];+      j = j-1;+    }+    a[j] = val_i;+  }+}
+ tests/Advanced/Advanced4.fct view
@@ -0,0 +1,102 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("fib_aux",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("fib",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("fib_aux"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("i",+              allocate-initialised-variable+                (values,+                 given))),+           pattern closure (bind+             ("m",+              allocate-initialised-variable+                (values,+                 given))),+           pattern closure (bind+             ("n",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (if-else+           (is-equal+             (assigned (bound ("i")),+              decimal-natural ("1")),+            return (assigned (bound ("n"))),+            return (apply+              (assigned (bound ("fib_aux")),+               tuple (integer-subtract+                 (assigned (bound ("i")),+                  decimal-natural ("1")),+               assigned (bound ("n")),+               integer-add+                 (assigned (bound ("m")),+                  assigned (bound ("n"))))))))))),+   assign+     (bound ("fib"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("n",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (if-else+           (is-equal+             (assigned (bound ("n")),+              decimal-natural ("0")),+            return (decimal-natural ("0")),+            return (apply+              (assigned (bound ("fib_aux")),+               tuple (assigned (bound ("n")),+               decimal-natural ("0"),+               decimal-natural ("1"))))))))),+   assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("i",+              allocate-initialised-variable+                (values,+                 decimal-natural ("1"))),+            while+              (is-less+                (assigned (bound ("i")),+                 decimal-natural ("8")),+               sequential+                 (print (apply+                   (assigned (bound ("fib")),+                    tuple (assigned (bound ("i"))))),+                  effect (give+                    (bound ("i"),+                     sequential+                       (assign+                         (given,+                          integer-add+                            (assigned (given),+                             1)),+                        assigned (given))))))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Advanced/Advanced4.output view
@@ -0,0 +1,29 @@+=== Program ===+function fib_aux(i,m,n) {+	if (i == 1) {+		return n;+	} else {+		return fib_aux(i-1,n,m+n);+	}+}++function fib(n) {+	if (n == 0 ) {+		return 0;+	} else {+		return fib_aux(n,0,1);+	}+}++function main() {+	for (var i = 1 ; i < 8 ; ++i) {+		print(fib(i));+	}+}+=== Output ===+Result:+null-value++Output Entity: standard-out+1,1,2,3,5,8,13+
+ tests/Advanced/Advanced4.smp view
@@ -0,0 +1,21 @@+function fib_aux(i,m,n) {+	if (i == 1) {+		return n;+	} else {+		return fib_aux(i-1,n,m+n);+	}+}++function fib(n) {+	if (n == 0 ) {+		return 0;+	} else {+		return fib_aux(n,0,1);+	}+}++function main() {+	for (var i = 1 ; i < 8 ; ++i) {+		print(fib(i));+	}+}
+ tests/Advanced/Advanced5.fct view
@@ -0,0 +1,101 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("n",+              allocate-initialised-variable+                (values,+                 decimal-natural ("15"))),+            scope+              (bind+                ("fib",+                 allocate-nested-vectors (integer-add+                   (assigned (bound ("n")),+                    decimal-natural ("2")))),+               sequential+                 (effect (give+                   (decimal-natural ("0"),+                    sequential+                      (assign+                        (checked index+                          (integer-add+                            (1,+                             decimal-natural ("0")),+                           vector-elements (assigned (bound ("fib")))),+                         given),+                       given))),+                  effect (give+                    (decimal-natural ("1"),+                     sequential+                       (assign+                         (checked index+                           (integer-add+                             (1,+                              decimal-natural ("1")),+                            vector-elements (assigned (bound ("fib")))),+                          given),+                        given))),+                  scope+                    (bind+                      ("i",+                       allocate-initialised-variable+                         (values,+                          decimal-natural ("0"))),+                     while+                       (is-less+                         (assigned (bound ("i")),+                          assigned (bound ("n"))),+                        sequential+                          (sequential+                            (effect (give+                              (integer-add+                                (assigned (checked index+                                  (integer-add+                                    (1,+                                     assigned (bound ("i"))),+                                   vector-elements (assigned (bound ("fib"))))),+                                 assigned (checked index+                                   (integer-add+                                     (1,+                                      integer-add+                                        (assigned (bound ("i")),+                                         decimal-natural ("1"))),+                                    vector-elements (assigned (bound ("fib")))))),+                               sequential+                                 (assign+                                   (checked index+                                     (integer-add+                                       (1,+                                        integer-add+                                          (assigned (bound ("i")),+                                           decimal-natural ("2"))),+                                      vector-elements (assigned (bound ("fib")))),+                                    given),+                                  given))),+                             print (assigned (checked index+                               (integer-add+                                 (1,+                                  assigned (bound ("i"))),+                                vector-elements (assigned (bound ("fib"))))))),+                           effect (give+                             (bound ("i"),+                              sequential+                                (assign+                                  (given,+                                   integer-add+                                     (assigned (given),+                                      1)),+                                 assigned (given)))))))))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Advanced/Advanced5.output view
@@ -0,0 +1,21 @@+=== Program ===+function main() {+	+	var n = 15;+	+	var fib[n+2];+	+	fib[0] = 0;+	fib[1] = 1;+	+	for(var i=0; i<n; ++i) {+		fib[i+2] = fib[i] + fib[i+1];+		print(fib[i]);+	}+}=== Output ===+Result:+null-value++Output Entity: standard-out+0,1,1,2,3,5,8,13,21,34,55,89,144,233,377+
+ tests/Advanced/Advanced5.smp view
@@ -0,0 +1,14 @@+function main() {+	+	var n = 15;+	+	var fib[n+2];+	+	fib[0] = 0;+	fib[1] = 1;+	+	for(var i=0; i<n; ++i) {+		fib[i+2] = fib[i] + fib[i+1];+		print(fib[i]);+	}+}
+ tests/Basic/Basic01.fct view
@@ -0,0 +1,16 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (null)))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic01.output view
@@ -0,0 +1,6 @@+=== Program ===+function main() { }+=== Output ===+Result:+null-value+
+ tests/Basic/Basic01.smp view
@@ -0,0 +1,1 @@+function main() { }
+ tests/Basic/Basic02.fct view
@@ -0,0 +1,16 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (return (decimal-natural ("0")))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic02.output view
@@ -0,0 +1,8 @@+=== Program ===+function main() {+  return 0;+}+=== Output ===+Result:+0+
+ tests/Basic/Basic02.smp view
@@ -0,0 +1,3 @@+function main() {+  return 0;+}
+ tests/Basic/Basic03.fct view
@@ -0,0 +1,22 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("x",+              allocate-initialised-variable+                (values,+                 decimal-natural ("1"))),+            return (assigned (bound ("x")))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic03.output view
@@ -0,0 +1,9 @@+=== Program ===+function main() {+  var x = 1;+  return x;+}+=== Output ===+Result:+1+
+ tests/Basic/Basic03.smp view
@@ -0,0 +1,4 @@+function main() {+  var x = 1;+  return x;+}
+ tests/Basic/Basic04.fct view
@@ -0,0 +1,26 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("x",+              allocate-variable (values)),+            scope+              (bind+                ("y",+                 allocate-variable (values)),+               effect (bind+                 ("z",+                  allocate-variable (values))))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic04.output view
@@ -0,0 +1,10 @@+=== Program ===+function main() {+  var x;+  var y;+  var z;+}+=== Output ===+Result:+null-value+
+ tests/Basic/Basic04.smp view
@@ -0,0 +1,5 @@+function main() {+  var x;+  var y;+  var z;+}
+ tests/Basic/Basic05.fct view
@@ -0,0 +1,32 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("x",+              allocate-initialised-variable+                (values,+                 decimal-natural ("1"))),+            scope+              (bind+                ("y",+                 allocate-variable (values)),+               scope+                 (bind+                   ("z",+                    allocate-initialised-variable+                      (values,+                       assigned (bound ("x")))),+                  return (assigned (bound ("z")))))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic05.output view
@@ -0,0 +1,9 @@+=== Program ===+function main() {+  var x = 1, y, z = x;+  return z;+}+=== Output ===+Result:+1+
+ tests/Basic/Basic05.smp view
@@ -0,0 +1,4 @@+function main() {+  var x = 1, y, z = x;+  return z;+}
+ tests/Basic/Basic06.fct view
@@ -0,0 +1,18 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (return (integer-add+           (decimal-natural ("3"),+            decimal-natural ("4"))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic06.output view
@@ -0,0 +1,8 @@+=== Program ===+function main() {+  return 3 + 4;+}+=== Output ===+Result:+7+
+ tests/Basic/Basic06.smp view
@@ -0,0 +1,3 @@+function main() {+  return 3 + 4;+}
+ tests/Basic/Basic07.fct view
@@ -0,0 +1,32 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("x",+              allocate-initialised-variable+                (values,+                 integer-subtract+                   (checked integer-modulo+                     (integer-multiply+                       (decimal-natural ("8"),+                        decimal-natural ("5")),+                      decimal-natural ("14")),+                    checked integer-divide+                      (integer-multiply+                        (decimal-natural ("2"),+                         decimal-natural ("6")),+                       decimal-natural ("3"))))),+            return (assigned (bound ("x")))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic07.output view
@@ -0,0 +1,8 @@+=== Program ===+function main() {+  var x = 8 * 5 % 14 - 2 * 6 / 3;+  return x;+}=== Output ===+Result:+8+
+ tests/Basic/Basic07.smp view
@@ -0,0 +1,4 @@+function main() {+  var x = 8 * 5 % 14 - 2 * 6 / 3;+  return x;+}
+ tests/Basic/Basic08.fct view
@@ -0,0 +1,45 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("x",+              allocate-initialised-variable+                (values,+                 decimal-natural ("1"))),+            scope+              (bind+                ("y",+                 allocate-initialised-variable+                   (values,+                    assigned (bound ("x")))),+               sequential+                 (if-else+                   (if-else+                     (if-else+                       (is-greater+                         (decimal-natural ("7"),+                          decimal-natural ("4")),+                        not (is-equal+                          (assigned (bound ("x")),+                           assigned (bound ("y")))),+                        false),+                      true,+                      is-greater+                        (assigned (bound ("x")),+                         decimal-natural ("1"))),+                    return (decimal-natural ("1")),+                    null),+                  return (decimal-natural ("0"))))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic08.output view
@@ -0,0 +1,13 @@+=== Program ===+function main() {+  var x = 1;+  var y = x;+  if (7 > 4 && !(x==y) || x > 1) {+    return 1;+  }+  return 0;+}+=== Output ===+Result:+0+
+ tests/Basic/Basic08.smp view
@@ -0,0 +1,8 @@+function main() {+  var x = 1;+  var y = x;+  if (7 > 4 && !(x==y) || x > 1) {+    return 1;+  }+  return 0;+}
+ tests/Basic/Basic09.fct view
@@ -0,0 +1,54 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("a",+              allocate-initialised-variable+                (values,+                 is-less+                   (decimal-natural ("2"),+                    decimal-natural ("3")))),+            scope+              (bind+                ("b",+                 allocate-initialised-variable+                   (values,+                    is-greater+                      (decimal-natural ("4"),+                       decimal-natural ("5")))),+               scope+                 (bind+                   ("c",+                    allocate-initialised-variable+                      (values,+                       is-less-or-equal+                         (decimal-natural ("6"),+                          decimal-natural ("7")))),+                  scope+                    (bind+                      ("d",+                       allocate-initialised-variable+                         (values,+                          is-greater-or-equal+                            (decimal-natural ("8"),+                             decimal-natural ("9")))),+                     sequential+                       (print (is-equal+                         (assigned (bound ("a")),+                          assigned (bound ("c")))),+                        print (not (is-equal+                          (assigned (bound ("b")),+                           assigned (bound ("d")))))))))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic09.output view
@@ -0,0 +1,16 @@+=== Program ===+function main() {+  var a = 2 < 3;  +  var b = 4 > 5; +  var c = 6 <= 7; +  var d = 8 >= 9; +  print(a == c); // true+  print(b != d); // false+}+=== Output ===+Result:+null-value++Output Entity: standard-out+true,false+
+ tests/Basic/Basic09.smp view
@@ -0,0 +1,8 @@+function main() {+  var a = 2 < 3;  +  var b = 4 > 5; +  var c = 6 <= 7; +  var d = 8 >= 9; +  print(a == c); // true+  print(b != d); // false+}
+ tests/Basic/Basic10.fct view
@@ -0,0 +1,24 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (sequential+           (print (decimal-natural ("1")),+            scope+              (bind+                ("x",+                 allocate-initialised-variable+                   (values,+                    decimal-natural ("2"))),+               print (assigned (bound ("x"))))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic10.output view
@@ -0,0 +1,12 @@+=== Program ===+function main() {+  print(1);+  var x = 2;+  print(x);+}=== Output ===+Result:+null-value++Output Entity: standard-out+1,2+
+ tests/Basic/Basic10.smp view
@@ -0,0 +1,5 @@+function main() {+  print(1);+  var x = 2;+  print(x);+}
+ tests/Basic/Basic11.fct view
@@ -0,0 +1,47 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("x",+              allocate-variable (values)),+            scope+              (bind+                ("y",+                 allocate-variable (values)),+               sequential+                 (effect (give+                   (give+                     (decimal-natural ("2"),+                      sequential+                        (assign+                          (bound ("y"),+                           given),+                         given)),+                    sequential+                      (assign+                        (bound ("x"),+                         given),+                       given))),+                  print (give+                    (bound ("x"),+                     sequential+                       (assign+                         (given,+                          integer-add+                            (assigned (given),+                             1)),+                        assigned (given)))),+                  print (assigned (bound ("y")))))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic11.output view
@@ -0,0 +1,13 @@+=== Program ===+function main() {+  var x,y;+  x = y = 2;+  print(++x);+  print(y);+}=== Output ===+Result:+null-value++Output Entity: standard-out+3,2+
+ tests/Basic/Basic11.smp view
@@ -0,0 +1,6 @@+function main() {+  var x,y;+  x = y = 2;+  print(++x);+  print(y);+}
+ tests/Basic/Basic12.fct view
@@ -0,0 +1,21 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (if-else+           (not (is-equal+             (decimal-natural ("3"),+              decimal-natural ("4"))),+            print ("good"),+            print ("bad")))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic12.output view
@@ -0,0 +1,15 @@+=== Program ===+function main() {+	if (3 != 4) {+		print("good");+	} else {+	    print("bad");+	}+}+=== Output ===+Result:+null-value++Output Entity: standard-out+"good"+
+ tests/Basic/Basic12.smp view
@@ -0,0 +1,7 @@+function main() {+	if (3 != 4) {+		print("good");+	} else {+	    print("bad");+	}+}
+ tests/Basic/Basic13.fct view
@@ -0,0 +1,21 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (if-else+           (not (is-equal+             (decimal-natural ("3"),+              decimal-natural ("4"))),+            print ("good"),+            null))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic13.output view
@@ -0,0 +1,13 @@+=== Program ===+function main() {+	if (3 != 4) {+		print("good");+	}+}+=== Output ===+Result:+null-value++Output Entity: standard-out+"good"+
+ tests/Basic/Basic13.smp view
@@ -0,0 +1,5 @@+function main() {+	if (3 != 4) {+		print("good");+	}+}
+ tests/Basic/Basic14.fct view
@@ -0,0 +1,38 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("x",+              allocate-initialised-variable+                (values,+                 decimal-natural ("0"))),+            sequential+              (while+                (is-less+                  (assigned (bound ("x")),+                   decimal-natural ("5")),+                 sequential+                   (print (assigned (bound ("x"))),+                    effect (give+                      (bound ("x"),+                       sequential+                         (assign+                           (given,+                            integer-add+                              (assigned (given),+                               1)),+                          assigned (given)))))),+               print ("done"))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic14.output view
@@ -0,0 +1,15 @@+=== Program ===+function main() {+	var x = 0;+	while (x < 5) {+		print(x);+		++x;+	}+	print("done");+}=== Output ===+Result:+null-value++Output Entity: standard-out+0,1,2,3,4,"done"+
+ tests/Basic/Basic14.smp view
@@ -0,0 +1,8 @@+function main() {+	var x = 0;+	while (x < 5) {+		print(x);+		++x;+	}+	print("done");+}
+ tests/Basic/Basic15.fct view
@@ -0,0 +1,38 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (sequential+           (scope+             (bind+               ("x",+                allocate-initialised-variable+                  (values,+                   decimal-natural ("0"))),+              while+                (is-less+                  (assigned (bound ("x")),+                   decimal-natural ("5")),+                 sequential+                   (print (assigned (bound ("x"))),+                    effect (give+                      (bound ("x"),+                       sequential+                         (assign+                           (given,+                            integer-add+                              (assigned (given),+                               1)),+                          assigned (given))))))),+            print ("done")))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic15.output view
@@ -0,0 +1,14 @@+=== Program ===+function main() {+	for (var x = 0; x < 5 ; ++x) {+		print(x);+	}+	print("done");+}+=== Output ===+Result:+null-value++Output Entity: standard-out+0,1,2,3,4,"done"+
+ tests/Basic/Basic15.smp view
@@ -0,0 +1,6 @@+function main() {+	for (var x = 0; x < 5 ; ++x) {+		print(x);+	}+	print("done");+}
+ tests/Basic/Basic16.fct view
@@ -0,0 +1,24 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("x",+              allocate-initialised-variable+                (values,+                 true)),+            print (assigned (bound ("x")),+            decimal-natural ("1"),+            "good")))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic16.output view
@@ -0,0 +1,11 @@+=== Program ===+function main() {+	var x = true;+	print(x,1,"good");+}=== Output ===+Result:+null-value++Output Entity: standard-out+true,1,"good"+
+ tests/Basic/Basic16.smp view
@@ -0,0 +1,4 @@+function main() {+	var x = true;+	print(x,1,"good");+}
+ tests/Basic/Basic17.fct view
@@ -0,0 +1,24 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (handle-thrown+           (print (decimal-natural ("1")),+            scope+              (bind+                ("x",+                 allocate-initialised-variable+                   (values,+                    given)),+               print (decimal-natural ("2")))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic17.output view
@@ -0,0 +1,15 @@+=== Program ===+function main() {+	try {+	  print(1);+	} catch(x) {+	  print(2);+	}+}+=== Output ===+Result:+null-value++Output Entity: standard-out+1+
+ tests/Basic/Basic17.smp view
@@ -0,0 +1,7 @@+function main() {+	try {+	  print(1);+	} catch(x) {+	  print(2);+	}+}
+ tests/Basic/Basic18.fct view
@@ -0,0 +1,29 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (handle-thrown+           (sequential+             (print (decimal-natural ("1")),+              throw ("exc"),+              print (decimal-natural ("2"))),+            scope+              (bind+                ("x",+                 allocate-initialised-variable+                   (values,+                    given)),+               sequential+                 (print (decimal-natural ("3")),+                  print (assigned (bound ("x")))))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic18.output view
@@ -0,0 +1,18 @@+=== Program ===+function main() {+	try {+	  print(1);+	  throw("exc");+	  print(2);	+	} catch(x)+	{+	  print(3);+	  print(x);+	}+}=== Output ===+Result:+null-value++Output Entity: standard-out+1,3,"exc"+
+ tests/Basic/Basic18.smp view
@@ -0,0 +1,11 @@+function main() {+	try {+	  print(1);+	  throw("exc");+	  print(2);	+	} catch(x)+	{+	  print(3);+	  print(x);+	}+}
+ tests/Basic/Basic19.fct view
@@ -0,0 +1,36 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("a",+              allocate-nested-vectors (decimal-natural ("3"))),+            sequential+              (effect (give+                ("B",+                 sequential+                   (assign+                     (checked index+                       (integer-add+                         (1,+                          decimal-natural ("1")),+                        vector-elements (assigned (bound ("a")))),+                      given),+                    given))),+               print (assigned (checked index+                 (integer-add+                   (1,+                    decimal-natural ("1")),+                  vector-elements (assigned (bound ("a")))))))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic19.output view
@@ -0,0 +1,12 @@+=== Program ===+function main() {+	var a[3];+	a[1] = "B";+	print(a[1]);+}=== Output ===+Result:+null-value++Output Entity: standard-out+"B"+
+ tests/Basic/Basic19.smp view
@@ -0,0 +1,5 @@+function main() {+	var a[3];+	a[1] = "B";+	print(a[1]);+}
+ tests/Basic/Basic20.fct view
@@ -0,0 +1,45 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("a",+              allocate-nested-vectors (decimal-natural ("2"),+              decimal-natural ("3"))),+            sequential+              (effect (give+                (true,+                 sequential+                   (assign+                     (checked index+                       (integer-add+                         (1,+                          decimal-natural ("2")),+                        vector-elements (assigned (checked index+                          (integer-add+                            (1,+                             decimal-natural ("1")),+                           vector-elements (assigned (bound ("a"))))))),+                      given),+                    given))),+               print (assigned (checked index+                 (integer-add+                   (1,+                    decimal-natural ("2")),+                  vector-elements (assigned (checked index+                    (integer-add+                      (1,+                       decimal-natural ("1")),+                     vector-elements (assigned (bound ("a"))))))))))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic20.output view
@@ -0,0 +1,12 @@+=== Program ===+function main() {+	var a[2][3];+	a[1][2] = true;+	print(a[1][2]);+}=== Output ===+Result:+null-value++Output Entity: standard-out+true+
+ tests/Basic/Basic20.smp view
@@ -0,0 +1,5 @@+function main() {+	var a[2][3];+	a[1][2] = true;+	print(a[1][2]);+}
+ tests/Basic/Basic21.fct view
@@ -0,0 +1,45 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("a",+              allocate-nested-vectors (decimal-natural ("2"),+              decimal-natural ("3"))),+            sequential+              (effect (give+                (true,+                 sequential+                   (assign+                     (checked index+                       (integer-add+                         (1,+                          decimal-natural ("2")),+                        vector-elements (assigned (checked index+                          (integer-add+                            (1,+                             decimal-natural ("1")),+                           vector-elements (assigned (bound ("a"))))))),+                      given),+                    given))),+               print (assigned (checked index+                 (integer-add+                   (1,+                    decimal-natural ("2")),+                  vector-elements (assigned (checked index+                    (integer-add+                      (1,+                       decimal-natural ("1")),+                     vector-elements (assigned (bound ("a"))))))))))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic21.output view
@@ -0,0 +1,12 @@+=== Program ===+function main() {+	var a[2,3];+	a[1,2] = true;+	print(a[1,2]);+}=== Output ===+Result:+null-value++Output Entity: standard-out+true+
+ tests/Basic/Basic21.smp view
@@ -0,0 +1,5 @@+function main() {+	var a[2,3];+	a[1,2] = true;+	print(a[1,2]);+}
+ tests/Basic/Basic22.fct view
@@ -0,0 +1,63 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("a",+              allocate-nested-vectors (decimal-natural ("1"),+              decimal-natural ("2"),+              decimal-natural ("3"),+              decimal-natural ("4"))),+            sequential+              (effect (give+                (true,+                 sequential+                   (assign+                     (checked index+                       (integer-add+                         (1,+                          decimal-natural ("3")),+                        vector-elements (assigned (checked index+                          (integer-add+                            (1,+                             decimal-natural ("1")),+                           vector-elements (assigned (checked index+                             (integer-add+                               (1,+                                decimal-natural ("1")),+                              vector-elements (assigned (checked index+                                (integer-add+                                  (1,+                                   decimal-natural ("0")),+                                 vector-elements (assigned (bound ("a"))))))))))))),+                      given),+                    given))),+               print (assigned (checked index+                 (integer-add+                   (1,+                    decimal-natural ("3")),+                  vector-elements (assigned (checked index+                    (integer-add+                      (1,+                       decimal-natural ("1")),+                     vector-elements (assigned (checked index+                       (integer-add+                         (1,+                          decimal-natural ("1")),+                        vector-elements (assigned (checked index+                          (integer-add+                            (1,+                             decimal-natural ("0")),+                           vector-elements (assigned (bound ("a"))))))))))))))))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic22.output view
@@ -0,0 +1,12 @@+=== Program ===+function main() {+	var a[1][2,3][4];+	a[0][1,1][3] = true;+	print(a[0][1,1][3]);+}=== Output ===+Result:+null-value++Output Entity: standard-out+true+
+ tests/Basic/Basic22.smp view
@@ -0,0 +1,5 @@+function main() {+	var a[1][2,3][4];+	a[0][1,1][3] = true;+	print(a[0][1,1][3]);+}
+ tests/Basic/Basic23.fct view
@@ -0,0 +1,44 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("a",+     allocate-nested-vectors (integer-add+       (decimal-natural ("2"),+        decimal-natural ("3")))),+  bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (null,+   assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("y",+              allocate-initialised-variable+                (values,+                 decimal-natural ("4"))),+            sequential+              (effect (give+                ("A",+                 sequential+                   (assign+                     (checked index+                       (integer-add+                         (1,+                          assigned (bound ("y"))),+                        vector-elements (assigned (bound ("a")))),+                      given),+                    given))),+               print (assigned (checked index+                 (integer-add+                   (1,+                    assigned (bound ("y"))),+                  vector-elements (assigned (bound ("a")))))))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic23.output view
@@ -0,0 +1,15 @@+=== Program ===+var a[2+3];++function main() {+  var y = 4;+  a[y] = "A";+  print(a[y]);+}+=== Output ===+Result:+null-value++Output Entity: standard-out+"A"+
+ tests/Basic/Basic23.smp view
@@ -0,0 +1,7 @@+var a[2+3];++function main() {+  var y = 4;+  a[y] = "A";+  print(a[y]);+}
+ tests/Basic/Basic24.fct view
@@ -0,0 +1,50 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("x",+     allocate-initialised-variable+       (values,+        decimal-natural ("3"))),+  bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (null,+   assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("a",+              allocate-nested-vectors (integer-add+                (decimal-natural ("2"),+                 assigned (bound ("x"))))),+            scope+              (bind+                ("y",+                 allocate-initialised-variable+                   (values,+                    decimal-natural ("4"))),+               sequential+                 (effect (give+                   ("A",+                    sequential+                      (assign+                        (checked index+                          (integer-add+                            (1,+                             assigned (bound ("y"))),+                           vector-elements (assigned (bound ("a")))),+                         given),+                       given))),+                  print (assigned (checked index+                    (integer-add+                      (1,+                       assigned (bound ("y"))),+                     vector-elements (assigned (bound ("a"))))))))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic24.output view
@@ -0,0 +1,16 @@+=== Program ===+var x = 3;++function main() {+  var a[2+x];+  var y = 4;+  a[y] = "A";+  print(a[y]);+}+=== Output ===+Result:+null-value++Output Entity: standard-out+"A"+
+ tests/Basic/Basic24.smp view
@@ -0,0 +1,8 @@+var x = 3;++function main() {+  var a[2+x];+  var y = 4;+  a[y] = "A";+  print(a[y]);+}
+ tests/Basic/Basic25.fct view
@@ -0,0 +1,30 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("f",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (print (apply+           (assigned (bound ("f")),+            tuple ())))))),+   assign+     (bound ("f"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (return (decimal-natural ("3")))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic25.output view
@@ -0,0 +1,15 @@+=== Program ===+function main() {+	print(f());+}++function f() {+	return 3;+}+=== Output ===+Result:+null-value++Output Entity: standard-out+3+
+ tests/Basic/Basic25.smp view
@@ -0,0 +1,7 @@+function main() {+	print(f());+}++function f() {+	return 3;+}
+ tests/Basic/Basic26.fct view
@@ -0,0 +1,36 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("f",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (print (apply+           (assigned (bound ("f")),+            tuple (decimal-natural ("3")))))))),+   assign+     (bound ("f"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("x",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (return (integer-add+           (assigned (bound ("x")),+            assigned (bound ("x")))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Basic/Basic26.output view
@@ -0,0 +1,15 @@+=== Program ===+function main() {+	print(f(3));+}++function f(x) {+	return (x + x);+}+=== Output ===+Result:+null-value++Output Entity: standard-out+6+
+ tests/Basic/Basic26.smp view
@@ -0,0 +1,7 @@+function main() {+	print(f(3));+}++function f(x) {+	return (x + x);+}
+ tests/Kdiverse/Kdiverse1.fct view
@@ -0,0 +1,43 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("x",+              allocate-initialised-variable+                (values,+                 decimal-natural ("1"))),+            print (checked integer-divide+              (give+                (bound ("x"),+                 sequential+                   (assign+                     (given,+                      integer-add+                        (assigned (given),+                         1)),+                    assigned (given))),+               checked integer-divide+                 (give+                   (bound ("x"),+                    sequential+                      (assign+                        (given,+                         integer-add+                           (assigned (given),+                            1)),+                       assigned (given))),+                  assigned (bound ("x")))),+            "\n")))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Kdiverse/Kdiverse1.output view
@@ -0,0 +1,24 @@+=== Program ===+// copied from K: tests/diverse/div-nondet.simple+// Program manifesting several behaviors, including an undefined one.+// However, to make it generate all those behaviors, you need to add+// the "superheat" tag to the division and the "supercool" tag to the+// variable lookup and increment rules.++function main() {+  var x = 1 ;+  print(++ x / (++ x / x),"\n");+}++// 0+// 1+// 2+// 3+// undefined (gets stuck with division-by-zero at top of computation)+=== Output ===+Result:+null-value++Output Entity: standard-out+2,"\n"+
+ tests/Kdiverse/Kdiverse1.smp view
@@ -0,0 +1,16 @@+// copied from K: tests/diverse/div-nondet.simple+// Program manifesting several behaviors, including an undefined one.+// However, to make it generate all those behaviors, you need to add+// the "superheat" tag to the division and the "supercool" tag to the+// variable lookup and increment rules.++function main() {+  var x = 1 ;+  print(++ x / (++ x / x),"\n");+}++// 0+// 1+// 2+// 3+// undefined (gets stuck with division-by-zero at top of computation)
+ tests/Kdiverse/Kdiverse2.config view
@@ -0,0 +1,3 @@+inputs {+    standard-in: 5;+}
+ tests/Kdiverse/Kdiverse2.fct view
@@ -0,0 +1,77 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("factorial",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("factorial"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("y",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (sequential+           (print ("Factorial of ",+           assigned (bound ("y")),+           " is: "),+            scope+              (bind+                ("t",+                 allocate-initialised-variable+                   (values,+                    decimal-natural ("1"))),+               sequential+                 (scope+                   (bind+                     ("i",+                      allocate-initialised-variable+                        (values,+                         decimal-natural ("1"))),+                    while+                      (is-less-or-equal+                        (assigned (bound ("i")),+                         assigned (bound ("y"))),+                       sequential+                         (effect (give+                           (integer-multiply+                             (assigned (bound ("t")),+                              assigned (bound ("i"))),+                            sequential+                              (assign+                                (bound ("t"),+                                 given),+                               given))),+                          effect (give+                            (bound ("i"),+                             sequential+                               (assign+                                 (given,+                                  integer-add+                                    (assigned (given),+                                     1)),+                                assigned (given))))))),+                  return (assigned (bound ("t")))))))))),+   assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (sequential+           (print ("Input a natural number: "),+            print (apply+              (assigned (bound ("factorial")),+               tuple (read)),+            "\n")))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Kdiverse/Kdiverse2.output view
@@ -0,0 +1,24 @@+=== Program ===+// copied from K: tests/diverse/factorial.simple+// The following program calculates the factorial of a user-provided number.++function factorial(y) {+  print("Factorial of ", y, " is: ");+  var t=1;+  for(var i=1; i<=y; ++i) {+    t = t*i;+  }+  return t;+}++function main() {+  print("Input a natural number: ");+  print(factorial(read()),"\n");+}+=== Output ===+Result:+null-value++Output Entity: standard-out+"Input a natural number: ","Factorial of ",5," is: ",120,"\n"+
+ tests/Kdiverse/Kdiverse2.smp view
@@ -0,0 +1,16 @@+// copied from K: tests/diverse/factorial.simple+// The following program calculates the factorial of a user-provided number.++function factorial(y) {+  print("Factorial of ", y, " is: ");+  var t=1;+  for(var i=1; i<=y; ++i) {+    t = t*i;+  }+  return t;+}++function main() {+  print("Input a natural number: ");+  print(factorial(read()),"\n");+}
+ tests/Kdiverse/Kdiverse3.config view
@@ -0,0 +1,3 @@+inputs {+    standard-in: 5;+}
+ tests/Kdiverse/Kdiverse3.fct view
@@ -0,0 +1,118 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("collatz",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("collatz"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("n",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (scope+           (bind+             ("s",+              allocate-initialised-variable+                (values,+                 decimal-natural ("0"))),+            sequential+              (print ("Testing Collatz' conjecture for n = ",+              assigned (bound ("n")),+              " ... "),+               while+                 (is-greater+                   (assigned (bound ("n")),+                    decimal-natural ("1")),+                  sequential+                    (effect (give+                      (integer-add+                        (assigned (bound ("s")),+                         decimal-natural ("1")),+                       sequential+                         (assign+                           (bound ("s"),+                            given),+                          given))),+                     if-else+                       (is-equal+                         (assigned (bound ("n")),+                          integer-multiply+                            (checked integer-divide+                              (assigned (bound ("n")),+                               decimal-natural ("2")),+                             decimal-natural ("2"))),+                        effect (give+                          (checked integer-divide+                            (assigned (bound ("n")),+                             decimal-natural ("2")),+                           sequential+                             (assign+                               (bound ("n"),+                                given),+                              given))),+                        effect (give+                          (integer-add+                            (integer-multiply+                              (decimal-natural ("3"),+                               assigned (bound ("n"))),+                             decimal-natural ("1")),+                           sequential+                             (assign+                               (bound ("n"),+                                given),+                              given)))))),+               print ("Done! It took ",+               assigned (bound ("s")),+               " steps.\n"))))))),+   assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (sequential+           (print ("Testing Collatz' conjecture up to what number? "),+            scope+              (bind+                ("m",+                 allocate-initialised-variable+                   (values,+                    read)),+               sequential+                 (scope+                   (bind+                     ("i",+                      allocate-initialised-variable+                        (values,+                         decimal-natural ("1"))),+                    while+                      (is-less-or-equal+                        (assigned (bound ("i")),+                         assigned (bound ("m"))),+                       sequential+                         (effect (apply+                           (assigned (bound ("collatz")),+                            tuple (assigned (bound ("i"))))),+                          effect (give+                            (bound ("i"),+                             sequential+                               (assign+                                 (given,+                                  integer-add+                                    (assigned (given),+                                     1)),+                                assigned (given))))))),+                  print ("Done.  It appears to hold.\n")))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Kdiverse/Kdiverse3.output view
@@ -0,0 +1,28 @@+=== Program ===+// copied from K: tests/diverse/collatz.simple+// Program testing Collatz' conjecture up to a user-provided number.++function collatz(n) {+  var s=0;+  print("Testing Collatz' conjecture for n = ",n," ... ");+  while (n > 1) {+    s = s+1;+    if (n == (n/2)*2) { n = n/2; }+    else { n = 3*n+1; }+  }+  print("Done! It took ",s," steps.\n");+}++function main() {+  print("Testing Collatz' conjecture up to what number? ");+  var m = read();+  for (var i=1; i<=m; ++i) { collatz(i); }+  print("Done.  It appears to hold.\n");+}+=== Output ===+Result:+null-value++Output Entity: standard-out+"Testing Collatz' conjecture up to what number? ","Testing Collatz' conjecture for n = ",1," ... ","Done! It took ",0," steps.\n","Testing Collatz' conjecture for n = ",2," ... ","Done! It took ",1," steps.\n","Testing Collatz' conjecture for n = ",3," ... ","Done! It took ",7," steps.\n","Testing Collatz' conjecture for n = ",4," ... ","Done! It took ",2," steps.\n","Testing Collatz' conjecture for n = ",5," ... ","Done! It took ",5," steps.\n","Done.  It appears to hold.\n"+
+ tests/Kdiverse/Kdiverse3.smp view
@@ -0,0 +1,20 @@+// copied from K: tests/diverse/collatz.simple+// Program testing Collatz' conjecture up to a user-provided number.++function collatz(n) {+  var s=0;+  print("Testing Collatz' conjecture for n = ",n," ... ");+  while (n > 1) {+    s = s+1;+    if (n == (n/2)*2) { n = n/2; }+    else { n = 3*n+1; }+  }+  print("Done! It took ",s," steps.\n");+}++function main() {+  print("Testing Collatz' conjecture up to what number? ");+  var m = read();+  for (var i=1; i<=m; ++i) { collatz(i); }+  print("Done.  It appears to hold.\n");+}
+ tests/Kdiverse/Kdiverse4.fct view
@@ -0,0 +1,449 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("x",+     allocate-variable (values)),+  bind+    ("a",+     allocate-nested-vectors (decimal-natural ("10"))),+  bind+    ("incx",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("zero",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("id",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("double",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("hoincx",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("hozero",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("hoid",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("hodouble",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("app0",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("app1",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("app2",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("map",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("printall",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (null,+   null,+   assign+     (bound ("incx"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (effect (give+           (bound ("x"),+            sequential+              (assign+                (given,+                 integer-add+                   (assigned (given),+                    1)),+               assigned (given)))))))),+   assign+     (bound ("zero"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (return (decimal-natural ("0")))))),+   assign+     (bound ("id"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("x",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (return (assigned (bound ("x"))))))),+   assign+     (bound ("double"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("x",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (return (integer-multiply+           (decimal-natural ("2"),+            assigned (bound ("x")))))))),+   assign+     (bound ("hoincx"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (return (assigned (bound ("incx"))))))),+   assign+     (bound ("hozero"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (return (assigned (bound ("zero"))))))),+   assign+     (bound ("hoid"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (return (assigned (bound ("id"))))))),+   assign+     (bound ("hodouble"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (return (assigned (bound ("double"))))))),+   assign+     (bound ("app0"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("f",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (effect (apply+           (assigned (bound ("f")),+            tuple ())))))),+   assign+     (bound ("app1"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("f",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (return (apply+           (assigned (bound ("f")),+            tuple ())))))),+   assign+     (bound ("app2"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("f",+              allocate-initialised-variable+                (values,+                 given))),+           pattern closure (bind+             ("x",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (return (apply+           (assigned (bound ("f")),+            tuple (assigned (bound ("x"))))))))),+   assign+     (bound ("map"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("f",+              allocate-initialised-variable+                (values,+                 given))),+           pattern closure (bind+             ("x",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (scope+           (bind+             ("i",+              allocate-initialised-variable+                (values,+                 decimal-natural ("0"))),+            while+              (is-less-or-equal+                (assigned (bound ("i")),+                 integer-subtract+                   (length (vector-elements (assigned (bound ("x")))),+                    decimal-natural ("1"))),+               sequential+                 (effect (give+                   (apply+                     (assigned (bound ("app2")),+                      tuple (assigned (bound ("f")),+                      assigned (checked index+                        (integer-add+                          (1,+                           assigned (bound ("i"))),+                         vector-elements (assigned (bound ("x"))))))),+                    sequential+                      (assign+                        (checked index+                          (integer-add+                            (1,+                             assigned (bound ("i"))),+                           vector-elements (assigned (bound ("x")))),+                         given),+                       given))),+                  effect (give+                    (bound ("i"),+                     sequential+                       (assign+                         (given,+                          integer-add+                            (assigned (given),+                             1)),+                        assigned (given))))))))))),+   assign+     (bound ("printall"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (sequential+           (print ("x = ",+           assigned (bound ("x")),+           ";  a[] = "),+            scope+              (bind+                ("i",+                 allocate-initialised-variable+                   (values,+                    decimal-natural ("0"))),+               while+                 (is-less-or-equal+                   (assigned (bound ("i")),+                    integer-subtract+                      (length (vector-elements (assigned (bound ("a")))),+                       decimal-natural ("1"))),+                  sequential+                    (print (assigned (checked index+                      (integer-add+                        (1,+                         assigned (bound ("i"))),+                       vector-elements (assigned (bound ("a"))))),+                    " "),+                     effect (give+                       (bound ("i"),+                        sequential+                          (assign+                            (given,+                             integer-add+                               (assigned (given),+                                1)),+                           assigned (given))))))),+            print ("\n")))))),+   assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (sequential+           (effect (give+             (decimal-natural ("0"),+              sequential+                (assign+                  (bound ("x"),+                   given),+                 given))),+            scope+              (bind+                ("i",+                 allocate-variable (values)),+               sequential+                 (scope+                   (bind+                     ("i",+                      allocate-initialised-variable+                        (values,+                         decimal-natural ("0"))),+                    while+                      (is-less-or-equal+                        (assigned (bound ("i")),+                         integer-subtract+                           (length (vector-elements (assigned (bound ("a")))),+                            decimal-natural ("1"))),+                       sequential+                         (effect (give+                           (assigned (bound ("i")),+                            sequential+                              (assign+                                (checked index+                                  (integer-add+                                    (1,+                                     assigned (bound ("i"))),+                                   vector-elements (assigned (bound ("a")))),+                                 given),+                               given))),+                          effect (give+                            (bound ("i"),+                             sequential+                               (assign+                                 (given,+                                  integer-add+                                    (assigned (given),+                                     1)),+                                assigned (given))))))),+                  effect (apply+                    (assigned (bound ("printall")),+                     tuple ())),+                  effect (apply+                    (apply+                      (assigned (bound ("hoincx")),+                       tuple ()),+                     tuple ())),+                  print (assigned (bound ("x")),+                  " ",+                  apply+                    (apply+                      (assigned (bound ("hozero")),+                       tuple ()),+                     tuple ()),+                  " ",+                  apply+                    (apply+                      (assigned (bound ("hoid")),+                       tuple ()),+                     tuple (decimal-natural ("7"))),+                  " ",+                  apply+                    (apply+                      (assigned (bound ("hodouble")),+                       tuple ()),+                     tuple (decimal-natural ("7"))),+                  "\n"),+                  effect (apply+                    (apply+                      (assigned (bound ("id")),+                       tuple (apply+                         (assigned (bound ("hoincx")),+                          tuple ()))),+                     tuple ())),+                  print (assigned (bound ("x")),+                  " ",+                  apply+                    (apply+                      (assigned (bound ("id")),+                       tuple (apply+                         (assigned (bound ("hozero")),+                          tuple ()))),+                     tuple ()),+                  " ",+                  apply+                    (apply+                      (assigned (bound ("id")),+                       tuple (apply+                         (assigned (bound ("hoid")),+                          tuple ()))),+                     tuple (decimal-natural ("7"))),+                  " ",+                  apply+                    (apply+                      (assigned (bound ("id")),+                       tuple (apply+                         (assigned (bound ("hodouble")),+                          tuple ()))),+                     tuple (decimal-natural ("7"))),+                  "\n"),+                  effect (apply+                    (assigned (bound ("app0")),+                     tuple (apply+                       (assigned (bound ("id")),+                        tuple (apply+                          (assigned (bound ("hoincx")),+                           tuple ())))))),+                  print (assigned (bound ("x")),+                  " ",+                  apply+                    (assigned (bound ("app1")),+                     tuple (apply+                       (assigned (bound ("id")),+                        tuple (apply+                          (assigned (bound ("hozero")),+                           tuple ()))))),+                  " ",+                  apply+                    (assigned (bound ("app2")),+                     tuple (apply+                       (assigned (bound ("id")),+                        tuple (apply+                          (assigned (bound ("hoid")),+                           tuple ()))),+                     decimal-natural ("7"))),+                  " ",+                  apply+                    (assigned (bound ("app2")),+                     tuple (apply+                       (assigned (bound ("id")),+                        tuple (apply+                          (assigned (bound ("hodouble")),+                           tuple ()))),+                     decimal-natural ("7"))),+                  "\n"),+                  effect (apply+                    (assigned (bound ("map")),+                     tuple (assigned (bound ("double")),+                     assigned (bound ("a"))))),+                  effect (apply+                    (assigned (bound ("printall")),+                     tuple ()))))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Kdiverse/Kdiverse4.output view
@@ -0,0 +1,86 @@+=== Program ===+// copied from K: tests/diverse/higher-order.simple+var x, a[10];++function incx() {+  ++x;+}++function zero() {+  return 0;+}++function id(x) {+  return x;+}++function double(x) {+  return 2*x;+}++function hoincx() {+  return incx;+}++function hozero() {+  return zero;+}++function hoid() {+  return id;+}++function hodouble() {+  return double;+}++function app0(f) {+  f();+}++function app1(f) {+  return f();+}++function app2(f,x) {+  return f(x);+}++function map(f,x) {+  for (var i = 0; i <= sizeOf(x) - 1; ++i) {+    x[i] = app2(f,x[i]);+  }+}++function printall() {+  print("x = ",x, ";  a[] = ");+  for (var i = 0; i <= sizeOf(a) - 1; ++i) {+    print(a[i], " ");+  }+  print("\n");+}++function main() {+  x = 0; var i;+  for (var i=0; i <= sizeOf(a) - 1; ++i) {+    a[i]=i;+  }+  printall();+  hoincx()();+  print(x," ", hozero()()," ", hoid()(7)," ", hodouble()(7),"\n");+  id(hoincx())();+  print(x," ", id(hozero())()," ", +        id(hoid())(7)," ", id(hodouble())(7),"\n");+  app0(id(hoincx()));+  print(x," ", app1(id(hozero()))," ", +        app2(id(hoid()),7)," ", app2(id(hodouble()),7),"\n");+  map(double,a);+  printall();+}+=== Output ===+Result:+null-value++Output Entity: standard-out+"x = ",0,";  a[] = ",0," ",1," ",2," ",3," ",4," ",5," ",6," ",7," ",8," ",9," ","\n",1," ",0," ",7," ",14,"\n",2," ",0," ",7," ",14,"\n",3," ",0," ",7," ",14,"\n","x = ",3,";  a[] = ",0," ",2," ",4," ",6," ",8," ",10," ",12," ",14," ",16," ",18," ","\n"+
+ tests/Kdiverse/Kdiverse4.smp view
@@ -0,0 +1,78 @@+// copied from K: tests/diverse/higher-order.simple+var x, a[10];++function incx() {+  ++x;+}++function zero() {+  return 0;+}++function id(x) {+  return x;+}++function double(x) {+  return 2*x;+}++function hoincx() {+  return incx;+}++function hozero() {+  return zero;+}++function hoid() {+  return id;+}++function hodouble() {+  return double;+}++function app0(f) {+  f();+}++function app1(f) {+  return f();+}++function app2(f,x) {+  return f(x);+}++function map(f,x) {+  for (var i = 0; i <= sizeOf(x) - 1; ++i) {+    x[i] = app2(f,x[i]);+  }+}++function printall() {+  print("x = ",x, ";  a[] = ");+  for (var i = 0; i <= sizeOf(a) - 1; ++i) {+    print(a[i], " ");+  }+  print("\n");+}++function main() {+  x = 0; var i;+  for (var i=0; i <= sizeOf(a) - 1; ++i) {+    a[i]=i;+  }+  printall();+  hoincx()();+  print(x," ", hozero()()," ", hoid()(7)," ", hodouble()(7),"\n");+  id(hoincx())();+  print(x," ", id(hozero())()," ", +        id(hoid())(7)," ", id(hodouble())(7),"\n");+  app0(id(hoincx()));+  print(x," ", app1(id(hozero()))," ", +        app2(id(hoid()),7)," ", app2(id(hodouble()),7),"\n");+  map(double,a);+  printall();+}
+ tests/Kdiverse/Kdiverse5.config view
@@ -0,0 +1,3 @@+inputs {+    standard-in: (2,4,1,5,7,8,27,1,2,3);+}
+ tests/Kdiverse/Kdiverse5.fct view
@@ -0,0 +1,549 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("readArray",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("printArray",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("transArray",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("mulArray",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("readArray"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("a",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (scope+           (bind+             ("m",+              allocate-initialised-variable+                (values,+                 integer-subtract+                   (length (vector-elements (assigned (bound ("a")))),+                    decimal-natural ("1")))),+            scope+              (bind+                ("n",+                 allocate-initialised-variable+                   (values,+                    integer-subtract+                      (length (vector-elements (assigned (checked index+                        (integer-add+                          (1,+                           decimal-natural ("0")),+                         vector-elements (assigned (bound ("a"))))))),+                       decimal-natural ("1")))),+               scope+                 (bind+                   ("i",+                    allocate-initialised-variable+                      (values,+                       decimal-natural ("0"))),+                  while+                    (is-less-or-equal+                      (assigned (bound ("i")),+                       assigned (bound ("m"))),+                     sequential+                       (sequential+                         (print ("Line ",+                         integer-add+                           (assigned (bound ("i")),+                            decimal-natural ("1")),+                         " (",+                         integer-add+                           (assigned (bound ("n")),+                            decimal-natural ("1")),+                         " elements): "),+                          scope+                            (bind+                              ("j",+                               allocate-initialised-variable+                                 (values,+                                  decimal-natural ("0"))),+                             while+                               (is-less-or-equal+                                 (assigned (bound ("j")),+                                  assigned (bound ("n"))),+                                sequential+                                  (effect (give+                                    (read,+                                     sequential+                                       (assign+                                         (checked index+                                           (integer-add+                                             (1,+                                              assigned (bound ("j"))),+                                            vector-elements (assigned (checked index+                                              (integer-add+                                                (1,+                                                 assigned (bound ("i"))),+                                               vector-elements (assigned (bound ("a"))))))),+                                          given),+                                        given))),+                                   effect (give+                                     (bound ("j"),+                                      sequential+                                        (assign+                                          (given,+                                           integer-add+                                             (assigned (given),+                                              1)),+                                         assigned (given)))))))),+                        effect (give+                          (bound ("i"),+                           sequential+                             (assign+                               (given,+                                integer-add+                                  (assigned (given),+                                   1)),+                              assigned (given))))))))))))),+   assign+     (bound ("printArray"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("a",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (scope+           (bind+             ("m",+              allocate-initialised-variable+                (values,+                 integer-subtract+                   (length (vector-elements (assigned (bound ("a")))),+                    decimal-natural ("1")))),+            scope+              (bind+                ("n",+                 allocate-initialised-variable+                   (values,+                    integer-subtract+                      (length (vector-elements (assigned (checked index+                        (integer-add+                          (1,+                           decimal-natural ("0")),+                         vector-elements (assigned (bound ("a"))))))),+                       decimal-natural ("1")))),+               scope+                 (bind+                   ("i",+                    allocate-initialised-variable+                      (values,+                       decimal-natural ("0"))),+                  while+                    (is-less-or-equal+                      (assigned (bound ("i")),+                       assigned (bound ("m"))),+                     sequential+                       (sequential+                         (print ("Line ",+                         integer-add+                           (assigned (bound ("i")),+                            decimal-natural ("1")),+                         " (",+                         integer-add+                           (assigned (bound ("n")),+                            decimal-natural ("1")),+                         " elements):"),+                          scope+                            (bind+                              ("j",+                               allocate-initialised-variable+                                 (values,+                                  decimal-natural ("0"))),+                             while+                               (is-less-or-equal+                                 (assigned (bound ("j")),+                                  assigned (bound ("n"))),+                                sequential+                                  (print (" ",+                                  assigned (checked index+                                    (integer-add+                                      (1,+                                       assigned (bound ("j"))),+                                     vector-elements (assigned (checked index+                                       (integer-add+                                         (1,+                                          assigned (bound ("i"))),+                                        vector-elements (assigned (bound ("a"))))))))),+                                   effect (give+                                     (bound ("j"),+                                      sequential+                                        (assign+                                          (given,+                                           integer-add+                                             (assigned (given),+                                              1)),+                                         assigned (given))))))),+                          print ("\n")),+                        effect (give+                          (bound ("i"),+                           sequential+                             (assign+                               (given,+                                integer-add+                                  (assigned (given),+                                   1)),+                              assigned (given))))))))))))),+   assign+     (bound ("transArray"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("a",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (scope+           (bind+             ("m",+              allocate-initialised-variable+                (values,+                 integer-subtract+                   (length (vector-elements (assigned (bound ("a")))),+                    decimal-natural ("1")))),+            scope+              (bind+                ("n",+                 allocate-initialised-variable+                   (values,+                    integer-subtract+                      (length (vector-elements (assigned (checked index+                        (integer-add+                          (1,+                           decimal-natural ("0")),+                         vector-elements (assigned (bound ("a"))))))),+                       decimal-natural ("1")))),+               scope+                 (bind+                   ("b",+                    allocate-nested-vectors (integer-add+                      (assigned (bound ("n")),+                       decimal-natural ("1")),+                    integer-add+                      (assigned (bound ("m")),+                       decimal-natural ("1")))),+                  sequential+                    (scope+                      (bind+                        ("i",+                         allocate-initialised-variable+                           (values,+                            decimal-natural ("0"))),+                       while+                         (is-less-or-equal+                           (assigned (bound ("i")),+                            assigned (bound ("m"))),+                          sequential+                            (scope+                              (bind+                                ("j",+                                 allocate-initialised-variable+                                   (values,+                                    decimal-natural ("0"))),+                               while+                                 (is-less-or-equal+                                   (assigned (bound ("j")),+                                    assigned (bound ("n"))),+                                  sequential+                                    (effect (give+                                      (assigned (checked index+                                        (integer-add+                                          (1,+                                           assigned (bound ("j"))),+                                         vector-elements (assigned (checked index+                                           (integer-add+                                             (1,+                                              assigned (bound ("i"))),+                                            vector-elements (assigned (bound ("a")))))))),+                                       sequential+                                         (assign+                                           (checked index+                                             (integer-add+                                               (1,+                                                assigned (bound ("i"))),+                                              vector-elements (assigned (checked index+                                                (integer-add+                                                  (1,+                                                   assigned (bound ("j"))),+                                                 vector-elements (assigned (bound ("b"))))))),+                                            given),+                                          given))),+                                     effect (give+                                       (bound ("j"),+                                        sequential+                                          (assign+                                            (given,+                                             integer-add+                                               (assigned (given),+                                                1)),+                                           assigned (given))))))),+                             effect (give+                               (bound ("i"),+                                sequential+                                  (assign+                                    (given,+                                     integer-add+                                       (assigned (given),+                                        1)),+                                   assigned (given))))))),+                     return (assigned (bound ("b"))))))))))),+   assign+     (bound ("mulArray"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("a",+              allocate-initialised-variable+                (values,+                 given))),+           pattern closure (bind+             ("b",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (scope+           (bind+             ("m",+              allocate-initialised-variable+                (values,+                 integer-subtract+                   (length (vector-elements (assigned (bound ("a")))),+                    decimal-natural ("1")))),+            scope+              (bind+                ("n",+                 allocate-initialised-variable+                   (values,+                    integer-subtract+                      (length (vector-elements (assigned (bound ("b")))),+                       decimal-natural ("1")))),+               scope+                 (bind+                   ("p",+                    allocate-initialised-variable+                      (values,+                       integer-subtract+                         (length (vector-elements (assigned (checked index+                           (integer-add+                             (1,+                              decimal-natural ("0")),+                            vector-elements (assigned (bound ("b"))))))),+                          decimal-natural ("1")))),+                  scope+                    (bind+                      ("c",+                       allocate-nested-vectors (integer-add+                         (assigned (bound ("m")),+                          decimal-natural ("1")),+                       integer-add+                         (assigned (bound ("p")),+                          decimal-natural ("1")))),+                     sequential+                       (scope+                         (bind+                           ("i",+                            allocate-initialised-variable+                              (values,+                               decimal-natural ("0"))),+                          while+                            (is-less-or-equal+                              (assigned (bound ("i")),+                               assigned (bound ("m"))),+                             sequential+                               (scope+                                 (bind+                                   ("j",+                                    allocate-initialised-variable+                                      (values,+                                       decimal-natural ("0"))),+                                  while+                                    (is-less-or-equal+                                      (assigned (bound ("j")),+                                       assigned (bound ("p"))),+                                     sequential+                                       (sequential+                                         (effect (give+                                           (decimal-natural ("0"),+                                            sequential+                                              (assign+                                                (checked index+                                                  (integer-add+                                                    (1,+                                                     assigned (bound ("j"))),+                                                   vector-elements (assigned (checked index+                                                     (integer-add+                                                       (1,+                                                        assigned (bound ("i"))),+                                                      vector-elements (assigned (bound ("c"))))))),+                                                 given),+                                               given))),+                                          scope+                                            (bind+                                              ("k",+                                               allocate-initialised-variable+                                                 (values,+                                                  decimal-natural ("0"))),+                                             while+                                               (is-less-or-equal+                                                 (assigned (bound ("k")),+                                                  assigned (bound ("n"))),+                                                sequential+                                                  (effect (give+                                                    (integer-add+                                                      (assigned (checked index+                                                        (integer-add+                                                          (1,+                                                           assigned (bound ("j"))),+                                                         vector-elements (assigned (checked index+                                                           (integer-add+                                                             (1,+                                                              assigned (bound ("i"))),+                                                            vector-elements (assigned (bound ("c")))))))),+                                                       integer-multiply+                                                         (assigned (checked index+                                                           (integer-add+                                                             (1,+                                                              assigned (bound ("k"))),+                                                            vector-elements (assigned (checked index+                                                              (integer-add+                                                                (1,+                                                                 assigned (bound ("i"))),+                                                               vector-elements (assigned (bound ("a")))))))),+                                                          assigned (checked index+                                                            (integer-add+                                                              (1,+                                                               assigned (bound ("j"))),+                                                             vector-elements (assigned (checked index+                                                               (integer-add+                                                                 (1,+                                                                  assigned (bound ("k"))),+                                                                vector-elements (assigned (bound ("b")))))))))),+                                                     sequential+                                                       (assign+                                                         (checked index+                                                           (integer-add+                                                             (1,+                                                              assigned (bound ("j"))),+                                                            vector-elements (assigned (checked index+                                                              (integer-add+                                                                (1,+                                                                 assigned (bound ("i"))),+                                                               vector-elements (assigned (bound ("c"))))))),+                                                          given),+                                                        given))),+                                                   effect (give+                                                     (bound ("k"),+                                                      sequential+                                                        (assign+                                                          (given,+                                                           integer-add+                                                             (assigned (given),+                                                              1)),+                                                         assigned (given)))))))),+                                        effect (give+                                          (bound ("j"),+                                           sequential+                                             (assign+                                               (given,+                                                integer-add+                                                  (assigned (given),+                                                   1)),+                                              assigned (given))))))),+                                effect (give+                                  (bound ("i"),+                                   sequential+                                     (assign+                                       (given,+                                        integer-add+                                          (assigned (given),+                                           1)),+                                      assigned (given))))))),+                        return (assigned (bound ("c")))))))))))),+   assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (sequential+           (print ("Input the number of lines and columns (two natural numbers): "),+            scope+              (bind+                ("x",+                 allocate-initialised-variable+                   (values,+                    read)),+               scope+                 (bind+                   ("y",+                    allocate-initialised-variable+                      (values,+                       read)),+                  scope+                    (bind+                      ("a",+                       allocate-nested-vectors (assigned (bound ("x")),+                       assigned (bound ("y")))),+                     sequential+                       (effect (apply+                         (assigned (bound ("readArray")),+                          tuple (assigned (bound ("a"))))),+                        print ("Your matrix is:\n"),+                        effect (apply+                          (assigned (bound ("printArray")),+                           tuple (assigned (bound ("a"))))),+                        print ("The transpose of your matrix is:\n"),+                        effect (apply+                          (assigned (bound ("printArray")),+                           tuple (apply+                             (assigned (bound ("transArray")),+                              tuple (assigned (bound ("a"))))))),+                        print ("You matrix multiplied with its transpose is:\n"),+                        effect (apply+                          (assigned (bound ("printArray")),+                           tuple (apply+                             (assigned (bound ("mulArray")),+                              tuple (assigned (bound ("a")),+                              apply+                                (assigned (bound ("transArray")),+                                 tuple (assigned (bound ("a"))))))))),+                        print ("The transpose of your matrix multiplied with your matrix is:\n"),+                        effect (apply+                          (assigned (bound ("printArray")),+                           tuple (apply+                             (assigned (bound ("mulArray")),+                              tuple (apply+                                (assigned (bound ("transArray")),+                                 tuple (assigned (bound ("a")))),+                              assigned (bound ("a")))))))))))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Kdiverse/Kdiverse5.output view
@@ -0,0 +1,66 @@+=== Program ===+// copied from K: tests/diverse/matrix.simple+// This program tests multi-dimensional arrays.++function readArray(a) {+  var m = sizeOf(a) - 1, n = sizeOf(a[0]) - 1;+  for(var i=0; i<=m; ++i) {+    print("Line ",i+1," (",n+1," elements): ");+    for(var j=0; j<=n; ++j) { a[i][j] = read(); }+  }+}++function printArray(a) {+  var m = sizeOf(a) - 1, n = sizeOf(a[0]) - 1;+  for(var i=0; i<=m; ++i) {+    print("Line ",i+1," (",n+1," elements):");+    for(var j=0; j<=n; ++j) { print(" ",a[i,j]); }+  print("\n");+  }+}++function transArray(a) {+  var  m = sizeOf(a) - 1, n = sizeOf(a[0]) - 1, b[n+1,m+1];+  for (var i=0; i<=m; ++i) {+    for (var j=0; j<=n; ++j) {+      b[j,i] = a[i,j];+    }+  }+  return b;+}++function mulArray(a,b) {+  var m = sizeOf(a) - 1, n = sizeOf(b) - 1, p = sizeOf(b[0]) - 1, c[m+1,p+1];+  for (var i=0; i<=m; ++i) {+    for (var j=0; j<=p; ++j) {+      c[i,j] = 0;+      for (var k=0; k<=n; ++k) {+        c[i,j] = c[i,j] + a[i,k] * b[k,j];+      }+    }+  }+  return c;+}++function main() {+  print("Input the number of lines and columns (two natural numbers): ");+  var x = read(), y = read(), a[x,y];+  readArray(a);+  print("Your matrix is:\n");+  printArray(a);+  print("The transpose of your matrix is:\n");+  printArray(transArray(a));+  print("You matrix multiplied with its transpose is:\n");+  printArray(mulArray(a,transArray(a)));+  print("The transpose of your matrix multiplied with your matrix is:\n");+  printArray(mulArray(transArray(a),a));+}++// Should output what it says.+=== Output ===+Result:+null-value++Output Entity: standard-out+"Input the number of lines and columns (two natural numbers): ","Line ",1," (",4," elements): ","Line ",2," (",4," elements): ","Your matrix is:\n","Line ",1," (",4," elements):"," ",1," ",5," ",7," ",8,"\n","Line ",2," (",4," elements):"," ",27," ",1," ",2," ",3,"\n","The transpose of your matrix is:\n","Line ",1," (",2," elements):"," ",1," ",27,"\n","Line ",2," (",2," elements):"," ",5," ",1,"\n","Line ",3," (",2," elements):"," ",7," ",2,"\n","Line ",4," (",2," elements):"," ",8," ",3,"\n","You matrix multiplied with its transpose is:\n","Line ",1," (",2," elements):"," ",139," ",70,"\n","Line ",2," (",2," elements):"," ",70," ",743,"\n","The transpose of your matrix multiplied with your matrix is:\n","Line ",1," (",4," elements):"," ",730," ",32," ",61," ",89,"\n","Line ",2," (",4," elements):"," ",32," ",26," ",37," ",43,"\n","Line ",3," (",4," elements):"," ",61," ",37," ",53," ",62,"\n","Line ",4," (",4," elements):"," ",89," ",43," ",62," ",73,"\n"+
+ tests/Kdiverse/Kdiverse5.smp view
@@ -0,0 +1,58 @@+// copied from K: tests/diverse/matrix.simple+// This program tests multi-dimensional arrays.++function readArray(a) {+  var m = sizeOf(a) - 1, n = sizeOf(a[0]) - 1;+  for(var i=0; i<=m; ++i) {+    print("Line ",i+1," (",n+1," elements): ");+    for(var j=0; j<=n; ++j) { a[i][j] = read(); }+  }+}++function printArray(a) {+  var m = sizeOf(a) - 1, n = sizeOf(a[0]) - 1;+  for(var i=0; i<=m; ++i) {+    print("Line ",i+1," (",n+1," elements):");+    for(var j=0; j<=n; ++j) { print(" ",a[i,j]); }+  print("\n");+  }+}++function transArray(a) {+  var  m = sizeOf(a) - 1, n = sizeOf(a[0]) - 1, b[n+1,m+1];+  for (var i=0; i<=m; ++i) {+    for (var j=0; j<=n; ++j) {+      b[j,i] = a[i,j];+    }+  }+  return b;+}++function mulArray(a,b) {+  var m = sizeOf(a) - 1, n = sizeOf(b) - 1, p = sizeOf(b[0]) - 1, c[m+1,p+1];+  for (var i=0; i<=m; ++i) {+    for (var j=0; j<=p; ++j) {+      c[i,j] = 0;+      for (var k=0; k<=n; ++k) {+        c[i,j] = c[i,j] + a[i,k] * b[k,j];+      }+    }+  }+  return c;+}++function main() {+  print("Input the number of lines and columns (two natural numbers): ");+  var x = read(), y = read(), a[x,y];+  readArray(a);+  print("Your matrix is:\n");+  printArray(a);+  print("The transpose of your matrix is:\n");+  printArray(transArray(a));+  print("You matrix multiplied with its transpose is:\n");+  printArray(mulArray(a,transArray(a)));+  print("The transpose of your matrix multiplied with your matrix is:\n");+  printArray(mulArray(transArray(a),a));+}++// Should output what it says.
+ tests/Kdiverse/Kdiverse6.config view
@@ -0,0 +1,3 @@+inputs {+    standard-in: (5,71,23,43,23,91);+}
+ tests/Kdiverse/Kdiverse6.fct view
@@ -0,0 +1,1082 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("init",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("printArray",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("reverse",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("map",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("insertionSort",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("bubbleSort",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("siftDown",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("heapSort",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("init"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("n",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (scope+           (bind+             ("x",+              allocate-nested-vectors (assigned (bound ("n")))),+            sequential+              (print ("Type ",+              assigned (bound ("n")),+              " numbers: "),+               scope+                 (bind+                   ("i",+                    allocate-initialised-variable+                      (values,+                       decimal-natural ("0"))),+                  while+                    (is-less-or-equal+                      (assigned (bound ("i")),+                       integer-subtract+                         (assigned (bound ("n")),+                          decimal-natural ("1"))),+                     sequential+                       (effect (give+                         (read,+                          sequential+                            (assign+                              (checked index+                                (integer-add+                                  (1,+                                   assigned (bound ("i"))),+                                 vector-elements (assigned (bound ("x")))),+                               given),+                             given))),+                        effect (give+                          (bound ("i"),+                           sequential+                             (assign+                               (given,+                                integer-add+                                  (assigned (given),+                                   1)),+                              assigned (given))))))),+               print ("Finished reading the ",+               assigned (bound ("n")),+               " numbers\n"),+               return (assigned (bound ("x"))))))))),+   assign+     (bound ("printArray"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("x",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (sequential+           (print ("\n"),+            scope+              (bind+                ("i",+                 allocate-initialised-variable+                   (values,+                    decimal-natural ("0"))),+               while+                 (is-less-or-equal+                   (assigned (bound ("i")),+                    integer-subtract+                      (length (vector-elements (assigned (bound ("x")))),+                       decimal-natural ("1"))),+                  sequential+                    (print (assigned (checked index+                      (integer-add+                        (1,+                         assigned (bound ("i"))),+                       vector-elements (assigned (bound ("x"))))),+                    " "),+                     effect (give+                       (bound ("i"),+                        sequential+                          (assign+                            (given,+                             integer-add+                               (assigned (given),+                                1)),+                           assigned (given))))))),+            print ("\n")))))),+   assign+     (bound ("reverse"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("x",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (scope+           (bind+             ("n",+              allocate-initialised-variable+                (values,+                 length (vector-elements (assigned (bound ("x")))))),+            scope+              (bind+                ("i",+                 allocate-initialised-variable+                   (values,+                    decimal-natural ("0"))),+               while+                 (is-less-or-equal+                   (assigned (bound ("i")),+                    integer-subtract+                      (checked integer-divide+                        (assigned (bound ("n")),+                         decimal-natural ("2")),+                       decimal-natural ("1"))),+                  sequential+                    (scope+                      (bind+                        ("t",+                         allocate-initialised-variable+                           (values,+                            assigned (checked index+                              (integer-add+                                (1,+                                 assigned (bound ("i"))),+                               vector-elements (assigned (bound ("x"))))))),+                       sequential+                         (effect (give+                           (assigned (checked index+                             (integer-add+                               (1,+                                integer-subtract+                                  (integer-subtract+                                    (assigned (bound ("n")),+                                     assigned (bound ("i"))),+                                   decimal-natural ("1"))),+                              vector-elements (assigned (bound ("x"))))),+                            sequential+                              (assign+                                (checked index+                                  (integer-add+                                    (1,+                                     assigned (bound ("i"))),+                                   vector-elements (assigned (bound ("x")))),+                                 given),+                               given))),+                          effect (give+                            (assigned (bound ("t")),+                             sequential+                               (assign+                                 (checked index+                                   (integer-add+                                     (1,+                                      integer-subtract+                                        (integer-subtract+                                          (assigned (bound ("n")),+                                           assigned (bound ("i"))),+                                         decimal-natural ("1"))),+                                    vector-elements (assigned (bound ("x")))),+                                  given),+                                given))))),+                     effect (give+                       (bound ("i"),+                        sequential+                          (assign+                            (given,+                             integer-add+                               (assigned (given),+                                1)),+                           assigned (given)))))))))))),+   assign+     (bound ("map"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("m",+              allocate-initialised-variable+                (values,+                 given))),+           pattern closure (bind+             ("f",+              allocate-initialised-variable+                (values,+                 given))),+           pattern closure (bind+             ("x",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (scope+           (bind+             ("i",+              allocate-initialised-variable+                (values,+                 decimal-natural ("0"))),+            while+              (is-less-or-equal+                (assigned (bound ("i")),+                 integer-subtract+                   (length (vector-elements (assigned (bound ("f")))),+                    decimal-natural ("1"))),+               sequential+                 (sequential+                   (print (assigned (checked index+                     (integer-add+                       (1,+                        assigned (bound ("i"))),+                      vector-elements (assigned (bound ("m")))))),+                    effect (apply+                      (assigned (checked index+                        (integer-add+                          (1,+                           assigned (bound ("i"))),+                         vector-elements (assigned (bound ("f"))))),+                       tuple (assigned (bound ("x")))))),+                  effect (give+                    (bound ("i"),+                     sequential+                       (assign+                         (given,+                          integer-add+                            (assigned (given),+                             1)),+                        assigned (given))))))))))),+   assign+     (bound ("insertionSort"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("x",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (scope+           (bind+             ("i",+              allocate-initialised-variable+                (values,+                 decimal-natural ("1"))),+            while+              (is-less-or-equal+                (assigned (bound ("i")),+                 integer-subtract+                   (length (vector-elements (assigned (bound ("x")))),+                    decimal-natural ("1"))),+               sequential+                 (scope+                   (bind+                     ("v",+                      allocate-initialised-variable+                        (values,+                         assigned (checked index+                           (integer-add+                             (1,+                              assigned (bound ("i"))),+                            vector-elements (assigned (bound ("x"))))))),+                    scope+                      (bind+                        ("j",+                         allocate-initialised-variable+                           (values,+                            integer-subtract+                              (assigned (bound ("i")),+                               decimal-natural ("1")))),+                       sequential+                         (while+                           (if-else+                             (is-greater+                               (assigned (bound ("j")),+                                decimal-natural ("0")),+                              is-greater+                                (assigned (checked index+                                  (integer-add+                                    (1,+                                     assigned (bound ("j"))),+                                   vector-elements (assigned (bound ("x"))))),+                                 assigned (bound ("v"))),+                              false),+                            sequential+                              (effect (give+                                (assigned (checked index+                                  (integer-add+                                    (1,+                                     assigned (bound ("j"))),+                                   vector-elements (assigned (bound ("x"))))),+                                 sequential+                                   (assign+                                     (checked index+                                       (integer-add+                                         (1,+                                          integer-add+                                            (assigned (bound ("j")),+                                             decimal-natural ("1"))),+                                        vector-elements (assigned (bound ("x")))),+                                      given),+                                    given))),+                               effect (give+                                 (integer-subtract+                                   (assigned (bound ("j")),+                                    decimal-natural ("1")),+                                  sequential+                                    (assign+                                      (bound ("j"),+                                       given),+                                     given))))),+                          if-else+                            (is-greater+                              (assigned (checked index+                                (integer-add+                                  (1,+                                   decimal-natural ("0")),+                                 vector-elements (assigned (bound ("x"))))),+                               assigned (bound ("v"))),+                             sequential+                               (effect (give+                                 (assigned (checked index+                                   (integer-add+                                     (1,+                                      decimal-natural ("0")),+                                    vector-elements (assigned (bound ("x"))))),+                                  sequential+                                    (assign+                                      (checked index+                                        (integer-add+                                          (1,+                                           decimal-natural ("1")),+                                         vector-elements (assigned (bound ("x")))),+                                       given),+                                     given))),+                                effect (give+                                  (assigned (bound ("v")),+                                   sequential+                                     (assign+                                       (checked index+                                         (integer-add+                                           (1,+                                            decimal-natural ("0")),+                                          vector-elements (assigned (bound ("x")))),+                                        given),+                                      given)))),+                             effect (give+                               (assigned (bound ("v")),+                                sequential+                                  (assign+                                    (checked index+                                      (integer-add+                                        (1,+                                         integer-add+                                           (assigned (bound ("j")),+                                            decimal-natural ("1"))),+                                       vector-elements (assigned (bound ("x")))),+                                     given),+                                   given))))))),+                  effect (give+                    (bound ("i"),+                     sequential+                       (assign+                         (given,+                          integer-add+                            (assigned (given),+                             1)),+                        assigned (given))))))))))),+   assign+     (bound ("bubbleSort"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("v",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (scope+           (bind+             ("n",+              allocate-initialised-variable+                (values,+                 length (vector-elements (assigned (bound ("v")))))),+            scope+              (bind+                ("i",+                 allocate-initialised-variable+                   (values,+                    decimal-natural ("0"))),+               while+                 (is-less-or-equal+                   (assigned (bound ("i")),+                    integer-subtract+                      (assigned (bound ("n")),+                       decimal-natural ("1"))),+                  sequential+                    (scope+                      (bind+                        ("j",+                         allocate-initialised-variable+                           (values,+                            decimal-natural ("0"))),+                       while+                         (is-less-or-equal+                           (assigned (bound ("j")),+                            integer-subtract+                              (assigned (bound ("n")),+                               decimal-natural ("2"))),+                          sequential+                            (if-else+                              (is-greater+                                (assigned (checked index+                                  (integer-add+                                    (1,+                                     assigned (bound ("j"))),+                                   vector-elements (assigned (bound ("v"))))),+                                 assigned (checked index+                                   (integer-add+                                     (1,+                                      integer-add+                                        (assigned (bound ("j")),+                                         decimal-natural ("1"))),+                                    vector-elements (assigned (bound ("v")))))),+                               scope+                                 (bind+                                   ("t",+                                    allocate-initialised-variable+                                      (values,+                                       assigned (checked index+                                         (integer-add+                                           (1,+                                            integer-add+                                              (assigned (bound ("j")),+                                               decimal-natural ("1"))),+                                          vector-elements (assigned (bound ("v"))))))),+                                  sequential+                                    (effect (give+                                      (assigned (checked index+                                        (integer-add+                                          (1,+                                           assigned (bound ("j"))),+                                         vector-elements (assigned (bound ("v"))))),+                                       sequential+                                         (assign+                                           (checked index+                                             (integer-add+                                               (1,+                                                integer-add+                                                  (assigned (bound ("j")),+                                                   decimal-natural ("1"))),+                                              vector-elements (assigned (bound ("v")))),+                                            given),+                                          given))),+                                     effect (give+                                       (assigned (bound ("t")),+                                        sequential+                                          (assign+                                            (checked index+                                              (integer-add+                                                (1,+                                                 assigned (bound ("j"))),+                                               vector-elements (assigned (bound ("v")))),+                                             given),+                                           given))))),+                               null),+                             effect (give+                               (bound ("j"),+                                sequential+                                  (assign+                                    (given,+                                     integer-add+                                       (assigned (given),+                                        1)),+                                   assigned (given))))))),+                     effect (give+                       (bound ("i"),+                        sequential+                          (assign+                            (given,+                             integer-add+                               (assigned (given),+                                1)),+                           assigned (given)))))))))))),+   assign+     (bound ("siftDown"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("x",+              allocate-initialised-variable+                (values,+                 given))),+           pattern closure (bind+             ("root",+              allocate-initialised-variable+                (values,+                 given))),+           pattern closure (bind+             ("bottom",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (scope+           (bind+             ("done",+              allocate-initialised-variable+                (values,+                 false)),+            scope+              (bind+                ("maxChild",+                 allocate-variable (values)),+               while+                 (if-else+                   (is-less-or-equal+                     (integer-multiply+                       (assigned (bound ("root")),+                        decimal-natural ("2")),+                      assigned (bound ("bottom"))),+                    not (assigned (bound ("done"))),+                    false),+                  sequential+                    (if-else+                      (is-equal+                        (integer-multiply+                          (assigned (bound ("root")),+                           decimal-natural ("2")),+                         assigned (bound ("bottom"))),+                       effect (give+                         (integer-multiply+                           (assigned (bound ("root")),+                            decimal-natural ("2")),+                          sequential+                            (assign+                              (bound ("maxChild"),+                               given),+                             given))),+                       if-else+                         (is-greater+                           (assigned (checked index+                             (integer-add+                               (1,+                                integer-multiply+                                  (assigned (bound ("root")),+                                   decimal-natural ("2"))),+                              vector-elements (assigned (bound ("x"))))),+                            assigned (checked index+                              (integer-add+                                (1,+                                 integer-add+                                   (integer-multiply+                                     (assigned (bound ("root")),+                                      decimal-natural ("2")),+                                    decimal-natural ("1"))),+                               vector-elements (assigned (bound ("x")))))),+                          effect (give+                            (integer-multiply+                              (assigned (bound ("root")),+                               decimal-natural ("2")),+                             sequential+                               (assign+                                 (bound ("maxChild"),+                                  given),+                                given))),+                          effect (give+                            (integer-add+                              (integer-multiply+                                (assigned (bound ("root")),+                                 decimal-natural ("2")),+                               decimal-natural ("1")),+                             sequential+                               (assign+                                 (bound ("maxChild"),+                                  given),+                                given))))),+                     if-else+                       (is-less+                         (assigned (checked index+                           (integer-add+                             (1,+                              assigned (bound ("root"))),+                            vector-elements (assigned (bound ("x"))))),+                          assigned (checked index+                            (integer-add+                              (1,+                               assigned (bound ("maxChild"))),+                             vector-elements (assigned (bound ("x")))))),+                        scope+                          (bind+                            ("t",+                             allocate-initialised-variable+                               (values,+                                assigned (checked index+                                  (integer-add+                                    (1,+                                     assigned (bound ("root"))),+                                   vector-elements (assigned (bound ("x"))))))),+                           sequential+                             (effect (give+                               (assigned (checked index+                                 (integer-add+                                   (1,+                                    assigned (bound ("maxChild"))),+                                  vector-elements (assigned (bound ("x"))))),+                                sequential+                                  (assign+                                    (checked index+                                      (integer-add+                                        (1,+                                         assigned (bound ("root"))),+                                       vector-elements (assigned (bound ("x")))),+                                     given),+                                   given))),+                              effect (give+                                (assigned (bound ("t")),+                                 sequential+                                   (assign+                                     (checked index+                                       (integer-add+                                         (1,+                                          assigned (bound ("maxChild"))),+                                        vector-elements (assigned (bound ("x")))),+                                      given),+                                    given))),+                              effect (give+                                (assigned (bound ("maxChild")),+                                 sequential+                                   (assign+                                     (bound ("root"),+                                      given),+                                    given))))),+                        effect (give+                          (true,+                           sequential+                             (assign+                               (bound ("done"),+                                given),+                              given)))))))))))),+   assign+     (bound ("heapSort"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("x",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (scope+           (bind+             ("n",+              allocate-initialised-variable+                (values,+                 length (vector-elements (assigned (bound ("x")))))),+            scope+              (bind+                ("i",+                 allocate-initialised-variable+                   (values,+                    integer-subtract+                      (checked integer-divide+                        (assigned (bound ("n")),+                         decimal-natural ("2")),+                       decimal-natural ("1")))),+               sequential+                 (while+                   (is-greater-or-equal+                     (assigned (bound ("i")),+                      decimal-natural ("0")),+                    sequential+                      (effect (apply+                        (assigned (bound ("siftDown")),+                         tuple (assigned (bound ("x")),+                         assigned (bound ("i")),+                         integer-subtract+                           (assigned (bound ("n")),+                            decimal-natural ("1"))))),+                       effect (give+                         (integer-subtract+                           (assigned (bound ("i")),+                            decimal-natural ("1")),+                          sequential+                            (assign+                              (bound ("i"),+                               given),+                             given))))),+                  effect (give+                    (integer-subtract+                      (assigned (bound ("n")),+                       decimal-natural ("1")),+                     sequential+                       (assign+                         (bound ("i"),+                          given),+                        given))),+                  while+                    (is-greater-or-equal+                      (assigned (bound ("i")),+                       decimal-natural ("1")),+                     scope+                       (bind+                         ("t",+                          allocate-initialised-variable+                            (values,+                             assigned (checked index+                               (integer-add+                                 (1,+                                  decimal-natural ("0")),+                                vector-elements (assigned (bound ("x"))))))),+                        sequential+                          (effect (give+                            (assigned (checked index+                              (integer-add+                                (1,+                                 assigned (bound ("i"))),+                               vector-elements (assigned (bound ("x"))))),+                             sequential+                               (assign+                                 (checked index+                                   (integer-add+                                     (1,+                                      decimal-natural ("0")),+                                    vector-elements (assigned (bound ("x")))),+                                  given),+                                given))),+                           effect (give+                             (assigned (bound ("t")),+                              sequential+                                (assign+                                  (checked index+                                    (integer-add+                                      (1,+                                       assigned (bound ("i"))),+                                     vector-elements (assigned (bound ("x")))),+                                   given),+                                 given))),+                           effect (apply+                             (assigned (bound ("siftDown")),+                              tuple (assigned (bound ("x")),+                              decimal-natural ("0"),+                              integer-subtract+                                (assigned (bound ("i")),+                                 decimal-natural ("1"))))),+                           effect (give+                             (integer-subtract+                               (assigned (bound ("i")),+                                decimal-natural ("1")),+                              sequential+                                (assign+                                  (bound ("i"),+                                   given),+                                 given))))))))))))),+   assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (sequential+           (print ("Size of the array to sort = "),+            scope+              (bind+                ("x",+                 allocate-initialised-variable+                   (values,+                    apply+                      (assigned (bound ("init")),+                       tuple (read)))),+               scope+                 (bind+                   ("m",+                    allocate-nested-vectors (decimal-natural ("11"))),+                  scope+                    (bind+                      ("f",+                       allocate-nested-vectors (decimal-natural ("11"))),+                     sequential+                       (effect (give+                         ("The original unsorted array is:",+                          sequential+                            (assign+                              (checked index+                                (integer-add+                                  (1,+                                   decimal-natural ("0")),+                                 vector-elements (assigned (bound ("m")))),+                               given),+                             given))),+                        effect (give+                          (assigned (bound ("printArray")),+                           sequential+                             (assign+                               (checked index+                                 (integer-add+                                   (1,+                                    decimal-natural ("0")),+                                  vector-elements (assigned (bound ("f")))),+                                given),+                              given))),+                        effect (give+                          ("Reversing the array ... ",+                           sequential+                             (assign+                               (checked index+                                 (integer-add+                                   (1,+                                    decimal-natural ("1")),+                                  vector-elements (assigned (bound ("m")))),+                                given),+                              given))),+                        effect (give+                          (assigned (bound ("reverse")),+                           sequential+                             (assign+                               (checked index+                                 (integer-add+                                   (1,+                                    decimal-natural ("1")),+                                  vector-elements (assigned (bound ("f")))),+                                given),+                              given))),+                        effect (give+                          ("Done!\nThe reversed array is:",+                           sequential+                             (assign+                               (checked index+                                 (integer-add+                                   (1,+                                    decimal-natural ("2")),+                                  vector-elements (assigned (bound ("m")))),+                                given),+                              given))),+                        effect (give+                          (assigned (bound ("printArray")),+                           sequential+                             (assign+                               (checked index+                                 (integer-add+                                   (1,+                                    decimal-natural ("2")),+                                  vector-elements (assigned (bound ("f")))),+                                given),+                              given))),+                        effect (give+                          ("Sorting the array using insertion sort ... ",+                           sequential+                             (assign+                               (checked index+                                 (integer-add+                                   (1,+                                    decimal-natural ("3")),+                                  vector-elements (assigned (bound ("m")))),+                                given),+                              given))),+                        effect (give+                          (assigned (bound ("insertionSort")),+                           sequential+                             (assign+                               (checked index+                                 (integer-add+                                   (1,+                                    decimal-natural ("3")),+                                  vector-elements (assigned (bound ("f")))),+                                given),+                              given))),+                        effect (give+                          ("Done!\nThe resulting array is:",+                           sequential+                             (assign+                               (checked index+                                 (integer-add+                                   (1,+                                    decimal-natural ("4")),+                                  vector-elements (assigned (bound ("m")))),+                                given),+                              given))),+                        effect (give+                          (assigned (bound ("printArray")),+                           sequential+                             (assign+                               (checked index+                                 (integer-add+                                   (1,+                                    decimal-natural ("4")),+                                  vector-elements (assigned (bound ("f")))),+                                given),+                              given))),+                        effect (give+                          ("Reversing the array ... ",+                           sequential+                             (assign+                               (checked index+                                 (integer-add+                                   (1,+                                    decimal-natural ("5")),+                                  vector-elements (assigned (bound ("m")))),+                                given),+                              given))),+                        effect (give+                          (assigned (bound ("reverse")),+                           sequential+                             (assign+                               (checked index+                                 (integer-add+                                   (1,+                                    decimal-natural ("5")),+                                  vector-elements (assigned (bound ("f")))),+                                given),+                              given))),+                        effect (give+                          ("Done!\nSorting the array using bubble sort ... ",+                           sequential+                             (assign+                               (checked index+                                 (integer-add+                                   (1,+                                    decimal-natural ("6")),+                                  vector-elements (assigned (bound ("m")))),+                                given),+                              given))),+                        effect (give+                          (assigned (bound ("bubbleSort")),+                           sequential+                             (assign+                               (checked index+                                 (integer-add+                                   (1,+                                    decimal-natural ("6")),+                                  vector-elements (assigned (bound ("f")))),+                                given),+                              given))),+                        effect (give+                          ("Done!\nThe resulting array is:",+                           sequential+                             (assign+                               (checked index+                                 (integer-add+                                   (1,+                                    decimal-natural ("7")),+                                  vector-elements (assigned (bound ("m")))),+                                given),+                              given))),+                        effect (give+                          (assigned (bound ("printArray")),+                           sequential+                             (assign+                               (checked index+                                 (integer-add+                                   (1,+                                    decimal-natural ("7")),+                                  vector-elements (assigned (bound ("f")))),+                                given),+                              given))),+                        effect (give+                          ("Reversing the array ... ",+                           sequential+                             (assign+                               (checked index+                                 (integer-add+                                   (1,+                                    decimal-natural ("8")),+                                  vector-elements (assigned (bound ("m")))),+                                given),+                              given))),+                        effect (give+                          (assigned (bound ("reverse")),+                           sequential+                             (assign+                               (checked index+                                 (integer-add+                                   (1,+                                    decimal-natural ("8")),+                                  vector-elements (assigned (bound ("f")))),+                                given),+                              given))),+                        effect (give+                          ("Done!\nSorting the array using heap sort ... ",+                           sequential+                             (assign+                               (checked index+                                 (integer-add+                                   (1,+                                    decimal-natural ("9")),+                                  vector-elements (assigned (bound ("m")))),+                                given),+                              given))),+                        effect (give+                          (assigned (bound ("heapSort")),+                           sequential+                             (assign+                               (checked index+                                 (integer-add+                                   (1,+                                    decimal-natural ("9")),+                                  vector-elements (assigned (bound ("f")))),+                                given),+                              given))),+                        effect (give+                          ("Done!\nThe resulting array is:",+                           sequential+                             (assign+                               (checked index+                                 (integer-add+                                   (1,+                                    decimal-natural ("10")),+                                  vector-elements (assigned (bound ("m")))),+                                given),+                              given))),+                        effect (give+                          (assigned (bound ("printArray")),+                           sequential+                             (assign+                               (checked index+                                 (integer-add+                                   (1,+                                    decimal-natural ("10")),+                                  vector-elements (assigned (bound ("f")))),+                                given),+                              given))),+                        effect (apply+                          (assigned (bound ("map")),+                           tuple (assigned (bound ("m")),+                           assigned (bound ("f")),+                           assigned (bound ("x")))))))))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Kdiverse/Kdiverse6.output view
@@ -0,0 +1,143 @@+=== Program ===+// copied from K: tests/diverse/sortings.simple++function init(n) {+  var x[n];+  print("Type ",n," numbers: ");+  for (var i = 0; i <= n - 1; ++i) {+    x[i] = read();+  }+  print("Finished reading the ",n," numbers\n");+  return x;+}++function printArray(x) {+  print("\n");+  for (var i = 0; i <= sizeOf(x) - 1; ++i) {+    print(x[i]," ");+  }+  print("\n");+}++function reverse(x) {+  var n = sizeOf(x);+  for (var i = 0; i <= n/2 - 1; ++i) {+    var t = x[i];+    x[i] = x[n - i - 1];+    x[n - i - 1] = t;+  }+}++function map(m,f,x) {+  for (var i = 0; i <= sizeOf(f) - 1; ++i) {+    print(m[i]);+    f[i](x);+  }+}++function insertionSort(x) {+  for (var i = 1; i <= sizeOf(x) - 1; ++i) {+    var v = x[i], j = i - 1;+    while (j > 0 && x[j] > v) {  // doing the loop only up to 1+      x[j + 1] = x[j];+      j = j - 1;+    }+    if (x[0] > v) { +      x[1] = x[0];+      x[0] = v;+    }+    else {+      x[j+1] = v;+    }+  }+}++function bubbleSort(v) {+  var n = sizeOf(v);+  for (var i = 0; i <= n - 1; ++i) {+    for (var j = 0; j <= n - 2; ++j) {+      if (v[j] > v[j+1]) {+        var t = v[j+1];+        v[j+1] = v[j];+        v[j] = t;+      }+    }+  }+}++function siftDown(x, root, bottom) {+  var done = false, maxChild;+  while (root*2 <= bottom && !done) {+    if (root*2 == bottom) {+      maxChild = root*2;+    }+    else {+      if (x[root*2] > x[root*2 + 1]) {+        maxChild = root*2;+      }+      else {+        maxChild = root*2 + 1;+      }+    }+    if (x[root] < x[maxChild]) {+      var t = x[root];+      x[root] = x[maxChild];+      x[maxChild] = t;+      root = maxChild;+    }+    else {+      done = true;+    }+  }+}++function heapSort(x) {+  var n = sizeOf(x), i = n/2 - 1;+  while (i >= 0) {+    siftDown(x, i, n - 1);+    i = i - 1;+  }+  i = n - 1;+  while (i >= 1 ) {+    var t = x[0];+    x[0] = x[i] ;+    x[i] = t;+    siftDown(x, 0, i - 1);+    i = i - 1;+  }+}++function main() {+  print("Size of the array to sort = ");+  var x = init(read()), m[11], f[11];+  m[ 0] = "The original unsorted array is:";+  f[ 0] = printArray;+  m[ 1] = "Reversing the array ... ";+  f[ 1] = reverse;+  m[ 2] = "Done!\nThe reversed array is:";+  f[ 2] = printArray;+  m[ 3] = "Sorting the array using insertion sort ... ";+  f[ 3] = insertionSort;+  m[ 4] = "Done!\nThe resulting array is:";+  f[ 4] = printArray;+  m[ 5] = "Reversing the array ... ";+  f[ 5] = reverse;+  m[ 6] = "Done!\nSorting the array using bubble sort ... ";+  f[ 6] = bubbleSort;+  m[ 7] = "Done!\nThe resulting array is:";+  f[ 7] = printArray;+  m[ 8] = "Reversing the array ... ";+  f[ 8] = reverse;+  m[ 9] = "Done!\nSorting the array using heap sort ... ";+  f[ 9] = heapSort;+  m[10] = "Done!\nThe resulting array is:";+  f[10] = printArray;+  map(m,f,x);+}+=== Output ===+Result:+null-value++Output Entity: standard-out+"Size of the array to sort = ","Type ",5," numbers: ","Finished reading the ",5," numbers\n","The original unsorted array is:","\n",71," ",23," ",43," ",23," ",91," ","\n","Reversing the array ... ","Done!\nThe reversed array is:","\n",91," ",23," ",43," ",23," ",71," ","\n","Sorting the array using insertion sort ... ","Done!\nThe resulting array is:","\n",23," ",23," ",43," ",71," ",91," ","\n","Reversing the array ... ","Done!\nSorting the array using bubble sort ... ","Done!\nThe resulting array is:","\n",23," ",23," ",43," ",71," ",91," ","\n","Reversing the array ... ","Done!\nSorting the array using heap sort ... ","Done!\nThe resulting array is:","\n",23," ",23," ",43," ",71," ",91," ","\n"+
+ tests/Kdiverse/Kdiverse6.smp view
@@ -0,0 +1,135 @@+// copied from K: tests/diverse/sortings.simple++function init(n) {+  var x[n];+  print("Type ",n," numbers: ");+  for (var i = 0; i <= n - 1; ++i) {+    x[i] = read();+  }+  print("Finished reading the ",n," numbers\n");+  return x;+}++function printArray(x) {+  print("\n");+  for (var i = 0; i <= sizeOf(x) - 1; ++i) {+    print(x[i]," ");+  }+  print("\n");+}++function reverse(x) {+  var n = sizeOf(x);+  for (var i = 0; i <= n/2 - 1; ++i) {+    var t = x[i];+    x[i] = x[n - i - 1];+    x[n - i - 1] = t;+  }+}++function map(m,f,x) {+  for (var i = 0; i <= sizeOf(f) - 1; ++i) {+    print(m[i]);+    f[i](x);+  }+}++function insertionSort(x) {+  for (var i = 1; i <= sizeOf(x) - 1; ++i) {+    var v = x[i], j = i - 1;+    while (j > 0 && x[j] > v) {  // doing the loop only up to 1+      x[j + 1] = x[j];+      j = j - 1;+    }+    if (x[0] > v) { +      x[1] = x[0];+      x[0] = v;+    }+    else {+      x[j+1] = v;+    }+  }+}++function bubbleSort(v) {+  var n = sizeOf(v);+  for (var i = 0; i <= n - 1; ++i) {+    for (var j = 0; j <= n - 2; ++j) {+      if (v[j] > v[j+1]) {+        var t = v[j+1];+        v[j+1] = v[j];+        v[j] = t;+      }+    }+  }+}++function siftDown(x, root, bottom) {+  var done = false, maxChild;+  while (root*2 <= bottom && !done) {+    if (root*2 == bottom) {+      maxChild = root*2;+    }+    else {+      if (x[root*2] > x[root*2 + 1]) {+        maxChild = root*2;+      }+      else {+        maxChild = root*2 + 1;+      }+    }+    if (x[root] < x[maxChild]) {+      var t = x[root];+      x[root] = x[maxChild];+      x[maxChild] = t;+      root = maxChild;+    }+    else {+      done = true;+    }+  }+}++function heapSort(x) {+  var n = sizeOf(x), i = n/2 - 1;+  while (i >= 0) {+    siftDown(x, i, n - 1);+    i = i - 1;+  }+  i = n - 1;+  while (i >= 1 ) {+    var t = x[0];+    x[0] = x[i] ;+    x[i] = t;+    siftDown(x, 0, i - 1);+    i = i - 1;+  }+}++function main() {+  print("Size of the array to sort = ");+  var x = init(read()), m[11], f[11];+  m[ 0] = "The original unsorted array is:";+  f[ 0] = printArray;+  m[ 1] = "Reversing the array ... ";+  f[ 1] = reverse;+  m[ 2] = "Done!\nThe reversed array is:";+  f[ 2] = printArray;+  m[ 3] = "Sorting the array using insertion sort ... ";+  f[ 3] = insertionSort;+  m[ 4] = "Done!\nThe resulting array is:";+  f[ 4] = printArray;+  m[ 5] = "Reversing the array ... ";+  f[ 5] = reverse;+  m[ 6] = "Done!\nSorting the array using bubble sort ... ";+  f[ 6] = bubbleSort;+  m[ 7] = "Done!\nThe resulting array is:";+  f[ 7] = printArray;+  m[ 8] = "Reversing the array ... ";+  f[ 8] = reverse;+  m[ 9] = "Done!\nSorting the array using heap sort ... ";+  f[ 9] = heapSort;+  m[10] = "Done!\nThe resulting array is:";+  f[10] = printArray;+  map(m,f,x);+}
+ tests/Kexceptions/Kexceptions01.fct view
@@ -0,0 +1,51 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("e",+              allocate-initialised-variable+                (values,+                 decimal-natural ("100"))),+            sequential+              (handle-thrown+                (scope+                  (bind+                    ("x",+                     allocate-initialised-variable+                       (values,+                        decimal-natural ("5"))),+                   sequential+                     (if-else+                       (is-greater-or-equal+                         (assigned (bound ("x")),+                          decimal-natural ("0")),+                        throw (integer-add+                          (assigned (bound ("x")),+                           decimal-natural ("2"))),+                        null),+                      print (decimal-natural ("20")))),+                 scope+                   (bind+                     ("e",+                      allocate-initialised-variable+                        (values,+                         given)),+                    print (assigned (bound ("e")),+                    " "))),+               print (assigned (bound ("e")),+               " "),+               print (decimal-natural ("10"),+               "\n"))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Kexceptions/Kexceptions01.output view
@@ -0,0 +1,24 @@+=== Program ===+function main() {+  var e = 100;+  try {+    var x = 5;+    if (x >= 0) {+      throw x+2;+    }+    print(20);      // should not be printed+  } catch(e) {+    print(e," ");   // should print 7+  }+  print(e," ");     // should print 100+  print(10,"\n");+}++// 7 100 10+=== Output ===+Result:+null-value++Output Entity: standard-out+7," ",100," ",10,"\n"+
+ tests/Kexceptions/Kexceptions01.smp view
@@ -0,0 +1,16 @@+function main() {+  var e = 100;+  try {+    var x = 5;+    if (x >= 0) {+      throw x+2;+    }+    print(20);      // should not be printed+  } catch(e) {+    print(e," ");   // should print 7+  }+  print(e," ");     // should print 100+  print(10,"\n");+}++// 7 100 10
+ tests/Kexceptions/Kexceptions02.fct view
@@ -0,0 +1,53 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("foo",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (handle-thrown+           (effect (apply+             (assigned (bound ("foo")),+              tuple ())),+            scope+              (bind+                ("e",+                 allocate-initialised-variable+                   (values,+                    given)),+               print (assigned (bound ("e")),+               "\n"))))))),+   assign+     (bound ("foo"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (sequential+           (handle-thrown+             (sequential+               (throw (decimal-natural ("5")),+                print (decimal-natural ("17"))),+              scope+                (bind+                  ("e",+                   allocate-initialised-variable+                     (values,+                      given)),+                 throw (integer-add+                   (assigned (bound ("e")),+                    decimal-natural ("2"))))),+            throw (decimal-natural ("1"))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Kexceptions/Kexceptions02.output view
@@ -0,0 +1,28 @@+=== Program ===+function main() {+  try {+    foo();+  }+  catch(e) {+    print(e,"\n");  // should print 7+  }+}++function foo() {+  try {+    throw 5;+    print(17);      // should not be printed+  } catch(e) {+    throw e + 2;    // throws 7+  }+  throw 1;          // should not be reached+}++// 7+=== Output ===+Result:+null-value++Output Entity: standard-out+7,"\n"+
+ tests/Kexceptions/Kexceptions02.smp view
@@ -0,0 +1,20 @@+function main() {+  try {+    foo();+  }+  catch(e) {+    print(e,"\n");  // should print 7+  }+}++function foo() {+  try {+    throw 5;+    print(17);      // should not be printed+  } catch(e) {+    throw e + 2;    // throws 7+  }+  throw 1;          // should not be reached+}++// 7
+ tests/Kexceptions/Kexceptions03.fct view
@@ -0,0 +1,60 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("x",+              allocate-initialised-variable+                (values,+                 decimal-natural ("1"))),+            sequential+              (handle-thrown+                (sequential+                  (effect (give+                    (integer-add+                      (assigned (bound ("x")),+                       decimal-natural ("1")),+                     sequential+                       (assign+                         (bound ("x"),+                          given),+                        given))),+                   throw (assigned (bound ("x"))),+                   effect (give+                     (checked integer-divide+                       (assigned (bound ("x")),+                        decimal-natural ("0")),+                      sequential+                        (assign+                          (bound ("x"),+                           given),+                         given)))),+                 scope+                   (bind+                     ("y",+                      allocate-initialised-variable+                        (values,+                         given)),+                    effect (give+                      (integer-add+                        (assigned (bound ("y")),+                         decimal-natural ("1")),+                       sequential+                         (assign+                           (bound ("x"),+                            given),+                          given))))),+               print (assigned (bound ("x")),+               "\n"))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Kexceptions/Kexceptions03.output view
@@ -0,0 +1,16 @@+=== Program ===+function main() {+  var x = 1;+  try { x = x + 1; throw x; x = x/0;}     // division by zero unreachable+  catch(y) {x = y+1;}+  print(x,"\n");+}++// 3+=== Output ===+Result:+null-value++Output Entity: standard-out+3,"\n"+
+ tests/Kexceptions/Kexceptions03.smp view
@@ -0,0 +1,8 @@+function main() {+  var x = 1;+  try { x = x + 1; throw x; x = x/0;}     // division by zero unreachable+  catch(y) {x = y+1;}+  print(x,"\n");+}++// 3
+ tests/Kexceptions/Kexceptions04.fct view
@@ -0,0 +1,58 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("x",+              allocate-initialised-variable+                (values,+                 decimal-natural ("1"))),+            sequential+              (handle-thrown+                (scope+                  (bind+                    ("x",+                     allocate-initialised-variable+                       (values,+                        decimal-natural ("5"))),+                   sequential+                     (throw (assigned (bound ("x"))),+                      effect (bind+                        ("y",+                         allocate-initialised-variable+                           (values,+                            checked integer-divide+                              (assigned (bound ("x")),+                               decimal-natural ("0"))))))),+                 scope+                   (bind+                     ("y",+                      allocate-initialised-variable+                        (values,+                         given)),+                    sequential+                      (effect (give+                        (integer-add+                          (assigned (bound ("y")),+                           decimal-natural ("2")),+                         sequential+                           (assign+                             (bound ("y"),+                              given),+                            given))),+                       print (assigned (bound ("y")),+                       " ")))),+               print (assigned (bound ("x")),+               "\n"))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Kexceptions/Kexceptions04.output view
@@ -0,0 +1,16 @@+=== Program ===+function main() {+  var x = 1;+  try { var x = 5; throw x; var y = x/0;}   // division by zero unreachable+  catch(y) {y = y + 2; print(y," ");}       // new y here, the one declared by catch+  print(x,"\n");+}++// 7 1+=== Output ===+Result:+null-value++Output Entity: standard-out+7," ",1,"\n"+
+ tests/Kexceptions/Kexceptions04.smp view
@@ -0,0 +1,8 @@+function main() {+  var x = 1;+  try { var x = 5; throw x; var y = x/0;}   // division by zero unreachable+  catch(y) {y = y + 2; print(y," ");}       // new y here, the one declared by catch+  print(x,"\n");+}++// 7 1
+ tests/Kexceptions/Kexceptions05.fct view
@@ -0,0 +1,99 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("x",+     allocate-variable (values)),+  bind+    ("f",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (null,+   assign+     (bound ("f"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("y",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (scope+           (bind+             ("t",+              allocate-initialised-variable+                (values,+                 decimal-natural ("1"))),+            sequential+              (handle-thrown+                (sequential+                  (print (assigned (bound ("t")),+                  " "),+                   throw (decimal-natural ("5")),+                   print (decimal-natural ("8"))),+                 scope+                   (bind+                     ("p",+                      allocate-initialised-variable+                        (values,+                         given)),+                    print (integer-add+                      (assigned (bound ("p")),+                       decimal-natural ("10")),+                    " "))),+               scope+                 (bind+                   ("i",+                    allocate-initialised-variable+                      (values,+                       decimal-natural ("1"))),+                  while+                    (is-less-or-equal+                      (assigned (bound ("i")),+                       assigned (bound ("y"))),+                     sequential+                       (effect (give+                         (integer-multiply+                           (assigned (bound ("t")),+                            assigned (bound ("i"))),+                          sequential+                            (assign+                              (bound ("t"),+                               given),+                             given))),+                        effect (give+                          (bound ("i"),+                           sequential+                             (assign+                               (given,+                                integer-add+                                  (assigned (given),+                                   1)),+                              assigned (given))))))),+               return (assigned (bound ("t"))))))))),+   assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (sequential+           (effect (give+             (decimal-natural ("5"),+              sequential+                (assign+                  (bound ("x"),+                   given),+                 given))),+            print (apply+              (assigned (bound ("f")),+               tuple (assigned (bound ("x")))),+            "\n")))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Kexceptions/Kexceptions05.output view
@@ -0,0 +1,31 @@+=== Program ===+var x;++function f(y) {+  var t = 1;+  try{+    print(t," ");+    throw 5;+    print(8);      // not reachable+  } catch(p) {+    print(p+10," ");+  }+  for (var i = 1; i <= y; ++i) {+    t = t*i;+  }+  return t;+}++function main() {+  x = 5;+  print(f(x),"\n");+}++// 1 15 120+=== Output ===+Result:+null-value++Output Entity: standard-out+1," ",15," ",120,"\n"+
+ tests/Kexceptions/Kexceptions05.smp view
@@ -0,0 +1,23 @@+var x;++function f(y) {+  var t = 1;+  try{+    print(t," ");+    throw 5;+    print(8);      // not reachable+  } catch(p) {+    print(p+10," ");+  }+  for (var i = 1; i <= y; ++i) {+    t = t*i;+  }+  return t;+}++function main() {+  x = 5;+  print(f(x),"\n");+}++// 1 15 120
+ tests/Kexceptions/Kexceptions06.fct view
@@ -0,0 +1,98 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("x",+     allocate-variable (values)),+  bind+    ("f",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (null,+   assign+     (bound ("f"),+      function closure (scope+        (match+          (given,+           tuple (pattern closure (bind+             ("y",+              allocate-initialised-variable+                (values,+                 given))))),+         handle-return (scope+           (bind+             ("t",+              allocate-initialised-variable+                (values,+                 decimal-natural ("1"))),+            sequential+              (handle-thrown+                (sequential+                  (print (assigned (bound ("t")),+                  " "),+                   print (decimal-natural ("8"),+                   " ")),+                 scope+                   (bind+                     ("p",+                      allocate-initialised-variable+                        (values,+                         given)),+                    print (integer-add+                      (assigned (bound ("p")),+                       decimal-natural ("10"))))),+               scope+                 (bind+                   ("i",+                    allocate-initialised-variable+                      (values,+                       decimal-natural ("1"))),+                  while+                    (is-less-or-equal+                      (assigned (bound ("i")),+                       assigned (bound ("y"))),+                     sequential+                       (effect (give+                         (integer-multiply+                           (assigned (bound ("t")),+                            assigned (bound ("i"))),+                          sequential+                            (assign+                              (bound ("t"),+                               given),+                             given))),+                        effect (give+                          (bound ("i"),+                           sequential+                             (assign+                               (given,+                                integer-add+                                  (assigned (given),+                                   1)),+                              assigned (given))))))),+               return (assigned (bound ("t"))))))))),+   assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (sequential+           (effect (give+             (decimal-natural ("5"),+              sequential+                (assign+                  (bound ("x"),+                   given),+                 given))),+            print (apply+              (assigned (bound ("f")),+               tuple (assigned (bound ("x")))),+            "\n")))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Kexceptions/Kexceptions06.output view
@@ -0,0 +1,30 @@+=== Program ===+var x;++function f(y) {+  var t = 1;+  try {+    print(t," ");+    print(8," ");+  } catch(p) {+    print(p+10);  // not reachable+  }+  for (var i = 1; i <= y; ++i) {+    t = t*i;+  }+  return t;+}++function main() {+  x = 5;+  print(f(x),"\n");+}++// 1 8 120+=== Output ===+Result:+null-value++Output Entity: standard-out+1," ",8," ",120,"\n"+
+ tests/Kexceptions/Kexceptions06.smp view
@@ -0,0 +1,22 @@+var x;++function f(y) {+  var t = 1;+  try {+    print(t," ");+    print(8," ");+  } catch(p) {+    print(p+10);  // not reachable+  }+  for (var i = 1; i <= y; ++i) {+    t = t*i;+  }+  return t;+}++function main() {+  x = 5;+  print(f(x),"\n");+}++// 1 8 120
+ tests/Kexceptions/Kexceptions07.fct view
@@ -0,0 +1,48 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("e",+              allocate-variable (values)),+            handle-thrown+              (scope+                (bind+                  ("x",+                   allocate-initialised-variable+                     (values,+                      decimal-natural ("2"))),+                 sequential+                   (print (assigned (bound ("x")),+                   " "),+                    throw (integer-add+                      (give+                        (bound ("x"),+                         sequential+                           (assign+                             (given,+                              integer-add+                                (assigned (given),+                                 1)),+                            assigned (given))),+                       assigned (bound ("x")))))),+               scope+                 (bind+                   ("e",+                    allocate-initialised-variable+                      (values,+                       given)),+                  print (assigned (bound ("e")),+                  "\n")))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Kexceptions/Kexceptions07.output view
@@ -0,0 +1,21 @@+=== Program ===+function main() {+  var e;+  try {+    var x = 2;+    print(x," ");+    throw ++x + x;+  }+  catch(e) {+    print(e,"\n");+  }+}++// 2 6 or 2 5+=== Output ===+Result:+null-value++Output Entity: standard-out+2," ",6,"\n"+
+ tests/Kexceptions/Kexceptions07.smp view
@@ -0,0 +1,13 @@+function main() {+  var e;+  try {+    var x = 2;+    print(x," ");+    throw ++x + x;+  }+  catch(e) {+    print(e,"\n");+  }+}++// 2 6 or 2 5
+ tests/Kexceptions/Kexceptions08.fct view
@@ -0,0 +1,103 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (scope+           (bind+             ("e",+              allocate-variable (values)),+            handle-thrown+              (handle-thrown+                (handle-thrown+                  (handle-thrown+                    (scope+                      (bind+                        ("x",+                         allocate-initialised-variable+                           (values,+                            decimal-natural ("1"))),+                       sequential+                         (print (assigned (bound ("x")),+                         " "),+                          throw (give+                            (bound ("x"),+                             sequential+                               (assign+                                 (given,+                                  integer-add+                                    (assigned (given),+                                     1)),+                                assigned (given)))))),+                     scope+                       (bind+                         ("e",+                          allocate-initialised-variable+                            (values,+                             given)),+                        sequential+                          (print (assigned (bound ("e")),+                          " "),+                           throw (give+                             (bound ("e"),+                              sequential+                                (assign+                                  (given,+                                   integer-add+                                     (assigned (given),+                                      1)),+                                 assigned (given))))))),+                   scope+                     (bind+                       ("e",+                        allocate-initialised-variable+                          (values,+                           given)),+                      sequential+                        (print (assigned (bound ("e")),+                        " "),+                         throw (give+                           (bound ("e"),+                            sequential+                              (assign+                                (given,+                                 integer-add+                                   (assigned (given),+                                    1)),+                               assigned (given))))))),+                 scope+                   (bind+                     ("e",+                      allocate-initialised-variable+                        (values,+                         given)),+                    sequential+                      (print (assigned (bound ("e")),+                      " "),+                       throw (give+                         (bound ("e"),+                          sequential+                            (assign+                              (given,+                               integer-add+                                 (assigned (given),+                                  1)),+                             assigned (given))))))),+               scope+                 (bind+                   ("e",+                    allocate-initialised-variable+                      (values,+                       given)),+                  print (assigned (bound ("e")),+                  "\n")))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Kexceptions/Kexceptions08.output view
@@ -0,0 +1,35 @@+=== Program ===+function main() {+  var e;+  try {+    try {+      try {+        try {+          var x = 1;+          print(x," ");+          throw ++x;+        } catch(e) {+          print(e," ");+          throw ++e;+        }+      } catch(e) {+        print(e," ");+        throw ++e;+      }+    } catch(e) {+      print(e," ");+      throw ++e;+    }+  } catch(e) {+    print(e,"\n");+  }+}++// 1 2 3 4 5+=== Output ===+Result:+null-value++Output Entity: standard-out+1," ",2," ",3," ",4," ",5,"\n"+
+ tests/Kexceptions/Kexceptions08.smp view
@@ -0,0 +1,27 @@+function main() {+  var e;+  try {+    try {+      try {+        try {+          var x = 1;+          print(x," ");+          throw ++x;+        } catch(e) {+          print(e," ");+          throw ++e;+        }+      } catch(e) {+        print(e," ");+        throw ++e;+      }+    } catch(e) {+      print(e," ");+      throw ++e;+    }+  } catch(e) {+    print(e,"\n");+  }+}++// 1 2 3 4 5
+ tests/Kexceptions/Kexceptions09.fct view
@@ -0,0 +1,84 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("x",+     allocate-variable (values)),+  bind+    ("y",+     allocate-variable (values)),+  bind+    ("z",+     allocate-variable (values)),+  bind+    ("g",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("f",+     allocate-variable (functions+       (tuples ((values)*),+        values))),+  bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (null,+   null,+   null,+   assign+     (bound ("g"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (throw (decimal-natural ("15")))))),+   assign+     (bound ("f"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (effect (apply+           (assigned (bound ("g")),+            tuple ())))))),+   assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (sequential+           (effect (give+             (decimal-natural ("5"),+              sequential+                (assign+                  (bound ("x"),+                   given),+                 given))),+            effect (give+              (decimal-natural ("10"),+               sequential+                 (assign+                   (bound ("y"),+                    given),+                  given))),+            handle-thrown+              (effect (apply+                (assigned (bound ("f")),+                 tuple ())),+               scope+                 (bind+                   ("y",+                    allocate-initialised-variable+                      (values,+                       given)),+                  print (assigned (bound ("y")),+                  " "))),+            print (assigned (bound ("x")),+            " "),+            print (assigned (bound ("y")),+            "\n")))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Kexceptions/Kexceptions09.output view
@@ -0,0 +1,32 @@+=== Program ===+var x, y, z;++function g() {+  throw 15;+}++function f() {+  g();+}++function main() {+  x = 5;+  y = 10;++  try {+    f();+  } catch(y) {+    print(y," ");+  }+  print(x," ");+  print(y,"\n");+}++// 15 5 10+=== Output ===+Result:+null-value++Output Entity: standard-out+15," ",5," ",10,"\n"+
+ tests/Kexceptions/Kexceptions09.smp view
@@ -0,0 +1,24 @@+var x, y, z;++function g() {+  throw 15;+}++function f() {+  g();+}++function main() {+  x = 5;+  y = 10;++  try {+    f();+  } catch(y) {+    print(y," ");+  }+  print(x," ");+  print(y,"\n");+}++// 15 5 10
+ tests/Kexceptions/Kexceptions1.output view
@@ -0,0 +1,24 @@+=== Program ===+function main() {+  var e = 100;+  try {+    var x = 5;+    if (x >= 0) {+      throw x+2;+    }+    print(20);      // should not be printed+  } catch(e) {+    print(e," ");   // should print 7+  }+  print(e," ");     // should print 100+  print(10,"\n");+}++// 7 100 10+=== Output ===+Result:+()++Output Entity: standard-out+[7,"",100,"",10,"\n"]+
+ tests/Kexceptions/Kexceptions10.fct view
@@ -0,0 +1,39 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("x",+     allocate-variable (values)),+  bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (null,+   assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (sequential+           (effect (give+             (decimal-natural ("5"),+              sequential+                (assign+                  (bound ("x"),+                   given),+                 given))),+            handle-thrown+              (sequential+                (throw (decimal-natural ("3")),+                 print (assigned (bound ("x")))),+               scope+                 (bind+                   ("y",+                    allocate-initialised-variable+                      (values,+                       given)),+                  print (assigned (bound ("y")),+                  "\n")))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Kexceptions/Kexceptions10.output view
@@ -0,0 +1,21 @@+=== Program ===+var x;++function main() {+  x = 5;+  try {+    throw 3;+    print(x);       // should not print this+  } catch(y) {+    print(y,"\n");  // should print this+  }+}++// 3+=== Output ===+Result:+null-value++Output Entity: standard-out+3,"\n"+
+ tests/Kexceptions/Kexceptions10.smp view
@@ -0,0 +1,13 @@+var x;++function main() {+  x = 5;+  try {+    throw 3;+    print(x);       // should not print this+  } catch(y) {+    print(y,"\n");  // should print this+  }+}++// 3
+ tests/Kexceptions/Kexceptions11.fct view
@@ -0,0 +1,87 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("i",+     allocate-variable (values)),+  bind+    ("j",+     allocate-variable (values)),+  bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (null,+   null,+   assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (sequential+           (effect (give+             (decimal-natural ("0"),+              sequential+                (assign+                  (bound ("i"),+                   given),+                 given))),+            while+              (is-less-or-equal+                (give+                  (bound ("i"),+                   sequential+                     (assign+                       (given,+                        integer-add+                          (assigned (given),+                           1)),+                      assigned (given))),+                 decimal-natural ("3")),+               print (assigned (bound ("i")),+               " ")),+            handle-thrown+              (sequential+                (throw (give+                  (decimal-natural ("1"),+                   sequential+                     (assign+                       (bound ("j"),+                        given),+                      given))),+                 effect (give+                   (decimal-natural ("10"),+                    sequential+                      (assign+                        (bound ("i"),+                         given),+                       given))),+                 print (assigned (bound ("i")))),+               scope+                 (bind+                   ("j",+                    allocate-initialised-variable+                      (values,+                       given)),+                  sequential+                    (effect (give+                      (decimal-natural ("20"),+                       sequential+                         (assign+                           (bound ("i"),+                            given),+                          given))),+                     print (assigned (bound ("i")),+                     " ")))),+            effect (give+              (decimal-natural ("15"),+               sequential+                 (assign+                   (bound ("i"),+                    given),+                  given))),+            print (assigned (bound ("i")),+            "\n")))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Kexceptions/Kexceptions11.output view
@@ -0,0 +1,28 @@+=== Program ===+var i, j;++function main() {+  i = 0;+  while (++i <= 3) {+    print(i," ");+  }+  try {+    throw j=1;+    i = 10;+    print(i);   // should not print this+  } catch(j) {+    i = 20;+    print(i," ");   // should print this+  }+  i = 15;+  print(i,"\n");+}++// 1 2 3 20 15+=== Output ===+Result:+null-value++Output Entity: standard-out+1," ",2," ",3," ",20," ",15,"\n"+
+ tests/Kexceptions/Kexceptions11.smp view
@@ -0,0 +1,20 @@+var i, j;++function main() {+  i = 0;+  while (++i <= 3) {+    print(i," ");+  }+  try {+    throw j=1;+    i = 10;+    print(i);   // should not print this+  } catch(j) {+    i = 20;+    print(i," ");   // should print this+  }+  i = 15;+  print(i,"\n");+}++// 1 2 3 20 15
+ tests/Kexceptions/Kexceptions12.fct view
@@ -0,0 +1,80 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("i",+     allocate-variable (values)),+  bind+    ("j",+     allocate-variable (values)),+  bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (null,+   null,+   assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (sequential+           (effect (give+             (decimal-natural ("0"),+              sequential+                (assign+                  (bound ("i"),+                   given),+                 given))),+            while+              (is-less-or-equal+                (give+                  (bound ("i"),+                   sequential+                     (assign+                       (given,+                        integer-add+                          (assigned (given),+                           1)),+                      assigned (given))),+                 decimal-natural ("3")),+               print (assigned (bound ("i")),+               " ")),+            handle-thrown+              (sequential+                (effect (give+                  (decimal-natural ("10"),+                   sequential+                     (assign+                       (bound ("i"),+                        given),+                      given))),+                 print (assigned (bound ("i")),+                 " ")),+               scope+                 (bind+                   ("j",+                    allocate-initialised-variable+                      (values,+                       given)),+                  sequential+                    (effect (give+                      (decimal-natural ("20"),+                       sequential+                         (assign+                           (bound ("i"),+                            given),+                          given))),+                     print (assigned (bound ("i")))))),+            effect (give+              (decimal-natural ("15"),+               sequential+                 (assign+                   (bound ("i"),+                    given),+                  given))),+            print (assigned (bound ("i")),+            "\n")))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Kexceptions/Kexceptions12.output view
@@ -0,0 +1,27 @@+=== Program ===+var i, j;++function main() {+  i = 0;+  while (++i <= 3) {+    print(i," ");+  }+  try {+    i = 10;+    print(i," ");+  } catch(j) {+    i = 20;+    print(i);  // should not print this+  }+  i = 15;+  print(i,"\n");+}++// 1 2 3 10 15+=== Output ===+Result:+null-value++Output Entity: standard-out+1," ",2," ",3," ",10," ",15,"\n"+
+ tests/Kexceptions/Kexceptions12.smp view
@@ -0,0 +1,19 @@+var i, j;++function main() {+  i = 0;+  while (++i <= 3) {+    print(i," ");+  }+  try {+    i = 10;+    print(i," ");+  } catch(j) {+    i = 20;+    print(i);  // should not print this+  }+  i = 15;+  print(i,"\n");+}++// 1 2 3 10 15
+ tests/Kexceptions/Kexceptions13.fct view
@@ -0,0 +1,28 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (sequential+           (handle-thrown+             (throw (decimal-natural ("4")),+              scope+                (bind+                  ("e",+                   allocate-initialised-variable+                     (values,+                      given)),+                 print (assigned (bound ("e")),+                 " "))),+            print (decimal-natural ("42"),+            "\n")))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Kexceptions/Kexceptions13.output view
@@ -0,0 +1,18 @@+=== Program ===+function main() {+  try {+    throw 4;+  } catch (e) {+    print(e," ");+  }+  print(42,"\n");+}++// 4 42+=== Output ===+Result:+null-value++Output Entity: standard-out+4," ",42,"\n"+
+ tests/Kexceptions/Kexceptions13.smp view
@@ -0,0 +1,10 @@+function main() {+  try {+    throw 4;+  } catch (e) {+    print(e," ");+  }+  print(42,"\n");+}++// 4 42
+ tests/Kexceptions/Kexceptions14.fct view
@@ -0,0 +1,27 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (sequential+           (handle-thrown+             (effect (decimal-natural ("15")),+              scope+                (bind+                  ("e",+                   allocate-initialised-variable+                     (values,+                      given)),+                 print (assigned (bound ("e"))))),+            print (decimal-natural ("42"),+            "\n")))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Kexceptions/Kexceptions14.output view
@@ -0,0 +1,18 @@+=== Program ===+function main() {+  try {+    15;+  } catch(e) {+    print(e);   // should not print this+  }+  print(42,"\n");+}++// 42+=== Output ===+Result:+null-value++Output Entity: standard-out+42,"\n"+
+ tests/Kexceptions/Kexceptions14.smp view
@@ -0,0 +1,10 @@+function main() {+  try {+    15;+  } catch(e) {+    print(e);   // should not print this+  }+  print(42,"\n");+}++// 42
+ tests/Kexceptions/Kexceptions15.fct view
@@ -0,0 +1,36 @@+initialise-binding initialise-storing initialise-giving finalise-failing finalise-throwing scope+  (collateral (bind+    ("main",+     allocate-variable (functions+       (tuples ((values)*),+        values)))),+   sequential (assign+     (bound ("main"),+      function closure (scope+        (match+          (given,+           tuple ()),+         handle-return (handle-thrown+           (sequential+             (effect (decimal-natural ("1")),+              handle-thrown+                (effect (decimal-natural ("2")),+                 scope+                   (bind+                     ("a",+                      allocate-initialised-variable+                        (values,+                         given)),+                    print (decimal-natural ("2")))),+              throw (decimal-natural ("1"))),+            scope+              (bind+                ("b",+                 allocate-initialised-variable+                   (values,+                    given)),+               print (decimal-natural ("1"),+               "\n"))))))),+   apply+     (assigned (bound ("main")),+      tuple ())))
+ tests/Kexceptions/Kexceptions15.output view
@@ -0,0 +1,23 @@+=== Program ===+function main() {+  try {+    1;+    try {+      2;+    } catch(a) {+      print(2);     // should not print this+    }+    throw 1;+  } catch(b) {+    print(1,"\n");  // should print this+  }+}++// 1+=== Output ===+Result:+null-value++Output Entity: standard-out+1,"\n"+
+ tests/Kexceptions/Kexceptions15.smp view
@@ -0,0 +1,15 @@+function main() {+  try {+    1;+    try {+      2;+    } catch(a) {+      print(2);     // should not print this+    }+    throw 1;+  } catch(b) {+    print(1,"\n");  // should print this+  }+}++// 1
+ tests/Kexceptions/Kexceptions2.output view
@@ -0,0 +1,28 @@+=== Program ===+function main() {+  try {+    foo();+  }+  catch(e) {+    print(e,"\n");  // should print 7+  }+}++function foo() {+  try {+    throw 5;+    print(17);      // should not be printed+  } catch(e) {+    throw e + 2;    // throws 7+  }+  throw 1;          // should not be reached+}++// 7+=== Output ===+Result:+()++Output Entity: standard-out+[7,"\n"]+
+ tests/Kexceptions/Kexceptions3.output view
@@ -0,0 +1,16 @@+=== Program ===+function main() {+  var x = 1;+  try { x = x + 1; throw x; x = x/0;}     // division by zero unreachable+  catch(y) {x = y+1;}+  print(x,"\n");+}++// 3+=== Output ===+Result:+()++Output Entity: standard-out+[3,"\n"]+
+ tests/README.txt view
@@ -0,0 +1,48 @@+SIMPLE TESTS+============++This directors contains several sets of SIMPLE test programs:+  - Basic+  - Advanced+  - KExceptions+  - Kdiverse+The latter two sets are taken from the K Framework distribution.++Each directory contains:+  - several test programs (*.smp), +  - the funcon terms generated from those test programs (*.fct), and +  - in some cases, configuration files providing sample input values (*.config).+++Running Funcon Terms+--------------------++To run a test, you will first need to have built the SIMPLE interpreter +(see ../README.txt). Then invoke it as follows (using Kdiverse2.fct as an example):++> runfct-SIMPLE Kdiverse/Kdiverse2.fct++Tests involving reading input take their input from the individual .config files,+e.g. Kdiverse/Kdiverse2.config.++To run a test interactively, you should load the "SIMPLE-interactive.config"+configuration file:++> runfct-SIMPLE --config SIMPLE-interactive.config Kdiverse/Kdiverse2.fct+++Regenerating Funcon Terms+-------------------------++Note: All funcon terms have already been generated, so regenerating them is only+necessary if you have added or modified a test program, or changed the CBS+definition of SIMPLE.++To generate the funcon terms from test files, you first need to have imported+and built the "SIMPLE-Editor" Spoofax project in Eclipse.++Then you can run the "regen-funcons" script.  E.g.++> sh ./regen-funcons.sh Basic++will generate a *.fct file for each *.smp file in the folder "Basic".
+ tests/SIMPLE-interactive.config view
@@ -0,0 +1,4 @@+general {+    interactive-mode;+    auto-config: false;+}
+ tests/SIMPLE.config view
@@ -0,0 +1,3 @@+general {+  refocus;+}