The direct product of two functions over the same domain is
another function over that domain whose co-domain is the product
of the co-domains their co-domains.
Axiom makes this a little awkward because it currently does not
properly support non-homogeneous tuples (Tuple ANY) as the output
of functions (i.e. co-domains that are general products). We use
Axiom's Record type below. It is also possible to write this
using non-homogeneous Lists or DirectProducts?.
fricas
(1) -> )abbrev package MAPHAC3X MapPackInternalHac3x
++ Description: Mapping hack for Addition
++ The function \spad{fDirPrd(f,g,x)} is \spad{(fx,gx)} which is needed below
MapPackInternalHac3x(A: SetCategory, B: SetCategory, C: SetCategory):
with fDirPrd: (A->B, A->C,A) -> Record(a:B,b:C) ==
add
fDirPrd(g,h,x) == [(g x), (h x)]
fricas
Compiling FriCAS source code from file
/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/5523093780900071215-25px.001.spad
using old system compiler.
MAPHAC3X abbreviates package MapPackInternalHac3x
------------------------------------------------------------------------
initializing NRLIB MAPHAC3X for MapPackInternalHac3x
compiling into NRLIB MAPHAC3X
compiling exported fDirPrd : (A -> B,A -> C,A) -> Record(a: B,b: C)
Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |MapPackInternalHac3x| REDEFINED
;;; *** |MapPackInternalHac3x| REDEFINED
Time: 0 SEC.
Cumulative Statistics for Constructor MapPackInternalHac3x
Time: 0 seconds
finalizing NRLIB MAPHAC3X
Processing MapPackInternalHac3x for Browser database:
--------constructor---------
--->-->MapPackInternalHac3x((fDirPrd ((Record (: a B) (: b C)) (Mapping B A) (Mapping C A) A))): Not documented!!!!
; compiling file "/var/aw/var/LatexWiki/MAPHAC3X.NRLIB/MAPHAC3X.lsp" (written 28 NOV 2024 07:44:40 PM):
; wrote /var/aw/var/LatexWiki/MAPHAC3X.NRLIB/MAPHAC3X.fasl
; compilation finished in 0:00:00.008
------------------------------------------------------------------------
MapPackInternalHac3x is now explicitly exposed in frame initial
MapPackInternalHac3x will be automatically loaded when needed from
/var/aw/var/LatexWiki/MAPHAC3X.NRLIB/MAPHAC3X
fricas
)abbrev package MAPPK3X MappingPackage3x
++ Description: Functional Direct Product
++ Given functions f:A->B and g:A->C, X returns the function ++ \spad{(fx,gx):A->BxC}
++ \spad<b>&X g</b> is the function \spad{h} such that \spad{h x = (f x , g x)}.
MappingPackage3x(A:SetCategory, B:SetCategory, C:SetCategory):
with X: (A->B, A->C) -> (A->Record(a:B,b:C)) ==
add
import MapPackInternalHac3x(A, B, C)
fab: A -> B
fac: A -> C
X(fab,fac) == fDirPrd(fab,fac,#1)
fricas
Compiling FriCAS source code from file
/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/6114962443719445214-25px.002.spad
using old system compiler.
MAPPK3X abbreviates package MappingPackage3x
------------------------------------------------------------------------
initializing NRLIB MAPPK3X for MappingPackage3x
compiling into NRLIB MAPPK3X
importing MapPackInternalHac3x(A,B,C)
compiling exported X : (A -> B,A -> C) -> A -> Record(a: B,b: C)
Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |MappingPackage3x| REDEFINED
;;; *** |MappingPackage3x| REDEFINED
Time: 0 SEC.
Cumulative Statistics for Constructor MappingPackage3x
Time: 0 seconds
finalizing NRLIB MAPPK3X
Processing MappingPackage3x for Browser database:
--------constructor---------
--->-->MappingPackage3x((X ((Mapping (Record (: a B) (: b C)) A) (Mapping B A) (Mapping C A)))): Not documented!!!!
; compiling file "/var/aw/var/LatexWiki/MAPPK3X.NRLIB/MAPPK3X.lsp" (written 28 NOV 2024 07:44:40 PM):
; wrote /var/aw/var/LatexWiki/MAPPK3X.NRLIB/MAPPK3X.fasl
; compilation finished in 0:00:00.004
------------------------------------------------------------------------
MappingPackage3x is now explicitly exposed in frame initial
MappingPackage3x will be automatically loaded when needed from
/var/aw/var/LatexWiki/MAPPK3X.NRLIB/MAPPK3X
Test the product with two functions f and g.
fricas
f := (x:INT):INT +-> 3*x
Type: (Integer -> Integer)
fricas
g := (x:INT):INT +-> x^3
Type: (Integer -> Integer)
fricas
fg:=(f &X g)
Type: (Integer -> Record(a: Integer,b: Integer))
fricas
fg(3)
Type: Record(a: Integer,b: Integer)
Since the result of the functional direct product is a function whose
co-domain is a Record, for functional composition we need to write
a function whose domain is a Record, i.e. so that it takes as input
the data output output by another function.
fricas
s := (x:Record(a:INT,b:INT)):INT+->(x.a+x.b)
Type: (Record(a: Integer,b: Integer) -> Integer)
fricas
sX := (s * (f &X g))
Type: (Integer -> Integer)
fricas
sX(9)
From William Sit, July 1, 2005 7:46:00 -5:00
The Cartesian Product of two domains is implemented in Product
. The DirectProduct
domain is when the component domains are all the same. You worked too hard. The "product" of two functions can be defined on the fly naturally:
fricas
h(x:INT):Product(INT,INT)== [f x,g x]
Function declaration h : Integer -> Product(Integer,Integer) has
been added to workspace.
Type: Void
fricas
h(3)
fricas
Compiling function h with type Integer -> Product(Integer,Integer)
Type: Product(Integer,Integer)
Or, if you really want to make a package out of this:
fricas
)abbrev package FUNCPROD FunctionalProduct
++ Description: Allows making one function out of two components
++ The function \spad{product(f,g)} is the function whose components are f and g
FunctionalProduct(A: SetCategory, B: SetCategory, C: SetCategory): Package == Code where
D ==> Product(B,C)
Package ==> with
product: (A->B, A->C) -> (A->D)
Code ==> add
product(g,h) == [g #1, h #1]$D
fricas
Compiling FriCAS source code from file
/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/3755633970012740168-25px.006.spad
using old system compiler.
FUNCPROD abbreviates package FunctionalProduct
------------------------------------------------------------------------
initializing NRLIB FUNCPROD for FunctionalProduct
compiling into NRLIB FUNCPROD
compiling exported product : (A -> B,A -> C) -> A -> Product(B,C)
Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |FunctionalProduct| REDEFINED
;;; *** |FunctionalProduct| REDEFINED
Time: 0 SEC.
Cumulative Statistics for Constructor FunctionalProduct
Time: 0 seconds
finalizing NRLIB FUNCPROD
Processing FunctionalProduct for Browser database:
--------constructor---------
--->-->FunctionalProduct((product ((Mapping (Product B C) A) (Mapping B A) (Mapping C A)))): Not documented!!!!
; compiling file "/var/aw/var/LatexWiki/FUNCPROD.NRLIB/FUNCPROD.lsp" (written 28 NOV 2024 07:44:40 PM):
; wrote /var/aw/var/LatexWiki/FUNCPROD.NRLIB/FUNCPROD.fasl
; compilation finished in 0:00:00.004
------------------------------------------------------------------------
FunctionalProduct is now explicitly exposed in frame initial
FunctionalProduct will be automatically loaded when needed from
/var/aw/var/LatexWiki/FUNCPROD.NRLIB/FUNCPROD
fricas
k:=product(f,g)
Type: (Integer -> Product(Integer,Integer))
fricas
k(3)
Type: Product(Integer,Integer)
William Sit wrote:
The Cartesian Product of two domains is implemented in Product.
The DirectProduct? domain is when the component domains are all
the same. You worked too hard. The "product" of two functions
can be defined on the fly naturally ...
I have not been able to find any documentation about this
domain in the Axiom Book. Did I just miss it?
So now I want to know how the domain Product relates to
tuples. Really from the point of view of category theory
we want a tuple to be a member of an n-ary Product.
Still the use of Product for 2-tuples is quite straightforward.
For example:
fricas
)expose Product
Product is now explicitly exposed in frame initial
g:Product(INT,Float)->Product(Float,INT)
Compiled code for h has been cleared.
Cannot process mapping declaration on g since it already has a
value.