Skip to content

Commit 243fa67

Browse files
committed
Add Functions!Pointwise
Adds Github issue #96 #96 [Feature]
1 parent 64513ec commit 243fa67

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

modules/Functions.tla

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ RestrictValues(f, Test(_)) ==
5252
(***************************************************************************)
5353
Range(f) == { f[x] : x \in DOMAIN f }
5454

55+
(***************************************************************************)
56+
(* Assuming DOMAIN f \subseteq DOMAIN g, apply the binary operation T to *)
57+
(* the corresponding elements of the two functions f and g. *)
58+
(* *)
59+
(* Example: *)
60+
(* LET f == ("a" :> 0 @@ "b" :> 1 @@ "c" :> 2) *)
61+
(* g == ("a" :> 1 @@ "b" :> 1 @@ "c" :> 3) *)
62+
(* IN Pointwise(f,g,+) = ("a" :> 1 @@ "b" :> 2 @@ "c" :> 5 ) *)
63+
(***************************************************************************)
64+
Pointwise(f, g, T(_,_)) == [ e \in DOMAIN f |-> T(f[e], g[e]) ]
5565

5666
(***************************************************************************)
5767
(* The inverse of a function. *)

tests/FunctionsTests.tla

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
------------------------- MODULE FunctionsTests -------------------------
2-
EXTENDS Functions, Naturals, TLC, TLCExt, FiniteSets, Sequences
2+
EXTENDS Functions, Integers, TLC, TLCExt, FiniteSets, Sequences
33

44
ASSUME LET T == INSTANCE TLC IN T!PrintT("FunctionsTests")
55

@@ -97,4 +97,14 @@ ASSUME
9797
LET F == (0 :> "n1" @@ 2 :> "n2" @@ 1 :> "n3")
9898
IN AntiFunction(AntiFunction(F)) = F
9999

100+
ASSUME
101+
LET f == ("a" :> 0 @@ "b" :> 1 @@ "c" :> 2)
102+
g == ("a" :> 1 @@ "b" :> 1 @@ "c" :> 3)
103+
IN Pointwise(f,g,+) = ("a" :> 1 @@ "b" :> 2 @@ "c" :> 5 )
104+
105+
ASSUME
106+
LET f == ("a" :> 1 @@ "b" :> 1 @@ "c" :> 2)
107+
g == ("a" :> 1 @@ "b" :> 1 @@ "c" :> 3)
108+
IN Pointwise(f,g,-) = ("a" :> 0 @@ "b" :> 0 @@ "c" :> (-1) )
109+
100110
=============================================================================

0 commit comments

Comments
 (0)