From 868324b6ab2f0c069837c7bfc9604c89a3200f38 Mon Sep 17 00:00:00 2001 From: Lars Date: Thu, 15 Nov 2012 22:05:59 +0100 Subject: [PATCH] added all the examples used in my presentation use the makefile in examples_pk/presentation to run them after installing pk2000 the symmetry examples does not work, because one variable can't have multiple slot accesses at the same time. therefore, there can't be a symmetry check this way. --- examples_pk/presentation/Makefile | 11 +++++++++++ examples_pk/presentation/inc.pk | 9 +++++++++ examples_pk/presentation/maj.pk | 4 ++++ examples_pk/presentation/sym.pk | 13 +++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 examples_pk/presentation/Makefile create mode 100644 examples_pk/presentation/inc.pk create mode 100644 examples_pk/presentation/maj.pk create mode 100644 examples_pk/presentation/sym.pk diff --git a/examples_pk/presentation/Makefile b/examples_pk/presentation/Makefile new file mode 100644 index 0000000..1a89331 --- /dev/null +++ b/examples_pk/presentation/Makefile @@ -0,0 +1,11 @@ +all: + ruby ../../pkc.rb -i inc.pk + echo "\n\nputs \"* Increment function\"\nputs \" inc(1): ( \"+Plankalkuel.p1(1)[0].to_i.to_s+\", \"+Plankalkuel.p1(1)[1].to_i.to_s+\")\"\nputs \" inc(65535): ( \"+Plankalkuel.p1(65535)[0].to_i.to_s+\", \"+Plankalkuel.p1(65535)[1].to_i.to_s+\")\"" >> inc.rb + ruby inc.rb + ruby ../../pkc.rb -i maj.pk + echo "\n\nputs \"* Major function\"\nputs \" max(16, 18): \"+Plankalkuel.p2(16, 18).to_i.to_s\nputs \" max(18, 16): \"+Plankalkuel.p2(18, 16).to_i.to_s\nputs \" max(16, 16): \"+Plankalkuel.p2(16, 16).to_i.to_s" >> maj.rb + ruby maj.rb + ruby ../../pkc.rb -i sym.pk + echo "\n\nputs \"* Symmetry (for 16bit numbers)\"\nputs \" sym(0): \"+Plankalkuel.p3(0).to_i.to_s\nputs \" sym(8): \"+Plankalkuel.p3(8).to_i.to_s" >> sym.rb + ruby sym.rb + diff --git a/examples_pk/presentation/inc.pk b/examples_pk/presentation/inc.pk new file mode 100644 index 0000000..9ad68e8 --- /dev/null +++ b/examples_pk/presentation/inc.pk @@ -0,0 +1,9 @@ +P1 (V0[:16.0]) => (R0[:16.0], R1[:0]) + 1 => Z0[:0] + 0 => R0[:16.0] + W1(16)[ + !(V0[i:0] ~ Z0[:0]) => R0[i:0] + V0[i:0] & Z0[:0] => Z0[:0] + ] + Z0[:0] => R1[:0] +END diff --git a/examples_pk/presentation/maj.pk b/examples_pk/presentation/maj.pk new file mode 100644 index 0000000..159468f --- /dev/null +++ b/examples_pk/presentation/maj.pk @@ -0,0 +1,4 @@ +P2 (V0[:16.0], V1[:16.0]) => R0[:16.0] + V0[:16.0] > V1[:16.0] -> (V0[:16.0] => R0[:16.0]) + ! V0[:16.0] > V1[:16.0] -> (V1[:16.0] => R0[:16.0]) +END diff --git a/examples_pk/presentation/sym.pk b/examples_pk/presentation/sym.pk new file mode 100644 index 0000000..1acb8bd --- /dev/null +++ b/examples_pk/presentation/sym.pk @@ -0,0 +1,13 @@ +P3 (V0[:16.0]) => R0[:0] + 0 => Z1[:4.0] + 15 => Z2[:4.0] + 1 => Z0[:0] + W[ + Z1[:4.0] < Z2[:4.0] -> [ + (V0[Z1[:4.0]:0] ~ V0[Z2[:4.0]:0]) & Z0[:0] => Z0[:0] + Z1[:4.0] + 1 => Z1[:4.0] + Z2[:4.0] - 1 => Z2[:4.0] + ] + ] + Z0[:0] => R0[:0] +END