Download Knowledge Spaces Mathematica Package - Technical Report
Transcript
KSMP Techical Report
Andrej Zaluski
(* FunctionInjectionQ[f] tests whether the function f is an injection *)
FunctionInjectionQ[Mapping[D0_,C0_,M0_]]:=
Module[{D=D0,C=C0,M=M0,DxD=CartesianProduct[D0,D0],f=Mapping[D0,C0,M0]},
Apply[And,
Map[(#[[1,1]]\[NotEqual]#[[1,2]]\[Implies]#[[2,1]]\[NotEqual]#[[2,
2]])&,
Table[{DxD[[i]],
{FunctionValue[f,DxD[[i,1]]],FunctionValue[f,DxD[[i,2]]]}},
{i,1,Length[DxD]}
]]]] /; FunctionWellDefinedQ[Mapping[D0,C0,M0]]
(* CompositionOfFunctions[
functions]returns the composition(fn\[SmallCircle]..\[SmallCircle]
f2\[SmallCircle]f1) of the functions (taking from right to left),
in case that such composition is defined *)
CompositionOfFunctions[functions_List]:=Module[
{i,k=Length[functions],A1,f},
A1=FunctionDomain[functions[[k]]];
f=Mapping[A1,
FunctionCodomain[functions[[1]]],
Transpose[{A1,FunctionValue[functions,A1]}]];
Return[f]
] /; (Length[functions]\[GreaterEqual]2) \[And]
(Apply[And,Map[(Head[#]===Mapping)&,functions]]) \[And]
(Apply[And,Table[SubsetQ[FunctionCodomain[functions[[i+1]]],
FunctionDomain[functions[[i]]]],
{i,Length[functions]-1,1,-1}]])
(* EqualFunctionsQ[f1,f2] returns true iff the functions f1 and f2
are equal *)
EqualFunctionsQ[Mapping[D1_,C1_,R1_],Mapping[D2_,C2_,R2_]]:=
EqualSetsQ[D1,D2]&&EqualSetsQ[C1,C2]&&EqualSetsQ[R1,R2]
(* MakeStructure[X,F] creates a structure (X,F) *)
MakeStructure[X_List,F_List]:=Structure[X,F]
(* StructureQ[SF] returns True if SF is a structure *)
StructureQ[SF_]:=If[Head[SF]===Structure,True,False]
(* FamilyQ[F] returns True if SF is a family of subsets *)
FamilyQ[F_]:=SetQ[F]
(* StructureSet[SF] returns the set forming the structure SF *)
StructureSet[Structure[X_,F_]]:=X
(* StructureFamily[SF] returns the family forming the structure SF *)
StructureFamily[Structure[X_,F_]]:=F
(* StructureReplaceSet[SF,
X1] primitive function that replaces the set forming the structure SF \
60