├── .circleci ├── config.yml └── test.sh ├── .clang-format ├── .github ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE │ ├── feature_request.md │ ├── student_project.md │ └── weed_report.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .markdownlint.json ├── CMakeLists.txt ├── CPPLINT.cfg ├── DevUtils ├── BuildLibSetReplace.m ├── Console.m ├── FileTreeHashes.m ├── GitLink.m ├── PackSetReplace.m ├── Rasterization.m └── init.m ├── Documentation ├── Generators │ ├── $SetReplaceGenerators.md │ ├── $SetReplaceSystems.md │ ├── GenerateMultihistory.md │ ├── GenerateSingleHistory.md │ ├── MaxDestroyerEvents.md │ ├── MaxEventInputs.md │ ├── MaxEvents.md │ ├── MaxGeneration.md │ ├── MinEventInputs.md │ ├── README.md │ └── SetReplaceSystemParameters.md ├── Images │ ├── $SetReplaceTypeGraph.png │ ├── $SetReplaceTypes.png │ ├── AbortedEvolutionObject.png │ ├── AcyclicGraphTakeInput.png │ ├── AcyclicGraphTakeOutput.png │ ├── AllEventOrderingFunctionPlots.png │ ├── AllEventsRuleIndicesOfEvolutionObject.png │ ├── AllEventsStatesListPlot.png │ ├── ArgumentChecks.png │ ├── ArithmeticModelCausalGraph.png │ ├── ArithmeticModelExpressionsEventsGraph.png │ ├── ArithmeticModelLayeredCausalGraph.png │ ├── AtomicStateMultihistory.png │ ├── AtomicStateSystemExample.png │ ├── AtomicStateToMultisetMultihistory.png │ ├── AtomicStateToMultisetMultihistoryVersioned.png │ ├── AutomaticStepsGrowing.png │ ├── AutomaticStepsNotGrowing.png │ ├── BasicHypergraphPlot.png │ ├── BinaryAndUnaryEdgesPlot.png │ ├── BranchlikeMatching.png │ ├── BuildTime.png │ ├── CausalDensityDimensionInput.png │ ├── CausalGraphStyles.png │ ├── ColoredCausalGraph.png │ ├── CyclicPlot.png │ ├── DifferentOrdersDifferentFinalStates.png │ ├── DifferentOrdersDifferentHistories.png │ ├── DirectedCircularGridGraph.png │ ├── EventsCountOfEvolutionObject.png │ ├── EventsStatesPlotsList.png │ ├── EvolutionObject10Steps.png │ ├── EvolutionObject3Steps.png │ ├── EvolutionObjectFromMultipleRules.png │ ├── EvolutionObjectWithDroppedGenerations.png │ ├── EvolutionObjectWithPartialGenerations.png │ ├── EvolutionResult100Steps.png │ ├── EvolutionResult10Steps.png │ ├── EvolutionResult1Step.png │ ├── ExpressionsEventsGraphWithBoundaryEvents.png │ ├── FakeStyledSpatialGraph3D.png │ ├── FastSymbolicTiming.png │ ├── FeatureAssociationExampleMultihistory.png │ ├── FeatureAssociationExampleSingleHistory.png │ ├── FeatureAssociationFeatureSpacePlot.png │ ├── FeatureVectorExampleSingleHistory.png │ ├── FeatureVectorFeatureSpacePlot.png │ ├── FinalStatePlot.png │ ├── FinalStatePlotWithVertexLabels.png │ ├── FoliatedExpressionsEventsGraph.png │ ├── GenerateMultihistoryExample.png │ ├── GenerateSingleHistoryExample.png │ ├── GenerationColoredStatePlots.png │ ├── GenerationOfEvolutionObject.png │ ├── GlobalSpacelikeEvolution.png │ ├── GridGraph.png │ ├── GridGraphWithCoordinateNamedVertices.png │ ├── GridGraphWithDifferentEdgeStyles.png │ ├── HighlightMissingArgumentsWithTemplate.png │ ├── HyperSelfLoopDoubleBinaryEdgesComparison.png │ ├── HypergraphModelCausalGraph.png │ ├── HypergraphModelLayeredCausalGraph.png │ ├── HypergraphPlot.png │ ├── HypergraphToGraphDirectedDistancePreserving.png │ ├── HypergraphToGraphStructurePreserving.png │ ├── HypergraphToGraphUndirectedDistancePreserving.png │ ├── HypergraphUnificationsPlot.png │ ├── HypergraphUnificationsPlotWithMultipleArities.png │ ├── IncorrectlyScaledPlot.png │ ├── IncorrectlyScaledRulePlot.png │ ├── InputFormOfEvolutionObject.png │ ├── MatchAllQuantumSpacelikeMatching.png │ ├── MatchAllSpacelikeBranchlikeMixed.png │ ├── MaxDestroyerEvents1.png │ ├── MaxDestroyerEvents5.png │ ├── MaxDestroyerEventsInfinity.png │ ├── MaxEventsExample.png │ ├── MaxGeneration.png │ ├── MaxGenerationsFinalStatePlot.png │ ├── MaxVerticesEvolutionObject.png │ ├── MaxVerticesFinalStatePlot.png │ ├── MinEventInputs0.png │ ├── MinEventInputs2.png │ ├── MultiedgesPlot.png │ ├── MultipleRulesPlot.png │ ├── MultisetMultihistory.png │ ├── MultisetSubstitutionSystemConditionsAndSequences.png │ ├── MultisetSubstitutionSystemExample.png │ ├── MultisetSubstitutionSystemPartialMultihistory.png │ ├── MultiwayExpressionsEventsGraph.png │ ├── MultiwayExpressionsEventsGraphEchoed.png │ ├── MultiwayExpressionsEventsGraphIndex.png │ ├── MyrheimMeyer.png │ ├── NoArgumentChecks.png │ ├── NoBranchlikeMatching.png │ ├── NonoverlappingEvolutionWithAutomaticOrdering.png │ ├── NonoverlappingEvolutionWithNewestEdgeOrdering.png │ ├── NonoverlappingRandomEvolutionComparison.png │ ├── OverlappingEvolutionAutomaticOrdering.png │ ├── OverlappingEvolutionRuleOrderingOrdering.png │ ├── PlotOfHypergraphFragment.png │ ├── PlotWithAritywiseStyles.png │ ├── PlotWithCompensatedScale.png │ ├── PlotWithCustomCoordinates.png │ ├── PlotWithCustomEdgePolygonStyle.png │ ├── PlotWithCustomEdgeStyle.png │ ├── PlotWithCustomElementSizes.png │ ├── PlotWithCustomPlotStyle.png │ ├── PlotWithCustomVertexStyle.png │ ├── PlotWithElementwiseStyles.png │ ├── PlotWithGreenHighlight.png │ ├── PlotWithHighlight.png │ ├── PlotWithImageSize.png │ ├── PlotWithMaxImageSize.png │ ├── PlotWithMultiedgeHighlight.png │ ├── PlotWithNoArrowsAndVertices.png │ ├── PlotWithVertexLabels.png │ ├── PropertiesOfEvolutionObject.png │ ├── RandomEvolutionObject.png │ ├── RandomEvolutionPlotWithDroppedGenerations.png │ ├── RulePlot.png │ ├── RulePlotWithCustomCoordinates.png │ ├── RulePlotWithSharedEdges.png │ ├── RulePlotWithSmallSpacings.png │ ├── RulePlotWolframModelEvolutionObjectInput.png │ ├── SameStateMultipleMatches.png │ ├── SelfLoopsPlot.png │ ├── SeparationComparison.png │ ├── SetReplaceObjectQOfMultihistory.png │ ├── SetReplaceObjectTypeOfMultihistory.png │ ├── SinglewayExpressionsEventsGraphEchoed.png │ ├── SlowLowLevelTiming.png │ ├── SpacelikeMatching.png │ ├── SpatialGraph3DOptions.png │ ├── SpatialGraphEdgePolygonStyle.png │ ├── SquareRulePlot.png │ ├── StateAfterEventOfEvolutionObject.png │ ├── StateAfterEventPlot.png │ ├── StatesListOfEvolutionObject.png │ ├── StatesListPlot.png │ ├── SubgraphsHyperedgeRendering.png │ ├── SymmetricHypergraphPlot.png │ ├── TimeConstrainedEvolutionObject.png │ ├── TimelikeMatching.png │ ├── TokenEventGraphGenerations.png │ ├── TraditionalSignature.png │ ├── TwoIdentifiedMatchOrders.png │ ├── TwoIsomorphicMatchOrders.png │ ├── TwoMatchOrdersDifferentOutcomes.png │ ├── TwoMatchOrdersSameOutcome.png │ └── UnorderedPlot.png ├── Properties │ └── README.md ├── SymbolsAndFunctions │ ├── HypergraphPlot.md │ ├── RulePlotOfWolframModel.md │ ├── SetReplace.md │ ├── ToPatternRules.md │ ├── UtilityFunctions │ │ ├── AcyclicGraphTake.md │ │ ├── BuildData.md │ │ ├── CausalDensityDimension.md │ │ ├── GeneralizedGridGraph.md │ │ ├── HypergraphAutomorphismGroup.md │ │ ├── HypergraphToGraph.md │ │ ├── HypergraphUnifications.md │ │ ├── IndexHypergraph.md │ │ ├── IsomorphicHypergraphQ.md │ │ ├── RandomHypergraph.md │ │ ├── SetReplaceStyleData.md │ │ ├── Subhypergraph.md │ │ └── WolframModelRuleValue.md │ └── WolframModelAndWolframModelEvolutionObject │ │ ├── Options │ │ ├── EventDeduplication.md │ │ ├── EventOrderingFunction.md │ │ ├── EventSelectionFunction.md │ │ ├── IncludeBoundaryEvents.md │ │ ├── IncludePartialGenerations.md │ │ ├── Method.md │ │ ├── TimeConstraint.md │ │ └── VertexNamingFunction.md │ │ ├── Properties │ │ ├── AllEdgesThroughoutEvolution.md │ │ ├── CausalGraphs.md │ │ ├── CreatorAndDestroyerEvents.md │ │ ├── EdgeAndEventGenerations.md │ │ ├── ElementCountLists.md │ │ ├── EventCounts.md │ │ ├── Events.md │ │ ├── EventsAndStates.md │ │ ├── ExpressionSeparations.md │ │ ├── FeatureAssociation.md │ │ ├── FeatureVector.md │ │ ├── FinalElementCounts.md │ │ ├── GenerationCounts.md │ │ ├── MultiwayQ.md │ │ ├── PlotsOfEvents.md │ │ ├── PlotsOfStates.md │ │ ├── RuleIndicesForEvents.md │ │ ├── Rules.md │ │ ├── States.md │ │ ├── StatesAsEdgeIndices.md │ │ ├── TerminationReason.md │ │ ├── TotalElementCounts.md │ │ └── Version.md │ │ └── WolframModelAndWolframModelEvolutionObject.md ├── Systems │ ├── AtomicStateSystem.md │ ├── MultisetSubstitutionSystem.md │ └── README.md ├── TypeSystem │ ├── $SetReplaceProperties.md │ ├── $SetReplaceTypeGraph.md │ ├── $SetReplaceTypes.md │ ├── README.md │ ├── SetReplaceMethodImplementation.md │ ├── SetReplaceObjectQ.md │ ├── SetReplaceObjectType.md │ ├── SetReplaceProperty.md │ ├── SetReplaceType.md │ └── SetReplaceTypeConvert.md └── Types │ ├── Multihistory │ ├── AtomicStateSystem0.md │ ├── MultisetSubstitutionSystem0.md │ └── README.md │ └── README.md ├── Kernel ├── $graphIcon.m ├── A0$messages.m ├── A0$style.m ├── A00$buildData.m ├── A01$libSetReplace.m ├── A1$generatorSystem.m ├── A1$typeSystem.m ├── A1$utilities.m ├── AcyclicGraphTake.m ├── AtomicStateSystem.m ├── CausalDensityDimension.m ├── GeneralizedGridGraph.m ├── HypergraphAutomorphismGroup.m ├── HypergraphPlot.m ├── HypergraphToGraph.m ├── HypergraphUnifications.m ├── HypergraphUnificationsPlot.m ├── IndexHypergraph.m ├── IsomorphicHypergraphQ.m ├── Multihistory.m ├── MultisetSubstitutionSystem.m ├── MultisetToWolframModelEvolutionObject.m ├── RandomHypergraph.m ├── RulePlot.m ├── SetReplace.m ├── SetReplaceAll.m ├── SetReplaceFixedPoint.m ├── SetReplaceFixedPointList.m ├── SetReplaceList.m ├── SetReplaceStyleData.m ├── Subhypergraph.m ├── ToPatternRules.m ├── WolframModel.m ├── WolframModelEvolutionObject.m ├── WolframModelRuleValue.m ├── argumentsChecking.m ├── arrow.m ├── convexHullPolygon.m ├── globals.m ├── init.m ├── setSubstitutionSystem$cpp.m ├── setSubstitutionSystem$wl.m ├── setSubstitutionSystem.m ├── systemGenerators.m ├── systemParameters.m ├── testUtilities.m └── toCanonicalRules.m ├── LICENSE ├── PacletInfo.m ├── README.md ├── Research ├── ConfluenceAndCausalInvariance │ ├── ConfluenceAndCausalInvariance.md │ └── Images │ │ ├── CausalInvariantCausalGraphs.png │ │ ├── CausalInvariantEvolutions.png │ │ ├── CausalInvariantMultiwaySystem.png │ │ ├── CausalInvariantStatesGraph.png │ │ ├── ConfluentCausalGraphs.png │ │ ├── ConfluentStatesGraph.png │ │ ├── LargeCausalInvariantEvolution.png │ │ └── LargeConfluentEvolution.png └── LocalMultiwaySystem │ ├── Images │ ├── BasicGlobalMultiway.png │ ├── BranchingGlobalMultiway.png │ ├── GlobalMultiwayEventSeparation.png │ ├── GlobalMultiwayIsomorphism.png │ ├── GlobalMultiwayParticle.png │ ├── IsomorphicBranching.png │ ├── LocalMultiwayEventSeparation.png │ ├── LocalMultiwayIsomorphism.png │ ├── LocalMultiwayNoIsomorphism.png │ ├── LocalMultiwayParticle.png │ ├── LocalMultiwayParticleInit.png │ ├── LocalMultiwayParticleSpringElectrical.png │ ├── MatchAllBranchlikeMatching.png │ ├── MatchAllQuantumSpacelikeMatching.png │ ├── MatchAllRepeatingMatching.png │ ├── MatchAllSpacelikeBranchlikeMixed.png │ ├── MatchAllTimelikeMatching.png │ ├── SeparationComparison.png │ └── WanderingParticleRule.png │ └── LocalMultiwaySystem.md ├── SetReplace.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings └── xcshareddata │ └── xcschemes │ ├── SetReplace.xcscheme │ └── SetReplaceTests.xcscheme ├── Tests ├── AcyclicGraphTake.wlt ├── AtomicStateSystem.wlt ├── CausalDensityDimension.wlt ├── GeneralizedGridGraph.wlt ├── HypergraphAutomorphismGroup.wlt ├── HypergraphPlot.wlt ├── HypergraphToGraph.wlt ├── HypergraphUnifications.wlt ├── HypergraphUnificationsPlot.wlt ├── IndexHypergraph.wlt ├── IsomorphicHypergraphQ.wlt ├── Multihistory.wlt ├── MultisetSubstitutionSystem.wlt ├── MultisetToWolframModelEvolutionObject.wlt ├── RandomHypergraph.wlt ├── RulePlot.wlt ├── SetReplace.wlt ├── SetReplaceAll.wlt ├── SetReplaceFixedPoint.wlt ├── SetReplaceFixedPointList.wlt ├── SetReplaceList.wlt ├── SetReplaceStyleData.wlt ├── Subhypergraph.wlt ├── ToPatternRules.wlt ├── WolframModel.wlt ├── WolframModelEvolutionObject.wlt ├── WolframModelRuleValue.wlt ├── buildData.wlt ├── convexHullPolygon.wlt ├── eventDeduplication.wlt ├── eventOrderingFunction.wlt ├── eventSelectionFunction.wlt ├── evolutionConsistency.wlt ├── generatorSystem.wlt ├── hypergraphMatching.wlt ├── lowLevelEvolution.wlt ├── message.wlt ├── meta.wlt ├── performance.wlt ├── symbolicEvolution.wlt ├── typeSystem.wlt └── utilities.wlt ├── build.wls ├── cmake └── SetReplaceConfig.cmake.in ├── install.wls ├── libSetReplace ├── AtomsIndex.cpp ├── AtomsIndex.hpp ├── HypergraphMatcher.cpp ├── HypergraphMatcher.hpp ├── HypergraphSubstitutionSystem.cpp ├── HypergraphSubstitutionSystem.hpp ├── IDTypes.hpp ├── Parallelism.cpp ├── Parallelism.hpp ├── Rule.hpp ├── TokenEventGraph.cpp ├── TokenEventGraph.hpp ├── WolframHeaders │ ├── WolframLibrary.h │ ├── dllexport.h │ └── extern.h ├── WolframLanguageAPI.cpp ├── WolframLanguageAPI.hpp └── test │ ├── CMakeLists.txt │ ├── HypergraphSubstitutionSystem_test.cpp │ ├── Parallelism_tests.cpp │ └── profile_tests.cpp ├── libSetReplaceTest.sh ├── lint.sh ├── pack.wls ├── performanceTest.wls ├── scripts ├── activateWolframScript.sh ├── buildLibraryResources.sh ├── checkLineWidth.sh ├── git_hooks │ ├── pre-commit │ └── pre-push ├── install_git_hooks.sh ├── version.wl └── whitespaceFormat.sh └── test.wls /.circleci/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | if [ "$CIRCLE_NODE_INDEX" -eq 2 ]; then 5 | testsToRun=hypergraphMatching 6 | elif [ "$CIRCLE_NODE_INDEX" -eq 3 ]; then 7 | testsToRun=WolframModel 8 | else 9 | mapfile -t testsToRun < <(circleci tests glob "Tests/*.wlt" | 10 | sed "/Tests\/performance.wlt/d" | 11 | sed "/Tests\/hypergraphMatching.wlt/d" | 12 | sed "/Tests\/WolframModel.wlt/d" | 13 | circleci tests split --total=2 --split-by=filesize | 14 | sed "s/\.wlt//" | 15 | sed "s/Tests\///") 16 | fi 17 | 18 | rm -f exit_status.txt 19 | STATUS_FILE=1 ./test.wls -lip "${testsToRun[@]}" 20 | [[ -f exit_status.txt && $( {list_}}; 9 | 10 | SetUsage @ " 11 | ConsolePrintList[list$] will print a list of items in InputForm, one per line, with commas as appropriate. 12 | "; 13 | 14 | ConsolePrintList[list_List] := ( 15 | Print["{"]; 16 | Scan[Print[" ", ToString[#, InputForm], ","]&, Most @ list]; 17 | Print[" ", ToString[#, InputForm]]& @ Last @ list; 18 | Print["}"]; 19 | ); 20 | 21 | SyntaxInformation[ConsoleTryEnvironment] = {"ArgumentsPattern" -> {var_, default_}}; 22 | 23 | SetUsage @ " 24 | ConsoleTryEnvironment[var$, default$] will look up the value of the environment variable var$, but use \ 25 | default$ if it is not availabe. 26 | "; 27 | 28 | SetAttributes[ConsoleTryEnvironment, HoldRest]; 29 | ConsoleTryEnvironment[var_, default_] := Replace[$Failed :> default] @ Environment[var]; 30 | -------------------------------------------------------------------------------- /DevUtils/FileTreeHashes.m: -------------------------------------------------------------------------------- 1 | Package["SetReplaceDevUtils`"] 2 | 3 | PackageImport["GeneralUtilities`"] 4 | 5 | PackageExport["FileTreeHashes"] 6 | 7 | SyntaxInformation[FileTreeHashes] = {"ArgumentsPattern" -> {path_, pattern_, depth_., excludeList_.}}; 8 | 9 | FE`Evaluate[FEPrivate`AddSpecialArgCompletion["FileTreeHashes" -> {2, 0, 0, 0}]]; 10 | 11 | SetUsage @ " 12 | FileTreeHashes['path$', pattern$, depth$, excludeList$] returns a list of pairs consisting of {'filename', hash}. 13 | * The files found are those matching pattern$ that are within 'path$'. 14 | * The file pattern pattern$ is as used by FileNames, and can be a list. 15 | * depth$ instructs FileTreeHash how many directories to preserve from the returned absolute paths to ensure they 16 | are independent of the overall location of a file tree on disk. 17 | * excludeList$ can contain a list of file names to exclude. 18 | "; 19 | 20 | FileTreeHashes[path_, pattern_, depth_:1, excludeList_:{}] := ModuleScope[ 21 | path = AbsoluteFileName[path]; 22 | If[FailureQ[path] || !DirectoryQ[path], Return[$Failed]]; 23 | fileNames = FileNames[pattern, path, IgnoreCase -> True]; 24 | If[excludeList =!= {}, 25 | fileNames = Discard[fileNames, StringEndsQ[#, excludeList, IgnoreCase -> True] &] 26 | ]; 27 | hashes = FileHash[fileNames, "SHA"]; 28 | (* strip off *depth* subdirs to get the canonical path *) 29 | fileNames = StringDrop[fileNames, StringLength @ FileNameDrop[path, -depth]]; 30 | Transpose[{fileNames, hashes}] 31 | ]; 32 | -------------------------------------------------------------------------------- /DevUtils/init.m: -------------------------------------------------------------------------------- 1 | Package["SetReplaceDevUtils`"] 2 | 3 | (* SetReplaceDevUtils is *not* included in paclet builds, so is not visible to users, 4 | but is available for developer workflow purposes, and is used by the build scripts *) 5 | 6 | PackageImport["GeneralUtilities`"] 7 | 8 | PackageExport["$SetReplaceRoot"] 9 | PackageExport["$DevUtilsRoot"] 10 | PackageExport["$DevUtilsTemporaryDirectory"] 11 | 12 | SetUsage @ " 13 | $SetReplaceRoot is the directory from which SetReplace was loaded. 14 | "; 15 | 16 | $SetReplaceRoot = FileNameDrop[$InputFileName, -2]; 17 | 18 | SetUsage @ " 19 | $DevUtilsRoot is the directory from which the DevUtils package was loaded. 20 | "; 21 | 22 | $DevUtilsRoot = FileNameDrop[$InputFileName, -1]; 23 | 24 | SetUsage @ " 25 | $DevUtilsTemporaryDirectory is the temprary directory that DevUtils uses. 26 | "; 27 | 28 | $DevUtilsTemporaryDirectory := EnsureDirectory @ FileNameJoin[{$TemporaryDirectory, "SetReplace"}]; 29 | -------------------------------------------------------------------------------- /Documentation/Generators/$SetReplaceGenerators.md: -------------------------------------------------------------------------------- 1 | # $SetReplaceGenerators 2 | 3 | **`$SetReplaceGenerators`** gives the list of all generators that can be used to evaluate 4 | [computational systems](/Documentation/Systems/README.md): 5 | 6 | ```wl 7 | In[] := $SetReplaceGenerators 8 | Out[] = {GenerateMultihistory, GenerateSingleHistory} 9 | ``` 10 | -------------------------------------------------------------------------------- /Documentation/Generators/$SetReplaceSystems.md: -------------------------------------------------------------------------------- 1 | # $SetReplaceSystems 2 | 3 | **`$SetReplaceSystems`** gives the list of all [computational systems](/Documentation/Systems/README.md) that can be 4 | used with [GenerateMultihistory](/Documentation/Generators/GenerateMultihistory.md) and other [generators](README.md): 5 | 6 | ```wl 7 | In[] := $SetReplaceSystems 8 | Out[] = {AtomicStateSystem, MultisetSubstitutionSystem} 9 | ``` 10 | -------------------------------------------------------------------------------- /Documentation/Generators/GenerateMultihistory.md: -------------------------------------------------------------------------------- 1 | # GenerateMultihistory 2 | 3 | **`GenerateMultihistory`** is the most configurable multihistory generator. With no parameters specified, it attempts to 4 | generate all possible histories starting from the initial state. However, it can be configured to generate partial 5 | multihistories and even single histories, although [`GenerateSingleHistory`](GenerateSingleHistory.md) is more 6 | convenient for that. 7 | 8 | For example, for a [`MultisetSubstitutionSystem`](/Documentation/Systems/MultisetSubstitutionSystem.md): 9 | 10 | ```wl 11 | In[] := multihistory = GenerateMultihistory[ 12 | MultisetSubstitutionSystem[{a_, b_} :> {a + b}], MaxDestroyerEvents -> 3, MaxEvents -> 10] @ {1, 2, 3, 4} 13 | ``` 14 | 15 | 16 | 17 | ```wl 18 | In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] & @ 19 | SetReplaceTypeConvert[WolframModelEvolutionObject] @ multihistory 20 | ``` 21 | 22 | 23 | -------------------------------------------------------------------------------- /Documentation/Generators/GenerateSingleHistory.md: -------------------------------------------------------------------------------- 1 | # GenerateSingleHistory 2 | 3 | **`GenerateSingleHistory`** generates single histories, which it achieves by setting 4 | [`MaxDestroyerEvents`](MaxDestroyerEvents.md) to one. Note that for nondeterministic systems, the history generated may 5 | depend on the event order. 6 | 7 | For example, for a [`MultisetSubstitutionSystem`](/Documentation/Systems/MultisetSubstitutionSystem.md): 8 | 9 | ```wl 10 | In[] := multihistory = GenerateSingleHistory[ 11 | MultisetSubstitutionSystem[{a_, b_} :> {a + b, a - b, a * b}], MaxEvents -> 10] @ {1, 2} 12 | ``` 13 | 14 | 15 | 16 | ```wl 17 | In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] & @ 18 | SetReplaceTypeConvert[WolframModelEvolutionObject] @ multihistory 19 | ``` 20 | 21 | 22 | 23 | Note that there is a distinction between single-history and single-path systems. Single-path systems are defined as ones 24 | where there is only one event possible from every state. A Turing machine would be an example of a single-path system. 25 | On the other hand, single-history systems allow multiple events from a single state, but all these events must be 26 | consistent, i.e., take non-overlapping inputs. Neither single-path nor single-history systems have branchlike-separated 27 | events. 28 | -------------------------------------------------------------------------------- /Documentation/Generators/MaxDestroyerEvents.md: -------------------------------------------------------------------------------- 1 | # MaxDestroyerEvents 2 | 3 | `MaxDestroyerEvents` is an event-selection parameter that controls the number of inconsistent events allowed to take the 4 | same token as an input. [`GenerateSingleHistory`](GenerateSingleHistory.md) limits the evaluation to a single history by 5 | setting `MaxDestroyerEvents` to one. 6 | 7 | ```wl 8 | In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] & @ 9 | SetReplaceTypeConvert[WolframModelEvolutionObject] @ 10 | GenerateMultihistory[MultisetSubstitutionSystem[{a_, b_} :> {a + b}], MaxDestroyerEvents -> 1] @ {1, 2, 3} 11 | ``` 12 | 13 | 14 | 15 | If unset (which defaults to [`Infinity`](https://reference.wolfram.com/language/ref/Infinity.html)), it will generate a 16 | full multihistory object subject to other selection and stopping parameters: 17 | 18 | ```wl 19 | In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] & @ 20 | SetReplaceTypeConvert[WolframModelEvolutionObject] @ 21 | GenerateMultihistory[ 22 | MultisetSubstitutionSystem[{a_, b_} :> {a + b}], MaxDestroyerEvents -> Infinity, MaxGeneration -> 1] @ {1, 2, 3} 23 | ``` 24 | 25 | 26 | 27 | If set to a finite number, it will generate a partial multihistory: 28 | 29 | ```wl 30 | In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] & @ 31 | SetReplaceTypeConvert[WolframModelEvolutionObject] @ 32 | GenerateMultihistory[MultisetSubstitutionSystem[{a_, b_} :> {a + b}], MaxDestroyerEvents -> 5] @ {1, 2, 3} 33 | ``` 34 | 35 | 36 | 37 | Note that results generally depend on the event order in this case, similar to single histories. 38 | -------------------------------------------------------------------------------- /Documentation/Generators/MaxEventInputs.md: -------------------------------------------------------------------------------- 1 | # MaxEventInputs 2 | 3 | `MaxEventInputs` and [`MinEventInputs`](MinEventInputs.md) are event-selection parameters that control the maximum and 4 | minimum numbers of input tokens allowed per event. 5 | 6 | In addition to [being useful](MinEventInputs.md) for rules with variable numbers of inputs, `MaxEventInputs` is 7 | sometimes useful for optimization. By default, systems like 8 | [`MultisetSubstitutionSystem`](/Documentation/Systems/MultisetSubstitutionSystem.md) consider all subsets of tokens to 9 | find matches, which can be slow. However, if the range of match sizes is known ahead of time, one can set it explicitly 10 | to reduce the number of matches enumerated. Compare: 11 | 12 | ```wl 13 | In[] := First @ AbsoluteTiming @ 14 | GenerateMultihistory[ 15 | MultisetSubstitutionSystem[{a___} /; Length[{a}] == 4 :> {Total[{a}]}], MaxEvents -> 20, #] @ {1, 2, 3, 4} & /@ 16 | {{}, {MinEventInputs -> 4, MaxEventInputs -> 4}} 17 | Out[] = {0.793215, 0.014419} 18 | ``` 19 | -------------------------------------------------------------------------------- /Documentation/Generators/MaxEvents.md: -------------------------------------------------------------------------------- 1 | # MaxEvents 2 | 3 | `MaxEvents` is the most basic stopping condition. It stops the evaluation once the given number of events is reached 4 | (regardless of causal dependencies between these events): 5 | 6 | ```wl 7 | In[] := #["ExpressionsEventsGraph"] & @ 8 | SetReplaceTypeConvert[WolframModelEvolutionObject] @ 9 | GenerateMultihistory[MultisetSubstitutionSystem[{a_, b_} /; a < b :> {a + b}], MaxEvents -> 9] @ {1, 2, 3, 4} 10 | ``` 11 | 12 | 13 | 14 | Compare to [`MaxGeneration`](MaxGeneration.md), which controls the depth of the evaluation instead. 15 | -------------------------------------------------------------------------------- /Documentation/Generators/MinEventInputs.md: -------------------------------------------------------------------------------- 1 | # MinEventInputs 2 | 3 | `MinEventInputs` and [`MaxEventInputs`](MaxEventInputs.md) are event-selection parameters that control the min and max 4 | numbers of input tokens allowed per event. These parameters are useful in systems where rules with variable numbers of 5 | inputs are possible, such as [`MultisetSubstitutionSystem`](/Documentation/Systems/MultisetSubstitutionSystem.md). 6 | Compare, for example, `MinEventInputs -> 0` (default): 7 | 8 | ```wl 9 | In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] & @ 10 | SetReplaceTypeConvert[WolframModelEvolutionObject] @ 11 | GenerateMultihistory[ 12 | MultisetSubstitutionSystem[{a___} :> {Total[{a}]}], MinEventInputs -> 0, MaxEvents -> 10] @ {1, 2, 3} 13 | ``` 14 | 15 | 16 | 17 | and `MinEventInputs -> 2`: 18 | 19 | ```wl 20 | In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] & @ 21 | SetReplaceTypeConvert[WolframModelEvolutionObject] @ 22 | GenerateMultihistory[ 23 | MultisetSubstitutionSystem[{a___} :> {Total[{a}]}], MinEventInputs -> 2, MaxEvents -> 10] @ {1, 2, 3} 24 | ``` 25 | 26 | 27 | -------------------------------------------------------------------------------- /Documentation/Generators/SetReplaceSystemParameters.md: -------------------------------------------------------------------------------- 1 | # SetReplaceSystemParameters 2 | 3 | **`SetReplaceSystemParameters`** gives the list of parameters that can be used as keys in generators such as 4 | [`GenerateMultihistory`](GenerateMultihistory.md): 5 | 6 | ```wl 7 | In[] := SetReplaceSystemParameters[MultisetSubstitutionSystem] 8 | Out[] = {MaxGeneration, MaxDestroyerEvents, MinEventInputs, MaxEventInputs, MaxEvents} 9 | ``` 10 | 11 | The entire system spec including the rules can be passed as well (rules don't affect the result): 12 | 13 | ```wl 14 | In[] := SetReplaceSystemParameters[AtomicStateSystem[a_ :> a + 1]] 15 | Out[] = {MaxGeneration, MaxDestroyerEvents, MaxEvents} 16 | ``` 17 | -------------------------------------------------------------------------------- /Documentation/Images/$SetReplaceTypeGraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/$SetReplaceTypeGraph.png -------------------------------------------------------------------------------- /Documentation/Images/$SetReplaceTypes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/$SetReplaceTypes.png -------------------------------------------------------------------------------- /Documentation/Images/AbortedEvolutionObject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/AbortedEvolutionObject.png -------------------------------------------------------------------------------- /Documentation/Images/AcyclicGraphTakeInput.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/AcyclicGraphTakeInput.png -------------------------------------------------------------------------------- /Documentation/Images/AcyclicGraphTakeOutput.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/AcyclicGraphTakeOutput.png -------------------------------------------------------------------------------- /Documentation/Images/AllEventOrderingFunctionPlots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/AllEventOrderingFunctionPlots.png -------------------------------------------------------------------------------- /Documentation/Images/AllEventsRuleIndicesOfEvolutionObject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/AllEventsRuleIndicesOfEvolutionObject.png -------------------------------------------------------------------------------- /Documentation/Images/AllEventsStatesListPlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/AllEventsStatesListPlot.png -------------------------------------------------------------------------------- /Documentation/Images/ArgumentChecks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/ArgumentChecks.png -------------------------------------------------------------------------------- /Documentation/Images/ArithmeticModelCausalGraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/ArithmeticModelCausalGraph.png -------------------------------------------------------------------------------- /Documentation/Images/ArithmeticModelExpressionsEventsGraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/ArithmeticModelExpressionsEventsGraph.png -------------------------------------------------------------------------------- /Documentation/Images/ArithmeticModelLayeredCausalGraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/ArithmeticModelLayeredCausalGraph.png -------------------------------------------------------------------------------- /Documentation/Images/AtomicStateMultihistory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/AtomicStateMultihistory.png -------------------------------------------------------------------------------- /Documentation/Images/AtomicStateSystemExample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/AtomicStateSystemExample.png -------------------------------------------------------------------------------- /Documentation/Images/AtomicStateToMultisetMultihistory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/AtomicStateToMultisetMultihistory.png -------------------------------------------------------------------------------- /Documentation/Images/AtomicStateToMultisetMultihistoryVersioned.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/AtomicStateToMultisetMultihistoryVersioned.png -------------------------------------------------------------------------------- /Documentation/Images/AutomaticStepsGrowing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/AutomaticStepsGrowing.png -------------------------------------------------------------------------------- /Documentation/Images/AutomaticStepsNotGrowing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/AutomaticStepsNotGrowing.png -------------------------------------------------------------------------------- /Documentation/Images/BasicHypergraphPlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/BasicHypergraphPlot.png -------------------------------------------------------------------------------- /Documentation/Images/BinaryAndUnaryEdgesPlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/BinaryAndUnaryEdgesPlot.png -------------------------------------------------------------------------------- /Documentation/Images/BranchlikeMatching.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/BranchlikeMatching.png -------------------------------------------------------------------------------- /Documentation/Images/BuildTime.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/BuildTime.png -------------------------------------------------------------------------------- /Documentation/Images/CausalDensityDimensionInput.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/CausalDensityDimensionInput.png -------------------------------------------------------------------------------- /Documentation/Images/CausalGraphStyles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/CausalGraphStyles.png -------------------------------------------------------------------------------- /Documentation/Images/ColoredCausalGraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/ColoredCausalGraph.png -------------------------------------------------------------------------------- /Documentation/Images/CyclicPlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/CyclicPlot.png -------------------------------------------------------------------------------- /Documentation/Images/DifferentOrdersDifferentFinalStates.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/DifferentOrdersDifferentFinalStates.png -------------------------------------------------------------------------------- /Documentation/Images/DifferentOrdersDifferentHistories.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/DifferentOrdersDifferentHistories.png -------------------------------------------------------------------------------- /Documentation/Images/DirectedCircularGridGraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/DirectedCircularGridGraph.png -------------------------------------------------------------------------------- /Documentation/Images/EventsCountOfEvolutionObject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/EventsCountOfEvolutionObject.png -------------------------------------------------------------------------------- /Documentation/Images/EventsStatesPlotsList.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/EventsStatesPlotsList.png -------------------------------------------------------------------------------- /Documentation/Images/EvolutionObject10Steps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/EvolutionObject10Steps.png -------------------------------------------------------------------------------- /Documentation/Images/EvolutionObject3Steps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/EvolutionObject3Steps.png -------------------------------------------------------------------------------- /Documentation/Images/EvolutionObjectFromMultipleRules.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/EvolutionObjectFromMultipleRules.png -------------------------------------------------------------------------------- /Documentation/Images/EvolutionObjectWithDroppedGenerations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/EvolutionObjectWithDroppedGenerations.png -------------------------------------------------------------------------------- /Documentation/Images/EvolutionObjectWithPartialGenerations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/EvolutionObjectWithPartialGenerations.png -------------------------------------------------------------------------------- /Documentation/Images/EvolutionResult100Steps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/EvolutionResult100Steps.png -------------------------------------------------------------------------------- /Documentation/Images/EvolutionResult10Steps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/EvolutionResult10Steps.png -------------------------------------------------------------------------------- /Documentation/Images/EvolutionResult1Step.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/EvolutionResult1Step.png -------------------------------------------------------------------------------- /Documentation/Images/ExpressionsEventsGraphWithBoundaryEvents.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/ExpressionsEventsGraphWithBoundaryEvents.png -------------------------------------------------------------------------------- /Documentation/Images/FakeStyledSpatialGraph3D.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/FakeStyledSpatialGraph3D.png -------------------------------------------------------------------------------- /Documentation/Images/FastSymbolicTiming.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/FastSymbolicTiming.png -------------------------------------------------------------------------------- /Documentation/Images/FeatureAssociationExampleMultihistory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/FeatureAssociationExampleMultihistory.png -------------------------------------------------------------------------------- /Documentation/Images/FeatureAssociationExampleSingleHistory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/FeatureAssociationExampleSingleHistory.png -------------------------------------------------------------------------------- /Documentation/Images/FeatureAssociationFeatureSpacePlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/FeatureAssociationFeatureSpacePlot.png -------------------------------------------------------------------------------- /Documentation/Images/FeatureVectorExampleSingleHistory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/FeatureVectorExampleSingleHistory.png -------------------------------------------------------------------------------- /Documentation/Images/FeatureVectorFeatureSpacePlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/FeatureVectorFeatureSpacePlot.png -------------------------------------------------------------------------------- /Documentation/Images/FinalStatePlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/FinalStatePlot.png -------------------------------------------------------------------------------- /Documentation/Images/FinalStatePlotWithVertexLabels.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/FinalStatePlotWithVertexLabels.png -------------------------------------------------------------------------------- /Documentation/Images/FoliatedExpressionsEventsGraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/FoliatedExpressionsEventsGraph.png -------------------------------------------------------------------------------- /Documentation/Images/GenerateMultihistoryExample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/GenerateMultihistoryExample.png -------------------------------------------------------------------------------- /Documentation/Images/GenerateSingleHistoryExample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/GenerateSingleHistoryExample.png -------------------------------------------------------------------------------- /Documentation/Images/GenerationColoredStatePlots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/GenerationColoredStatePlots.png -------------------------------------------------------------------------------- /Documentation/Images/GenerationOfEvolutionObject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/GenerationOfEvolutionObject.png -------------------------------------------------------------------------------- /Documentation/Images/GlobalSpacelikeEvolution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/GlobalSpacelikeEvolution.png -------------------------------------------------------------------------------- /Documentation/Images/GridGraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/GridGraph.png -------------------------------------------------------------------------------- /Documentation/Images/GridGraphWithCoordinateNamedVertices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/GridGraphWithCoordinateNamedVertices.png -------------------------------------------------------------------------------- /Documentation/Images/GridGraphWithDifferentEdgeStyles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/GridGraphWithDifferentEdgeStyles.png -------------------------------------------------------------------------------- /Documentation/Images/HighlightMissingArgumentsWithTemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/HighlightMissingArgumentsWithTemplate.png -------------------------------------------------------------------------------- /Documentation/Images/HyperSelfLoopDoubleBinaryEdgesComparison.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/HyperSelfLoopDoubleBinaryEdgesComparison.png -------------------------------------------------------------------------------- /Documentation/Images/HypergraphModelCausalGraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/HypergraphModelCausalGraph.png -------------------------------------------------------------------------------- /Documentation/Images/HypergraphModelLayeredCausalGraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/HypergraphModelLayeredCausalGraph.png -------------------------------------------------------------------------------- /Documentation/Images/HypergraphPlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/HypergraphPlot.png -------------------------------------------------------------------------------- /Documentation/Images/HypergraphToGraphDirectedDistancePreserving.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/HypergraphToGraphDirectedDistancePreserving.png -------------------------------------------------------------------------------- /Documentation/Images/HypergraphToGraphStructurePreserving.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/HypergraphToGraphStructurePreserving.png -------------------------------------------------------------------------------- /Documentation/Images/HypergraphToGraphUndirectedDistancePreserving.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/HypergraphToGraphUndirectedDistancePreserving.png -------------------------------------------------------------------------------- /Documentation/Images/HypergraphUnificationsPlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/HypergraphUnificationsPlot.png -------------------------------------------------------------------------------- /Documentation/Images/HypergraphUnificationsPlotWithMultipleArities.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/HypergraphUnificationsPlotWithMultipleArities.png -------------------------------------------------------------------------------- /Documentation/Images/IncorrectlyScaledPlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/IncorrectlyScaledPlot.png -------------------------------------------------------------------------------- /Documentation/Images/IncorrectlyScaledRulePlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/IncorrectlyScaledRulePlot.png -------------------------------------------------------------------------------- /Documentation/Images/InputFormOfEvolutionObject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/InputFormOfEvolutionObject.png -------------------------------------------------------------------------------- /Documentation/Images/MatchAllQuantumSpacelikeMatching.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/MatchAllQuantumSpacelikeMatching.png -------------------------------------------------------------------------------- /Documentation/Images/MatchAllSpacelikeBranchlikeMixed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/MatchAllSpacelikeBranchlikeMixed.png -------------------------------------------------------------------------------- /Documentation/Images/MaxDestroyerEvents1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/MaxDestroyerEvents1.png -------------------------------------------------------------------------------- /Documentation/Images/MaxDestroyerEvents5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/MaxDestroyerEvents5.png -------------------------------------------------------------------------------- /Documentation/Images/MaxDestroyerEventsInfinity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/MaxDestroyerEventsInfinity.png -------------------------------------------------------------------------------- /Documentation/Images/MaxEventsExample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/MaxEventsExample.png -------------------------------------------------------------------------------- /Documentation/Images/MaxGeneration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/MaxGeneration.png -------------------------------------------------------------------------------- /Documentation/Images/MaxGenerationsFinalStatePlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/MaxGenerationsFinalStatePlot.png -------------------------------------------------------------------------------- /Documentation/Images/MaxVerticesEvolutionObject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/MaxVerticesEvolutionObject.png -------------------------------------------------------------------------------- /Documentation/Images/MaxVerticesFinalStatePlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/MaxVerticesFinalStatePlot.png -------------------------------------------------------------------------------- /Documentation/Images/MinEventInputs0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/MinEventInputs0.png -------------------------------------------------------------------------------- /Documentation/Images/MinEventInputs2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/MinEventInputs2.png -------------------------------------------------------------------------------- /Documentation/Images/MultiedgesPlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/MultiedgesPlot.png -------------------------------------------------------------------------------- /Documentation/Images/MultipleRulesPlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/MultipleRulesPlot.png -------------------------------------------------------------------------------- /Documentation/Images/MultisetMultihistory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/MultisetMultihistory.png -------------------------------------------------------------------------------- /Documentation/Images/MultisetSubstitutionSystemConditionsAndSequences.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/MultisetSubstitutionSystemConditionsAndSequences.png -------------------------------------------------------------------------------- /Documentation/Images/MultisetSubstitutionSystemExample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/MultisetSubstitutionSystemExample.png -------------------------------------------------------------------------------- /Documentation/Images/MultisetSubstitutionSystemPartialMultihistory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/MultisetSubstitutionSystemPartialMultihistory.png -------------------------------------------------------------------------------- /Documentation/Images/MultiwayExpressionsEventsGraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/MultiwayExpressionsEventsGraph.png -------------------------------------------------------------------------------- /Documentation/Images/MultiwayExpressionsEventsGraphEchoed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/MultiwayExpressionsEventsGraphEchoed.png -------------------------------------------------------------------------------- /Documentation/Images/MultiwayExpressionsEventsGraphIndex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/MultiwayExpressionsEventsGraphIndex.png -------------------------------------------------------------------------------- /Documentation/Images/MyrheimMeyer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/MyrheimMeyer.png -------------------------------------------------------------------------------- /Documentation/Images/NoArgumentChecks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/NoArgumentChecks.png -------------------------------------------------------------------------------- /Documentation/Images/NoBranchlikeMatching.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/NoBranchlikeMatching.png -------------------------------------------------------------------------------- /Documentation/Images/NonoverlappingEvolutionWithAutomaticOrdering.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/NonoverlappingEvolutionWithAutomaticOrdering.png -------------------------------------------------------------------------------- /Documentation/Images/NonoverlappingEvolutionWithNewestEdgeOrdering.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/NonoverlappingEvolutionWithNewestEdgeOrdering.png -------------------------------------------------------------------------------- /Documentation/Images/NonoverlappingRandomEvolutionComparison.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/NonoverlappingRandomEvolutionComparison.png -------------------------------------------------------------------------------- /Documentation/Images/OverlappingEvolutionAutomaticOrdering.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/OverlappingEvolutionAutomaticOrdering.png -------------------------------------------------------------------------------- /Documentation/Images/OverlappingEvolutionRuleOrderingOrdering.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/OverlappingEvolutionRuleOrderingOrdering.png -------------------------------------------------------------------------------- /Documentation/Images/PlotOfHypergraphFragment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/PlotOfHypergraphFragment.png -------------------------------------------------------------------------------- /Documentation/Images/PlotWithAritywiseStyles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/PlotWithAritywiseStyles.png -------------------------------------------------------------------------------- /Documentation/Images/PlotWithCompensatedScale.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/PlotWithCompensatedScale.png -------------------------------------------------------------------------------- /Documentation/Images/PlotWithCustomCoordinates.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/PlotWithCustomCoordinates.png -------------------------------------------------------------------------------- /Documentation/Images/PlotWithCustomEdgePolygonStyle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/PlotWithCustomEdgePolygonStyle.png -------------------------------------------------------------------------------- /Documentation/Images/PlotWithCustomEdgeStyle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/PlotWithCustomEdgeStyle.png -------------------------------------------------------------------------------- /Documentation/Images/PlotWithCustomElementSizes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/PlotWithCustomElementSizes.png -------------------------------------------------------------------------------- /Documentation/Images/PlotWithCustomPlotStyle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/PlotWithCustomPlotStyle.png -------------------------------------------------------------------------------- /Documentation/Images/PlotWithCustomVertexStyle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/PlotWithCustomVertexStyle.png -------------------------------------------------------------------------------- /Documentation/Images/PlotWithElementwiseStyles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/PlotWithElementwiseStyles.png -------------------------------------------------------------------------------- /Documentation/Images/PlotWithGreenHighlight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/PlotWithGreenHighlight.png -------------------------------------------------------------------------------- /Documentation/Images/PlotWithHighlight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/PlotWithHighlight.png -------------------------------------------------------------------------------- /Documentation/Images/PlotWithImageSize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/PlotWithImageSize.png -------------------------------------------------------------------------------- /Documentation/Images/PlotWithMaxImageSize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/PlotWithMaxImageSize.png -------------------------------------------------------------------------------- /Documentation/Images/PlotWithMultiedgeHighlight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/PlotWithMultiedgeHighlight.png -------------------------------------------------------------------------------- /Documentation/Images/PlotWithNoArrowsAndVertices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/PlotWithNoArrowsAndVertices.png -------------------------------------------------------------------------------- /Documentation/Images/PlotWithVertexLabels.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/PlotWithVertexLabels.png -------------------------------------------------------------------------------- /Documentation/Images/PropertiesOfEvolutionObject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/PropertiesOfEvolutionObject.png -------------------------------------------------------------------------------- /Documentation/Images/RandomEvolutionObject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/RandomEvolutionObject.png -------------------------------------------------------------------------------- /Documentation/Images/RandomEvolutionPlotWithDroppedGenerations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/RandomEvolutionPlotWithDroppedGenerations.png -------------------------------------------------------------------------------- /Documentation/Images/RulePlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/RulePlot.png -------------------------------------------------------------------------------- /Documentation/Images/RulePlotWithCustomCoordinates.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/RulePlotWithCustomCoordinates.png -------------------------------------------------------------------------------- /Documentation/Images/RulePlotWithSharedEdges.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/RulePlotWithSharedEdges.png -------------------------------------------------------------------------------- /Documentation/Images/RulePlotWithSmallSpacings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/RulePlotWithSmallSpacings.png -------------------------------------------------------------------------------- /Documentation/Images/RulePlotWolframModelEvolutionObjectInput.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/RulePlotWolframModelEvolutionObjectInput.png -------------------------------------------------------------------------------- /Documentation/Images/SameStateMultipleMatches.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/SameStateMultipleMatches.png -------------------------------------------------------------------------------- /Documentation/Images/SelfLoopsPlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/SelfLoopsPlot.png -------------------------------------------------------------------------------- /Documentation/Images/SeparationComparison.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/SeparationComparison.png -------------------------------------------------------------------------------- /Documentation/Images/SetReplaceObjectQOfMultihistory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/SetReplaceObjectQOfMultihistory.png -------------------------------------------------------------------------------- /Documentation/Images/SetReplaceObjectTypeOfMultihistory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/SetReplaceObjectTypeOfMultihistory.png -------------------------------------------------------------------------------- /Documentation/Images/SinglewayExpressionsEventsGraphEchoed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/SinglewayExpressionsEventsGraphEchoed.png -------------------------------------------------------------------------------- /Documentation/Images/SlowLowLevelTiming.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/SlowLowLevelTiming.png -------------------------------------------------------------------------------- /Documentation/Images/SpacelikeMatching.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/SpacelikeMatching.png -------------------------------------------------------------------------------- /Documentation/Images/SpatialGraph3DOptions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/SpatialGraph3DOptions.png -------------------------------------------------------------------------------- /Documentation/Images/SpatialGraphEdgePolygonStyle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/SpatialGraphEdgePolygonStyle.png -------------------------------------------------------------------------------- /Documentation/Images/SquareRulePlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/SquareRulePlot.png -------------------------------------------------------------------------------- /Documentation/Images/StateAfterEventOfEvolutionObject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/StateAfterEventOfEvolutionObject.png -------------------------------------------------------------------------------- /Documentation/Images/StateAfterEventPlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/StateAfterEventPlot.png -------------------------------------------------------------------------------- /Documentation/Images/StatesListOfEvolutionObject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/StatesListOfEvolutionObject.png -------------------------------------------------------------------------------- /Documentation/Images/StatesListPlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/StatesListPlot.png -------------------------------------------------------------------------------- /Documentation/Images/SubgraphsHyperedgeRendering.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/SubgraphsHyperedgeRendering.png -------------------------------------------------------------------------------- /Documentation/Images/SymmetricHypergraphPlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/SymmetricHypergraphPlot.png -------------------------------------------------------------------------------- /Documentation/Images/TimeConstrainedEvolutionObject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/TimeConstrainedEvolutionObject.png -------------------------------------------------------------------------------- /Documentation/Images/TimelikeMatching.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/TimelikeMatching.png -------------------------------------------------------------------------------- /Documentation/Images/TokenEventGraphGenerations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/TokenEventGraphGenerations.png -------------------------------------------------------------------------------- /Documentation/Images/TraditionalSignature.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/TraditionalSignature.png -------------------------------------------------------------------------------- /Documentation/Images/TwoIdentifiedMatchOrders.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/TwoIdentifiedMatchOrders.png -------------------------------------------------------------------------------- /Documentation/Images/TwoIsomorphicMatchOrders.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/TwoIsomorphicMatchOrders.png -------------------------------------------------------------------------------- /Documentation/Images/TwoMatchOrdersDifferentOutcomes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/TwoMatchOrdersDifferentOutcomes.png -------------------------------------------------------------------------------- /Documentation/Images/TwoMatchOrdersSameOutcome.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/TwoMatchOrdersSameOutcome.png -------------------------------------------------------------------------------- /Documentation/Images/UnorderedPlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Documentation/Images/UnorderedPlot.png -------------------------------------------------------------------------------- /Documentation/Properties/README.md: -------------------------------------------------------------------------------- 1 | # Properties 2 | 3 | Properties allow one to extract data from [`Multihistory`](/Documentation/Types/Multihistory/README.md) objects, 4 | however, we have not implemented any properties yet. 5 | 6 | The list of properties can be obtained with 7 | [`$SetReplaceProperties`](/Documentation/TypeSystem/$SetReplaceProperties.md). 8 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/ToPatternRules.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > 2 | 3 | # ToPatternRules 4 | 5 | **`ToPatternRules`** is a convenience function used to quickly enter rules such as the one mentioned previously: 6 | 7 | ```wl 8 | {{v1_, v2_, v3_}, {v2_, v4_, v5_}} :> 9 | Module[{v6}, {{v5, v6, v1}, {v6, v4, v2}, {v4, v5, v3}}] 10 | ``` 11 | 12 | This is the type of rule we study the most, and it satisfies the following set of conditions: 13 | 14 | * Both input and output subsets consist of ordered lists of atomic vertices. 15 | * The input (left-hand side) only contains patterns, it never refers to explicit vertex names. 16 | * The name of the vertex is only used to identify it, it does not contain any additional information. In particular, 17 | there are no conditions on the left-hand side of the rule (neither on the entire subset nor on individual vertices or 18 | edges), except for the implicit condition of the same vertices appearing multiple times. 19 | * The output may contain new vertices (the ones that don't appear on the left-hand side), in which 20 | case [`Module`](https://reference.wolfram.com/language/ref/Module.html) is used to create them. 21 | 22 | `ToPatternRules` provides a more straightforward way to specify such rules by automatically assuming that all level-2 23 | expressions on the left-hand side are patterns, and vertices used on the right that don't appear on the left are new and 24 | should be created with a [`Module`](https://reference.wolfram.com/language/ref/Module.html). For example, the rule above 25 | can simply be written as 26 | 27 | ```wl 28 | In[] := ToPatternRules[{{v1, v2, v3}, {v2, v4, v5}} -> 29 | {{v5, v6, v1}, {v6, v4, v2}, {v4, v5, v3}}] 30 | Out[] = {{v1_, v2_, v3_}, {v2_, v4_, v5_}} :> 31 | Module[{v6}, {{v5, v6, v1}, {v6, v4, v2}, {v4, v5, v3}}] 32 | ``` 33 | 34 | or even simpler as 35 | 36 | ```wl 37 | In[] := ToPatternRules[{{1, 2, 3}, {2, 4, 5}} -> 38 | {{5, 6, 1}, {6, 4, 2}, {4, 5, 3}}] 39 | Out[] = {{v1_, v2_, v3_}, {v2_, v4_, v5_}} :> 40 | Module[{v6}, {{v5, v6, v1}, {v6, v4, v2}, {v4, v5, v3}}] 41 | ``` 42 | 43 | This last form of the rule is the one that we use most often and is also the 44 | one [`WolframModel`](WolframModelAndWolframModelEvolutionObject/WolframModelAndWolframModelEvolutionObject.md) accepts 45 | by default. 46 | 47 | `ToPatternRules` is listable in a trivial way: 48 | 49 | ```wl 50 | In[] := ToPatternRules[{{{1, 2}} -> {{1, 2}, {2, 3}}, 51 | {{1, 2}} -> {{1, 3}, {3, 2}}}] 52 | Out[] = {{{v1_, v2_}} :> Module[{v3}, {{v1, v2}, {v2, v3}}], 53 | {{v1_, v2_}} :> Module[{v3}, {{v1, v3}, {v3, v2}}]} 54 | ``` 55 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/UtilityFunctions/AcyclicGraphTake.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > Utility Functions > 2 | 3 | # AcyclicGraphTake 4 | 5 | **`AcyclicGraphTake`** gives the intersection of the out-component of the first vertex 6 | with the in-component of the second vertex: 7 | 8 | ```wl 9 | In[] := graph = BlockRandom[ 10 | DirectedGraph[RandomGraph[{10, 10}], "Acyclic", VertexLabels -> Automatic], 11 | RandomSeeding -> 2 12 | ] 13 | ``` 14 | 15 | 16 | 17 | ```wl 18 | In[] := AcyclicGraphTake[graph, {1, 9}] 19 | ``` 20 | 21 | 22 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/UtilityFunctions/BuildData.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > Utility Functions > 2 | 3 | # Build Data 4 | 5 | There are two constants containing information about the build. **`$SetReplaceGitSHA`** is a git SHA of the 6 | currently-used version of *SetReplace*: 7 | 8 | ```wl 9 | In[] := $SetReplaceGitSHA 10 | Out[] = "320b91b5ca1d91b9b7890aa181ad457de3e38939" 11 | ``` 12 | 13 | If the build directory were not clean, it would have "\*" at the end. 14 | 15 | **`$SetReplaceBuildTime`** gives a date object of when the paclet was created: 16 | 17 | ```wl 18 | In[] := $SetReplaceBuildTime 19 | ``` 20 | 21 | 22 | 23 | These constants are particularly useful for reporting issues with the code. 24 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/UtilityFunctions/GeneralizedGridGraph.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > Utility Functions > 2 | 3 | # GeneralizedGridGraph 4 | 5 | **`GeneralizedGridGraph`** is similar to [`GridGraph`](https://reference.wolfram.com/language/ref/GridGraph.html), but 6 | it allows for additional specifiers in each direction of the grid: 7 | 8 | ```wl 9 | In[] := GeneralizedGridGraph[{5 -> "Directed", 5 -> "Circular"}] 10 | ``` 11 | 12 | 13 | 14 | Possible specifiers are `"Directed"` and `"Circular"`, and they can be combined: 15 | 16 | ```wl 17 | In[] := GeneralizedGridGraph[{3 -> {"Directed", "Circular"}, 6}] 18 | ``` 19 | 20 | 21 | 22 | The same options as [`GridGraph`](https://reference.wolfram.com/language/ref/GridGraph.html) are supported. In 23 | addition `"VertexNamingFunction" -> "Coordinates"` names vertices according to their position in a grid: 24 | 25 | ```wl 26 | In[] := GeneralizedGridGraph[{4, 5, 2}, 27 | "VertexNamingFunction" -> "Coordinates", VertexLabels -> Automatic] 28 | ``` 29 | 30 | 31 | 32 | Finally, it's possible to use different `EdgeStyle` in different directions by specifying it as a list: 33 | 34 | ```wl 35 | In[] := GeneralizedGridGraph[{4 -> "Directed", 5, 2}, 36 | "VertexNamingFunction" -> "Coordinates", 37 | EdgeStyle -> Darker /@ {Red, Green, Blue}] 38 | ``` 39 | 40 | 41 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/UtilityFunctions/HypergraphAutomorphismGroup.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > Utility Functions > 2 | 3 | # HypergraphAutomorphismGroup 4 | 5 | **`HypergraphAutomorphismGroup`** does the same thing 6 | as [`GraphAutomorphismGroup`](https://reference.wolfram.com/language/ref/GraphAutomorphismGroup.html), but for ordered 7 | hypergraphs: 8 | 9 | ```wl 10 | In[] := HypergraphAutomorphismGroup[{{1, 2, 3}, {1, 2, 4}}] 11 | Out[] = PermutationGroup[{Cycles[{{3, 4}}]}] 12 | ``` 13 | 14 | A more complicated example: 15 | 16 | ```wl 17 | In[] := GroupOrder[ 18 | HypergraphAutomorphismGroup[ 19 | EchoFunction[ 20 | HypergraphPlot] @ {{1, 2, 3}, {3, 4, 5}, {5, 6, 1}, {1, 7, 3}, {3, 21 | 8, 5}, {5, 9, 1}}]] 22 | ``` 23 | 24 | 25 | 26 | ```wl 27 | Out[] = 24 28 | ``` 29 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/UtilityFunctions/HypergraphUnifications.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > Utility Functions > 2 | 3 | # HypergraphUnifications 4 | 5 | When considering which matches could potentially exist to a given set of rule inputs, it is often useful to see all 6 | possible ways hypergraphs can overlap. **`HypergraphUnifications`** constructs all possible hypergraphs that contain 7 | subgraphs matching both of its arguments. The argument-hypergraphs must overlap by at least a single 8 | edge. `HypergraphUnifications` identifies vertices to the least extent possible, but it makes some identifications if 9 | necessary for matching. 10 | 11 | The output format is a list of triples `{unified hypergraph, first argument edge matches, second argument edge matches}` 12 | , where the last two elements are associations mapping the edge indices in the input hypergraphs to the edge indices in 13 | the unified hypergraph. 14 | 15 | As an example, consider a simple case of two adjacent binary edges: 16 | 17 | ```wl 18 | In[] := HypergraphUnifications[{{1, 2}, {2, 3}}, {{1, 2}, {2, 3}}] 19 | Out[] = {{{{3, 1}, {3, 4}, {2, 3}}, <|1 -> 3, 2 -> 1|>, <|1 -> 3, 2 -> 2|>}, 20 | {{{2, 3}, {3, 1}}, <|1 -> 1, 2 -> 2|>, <|1 -> 1, 2 -> 2|>}, 21 | {{{4, 1}, {2, 3}, {3, 4}}, <|1 -> 3, 2 -> 1|>, <|1 -> 2, 2 -> 3|>}, 22 | {{{1, 2}, {2, 1}}, <|1 -> 1, 2 -> 2|>, <|1 -> 2, 2 -> 1|>}, 23 | {{{1, 2}, {3, 4}, {2, 3}}, <|1 -> 1, 2 -> 3|>, <|1 -> 3, 2 -> 2|>}, 24 | {{{1, 3}, {2, 3}, {3, 4}}, <|1 -> 1, 2 -> 3|>, <|1 -> 2, 2 -> 3|>}} 25 | ``` 26 | 27 | In the first output here `{{{3, 1}, {3, 4}, {2, 3}}, <|1 -> 3, 2 -> 1|>, <|1 -> 3, 2 -> 2|>}`, the graphs are 28 | overlapping by a shared edge `{2, 3}`, and two inputs are matched respectively to `{{2, 3}, {3, 1}}` 29 | and `{{2, 3}, {3, 4}}`. 30 | 31 | All unifications can be visualized with **`HypergraphUnificationsPlot`**: 32 | 33 | ```wl 34 | In[] := HypergraphUnificationsPlot[{{1, 2}, {2, 3}}, {{1, 2}, {2, 3}}] 35 | ``` 36 | 37 | 38 | 39 | Vertex labels here show the vertex names in the input graphs to which the unification is matched. 40 | 41 | A more complicated example with edges of various arities is 42 | 43 | ```wl 44 | In[] := HypergraphUnificationsPlot[{{1, 2, 3}, {4, 5, 6}, {1, 4}}, 45 | {{1, 2, 3}, {4, 5, 6}, {1, 4}}, VertexLabels -> Automatic] 46 | ``` 47 | 48 | 49 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/UtilityFunctions/IndexHypergraph.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > Utility Functions > 2 | 3 | # IndexHypergraph 4 | 5 | **`IndexHypergraph`** replaces the vertices of the hypergraph by its vertex indices: 6 | 7 | ```wl 8 | In[]:= IndexHypergraph[{{x, y, z}, {w, y}, {z, {x}, {{y}}}}] 9 | Out[]= {{2, 3, 4}, {1, 3}, {4, 5, 6}} 10 | ``` 11 | 12 | Replace the vertices with integers starting from -10: 13 | 14 | ```wl 15 | In[]:= IndexHypergraph[{{x, y, z}, {w, y}, {z, {x}, {{y}}}}, -10] 16 | Out[]= {{-9, -8, -7}, {-10, -8}, {-7, -6, -5}} 17 | ``` 18 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/UtilityFunctions/IsomorphicHypergraphQ.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > Utility Functions > 2 | 3 | # IsomorphicHypergraphQ 4 | 5 | **`IsomorphicHypergraphQ`** is the natural extension 6 | of [`IsomorphicGraphQ`](https://reference.wolfram.com/language/ref/IsomorphicGraphQ.html) for hypergraphs. It 7 | yields [`True`](https://reference.wolfram.com/language/ref/True.html) 8 | for [isomorphic](https://en.wikipedia.org/wiki/Hypergraph#Isomorphism_and_equality) (ordered) hypergraphs, 9 | and [`False`](https://reference.wolfram.com/language/ref/False.html) otherwise: 10 | 11 | ```wl 12 | In[]:= IsomorphicHypergraphQ[ 13 | {{a, e, d}, {d, c}, {c, b}, {b, a}}, 14 | {{2, 4}, {4, 5, 1}, {1, 3}, {3, 2}}] 15 | Out[]= True 16 | ``` 17 | 18 | ```wl 19 | In[]:= IsomorphicHypergraphQ[ 20 | {{a, e, d}, {d, c}, {c, b}, {b, a}}, 21 | {{2, 4}, {4, 3, 1}, {1, 3}, {5, 2}}] 22 | Out[]= False 23 | ``` 24 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/UtilityFunctions/RandomHypergraph.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > Utility Functions > 2 | 3 | # RandomHypergraph 4 | 5 | **`RandomHypergraph`** generates a random hypergraph. The first argument specifies either the hypergraph "complexity" or 6 | its signature. The second (optional) argument is the maximum possible number of distinct vertices of said hypergraph. 7 | 8 | Pass a positive integer `n` to generate a hypergraph where the total of all hyperedge arities is `n`: 9 | 10 | ```wl 11 | In[] := RandomHypergraph[15] 12 | Out[] = {{5, 14, 13}, {8}, {4}, {7, 13}, {15}, {13, 12, 4, 14}, {14, 2}, {12}} 13 | ``` 14 | 15 | ```wl 16 | In[] := Total[Length /@ %] 17 | Out[] = 15 18 | ``` 19 | 20 | Generate a random hypergraph with the same complexity but with at most 20 distinct vertices: 21 | 22 | ```wl 23 | In[] := RandomHypergraph[15, 20] 24 | Out[] = {{14, 17, 11, 10}, {6}, {13, 12, 17}, {1}, {1, 12}, {3, 20, 12, 17}} 25 | ``` 26 | 27 | Pass `sig` to generate a hypergraph with `sig` as its signature: 28 | 29 | ```wl 30 | In[] := RandomHypergraph[{5, 2}] 31 | Out[] = {{4, 3}, {2, 8}, {5, 7}, {9, 5}, {4, 7}} 32 | ``` 33 | 34 | A signature with multiple arities also works: 35 | 36 | ```wl 37 | In[] := RandomHypergraph[{{5, 2}, {4, 3}}] 38 | Out[] = {{10, 22}, {18, 6}, {3, 19}, {1, 14}, {21, 2}, {11, 19, 20}, {11, 8, 3}, {18, 20, 3}, {3, 17, 17}} 39 | ``` 40 | 41 | Restrict this hypergraph to have `{1, 2}` as its vertex list: 42 | 43 | ```wl 44 | In[] := RandomHypergraph[{{5, 2}, {4, 3}}, 2] 45 | Out[] = {{1, 1}, {1, 2}, {1, 2}, {2, 1}, {2, 1}, {2, 2, 2}, {1, 1, 2}, {1, 1, 2}, {1, 1, 1}} 46 | ``` 47 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/UtilityFunctions/SetReplaceStyleData.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > Utility Functions > 2 | 3 | # SetReplaceStyleData 4 | 5 | **`SetReplaceStyleData`** allows one to lookup styles used in various *SetReplace* functions and properties such as 6 | [`HypergraphPlot`](../HypergraphPlot.md) 7 | and [`"CausalGraph"`](../WolframModelAndWolframModelEvolutionObject/Properties/CausalGraphs.md). 8 | 9 | For example, here is the default style used to draw polygons in [`HypergraphPlot`](../HypergraphPlot.md): 10 | 11 | ```wl 12 | In[] := SetReplaceStyleData["SpatialGraph", "EdgePolygonStyle"] 13 | ``` 14 | 15 | 16 | 17 | The full specification is `SetReplaceStyleData[theme, plot type, style element]`, however either the last or 18 | the last two elements can be omitted to obtain a 19 | full [`Association`](https://reference.wolfram.com/language/ref/Association.html) of styles. The `theme` argument can be 20 | omitted to get the result for the default plot theme (only `"Light"` theme is supported at the moment). Here are all 21 | styles used in [`"CausalGraph"`](../WolframModelAndWolframModelEvolutionObject/Properties/CausalGraphs.md) for example: 22 | 23 | ```wl 24 | In[] := SetReplaceStyleData["CausalGraph"] 25 | ``` 26 | 27 | 28 | 29 | This function is useful if one needs to produce "fake" example plots using styles consistent with *SetReplace*. 30 | 31 | For graphs composed of only a single type of vertices and edges, there is a short-hand syntax. One can get the list of 32 | all options that needs to be passed using an `"Options"` property: 33 | 34 | ```wl 35 | In[] := SetReplaceStyleData["SpatialGraph3D", "Options"] 36 | ``` 37 | 38 | 39 | 40 | Alternatively, one can use the `"Function"` property, which would give a function that takes a graph and produces a 41 | correctly styled graph: 42 | 43 | ```wl 44 | In[] := SetReplaceStyleData["SpatialGraph3D", "Function"][ 45 | Graph3D[{1 -> 2, 2 -> 3, 3 -> 1, 3 -> 4, 4 -> 1}]] 46 | ``` 47 | 48 | 49 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/UtilityFunctions/Subhypergraph.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > Utility Functions > 2 | 3 | # Subhypergraph 4 | 5 | **`Subhypergraph`** is a small utility function that selects hyperedges that only contain vertices from the requested 6 | list: 7 | 8 | ```wl 9 | In[]:= Subhypergraph[{{1, 1, 1}, {1, 2}, {2, 3, 3}, {2, 3, 4}}, {2, 3, 4}] 10 | Out[]= {{2, 3, 3}, {2, 3, 4}} 11 | ``` 12 | 13 | **`WeakSubhypergraph`** is the weak version of the previous function, where hyperedges are selected if they contain any 14 | vertex from the requested list: 15 | 16 | ```wl 17 | In[]:= WeakSubhypergraph[{{1, 1}, {2, 3}, {3, 4, 4}}, {1, 3}] 18 | Out[]= {{1, 1}, {2, 3}, {3, 4, 4}} 19 | ``` 20 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Options/EventDeduplication.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Options](../WolframModelAndWolframModelEvolutionObject.md#options) > 2 | 3 | # "EventDeduplication" 4 | 5 | Some rules can match the same set of inputs in different ways. For example, consider the 6 | rule `{{a, b}, {a, c}} -> {{b, c}}` starting with an initial condition `{{1, 2}, {1, 3}}`. There are two possible ways 7 | to match it: `<|a -> 1, b -> 2, c -> 3|>` and `<|a -> 1, b -> 3, c -> 2|>`. In this case, these matches yield different 8 | results, `{2, 3}` and `{3, 2}` respectively: 9 | 10 | ```wl 11 | In[] := WolframModel[{{a, b}, {a, c}} -> {{b, c}}, {{1, 2}, {1, 3}}, 12 | "EventSelectionFunction" -> 13 | "MultiwaySpacelike"]["ExpressionsEventsGraph", 14 | VertexLabels -> Automatic] 15 | ``` 16 | 17 | 18 | 19 | In the case above the outputs are different, however sometimes they are the same (more precisely, isomorphic): 20 | 21 | ```wl 22 | In[] := WolframModel[{{a, b}, {a, c}} -> {{b, c}, {c, b}}, {{1, 2}, {1, 3}}, 23 | "EventSelectionFunction" -> 24 | "MultiwaySpacelike"]["ExpressionsEventsGraph", 25 | VertexLabels -> Automatic] 26 | ``` 27 | 28 | 29 | 30 | **`EventDeduplication`** option can be used in a case like this to combine these two identical events into one: 31 | 32 | ```wl 33 | In[] := WolframModel[{{a, b}, {a, c}} -> {{b, c}, {c, b}}, {{1, 2}, {1, 3}}, 34 | "EventSelectionFunction" -> "MultiwaySpacelike", 35 | "EventDeduplication" -> "SameInputSetIsomorphicOutputs"]["ExpressionsEventsGraph", 36 | VertexLabels -> Automatic] 37 | ``` 38 | 39 | 40 | 41 | The outputs of the rule need not be identical, but should be isomorphic with respect to renaming of new atoms: 42 | 43 | ```wl 44 | In[] := WolframModel[{{a, b}, {a, c}} -> {{b, d}, {c, d}}, {{1, 2}, {1, 3}}, 45 | "EventSelectionFunction" -> "MultiwaySpacelike", 46 | "EventDeduplication" -> "SameInputSetIsomorphicOutputs"]["ExpressionsEventsGraph", 47 | VertexLabels -> Automatic] 48 | ``` 49 | 50 | 51 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Options/IncludeBoundaryEvents.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Options](../WolframModelAndWolframModelEvolutionObject.md#options) > 2 | 3 | # "IncludeBoundaryEvents" 4 | 5 | **`"IncludeBoundaryEvents"`** allows one to include "fake" initial and final events in properties such 6 | as [`"ExpressionsEventsGraph"`](../Properties/CausalGraphs.md). It does not affect the evolution itself and does not 7 | affect the evolution object. It has 4 settings: [`None`](https://reference.wolfram.com/language/ref/None.html) 8 | , `"Initial"`, `"Final"` and [`All`](https://reference.wolfram.com/language/ref/All.html). 9 | 10 | Here is an example of an [`"ExpressionsEventsGraph"`](../Properties/CausalGraphs.md) with the initial and final "events" 11 | included: 12 | 13 | ```wl 14 | In[] := WolframModel[<|"PatternRules" -> {a_, b_} :> a + b|>, 15 | {3, 8, 8, 8, 2, 10, 0, 9, 7}, Infinity]["ExpressionsEventsGraph", 16 | "IncludeBoundaryEvents" -> All, 17 | VertexLabels -> Placed[Automatic, After]] 18 | ``` 19 | 20 | 21 | 22 | Properties like [`"AllEventsList"`](../Properties/Events.md) are affected as well: 23 | 24 | ```wl 25 | In[] := WolframModel[<|"PatternRules" -> {a_, b_} :> a + b|>, 26 | {3, 8, 8, 8, 2, 10, 0, 9, 7}, Infinity, "AllEventsList", 27 | "IncludeBoundaryEvents" -> "Final"] 28 | Out[] = {{1, {1, 2} -> {10}}, {1, {3, 4} -> {11}}, 29 | {1, {5, 6} -> {12}}, {1, {7, 8} -> {13}}, 30 | {1, {9, 10} -> {14}}, {1, {11, 12} -> {15}}, 31 | {1, {13, 14} -> {16}}, {1, {15, 16} -> {17}}, 32 | {Infinity, {17} -> {}}} 33 | ``` 34 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Options/IncludePartialGenerations.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Options](../WolframModelAndWolframModelEvolutionObject.md#options) > 2 | 3 | # "IncludePartialGenerations" 4 | 5 | In case partial generations were produced, they can be automatically dropped by 6 | setting **`"IncludePartialGenerations"`** to [`False`](https://reference.wolfram.com/language/ref/False.html). Compare 7 | for instance 8 | 9 | ```wl 10 | In[] := WolframModel[{{1, 2}} -> {{1, 3}, {1, 3}, {3, 2}}, 11 | {{1, 1}}, <|"MaxEvents" -> 42|>] 12 | ``` 13 | 14 | 15 | 16 | with 17 | 18 | ```wl 19 | In[] := WolframModel[{{1, 2}} -> {{1, 3}, {1, 3}, {3, 2}}, 20 | {{1, 1}}, <|"MaxEvents" -> 42|>, 21 | "IncludePartialGenerations" -> False] 22 | ``` 23 | 24 | 25 | 26 | One neat use of this is producing a uniformly random evolution for a complete number of generations: 27 | 28 | ```wl 29 | In[] := WolframModel[{{1, 2, 3}, {2, 4, 5}} -> 30 | {{6, 6, 3}, {2, 6, 2}, {6, 4, 2}, {5, 3, 6}}, 31 | {{1, 1, 1}, {1, 1, 1}}, <|"MaxEvents" -> 10000|>, "FinalStatePlot", 32 | "EventOrderingFunction" -> "Random", 33 | "IncludePartialGenerations" -> False] 34 | ``` 35 | 36 | 37 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Options/TimeConstraint.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Options](../WolframModelAndWolframModelEvolutionObject.md#options) > 2 | 3 | # TimeConstraint 4 | 5 | **`TimeConstraint`** option allows one to stop the evolution early. If an evolution object is requested, it will return 6 | a partial result, otherwise, it will just give [`$Aborted`](https://reference.wolfram.com/language/ref/$Aborted.html): 7 | 8 | ```wl 9 | In[] := WolframModel[{{1, 2}} -> {{1, 3}, {1, 3}, {3, 2}}, 10 | {{1, 1}}, Infinity, TimeConstraint -> 1] 11 | ``` 12 | 13 | 14 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Options/VertexNamingFunction.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Options](../WolframModelAndWolframModelEvolutionObject.md#options) > 2 | 3 | # "VertexNamingFunction" 4 | 5 | **`"VertexNamingFunction"`** controls the names chosen for vertices, particularly the newly created ones. It can take 6 | three values: [`None`](https://reference.wolfram.com/language/ref/None.html) 7 | , [`Automatic`](https://reference.wolfram.com/language/ref/Automatic.html), 8 | and [`All`](https://reference.wolfram.com/language/ref/All.html). 9 | 10 | [`None`](https://reference.wolfram.com/language/ref/None.html) does not do anything, the vertices in the initial 11 | condition are left as-is, and the newly created vertices use symbol names as, i.e., `Module[{v}, v]` could generate: 12 | 13 | ```wl 14 | In[] := WolframModel[{{1, 2}} -> {{1, 3}, {1, 3}, {3, 2}}, 15 | {{v1, v1}}, 2, "StatesList", "VertexNamingFunction" -> None] 16 | Out[] = {{{v1, v1}}, {{v1, v256479}, {v1, v256479}, {v256479, v1}}, {{v1, 17 | v256480}, {v1, v256480}, {v256480, v256479}, {v1, v256481}, {v1, 18 | v256481}, {v256481, v256479}, {v256479, v256482}, {v256479, 19 | v256482}, {v256482, v1}}} 20 | ``` 21 | 22 | [`All`](https://reference.wolfram.com/language/ref/All.html) renames all vertices as sequential integers, including the 23 | ones in the the initial condition, and including ones manually generated 24 | in [pattern rules](../WolframModelAndWolframModelEvolutionObject.md#pattern-rules): 25 | 26 | ```wl 27 | In[] := WolframModel[{{1, 2}} -> {{1, 3}, {1, 3}, {3, 2}}, 28 | {{v1, v1}}, 2, "StatesList", "VertexNamingFunction" -> All] 29 | Out[] = {{{1, 1}}, {{1, 2}, {1, 2}, {2, 1}}, {{1, 3}, {1, 3}, {3, 2}, {1, 30 | 4}, {1, 4}, {4, 2}, {2, 5}, {2, 5}, {5, 1}}} 31 | ``` 32 | 33 | [`Automatic`](https://reference.wolfram.com/language/ref/Automatic.html) only renames newly created vertices with 34 | non-previously-used integers, and leaves the initial condition as-is. It does nothing in the case 35 | of [pattern rules](../WolframModelAndWolframModelEvolutionObject.md#pattern-rules). 36 | 37 | ```wl 38 | In[] := WolframModel[{{1, 2}} -> {{1, 3}, {1, 3}, {3, 2}}, 39 | {{v1, v1}}, 2, "StatesList", "VertexNamingFunction" -> Automatic] 40 | Out[] = {{{v1, v1}}, {{v1, 1}, {v1, 1}, {1, v1}}, {{v1, 2}, {v1, 2}, {2, 41 | 1}, {v1, 3}, {v1, 3}, {3, 1}, {1, 4}, {1, 4}, {4, v1}}} 42 | ``` 43 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/AllEdgesThroughoutEvolution.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Properties](../WolframModelAndWolframModelEvolutionObject.md#properties) > 2 | 3 | # All Edges throughout Evolution 4 | 5 | **`"AllEventsEdgesList"`** (aka `"AllExpressions"`) returns the list of edges throughout evolution. This is distinct 6 | from a catenated [`"StateList"`](States.md), as the edge does not appear twice if it moved from one generation to the 7 | next without being involved in an event. 8 | 9 | Compare for instance the output of [`"StatesList"`](States.md) for a system where only one replacement is made per 10 | generation: 11 | 12 | ```wl 13 | In[] := WolframModel[<|"PatternRules" -> {x_?OddQ, y_} :> x + y|>, 14 | {1, 2, 4, 6}, Infinity, "StatesList"] 15 | Out[] = {{1, 2, 4, 6}, {4, 6, 3}, {6, 7}, {13}} 16 | ``` 17 | 18 | to the output of `"AllEventsEdgesList"`: 19 | 20 | ```wl 21 | In[] := WolframModel[<|"PatternRules" -> {x_?OddQ, y_} :> x + y|>, 22 | {1, 2, 4, 6}, Infinity, "AllEventsEdgesList"] 23 | Out[] = {1, 2, 4, 6, 3, 7, 13} 24 | ``` 25 | 26 | Note how 4 and 6 only appear once in the list. 27 | 28 | Edge indices from `"AllEventsEdgesList"` are used in various other properties such as [`"AllEventsList"`](Events.md) 29 | and [`"EventsStatesList"`](EventsAndStates.md). 30 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/CreatorAndDestroyerEvents.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Properties](../WolframModelAndWolframModelEvolutionObject.md#properties) > 2 | 3 | # Creator and Destroyer Events 4 | 5 | An event is said to *destroy* the edges in its input, and *create* the edges in its output. Creator and destroyer events 6 | for each edge can be obtained with **`"EdgeCreatorEventIndices"`** (aka `"CreatorEvents"`) 7 | and **`"EdgeDestroyerEventsIndices"`** properties. 8 | 9 | As an example, for a simple rule that splits each edge in two, one can see that edges are created in pairs: 10 | 11 | ```wl 12 | In[] := WolframModel[{{1, 2}} -> {{1, 3}, {3, 2}}, 13 | {{1, 1}}, 4, "EdgeCreatorEventIndices"] 14 | Out[] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 15 | 11, 12, 12, 13, 13, 14, 14, 15, 15} 16 | ``` 17 | 18 | and destroyed one-by-one: 19 | 20 | ```wl 21 | In[] := WolframModel[{{1, 2}} -> {{1, 3}, {3, 2}}, 22 | {{1, 1}}, 4, "EdgeDestroyerEventsIndices"] 23 | Out[] = {{1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}, 24 | {13}, {14}, {15}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, 25 | {}, {}, {}, {}} 26 | ``` 27 | 28 | Here 0 refers to the initial state. Note the format is different for creator and destroyer events. That is because each 29 | edge has a unique creator event, but can have multiple destroyer events 30 | in [multiway systems](../Options/EventSelectionFunction.md). 31 | 32 | There is another property, **`"EdgeDestroyerEventIndices"`** (aka `"DestroyerEvents"`), left for compatibility reasons, 33 | which has the same format as **`"EdgeCreatorEventIndices"`**. However, it does not work 34 | for [multiway systems](../Options/EventSelectionFunction.md). 35 | 36 | ```wl 37 | In[] := WolframModel[{{1, 2}} -> {{1, 3}, {3, 2}}, 38 | {{1, 1}}, 4, "EdgeDestroyerEventIndices"] 39 | Out[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, Infinity, 40 | Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 41 | Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 42 | Infinity, Infinity, Infinity} 43 | ``` 44 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/EdgeAndEventGenerations.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Properties](../WolframModelAndWolframModelEvolutionObject.md#properties) > 2 | 3 | # Edge and Event Generations 4 | 5 | **`"EdgeGenerationsList"`** (aka `"ExpressionGenerations"`) yields the list of generation numbers (numbers of 6 | predecessor layers) for each edge in [`"AllEventsEdgesList"`](AllEdgesThroughoutEvolution.md): 7 | 8 | ```wl 9 | In[] := WolframModel[{{1, 2}, {1, 3}, {1, 4}} -> 10 | {{2, 2}, {3, 2}, {3, 4}, {3, 5}}, 11 | {{1, 1}, {1, 1}, {1, 1}}, 5, "EdgeGenerationsList"] 12 | Out[] = {0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 13 | 5, 5, 5, 5} 14 | ``` 15 | 16 | **`"AllEventsGenerationsList"`** (aka `"EventGenerations"`) gives the same for events. The generation of an event is 17 | defined as the generation of edges it produces as output. Here edges of different generations are colored differently: 18 | 19 | ```wl 20 | In[] := With[{ 21 | evolution = WolframModel[{{1, 2}, {1, 3}, {1, 4}} -> 22 | {{2, 2}, {3, 2}, {3, 4}, {3, 5}}, 23 | {{1, 1}, {1, 1}, {1, 1}}, 5]}, 24 | MapThread[ 25 | HypergraphPlot[#, EdgeStyle -> #2] &, {evolution["StatesList"], 26 | Replace[evolution[ 27 | "EdgeGenerationsList"][[#]] & /@ (evolution[ 28 | "StateEdgeIndicesAfterEvent", #] &) /@ 29 | Prepend[0] @ Accumulate @ evolution["GenerationEventsCountList"], 30 | g_ :> ColorData["Rainbow"][g/5], {2}]}]] 31 | ``` 32 | 33 | 34 | 35 | Event and expression generations correspond to layers in [`"LayeredCausalGraph"`](CausalGraphs.md) 36 | and [`"ExpressionsEventsGraph"`](CausalGraphs.md): 37 | 38 | ```wl 39 | In[] := WolframModel[{{1, 2}, {1, 3}, {1, 4}} -> 40 | {{2, 2}, {3, 2}, {3, 4}, {3, 5}}, 41 | {{1, 1}, {1, 1}, {1, 1}}, 5, "AllEventsGenerationsList"] 42 | Out[] = {1, 2, 3, 4, 5, 5} 43 | ``` 44 | 45 | ```wl 46 | In[] := WolframModel[{{1, 2}, {1, 3}, {1, 4}} -> 47 | {{2, 2}, {3, 2}, {3, 4}, {3, 5}}, 48 | {{1, 1}, {1, 1}, {1, 1}}, 5, "LayeredCausalGraph"] 49 | ``` 50 | 51 | 52 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/ElementCountLists.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Properties](../WolframModelAndWolframModelEvolutionObject.md#properties) > 2 | 3 | # Element Count Lists 4 | 5 | **`"VertexCountList"`** and **`"EdgeCountList"`** return counts of vertices and edges respectively in each state 6 | of [`"StatesList"`](States.md). They are useful to see how quickly a particular system grows: 7 | 8 | ```wl 9 | In[] := WolframModel[{{1, 2, 3}, {2, 4, 5}} -> 10 | {{6, 6, 3}, {2, 6, 2}, {6, 4, 2}, {5, 3, 6}}, 11 | {{1, 1, 1}, {1, 1, 1}}, 10, "VertexCountList"] 12 | Out[] = {1, 2, 4, 8, 14, 27, 49, 92, 171, 324, 622} 13 | ``` 14 | 15 | ```wl 16 | In[] := WolframModel[{{1, 2, 3}, {2, 4, 5}} -> 17 | {{6, 6, 3}, {2, 6, 2}, {6, 4, 2}, {5, 3, 6}}, 18 | {{1, 1, 1}, {1, 1, 1}}, 10, "EdgeCountList"] 19 | Out[] = {2, 4, 8, 16, 28, 54, 98, 184, 342, 648, 1244} 20 | ``` 21 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/EventCounts.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Properties](../WolframModelAndWolframModelEvolutionObject.md#properties) > 2 | 3 | # Event Counts 4 | 5 | **`"AllEventsCount"`** (aka `"EventsCount"`) returns the overall number of events throughout the evolution ( 6 | the [`Length`](https://reference.wolfram.com/language/ref/Length.html) of [`"AllEventsList"`](Events.md)). 7 | 8 | **`"GenerationEventsCountList"`** gives the number of events per each 9 | generation ([`Length`](https://reference.wolfram.com/language/ref/Length.html) mapped 10 | over [`"GenerationEventsList"`](Events.md)): 11 | 12 | ```wl 13 | In[] := WolframModel[{{1, 2}} -> {{1, 3}, {1, 3}, {3, 2}}, 14 | {{1, 1}}, 5, "GenerationEventsCountList"] 15 | Out[] = {1, 3, 9, 27, 81} 16 | ``` 17 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/Events.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Properties](../WolframModelAndWolframModelEvolutionObject.md#properties) > 2 | 3 | # Events 4 | 5 | **`"AllEventsList"`** (aka `"EventsList"`) and **`"GenerationEventsList"`** both return all replacement events 6 | throughout the evolution. The only difference is how the events are arranged. `"AllEventsList"` returns the flat list of 7 | all events, whereas `"GenerationEventsList"` splits them into sublists for each generation: 8 | 9 | ```wl 10 | In[] := WolframModel[{{1, 2}} -> {{3, 4}, {3, 1}, {4, 1}, {2, 4}}, 11 | {{1, 1}}, 2, "AllEventsList"] 12 | Out[] = {{1, {1} -> {2, 3, 4, 5}}, {1, {2} -> {6, 7, 8, 9}}, 13 | {1, {3} -> {10, 11, 12, 13}}, {1, {4} -> {14, 15, 16, 17}}, 14 | {1, {5} -> {18, 19, 20, 21}}} 15 | ``` 16 | 17 | ```wl 18 | In[] := WolframModel[{{1, 2}} -> {{3, 4}, {3, 1}, {4, 1}, {2, 4}}, 19 | {{1, 1}}, 2, "GenerationEventsList"] 20 | Out[] = {{{1, {1} -> {2, 3, 4, 5}}}, 21 | {{1, {2} -> {6, 7, 8, 9}}, {1, {3} -> {10, 11, 12, 13}}, 22 | {1, {4} -> {14, 15, 16, 17}}, {1, {5} -> {18, 19, 20, 21}}}} 23 | ``` 24 | 25 | The format for the events is 26 | 27 | ```wl 28 | {ruleIndex, {inputEdgeIndices} -> {outputEdgeIndices}} 29 | ``` 30 | 31 | where the edge indices refer to expressions from [`"AllEventsEdgesList"`](AllEdgesThroughoutEvolution.md). 32 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/EventsAndStates.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Properties](../WolframModelAndWolframModelEvolutionObject.md#properties) > 2 | 3 | # Events and States 4 | 5 | **`"EventsStatesList"`** just produces a list of `{event, state}` pairs, where state is the complete state right after 6 | this event is applied. Events are the same as generated by [`"AllEventsList"`](Events.md), and the states are 7 | represented as edge indices as in [`"AllEventsStatesEdgeIndicesList"`](StatesAsEdgeIndices.md): 8 | 9 | ```wl 10 | In[] := WolframModel[{{1, 2}} -> {{3, 4}, {3, 1}, {4, 1}, {2, 4}}, 11 | {{1, 1}}, 2, "EventsStatesList"] 12 | Out[] = {{{1, {1} -> {2, 3, 4, 5}}, {2, 3, 4, 5}}, 13 | {{1, {2} -> {6, 7, 8, 9}}, {3, 4, 5, 6, 7, 8, 9}}, 14 | {{1, {3} -> {10, 11, 12, 13}}, {4, 5, 6, 7, 8, 9, 10, 11, 12, 13}}, 15 | {{1, {4} -> {14, 15, 16, 17}}, 16 | {5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}}, 17 | {{1, {5} -> {18, 19, 20, 21}}, 18 | {6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21}}} 19 | ``` 20 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/FeatureVector.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Properties](../WolframModelAndWolframModelEvolutionObject.md#properties) > 2 | 3 | # Feature Vector 4 | 5 | **`"FeatureVector"`** returns the values of the features of 6 | the [`WolframModel`](/Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/WolframModelAndWolframModelEvolutionObject.md) 7 | evolution as computed 8 | by [`"FeatureAssociation"`](/Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/FeatureAssociation.md). 9 | 10 | ```wl 11 | In[] := WolframModel[{{x, y}, {x, z}} -> {{x, z}, {x, w}, {y, w}, {z, w}}, {{0, 0}, {0, 0}}, 5]["FeatureVector"] 12 | ``` 13 | 14 | 15 | 16 | For the list of features 17 | see [`FeatureAssociation`](/Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/FeatureAssociation.md). 18 | 19 | This property is useful for applying machine learning to Wolfram Models explorations. 20 | 21 | ## Example 22 | 23 | ```wl 24 | In[] := BlockRandom[ 25 | FeatureSpacePlot[#["FeatureVector"] -> Image[#["FinalStatePlot"], ImageSize -> Tiny] & /@ 26 | (WolframModel[{{x, y}, {x, z}} -> {{x, z}, {x, w}, {y, w}, {z, w}}, #, 6] &) /@ 27 | Table[RandomHypergraph[{3, 2}, 2], 10], LabelingFunction -> Callout], RandomSeeding -> 2 28 | ] 29 | ``` 30 | 31 | 32 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/FinalElementCounts.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Properties](../WolframModelAndWolframModelEvolutionObject.md#properties) > 2 | 3 | # Final Element Counts 4 | 5 | **`FinalDistinctElementsCount`** (aka `"AtomsCountFinal"`) and **`FinalEdgeCount`** (aka `"ExpressionsCountFinal"`) are 6 | similar to corresponding [`*List`](ElementCountLists.md) properties, except we don't have `"FinalVertexCount"` (we 7 | should have it and also `"DistinctElementsCountList"`, but they are not currently implemented). 8 | 9 | The difference is that [`"VertexCountList"`](ElementCountLists.md) counts expressions on level 2 in the states 10 | whereas `"FinalDistinctElementsCount"` counts all expressions matching `_ ? AtomQ` (on any level). The difference 11 | becomes apparent for edges that contain non-trivially nested lists. 12 | 13 | For example, consider a rule that performs non-trivial nesting: 14 | 15 | ```wl 16 | In[] := WolframModel[<| 17 | "PatternRules" -> {{a_}} :> {{a + 1}, {a - 1}, {{a + 2, a - 2}}}|>, 18 | {{1}}, 7, "VertexCountList"] 19 | Out[] = {1, 3, 6, 10, 15, 21, 28, 36} 20 | ``` 21 | 22 | ```wl 23 | In[] := WolframModel[<|"PatternRules" -> 24 | {{a_}} :> {{a + 1}, {a - 1}, {{a + 2, a - 2}}}|>, 25 | {{1}}, #, "FinalDistinctElementsCount"] & /@ Range[0, 7] 26 | Out[] = {1, 4, 9, 13, 17, 21, 25, 29} 27 | ``` 28 | 29 | To understand why this is happening, consider the state after one step: 30 | 31 | ```wl 32 | In[] := WolframModel[<| 33 | "PatternRules" -> {{a_}} :> {{a + 1}, {a - 1}, {{a + 2, a - 2}}}|>, 34 | {{1}}, 1, "FinalState"] 35 | Out[] = {{2}, {0}, {{3, -1}}} 36 | ``` 37 | 38 | This state has 3 vertices (distinct level-2 expressions): `2`, `0`, and `{3, -1}`, but 4 atoms: `2`, `0`, `3`, and `-1`. 39 | This distinction does not usually come up in our models since vertices and atoms are usually the same things, but it is 40 | significant in exotic cases like this. 41 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/GenerationCounts.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Properties](../WolframModelAndWolframModelEvolutionObject.md#properties) > 2 | 3 | # Generation Counts 4 | 5 | **`"TotalGenerationsCount"`** returns the largest generation of any edge during the evolution: 6 | 7 | ```wl 8 | In[] := WolframModel[{{1, 2}} -> {{1, 3}, {1, 3}, {3, 2}}, {{1, 1}}, 9 | <|"MaxEvents" -> 42|>, "TotalGenerationsCount"] 10 | Out[] = 5 11 | ``` 12 | 13 | **`"CompleteGenerationsCount"`** yields the number of generations that are "completely done". That is, no more matches 14 | can be made involving this or earlier generations. If the 15 | default [evaluation order](../Options/EventOrderingFunction.md) is used, this can only be either the same 16 | as `"TotalGenerationsCount"` (if we just finished a step) or one less (if we are in the middle of a step). However, it 17 | gets much more interesting if a different event order is used. For a random evolution, for instance, one can get 18 | 19 | ```wl 20 | In[] := WolframModel[{{1, 2}} -> {{1, 3}, {1, 3}, {3, 2}}, {{1, 1}}, 21 | <|"MaxEvents" -> 42|>, "EventOrderingFunction" -> "Random"] 22 | ``` 23 | 24 | 25 | 26 | Note, in this case, only one generation is complete, and seven are partial. That happens because the states grow with 27 | each generation, so it becomes more likely for a random choice to pick an edge from a later generation. Thus earlier 28 | ones are left unevolved. 29 | 30 | **`"PartialGenerationsCount"`** is simply a difference of `"TotalGenerationsCount"` and `"CompleteGenerationsCount"`, 31 | and **`"GenerationsCount"`** is equivalent to `{"CompleteGenerationsCount", "PartialGenerationsCount"}`. 32 | 33 | **`"GenerationComplete"`** takes a generation number as an argument, and 34 | gives [`True`](https://reference.wolfram.com/language/ref/True.html) 35 | or [`False`](https://reference.wolfram.com/language/ref/False.html) depending on whether that particular generation is 36 | complete: 37 | 38 | ```wl 39 | In[] := WolframModel[{{1, 2}} -> {{1, 3}, {1, 3}, {3, 2}}, {{1, 1}}, 40 | <|"MaxEvents" -> 42|>]["GenerationComplete", 5] 41 | Out[] = False 42 | ``` 43 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/MultiwayQ.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Properties](../WolframModelAndWolframModelEvolutionObject.md#properties) > 2 | 3 | # MultiwayQ 4 | 5 | **`"MultiwayQ"`** checks if a given evolution contains multiway branching, i.e., there is an expression used in multiple 6 | events. 7 | 8 | ```wl 9 | In[] := EchoFunction[#["ExpressionsEventsGraph"] &][ 10 | WolframModel[{{1, 2}, {2, 3}} -> {{1, 2}, {2, 3}, {3, 4}}, 11 | {{1, 2}, {2, 3}, {3, 4}}, 12 | 1, 13 | "EventSelectionFunction" -> "MultiwaySpacelike"]]["MultiwayQ"] 14 | ``` 15 | 16 | 17 | 18 | ```wl 19 | Out[] = True 20 | ``` 21 | 22 | Note that even 23 | if [`"EventSelectionFunction"`](/Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Options/EventSelectionFunction.md) 24 | is set to allow multiway branching, the system might still be singleway if no overlapping matches occurred: 25 | 26 | ```wl 27 | In[] := EchoFunction[#["ExpressionsEventsGraph"] &][WolframModel[ 28 | {{1, 2}} -> {{1, 3}, {3, 2}}, {{1, 1}}, 2, "EventSelectionFunction" -> "MultiwaySpacelike"]]["MultiwayQ"] 29 | ``` 30 | 31 | 32 | 33 | ```wl 34 | Out[] = False 35 | ``` 36 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/PlotsOfEvents.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Properties](../WolframModelAndWolframModelEvolutionObject.md#properties) > 2 | 3 | # Plots of Events 4 | 5 | The plotting function corresponding to [`"AllEventsStatesList"`](States.md) is more interesting than the other 6 | ones. **`"EventsStatesPlotsList"`** plots not only the states, but also the events that produced them: 7 | 8 | ```wl 9 | In[] := WolframModel[{{1, 2, 3}, {4, 5, 6}, {1, 4}} -> 10 | {{2, 7, 8}, {3, 9, 10}, {5, 11, 12}, {6, 13, 14}, {8, 12}, {11, 11 | 10}, {13, 7}, {14, 9}}, 12 | {{1, 1, 1}, {1, 1, 1}, {1, 1}, {1, 1}, {1, 1}}, 13 | 3, "EventsStatesPlotsList"] 14 | ``` 15 | 16 | 17 | 18 | Here the dotted gray edges are the ones about to be deleted, whereas the red ones have just been created. 19 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/PlotsOfStates.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Properties](../WolframModelAndWolframModelEvolutionObject.md#properties) > 2 | 3 | # Plots of States 4 | 5 | Instead of explicitly calling [`HypergraphPlot`](../../HypergraphPlot.md), one can use short-hand 6 | properties **`"FinalStatePlot"`** and **`"StatesPlotsList"`**: 7 | 8 | ```wl 9 | In[] := WolframModel[{{1, 2, 3}, {4, 5, 6}, {1, 4}} -> 10 | {{2, 7, 8}, {3, 9, 10}, {5, 11, 12}, {6, 13, 14}, {8, 12}, {11, 11 | 10}, {13, 7}, {14, 9}}, 12 | {{1, 1, 1}, {1, 1, 1}, {1, 1}, {1, 1}, {1, 1}}, 6, "FinalStatePlot"] 13 | ``` 14 | 15 | 16 | 17 | ```wl 18 | In[] := WolframModel[{{1, 2, 3}, {4, 5, 6}, {1, 4}} -> 19 | {{2, 7, 8}, {3, 9, 10}, {5, 11, 12}, {6, 13, 14}, {8, 12}, {11, 20 | 10}, {13, 7}, {14, 9}}, 21 | {{1, 1, 1}, {1, 1, 1}, {1, 1}, {1, 1}, {1, 1}}, 6, "StatesPlotsList"] 22 | ``` 23 | 24 | 25 | 26 | These properties take the same options as [`HypergraphPlot`](../../HypergraphPlot.md) (but one has to specify them in a 27 | call to the evolution object, not `WolframModel`): 28 | 29 | ```wl 30 | In[] := WolframModel[{{1, 2, 3}, {4, 5, 6}, {1, 4}} -> 31 | {{2, 7, 8}, {3, 9, 10}, {5, 11, 12}, {6, 13, 14}, {8, 12}, {11, 32 | 10}, {13, 7}, {14, 9}}, 33 | {{1, 1, 1}, {1, 1, 1}, {1, 1}, {1, 1}, {1, 1}}, 3]["FinalStatePlot", 34 | VertexLabels -> Automatic] 35 | ``` 36 | 37 | 38 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/RuleIndicesForEvents.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Properties](../WolframModelAndWolframModelEvolutionObject.md#properties) > 2 | 3 | # Rule Indices for Events 4 | 5 | **`"AllEventsRuleIndices"`** returns which rule was used for each event (the same can be obtained by 6 | mapping [`First`](https://reference.wolfram.com/language/ref/First.html) over [`"AllEventsList"`](Events.md)): 7 | 8 | ```wl 9 | In[] := WolframModel[{{{1, 1, 2}} -> {{2, 2, 1}, {2, 3, 2}, {1, 2, 3}}, 10 | {{1, 2, 1}, {3, 4, 2}} -> {{4, 3, 2}}}, 11 | {{1, 1, 1}}, 4, "AllEventsRuleIndices"] 12 | Out[] = {1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 2} 13 | ``` 14 | 15 | A neat example of using `"AllEventsRuleIndices"` is coloring events in a causal graph according to the rule index. With 16 | this visualization, one can see, for instance, that the outputs of the second rule in the example above are never used 17 | in any further inputs: 18 | 19 | ```wl 20 | In[] := With[{ 21 | evolution = 22 | WolframModel[{{{1, 1, 2}} -> {{2, 2, 1}, {2, 3, 2}, {1, 2, 3}}, 23 | {{1, 2, 1}, {3, 4, 2}} -> {{4, 3, 2}}}, {{1, 1, 1}}, 6]}, With[{ 24 | causalGraph = evolution["LayeredCausalGraph"]}, 25 | Graph[causalGraph, 26 | VertexStyle -> 27 | Thread[VertexList[causalGraph] -> 28 | Replace[evolution["AllEventsRuleIndices"], {1 -> Black, 29 | 2 -> White}, {1}]], VertexSize -> Medium]]] 30 | ``` 31 | 32 | 33 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/Rules.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Properties](../WolframModelAndWolframModelEvolutionObject.md#properties) > 2 | 3 | # Rules 4 | 5 | **`"Rules"`** just stores the rules in the same way they were entered as an input to `WolframModel`: 6 | 7 | ```wl 8 | In[] := WolframModel[<|"PatternRules" -> 9 | {{a_}} :> {{a + 1}, {a - 1}, {{a + 2, a - 2}}}|>, 10 | {{1}}, 1]["Rules"] 11 | Out[] = <|"PatternRules" -> {{a_}} :> {{a + 1}, {a - 1}, {{a + 2, a - 2}}}|> 12 | ``` 13 | 14 | This is useful for display in the information box of the evolution object, and if one needs to reproduce an evolution 15 | object, the input for which is no longer available. 16 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/TerminationReason.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Properties](../WolframModelAndWolframModelEvolutionObject.md#properties) > 2 | 3 | # Termination Reason 4 | 5 | **`"TerminationReason"`** shows why the evaluation of the model was stopped. It's particularly useful if 6 | multiple [stopping conditions](../WolframModelAndWolframModelEvolutionObject.md#step-limiters) are specified. 7 | 8 | All possible values are: 9 | 10 | * `"MaxEvents"`, `"MaxGenerations"`, `"MaxVertices"`, `"MaxVertexDegree"` and `"MaxEdges"` correspond directly 11 | to [step limiters](../WolframModelAndWolframModelEvolutionObject.md#step-limiters). 12 | * `"FixedPoint"` means there were no more matches possible to rule inputs. 13 | * `"TimeConstraint"` could occur if a [`"TimeConstraint"`](../Options/TimeConstraint.md) option is used. 14 | * `"Aborted"` would occur if the evaluation was manually interrupted (i.e., by pressing ⌘. on a Mac). In that case, a 15 | partially computed evolution object is returned. 16 | 17 | As an example, in our arithmetic model a `"FixedPoint"` is reached (which is why we can 18 | use [`Infinity`](https://reference.wolfram.com/language/ref/Infinity.html) as the number of steps): 19 | 20 | ```wl 21 | In[] := WolframModel[<|"PatternRules" -> {a_, b_} :> a + b|>, 22 | {3, 8, 8, 8, 2, 10, 0, 9, 7}, Infinity]["TerminationReason"] 23 | Out[] = "FixedPoint" 24 | ``` 25 | 26 | And if we manually abort the evolution, we could get something like this: 27 | 28 | ```wl 29 | In[] := WolframModel[{{1, 2, 3}, {4, 5, 6}, {1, 4}} -> 30 | {{2, 7, 8}, {5, 9, 10}, {6, 11, 12}, {13, 3, 14}, {8, 13}, {9, 31 | 7}, {10, 12}, {14, 11}}, 32 | {{1, 1, 1}, {1, 1, 1}, {1, 1}, {1, 1}, {1, 1}}, 100] 33 | ⌘. 34 | ``` 35 | 36 | 37 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/TotalElementCounts.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Properties](../WolframModelAndWolframModelEvolutionObject.md#properties) > 2 | 3 | # Total Element Counts 4 | 5 | **`"AllEventsDistinctElementsCount"`** (aka `"AtomsCountTotal"`) and **`"AllEventsEdgesCount"`** ( 6 | aka `"ExpressionsCountTotal"`) are similar to [`"FinalDistinctElementsCount"`](FinalElementCounts.md) 7 | and [`"FinalEdgeCount"`](FinalElementCounts.md), except they count atoms and edges throughout the entire evolution 8 | instead of just in the final step. 9 | 10 | For instance, 11 | 12 | ```wl 13 | In[] := WolframModel[{{1, 2, 3}, {2, 4, 5}} -> 14 | {{6, 6, 3}, {2, 6, 2}, {6, 4, 2}, {5, 3, 6}}, 15 | {{1, 1, 1}, {1, 1, 1}}, 10, 16 | {"AllEventsDistinctElementsCount", "AllEventsEdgesCount"}] 17 | Out[] = {622, 2486} 18 | ``` 19 | -------------------------------------------------------------------------------- /Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/Version.md: -------------------------------------------------------------------------------- 1 | ###### [Symbols and Functions](/README.md#symbols-and-functions) > [WolframModel and WolframModelEvolutionObject](../WolframModelAndWolframModelEvolutionObject.md) > [Properties](../WolframModelAndWolframModelEvolutionObject.md#properties) > 2 | 3 | # Version 4 | 5 | **`"Version"`** returns the version of the data structure used in the evolution object. It will always be the same for 6 | the same version of *SetReplace*: 7 | 8 | ```wl 9 | In[] := WolframModel[1 -> 2, {1}]["Version"] 10 | Out[] = 2 11 | ``` 12 | 13 | Objects are automatically converted to the latest version when they are encountered by the newer version of 14 | *SetReplace*. 15 | -------------------------------------------------------------------------------- /Documentation/Systems/AtomicStateSystem.md: -------------------------------------------------------------------------------- 1 | # AtomicStateSystem 2 | 3 | **`AtomicStateSystem`** is a simple system where states consist of single tokens. The rules consist of patterns on the 4 | left that can match these states, and the arbitrary code on the right that creates a new state: 5 | 6 | ```wl 7 | In[] := #["ExpressionsEventsGraph", VertexLabels -> Placed[Automatic, After]] & @ 8 | SetReplaceTypeConvert[WolframModelEvolutionObject] @ 9 | GenerateMultihistory[AtomicStateSystem[{n_ :> n + 1, n_ :> n - 1}], MaxGeneration -> 4][0] 10 | ``` 11 | 12 | 13 | 14 | Note that spacelike separation is not possible in the `AtomicStateSystem`. As a result, branching due to overlaps of 15 | different subsets of input tokens cannot occur. And, since events cannot produce branchlike-separated outputs and there 16 | is currently no way to assign multiple outputs to a single match of a left-hand side of a rule, branching can only occur 17 | due to multiple rules. 18 | -------------------------------------------------------------------------------- /Documentation/Systems/README.md: -------------------------------------------------------------------------------- 1 | # Systems 2 | 3 | *SetReplace* supports multiple computational systems. The system-specific functions such as 4 | [`MultisetSubstitutionSystem`](MultisetSubstitutionSystem.md) do not perform the evaluation themselves. Instead, one 5 | uses them to specify the rules for the [generators](/Documentation/Generators/README.md). 6 | 7 | These functions typically take a single argument for the system-specific rules: 8 | 9 | * [`AtomicStateSystem`](AtomicStateSystem.md) 10 | * [`MultisetSubstitutionSystem`](MultisetSubstitutionSystem.md) 11 | -------------------------------------------------------------------------------- /Documentation/TypeSystem/$SetReplaceProperties.md: -------------------------------------------------------------------------------- 1 | # $SetReplaceProperties 2 | 3 | **`$SetReplaceProperties`** gives the list of all [properties](/Documentation/Properties/README.md) defined in 4 | *SetReplace*: 5 | 6 | ```wl 7 | In[] := $SetReplaceProperties 8 | Out[] = {} 9 | ``` 10 | -------------------------------------------------------------------------------- /Documentation/TypeSystem/$SetReplaceTypeGraph.md: -------------------------------------------------------------------------------- 1 | # $SetReplaceTypeGraph 2 | 3 | **`$SetReplaceTypeGraph`** gives the [`Graph`](https://reference.wolfram.com/language/ref/Graph.html) showing 4 | [types](/Documentation/Types/README.md) and [properties](/Documentation/Properties/README.md) defined in *SetReplace* 5 | (including internal ones) and possible computation paths between them: 6 | 7 | ```wl 8 | In[] := $SetReplaceTypeGraph 9 | ``` 10 | 11 | 12 | 13 | It is a [`Graph`](https://reference.wolfram.com/language/ref/Graph.html) representation of a directed hypergraph with 14 | types and properties as vertices and implementations of translations and properties as edges. 15 | 16 | Vertex heads are either [`SetReplaceType`](SetReplaceType.md), [`SetReplaceProperty`](SetReplaceProperty.md) or 17 | [`SetReplaceMethodImplementation`](SetReplaceMethodImplementation.md). 18 | -------------------------------------------------------------------------------- /Documentation/TypeSystem/$SetReplaceTypes.md: -------------------------------------------------------------------------------- 1 | # $SetReplaceTypes 2 | 3 | **`$SetReplaceTypes`** gives the list of all [types](/Documentation/Types/README.md) defined in *SetReplace*: 4 | 5 | ```wl 6 | In[] := $SetReplaceTypes 7 | ``` 8 | 9 | 10 | -------------------------------------------------------------------------------- /Documentation/TypeSystem/README.md: -------------------------------------------------------------------------------- 1 | # Type System 2 | 3 | The basis of *SetReplace* is the type system used for [`Multihistory`](/Documentation/Types/Multihistory/README.md) 4 | objects describing evolutions of various computational systems. 5 | 6 | `Multihistory` objects can be created with functions such as 7 | [`GenerateMultihistory`](/Documentation/Generators/GenerateMultihistory.md). 8 | 9 | These functions take various [computational systems](/Documentation/Systems/README.md) such as 10 | [`MultisetSubstitutionSystem`](/Documentation/Systems/MultisetSubstitutionSystem.md) as an argument. 11 | 12 | We will also have [properties](/Documentation/Properties/README.md) implemented for some of these objects, e.g., 13 | `TokenEventGraph`. These properties can transparently convert objects to the [type](/Documentation/Types/README.md) 14 | required to evaluate them. 15 | 16 | Most of the time, it is sufficient to rely on these automatic conversions. However, sometimes it might be useful to 17 | convert an object to a different type manually for persistence or optimization, in which case one can use the 18 | [`SetReplaceTypeConvert`](SetReplaceTypeConvert.md) function. 19 | 20 | [`SetReplaceObjectQ`](SetReplaceObjectQ.md) can be used to find out if an expression is a *SetReplace* object, and 21 | [`SetReplaceObjectType`](SetReplaceObjectType.md) can be used to determine its type. 22 | 23 | * Enumeration: 24 | * [`$SetReplaceTypes`]($SetReplaceTypes.md) 25 | * [`$SetReplaceProperties`]($SetReplaceProperties.md) 26 | * [`$SetReplaceTypeGraph`]($SetReplaceTypeGraph.md) — a graph showing translations/property implementation paths 27 | * Vertex heads: [`SetReplaceType`](SetReplaceType.md), 28 | [`SetReplaceProperty`](SetReplaceProperty.md), 29 | [`SetReplaceMethodImplementation`](SetReplaceMethodImplementation.md) 30 | * Introspection: 31 | * [`SetReplaceObjectQ`](SetReplaceObjectQ.md) 32 | * [`SetReplaceObjectType`](SetReplaceObjectType.md) 33 | * Conversion: 34 | * [`SetReplaceTypeConvert`](SetReplaceTypeConvert.md) — change an object from one type to another 35 | -------------------------------------------------------------------------------- /Documentation/TypeSystem/SetReplaceMethodImplementation.md: -------------------------------------------------------------------------------- 1 | # SetReplaceMethodImplementation 2 | 3 | **`SetReplaceMethodImplementation`** represents a (usually internal) implementation of either a translation or a 4 | property. It has the implementation symbol as the only argument. 5 | 6 | It is used in vertex names of [`$SetReplaceTypeGraph`]($SetReplaceTypeGraph.md). 7 | -------------------------------------------------------------------------------- /Documentation/TypeSystem/SetReplaceObjectQ.md: -------------------------------------------------------------------------------- 1 | # SetReplaceObjectQ 2 | 3 | **`SetReplaceObjectQ`** yields [`True`](https://reference.wolfram.com/language/ref/True.html) for *SetReplace* objects 4 | and [`False`](https://reference.wolfram.com/language/ref/False.html) otherwise: 5 | 6 | 7 | 8 | ```wl 9 | Out[] = True 10 | ``` 11 | 12 | ```wl 13 | In[] := SetReplaceObjectQ["just a string"] 14 | Out[] = False 15 | ``` 16 | -------------------------------------------------------------------------------- /Documentation/TypeSystem/SetReplaceObjectType.md: -------------------------------------------------------------------------------- 1 | # SetReplaceObjectType 2 | 3 | **`SetReplaceObjectType`** yields [the type](/Documentation/Types/README.md) of an object. Note that the type 4 | specification usually contains its version: 5 | 6 | 7 | -------------------------------------------------------------------------------- /Documentation/TypeSystem/SetReplaceProperty.md: -------------------------------------------------------------------------------- 1 | # SetReplaceProperty 2 | 3 | **`SetReplaceProperty`** represents a *SetReplace* property. It has the property symbol as its single argument. 4 | 5 | It is used in vertex names of [`$SetReplaceTypeGraph`]($SetReplaceTypeGraph.md). 6 | -------------------------------------------------------------------------------- /Documentation/TypeSystem/SetReplaceType.md: -------------------------------------------------------------------------------- 1 | # SetReplaceType 2 | 3 | **`SetReplaceType`** represents a *SetReplace* [type](/Documentation/Types/README.md). It has the format 4 | 5 | ```wl 6 | SetReplaceType[name, version] 7 | ``` 8 | 9 | It is used in vertex names of [`$SetReplaceTypeGraph`]($SetReplaceTypeGraph.md) and is returned by functions such as 10 | [`SetReplaceObjectType`](SetReplaceObjectType.md). 11 | -------------------------------------------------------------------------------- /Documentation/TypeSystem/SetReplaceTypeConvert.md: -------------------------------------------------------------------------------- 1 | # SetReplaceTypeConvert 2 | 3 | **`SetReplaceTypeConvert`** allows one to convert one [type](/Documentation/Types/README.md) (of, e.g., 4 | [`Multihistory`](/Documentation/Types/Multihistory/README.md)) into another: 5 | 6 | ```wl 7 | SetReplaceTypeConvert[newType][object] 8 | ``` 9 | 10 | For example, one can convert an 11 | [`AtomicStateSystem` multihistory](/Documentation/Types/Multihistory/AtomicStateSystem0.md) to a 12 | [`MultisetSubstitutionSystem` multihistory](/Documentation/Types/Multihistory/MultisetSubstitutionSystem0.md): 13 | 14 | 15 | 16 | To convert to a specific version of a type, one can use the full type specification: 17 | 18 | 19 | -------------------------------------------------------------------------------- /Documentation/Types/Multihistory/AtomicStateSystem0.md: -------------------------------------------------------------------------------- 1 | # AtomicStateSystem Multihistory 2 | 3 | [**`AtomicStateSystem`**](/Documentation/Systems/AtomicStateSystem.md) [`Multihistory`](README.md) object is returned by 4 | [generators](/Documentation/Generators/README.md) of the 5 | [`AtomicStateSystem`](/Documentation/Systems/AtomicStateSystem.md): 6 | 7 | ```wl 8 | In[] := GenerateMultihistory[AtomicStateSystem[a_ :> a + 1], MaxEvents -> 10][0] 9 | ``` 10 | 11 | 12 | 13 | Internally, [`AtomicStateSystem`](/Documentation/Systems/AtomicStateSystem.md) is implemented by running a special case 14 | of the [`MultisetSubstitutionSystem`](/Documentation/Systems/MultisetSubstitutionSystem.md). The object contains a 15 | [`MultisetSubstitutionSystem` multihistory](MultisetSubstitutionSystem0.md) and can be converted to it. 16 | -------------------------------------------------------------------------------- /Documentation/Types/Multihistory/MultisetSubstitutionSystem0.md: -------------------------------------------------------------------------------- 1 | # MultisetSubstitutionSystem Multihistory 2 | 3 | [**`MultisetSubstitutionSystem`**](/Documentation/Systems/MultisetSubstitutionSystem.md) [`Multihistory`](README.md) 4 | object is returned by [generators](/Documentation/Generators/README.md) of the 5 | [`MultisetSubstitutionSystem`](/Documentation/Systems/MultisetSubstitutionSystem.md): 6 | 7 | ```wl 8 | In[] := GenerateMultihistory[MultisetSubstitutionSystem[{a_, b_} :> {a + b}], MaxEvents -> 10] @ {1, 2, 3} 9 | ``` 10 | 11 | 12 | 13 | It is implemented as an [`Association`](https://reference.wolfram.com/language/guide/Associations.html) of 14 | [data structures](https://reference.wolfram.com/language/ref/DataStructure.html) containing information about the rules, 15 | termination reason, contents of expressions, rule indices used for each event, event inputs and outputs, generations, 16 | separations of expressions and other values used for optimization. 17 | 18 | There are no properties implemented for it yet, however, it can be 19 | [converted](/Documentation/TypeSystem/SetReplaceTypeConvert.md) to a 20 | [WolframModelEvolutionObject](/Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/WolframModelAndWolframModelEvolutionObject.md) 21 | for backwards compatibility. 22 | -------------------------------------------------------------------------------- /Documentation/Types/Multihistory/README.md: -------------------------------------------------------------------------------- 1 | # Multihistory 2 | 3 | **`Multihistory`** is a head used for [types](/Documentation/Types/README.md) representing an evaluation history of a 4 | [computational system](/Documentation/Systems/README.md). 5 | 6 | For example, for a [`MultisetSubstitutionSystem`](/Documentation/Systems/MultisetSubstitutionSystem.md), 7 | 8 | ```wl 9 | In[] := GenerateMultihistory[MultisetSubstitutionSystem[{a_, b_} :> {a + b}], MaxEvents -> 10] @ {1, 2, 3} 10 | ``` 11 | 12 | 13 | 14 | You will be able to use [`properties`](/Documentation/Properties/README.md) to extract information about multihistories, 15 | but we have not implemented any properties yet. 16 | 17 | * [`AtomicStateSystem`](AtomicStateSystem0.md) 18 | * [`MultisetSubstitutionSystem`](MultisetSubstitutionSystem0.md) 19 | -------------------------------------------------------------------------------- /Documentation/Types/README.md: -------------------------------------------------------------------------------- 1 | # Types 2 | 3 | The basis of *SetReplace* is a [type system](/Documentation/TypeSystem/README.md) which allows one to separate 4 | generation of data (such as the data about the evaluation of a 5 | [nondeterministic system](/Documentation/Systems/README.md)) and computation of 6 | [properties](/Documentation/Properties/README.md) from that data. 7 | 8 | Multihistory types are named after systems that produce them, e.g., `SetReplaceType[MultisetSubstitutionSystem, 0]`. 9 | 10 | * [`Multihistory`](Multihistory/README.md) — a generic kind of types for computational systems: 11 | * [`AtomicStateSystem`](Multihistory/AtomicStateSystem0.md) 12 | * [`MultisetSubstitutionSystem`](Multihistory/MultisetSubstitutionSystem0.md) 13 | -------------------------------------------------------------------------------- /Kernel/$graphIcon.m: -------------------------------------------------------------------------------- 1 | Package["SetReplace`"] 2 | 3 | PackageScope["$graphIcon"] 4 | 5 | (* This is an icon that is used for objects such as Graph if one sets GraphLayout -> None. 6 | Extracted from boxes of that object. *) 7 | 8 | $graphIcon = Graphics[ 9 | GraphicsComplexBox[ 10 | {{0.1`, -3.31951456589972`}, 11 | {-0.14816751450286603`, -2.625037331552915`}, 12 | {0.6310524421714278`, -1.3`}, 13 | {0.9405108616213151`, -2.8841601437046225`}, 14 | {0.4967448863824806`, -2.092358403567382`}, 15 | {-0.846735323402297`, -1.466588600696043`}, 16 | {0.8846460183439665`, -0.5107506168284197`}, 17 | {1.8939086566530445`, -2.50980168725566`}, 18 | {1.756629266633539`, -3.4622764737192444`}, 19 | {2.119361963550152`, -2.99`}, 20 | {-0.5709741939515942`, -4.632295267644082`}, 21 | {0.20977925607671288`, -4.647162049737781`}, 22 | {-1.0861820131541373`, -4.047493574735101`}, 23 | {-1.2223073729506904`, -2.2040562174063485`}}, 24 | {Hue[0.6`,0.7`,0.5`], 25 | Opacity[0.7`], 26 | Arrowheads[0.`], 27 | ArrowBox[ 28 | {{1, 2}, 29 | {1, 4}, 30 | {1, 11}, 31 | {1, 12}, 32 | {1, 13}, 33 | {2, 3}, 34 | {2, 4}, 35 | {2, 5}, 36 | {2, 6}, 37 | {2, 14}, 38 | {3, 4}, 39 | {3, 7}, 40 | {4, 5}, 41 | {4, 8}, 42 | {4, 9}, 43 | {8, 10}, 44 | {9, 10}}, 45 | 0.0378698213750627`], 46 | Hue[0.6`, 0.2`, 0.8`], 47 | EdgeForm[{GrayLevel[0], Opacity[0.7`]}], 48 | DiskBox[1, 0.05`], 49 | DiskBox[2, 0.05`], 50 | DiskBox[3, 0.05`], 51 | DiskBox[4, 0.05`], 52 | DiskBox[5, 0.05`], 53 | DiskBox[6, 0.05`], 54 | DiskBox[7, 0.05`], 55 | DiskBox[8, 0.05`], 56 | DiskBox[9, 0.05`], 57 | DiskBox[10, 0.05`], 58 | DiskBox[11, 0.05`], 59 | DiskBox[12, 0.05`], 60 | DiskBox[13, 0.05`], 61 | DiskBox[14, 0.05`]}], 62 | AspectRatio -> 1, 63 | Background -> GrayLevel[0.93`], 64 | ImagePadding -> 0, 65 | FrameStyle -> Directive[ 66 | Opacity[0.5`], 67 | Thickness[Tiny], 68 | RGBColor[0.368417`, 0.506779`, 0.709798`]], 69 | Frame -> True, 70 | FrameTicks -> None, 71 | ImageSize -> Dynamic[{ 72 | Automatic, 73 | 3.5` CurrentValue["FontCapHeight"] / AbsoluteCurrentValue[Magnification]}], 74 | PlotRange -> {{-1.1`, 2.4`}, {-4.4`, -0.7`}}]; 75 | -------------------------------------------------------------------------------- /Kernel/A01$libSetReplace.m: -------------------------------------------------------------------------------- 1 | Package["SetReplace`"] 2 | 3 | PackageImport["GeneralUtilities`"] 4 | 5 | PackageScope["$libSetReplaceAvailable"] 6 | PackageScope["unloadLibrary"] 7 | PackageScope["importLibSetReplaceFunction"] 8 | 9 | (* All functions loaded from C++ should go in this file. This is the counterpart of libSetReplace/SetReplace.hpp *) 10 | 11 | (* this function is defined now, but only run the *next* time Kernel/init.m is called, before all symbols 12 | are cleared. *) 13 | unloadLibrary[] := If[StringQ[$libraryFile], 14 | Scan[LibraryFunctionUnload, $libraryFunctions]; 15 | $libraryFunctions = Null; 16 | Quiet @ LibraryUnload[$libraryFile]; 17 | ]; 18 | 19 | SetReplace::nolibsetreplace = "libSetReplace (``) could not be found, some functionality will not be available."; 20 | 21 | $libraryFile = $SetReplaceLibraryPath; 22 | 23 | If[!StringQ[$libraryFile] || !FileExistsQ[$libraryFile], 24 | Message[SetReplace::nolibsetreplace, $libraryFile]; 25 | $libraryFile = $Failed; 26 | ]; 27 | 28 | $libraryFunctions = {}; 29 | 30 | $cppRedistributableURL = 31 | "https://support.microsoft.com/en-us/topic/" <> 32 | "the-latest-supported-visual-c-downloads-2647da03-1eea-4433-9aff-95f26a218cc0"; 33 | 34 | SetReplace::cppRedistributable = 35 | "Check that " <> 36 | "\!\(\*TemplateBox[" <> 37 | "{\"Microsoft Visual C++ Redistributable\", " <> 38 | "{URL[\"" <> $cppRedistributableURL <> "\"], None}, " <> 39 | "\"" <> $cppRedistributableURL <> "\", " <> 40 | "\"HyperlinkActionRecycled\", " <> 41 | "{\"HyperlinkActive\"}, " <> 42 | "BaseStyle -> {\"URL\"}, " <> 43 | "HyperlinkAction -> \"Recycled\"}, " <> 44 | "\"HyperlinkTemplate\"]\)" <> 45 | " is installed."; 46 | 47 | importLibSetReplaceFunction[cppFunctionName_ -> symbol_, argumentTypes_, outputType_] := ( 48 | symbol = If[$libraryFile =!= $Failed, 49 | Check[ 50 | LibraryFunctionLoad[$libraryFile, cppFunctionName, argumentTypes, outputType], 51 | If[$SystemID === "Windows-x86-64", Message[SetReplace::cppRedistributable]]; $Failed, 52 | {LibraryFunction::libload} 53 | ] 54 | , 55 | $Failed 56 | ]; 57 | AppendTo[$libraryFunctions, symbol]; 58 | ); 59 | 60 | $libSetReplaceAvailable := FreeQ[$libraryFunctions, $Failed]; 61 | -------------------------------------------------------------------------------- /Kernel/AcyclicGraphTake.m: -------------------------------------------------------------------------------- 1 | Package["SetReplace`"] 2 | 3 | PackageImport["GeneralUtilities`"] 4 | 5 | PackageExport["AcyclicGraphTake"] 6 | 7 | PackageScope["acyclicGraphTake"] 8 | 9 | (* Utility function to check for directed, acyclic graphs *) 10 | dagQ[graph_] := AcyclicGraphQ[graph] && DirectedGraphQ[graph] && LoopFreeGraphQ[graph] 11 | 12 | (* Documentation *) 13 | SetUsage @ " 14 | AcyclicGraphTake[graph$, vertexList$] gives the intersection in graph$ of the in-component of the first vertex in \ 15 | vertexList$ with the out-component of the second vertex in vertexList$. 16 | "; 17 | 18 | (* SyntaxInformation *) 19 | SyntaxInformation[AcyclicGraphTake] = {"ArgumentsPattern" -> {graph_, vertexList_}}; 20 | 21 | (* Argument count *) 22 | AcyclicGraphTake[args___] := 0 /; 23 | !Developer`CheckArgumentCount[AcyclicGraphTake[args], 2, 2] && False; 24 | 25 | (* main *) 26 | expr : AcyclicGraphTake[graph_, vertices_] := ModuleScope[ 27 | res = Catch[acyclicGraphTake[graph, vertices]]; 28 | If[FailureQ[res], Switch[res[[1]], 29 | "invalidGraph", Message[AcyclicGraphTake::invalidGraph, 1, HoldForm @ expr], 30 | "invalidVertexList", Message[AcyclicGraphTake::invalidVertexList, 2, HoldForm @ expr], 31 | "invalidVertex", Message[AcyclicGraphTake::invalidVertex, res[[2, "vertex"]], HoldForm @ expr] 32 | ]]; 33 | res /; !FailureQ[res] 34 | ]; 35 | 36 | (* Normal form *) 37 | acyclicGraphTake[graph_ ? dagQ, {startVertex_, endVertex_}] /; 38 | VertexQ[graph, startVertex] && VertexQ[graph, endVertex] := ModuleScope[ 39 | Subgraph[graph, Intersection[ 40 | VertexInComponent[graph, endVertex], VertexOutComponent[graph, startVertex]]] 41 | ] 42 | 43 | (* Incorrect arguments messages *) 44 | General::invalidGraph = "The argument at position `1` in `2` should be a directed, acyclic graph."; 45 | acyclicGraphTake[graph_ ? (Not @* dagQ), _] := 46 | Throw[Failure["invalidGraph", <||>]]; 47 | 48 | General::invalidVertexList = "The argument at position `1` in `2` should be a list of two vertices."; 49 | acyclicGraphTake[_, Except[{_, _}]] := 50 | Throw[Failure["invalidVertexList", <||>]]; 51 | 52 | General::invalidVertex = "The argument `1` is not a valid vertex in `2`."; 53 | acyclicGraphTake[graph_Graph, {startVertex_, endVertex_}] /; 54 | (Not @ (VertexQ[graph, startVertex] && VertexQ[graph, endVertex])) := 55 | Throw[Failure["invalidVertex", <|"vertex" -> If[VertexQ[graph, startVertex], endVertex, startVertex]|>]]; 56 | -------------------------------------------------------------------------------- /Kernel/AtomicStateSystem.m: -------------------------------------------------------------------------------- 1 | Package["SetReplace`"] 2 | 3 | PackageImport["GeneralUtilities`"] 4 | 5 | PackageExport["AtomicStateSystem"] 6 | 7 | SetUsage @ " 8 | AtomicStateSystem[{pattern$1 :> output$1, pattern$2 :> output$2, $$}] is a rewriting system that matches pattern$i to \ 9 | entire states and replaces them with output$i. 10 | AtomicStateSystem should be used as the first argument in functions such as GenerateMultihistory. 11 | "; 12 | 13 | SyntaxInformation[AtomicStateSystem] = {"ArgumentsPattern" -> {rules_}}; 14 | 15 | declareSystem[AtomicStateSystem, generateAtomicStateSystem, _, {MaxGeneration, MaxDestroyerEvents, MaxEvents}, True]; 16 | 17 | generateAtomicStateSystem[AtomicStateSystem[rules___], init_, parameters_] := ModuleScope[ 18 | toAtomicStateMultihistory[rules] @ generateMultihistory[ 19 | MultisetSubstitutionSystem[toMultisetRules[rules]], 20 | Join[parameters, <|MinEventInputs -> 1, MaxEventInputs -> 1|>]] @ {init} 21 | ]; 22 | 23 | (* Parsing *) 24 | 25 | $singleRulePattern = _Rule | _RuleDelayed; 26 | toMultisetRules[atomicRules : $singleRulePattern] := toMultisetRules @ {atomicRules}; 27 | toMultisetRules[atomicRules : {$singleRulePattern...}] := Map[List, atomicRules, {2}]; 28 | declareMessage[General::invalidAtomicStateRules, "Rules `rules` must be a Rule, a RuleDelayed or a List of them."]; 29 | toMultisetRules[atomicRules_] := throw[Failure["invalidAtomicStateRules", <|"rules" -> atomicRules|>]]; 30 | toMultisetRules[atomicRules___] /; !CheckArguments[AtomicStateSystem[atomicRules], 1] := throw[Failure[None, <||>]]; 31 | 32 | (* Conversion to Atomic State Multihistory *) 33 | (* Not done as a normal translation because it should fail if rules have multiple inputs/outputs. *) 34 | 35 | toAtomicStateMultihistory[rules_][multisetMultihistory_] := Multihistory[ 36 | SetReplaceType[AtomicStateSystem, 0], <|"Rules" -> rules, "MultisetMultihistory" -> multisetMultihistory|>]; 37 | 38 | (* Conversion to Multiset Multihistory *) 39 | 40 | declareTypeTranslation[ 41 | toMultisetMultihistory, SetReplaceType[AtomicStateSystem, 0], SetReplaceType[MultisetSubstitutionSystem, 0]]; 42 | 43 | toMultisetMultihistory[Multihistory[_, data_]] := data["MultisetMultihistory"]; 44 | -------------------------------------------------------------------------------- /Kernel/CausalDensityDimension.m: -------------------------------------------------------------------------------- 1 | Package["SetReplace`"] 2 | 3 | PackageImport["GeneralUtilities`"] 4 | 5 | PackageExport["CausalDensityDimension"] 6 | 7 | (* Documentation *) 8 | SetUsage @ " 9 | CausalDensityDimension[graph$, vertices$] gives an estimate of the dimension of a subgraph of the graph graph$ \ 10 | between the vertices vertices$, using the Myrheim-Meyer dimension estimation algorithm. 11 | "; 12 | 13 | (* SyntaxInformation *) 14 | SyntaxInformation[CausalDensityDimension] = 15 | {"ArgumentsPattern" -> {causalGraph_, vertices_}}; 16 | 17 | (* Argument count *) 18 | CausalDensityDimension[args___] := 0 /; 19 | !Developer`CheckArgumentCount[CausalDensityDimension[args], 2, 2] && False; 20 | 21 | (* main *) 22 | expr : CausalDensityDimension[causalGraph_, vertices_] := ModuleScope[ 23 | res = Catch[causalDensityDimension[causalGraph, vertices]]; 24 | If[FailureQ[res], Switch[res[[1]], 25 | "invalidGraph", Message[CausalDensityDimension::invalidGraph, 1, HoldForm @ expr], 26 | "invalidVertexList", Message[CausalDensityDimension::invalidVertexList, 2, HoldForm @ expr], 27 | "invalidVertex", Message[CausalDensityDimension::invalidVertex, res[[2, "vertex"]], HoldForm @ expr] 28 | ]]; 29 | res /; !FailureQ[res] 30 | ]; 31 | 32 | (* Normal form *) 33 | causalDensityDimension[causalGraph_, vertices_] := Module[{d}, 34 | With[{ 35 | diamond = TransitiveClosureGraph[acyclicGraphTake[causalGraph, vertices]]}, 36 | If[EmptyGraphQ[diamond], 37 | Infinity 38 | , 39 | Replace[d, FindRoot[ 40 | {EdgeCount[diamond] / ((VertexCount[diamond])^2) == (Gamma[d + 1] * Gamma[d / 2])/(4 Gamma[3 d / 2])}, 41 | {d, 1, 0, Infinity}]]] 42 | ] 43 | ] 44 | -------------------------------------------------------------------------------- /Kernel/IndexHypergraph.m: -------------------------------------------------------------------------------- 1 | Package["SetReplace`"] 2 | 3 | PackageImport["GeneralUtilities`"] 4 | 5 | PackageExport["IndexHypergraph"] 6 | 7 | (* Documentation *) 8 | 9 | SetUsage @ " 10 | IndexHypergraph[hypergraph$] replaces the vertices of hypergraph$ by its vertex indices. 11 | IndexHypergraph[hypergraph$, startIndex$] replaces the vertices with integers startIndex$, startIndex$ + 1, $$. 12 | "; 13 | 14 | (* SyntaxInformation *) 15 | SyntaxInformation[IndexHypergraph] = {"ArgumentsPattern" -> {hypergraph_, startIndex_.}}; 16 | 17 | (* Argument count *) 18 | IndexHypergraph[args___] := 0 /; 19 | !Developer`CheckArgumentCount[IndexHypergraph[args], 1, 2] && False; 20 | 21 | (* main *) 22 | expr : IndexHypergraph[hypergraph_, startIndex : _ : 1] := ModuleScope[ 23 | res = Catch[indexHypergraph[HoldForm @ expr, hypergraph, startIndex]]; 24 | res /; res =!= $Failed 25 | ]; 26 | 27 | (* Normal form *) 28 | indexHypergraph[_, hypergraph_ ? hypergraphQ, startIndex : _Integer ? IntegerQ] := ModuleScope[ 29 | vertices = vertexList @ hypergraph; 30 | vertexIndices = Range[0, Length[vertices] - 1] + startIndex; 31 | Replace[hypergraph, Thread[vertices -> vertexIndices], {2}] 32 | ]; 33 | 34 | (* Incorrect arguments messages *) 35 | indexHypergraph[expr_, hypergraph_ ? (Not @* hypergraphQ), ___] := 36 | (Message[IndexHypergraph::invalidHypergraph, 1, HoldForm @ expr]; 37 | Throw[$Failed]); 38 | 39 | indexHypergraph[expr_, _ , _] := 40 | (Message[IndexHypergraph::int, expr, 2]; 41 | Throw[$Failed]); 42 | -------------------------------------------------------------------------------- /Kernel/IsomorphicHypergraphQ.m: -------------------------------------------------------------------------------- 1 | Package["SetReplace`"] 2 | 3 | PackageImport["GeneralUtilities`"] 4 | 5 | PackageExport["IsomorphicHypergraphQ"] 6 | 7 | (* Documentation *) 8 | 9 | SetUsage @ " 10 | IsomorphicHypergraphQ[hypergraph$1, hypergraph$2] yields True if hypergraph$1 and hypergraph$2 are isomorphic, and \ 11 | False otherwise. 12 | "; 13 | 14 | (* SyntaxInformation *) 15 | SyntaxInformation[IsomorphicHypergraphQ] = 16 | {"ArgumentsPattern" -> {hypergraph1_, hypergraph2_}}; 17 | 18 | (* Argument count *) 19 | IsomorphicHypergraphQ[args___] := 0 /; 20 | !Developer`CheckArgumentCount[IsomorphicHypergraphQ[args], 2, 2] && False; 21 | 22 | (* main *) 23 | expr : IsomorphicHypergraphQ[hypergraph1_, hypergraph2_] := ModuleScope[ 24 | res = Catch[isomorphicHypergraphQ[HoldForm @ expr, hypergraph1, hypergraph2]]; 25 | res /; res =!= $Failed 26 | ]; 27 | 28 | (* Normal form *) 29 | isomorphicHypergraphQ[_, hypergraph1_ ? hypergraphQ, hypergraph2_ ? hypergraphQ] := With[{ 30 | graph1 = HypergraphToGraph[hypergraph1, "StructurePreserving"], 31 | graph2 = HypergraphToGraph[hypergraph2, "StructurePreserving"]}, 32 | IsomorphicGraphQ[graph1, graph2] 33 | ]; 34 | 35 | (* Incorrect arguments messages *) 36 | isomorphicHypergraphQ[expr_, _ ? (Not @* hypergraphQ), _] := 37 | (Message[IsomorphicHypergraphQ::invalidHypergraph, 1, HoldForm @ expr]; 38 | Throw[$Failed]); 39 | 40 | isomorphicHypergraphQ[expr_, _, _? (Not @* hypergraphQ)] := 41 | (Message[IsomorphicHypergraphQ::invalidHypergraph, 2, HoldForm @ expr]; 42 | Throw[$Failed]); 43 | -------------------------------------------------------------------------------- /Kernel/Multihistory.m: -------------------------------------------------------------------------------- 1 | Package["SetReplace`"] 2 | 3 | PackageImport["GeneralUtilities`"] 4 | 5 | PackageExport["Multihistory"] 6 | 7 | SetUsage @ " 8 | Multihistory[$$] is an object containing evaluation of a possibly nondeterministic computational system. 9 | "; 10 | 11 | SyntaxInformation[Multihistory] = {"ArgumentsPattern" -> {type_, internalData_}}; 12 | 13 | (* Multihistory can contain an evaluation of any substitution system, such as multiset, hypergraph, string, etc. 14 | Internally, it has a type specifying what kind of system it is as the first argument (including the version), and any 15 | data as the second. 16 | Note that specific types should never appear in this file, as Multihistory implementation is not type specific. *) 17 | 18 | objectType[Multihistory[type_, _]] := type; 19 | 20 | (* This is temporary and will need to be updated to use a composite property to automatically extract data from a 21 | Multihistory. Using a composite property will also allow objects to implement custom boxes for themselves. *) 22 | 23 | $genericMultihistoryIcon = GraphPlot[ 24 | {DirectedEdge[0, 1], DirectedEdge[1, 2], DirectedEdge[1, 3]}, 25 | GraphLayout -> "LayeredDigraphEmbedding", 26 | VertexStyle -> {1 -> style[$lightTheme][$tokenVertexStyle], style[$lightTheme][$eventVertexStyle]}, 27 | EdgeStyle -> Directive[style[$lightTheme][$causalEdgeStyle], Arrowheads[0]], 28 | VertexCoordinates -> {{0, 1}, {0, 0}, {0, -1} . RotationMatrix[Pi / 4], {0, -1} . RotationMatrix[-Pi / 4]}, 29 | VertexSize -> 0.5, 30 | PlotRange -> {{-1.3, 1.3}, {-1.3, 1.3}}, 31 | Background -> style[$lightTheme][$tokenEventGraphBackground]]; 32 | 33 | Multihistory /: MakeBoxes[object : Multihistory[_, _], format_] := ModuleScope[ 34 | type = objectType[object]; 35 | BoxForm`ArrangeSummaryBox[ 36 | Multihistory, 37 | object, 38 | $genericMultihistoryIcon, 39 | (* Always displayed *) 40 | {{BoxForm`SummaryItem[{TraditionalForm[type]}]}}, 41 | (* Displayed on request *) 42 | {}, 43 | format, 44 | "Interpretable" -> Automatic 45 | ] 46 | ]; 47 | 48 | declareMessage[ 49 | Multihistory::invalid, 50 | "Multihistory object `expr` is invalid. Use GenerateMultihistory, GenerateAllHistories or GenerateSingleHistory " <> 51 | "to construct Multihistory objects."]; 52 | 53 | expr : Multihistory[args___] /; Length[{args}] =!= 2 := ModuleScope[ 54 | message[Multihistory::invalid, <|"expr" -> HoldForm[expr]|>]; 55 | None /; False 56 | ]; 57 | -------------------------------------------------------------------------------- /Kernel/MultisetToWolframModelEvolutionObject.m: -------------------------------------------------------------------------------- 1 | Package["SetReplace`"] 2 | 3 | PackageImport["GeneralUtilities`"] 4 | 5 | declareTypeTranslation[toWolframModelEvolutionObject, 6 | SetReplaceType[MultisetSubstitutionSystem, 0], 7 | SetReplaceType[WolframModelEvolutionObject, 2]]; 8 | 9 | toWolframModelEvolutionObject[Multihistory[_, data_]] := WolframModelEvolutionObject[<| 10 | "Version" -> 2, 11 | "Rules" -> Normal @ checkNotMissing[data["Rules"]], 12 | "MaxCompleteGeneration" -> Missing[], 13 | "TerminationReason" -> Switch[data["TerminationReason"], 14 | "Complete", "FixedPoint", 15 | "MaxEvents", "MaxEvents", 16 | _, throw[Failure["corruptMultisetMultihistory", <||>]]], 17 | "AtomLists" -> Normal @ checkNotMissing[data["Expressions"]], 18 | "EventRuleIDs" -> Normal @ checkNotMissing[data["EventRuleIndices"]], 19 | "EventInputs" -> Normal @ checkNotMissing[data["EventInputs"]], 20 | "EventOutputs" -> Normal @ checkNotMissing[data["EventOutputs"]], 21 | "EventGenerations" -> Normal @ checkNotMissing[data["EventGenerations"]] 22 | |>]; 23 | 24 | declareMessage[ 25 | General::corruptMultisetMultihistory, 26 | "MultisetSubstitutionSystem Multihistory is corrupt in `expr`. Use MultisetSubstitutionSystem and a generator " <> 27 | "function such as GenerateMultihistory to generate MultisetSubstitutionSystem Multihistory objects."]; 28 | 29 | checkNotMissing[_ ? MissingQ] := throw[Failure["corruptMultisetMultihistory", <||>]]; 30 | checkNotMissing[arg_] := arg; 31 | -------------------------------------------------------------------------------- /Kernel/SetReplace.m: -------------------------------------------------------------------------------- 1 | Package["SetReplace`"] 2 | 3 | PackageImport["GeneralUtilities`"] 4 | 5 | PackageExport["SetReplace"] 6 | 7 | (* This function behaves similarly to StringReplace. The implementation is done with WolframModel, which is a more 8 | general function. *) 9 | 10 | SetUsage @ " 11 | SetReplace[set$, {input$1 -> output$1, input$2 -> output$2, $$}] attempts to replace a subset input$1 of set$ with \ 12 | output$1. If not found, replaces input$2 with output$2, etc. Elements of input$k can appear in set$ in any order, \ 13 | however the elements closest to the beginning of set$ will be replaced, and the elements of output$k will be put at \ 14 | the end. 15 | SetReplace[set$, {input$1 -> output$1, input$2 -> output$2, $$}, eventCount$] performs replacement eventCount$ times \ 16 | and returns the result. 17 | "; 18 | 19 | Options[SetReplace] = { 20 | Method -> Automatic, 21 | TimeConstraint -> Infinity, 22 | "EventOrderingFunction" -> Automatic}; 23 | 24 | SyntaxInformation[SetReplace] = { 25 | "ArgumentsPattern" -> {set_, rules_, eventCount_., OptionsPattern[]}, 26 | "OptionNames" -> Options[SetReplace][[All, 1]]}; 27 | 28 | SetReplace[args___] := 0 /; 29 | !Developer`CheckArgumentCount[SetReplace[args], 2, 3] && False; 30 | 31 | expr : SetReplace[set_, rules_, eventCount : Except[_ ? OptionQ] : 1, o : OptionsPattern[]] /; 32 | recognizedOptionsQ[expr, SetReplace, {o}] := 33 | ModuleScope[ 34 | result = Check[ 35 | setSubstitutionSystem[rules, set, <|$maxEvents -> eventCount|>, SetReplace, False, o] 36 | , 37 | $Failed 38 | ]; 39 | If[result === $Aborted, result, result[-1]] /; result =!= $Failed 40 | ]; 41 | -------------------------------------------------------------------------------- /Kernel/SetReplaceAll.m: -------------------------------------------------------------------------------- 1 | Package["SetReplace`"] 2 | 3 | PackageImport["GeneralUtilities`"] 4 | 5 | PackageExport["SetReplaceAll"] 6 | 7 | (* The idea for SetReplaceAll is to keep performing SetReplace on the graph until no replacement can be done without 8 | touching the same edge twice. 9 | Note, it's not doing replacement until all edges are touched at least once. That may not always be possible. We just 10 | don't want to touch edges twice in a single step. *) 11 | 12 | SetUsage @ " 13 | SetReplaceAll[set$, rules$] performs SetReplace[set$, rules$] as many times as it takes until no \ 14 | replacement can be done without touching the same expression twice. 15 | SetReplaceAll[set$, rules$, generationCount$] performes the same operation generationCount$ times, i.e., any edge will \ 16 | at most be replaced generationCount$ times. 17 | "; 18 | 19 | Options[SetReplaceAll] = { 20 | Method -> Automatic, 21 | TimeConstraint -> Infinity, 22 | "EventOrderingFunction" -> Automatic}; 23 | 24 | SyntaxInformation[SetReplaceAll] = { 25 | "ArgumentsPattern" -> {set_, rules_, generationCount_., OptionsPattern[]}, 26 | "OptionNames" -> Options[SetReplaceAll][[All, 1]]}; 27 | 28 | SetReplaceAll[args___] := 0 /; 29 | !Developer`CheckArgumentCount[SetReplaceAll[args], 2, 3] && False; 30 | 31 | (* We just run SetSubstitutionSystem for the specified number of generations, and take the last set. *) 32 | 33 | expr : SetReplaceAll[ 34 | set_, rules_, generationCount : Except[_ ? OptionQ] : 1, o : OptionsPattern[]] /; 35 | recognizedOptionsQ[expr, SetReplaceAll, {o}] := 36 | ModuleScope[ 37 | result = Check[ 38 | setSubstitutionSystem[rules, set, <|$maxGenerationsLocal -> generationCount|>, SetReplaceAll, False, o] 39 | , 40 | $Failed 41 | ]; 42 | If[result === $Aborted, result, result[-1]] /; result =!= $Failed 43 | ]; 44 | -------------------------------------------------------------------------------- /Kernel/SetReplaceFixedPoint.m: -------------------------------------------------------------------------------- 1 | Package["SetReplace`"] 2 | 3 | PackageImport["GeneralUtilities`"] 4 | 5 | PackageExport["SetReplaceFixedPoint"] 6 | 7 | (* Same as SetReplace, but automatically stops replacing when the set no longer changes. *) 8 | 9 | SetUsage @ " 10 | SetReplaceFixedPoint[set$, {input$1 -> output$1, input$2 -> output$2, $$}] performs SetReplace repeatedly until \ 11 | no further events can be matched, and returns the final set. 12 | It will go into an infinite loop if a fixed point does not exist. 13 | "; 14 | 15 | Options[SetReplaceFixedPoint] = { 16 | Method -> Automatic, 17 | TimeConstraint -> Infinity, 18 | "EventOrderingFunction" -> Automatic}; 19 | 20 | SyntaxInformation[SetReplaceFixedPoint] = { 21 | "ArgumentsPattern" -> {set_, rules_, OptionsPattern[]}, 22 | "OptionNames" -> Options[SetReplaceFixedPoint][[All, 1]]}; 23 | 24 | SetReplaceFixedPoint[args___] := 0 /; 25 | !Developer`CheckArgumentCount[SetReplaceFixedPoint[args], 2, 2] && False; 26 | 27 | SetReplaceFixedPoint[set_, rules_, o : OptionsPattern[]] /; 28 | recognizedOptionsQ[expr, SetReplaceFixedPoint, {o}] := ModuleScope[ 29 | result = Check[ 30 | setSubstitutionSystem[rules, set, <||>, SetReplaceFixedPoint, False, o] 31 | , 32 | $Failed 33 | ]; 34 | If[result === $Aborted, result, result[-1]] /; result =!= $Failed 35 | ]; 36 | -------------------------------------------------------------------------------- /Kernel/SetReplaceFixedPointList.m: -------------------------------------------------------------------------------- 1 | Package["SetReplace`"] 2 | 3 | PackageImport["GeneralUtilities`"] 4 | 5 | PackageExport["SetReplaceFixedPointList"] 6 | 7 | (* Same as SetReplaceFixedPoint, but returns all intermediate steps. *) 8 | 9 | SetUsage @ " 10 | SetReplaceFixedPointList[set$, {input$1 -> output$1, input$2 -> output$2, $$}] performs SetReplace repeatedly until \ 11 | no further events can be matched, and returns the list of all intermediate sets. 12 | "; 13 | 14 | Options[SetReplaceFixedPointList] = { 15 | Method -> Automatic, 16 | TimeConstraint -> Infinity, 17 | "EventOrderingFunction" -> Automatic}; 18 | 19 | SyntaxInformation[SetReplaceFixedPointList] = { 20 | "ArgumentsPattern" -> {set_, rules_, OptionsPattern[]}, 21 | "OptionNames" -> Options[SetReplaceFixedPointList][[All, 1]]}; 22 | 23 | SetReplaceFixedPointList[args___] := 0 /; 24 | !Developer`CheckArgumentCount[SetReplaceFixedPointList[args], 2, 2] && False; 25 | 26 | SetReplaceFixedPointList[set_, rules_, o : OptionsPattern[]] /; 27 | recognizedOptionsQ[expr, SetReplaceFixedPointList, {o}] := ModuleScope[ 28 | result = Check[ 29 | setSubstitutionSystem[rules, set, <||>, SetReplaceFixedPointList, False, o] 30 | , 31 | $Failed 32 | ]; 33 | If[result === $Aborted, result, result["SetAfterEvent", #] & /@ Range[0, result["EventsCount"]]] /; 34 | result =!= $Failed 35 | ]; 36 | -------------------------------------------------------------------------------- /Kernel/SetReplaceList.m: -------------------------------------------------------------------------------- 1 | Package["SetReplace`"] 2 | 3 | PackageImport["GeneralUtilities`"] 4 | 5 | PackageExport["SetReplaceList"] 6 | 7 | (* Same as SetReplace, but returns all intermediate steps in a List. *) 8 | 9 | SetUsage @ " 10 | SetReplaceList[set$, rules$, eventCount$] performs SetReplace eventCount$ times and returns the list of all \ 11 | intermediate results. 12 | "; 13 | 14 | Options[SetReplaceList] = { 15 | Method -> Automatic, 16 | TimeConstraint -> Infinity, 17 | "EventOrderingFunction" -> Automatic}; 18 | 19 | SyntaxInformation[SetReplaceList] = { 20 | "ArgumentsPattern" -> {set_, rules_, eventCount_, OptionsPattern[]}, 21 | "OptionNames" -> Options[SetReplaceList][[All, 1]]}; 22 | 23 | SetReplaceList[args___] := 0 /; 24 | !Developer`CheckArgumentCount[SetReplaceList[args], 2, 3] && False; 25 | 26 | SetReplaceList[set_, rules_, events : Except[_ ? OptionQ] : 1, o : OptionsPattern[]] /; 27 | recognizedOptionsQ[expr, SetReplaceList, {o}] := 28 | ModuleScope[ 29 | result = Check[ 30 | setSubstitutionSystem[rules, set, <|$maxEvents -> events|>, SetReplaceList, False, o] 31 | , 32 | $Failed 33 | ]; 34 | If[result === $Aborted, result, result["SetAfterEvent", #] & /@ Range[0, result["EventsCount"]]] /; 35 | result =!= $Failed 36 | ]; 37 | -------------------------------------------------------------------------------- /Kernel/argumentsChecking.m: -------------------------------------------------------------------------------- 1 | Package["SetReplace`"] 2 | 3 | PackageImport["GeneralUtilities`"] 4 | 5 | PackageScope["checkEnumOptionValue"] 6 | PackageScope["checkIfKnownOptions"] 7 | 8 | declareMessage[General::invalidOptionChoice, "Option value `option` -> `value` in `expr` should be one of `choices`."]; 9 | checkEnumOptionValue[func_, optionToCheck_, validValues_, options_] := With[{ 10 | value = OptionValue[func, {options}, optionToCheck]}, 11 | If[!MemberQ[validValues, value], 12 | throw[Failure["invalidOptionChoice", <|"value" -> value, "option" -> optionToCheck, "choices" -> validValues|>]] 13 | ]; 14 | ]; 15 | 16 | declareMessage[General::optx, StringTemplate[General::optx]["`opt`", "`expr`"]]; 17 | checkIfKnownOptions[func_, options_, allowedOptions_ : Automatic] := With[{ 18 | unknownOptions = Complement @@ 19 | {Flatten[{options}][[All, 1]], If[allowedOptions === Automatic, Options[func][[All, 1]], allowedOptions]}}, 20 | If[Length[unknownOptions] > 0, throw[Failure["optx", <|"opt" -> unknownOptions[[1]]|>]]]; 21 | ]; 22 | -------------------------------------------------------------------------------- /Kernel/arrow.m: -------------------------------------------------------------------------------- 1 | Package["SetReplace`"] 2 | 3 | PackageImport["GeneralUtilities`"] 4 | 5 | PackageScope["arrow"] 6 | 7 | arrow[shape_, arrowheadLength_, vertexSize_][pts_] := ModuleScope[ 8 | ptsStartToArrowEnd = lineTake[pts, vertexSize ;; - vertexSize]; 9 | ptsStartToLineEnd = lineTake[ptsStartToArrowEnd, 0 ;; - arrowheadLength]; 10 | { 11 | Line[ptsStartToLineEnd], 12 | If[Length[ptsStartToArrowEnd] > 1 && arrowheadLength > 0, 13 | If[MatchQ[shape, Polygon[{{_ ? NumericQ, _ ? NumericQ}...}]], polygonArrowhead, arrowhead][ 14 | shape, 15 | Last[ptsStartToArrowEnd], 16 | Normalize[ptsStartToArrowEnd[[-1]] - ptsStartToLineEnd[[-1]]], 17 | arrowheadLength] 18 | , 19 | Nothing 20 | ] 21 | } 22 | ]; 23 | 24 | polygonArrowhead[shape_, endPt_, {0 | 0., 0 | 0.}, length_] := {}; 25 | 26 | polygonArrowhead[shape_, endPt_, direction_, length_] := With[{ 27 | rotationMatrix = RotationMatrix[{{1, 0}, direction}]}, 28 | Polygon[Transpose[rotationMatrix.Transpose[length shape[[1]]] + endPt]] 29 | ]; 30 | 31 | arrowhead[shape_, endPt_, {0 | 0., 0 | 0.}, length_] := {}; 32 | 33 | arrowhead[shape_, endPt_, direction_, length_] := 34 | (Translate[#, endPt] &) @ 35 | (Rotate[#, {{1, 0}, direction}] &) @ 36 | (Scale[#, length, {0, 0}] &) @ 37 | shape; 38 | 39 | lineTake[pts_, start_ ;; end_] := Reverse[lineDrop[Reverse[lineDrop[pts, start]], -end]]; 40 | 41 | lineDrop[pts_, length_] /; Length[pts] > 2 := With[{ 42 | firstSegmentLength = EuclideanDistance @@ pts[[{1, 2}]]}, 43 | If[firstSegmentLength <= length, 44 | lineDrop[Rest[pts], length - firstSegmentLength] 45 | , 46 | Join[lineDrop[pts[[{1, 2}]], length], Drop[pts, 2]] 47 | ] 48 | ]; 49 | 50 | lineDrop[{pt1_, pt2_}, length_] := {pt1 + Normalize[pt2 - pt1] * length, pt2}; 51 | 52 | lineDrop[pts : ({_} | {}), _] := pts; 53 | -------------------------------------------------------------------------------- /Kernel/convexHullPolygon.m: -------------------------------------------------------------------------------- 1 | Package["SetReplace`"] 2 | 3 | PackageImport["GeneralUtilities`"] 4 | 5 | PackageScope["convexHullPolygon"] 6 | 7 | (* Graham scan algorithm, https://en.wikipedia.org/wiki/Graham_scan *) 8 | 9 | polarAngle = ArcTan @@ # &; 10 | 11 | peekNextToTop[stack_] := With[{ 12 | top = stack["Pop"], 13 | nextToTop = stack["Peek"]}, 14 | stack["Push", top]; 15 | nextToTop 16 | ]; 17 | 18 | (* Returns a positive value for counterclockwise direction, negative for clockwise, and zero otherwise *) 19 | rotationDirection[pt1_, pt2_, pt3_] := 20 | (pt2[[1]] - pt1[[1]]) (pt3[[2]] - pt2[[2]]) - (pt2[[2]] - pt1[[2]]) (pt3[[1]] - pt2[[1]]); 21 | 22 | convexHullPolygon[points_] := ModuleScope[ 23 | (* Sort uses lexicographic rather than numeric ordering, so it might not work if the points are not numeric. *) 24 | numericPoints = N[points]; 25 | stack = CreateDataStructure["Stack"]; 26 | (* find a bottommost point, if multiple, find the leftmost one *) 27 | center = First[MinimalBy[MinimalBy[numericPoints, Last], First]]; 28 | centeredPoints = # - center & /@ DeleteCases[numericPoints, center, {1}]; 29 | counterClockwisePoints = SortBy[centeredPoints, polarAngle]; 30 | (* if there are multiple points with the same polar angle, pick the farthest *) 31 | deduplicatedPoints = Values[First /@ MaximalBy[Norm] /@ GroupBy[counterClockwisePoints, polarAngle]]; 32 | 33 | Scan[( 34 | (* pop the last point from the stack if we turn clockwise to reach this point *) 35 | While[stack["Length"] > 1 && rotationDirection[peekNextToTop[stack], stack["Peek"], #] <= 0, stack["Pop"]]; 36 | stack["Push", #] 37 | ) &, deduplicatedPoints]; 38 | 39 | Polygon[Join[{center}, # + center & /@ Normal[stack]]] 40 | ]; 41 | -------------------------------------------------------------------------------- /Kernel/globals.m: -------------------------------------------------------------------------------- 1 | Package["SetReplace`"] 2 | 3 | PackageImport["GeneralUtilities`"] 4 | 5 | (* Note: this is actually set in Kernel/init.m, but it needs to be exported from a new-style package so that 6 | the new-style package loader understands that this is a global symbol *) 7 | PackageExport["$SetReplaceRootDirectory"] 8 | 9 | SetUsage @ " 10 | $SetReplaceRootDirectory contains the path of the root of the SetReplace package that was loaded. \ 11 | This corresponds to the directory that containts the Kernel/ directory. 12 | "; 13 | -------------------------------------------------------------------------------- /Kernel/init.m: -------------------------------------------------------------------------------- 1 | Unprotect["SetReplace`*"]; 2 | 3 | (* this is a no-op the first time round, subsequent loads will unload the C++ library first *) 4 | SetReplace`PackageScope`unloadLibrary[]; 5 | 6 | ClearAll @@ (# <> "*" & /@ Contexts["SetReplace`*"]); 7 | 8 | (* Make sure that we don't affect $ContextPath by getting GU, and that we are isolated from 9 | any user contexts *) 10 | BeginPackage["SetReplace`"]; 11 | 12 | (* This is useful for various purposes, like loading libraries from the 'same place' as the 13 | paclet, and also knowing *where* the loaded code even came from. *) 14 | $SetReplaceRootDirectory = FileNameDrop[$InputFileName, -2]; 15 | 16 | Needs["GeneralUtilities`"]; 17 | 18 | (* ensure private symbols we use below don't show up on Global, etc *) 19 | Begin["SetReplace`Private`"]; 20 | 21 | Block[ 22 | (* Temporarily overrule some of the more exotic features of the macro system. 23 | TODO: Fix this upstream when GU is open sourced. *) 24 | {GeneralUtilities`Control`PackagePrivate`$DesugaringRules = { 25 | HoldPattern[$Unreachable] :> Unreachable[$LHSHead], 26 | HoldPattern[ReturnFailed[msg_String, args___]] :> ReturnFailed[MessageName[$LHSHead, msg], args], 27 | HoldPattern[ReturnFailure[msg_String, args___]] :> ReturnFailure[MessageName[$LHSHead, msg], args] 28 | }}, 29 | (* All files are loaded lexicographically starting with A0*. Note, "$" comes after "A" in Wolfram Language. 30 | File names starting with digits are not allowed. "_" and "-" are not allowed. *) 31 | Get[First[FileNames["*", FileNameJoin[{$SetReplaceRootDirectory, "Kernel"}]]]]; 32 | 33 | (* Type system and generators should be initialized after all Kernel files are loaded. *) 34 | SetReplace`PackageScope`initializeTypeSystem[]; 35 | SetReplace`PackageScope`initializeSystemGenerators[]; 36 | ]; 37 | 38 | End[]; 39 | 40 | EndPackage[]; 41 | 42 | SetAttributes[#, {Protected, ReadProtected}] & /@ Evaluate @ Names @ "SetReplace`*"; 43 | -------------------------------------------------------------------------------- /Kernel/systemGenerators.m: -------------------------------------------------------------------------------- 1 | Package["SetReplace`"] 2 | 3 | PackageImport["GeneralUtilities`"] 4 | 5 | PackageExport["GenerateMultihistory"] 6 | PackageExport["GenerateSingleHistory"] 7 | 8 | PackageScope["generateMultihistory"] 9 | PackageScope["generateSingleHistory"] 10 | 11 | declareSystemGenerator[ 12 | GenerateMultihistory, 13 | generateMultihistory, 14 | <||>, 15 | Identity, 16 | "yields a Multihistory object of the evaluation of a specified system$ starting from an initial state init$."]; 17 | 18 | declareSystemGenerator[ 19 | GenerateSingleHistory, 20 | generateSingleHistory, 21 | <|MaxDestroyerEvents -> 1|>, 22 | Identity, 23 | "yields a single history of the evaluation of a specified system$ starting from an initial state init$."]; 24 | -------------------------------------------------------------------------------- /Kernel/systemParameters.m: -------------------------------------------------------------------------------- 1 | Package["SetReplace`"] 2 | 3 | (* Event-selection parameters *) 4 | 5 | PackageExport["MaxGeneration"] 6 | PackageExport["MaxDestroyerEvents"] 7 | PackageExport["MinEventInputs"] 8 | PackageExport["MaxEventInputs"] 9 | PackageExport["MaxEvents"] 10 | 11 | declareSystemParameter[#, #2, _ ? (GreaterEqualThan[0]), #3] & @@@ { 12 | {MaxGeneration, 13 | Infinity, 14 | "is an event-selection parameter specifying the maximum generation of created tokens.\n" <> 15 | "* Tokens in init$ are assumed to have generation 0.\n" <> 16 | "* A generation of an event and its output tokens is defined as the largest generation of its inputs plus one."}, 17 | {MaxDestroyerEvents, 18 | Infinity, 19 | "is an event-selection parameter specifying the number of events that can use a single token as their input.\n" <> 20 | "* Setting this to 1 limits evaluation to a single history."}, 21 | {MinEventInputs, 0, "is an event-selection parameter specifying the minimum number of input tokens of events."}, 22 | {MaxEventInputs, Infinity, "is an event-selection parameter specifying the maximum number of input tokens of events."} 23 | }; 24 | 25 | (* Stopping-condition parameters *) 26 | 27 | declareSystemParameter[ 28 | MaxEvents, 29 | Infinity, 30 | _ ? (GreaterEqualThan[0]), 31 | "is a stopping-condition parameter that stops evaluation after a specified number of events."]; 32 | -------------------------------------------------------------------------------- /Kernel/testUtilities.m: -------------------------------------------------------------------------------- 1 | Package["SetReplace`"] 2 | 3 | PackageImport["GeneralUtilities`"] 4 | 5 | PackageScope["testUnevaluated"] 6 | PackageScope["testSymbolLeak"] 7 | PackageScope["checkGraphics"] 8 | PackageScope["graphicsQ"] 9 | 10 | (* VerificationTest should not directly appear here, as it is replaced by test.wls into other heads during evaluation. 11 | Use testHead argument instead. *) 12 | 13 | (* It is necessary to compare strings because, i.e., 14 | MatchQ[<|x -> 1|>, HoldPattern[<|x -> 1|>]] returns False. *) 15 | Attributes[testUnevaluated] = {HoldAll}; 16 | testUnevaluated[testHead_, input_, messages_, opts___] := 17 | testHead[ 18 | ToString[FullForm[input]], 19 | StringReplace[ToString[FullForm[Hold[input]]], StartOfString ~~ "Hold[" ~~ expr___ ~~ "]" ~~ EndOfString :> expr], 20 | messages, 21 | opts]; 22 | 23 | Attributes[testSymbolLeak] = {HoldAll}; 24 | testSymbolLeak[testHead_, expr_, opts___] := 25 | testHead[ 26 | Module[{Global`before, Global`after}, 27 | expr; (* symbols might get created at the first run due to initialization *) 28 | Global`before = Length[Names["*`*"]]; 29 | expr; 30 | Global`after = Length[Names["*`*"]]; 31 | Global`after - Global`before 32 | ], 33 | 0, 34 | opts 35 | ]; 36 | 37 | (* UsingFrontEnd is necessary while running from wolframscript *) 38 | (* Flashes a new frontend window momentarily, but that is ok, because this function is mostly for use in the CI *) 39 | frontEndErrors[expr_] := UsingFrontEnd @ Module[{notebook, result}, 40 | notebook = CreateDocument[ExpressionCell[expr]]; 41 | SelectionMove[notebook, All, Notebook]; 42 | result = MathLink`CallFrontEnd[FrontEnd`GetErrorsInSelectionPacket[notebook]]; 43 | NotebookClose[notebook]; 44 | result 45 | ]; 46 | 47 | checkGraphics::frontEndErrors := "``"; 48 | 49 | checkGraphics[graphics_] := ( 50 | Message[checkGraphics::frontEndErrors, #] & /@ Flatten[frontEndErrors[graphics]]; 51 | graphics 52 | ); 53 | 54 | graphicsQ[graphics_] := Head[graphics] === Graphics && frontEndErrors[graphics] === {}; 55 | -------------------------------------------------------------------------------- /Kernel/toCanonicalRules.m: -------------------------------------------------------------------------------- 1 | Package["SetReplace`"] 2 | 3 | PackageScope["toCanonicalRules"] 4 | 5 | (* Rules can be specified in various ways, in particular, a single rule instead of a list, with or without a Module, 6 | etc. This function is needed to canonicalize that so that the rules are easy to parse: 7 | 1. Rules should always be specified as a list of rules instead of a single rule. 8 | 2. RuleDelayed should be used instead of Rule. 9 | 3. Condition should be used on the left-hand side ({atom1, atom2, ...} /; condition) even if condition === True. 10 | 4. Module should be used on the right-hand side of the rule, even with the empty first argument. 11 | 5. Left- and right-hand sides of the rules should explicitly be lists, even if sets only have one element. *) 12 | 13 | (* If there is a single rule, we put it in a list *) 14 | 15 | toCanonicalRules[rules_List] := toCanonicalRule /@ (rules /. Condition -> inertCondition); 16 | 17 | toCanonicalRules[rule : Except[_List]] := toCanonicalRules[{rule}]; 18 | 19 | (* Force RuleDelayed *) 20 | 21 | toCanonicalRule[input_ -> output_] := toCanonicalRule[input :> output]; 22 | 23 | (* Force Condition *) 24 | 25 | toCanonicalRule[input : Except[_inertCondition] :> output_] := toCanonicalRule[inertCondition[input, True] :> output]; 26 | 27 | (* Force Module *) 28 | 29 | toCanonicalRule[input_ :> output : Except[_Module]] := toCanonicalRule[input :> Module[{}, output]]; 30 | 31 | (* If input or output are not lists, we assume it is a single element set, so we put it into a single element list *) 32 | 33 | SetAttributes[inertCondition, HoldRest]; 34 | 35 | toCanonicalRule[inertCondition[inputExprs : Except[_List], condition_] :> output_] := 36 | toCanonicalRule[inertCondition[{inputExprs}, condition] :> output]; 37 | 38 | toCanonicalRule[input_ :> Module[newAtoms_List, outputExprs : Except[_List]]] := 39 | toCanonicalRule[input :> Module[newAtoms, {outputExprs}]]; 40 | 41 | (* After all of that's done, drop toCanonicalRule *) 42 | 43 | toCanonicalRule[rule : (inertCondition[inputExprs_List, condition_] :> Module[newAtoms_List, outputExprs_List])] := 44 | rule /. inertCondition -> Condition; 45 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Maksim Piskunov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /PacletInfo.m: -------------------------------------------------------------------------------- 1 | (* ::Package:: *) 2 | 3 | Paclet[ 4 | Name -> "SetReplace", 5 | Version -> "0.3", 6 | MathematicaVersion -> "12.3+", 7 | Description -> "SetReplace implements WolframModel and other functions used in the Wolfram Physics Project.", 8 | Creator -> "Wolfram Research", 9 | URL -> "https://github.com/maxitg/SetReplace", 10 | SystemID -> {"MacOSX-x86-64", "Linux-x86-64", "Windows-x86-64", "MacOSX-ARM64"}, 11 | Extensions -> { 12 | {"Kernel", Context -> "SetReplace`"}, 13 | {"LibraryLink"} 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /Research/ConfluenceAndCausalInvariance/Images/CausalInvariantCausalGraphs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/ConfluenceAndCausalInvariance/Images/CausalInvariantCausalGraphs.png -------------------------------------------------------------------------------- /Research/ConfluenceAndCausalInvariance/Images/CausalInvariantEvolutions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/ConfluenceAndCausalInvariance/Images/CausalInvariantEvolutions.png -------------------------------------------------------------------------------- /Research/ConfluenceAndCausalInvariance/Images/CausalInvariantMultiwaySystem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/ConfluenceAndCausalInvariance/Images/CausalInvariantMultiwaySystem.png -------------------------------------------------------------------------------- /Research/ConfluenceAndCausalInvariance/Images/CausalInvariantStatesGraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/ConfluenceAndCausalInvariance/Images/CausalInvariantStatesGraph.png -------------------------------------------------------------------------------- /Research/ConfluenceAndCausalInvariance/Images/ConfluentCausalGraphs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/ConfluenceAndCausalInvariance/Images/ConfluentCausalGraphs.png -------------------------------------------------------------------------------- /Research/ConfluenceAndCausalInvariance/Images/ConfluentStatesGraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/ConfluenceAndCausalInvariance/Images/ConfluentStatesGraph.png -------------------------------------------------------------------------------- /Research/ConfluenceAndCausalInvariance/Images/LargeCausalInvariantEvolution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/ConfluenceAndCausalInvariance/Images/LargeCausalInvariantEvolution.png -------------------------------------------------------------------------------- /Research/ConfluenceAndCausalInvariance/Images/LargeConfluentEvolution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/ConfluenceAndCausalInvariance/Images/LargeConfluentEvolution.png -------------------------------------------------------------------------------- /Research/LocalMultiwaySystem/Images/BasicGlobalMultiway.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/LocalMultiwaySystem/Images/BasicGlobalMultiway.png -------------------------------------------------------------------------------- /Research/LocalMultiwaySystem/Images/BranchingGlobalMultiway.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/LocalMultiwaySystem/Images/BranchingGlobalMultiway.png -------------------------------------------------------------------------------- /Research/LocalMultiwaySystem/Images/GlobalMultiwayEventSeparation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/LocalMultiwaySystem/Images/GlobalMultiwayEventSeparation.png -------------------------------------------------------------------------------- /Research/LocalMultiwaySystem/Images/GlobalMultiwayIsomorphism.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/LocalMultiwaySystem/Images/GlobalMultiwayIsomorphism.png -------------------------------------------------------------------------------- /Research/LocalMultiwaySystem/Images/GlobalMultiwayParticle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/LocalMultiwaySystem/Images/GlobalMultiwayParticle.png -------------------------------------------------------------------------------- /Research/LocalMultiwaySystem/Images/IsomorphicBranching.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/LocalMultiwaySystem/Images/IsomorphicBranching.png -------------------------------------------------------------------------------- /Research/LocalMultiwaySystem/Images/LocalMultiwayEventSeparation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/LocalMultiwaySystem/Images/LocalMultiwayEventSeparation.png -------------------------------------------------------------------------------- /Research/LocalMultiwaySystem/Images/LocalMultiwayIsomorphism.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/LocalMultiwaySystem/Images/LocalMultiwayIsomorphism.png -------------------------------------------------------------------------------- /Research/LocalMultiwaySystem/Images/LocalMultiwayNoIsomorphism.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/LocalMultiwaySystem/Images/LocalMultiwayNoIsomorphism.png -------------------------------------------------------------------------------- /Research/LocalMultiwaySystem/Images/LocalMultiwayParticle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/LocalMultiwaySystem/Images/LocalMultiwayParticle.png -------------------------------------------------------------------------------- /Research/LocalMultiwaySystem/Images/LocalMultiwayParticleInit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/LocalMultiwaySystem/Images/LocalMultiwayParticleInit.png -------------------------------------------------------------------------------- /Research/LocalMultiwaySystem/Images/LocalMultiwayParticleSpringElectrical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/LocalMultiwaySystem/Images/LocalMultiwayParticleSpringElectrical.png -------------------------------------------------------------------------------- /Research/LocalMultiwaySystem/Images/MatchAllBranchlikeMatching.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/LocalMultiwaySystem/Images/MatchAllBranchlikeMatching.png -------------------------------------------------------------------------------- /Research/LocalMultiwaySystem/Images/MatchAllQuantumSpacelikeMatching.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/LocalMultiwaySystem/Images/MatchAllQuantumSpacelikeMatching.png -------------------------------------------------------------------------------- /Research/LocalMultiwaySystem/Images/MatchAllRepeatingMatching.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/LocalMultiwaySystem/Images/MatchAllRepeatingMatching.png -------------------------------------------------------------------------------- /Research/LocalMultiwaySystem/Images/MatchAllSpacelikeBranchlikeMixed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/LocalMultiwaySystem/Images/MatchAllSpacelikeBranchlikeMixed.png -------------------------------------------------------------------------------- /Research/LocalMultiwaySystem/Images/MatchAllTimelikeMatching.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/LocalMultiwaySystem/Images/MatchAllTimelikeMatching.png -------------------------------------------------------------------------------- /Research/LocalMultiwaySystem/Images/SeparationComparison.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/LocalMultiwaySystem/Images/SeparationComparison.png -------------------------------------------------------------------------------- /Research/LocalMultiwaySystem/Images/WanderingParticleRule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxitg/SetReplace/44c868bf4622e4542b306846ffdcc47c19d0bba8/Research/LocalMultiwaySystem/Images/WanderingParticleRule.png -------------------------------------------------------------------------------- /SetReplace.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SetReplace.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /SetReplace.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Tests/AtomicStateSystem.wlt: -------------------------------------------------------------------------------- 1 | <| 2 | "AtomicStateSystem" -> <| 3 | "init" -> ( 4 | Attributes[Global`testUnevaluated] = Attributes[Global`testSymbolLeak] = {HoldAll}; 5 | Global`testUnevaluated[args___] := SetReplace`PackageScope`testUnevaluated[VerificationTest, args]; 6 | Global`testSymbolLeak[args___] := SetReplace`PackageScope`testSymbolLeak[VerificationTest, args]; 7 | 8 | (* This will not be necessary once we have properties. *) 9 | allExpressions[Multihistory[_, data_]] := Normal @ data["MultisetMultihistory"][[2]]["Expressions"]; 10 | ), 11 | "tests" -> { 12 | (* Symbol Leak *) 13 | testSymbolLeak[GenerateMultihistory[AtomicStateSystem[a_ :> a + 1], MaxEvents -> 5][0]], 14 | 15 | (* Rules *) 16 | testUnevaluated[GenerateMultihistory[AtomicStateSystem[##2]][1], {#}] & @@@ { 17 | {AtomicStateSystem::argx}, 18 | {AtomicStateSystem::argx, 1, 2}, 19 | {GenerateMultihistory::invalidAtomicStateRules, 1}}, 20 | 21 | (* Parameters *) 22 | testUnevaluated[GenerateMultihistory[AtomicStateSystem[1 -> 2], MaxGeneration -> -1][1], 23 | {GenerateMultihistory::invalidParameter}], 24 | 25 | Function[{rules, parameters, init, expectedCreatedExpressions}, 26 | VerificationTest[allExpressions @ GenerateMultihistory[AtomicStateSystem[rules], parameters] @ init, 27 | Join[{init}, expectedCreatedExpressions], 28 | SameTest -> MatchQ]] @@@ { 29 | {1 -> 1, MaxEvents -> 1, 1, {1}}, 30 | {1 -> 2, MaxEvents -> 1, 1, {2}}, 31 | {1 -> 2, MaxGeneration -> 1, 1, {2}}, 32 | {2 :> 5, MaxGeneration -> 1, 2, {5}}, 33 | {{2 -> 5, 2 :> 6}, MaxGeneration -> 1, 2, {5, 6}}, 34 | {{2 :> 3, 3 :> 4}, MaxGeneration -> 2, 2, {3, 4}}, 35 | {x_ :> x + 1, MaxGeneration -> 2, 2, {3, 4}}, 36 | {{x_ :> x - 1, x_ :> x + 1}, MaxGeneration -> 2, 0, {-1, 1, -2, 0, 0, 2}}, 37 | {{x_ ? EvenQ :> x - 1, x_ ? OddQ :> x + 1}, MaxGeneration -> 2, 0, {-1, 0}}, 38 | (* only valid patterns should be matched *) 39 | {x_String :> x <> "x", MaxEvents -> 2, 0, {}}}, 40 | 41 | VerificationTest[allExpressions @ GenerateMultihistory[AtomicStateSystem[{1 -> 3, 2 -> 3, 0 -> 1, 0 -> 2}]][0], 42 | {0, 1, 2, 3, 3}] 43 | } 44 | |> 45 | |> 46 | -------------------------------------------------------------------------------- /Tests/IndexHypergraph.wlt: -------------------------------------------------------------------------------- 1 | <| 2 | "IndexHypergraph" -> <| 3 | "init" -> ( 4 | Attributes[Global`testUnevaluated] = {HoldAll}; 5 | Global`testUnevaluated[args___] := SetReplace`PackageScope`testUnevaluated[VerificationTest, args]; 6 | ), 7 | "tests" -> { 8 | 9 | VerificationTest[ 10 | IndexHypergraph[{}], 11 | {} 12 | ], 13 | 14 | VerificationTest[ 15 | IndexHypergraph[{{}}], 16 | {{}} 17 | ], 18 | 19 | VerificationTest[ 20 | IndexHypergraph[{{{1}}}], 21 | {{1}} 22 | ], 23 | 24 | VerificationTest[ 25 | IndexHypergraph[{Range[5]}, -10], 26 | {{-10, -9, -8, -7, -6}} 27 | ], 28 | 29 | VerificationTest[ 30 | IndexHypergraph[{{x, y, z}, {y, z}, {y, y, x, z}}, 2], 31 | {{2, 3, 4}, {3, 4}, {3, 3, 2, 4}} 32 | ], 33 | 34 | VerificationTest[ 35 | IndexHypergraph[{Range[10, 6, -1], Range[-5, -1]}], 36 | {{10, 9, 8, 7, 6}, {1, 2, 3, 4, 5}} 37 | ], 38 | 39 | (* unevaluated *) 40 | 41 | (** argument count **) 42 | testUnevaluated[ 43 | IndexHypergraph[], 44 | {IndexHypergraph::argt} 45 | ], 46 | 47 | testUnevaluated[ 48 | IndexHypergraph[{{x, y, z}, {y, z}}, 2, 3], 49 | {IndexHypergraph::argt} 50 | ], 51 | 52 | (** first argument **) 53 | testUnevaluated[ 54 | IndexHypergraph[{x, y, {z}}], 55 | {IndexHypergraph::invalidHypergraph} 56 | ], 57 | 58 | testUnevaluated[ 59 | IndexHypergraph[{x, y, {z}}, 2], 60 | {IndexHypergraph::invalidHypergraph} 61 | ], 62 | 63 | (** second argument **) 64 | testUnevaluated[ 65 | IndexHypergraph[{{x, y, z}, {y, z, y}}, x], 66 | {IndexHypergraph::int} 67 | ] 68 | } 69 | |> 70 | |> 71 | -------------------------------------------------------------------------------- /Tests/IsomorphicHypergraphQ.wlt: -------------------------------------------------------------------------------- 1 | <| 2 | "IsomorphicHypergraphQ" -> <| 3 | "init" -> ( 4 | Attributes[Global`testUnevaluated] = {HoldAll}; 5 | Global`testUnevaluated[args___] := 6 | SetReplace`PackageScope`testUnevaluated[VerificationTest, args]; 7 | ), 8 | "tests" -> { 9 | 10 | (* unevaluated *) 11 | 12 | (** argument count **) 13 | testUnevaluated[ 14 | IsomorphicHypergraphQ[], 15 | {IsomorphicHypergraphQ::argrx} 16 | ], 17 | 18 | testUnevaluated[ 19 | IsomorphicHypergraphQ[{{1}}], 20 | {IsomorphicHypergraphQ::argr} 21 | ], 22 | 23 | testUnevaluated[ 24 | IsomorphicHypergraphQ[{{1}}, {{1}}, {{2}}], 25 | {IsomorphicHypergraphQ::argrx} 26 | ], 27 | 28 | (** invalid hypergraph **) 29 | testUnevaluated[ 30 | IsomorphicHypergraphQ[{1}, {{1}}], 31 | {IsomorphicHypergraphQ::invalidHypergraph} 32 | ], 33 | 34 | testUnevaluated[ 35 | IsomorphicHypergraphQ[{{1}}, {1}], 36 | {IsomorphicHypergraphQ::invalidHypergraph} 37 | ], 38 | 39 | (* eval *) 40 | VerificationTest[ 41 | IsomorphicHypergraphQ[{}, {}], 42 | True 43 | ], 44 | 45 | VerificationTest[ 46 | IsomorphicHypergraphQ[{}, {{}}], 47 | False 48 | ], 49 | 50 | VerificationTest[ 51 | IsomorphicHypergraphQ[{{}}, {{}}], 52 | True 53 | ], 54 | 55 | VerificationTest[ 56 | IsomorphicHypergraphQ[{{{{1}}}}, {{x}}], 57 | True 58 | ], 59 | 60 | VerificationTest[ 61 | IsomorphicHypergraphQ[{{1, 2}}, {{x, y}}], 62 | True 63 | ], 64 | 65 | VerificationTest[ 66 | IsomorphicHypergraphQ[ 67 | {{a, e, d}, {d, c}, {c, b}, {b, a}}, 68 | {{2, 4}, {4, 5, 1}, {1, 3}, {3, 2}}], 69 | True 70 | ], 71 | 72 | VerificationTest[ 73 | IsomorphicHypergraphQ[ 74 | {{a, e, d}, {d, c}, {c, b}, {b, a}}, 75 | {{2, 4}, {4, 3, 1}, {1, 3}, {5, 2}}], 76 | False 77 | ], 78 | 79 | VerificationTest[ 80 | IsomorphicHypergraphQ[ 81 | {{1, 2}, {2, 3}, {3, 4}, {4, 5}}, 82 | {{1, 2}, {2, 3}, {3, 4}, {1, 5}}], 83 | False 84 | ], 85 | 86 | VerificationTest[ 87 | IsomorphicHypergraphQ[ 88 | {{}, {x, x, y, z}, {z, w}}, 89 | {{}, {{x}, {x}, 2, 3}, {3, 4}}], 90 | True 91 | ] 92 | } 93 | |> 94 | |> 95 | -------------------------------------------------------------------------------- /Tests/Multihistory.wlt: -------------------------------------------------------------------------------- 1 | <| 2 | "Multihistory" -> <| 3 | "init" -> ( 4 | Attributes[Global`testUnevaluated] = {HoldAll}; 5 | Global`testUnevaluated[args___] := SetReplace`PackageScope`testUnevaluated[VerificationTest, args]; 6 | ), 7 | "tests" -> { 8 | (* Multihistory should never evaluate *) 9 | testUnevaluated[Multihistory["type", <||>], {}], 10 | testUnevaluated[Multihistory["type"], Multihistory::invalid], 11 | testUnevaluated[Multihistory["type", <||>, 4], Multihistory::invalid], 12 | 13 | VerificationTest[SetReplace`PackageScope`objectType[Multihistory["someType", <||>]], "someType"] 14 | } 15 | |> 16 | |> 17 | -------------------------------------------------------------------------------- /Tests/MultisetToWolframModelEvolutionObject.wlt: -------------------------------------------------------------------------------- 1 | <| 2 | "Multiset -> WolframModelEvolutionObject" -> <| 3 | "init" -> ( 4 | Attributes[Global`testUnevaluated] = Attributes[Global`testSymbolLeak] = {HoldAll}; 5 | Global`testUnevaluated[args___] := SetReplace`PackageScope`testUnevaluated[VerificationTest, args]; 6 | Global`testSymbolLeak[args___] := SetReplace`PackageScope`testSymbolLeak[VerificationTest, args]; 7 | ), 8 | "tests" -> { 9 | VerificationTest[ 10 | (VertexCount @ #["ExpressionsEventsGraph"] &) @ 11 | SetReplaceTypeConvert[WolframModelEvolutionObject] @ 12 | GenerateMultihistory[MultisetSubstitutionSystem[{a_, b_} :> {a + b}], MaxGeneration -> 1] @ {1, 2, 3}, 13 | 15], 14 | 15 | VerificationTest[ 16 | (#["EventsCount"] &) @ 17 | SetReplaceTypeConvert[WolframModelEvolutionObject] @ 18 | GenerateMultihistory[MultisetSubstitutionSystem[{a_, b_} :> {a + b}], MaxEvents -> 10] @ {1, 2, 3}, 19 | 10] 20 | } 21 | |> 22 | |> 23 | -------------------------------------------------------------------------------- /Tests/buildData.wlt: -------------------------------------------------------------------------------- 1 | <| 2 | "$SetReplaceRootDirectory" -> <| 3 | "tests" -> { 4 | VerificationTest[ 5 | FileExistsQ @ $SetReplaceRootDirectory 6 | ] 7 | } 8 | |>, 9 | 10 | "$SetReplaceGitSHA" -> <| 11 | "tests" -> { 12 | VerificationTest[ 13 | StringMatchQ[$SetReplaceGitSHA, Repeated[HexadecimalCharacter, 40] ~~ Repeated["*", {0, 1}]] 14 | ] 15 | } 16 | |>, 17 | 18 | "$SetReplaceBuildTime" -> <| 19 | "tests" -> { 20 | VerificationTest[ 21 | DateObjectQ @ $SetReplaceBuildTime 22 | ], 23 | 24 | VerificationTest[ 25 | $SetReplaceBuildTime["TimeZone"], 26 | "UTC" 27 | ], 28 | 29 | (* could not be built in the future *) 30 | VerificationTest[ 31 | $SetReplaceBuildTime < Now 32 | ], 33 | 34 | (* could not be built before $SetReplaceBuildTime was implemented *) 35 | VerificationTest[ 36 | DateObject[{2020, 3, 17, 0, 0, 0}, TimeZone -> "UTC"] < $SetReplaceBuildTime 37 | ] 38 | } 39 | |>, 40 | 41 | "$SetReplaceLibraryPath" -> <| 42 | "tests" -> { 43 | VerificationTest[ 44 | StringQ @ $SetReplaceLibraryPath 45 | ], 46 | 47 | VerificationTest[ 48 | FileExistsQ @ $SetReplaceLibraryPath 49 | ] 50 | } 51 | |>, 52 | 53 | "$SetReplaceLibraryBuildTime" -> <| 54 | "tests" -> { 55 | VerificationTest[ 56 | DateObjectQ @ $SetReplaceLibraryBuildTime 57 | ], 58 | 59 | VerificationTest[ 60 | $SetReplaceLibraryBuildTime["TimeZone"], 61 | "UTC" 62 | ], 63 | 64 | (* could not be built in the future *) 65 | VerificationTest[ 66 | $SetReplaceLibraryBuildTime < Now 67 | ], 68 | 69 | (* could not be built before $SetReplaceLibraryBuildTime was implemented *) 70 | VerificationTest[ 71 | DateObject[{2020, 11, 22, 0, 0, 0}, TimeZone -> "UTC"] < $SetReplaceLibraryBuildTime 72 | ] 73 | } 74 | |> 75 | |> 76 | -------------------------------------------------------------------------------- /Tests/lowLevelEvolution.wlt: -------------------------------------------------------------------------------- 1 | <| 2 | (* These are tests specific to Method -> "LowLevel" option of WolframModel (libSetReplace). 3 | Other test groups (like globalSpacelikeEvolution and matching) should be used to test libSetReplace as well. *) 4 | "lowLevelEvolution" -> <| 5 | "init" -> ( 6 | Attributes[Global`testUnevaluated] = {HoldAll}; 7 | Global`testUnevaluated[args___] := SetReplace`PackageScope`testUnevaluated[VerificationTest, args]; 8 | ), 9 | "tests" -> { 10 | (** Relatively large prime number of rules to verify all rules are allocated to threads when matching. **) 11 | VerificationTest[ 12 | WolframModel[ 13 | Array[{Range[1, #1]} -> {} &, 59], 14 | Array[Range[1, #1] &, 59], 15 | "FinalState"], 16 | {}, 17 | SameTest -> SameQ 18 | ] 19 | } 20 | |> 21 | |> 22 | -------------------------------------------------------------------------------- /Tests/meta.wlt: -------------------------------------------------------------------------------- 1 | <| 2 | "meta" -> <| 3 | "init" -> ( 4 | $testsDirectory = If[$TestFileName =!= "", 5 | FileNameJoin[Most @ FileNameSplit @ $TestFileName] 6 | , 7 | FileNameJoin[Append[Most[FileNameSplit[$ScriptCommandLine[[1]]]], "Tests"]] 8 | ]; 9 | ), 10 | "tests" -> { 11 | exports = Lookup[Package`PackageInformation["SetReplace`"], "PackageExports"]; 12 | 13 | (* All public symbols have usage message *) 14 | 15 | hasNoSymbolUsageQ = Function[symbol, 16 | Not @ StringQ @ MessageName[symbol, "usage"], HoldFirst]; 17 | VerificationTest[ 18 | Select[exports, hasNoSymbolUsageQ], 19 | HoldComplete[] 20 | ], 21 | 22 | (* All public symbols have syntax information *) 23 | (* Additionally, SyntaxInformation should specify "OptionNames" if the symbol has Options. *) 24 | 25 | hasSyntaxInformationQ = Function[ 26 | symbol, 27 | Or[ 28 | StringStartsQ[SymbolName @ Unevaluated @ symbol, "$"], 29 | And[ 30 | SyntaxInformation[Unevaluated @ symbol] =!= {}, 31 | Implies[ 32 | Options[Unevaluated @ symbol] =!= {}, 33 | ListQ[Lookup[SyntaxInformation[Unevaluated @ symbol], "OptionNames"]]]]], 34 | HoldFirst]; 35 | VerificationTest[ 36 | Complement[exports, Select[exports, hasSyntaxInformationQ]], 37 | HoldComplete[] 38 | ], 39 | 40 | (* Test coverage: all public symbols appear in unit tests *) 41 | allTestsCode = StringJoin[FileString /@ FileNames["*.wlt", $testsDirectory]]; 42 | doesNotAppearInTestsQ = Function[symbol, 43 | !StringContainsQ[allTestsCode, SymbolName @ Unevaluated @ symbol], 44 | HoldFirst]; 45 | VerificationTest[ 46 | Select[exports, doesNotAppearInTestsQ], 47 | HoldComplete[] 48 | ] 49 | }, 50 | "options" -> { 51 | "Parallel" -> False 52 | } 53 | |> 54 | |> 55 | -------------------------------------------------------------------------------- /build.wls: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env wolframscript 2 | 3 | Check[ 4 | Get[FileNameJoin[{DirectoryName[$InputFileName], "DevUtils", "init.m"}]]; 5 | Off[General::stop]; 6 | , 7 | Print["Message occurred during loading of DevUtils. Build failed."]; 8 | Exit[1]; 9 | ]; 10 | 11 | Check[ 12 | result = BuildLibSetReplace["Verbose" -> True]; 13 | If[!AssociationQ[result], Exit[1]]; 14 | , 15 | Print["Message occurred during building. Build failed."]; 16 | Exit[1]; 17 | ]; 18 | 19 | Print["Build succeeded."]; 20 | Exit[0]; 21 | -------------------------------------------------------------------------------- /cmake/SetReplaceConfig.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include(CMakeFindDependencyMacro) 4 | 5 | get_filename_component(SET_REPLACE_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) 6 | if(NOT TARGET SetReplace) 7 | include ("${SET_REPLACE_CMAKE_DIR}/SetReplaceTargets.cmake") 8 | endif() 9 | -------------------------------------------------------------------------------- /install.wls: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env wolframscript 2 | 3 | Check[ 4 | Get[FileNameJoin[{DirectoryName[$InputFileName], "DevUtils", "init.m"}]]; 5 | Off[General::stop]; 6 | , 7 | Print["Message occurred during loading of DevUtils. Build failed."]; 8 | Exit[1]; 9 | ]; 10 | 11 | Check[ 12 | InstallGitLink[]; 13 | 14 | buildResult = BuildLibSetReplace["Verbose" -> True]; 15 | If[!AssociationQ[buildResult], Exit[1]]; 16 | 17 | packResult = PackSetReplace["Verbose" -> True]; 18 | pacletLocation = packResult["Location"]; 19 | If[!StringQ[pacletLocation], Exit[1]]; 20 | 21 | previousPaclets = PacletFind["SetReplace"]; 22 | If[previousPaclets =!= {}, 23 | Print["Uninstalling previous SetReplace at ", First[previousPaclets]["Location"]]; 24 | If[FailureQ[PacletUninstall["SetReplace"]], 25 | Print["Could not uninstall old paclet."]; 26 | Exit[1]; 27 | ]; 28 | ]; 29 | 30 | Print["Installing paclet at ", pacletLocation]; 31 | installedPaclet = PacletInstall[pacletLocation]; 32 | If[FailureQ[installedPaclet], 33 | Print["Could not install new paclet."]; 34 | Exit[1]; 35 | ]; 36 | 37 | Print["Paclet installed to ", installedPaclet["Location"]]; 38 | , 39 | Print["Message occurred during installing. Install failed."]; 40 | Exit[1]; 41 | ]; 42 | 43 | Print["Install succeeded."]; 44 | Exit[0]; 45 | -------------------------------------------------------------------------------- /libSetReplace/AtomsIndex.cpp: -------------------------------------------------------------------------------- 1 | #include "AtomsIndex.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace SetReplace { 11 | class AtomsIndex::Implementation { 12 | private: 13 | const GetAtomsVectorFunc getAtomsVector_; 14 | std::unordered_map> index_; 15 | 16 | public: 17 | explicit Implementation(GetAtomsVectorFunc getAtomsVector) : getAtomsVector_(std::move(getAtomsVector)) {} 18 | 19 | void removeTokens(const std::vector& tokenIDs) { 20 | const std::unordered_set tokensToDelete(tokenIDs.begin(), tokenIDs.end()); 21 | 22 | std::unordered_set involvedAtoms; 23 | for (const auto& token : tokenIDs) { 24 | const auto& atomsVector = getAtomsVector_(token); 25 | involvedAtoms.insert(atomsVector.begin(), atomsVector.end()); 26 | } 27 | 28 | for (const auto& atom : involvedAtoms) { 29 | auto& atomTokenSet = index_[atom]; 30 | auto atomTokenIterator = atomTokenSet.begin(); 31 | const auto atomTokenSetEnd = atomTokenSet.cend(); 32 | while (atomTokenIterator != atomTokenSetEnd) { 33 | if (tokensToDelete.count(*atomTokenIterator)) { 34 | atomTokenIterator = atomTokenSet.erase(atomTokenIterator); 35 | } else { 36 | ++atomTokenIterator; 37 | } 38 | } 39 | if (atomTokenSet.empty()) { 40 | index_.erase(atom); 41 | } 42 | } 43 | } 44 | 45 | void addTokens(const std::vector& tokenIDs) { 46 | for (const auto& tokenID : tokenIDs) { 47 | for (const auto& atom : getAtomsVector_(tokenID)) { 48 | index_[atom].insert(tokenID); 49 | } 50 | } 51 | } 52 | 53 | std::unordered_set tokensContainingAtom(const Atom atom) const { 54 | const auto resultIterator = index_.find(atom); 55 | return resultIterator != index_.end() ? resultIterator->second : std::unordered_set(); 56 | } 57 | }; 58 | 59 | AtomsIndex::AtomsIndex(const GetAtomsVectorFunc& getAtomsVector) 60 | : implementation_(std::make_shared(getAtomsVector)) {} 61 | 62 | void AtomsIndex::removeTokens(const std::vector& tokenIDs) { implementation_->removeTokens(tokenIDs); } 63 | 64 | void AtomsIndex::addTokens(const std::vector& tokenIDs) { implementation_->addTokens(tokenIDs); } 65 | 66 | std::unordered_set AtomsIndex::tokensContainingAtom(const Atom atom) const { 67 | return implementation_->tokensContainingAtom(atom); 68 | } 69 | } // namespace SetReplace 70 | -------------------------------------------------------------------------------- /libSetReplace/AtomsIndex.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LIBSETREPLACE_ATOMSINDEX_HPP_ 2 | #define LIBSETREPLACE_ATOMSINDEX_HPP_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "IDTypes.hpp" 10 | 11 | namespace SetReplace { 12 | /** @brief AtomsIndex keeps references to tokens accessible by atoms, which is useful for matching. 13 | */ 14 | class AtomsIndex { 15 | public: 16 | /** @brief Creates an empty index. 17 | * @param getAtomsVector datasource function that returns the list of atoms for a requested token. 18 | */ 19 | explicit AtomsIndex(const GetAtomsVectorFunc& getAtomsVector); 20 | 21 | /** @brief Removes tokens with specified IDs from the index. 22 | */ 23 | void removeTokens(const std::vector& tokenIDs); 24 | 25 | /** @brief Adds tokens with specified IDs to the index. 26 | */ 27 | void addTokens(const std::vector& tokenIDs); 28 | 29 | /** @brief Returns the list of tokens containing a specified atom. 30 | */ 31 | std::unordered_set tokensContainingAtom(Atom atom) const; 32 | 33 | private: 34 | class Implementation; 35 | std::shared_ptr implementation_; 36 | }; 37 | } // namespace SetReplace 38 | 39 | #endif // LIBSETREPLACE_ATOMSINDEX_HPP_ 40 | -------------------------------------------------------------------------------- /libSetReplace/IDTypes.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LIBSETREPLACE_IDTYPES_HPP_ 2 | #define LIBSETREPLACE_IDTYPES_HPP_ 3 | 4 | #include 5 | #include 6 | 7 | namespace SetReplace { 8 | /** @brief Identifiers for tokens, which are the elements of the multiset in the multiset system, and contain ordered 9 | * sequences of atoms, e.g., hyperedges in the hypergraph system. 10 | */ 11 | using TokenID = int64_t; 12 | 13 | /** @brief Identifiers for atoms, which are the elements of tokens, e.g., vertices in the hypergraph in the hypergraph 14 | * system. 15 | * @details Positive IDs refer to specific atoms, negative IDs refer to patterns (as, for instance, can be used in the 16 | * rules). 17 | */ 18 | using Atom = int64_t; 19 | 20 | /** @brief List of atoms without references to events, as can be used in, e.g., rule specification. Corresponds to 21 | * contents of tokens in the hypergraph system. 22 | */ 23 | using AtomsVector = std::vector; 24 | 25 | /** @brief Function type used to get a token's corresponding AtomsVector. 26 | */ 27 | using GetAtomsVectorFunc = std::function; 28 | 29 | /** @brief Identifiers for rules, which stay the same for the entire evolution of the system. 30 | */ 31 | using RuleID = int; 32 | constexpr RuleID initialConditionRule = -1; 33 | 34 | /** @brief Identifiers for substitution events, later events have larger IDs. 35 | */ 36 | using EventID = int64_t; 37 | constexpr EventID initialConditionEvent = 0; 38 | 39 | /** @brief Layer this token belongs to in the causal graph. 40 | * @details Specifically, if the largest generation of tokens in the event inputs is n, the generation of its 41 | * outputs will be n + 1. 42 | */ 43 | using Generation = int64_t; 44 | constexpr Generation initialGeneration = 0; 45 | } // namespace SetReplace 46 | 47 | #endif // LIBSETREPLACE_IDTYPES_HPP_ 48 | -------------------------------------------------------------------------------- /libSetReplace/Parallelism.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LIBSETREPLACE_PARALLELISM_HPP_ 2 | #define LIBSETREPLACE_PARALLELISM_HPP_ 3 | 4 | #include 5 | 6 | namespace SetReplace::Parallelism { 7 | /** @brief The type of hardware that can be parallelized. 8 | */ 9 | enum class HardwareType { 10 | /** @brief The main CPU (accessible through standard header). 11 | */ 12 | StdCpu 13 | }; 14 | 15 | /** @brief RAII thread acquisition manager. 16 | * @details On construction, the given number of threads of the given hardware type will be reserved for use. On 17 | * destruction, the threads will be released. This class is thread-safe. 18 | */ 19 | class ThreadAcquisitionToken { 20 | public: 21 | ThreadAcquisitionToken(const HardwareType& type, const int& requestedNumThreads); 22 | 23 | /** @brief Returns the number of threads successfully reserved. 24 | */ 25 | [[nodiscard]] int numThreads() const noexcept; 26 | 27 | private: 28 | class Implementation; 29 | std::shared_ptr implementation_; 30 | }; 31 | 32 | using ThreadAcquisitionTokenPtr = std::shared_ptr; 33 | 34 | /** @brief Returns a RAII token for reserving the given number of threads for the given hardware type. 35 | */ 36 | inline ThreadAcquisitionTokenPtr acquire(const HardwareType& type, const int& requestedNumThreads) { 37 | return std::make_shared(type, requestedNumThreads); 38 | } 39 | 40 | /** @brief Returns whether the hardware type can be parallelized. 41 | */ 42 | bool isAvailable(const HardwareType& type); 43 | 44 | #ifdef LIBSETREPLACE_BUILD_TESTING 45 | namespace Testing { 46 | void overrideNumHardwareThreads(const HardwareType& type, const int& numThreads); 47 | } 48 | #endif 49 | } // namespace SetReplace::Parallelism 50 | 51 | #endif // LIBSETREPLACE_PARALLELISM_HPP_ 52 | -------------------------------------------------------------------------------- /libSetReplace/Rule.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LIBSETREPLACE_RULE_HPP_ 2 | #define LIBSETREPLACE_RULE_HPP_ 3 | 4 | #include 5 | 6 | #include "AtomsIndex.hpp" 7 | 8 | namespace SetReplace { 9 | /** @brief What kind of token types the rule should match. 10 | */ 11 | enum class EventSelectionFunction { 12 | All = 0, // match all events matching the input pattern 13 | Spacelike = 1 // only match spacelike groups of events 14 | }; 15 | 16 | /** @brief Substitution rule used in the evolution. 17 | */ 18 | struct Rule { 19 | const std::vector inputs; 20 | const std::vector outputs; 21 | const EventSelectionFunction eventSelectionFunction; 22 | }; 23 | } // namespace SetReplace 24 | 25 | #endif // LIBSETREPLACE_RULE_HPP_ 26 | -------------------------------------------------------------------------------- /libSetReplace/WolframHeaders/dllexport.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | 3 | Mathematica source file 4 | 5 | Copyright 1986 through 2015 by Wolfram Research Inc. 6 | 7 | This material contains trade secrets and may be registered with the 8 | U.S. Copyright Office as an unpublished work, pursuant to Title 17, 9 | U.S. Code, Section 408. Unauthorized copying, adaptation, distribution 10 | or display is prohibited. 11 | 12 | $Id$ 13 | 14 | *************************************************************************/ 15 | 16 | #ifndef DLL_EXPORT_H 17 | #define DLL_EXPORT_H 18 | 19 | /* Define DLL symbol export for LibraryLink etc */ 20 | 21 | #ifdef CONFIG_ENABLE_CUDA 22 | 23 | #define DLLEXPORT 24 | #define DLLIMPORT 25 | 26 | #elif defined(_WIN32) || defined(_WIN64) 27 | 28 | #define DLLEXPORT __declspec(dllexport) 29 | #define DLLIMPORT __declspec(dllimport) 30 | 31 | #else 32 | 33 | #define DLLEXPORT __attribute__((__visibility__("default"))) 34 | #define DLLIMPORT 35 | 36 | #endif 37 | 38 | /* Definition for the Runtime Library */ 39 | 40 | #if defined(MRTL_DYNAMIC_EXPORT) 41 | 42 | #define RTL_DLL_EXPORT DLLEXPORT 43 | 44 | #elif defined(MATHDLL_EXPORTS) 45 | 46 | #define RTL_DLL_EXPORT DLLIMPORT 47 | 48 | #else 49 | 50 | #define RTL_DLL_EXPORT 51 | 52 | #endif 53 | 54 | #endif /* DLL_EXPORT_H */ 55 | 56 | -------------------------------------------------------------------------------- /libSetReplace/WolframHeaders/extern.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | 3 | Mathematica source file 4 | 5 | Copyright 1986 through 2015 by Wolfram Research Inc. 6 | 7 | This material contains trade secrets and may be registered with the 8 | U.S. Copyright Office as an unpublished work, pursuant to Title 17, 9 | U.S. Code, Section 408. Unauthorized copying, adaptation, distribution 10 | or display is prohibited. 11 | 12 | $Id$ 13 | 14 | *************************************************************************/ 15 | 16 | #ifndef EXTERN_H 17 | #define EXTERN_H 18 | 19 | #ifndef EXTERN_C 20 | #ifdef __cplusplus 21 | #define EXTERN_C extern "C" 22 | #else 23 | #define EXTERN_C extern 24 | #endif 25 | #endif 26 | 27 | #endif /* EXTERN_H */ 28 | 29 | -------------------------------------------------------------------------------- /libSetReplace/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(_link_libraries SetReplace ${GTEST_LIBRARIES}) 2 | 3 | add_executable(Parallelism_test Parallelism_tests.cpp) 4 | add_executable(HypergraphSubstitutionSystem_test HypergraphSubstitutionSystem_test.cpp) 5 | add_executable(profile_tests profile_tests.cpp) 6 | 7 | target_link_libraries(Parallelism_test ${_link_libraries}) 8 | target_link_libraries(HypergraphSubstitutionSystem_test ${_link_libraries}) 9 | target_link_libraries(profile_tests ${_link_libraries}) 10 | 11 | gtest_discover_tests(Parallelism_test HypergraphSubstitutionSystem_test profile_tests) 12 | -------------------------------------------------------------------------------- /libSetReplaceTest.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | if [ "$(uname)" = "Darwin" ]; then 5 | testBinaries=$(find build/libSetReplace/test -type f -perm +111 -print) 6 | elif [ "$(uname)" = "Linux" ]; then 7 | testBinaries=$(find build/libSetReplace/test -type f -executable -print) 8 | else 9 | echo "Operating System not supported." 10 | exit 1 11 | fi 12 | 13 | if [ -z "$testBinaries" ]; then 14 | echo "No tests found." 15 | echo "Build libSetReplace tests first:" 16 | echo " mkdir build && cd build" 17 | echo " cmake .. -DSET_REPLACE_BUILD_TESTING=ON" 18 | echo " cmake --build ." 19 | echo " cd .." 20 | exit 1 21 | fi 22 | 23 | libSetReplaceTestsDir=TestResults/libSetReplace 24 | 25 | mkdir -p TestResults 26 | 27 | exitStatus=0 28 | isFirstTest=1 29 | for testBinary in $testBinaries; do 30 | if [ $isFirstTest -eq 0 ]; then 31 | echo 32 | fi 33 | isFirstTest=0 34 | testBasename=$(basename "$testBinary") 35 | echo "$testBasename..." 36 | if ! eval "$testBinary" --gtest_output=xml:"$libSetReplaceTestsDir"/"$testBasename".xml; then 37 | exitStatus=1 38 | fi 39 | done 40 | exit $exitStatus 41 | -------------------------------------------------------------------------------- /pack.wls: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env wolframscript 2 | 3 | Check[ 4 | Get[FileNameJoin[{DirectoryName[$InputFileName], "DevUtils", "init.m"}]]; 5 | Off[General::stop]; 6 | , 7 | Print["Message occurred during loading of DevUtils. Pack failed."]; 8 | Exit[1]; 9 | ]; 10 | 11 | Check[ 12 | InstallGitLink[]; 13 | 14 | buildResult = BuildLibSetReplace["Verbose" -> True]; 15 | If[!AssociationQ[buildResult], Exit[1]]; 16 | 17 | packResult = PackSetReplace["Verbose" -> True]; 18 | pacletLocation = packResult["Location"]; 19 | If[!StringQ[pacletLocation], Exit[1]]; 20 | , 21 | Print["Message occurred during packing. Pack failed."]; 22 | Exit[1]; 23 | ]; 24 | 25 | Print["Pack succeeded."]; 26 | Exit[0]; 27 | -------------------------------------------------------------------------------- /scripts/activateWolframScript.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Activation is flaky, try up to 3 times. 4 | n=0 5 | until [[ ${n} -ge 3 ]]; do 6 | ((n++)) 7 | echo "Attempt ${n}..." 8 | 9 | # Run the activation 10 | if wolframscript -authenticate "${WOLFRAM_ID}" "${WOLFRAM_PASSWORD}" && wolframscript -activate; then 11 | echo "Activation succeeded on attempt ${n}." 12 | break 13 | fi 14 | 15 | echo "Activation failed on attempt ${n}. Retrying..." 16 | sleep 5 17 | done 18 | 19 | # If after the loop it's still not activated, fail the build 20 | if [[ ${n} -eq 3 ]]; then 21 | echo "Activation failed after 3 attempts." 22 | exit 1 23 | fi 24 | -------------------------------------------------------------------------------- /scripts/checkLineWidth.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | if [[ $# -ne 2 || ! -f "$1" || ! "$2" =~ ^[0-9]+$ ]]; then 5 | echo "Usage: ./scripts/checkLineWidth.sh filename widthLimit" 6 | exit 1 7 | fi 8 | 9 | filename="$1" 10 | widthLimit="$2" 11 | 12 | grepOutput=$(grep --line-number --color=never --extended-regexp ".{$((widthLimit + 1))}" "$filename" || :) 13 | 14 | if [ -n "$grepOutput" ]; then 15 | echo "$grepOutput" | awk -v filename="$filename" '{print filename ":" $0}' 16 | exit 1 17 | fi 18 | -------------------------------------------------------------------------------- /scripts/git_hooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | stagedFiles=$(git diff --name-only --cached) 4 | 5 | for file in $stagedFiles; do 6 | ./lint.sh -f -i "$file" 7 | git add "$file" 8 | done 9 | -------------------------------------------------------------------------------- /scripts/git_hooks/pre-push: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if ! ./lint.sh; then 4 | echo "Linter errors need to be fixed before pushing." 5 | exit 1 6 | fi 7 | 8 | exit 0 9 | -------------------------------------------------------------------------------- /scripts/install_git_hooks.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Adapted from https://stackoverflow.com/a/3464399 3 | set -eo pipefail 4 | 5 | hookNames=$(find scripts/git_hooks -type f -exec basename {} \; | tr '\n' ' ') 6 | 7 | if [[ -n "$1" ]]; then 8 | if test -e "scripts/git_hooks/$1"; then 9 | hookNames="$1" 10 | else 11 | echo "The argument must be one of: $hookNames" 12 | exit 1 13 | fi 14 | fi 15 | 16 | repoRoot=$(git rev-parse --show-toplevel) 17 | hookDir=$repoRoot/.git/hooks 18 | 19 | for hook in $hookNames; do 20 | # If the hook already exists and is not a symlink, move it out of the way 21 | if [[ -e $hookDir/$hook && ! -L $hookDir/$hook ]]; then 22 | echo "Moving an existing hook $hookDir/$hook to $hookDir/$hook.local" 23 | mv "$hookDir"/"$hook" "$hookDir"/"$hook".local 24 | fi 25 | # create the symlink, overwriting the file if it exists 26 | echo "Symlinking $repoRoot/scripts/git_hooks/$hook to $hookDir/$hook" 27 | ln -s -f "$repoRoot"/scripts/git_hooks/"$hook" "$hookDir"/"$hook" 28 | done 29 | -------------------------------------------------------------------------------- /scripts/version.wl: -------------------------------------------------------------------------------- 1 | <| 2 | "Checkpoint" -> "58de7583018f3688e4f94cdd3bac1500df95f9df" 3 | |> 4 | -------------------------------------------------------------------------------- /scripts/whitespaceFormat.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | formatInPlace=0 5 | 6 | for arg in "$@"; do 7 | case $arg in 8 | -i) 9 | formatInPlace=1 10 | shift 11 | ;; 12 | *) 13 | break 14 | ;; 15 | esac 16 | done 17 | 18 | if [[ $# -ne 1 || ! -f "$1" ]]; then 19 | echo "Usage: ./scripts/whitespaceFormat.sh [-i] filename" 20 | exit 1 21 | fi 22 | 23 | filename="$1" 24 | 25 | formatted=$( 26 | expand -t 2 "$filename" | # Tabs to spaces 27 | sed "s/\r$//" | # Use Unix-style end of lines 28 | sed -E "s/[[:space:]]+$//" | # Remove trailing spaces 29 | awk '/./ {e = 0} /^$/ {e += 1} e <= 1' # Remove repeated empty lines 30 | ) 31 | 32 | if [ "$formatInPlace" -eq 1 ]; then 33 | echo "$formatted" >"$filename" 34 | else 35 | echo "$formatted" 36 | fi 37 | --------------------------------------------------------------------------------